Skip to content

Commit 8c26cf2

Browse files
fix: handle ad_break_id key in the ad Summary event
1 parent 2a3a225 commit 8c26cf2

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

media/src/main/java/com/mparticle/media/MediaSession.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class MediaSession protected constructor(builder: Builder) {
7878

7979
private var adContent: MediaAd? = null
8080
private var segment: MediaSegment? = null
81+
private var mediaAdBreak: MediaAdBreak? = null
8182

8283
var mediaSessionStartTimestamp: Long //Timestamp created on logMediaSessionStart event
8384
private set
@@ -283,6 +284,7 @@ class MediaSession protected constructor(builder: Builder) {
283284
val adBreakEvent = MediaEvent(this, MediaEventName.AD_BREAK_START, options = options).apply {
284285
this.adBreak = adBreak
285286
}
287+
mediaAdBreak = adBreak
286288
logEvent(adBreakEvent)
287289
}
288290

@@ -337,6 +339,9 @@ class MediaSession protected constructor(builder: Builder) {
337339
mediaTotalAdTimeSpent += ((endTime - startTime) / 1000)
338340
}
339341
val adEndEvent = MediaEvent(this, MediaEventName.AD_END, options = options)
342+
mediaAdBreak?.let {
343+
adContent?.adBreakId = it.id
344+
}
340345
logEvent(adEndEvent)
341346

342347
logAdSummary(adContent)
@@ -590,6 +595,9 @@ class MediaSession protected constructor(builder: Builder) {
590595
ad.title?.let {
591596
customAttributes[adContentTitleKey] = it
592597
}
598+
ad.adBreakId?.let {
599+
customAttributes[adBreakIdKey] = it
600+
}
593601
customAttributes[adContentSkippedKey] = ad.adSkipped.toString()
594602
customAttributes[adContentCompletedKey] = ad.adCompleted.toString()
595603

media/src/main/java/com/mparticle/media/events/MediaAd.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ class MediaAd(
1919
internal var adStartTimestamp: Long? = null,
2020
internal var adEndTimestamp: Long? = null,
2121
internal var adSkipped: Boolean = false,
22-
internal var adCompleted: Boolean = false
22+
internal var adCompleted: Boolean = false,
23+
internal var adBreakId: String? = null
2324
)

media/src/main/java/com/mparticle/media/events/MediaEvent.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ open class MediaEvent(
176176
adBreak?.apply {
177177
json.put(
178178
"adBreak", JSONObject()
179+
.put("id",id)
179180
.put("title", title)
180181
.put("duration", duration)
181182
)

0 commit comments

Comments
 (0)