diff --git a/spec/vast_tracker.spec.js b/spec/vast_tracker.spec.js index 71b3bdc3..eadf50a0 100644 --- a/spec/vast_tracker.spec.js +++ b/spec/vast_tracker.spec.js @@ -61,6 +61,17 @@ describe('VASTTracker', function () { ); }); + it('should set default ADTYPE macro to video when adType is not set', () => { + const adWithoutType = { ...ad, adType: null }; + vastTracker = new VASTTracker(vastClient, adWithoutType, ad.creatives[0]); + vastTracker.trackURLs([{ id: 'valid-url', url: 'http://example.com' }]); + expect(spyTrackUtil).toHaveBeenCalledWith( + ['http://example.com'], + expect.objectContaining({ ADTYPE: 'video' }), + expect.any(Object) + ); + }); + it('should call track with the expected macros if progress is defined', () => { vastTracker.progress = 12; vastTracker.trackURLs([{ id: 'valid-url', url: 'http://example.com' }]); diff --git a/src/vast_tracker.js b/src/vast_tracker.js index 400805cc..6f977821 100644 --- a/src/vast_tracker.js +++ b/src/vast_tracker.js @@ -921,22 +921,20 @@ export class VASTTracker extends EventEmitter { if (this.ad.sequence) { givenMacros['PODSEQUENCE'] = this.ad.sequence; } - if (this.ad.adType) { - givenMacros['ADTYPE'] = this.ad.adType; - } if (this.ad.adServingId) { givenMacros['ADSERVINGID'] = this.ad.adServingId; } if (this.ad.categories && this.ad.categories.length) { givenMacros['ADCATEGORIES'] = this.ad.categories - .map((category) => category.value) - .join(','); + .map((category) => category.value) + .join(','); } if (this.ad.blockedAdCategories && this.ad.blockedAdCategories.length) { givenMacros['BLOCKEDADCATEGORIES'] = this.ad.blockedAdCategories - .map((blockedCategorie) => blockedCategorie.value) - .join(','); + .map((blockedCategorie) => blockedCategorie.value) + .join(','); } + givenMacros['ADTYPE'] = this.ad.adType || 'video'; } util.track(validUrls, givenMacros, options);