Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions spec/vast_tracker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }]);
Expand Down
12 changes: 5 additions & 7 deletions src/vast_tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading