@@ -96,7 +96,7 @@ class NielsenDCRDestination : DestinationPlugin() {
9696 }
9797
9898 override fun screen (payload : ScreenEvent ): BaseEvent {
99- val propertiesMap = payload.properties.toContent().toMap() as Map < String , String >
99+ val propertiesMap = payload.properties.asStringMap()
100100 val name: String = fetchSectionProperty(propertiesMap, payload.name)
101101 val contentAssetId: String = fetchContentAssetId(propertiesMap)
102102 val metadata = JSONObject ()
@@ -135,11 +135,14 @@ class NielsenDCRDestination : DestinationPlugin() {
135135 }
136136
137137 override fun track (payload : TrackEvent ): BaseEvent {
138+ if (! EventVideoEnum .isVideoEvent(payload.event)) {
139+ analytics.log(" Event is not Video" )
140+ return payload
141+ }
138142 val eventEnum = EventVideoEnum [payload.event]
139- val nielsenProperties: Map <String , String > = payload.properties.toContent() as Map <String , String >
140- val nielsenOptions: Map <String , Any > =
141- ((payload.integrations.toContent()[" nielsen-dcr" ])
142- ? : emptyMap<String , String >()) as Map <String , String >
143+ val nielsenProperties: Map <String , String > = payload.properties.asStringMap()
144+ val nielsenOptions: Map <String , String > = ((payload.integrations[" nielsen-dcr" ]
145+ ? : JsonObject (emptyMap())) as JsonObject ).asStringMap()
143146 when (eventEnum) {
144147 EventVideoEnum .PlaybackStarted ,
145148 EventVideoEnum .PlaybackPaused ,
@@ -227,10 +230,10 @@ class NielsenDCRDestination : DestinationPlugin() {
227230 private fun fetchContentAssetId (properties : Map <String , String >): String {
228231 return if (nielsenDCRSettings!! .contentAssetIdPropertyName.isNotEmpty()) {
229232 properties[nielsenDCRSettings!! .contentAssetIdPropertyName]!!
230- } else if (! properties[" assetId" ].isNullOrEmpty ()) {
233+ } else if (( properties[" assetId" ]?.toString() ? : " " ).isNotEmpty ()) {
231234 properties[" assetId" ]!!
232235 } else {
233- properties[" contentAssetId" ]!!
236+ ( properties[" contentAssetId" ]? : " " ).toString()
234237 }
235238 }
236239
@@ -576,7 +579,8 @@ class NielsenDCRDestination : DestinationPlugin() {
576579 // In case of ad `type` preroll, call `loadMetadata` with metadata values for content,
577580 // followed by `loadMetadata` with ad (preroll) metadata
578581 if (properties[" type" ].equals(" pre-roll" )) {
579- val contentMap = (properties[" content" ]? : mapOf<String , String >()) as Map <String , String >
582+ val contentMap = ((payload.properties[" content" ]
583+ ? : JsonObject (emptyMap())) as JsonObject ).asStringMap()
580584 if (contentMap.isNotEmpty()) {
581585 val contentProperties = toCamelCase(contentMap, CONTENT_FORMATTER )
582586 val adContentAsset = buildContentMetadata(contentProperties, nielsenOptions)
@@ -642,6 +646,15 @@ internal enum class EventVideoEnum(
642646 }
643647 throw IllegalArgumentException (" $name is not a valid video event" )
644648 }
649+ /* *
650+ * Identifies if the event is a video event.
651+ *
652+ * @param eventName Event name
653+ * @return `true` if it's a video event, `false` otherwise.
654+ */
655+ fun isVideoEvent (eventName : String ): Boolean {
656+ return names!! .containsKey(eventName)
657+ }
645658 }
646659}
647660/* *
0 commit comments