From 09655cb37e66a80b4135e787a15b5bf57db8f950 Mon Sep 17 00:00:00 2001 From: Guillaume Andouard Date: Sat, 7 Oct 2023 18:06:29 +0200 Subject: [PATCH 1/4] add track once parameter to setProgress --- src/vast_tracker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vast_tracker.js b/src/vast_tracker.js index c6a8a8dc..9f670332 100644 --- a/src/vast_tracker.js +++ b/src/vast_tracker.js @@ -177,7 +177,7 @@ export class VASTTracker extends EventEmitter { * @emits VASTTracker#midpoint * @emits VASTTracker#thirdQuartile */ - setProgress(progress, macros = {}) { + setProgress(progress, macros = {}, trackOnce = true) { // check if progress is a valid time input if (!util.isValidTimeValue(progress) || typeof macros !== 'object') { return; @@ -213,7 +213,7 @@ export class VASTTracker extends EventEmitter { this.lastPercentage = percent; } events.forEach((eventName) => { - this.track(eventName, { macros, once: true }); + this.track(eventName, { macros, once: trackOnce }); }); if (progress < this.progress) { From a3c1690c0ebf58204312574075a990af808debab Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 17 Oct 2023 16:30:40 +0200 Subject: [PATCH 2/4] [test] setProgress trackOnce : chekc that trackOnce false is trasmited in the track() call. --- test/vast_tracker.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/vast_tracker.js b/test/vast_tracker.js index db5ad9d0..056d7758 100644 --- a/test/vast_tracker.js +++ b/test/vast_tracker.js @@ -130,6 +130,25 @@ describe('VASTTracker', function () { }); }); + describe('#setProgress trackOnce', () => { + + after(()=> { + this.stub?.restore(); + }) + + it('should send firstQuartile event with trackOnce : false', () => { + this.stub = sinon.stub(this.Tracker, 'track').callsFake((eventName, params) => { + console.log("testprogress : "+eventName); + if(eventName === 'progress-23') { + params.once.should.equal(false); + + } + }); + + this.Tracker.setProgress(23, null, false); + }); + }); + describe('#setMuted', () => { before((done) => { _eventsSent = []; From 1176e3eb2cf19b2244ecb265ae9ef069ea761ab9 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 17 Oct 2023 16:42:49 +0200 Subject: [PATCH 3/4] [docs] add parameter on setProgress doc --- docs/api/vast-tracker.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/api/vast-tracker.md b/docs/api/vast-tracker.md index e708b278..f7d0d85b 100644 --- a/docs/api/vast-tracker.md +++ b/docs/api/vast-tracker.md @@ -496,7 +496,7 @@ vastTracker.on('pause', () => { }); ``` -### setProgress(progress, macros) +### setProgress(progress, macros, trackOnce) Sets the duration of the ad and updates the quartiles based on that. This is required for tracking time related events such as `start`, `firstQuartile`, `midpoint`, `thirdQuartile` or `rewind`. @@ -504,6 +504,7 @@ Sets the duration of the ad and updates the quartiles based on that. This is req - **`progress: Number`** - Current playback time in seconds - **`macros: Object`** - Optional parameter. Object containing macros and their values to be replaced. Macros must be supported by VAST specification. +- **`trackOnce: Boolean`** - Optional parameter. If set to false, quartile events can be triggered again after a 'rewind' situation. #### Events emitted From cd68810e886193fc6eede9e1c75bf9cfab1f7cd5 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 17 Oct 2023 16:30:40 +0200 Subject: [PATCH 4/4] Revert "[test] setProgress trackOnce : chekc that trackOnce false is trasmited in the track() call." This reverts commit a3c1690c0ebf58204312574075a990af808debab. --- test/vast_tracker.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/test/vast_tracker.js b/test/vast_tracker.js index 056d7758..db5ad9d0 100644 --- a/test/vast_tracker.js +++ b/test/vast_tracker.js @@ -130,25 +130,6 @@ describe('VASTTracker', function () { }); }); - describe('#setProgress trackOnce', () => { - - after(()=> { - this.stub?.restore(); - }) - - it('should send firstQuartile event with trackOnce : false', () => { - this.stub = sinon.stub(this.Tracker, 'track').callsFake((eventName, params) => { - console.log("testprogress : "+eventName); - if(eventName === 'progress-23') { - params.once.should.equal(false); - - } - }); - - this.Tracker.setProgress(23, null, false); - }); - }); - describe('#setMuted', () => { before((done) => { _eventsSent = [];