From da9bb48d6d8786f4f99d0676eb28e1902507c298 Mon Sep 17 00:00:00 2001 From: Jeroen Veltmans Date: Tue, 13 Aug 2024 14:08:13 +0200 Subject: [PATCH 1/3] Update package-lock --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 4df815c9..1cb44395 100644 --- a/package-lock.json +++ b/package-lock.json @@ -88,7 +88,7 @@ }, "gemius": { "name": "@theoplayer/gemius-connector-web", - "version": "0.0.1", + "version": "0.1.0", "license": "MIT", "peerDependencies": { "theoplayer": "^7.0.0" From 692162dfdf667011d9cffa095359cd8211f2f574 Mon Sep 17 00:00:00 2001 From: Jeroen Veltmans Date: Tue, 13 Aug 2024 14:56:34 +0200 Subject: [PATCH 2/3] Extract google ima metadata to separate function --- conviva/src/integration/ads/AdReporter.ts | 11 +++++++- conviva/src/utils/Utils.ts | 34 +++++++++++++++++++---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/conviva/src/integration/ads/AdReporter.ts b/conviva/src/integration/ads/AdReporter.ts index 32bbe01a..43cd8697 100644 --- a/conviva/src/integration/ads/AdReporter.ts +++ b/conviva/src/integration/ads/AdReporter.ts @@ -1,6 +1,12 @@ import type { Ad, AdBreak, ChromelessPlayer, GoogleImaAd } from 'theoplayer'; import { type AdAnalytics, Constants, type ConvivaMetadata, type VideoAnalytics } from '@convivainc/conviva-js-coresdk'; -import { calculateAdType, calculateCurrentAdBreakInfo, collectAdMetadata, collectPlayerInfo } from '../../utils/Utils'; +import { + calculateAdType, + calculateCurrentAdBreakInfo, + collectAdMetadata, + collectPlayerInfo, + updateAdMetadataForGoogleIma +} from '../../utils/Utils'; export class AdReporter { private readonly player: ChromelessPlayer; @@ -47,6 +53,9 @@ export class AdReporter { return; } const adMetadata = collectAdMetadata(currentAd); + if (currentAd.integration === 'google-ima') { + updateAdMetadataForGoogleIma(currentAd as GoogleImaAd, adMetadata); + } // Every session ad or content has its session ID. In order to “attach” an ad to its respective content session, // there are two tags that are critical: diff --git a/conviva/src/utils/Utils.ts b/conviva/src/utils/Utils.ts index 99c6b7b5..a1496621 100644 --- a/conviva/src/utils/Utils.ts +++ b/conviva/src/utils/Utils.ts @@ -120,15 +120,39 @@ export function collectVerizonAdMetadata(ad: VerizonMediaAd): ConvivaMetadata { return adMetadata; } +export function updateAdMetadataForGoogleIma(ad: GoogleImaAd, metadata: ConvivaMetadata): ConvivaMetadata { + const adMetadata = metadata; + const streamUrl = ad.mediaUrl; + if (streamUrl) { + adMetadata[Constants.STREAM_URL] = streamUrl; + } + const assetName = ad.title; + if (assetName) { + adMetadata[Constants.ASSET_NAME] = assetName; + adMetadata['c3.ad.creativeName'] = assetName; + } + if (ad.wrapperAdIds[0]) { + adMetadata['c3.ad.firstAdId'] = ad.wrapperAdIds[0]; + } + if (ad.wrapperCreativeIds[0]) { + adMetadata['c3.ad.firstCreativeId'] = ad.wrapperCreativeIds[0]; + } + if (ad.wrapperAdSystems[0]) { + adMetadata['c3.ad.firstAdSystem'] = ad.wrapperAdSystems[0]; + } + + return adMetadata; +} + export function collectAdMetadata(ad: Ad): ConvivaMetadata { const adMetadata: ConvivaMetadata = { [Constants.DURATION]: ad.duration as any }; - const streamUrl = (ad as GoogleImaAd).mediaUrl || ad.resourceURI; + const streamUrl = ad.resourceURI; if (streamUrl) { adMetadata[Constants.STREAM_URL] = streamUrl; } - const assetName = (ad as GoogleImaAd).title || ad.id; + const assetName = ad.id; if (assetName) { adMetadata[Constants.ASSET_NAME] = assetName; } @@ -160,19 +184,19 @@ export function collectAdMetadata(ad: Ad): ConvivaMetadata { // This tag must capture the "first" Ad Id in the wrapper chain when a Linear creative is available or there is // an error at the end of the wrapper chain. Set to "NA" if not available. If there is no wrapper VAST response // then the Ad Id and First Ad Id should be the same. - adMetadata['c3.ad.firstAdId'] = (ad as GoogleImaAd).wrapperAdIds[0] || ad.id || 'NA'; + adMetadata['c3.ad.firstAdId'] = ad.id || 'NA'; // [Preferred] Only valid for wrapper VAST responses. // This tag must capture the "first" Creative Id in the wrapper chain when a Linear creative is available or // there is an error at the end of the wrapper chain. Set to "NA" if not available. If there is no wrapper // VAST response then the Ad Creative Id and First Ad Creative Id should be the same. - adMetadata['c3.ad.firstCreativeId'] = (ad as GoogleImaAd).wrapperCreativeIds[0] || ad.creativeId || 'NA'; + adMetadata['c3.ad.firstCreativeId'] = ad.creativeId || 'NA'; // [Preferred] Only valid for wrapper VAST responses. This tag must capture the "first" Ad System in the wrapper // chain when a Linear creative is available or there is an error at the end of the wrapper chain. Set to "NA" if // not available. If there is no wrapper VAST response then the Ad System and First Ad System should be the same. // Examples: "GDFP", "NA". - adMetadata['c3.ad.firstAdSystem'] = (ad as GoogleImaAd).wrapperAdSystems[0] || ad.adSystem || 'NA'; + adMetadata['c3.ad.firstAdSystem'] = ad.adSystem || 'NA'; // The name of the Ad Stitcher. If not using an Ad Stitcher, set to "NA" adMetadata['c3.ad.adStitcher'] = 'NA'; From 4bb94204f4a7a34095bb261ad161e903163c58e6 Mon Sep 17 00:00:00 2001 From: Jeroen Veltmans Date: Tue, 13 Aug 2024 15:02:49 +0200 Subject: [PATCH 3/3] Add changeset --- .changeset/clean-zoos-know.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/clean-zoos-know.md diff --git a/.changeset/clean-zoos-know.md b/.changeset/clean-zoos-know.md new file mode 100644 index 00000000..0e09f911 --- /dev/null +++ b/.changeset/clean-zoos-know.md @@ -0,0 +1,5 @@ +--- +"@theoplayer/conviva-connector-web": patch +--- + +Fixed an issue where we could throw an error for non Google-IMA ads.