@newrelic/video-core 3.2.0-beta-0 → 3.2.0-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ (()=>{"use strict";var e={51:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{}i.AdPositions={PRE:"pre",MID:"mid",POST:"post"},i.INTERVAL=1e4,i.MAX_EVENTS_PER_BATCH=1e3,i.MAX_PAYLOAD_SIZE=1,i.MAX_BEACON_SIZE=.0625,i.MAX_EVENT_SIZE=.0625,i.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],i.COLLECTOR={US:"bam-cell.nr-data.net",EU:"bam.eu01.nr-data.net",Stage:"staging-bam-cell.nr-data.net",GOV:"gov-bam.nr-data.net"},t.default=i},144:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{static error(...e){s(e,i.Levels.ERROR,"darkred")}static warn(...e){s(e,i.Levels.WARNING,"darkorange")}static notice(...e){s([].slice.call(arguments),i.Levels.NOTICE,"darkcyan")}static debug(...e){s(e,i.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(e,t,s){try{if(i.level<=i.Levels.DEBUG){s=s||function(e){i.debug("Event: "+e.type)};var n=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];t&&(null===t[0]?(t.shift(),n=t):n=n.concat(t));for(var r=0;r<n.length;r++)"function"==typeof e?e.call(window,n[r],s):e.on?e.on(n[r],s):e.addEventListener?e.addEventListener(n[r],s):e.addEventHandler?e.addEventHandler(n[r],s):i.warn("debugCommonVideoEvents: No common listener function found for ",e)}}catch(e){i.warn(e)}}}function s(e,t,s){t=t||i.Levels.NOTICE,s=s||"darkcyan";var a,o,d=i.prefix;i.includeTime&&(d+="["+("0"+(a=new Date).getDate()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)+":"+("0"+a.getSeconds()).slice(-2)+"."+("00"+a.getMilliseconds()).slice(-3)+"] "),d+=function(e){return r[e]}(t)+":",i.level<=t&&t!==i.Levels.SILENT&&(!i.colorful||"undefined"!=typeof document&&document.documentMode?n(e,d):(o=t===i.Levels.ERROR&&console.error?console.error:t===i.Levels.WARNING&&console.warn?console.warn:t===i.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,d="%c"+d,e.splice(0,0,d,"color: "+s),o.apply(console,e)))}function n(e,t){if(e instanceof Array)for(var i in e)n(e[i],t);else"string"==typeof e?console.log(t+" "+e):(console.log(t+"↵"),console.log(e))}i.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},i.level=i.Levels.ERROR,i.colorful=!0,i.includeTime=!0,i.prefix="[nrvideo]";const r={4:"e",3:"w",2:"n",1:"d"};!function(){if("undefined"!=typeof window&&window.location&&window.location.search){var e=/\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);null!==e&&("true"===e[1]?i.level=i.Levels.ALL:i.level=e[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(i.colorful=!1)}}(),t.default=i},302:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(i(330)),n=o(i(568)),r=o(i(455)),a=o(i(51));function o(e){return e&&e.__esModule?e:{default:e}}class d extends n.default{constructor(e){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new r.default,this._trackerReadyChrono.start(),this._actionTable=a.default.ACTION_TABLE,this._actionAdTable=a.default.ACTION_AD_TABLE,e=e||{},this.setOptions(e)}setOptions(e){e&&(e.parentTracker&&(this.parentTracker=e.parentTracker),e.customData&&(this.customData=e.customData),e.heartbeat&&(this.heartbeat=e.heartbeat))}dispose(){this.unregisterListeners()}registerListeners(){}unregisterListeners(){}getHeartbeat(){return this.state._isAd?2e3:this.heartbeat?this.heartbeat:this.parentTracker&&this.parentTracker.heartbeat?this.parentTracker.heartbeat:3e4}startHeartbeat(){this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),Math.max(this.getHeartbeat(),2e3))}stopHeartbeat(){this._heartbeatInterval&&clearInterval(this._heartbeatInterval)}sendHeartbeat(e){this.sendVideoAction(d.Events.HEARTBEAT,e)}getAttributes(e,t){(e=e||{}).trackerName=this.getTrackerName(),e.trackerVersion=this.getTrackerVersion(),e.coreVersion=s.default.version,e.timeSinceTrackerReady=this._trackerReadyChrono.getDeltaTime();for(let t in this.customData)e[t]=this.customData[t];return null!=document.hidden&&(e.isBackgroundEvent=document.hidden),e}getTrackerVersion(){return s.default.version}getTrackerName(){return"base-tracker"}sendVideoAction(e,t){this.emit("VideoAction",e,this.getAttributes(t))}sendVideoAdAction(e,t){this.emit("VideoAdAction",e,this.getAttributes(t))}sendVideoErrorAction(e,t){let i=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",e,this.getAttributes(t,i))}sendVideoCustomAction(e,t){this.emit("VideoCustomAction",e,this.getAttributes(t,"customAction"))}}d.Events={HEARTBEAT:"HEARTBEAT"},t.default=d},324:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NRVideoHarvester=void 0;var s=a(i(51)),n=a(i(330)),r=i(347);function a(e){return e&&e.__esModule?e:{default:e}}const{INTERVAL:o,MAX_EVENTS_PER_BATCH:d,MAX_PAYLOAD_SIZE:l,MAX_BEACON_SIZE:h}=s.default;t.NRVideoHarvester=class{#e=!1;#t;#i=null;constructor(e){this.#t=e,window.addEventListener("pagehide",(()=>this.triggerHarvest({isFinalHarvest:!0})))}startTimer(){if(this.#e)return;this.#e=!0;const e=()=>{this.triggerHarvest({}),this.#e&&(this.#i=setTimeout(e,o))};this.#i=setTimeout(e,o)}stopTimer(){this.#e=!1,this.#i&&(clearTimeout(this.#i),this.#i=null)}triggerHarvest(e={}){if(!this.#t.isEmpty())try{const t=this.#t.drain(),i=e.isFinalHarvest?h:l,s=this.chunkEvents(t,i);s.forEach(((t,i)=>{const n=i===s.length-1;this.sendChunk(t,e,n)}))}catch(e){console.error("Error during harvest:",e)}}chunkEvents(e,t){const i=[];let s=[];for(const n of e)if(s.length>=d&&(i.push(s),s=[]),s.push(n),(0,r.getPayloadSize)({ins:s})>t){const e=s.pop();s.length>0&&i.push(s),s=[e]}return s.length>0&&i.push(s),i}sendChunk(e,t,i){const s=this.#s();if(!s)return void this.#t.postHarvestCleanup({retry:!1,status:0});const n={body:{ins:e}};(0,r.callApi)({url:s,payload:n,options:t},(t=>{t.retry&&(t.chunk=e),this.#t.postHarvestCleanup(t)}))}#s(){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");const{beacon:e,licenseKey:t,applicationID:i,sa:s}=window.NRVIDEO.info;if(!e||!t||!i)throw new Error("Options object provided by New Relic is not correctly initialized");return`https://${e}/ins/1/${t}?a=${i}&v=${n.default.version}&ref=${window.location.href}&ca=VA`}catch(e){return console.error(e.message),null}}}},328:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(455)),n=r(i(144));function r(e){return e&&e.__esModule?e:{default:e}}t.default=class{constructor(){this.reset(),this._createdAt=Date.now(),this._hb=!0,this._acc=0,this._bufferAcc=0}reset(){this._viewSession=null,this._viewCount=0,this._isAd=!1,this.numberOfErrors=0,this.numberOfAds=0,this.numberOfVideos=0,this.totalPlaytime=0,this.totalAdPlaytime=0,this.isAdBreak=!1,this.initialBufferingHappened=!1,this.resetFlags(),this.resetChronos()}resetFlags(){this.isPlayerReady=!1,this.isRequested=!1,this.isStarted=!1,this.isPaused=!1,this.isSeeking=!1,this.isBuffering=!1,this.isPlaying=!1}resetChronos(){this.timeSinceRequested=new s.default,this.timeSinceStarted=new s.default,this.timeSincePaused=new s.default,this.timeSinceSeekBegin=new s.default,this.timeSinceBufferBegin=new s.default,this.timeSinceAdBreakStart=new s.default,this.timeSinceLastDownload=new s.default,this.timeSinceLastHeartbeat=new s.default,this.timeSinceLastRenditionChange=new s.default,this.timeSinceLastAdQuartile=new s.default,this.timeSinceLastAd=new s.default,this.timeSinceResumed=new s.default,this.timeSinceSeekEnd=new s.default,this.playtimeSinceLastEvent=new s.default,this.customTimeSinceAttributes={},this.elapsedTime=new s.default,this.bufferElapsedTime=new s.default}isAd(){return this._isAd}setIsAd(e){this._isAd=e}setTimeSinceAttribute(e){this.customTimeSinceAttributes[e]=new s.default,this.customTimeSinceAttributes[e].start()}removeTimeSinceAttribute(e){delete this.customTimeSinceAttributes[e]}getViewSession(){if(!this._viewSession){let e=(new Date).getTime(),t=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this._viewSession=e+"-"+t}return this._viewSession}getViewId(){return this.getViewSession()+"-"+this._viewCount}getStateAttributes(e){e=e||{},this.isAd()?(this.isRequested&&(e.timeSinceAdRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastAdHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceAdStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSinceAdPaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceAdBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceAdSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),this.isAdBreak&&(e.timeSinceAdBreakBegin=this.timeSinceAdBreakStart.getDeltaTime()),e.numberOfAds=this.numberOfAds):(this.isRequested&&(e.timeSinceRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSincePaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),e.timeSinceLastAd=this.timeSinceLastAd.getDeltaTime(),e.numberOfVideos=this.numberOfVideos),e.numberOfErrors=this.numberOfErrors,this.isAd()||(this.playtimeSinceLastEvent.startTime>0?e.playtimeSinceLastEvent=this.playtimeSinceLastEvent.getDeltaTime():e.playtimeSinceLastEvent=0,this.isPlaying?this.playtimeSinceLastEvent.start():this.playtimeSinceLastEvent.reset(),this.totalPlaytime+=e.playtimeSinceLastEvent,e.totalPlaytime=this.totalPlaytime);for(const[t,i]of Object.entries(this.customTimeSinceAttributes))e[t]=i.getDeltaTime();return e}calculateBufferType(e){let t="";return t=e?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",n.default.debug("Buffer Type = "+t),t}goViewCountUp(){this._viewCount++}goPlayerReady(){return!this.isPlayerReady&&(this.isPlayerReady=!0,!0)}goRequest(){return!this.isRequested&&(this.isRequested=!0,this.timeSinceLastAd.reset(),this.timeSinceRequested.start(),!0)}goStart(){return!(!this.isRequested||this.isStarted||(this.isAd()?this.numberOfAds++:this.numberOfVideos++,this.isStarted=!0,this.isPlaying=!0,this.timeSinceStarted.start(),this.playtimeSinceLastEvent.start(),0))}goEnd(){return!!this.isRequested&&(this.numberOfErrors=0,this.resetFlags(),this.timeSinceRequested.stop(),this.timeSinceStarted.stop(),this.playtimeSinceLastEvent.stop(),!0)}goPause(){return!(!this.isStarted||this.isPaused||(this.isPaused=!0,this.isPlaying=!1,this.timeSincePaused.start(),this.playtimeSinceLastEvent.stop(),this.timeSinceResumed.reset(),this.isBuffering&&(this._bufferAcc+=this.bufferElapsedTime.getDeltaTime()),this.elapsedTime.start(),0))}goResume(){return!(!this.isStarted||!this.isPaused||(this.isPaused=!1,this.isPlaying=!0,this.timeSincePaused.stop(),this.timeSinceResumed.start(),this._hb?(this._acc=this.elapsedTime.getDeltaTime(),this._hb=!1):(this.isBuffering&&this.bufferElapsedTime.start(),this._acc+=this.elapsedTime.getDeltaTime()),0))}goBufferStart(){return!(!this.isRequested||this.isBuffering||(this.isBuffering=!0,this.isPlaying=!1,this.timeSinceBufferBegin.start(),this.bufferElapsedTime.start(),0))}goBufferEnd(){return!(!this.isRequested||!this.isBuffering||(this.isBuffering=!1,this.isPlaying=!0,this.timeSinceBufferBegin.stop(),this._hb?(this._bufferAcc=this.bufferElapsedTime.getDeltaTime(),this._hb=!1):this._bufferAcc+=this.bufferElapsedTime.getDeltaTime(),0))}goSeekStart(){return!(!this.isStarted||this.isSeeking||(this.isSeeking=!0,this.isPlaying=!1,this.timeSinceSeekBegin.start(),this.timeSinceSeekEnd.reset(),0))}goSeekEnd(){return!(!this.isStarted||!this.isSeeking||(this.isSeeking=!1,this.isPlaying=!0,this.timeSinceSeekBegin.stop(),this.timeSinceSeekEnd.start(),0))}goAdBreakStart(){return!this.isAdBreak&&(this.isAdBreak=!0,this.timeSinceAdBreakStart.start(),!0)}goAdBreakEnd(){return!!this.isAdBreak&&(this.isRequested=!1,this.isAdBreak=!1,this.totalAdPlaytime=this.timeSinceAdBreakStart.getDeltaTime(),this.timeSinceAdBreakStart.stop(),!0)}goDownload(){this.timeSinceLastDownload.start()}goHeartbeat(){this.timeSinceLastHeartbeat.start()}goRenditionChange(){this.timeSinceLastRenditionChange.start()}goAdQuartile(){this.timeSinceLastAdQuartile.start()}goError(){this.isError=!0,this.numberOfErrors++}goLastAd(){this.timeSinceLastAd.start()}}},330:e=>{e.exports=JSON.parse('{"name":"@newrelic/video-core","version":"3.2.0-beta-1","description":"New Relic video tracking core library","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","scripts":{"build":"webpack --mode production","build:dev":"webpack --mode development","watch":"webpack --mode production --progress --color --watch","watch:dev":"webpack --progress --color --watch","clean":"rm -rf dist coverage doc","test":"nyc --reporter=html --reporter=text mocha --require @babel/register","doc":"jsdoc -c jsdoc.json -d documentation","deploy":"node scripts/deploy.js","third-party-updates":"oss third-party manifest --includeOptDeps && oss third-party notices --includeOptDeps && git add THIRD_PARTY_NOTICES.md third_party_manifest.json"},"repository":{"type":"git","url":"https://github.com/newrelic/video-core-js"},"author":"Jordi Aguilar","contributors":["Andreu Santarén Llop"],"license":"Apache-2.0","devDependencies":{"@babel/core":"^7.24.5","@babel/plugin-transform-modules-commonjs":"^7.24.1","@babel/preset-env":"^7.24.5","@babel/register":"^7.24.6","@newrelic/newrelic-oss-cli":"^0.1.2","aws-sdk":"^2.920.0","babel-loader":"^9.1.3","chai":"^4.3.4","diff":"^5.0.0","jsdom":"^25.0.1","mocha":"^10.4.0","nyc":"^15.1.0","sinon":"^2.4.1","webpack":"^5.91.0","webpack-cli":"^4.9.2"},"files":["THIRD_PARTY_NOTICES.md","dist","src","CHANGELOG.md","LICENSE","README.md","!test"],"publishConfig":{"access":"public"}}')},347:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.callApi=function({url:e,payload:t,options:i={}},s){if(!e||!t||!s)return console.error("callApi: Missing required parameters"),void(s&&s({retry:!1,status:0}));let n;try{n=JSON.stringify(t.body)}catch(e){return console.error("callApi: Error serializing payload",e),void s({retry:!1,status:0})}if(i.isFinalHarvest&&navigator.sendBeacon)try{const t=navigator.sendBeacon(e,n);s({retry:!t,status:t?200:0})}catch(e){s({retry:!0,status:0})}else fetch(e,{method:"POST",body:n,headers:{"Content-Type":"application/json"},keepalive:i.isFinalHarvest}).then((e=>{const t=function(e){switch(e){case 408:case 429:case 500:return!0;case 401:case 403:case 404:return!1}return e>=502&&e<=504||e>=512&&e<=530}(e.status);s({retry:t,status:e.status,ok:e.ok})})).catch((()=>{s({retry:!0,status:0})}))},t.getPayloadSize=function(e){if(!e||"object"!=typeof e)return 0;try{const t=JSON.stringify(e);return(new TextEncoder).encode(t).length/1048576}catch(e){return console.error("getPayloadSize: Error calculating payload size",e),0}}},399:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,n=(s=i(144))&&s.__esModule?s:{default:s},r=i(449),a=i(418);class o{static addTracker(e,t){(0,a.setAuthConfig)(t.info),e.on&&e.emit?(d.push(e),e.on("*",l),"function"==typeof e.trackerInit&&e.trackerInit()):n.default.error("Tried to load a non-tracker.",e)}static removeTracker(e){e.off("*",l),e.dispose();let t=d.indexOf(e);-1!==t&&d.splice(t,1)}static getTrackers(){return d}static send(e,t,i){i.timeSinceLoad=window.performance.now()/1e3,(0,r.recordEvent)(e,{actionName:t,...i})}static sendError(e){o.send("ERROR",e)}}let d=[];function l(e){let t=function(e){let t={};for(let i in e)null!==e[i]&&void 0!==e[i]&&(t[i]=e[i]);return t}(e.data);n.default.level<=n.default.Levels.DEBUG?n.default.notice("Sent",e.type,t):n.default.notice("Sent",e.type),o.send(e.eventType,e.type,t)}t.default=o},418:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setAuthConfig=function(e){try{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("setAuthConfig: info parameter must be a valid object");if(function(e){if(!e||"object"!=typeof e)return!1;const{licenseKey:t,appName:i,region:s,applicationID:n,beacon:r}=e;return!(!t||"string"!=typeof t||0===t.trim().length)&&(n?!!(r&&"string"==typeof r&&r.trim().length>0):!!(i&&"string"==typeof i&&i.trim().length>0&&s&&"string"==typeof s&&s.trim().length>0))}(e)){const{licenseKey:t,appName:i,region:s,beacon:n,sa:a,applicationID:o}=e;window.NRVIDEO=window.NRVIDEO||{};let d=n;if(!d&&s){if(!r[s])throw new Error(`setAuthConfig: Invalid region '${s}'. Valid regions: ${Object.keys(r).join(", ")}`);d=r[s]}return window.NRVIDEO.info={beacon:d,licenseKey:t,applicationID:o||null,appName:i||null,sa:a||0},!0}{const t=function(e){if(!e||"object"!=typeof e)return"info parameter must be a valid object";const{licenseKey:t,appName:i,region:s,applicationID:n,beacon:r}=e;if(!t||"string"!=typeof t||0===t.trim().length)return"licenseKey is required and must be a non-empty string";if(n){if(!r||"string"!=typeof r||0===r.trim().length)return"beacon URL is required when using applicationID"}else{if(!i||"string"!=typeof i||0===i.trim().length)return"appName is required when not using applicationID";if(!s||"string"!=typeof s||0===s.trim().length)return"region is required when not using applicationID"}return"configuration validation failed"}(e);throw new Error(`setAuthConfig: ${t}`)}}catch(e){return console.error("setAuthConfig:",e.message),!1}};var s,n=(s=i(51))&&s.__esModule?s:{default:s};const{COLLECTOR:r}=n.default},431:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NRVideoEventAggregator=void 0;var s,n=i(347),r=(s=i(51))&&s.__esModule?s:{default:s};const{MAX_EVENTS_PER_BATCH:a,MAX_PAYLOAD_SIZE:o}=r.default;t.NRVideoEventAggregator=class{#n=[];#r=[];isEmpty(){return 0===this.#n.length&&0===this.#r.length}drain(){const e=[...this.#r,...this.#n];return this.#n=[],this.#r=[],e}add(e){this.#n.push(e)}postHarvestCleanup(e){if(e.retry&&e.chunk?.length){for(;this.#r.length>0&&((0,n.getPayloadSize)(this.#r)+(0,n.getPayloadSize)(e.chunk)>o||this.#r.length+e.chunk.length>a);)this.#r.shift();this.#r.push(...e.chunk)}else this.#r=[]}}},449:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.recordEvent=function(e,t={}){if("string"!=typeof e||0===e.length||!o.includes(e))return console.warn("recordEvent: Invalid eventType provided:",e),!1;if(null!==t&&("object"!=typeof t||Array.isArray(t)))return console.warn("recordEvent: attributes must be a plain object"),!1;if(t=t||{},!window.NRVIDEO||!window.NRVIDEO.info)return console.error("recordEvent: NRVIDEO not properly initialized"),!1;try{const{appName:i}=window.NRVIDEO.info,s={...t,eventType:e,appName:i,timestamp:Date.now()},a=(0,r.getPayloadSize)(s);return a>d?(console.warn(`recordEvent: Event size (${a} bytes) exceeds maximum (${d} bytes)`),!1):(n.customEventAggregator.add(s),!0)}catch(e){return console.error("recordEvent: Error recording event:",e),!1}};var s,n=i(487),r=i(347),a=(s=i(51))&&s.__esModule?s:{default:s};const{VALID_EVENT_TYPES:o,MAX_EVENT_SIZE:d}=a.default},455:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(){this.reset()}reset(){this.startTime=0,this.stopTime=0,this.offset=0}getDeltaTime(){return this.startTime?this.offset+((new Date).getTime()-this.startTime):null}start(){this.startTime=(new Date).getTime(),this.stopTime=0}stop(){return this.stopTime=(new Date).getTime(),this.getDeltaTime()}clone(){var e=new i;return e.startTime=this.startTime,e.stopTime=this.stopTime,e.offset=this.offset,e}}t.default=i},487:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.customEventAggregator=void 0;var s=i(431),n=i(324);const r=t.customEventAggregator=new s.NRVideoEventAggregator;new n.NRVideoHarvester(r).startTimer()},568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=class{on(e,t){if(this._listeners=this._listeners||{},"function"==typeof t)return this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t),this}off(e,t){if(this._listeners=this._listeners||{},this._listeners[e]){var i=this._listeners[e].indexOf(t);-1!==i&&this._listeners[e].splice(i,1)}return this}emit(e,t,i){return this._listeners=this._listeners||{},i=i||{},Array.isArray(this._listeners[t])&&this._listeners[t].forEach((s=>{s.call(this,{eventType:e,type:t,data:i,target:this})})),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach((s=>{s.call(this,{eventType:e,type:t,data:i,target:this})})),this}}},793:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(i(144)),n=o(i(302)),r=o(i(328)),a=o(i(330));function o(e){return e&&e.__esModule?e:{default:e}}class d extends n.default{constructor(e,t){super(),this.state=new r.default,this.adsTracker=null,this._lastBufferType=null,this._userId=null,t=t||{},this.setOptions(t),e&&this.setPlayer(e,t.tag),s.default.notice("Tracker "+this.getTrackerName()+" v"+this.getTrackerVersion()+" is ready.")}setUserId(e){this._userId=e}setOptions(e){e&&(e.adsTracker&&this.setAdsTracker(e.adsTracker),"boolean"==typeof e.isAd&&this.setIsAd(e.isAd),n.default.prototype.setOptions.apply(this,arguments))}setPlayer(e,t){(this.player||this.tag)&&this.dispose(),"undefined"!=typeof document&&document.getElementById&&("string"==typeof e&&(e=document.getElementById(e)),"string"==typeof t&&(t=document.getElementById(t))),t=t||e,this.player=e,this.tag=t,this.registerListeners()}isAd(){return this.state.isAd()}setIsAd(e){this.state.setIsAd(e)}setAdsTracker(e){this.disposeAdsTracker(),e&&(this.adsTracker=e,this.adsTracker.setIsAd(!0),this.adsTracker.parentTracker=this,this.adsTracker.on("*",l.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",l),this.adsTracker.dispose())}dispose(){this.stopHeartbeat(),this.disposeAdsTracker(),this.unregisterListeners(),this.player=null,this.tag=null}registerListeners(){}unregisterListeners(){}getViewId(){return this.parentTracker?this.parentTracker.getViewId():this.state.getViewId()}getViewSession(){return this.parentTracker?this.parentTracker.getViewSession():this.state.getViewSession()}getVideoId(){return null}getTitle(){return null}isLive(){return null}getBitrate(){return null}getWebkitBitrate(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){let e;if(this._lastWebkitBitrate){e=this.tag.webkitVideoDecodedByteCount;let t=e-this._lastWebkitBitrate,i=this.getHeartbeat()/1e3;e=Math.round(t/i*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,e||null}}getRenditionName(){return null}getRenditionBitrate(){return null}getRenditionShift(e){let t,i=this.getRenditionBitrate();return this.isAd()?(t=this._lastAdRendition,e&&(this._lastAdRendition=i)):(t=this._lastRendition,e&&(this._lastRendition=i)),i&&t?i>t?"up":i<t?"down":null:null}getRenditionHeight(){return this.tag?this.tag.videoHeight:null}getRenditionWidth(){return this.tag?this.tag.videoWidth:null}getDuration(){return this.tag?this.tag.duration:null}getPlayhead(){return this.tag?this.tag.currentTime:null}getLanguage(){return null}getSrc(){return this.tag?this.tag.currentSrc:null}getPlayrate(){return this.tag?this.tag.playbackRate:null}isMuted(){return this.tag?this.tag.muted:null}isFullscreen(){return null}getCdn(){return null}getPlayerName(){return this.getTrackerName()}getPlayerVersion(){return a.default.version}getFps(){return null}isAutoplayed(){return this.tag?this.tag.autoplay:null}getPreload(){return this.tag?this.tag.preload:null}getAdQuartile(){return null}getAdPosition(){return this.parentTracker?this.parentTracker.state.isStarted?"mid":"pre":null}getAdPartner(){return null}getAdCreativeId(){return null}getInstrumentationProvider(){return null}getInstrumentationName(){return null}getInstrumentationVersion(){return null}getAttributes(e,t){if(void 0===(e=n.default.prototype.getAttributes.apply(this,arguments)).isAd&&(e.isAd=this.isAd()),e.viewSession=this.getViewSession(),e.viewId=this.getViewId(),e.playerName=this.getPlayerName(),e.playerVersion=this.getPlayerVersion(),e["instrumentation.provider"]=this.getInstrumentationProvider(),e["instrumentation.name"]=this.getInstrumentationName(),e["instrumentation.version"]=this.getInstrumentationVersion(),e["enduser.id"]=this._userId,e.src="Browser","customAction"===t)return e;try{e.pageUrl=window.location.href}catch(e){}this.isAd()?(e.adId=this.getVideoId(),e.adTitle=this.getTitle(),e.adSrc=this.getSrc(),e.adCdn=this.getCdn(),e.adBitrate=this.getBitrate()||this.getWebkitBitrate()||this.getRenditionBitrate(),e.adRenditionName=this.getRenditionName(),e.adRenditionBitrate=this.getRenditionBitrate(),e.adRenditionHeight=this.getRenditionHeight(),e.adRenditionWidth=this.getRenditionWidth(),e.adDuration=this.getDuration(),e.adPlayhead=this.getPlayhead(),e.adLanguage=this.getLanguage(),e.adIsMuted=this.isMuted(),e.adFps=this.getFps(),e.adPosition=this.getAdPosition(),e.adCreativeId=this.getAdCreativeId(),e.adPartner=this.getAdPartner()):(e.contentId=this.getVideoId(),e.contentTitle=this.getTitle(),e.contentSrc=this.getSrc(),e.contentCdn=this.getCdn(),e.contentPlayhead=this.getPlayhead(),e.contentIsLive=this.isLive(),e.contentBitrate=this.getBitrate()||this.getWebkitBitrate()||this.getRenditionBitrate(),e.contentRenditionName=this.getRenditionName(),e.contentRenditionBitrate=this.getRenditionBitrate(),e.contentRenditionHeight=this.getRenditionHeight(),e.contentRenditionWidth=this.getRenditionWidth(),e.contentDuration=this.getDuration(),e.contentLanguage=this.getLanguage(),e.contentPlayrate=this.getPlayrate(),e.contentIsFullscreen=this.isFullscreen(),e.contentIsMuted=this.isMuted(),e.contentIsAutoplayed=this.isAutoplayed(),e.contentPreload=this.getPreload(),e.contentFps=this.getFps(),null!=this.adsTracker&&this.adsTracker.state.totalAdPlaytime>0&&(e.totalAdPlaytime=this.adsTracker.state.totalAdPlaytime)),this.state.getStateAttributes(e);for(let t in this.customData)e[t]=this.customData[t];return e}sendCustom(e,t,i){i=i||{},this.sendVideoCustomAction(e,i),this.state.setTimeSinceAttribute(t)}sendPlayerReady(e){this.state.goPlayerReady()&&(e=e||{},this.sendVideoAction(d.Events.PLAYER_READY,e))}sendRequest(e){if(this.state.goRequest()){let t;this.isAd()?(t=d.Events.AD_REQUEST,this.sendVideoAdAction(t,e)):(t=d.Events.CONTENT_REQUEST,this.sendVideoAction(t,e))}}sendStart(e){if(this.state.goStart()){let t;this.isAd()?(t=d.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(t,e)):(t=d.Events.CONTENT_START,this.sendVideoAction(t,e)),this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(e){if(this.state.goEnd()){let t;e=e||{},this.isAd()?(t=d.Events.AD_END,e.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0)):(t=d.Events.CONTENT_END,e.timeSinceRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceStarted=this.state.timeSinceStarted.getDeltaTime()),this.stopHeartbeat(),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd(),this.state.goViewCountUp(),this.state.totalPlaytime=0}}sendPause(e){if(this.state.goPause()){let t=this.isAd()?d.Events.AD_PAUSE:d.Events.CONTENT_PAUSE;this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendResume(e){if(this.state.goResume()){let t;e=e||{},this.isAd()?(t=d.Events.AD_RESUME,e.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(t=d.Events.CONTENT_RESUME,e.timeSincePaused=this.state.timeSincePaused.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferStart(e){if(this.state.goBufferStart()){let t;e=e||{},t=this.isAd()?d.Events.AD_BUFFER_START:d.Events.CONTENT_BUFFER_START,e=this.buildBufferAttributes(e),this._lastBufferType=e.bufferType,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferEnd(e){if(this.state.goBufferEnd()){let t;e=e||{},this.isAd()?(t=d.Events.AD_BUFFER_END,e.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(t=d.Events.CONTENT_BUFFER_END,e.timeSinceBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()),e=this.buildBufferAttributes(e),null!=this._lastBufferType&&(e.bufferType=this._lastBufferType),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.initialBufferingHappened=!0}}buildBufferAttributes(e){return null==e.timeSinceStarted||e.timeSinceStarted<100?e.isInitialBuffering=!this.state.initialBufferingHappened:e.isInitialBuffering=!1,e.bufferType=this.state.calculateBufferType(e.isInitialBuffering),e.timeSinceResumed=this.state.timeSinceResumed.getDeltaTime(),e.timeSinceSeekEnd=this.state.timeSinceSeekEnd.getDeltaTime(),e}sendSeekStart(e){if(this.state.goSeekStart()){let t;t=this.isAd()?d.Events.AD_SEEK_START:d.Events.CONTENT_SEEK_START,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendSeekEnd(e){if(this.state.goSeekEnd()){let t;e=e||{},this.isAd()?(t=d.Events.AD_SEEK_END,e.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(t=d.Events.CONTENT_SEEK_END,e.timeSinceSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendDownload(e){(e=e||{}).state||s.default.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(d.Events.DOWNLOAD,e),this.state.goDownload()}sendError(e){(e=e||{}).isAd=this.isAd(),this.state.goError();let t=this.isAd()?d.Events.AD_ERROR:d.Events.CONTENT_ERROR;this.sendVideoErrorAction(t,e)}sendRenditionChanged(e){let t;(e=e||{}).timeSinceLastRenditionChange=this.state.timeSinceLastRenditionChange.getDeltaTime(),e.shift=this.getRenditionShift(!0),t=this.isAd()?d.Events.AD_RENDITION_CHANGE:d.Events.CONTENT_RENDITION_CHANGE,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.goRenditionChange()}sendHeartbeat(e){if(this.state.isRequested){let t,i=this.getHeartbeat();this.state._hb=!0,i=this.adjustElapsedTimeForPause(i),this.isAd()?(t=d.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(t,e):this.sendVideoAdAction(t,{elapsedTime:i,...e})):(t=d.Events.CONTENT_HEARTBEAT,this.sendVideoAction(t,{elapsedTime:i,...e})),this.state.goHeartbeat()}}adjustElapsedTimeForPause(e){return this.state._acc&&(e-=this.state._acc,this.state._acc=0),this.state.isPaused&&((e-=this.state.elapsedTime.getDeltaTime())<10&&(e=0),this.state.elapsedTime.start()),this.state._bufferAcc?(e-=this.state._bufferAcc,this.state._bufferAcc=0):this.state.isBuffering&&((e-=this.state.bufferElapsedTime.getDeltaTime())<5&&(e=0),this.state.bufferElapsedTime.start()),Math.max(0,e)}sendAdBreakStart(e){this.isAd()&&this.state.goAdBreakStart()&&(this.state.totalAdPlaytime=0,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(d.Events.AD_BREAK_START,e))}sendAdBreakEnd(e){this.isAd()&&this.state.goAdBreakEnd()&&((e=e||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(d.Events.AD_BREAK_END,e),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.stopHeartbeat(),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd())}sendAdQuartile(e){this.isAd()&&((e=e||{}).quartile||s.default.warn("Called sendAdQuartile without { quartile: xxxxx }."),e.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(d.Events.AD_QUARTILE,e),this.state.goAdQuartile())}sendAdClick(e){this.isAd()&&((e=e||{}).url||s.default.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(d.Events.AD_CLICK,e))}}function l(e){e.type!==d.Events.AD_ERROR?this.sendVideoAdAction(e.type,e.data):this.sendVideoErrorAction(e.type,e.data)}d.Events={PLAYER_READY:"PLAYER_READY",DOWNLOAD:"DOWNLOAD",ERROR:"ERROR",CONTENT_REQUEST:"CONTENT_REQUEST",CONTENT_START:"CONTENT_START",CONTENT_END:"CONTENT_END",CONTENT_PAUSE:"CONTENT_PAUSE",CONTENT_RESUME:"CONTENT_RESUME",CONTENT_SEEK_START:"CONTENT_SEEK_START",CONTENT_SEEK_END:"CONTENT_SEEK_END",CONTENT_BUFFER_START:"CONTENT_BUFFER_START",CONTENT_BUFFER_END:"CONTENT_BUFFER_END",CONTENT_HEARTBEAT:"CONTENT_HEARTBEAT",CONTENT_RENDITION_CHANGE:"CONTENT_RENDITION_CHANGE",CONTENT_ERROR:"CONTENT_ERROR",AD_REQUEST:"AD_REQUEST",AD_START:"AD_START",AD_END:"AD_END",AD_PAUSE:"AD_PAUSE",AD_RESUME:"AD_RESUME",AD_SEEK_START:"AD_SEEK_START",AD_SEEK_END:"AD_SEEK_END",AD_BUFFER_START:"AD_BUFFER_START",AD_BUFFER_END:"AD_BUFFER_END",AD_HEARTBEAT:"AD_HEARTBEAT",AD_RENDITION_CHANGE:"AD_RENDITION_CHANGE",AD_ERROR:"AD_ERROR",AD_BREAK_START:"AD_BREAK_START",AD_BREAK_END:"AD_BREAK_END",AD_QUARTILE:"AD_QUARTILE",AD_CLICK:"AD_CLICK"},t.default=d}},t={};function i(s){var n=t[s];if(void 0!==n)return n.exports;var r=t[s]={exports:{}};return e[s](r,r.exports,i),r.exports}var s={};(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=c(i(399)),n=c(i(51)),r=c(i(455)),a=c(i(144)),o=c(i(568)),d=c(i(302)),l=c(i(793)),h=c(i(328)),u=i(330);function c(e){return e&&e.__esModule?e:{default:e}}const g={Constants:n.default,Chrono:r.default,Log:a.default,Emitter:o.default,Tracker:d.default,VideoTracker:l.default,VideoTrackerState:h.default,Core:t.default,version:u.version};e.default=g})(),module.exports.nrvideo=s})();
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * @license Apache-2.0
3
+ * @newrelic/video-core 3.2.0-beta-1
4
+ * Copyright New Relic <http://newrelic.com/>
5
+ * @author Jordi Aguilar
6
+ */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","mappings":";uGAKA,MAAMA,GAONA,EAAUC,YAAc,CAEtBC,IAAK,MAELC,IAAK,MAELC,KAAM,QAGRJ,EAAUK,SAAW,IACrBL,EAAUM,qBAAuB,IACjCN,EAAUO,iBAAmB,EAC7BP,EAAUQ,gBAAkB,MAC5BR,EAAUS,eAAiB,MAC3BT,EAAUU,kBAAoB,CAC5B,cACA,gBACA,mBACA,qBAGFV,EAAUW,UAAY,CACpBC,GAAI,uBACJC,GAAI,uBACJC,MAAO,+BACPC,IAAK,uBAGPC,EAAAA,QAEehB,iFCpCf,MAAMiB,EAMJ,YAAOC,IAASC,GACdC,EAAQD,EAAKF,EAAII,OAAOC,MAAO,UACjC,CAQA,WAAOC,IAAQJ,GACbC,EAAQD,EAAKF,EAAII,OAAOG,QAAS,aACnC,CAQA,aAAOC,IAAUN,GACfC,EAAQ,GAAGM,MAAMC,KAAKC,WAAYX,EAAII,OAAOQ,OAAQ,WACvD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AyBE,GAAY,CAGjD5e,QAAS,CAAC,GAOX,OAHA+e,EAAoBH,GAAUE,EAAQA,EAAO9e,QAAS2e,GAG/CG,EAAO9e,OACf,0FCtBA,IAAAgf,EAAA/a,EAAAC,EAAA,MACAG,EAAAJ,EAAAC,EAAA,KACAE,EAAAH,EAAAC,EAAA,MACA2G,EAAA5G,EAAAC,EAAA,MACAC,EAAAF,EAAAC,EAAA,MACAyQ,EAAA1Q,EAAAC,EAAA,MACA+a,EAAAhb,EAAAC,EAAA,MACA0Q,EAAA3Q,EAAAC,EAAA,MACAF,EAAAE,EAAA,KAA0C,SAAAD,EAAA5C,GAAA,OAAAA,GAAAA,EAAAiD,WAAAjD,EAAA,CAAAkD,QAAAlD,EAAA,CAE1C,MAAM6d,EAAU,CACdlgB,UAAAA,EAAAA,QACAkG,OAAAA,EAAAA,QACAjF,IAAAA,EAAAA,QACAwE,QAAAA,EAAAA,QACAD,QAAAA,EAAAA,QACAqQ,aAAAA,EAAAA,QACAsK,kBAAAA,EAAAA,QACAvN,KAAAA,EAAAA,QACAxK,QAAAA,EAAAA,SACApH,EAAAA,QACakf","sources":["webpack://nrvideo/./src/constants.js","webpack://nrvideo/./src/log.js","webpack://nrvideo/./src/tracker.js","webpack://nrvideo/./src/harvester.js","webpack://nrvideo/./src/videotrackerstate.js","webpack://nrvideo/./src/utils.js","webpack://nrvideo/./src/core.js","webpack://nrvideo/./src/authConfiguration.js","webpack://nrvideo/./src/eventAggregator.js","webpack://nrvideo/./src/recordEvent.js","webpack://nrvideo/./src/chrono.js","webpack://nrvideo/./src/agent.js","webpack://nrvideo/./src/emitter.js","webpack://nrvideo/./src/videotracker.js","webpack://nrvideo/webpack/bootstrap","webpack://nrvideo/./src/index.js"],"sourcesContent":["/**\n * Constants for the library.\n * @class Constants\n * @static\n */\nclass Constants {}\n\n/**\n * Enum for types/positions of ads.\n * @example var type = Constants.AdPositions.PRE\n * @enum {String}\n */\nConstants.AdPositions = {\n /** For ads shown before the content. */\n PRE: \"pre\",\n /** For ads shown during the content. */\n MID: \"mid\",\n /** For ads shown after the content. */\n POST: \"post\",\n};\n\nConstants.INTERVAL = 10000;\nConstants.MAX_EVENTS_PER_BATCH = 1000;\nConstants.MAX_PAYLOAD_SIZE = 1; // 1mb\nConstants.MAX_BEACON_SIZE = 0.0625; // 64kb\nConstants.MAX_EVENT_SIZE = 0.0625; // 64kb\nConstants.VALID_EVENT_TYPES = [\n \"VideoAction\",\n \"VideoAdAction\",\n \"VideoErrorAction\",\n \"VideoCustomAction\",\n];\n\nConstants.COLLECTOR = {\n US: \"bam-cell.nr-data.net\",\n EU: \"bam.eu01.nr-data.net\",\n Stage: \"staging-bam-cell.nr-data.net\",\n GOV: \"gov-bam.nr-data.net\",\n};\n\n// \"bam.nr-data.net\",\n\nexport default Constants;\n","/**\n * Static Log class\n *\n * @class\n * @static\n */\nclass Log {\n /**\n * Sends an error console log.\n * @param {...any} [msg] Message to show\n * @static\n */\n static error(...msg) {\n _report(msg, Log.Levels.ERROR, \"darkred\");\n }\n\n /**\n * Sends a warning console log.\n * @method Log.warn\n * @static\n * @param {...any} msg Message to show\n */\n static warn(...msg) {\n _report(msg, Log.Levels.WARNING, \"darkorange\");\n }\n\n /**\n * Sends a notice console log.\n * @method Log.notice\n * @static\n * @param {...any} msg Message to show\n */\n static notice(...msg) {\n _report([].slice.call(arguments), Log.Levels.NOTICE, \"darkcyan\");\n }\n\n /**\n * Sends a debug message to console.\n * @method Log.debug\n * @static\n * @param {...any} msg Message to show\n */\n static debug(...msg) {\n _report(msg, Log.Levels.DEBUG, \"indigo\");\n }\n\n /**\n * This utility method will add most of the HTML5 common event listeners to the player sent.\n * Events will be reported as DEBUG level messages.\n *\n * @example\n * // Already included events:\n * ['canplay', 'buffering', 'waiting', 'ended', 'play', 'playing', 'pause', 'resume', 'error',\n * 'abort', 'seek', 'seeking', 'seeked', 'stalled', 'dispose', 'loadeddata', 'loadstart',\n * 'loadedmetadata']\n *\n * @method Log.debugCommonVideoEvents\n * @static\n * @param {object|function} o Object to attach the events.\n * @param {array} [extraEvents]\n * An array of extra events to watch. ie: ['timeupdate', 'progress'].\n * If the first item is null, no common events will be added.\n * @param {function} [report] Callback function called to report events.\n * Default calls Log.debug()\n */\n static debugCommonVideoEvents(o, extraEvents, report) {\n try {\n if (Log.level <= Log.Levels.DEBUG) {\n report =\n report ||\n function (e) {\n Log.debug(\"Event: \" + e.type);\n };\n\n var playerEvents = [\n \"canplay\",\n \"buffering\",\n \"waiting\",\n \"ended\",\n \"play\",\n \"playing\",\n \"pause\",\n \"resume\",\n \"error\",\n \"abort\",\n \"seek\",\n \"seeking\",\n \"seeked\",\n \"stalled\",\n \"dispose\",\n \"loadeddata\",\n \"loadstart\",\n \"loadedmetadata\",\n ];\n if (extraEvents) {\n if (extraEvents[0] === null) {\n extraEvents.shift();\n playerEvents = extraEvents;\n } else {\n playerEvents = playerEvents.concat(extraEvents);\n }\n }\n\n for (var i = 0; i < playerEvents.length; i++) {\n if (typeof o === \"function\") {\n o.call(window, playerEvents[i], report);\n } else if (o.on) {\n o.on(playerEvents[i], report);\n } else if (o.addEventListener) {\n o.addEventListener(playerEvents[i], report);\n } else if (o.addEventHandler) {\n o.addEventHandler(playerEvents[i], report);\n } else {\n Log.warn(\n \"debugCommonVideoEvents: No common listener function found for \",\n o\n );\n }\n }\n }\n } catch (err) {\n Log.warn(err);\n }\n }\n}\n\n/**\n * Enum for log levels\n * @enum {integer}\n * @static\n * @var\n */\nLog.Levels = {\n /** No console outputs */\n SILENT: 5,\n /** Console will show errors */\n ERROR: 4,\n /** Console will show warnings */\n WARNING: 3,\n /** Console will show notices (ie: life-cyrcle logs) */\n NOTICE: 2,\n /** Console will show debug messages. */\n DEBUG: 1,\n /** Show all messages. */\n ALL: 0,\n};\n\n/**\n * Only logs of this imporance or higher will be shown.\n * @example Log.level = Log.Levels.ALL\n * @default Log.Levels.ERROR\n * @static\n */\nLog.level = Log.Levels.ERROR;\n\n/**\n * If true, logs will be outputed with colors.\n * @default true\n * @static\n */\nLog.colorful = true;\n\n/**\n * If true, logs will include the time mark.\n * @default true\n * @static\n */\nLog.includeTime = true;\n\n/**\n * Prefix included at the start of every log.\n * @default '[New Relic]'\n * @static\n */\nLog.prefix = \"[nrvideo]\";\n\n// PRIVATE MEMBERS\n\n/**\n * Returns a console message\n *\n * @private\n * @param {array} msg Message array, error object or array of messages.\n * @param {Log.Level} [level=Log.Levels.NOTICE] Defines the level of the error sent.\n * Only errors with higher or equal level than Log.logLevel will be displayed.\n * @param {string} [color='darkgreen'] Color of the header\n * @see {@link Log.level}\n */\nfunction _report(msg, level, color) {\n level = level || Log.Levels.NOTICE;\n color = color || \"darkcyan\";\n\n var prefix = Log.prefix;\n if (Log.includeTime) prefix += _getCurrentTime() + \" \";\n prefix += _level2letter(level) + \":\";\n\n // Show messages in actual console if level is enought\n if (Log.level <= level && level !== Log.Levels.SILENT) {\n if (\n !Log.colorful ||\n (typeof document !== \"undefined\" && document.documentMode)\n ) {\n // document.documentMode exits only in IE\n _plainReport(msg, prefix);\n } else {\n // choose log method\n var logMethod;\n if (level === Log.Levels.ERROR && console.error) {\n logMethod = console.error;\n } else if (level === Log.Levels.WARNING && console.warn) {\n logMethod = console.warn;\n } else if (level === Log.Levels.DEBUG && console.debug) {\n // NOTE: for some reason console.debug doesn't work on CAF Receivers.\n if (window.cast == undefined) {\n logMethod = console.debug;\n } else {\n logMethod = console.log;\n }\n } else {\n logMethod = console.log;\n }\n\n // print message\n prefix = \"%c\" + prefix;\n msg.splice(0, 0, prefix, \"color: \" + color);\n logMethod.apply(console, msg);\n }\n }\n}\n\n/**\n * Returns the current time in format hh:mm:ss.mmm (with trailing 0s)\n * @private\n * @return {string} Current time.\n */\nfunction _getCurrentTime() {\n var d = new Date();\n var hh = (\"0\" + d.getDate()).slice(-2);\n var mm = (\"0\" + d.getMinutes()).slice(-2);\n var ss = (\"0\" + d.getSeconds()).slice(-2);\n var mmm = (\"00\" + d.getMilliseconds()).slice(-3);\n return \"[\" + hh + \":\" + mm + \":\" + ss + \".\" + mmm + \"]\";\n}\n\n/**\n * Returns a console message without style\n *\n * @private\n * @param {(string|object|array)} msg Message string, object or array of messages.\n * @param {string} prefix Prefix of the message.\n */\nfunction _plainReport(msg, prefix) {\n if (msg instanceof Array) {\n for (var m in msg) {\n _plainReport(msg[m], prefix);\n }\n } else {\n if (typeof msg === \"string\") {\n console.log(prefix + \" \" + msg);\n } else {\n console.log(prefix + \"↵\");\n console.log(msg);\n }\n }\n}\n\nconst _letters = {\n 4: \"e\", // Error\n 3: \"w\", // Warning\n 2: \"n\", // Notice\n 1: \"d\", // Debug\n};\n\n/**\n * Transforms a level to a letter to identify every message.\n *\n * @private\n * @param {sLog.Level} level Level of the message\n */\nfunction _level2letter(level) {\n return _letters[level];\n}\n\n/**\n * This function is automatically executed at load.\n * Will search inside window.location.search for attribute 'nrvideo-debug=X'.\n * X can have one of these values, that will modify Log.Levels.\n * 5: SILENT,\n * 4: ERROR,\n * 3: WARNING,\n * 2: NOTICE,\n * 1: DEBUG,\n *\n * If nrvideo-colors=false is present, Log.colorful will be set to false.\n *\n * @private\n */\nfunction _loadLevelFromUrl() {\n if (\n typeof window !== \"undefined\" &&\n window.location &&\n window.location.search\n ) {\n var m = /\\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);\n if (m !== null) {\n if (m[1] === \"true\") {\n Log.level = Log.Levels.ALL;\n } else {\n Log.level = m[1];\n }\n }\n\n var m2 = /\\?.*&*nrvideo-colors=false/i.exec(window.location.search);\n if (m2 !== null) {\n Log.colorful = false;\n }\n }\n}\n\n// Execute load level\n_loadLevelFromUrl();\n\nexport default Log;\n","import pkg from \"../package.json\";\nimport Emitter from \"./emitter\";\nimport Chrono from \"./chrono\";\nimport Constants from \"./constants\";\n\n/**\n * Tracker class provides the basic logic to extend Newrelic's Browser Agent capabilities.\n * Trackers are designed to listen third party elements (like video tags, banners, etc.) and send\n * information over to Browser Agent. Extend this class to create your own tracker, override\n * registerListeners and unregisterListeners for full coverage!\n *\n * @example\n * Tracker instances should be added to Core library to start sending data:\n * nrvideo.Core.addTracker(new Tracker())\n *\n * @extends Emitter\n */\nclass Tracker extends Emitter {\n /**\n * Constructor, receives options. You should call {@see registerListeners} after this.\n *\n * @param {Object} [options] Options for the tracker. See {@link setOptions}.\n */\n constructor(options) {\n super();\n\n /**\n * If you add something to this custom dictionary it will be added to every action. If you set\n * any value, it will always override the values returned by the getters.\n *\n * @example\n * If you define tracker.customData.contentTitle = 'a' and tracker.getTitle() returns 'b'.\n * 'a' will prevail.\n */\n this.customData = {};\n\n /**\n * Set time between hearbeats, in ms.\n */\n this.heartbeat = null;\n\n /**\n * Another Tracker instance. Useful to relate ad Trackers to their parent content Trackers.\n * @type Tracker\n */\n this.parentTracker = null;\n\n /**\n * Chrono that counts time since this class was instantiated.\n * @private\n */\n this._trackerReadyChrono = new Chrono();\n this._trackerReadyChrono.start();\n\n /**\n * Store the initial table of actions with time 0 ms\n */\n this._actionTable = Constants.ACTION_TABLE;\n this._actionAdTable = Constants.ACTION_AD_TABLE;\n\n options = options || {};\n this.setOptions(options);\n }\n\n /**\n * Set options for the Tracker.\n *\n * @param {Object} [options] Options for the tracker.\n * @param {number} [options.heartbeat] Set time between heartbeats. See {@link heartbeat}.\n * @param {Object} [options.customData] Set custom data. See {@link customData}.\n * @param {Tracker} [options.parentTracker] Set parent tracker. See {@link parentTracker}.\n */\n setOptions(options) {\n if (options) {\n if (options.parentTracker) this.parentTracker = options.parentTracker;\n if (options.customData) this.customData = options.customData;\n if (options.heartbeat) this.heartbeat = options.heartbeat;\n }\n }\n\n /**\n * Prepares tracker to dispose. Calls {@see unregisterListeners} and drops references.\n */\n dispose() {\n this.unregisterListeners();\n }\n\n /**\n * Override this method to register listeners to third party elements.\n *\n * @example\n * class SpecificTracker extends Tracker {\n * registerListeners() {\n * this.player.on('play', () => this.playHandler)\n * }\n *\n * playHandler() {\n * this.emit(Tracker.Events.REQUESTED)\n * }\n * }\n */\n registerListeners() {}\n\n /**\n * Override this method to unregister listeners to third party elements created with\n * {@see registerListeners}.\n *\n * @example\n * class SpecificTracker extends Tracker {\n * registerListeners() {\n * this.player.on('play', () => this.playHandler)\n * }\n *\n * unregisterListeners() {\n * this.player.off('play', () => this.playHandler)\n * }\n *\n * playHandler() {\n * this.emit(Tracker.Events.REQUESTED)\n * }\n * }\n */\n unregisterListeners() {}\n\n /**\n * Returns heartbeat time interval. 30000 (30s) if not set. See {@link setOptions}.\n * @return {number} Heartbeat interval in ms.\n * @final\n */\n getHeartbeat() {\n if (this.state._isAd) {\n // modifying heartbeat for Ad Tracker\n return 2000;\n } else {\n if (this.heartbeat) {\n return this.heartbeat;\n } else if (this.parentTracker && this.parentTracker.heartbeat) {\n return this.parentTracker.heartbeat;\n } else {\n return 30000;\n }\n }\n }\n\n /**\n * Starts heartbeating. Interval period set by options.heartbeat. Min 2000 ms.\n * This method is automaticaly called by the tracker once sendRequest is called.\n */\n startHeartbeat() {\n this._heartbeatInterval = setInterval(\n this.sendHeartbeat.bind(this),\n Math.max(this.getHeartbeat(), 2000)\n );\n }\n\n /**\n * Stops heartbeating. This method is automaticaly called by the tracker.\n */\n stopHeartbeat() {\n if (this._heartbeatInterval) {\n clearInterval(this._heartbeatInterval);\n }\n }\n\n /**\n * Heartbeating allows you to call this function each X milliseconds, defined by\n * {@link getHeartbeat}. This is useful to send regular events to track changes.\n *\n * By default it will send {@link Tracker.Events.HEARTBEAT}.\n * To start heartbeating use {@link startHeartbeat} and to stop them use {@link stopHeartbeat}.\n *\n * @example\n * Override this method to define your own Heartbeat reporting.\n *\n * class TrackerChild extends Tracker {\n * sendHeartbeat (att) {\n * this.send('MY_HEARBEAT_EVENT')\n * }\n * }\n *\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendHeartbeat(att) {\n this.sendVideoAction(Tracker.Events.HEARTBEAT, att);\n }\n\n /**\n * Override this method to return attributes for actions.\n *\n * @example\n * class SpecificTracker extends Tracker {\n * getAttributes(att) {\n * att = att || {}\n * att.information = 'something'\n * return att\n * }\n * }\n *\n * @param {object} [att] Collection of key value attributes\n * @return {object} Filled attributes\n * @final\n */\n getAttributes(att, eventType) {\n att = att || {};\n att.trackerName = this.getTrackerName();\n att.trackerVersion = this.getTrackerVersion();\n att.coreVersion = pkg.version;\n att.timeSinceTrackerReady = this._trackerReadyChrono.getDeltaTime();\n\n for (let key in this.customData) {\n att[key] = this.customData[key];\n }\n\n if (document.hidden != undefined) {\n att.isBackgroundEvent = document.hidden;\n }\n\n return att;\n }\n\n /** Override to change of the Version of tracker. ie: '1.0.1' */\n getTrackerVersion() {\n return pkg.version;\n }\n\n /** Override to change of the Name of the tracker. ie: 'custom-html5' */\n getTrackerName() {\n return \"base-tracker\";\n }\n\n /**\n * Send given event. Will automatically call {@see getAttributes} to fill information.\n * Internally, this will call {@see Emitter#emit}, so you could listen any event fired.\n *\n * @example\n * tracker.send('BANNER_CLICK', { url: 'http....' })\n *\n * @param {string} event Event name\n * @param {object} [att] Key:value dictionary filled with attributes.\n */\n\n /**\n * getElapsedTime: Calculate the time elapsed between two same actions\n *\n */\n\n sendVideoAction(event, att) {\n this.emit(\"VideoAction\", event, this.getAttributes(att));\n }\n\n sendVideoAdAction(event, att) {\n this.emit(\"VideoAdAction\", event, this.getAttributes(att));\n }\n\n sendVideoErrorAction(event, att) {\n let ev = this.isAd() ? \"adError\" : \"videoError\";\n this.emit(\"VideoErrorAction\", event, this.getAttributes(att, ev));\n }\n\n sendVideoCustomAction(event, att) {\n this.emit(\n \"VideoCustomAction\",\n event,\n this.getAttributes(att, \"customAction\")\n );\n }\n}\n\n/**\n * Enumeration of events fired by this class.\n *\n * @static\n * @memberof Tracker\n * @enum {string}\n */\nTracker.Events = {\n /** The heartbeat event is sent once every 30 seconds while the video is playing. */\n HEARTBEAT: \"HEARTBEAT\",\n};\n\nexport default Tracker;\n","import Constants from \"./constants\";\nimport pkg from \"../package.json\";\nimport { callApi, getPayloadSize } from \"./utils\";\n\nconst { INTERVAL, MAX_EVENTS_PER_BATCH, MAX_PAYLOAD_SIZE, MAX_BEACON_SIZE } =\n Constants;\n\n/**\n * A scheduler and dispatcher for sending raw event data to the New Relic 'ins' endpoint.\n * It manages the harvest cycle, URL construction, and retries.\n */\nexport class NRVideoHarvester {\n #started = false;\n #aggregate; // EventAggregator instance\n #timerId = null; // Timer ID for cleanup\n\n /**\n * @param {object} agentController - The agent's configuration object.\n * @param {object} aggregate - The aggregator instance (e.g., EventAggregator).\n */\n constructor(aggregate) {\n this.#aggregate = aggregate;\n // Ensure any queued data is sent when the user navigates away.\n window.addEventListener(\"pagehide\", () =>\n this.triggerHarvest({ isFinalHarvest: true })\n );\n }\n\n /**\n * Starts the periodic harvest timer.\n */\n startTimer() {\n if (this.#started) return;\n this.#started = true;\n const onHarvestInterval = () => {\n this.triggerHarvest({});\n if (this.#started) {\n this.#timerId = setTimeout(onHarvestInterval, INTERVAL);\n }\n };\n this.#timerId = setTimeout(onHarvestInterval, INTERVAL);\n }\n\n /**\n * Stops the harvest timer and cleans up resources.\n */\n stopTimer() {\n this.#started = false;\n if (this.#timerId) {\n clearTimeout(this.#timerId);\n this.#timerId = null;\n }\n }\n\n /**\n * Executes a harvest cycle by draining the queue and sending it in chunks.\n */\n\n triggerHarvest(options = {}) {\n if (this.#aggregate.isEmpty()) return;\n\n try {\n // 1. Drain the entire queue to get all pending events.\n const allEvents = this.#aggregate.drain();\n\n // 2. Determine the correct size limit for this harvest.\n const maxChunkSize = options.isFinalHarvest\n ? MAX_BEACON_SIZE\n : MAX_PAYLOAD_SIZE;\n\n // 3. Split the events into chunks that respect size and count limits.\n const chunks = this.chunkEvents(allEvents, maxChunkSize);\n\n // 4. Send each chunk sequentially.\n chunks.forEach((chunk, index) => {\n const isLastChunk = index === chunks.length - 1;\n this.sendChunk(chunk, options, isLastChunk);\n });\n } catch (error) {\n console.error(\"Error during harvest:\", error);\n // Re-add events to the queue if something went wrong\n // This is a failsafe to prevent data loss\n }\n }\n\n /**\n * Splits an array of events into multiple smaller arrays (chunks).\n */\n chunkEvents(events, maxChunkSize) {\n const chunks = [];\n let currentChunk = [];\n\n for (const event of events) {\n if (currentChunk.length >= MAX_EVENTS_PER_BATCH) {\n chunks.push(currentChunk);\n currentChunk = [];\n }\n\n currentChunk.push(event);\n const payloadSize = getPayloadSize({ ins: currentChunk });\n // Use the maxChunkSize passed into the function\n if (payloadSize > maxChunkSize) {\n const lastEvent = currentChunk.pop();\n if (currentChunk.length > 0) {\n chunks.push(currentChunk);\n }\n currentChunk = [lastEvent];\n }\n }\n\n if (currentChunk.length > 0) {\n chunks.push(currentChunk);\n }\n\n return chunks;\n }\n\n /**\n * Sends a single chunk of events.\n */\n sendChunk(chunk, options, isLastChunk) {\n const url = this.#buildUrl();\n if (!url) {\n // If URL construction failed, treat as a failed request that shouldn't be retried\n this.#aggregate.postHarvestCleanup({ retry: false, status: 0 });\n return;\n }\n\n const payload = { body: { ins: chunk } };\n\n callApi(\n {\n url: url,\n payload: payload,\n options: options,\n },\n (result) => {\n // Pass the failed chunk back to the aggregator for re-queuing.\n if (result.retry) {\n result.chunk = chunk;\n }\n this.#aggregate.postHarvestCleanup(result);\n }\n );\n }\n\n /**\n * Constructs the specific URL for the New Relic 'ins' endpoint with all required parameters.\n * @private\n */\n\n #buildUrl() {\n try {\n if (!window.NRVIDEO || !window.NRVIDEO.info) {\n throw new Error(\"NRVIDEO info is not available.\");\n }\n\n const { beacon, licenseKey, applicationID, sa } = window.NRVIDEO.info;\n\n if (!beacon || !licenseKey || !applicationID)\n throw new Error(\n \"Options object provided by New Relic is not correctly initialized\"\n );\n const url = `https://${beacon}/ins/1/${licenseKey}?a=${applicationID}&v=${pkg.version}&ref=${window.location.href}&ca=VA`;\n return url;\n } catch (error) {\n console.error(error.message);\n return null; // Return null instead of undefined\n }\n }\n}\n","import Chrono from \"./chrono\";\nimport Log from \"./log\";\n\n/**\n * State machine for a VideoTracker and its monitored video.\n */\nclass VideoTrackerState {\n /** Constructor */\n constructor() {\n this.reset();\n\n //this.setupNetworkListeners();\n\n /**\n * Time when the VideoTrackerState was initializated.\n * @private\n */\n this._createdAt = Date.now();\n this._hb = true;\n this._acc = 0;\n this._bufferAcc = 0;\n }\n\n /** Resets all flags and chronos. */\n reset() {\n /**\n * Unique identifier of the view.\n * @private\n */\n this._viewSession = null;\n\n /**\n * Number of views seen.\n * @private\n */\n this._viewCount = 0;\n\n /**\n * True if it is tracking ads.\n * @private\n */\n this._isAd = false;\n\n /**\n * Number of errors fired. 'End' resets it.\n */\n this.numberOfErrors = 0;\n\n /**\n * Number of ads shown.\n */\n this.numberOfAds = 0;\n\n /**\n * Number of videos played.\n */\n this.numberOfVideos = 0;\n\n /**\n * The amount of ms the user has been watching content (not paused, not buffering, not ads...)\n */\n this.totalPlaytime = 0;\n\n /**\n * The amount of ms the user has been watching ads during an ad break.\n */\n this.totalAdPlaytime = 0;\n\n /** True if you are in the middle of an ad break. */\n this.isAdBreak = false;\n\n /** True if initial buffering event already happened. */\n this.initialBufferingHappened = false;\n\n this.resetFlags();\n this.resetChronos();\n }\n\n /** Resets flags. */\n resetFlags() {\n /** True once the player has finished loading. */\n this.isPlayerReady = false;\n\n /** True if the video has been user-requested to play. ie: user cicks play. */\n this.isRequested = false;\n\n /** True if the video has starting playing. ie: actual images/audio showing in screen. */\n this.isStarted = false;\n\n /** True if the video is paused. */\n this.isPaused = false;\n\n /** True if the video is performing a seek action. */\n this.isSeeking = false;\n\n /** True if the video is currently buffering. */\n this.isBuffering = false;\n\n /** True if the video is currently playing (not buffering, not paused...) */\n this.isPlaying = false;\n }\n\n /** Resets chronos. */\n resetChronos() {\n /** Chrono that counts time since last requested event. */\n this.timeSinceRequested = new Chrono();\n\n /** Chrono that counts time since last start event. */\n this.timeSinceStarted = new Chrono();\n\n /** Chrono that counts time since last pause event. */\n this.timeSincePaused = new Chrono();\n\n /** Chrono that counts time since last seeking start event. */\n this.timeSinceSeekBegin = new Chrono();\n\n /** Chrono that counts time since last buffering start event. */\n this.timeSinceBufferBegin = new Chrono();\n\n /** Chrono that counts time since last ad break start event. */\n this.timeSinceAdBreakStart = new Chrono();\n\n /** Chrono that counts time since last download event. */\n this.timeSinceLastDownload = new Chrono();\n\n /** Chrono that counts time since last heartbeat. */\n this.timeSinceLastHeartbeat = new Chrono();\n\n /** Chrono that counts time since last rendition change. */\n this.timeSinceLastRenditionChange = new Chrono();\n\n /** Ads only. Chrono that counts time since last ad quartile. */\n this.timeSinceLastAdQuartile = new Chrono();\n\n /** Content only. Chrono that counts time since last AD_END. */\n this.timeSinceLastAd = new Chrono();\n\n /** Chrono that counts time since last *_RESUME. Only for buffering events. */\n this.timeSinceResumed = new Chrono();\n\n /** Chrono that counts time since last *_SEEK_END. Only for buffering events. */\n this.timeSinceSeekEnd = new Chrono();\n\n /** Chrono that counts the ammount of time the video have been playing since the last event. */\n this.playtimeSinceLastEvent = new Chrono();\n\n /** A dictionary containing the custom timeSince attributes. */\n this.customTimeSinceAttributes = {};\n\n /** This are used to collect the time of buffred and pause resume between two heartbeats */\n this.elapsedTime = new Chrono();\n this.bufferElapsedTime = new Chrono();\n }\n\n /** Returns true if the tracker is currently on ads. */\n isAd() {\n return this._isAd;\n }\n\n /** Sets if the tracker is currenlty tracking ads */\n setIsAd(isAd) {\n this._isAd = isAd;\n }\n\n /**\n * Set the Chrono for the custom attribute\n *\n * @param {object} name Time since attribute name.\n */\n setTimeSinceAttribute(name) {\n this.customTimeSinceAttributes[name] = new Chrono();\n this.customTimeSinceAttributes[name].start();\n }\n\n /**\n * Delete a time since attribute\n *\n * @param {object} name Time since attribute name.\n */\n removeTimeSinceAttribute(name) {\n delete this.customTimeSinceAttributes[name];\n }\n\n /**\n * Returns a random-generated view Session ID, useful to sort by views.\n */\n getViewSession() {\n if (!this._viewSession) {\n let time = new Date().getTime();\n let random =\n Math.random().toString(36).substring(2) +\n Math.random().toString(36).substring(2);\n\n this._viewSession = time + \"-\" + random;\n }\n\n return this._viewSession;\n }\n\n /**\n * Returns a random-generated view Session ID, plus a view count, allowing you to distinguish\n * between two videos played in the same session.\n */\n getViewId() {\n return this.getViewSession() + \"-\" + this._viewCount;\n }\n\n /**\n * Fills given object with state-based attributes.\n *\n * @param {object} att Collection fo key value attributes\n * @return {object} Filled attributes\n */\n getStateAttributes(att) {\n att = att || {};\n\n if (this.isAd()) {\n // Ads only\n if (this.isRequested) {\n att.timeSinceAdRequested = this.timeSinceRequested.getDeltaTime();\n att.timeSinceLastAdHeartbeat =\n this.timeSinceLastHeartbeat.getDeltaTime();\n }\n if (this.isStarted)\n att.timeSinceAdStarted = this.timeSinceStarted.getDeltaTime();\n if (this.isPaused)\n att.timeSinceAdPaused = this.timeSincePaused.getDeltaTime();\n if (this.isBuffering)\n att.timeSinceAdBufferBegin = this.timeSinceBufferBegin.getDeltaTime();\n if (this.isSeeking)\n att.timeSinceAdSeekBegin = this.timeSinceSeekBegin.getDeltaTime();\n if (this.isAdBreak)\n att.timeSinceAdBreakBegin = this.timeSinceAdBreakStart.getDeltaTime();\n att.numberOfAds = this.numberOfAds;\n } else {\n // Content only\n if (this.isRequested) {\n att.timeSinceRequested = this.timeSinceRequested.getDeltaTime();\n att.timeSinceLastHeartbeat = this.timeSinceLastHeartbeat.getDeltaTime();\n }\n if (this.isStarted)\n att.timeSinceStarted = this.timeSinceStarted.getDeltaTime();\n if (this.isPaused)\n att.timeSincePaused = this.timeSincePaused.getDeltaTime();\n if (this.isBuffering)\n att.timeSinceBufferBegin = this.timeSinceBufferBegin.getDeltaTime();\n if (this.isSeeking)\n att.timeSinceSeekBegin = this.timeSinceSeekBegin.getDeltaTime();\n att.timeSinceLastAd = this.timeSinceLastAd.getDeltaTime();\n att.numberOfVideos = this.numberOfVideos;\n }\n att.numberOfErrors = this.numberOfErrors;\n\n // Playtime\n if (!this.isAd()) {\n // Content only\n if (this.playtimeSinceLastEvent.startTime > 0) {\n att.playtimeSinceLastEvent = this.playtimeSinceLastEvent.getDeltaTime();\n } else {\n att.playtimeSinceLastEvent = 0;\n }\n if (this.isPlaying) {\n this.playtimeSinceLastEvent.start();\n } else {\n this.playtimeSinceLastEvent.reset();\n }\n this.totalPlaytime += att.playtimeSinceLastEvent;\n att.totalPlaytime = this.totalPlaytime;\n }\n\n for (const [key, value] of Object.entries(this.customTimeSinceAttributes)) {\n att[key] = value.getDeltaTime();\n }\n\n return att;\n }\n\n /**\n * Calculate the bufferType attribute.\n *\n * @param {boolean} isInitialBuffering Is initial buffering event.\n */\n calculateBufferType(isInitialBuffering) {\n let bufferType = \"\";\n if (isInitialBuffering) {\n bufferType = \"initial\";\n } else if (this.isSeeking) {\n bufferType = \"seek\";\n } else if (this.isPaused) {\n bufferType = \"pause\";\n } else {\n // If none of the above is true, it is a connection buffering\n bufferType = \"connection\";\n }\n Log.debug(\"Buffer Type = \" + bufferType);\n\n return bufferType;\n }\n\n /**\n * Augments view count. This will be called with each *_START and *_END.\n */\n goViewCountUp() {\n this._viewCount++;\n }\n\n /**\n * Checks flags and changes state.\n * @returns {boolean} True if the state changed.\n */\n goPlayerReady() {\n if (!this.isPlayerReady) {\n this.isPlayerReady = true;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goRequest() {\n if (!this.isRequested) {\n this.isRequested = true;\n\n this.timeSinceLastAd.reset();\n this.timeSinceRequested.start();\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goStart() {\n if (this.isRequested && !this.isStarted) {\n if (this.isAd()) {\n this.numberOfAds++;\n } else {\n this.numberOfVideos++;\n }\n this.isStarted = true;\n this.isPlaying = true;\n this.timeSinceStarted.start();\n this.playtimeSinceLastEvent.start();\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goEnd() {\n if (this.isRequested) {\n this.numberOfErrors = 0;\n this.resetFlags();\n this.timeSinceRequested.stop();\n this.timeSinceStarted.stop();\n this.playtimeSinceLastEvent.stop();\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goPause() {\n if (this.isStarted && !this.isPaused) {\n this.isPaused = true;\n this.isPlaying = false;\n this.timeSincePaused.start();\n this.playtimeSinceLastEvent.stop();\n this.timeSinceResumed.reset();\n if (this.isBuffering) {\n this._bufferAcc += this.bufferElapsedTime.getDeltaTime();\n }\n this.elapsedTime.start();\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goResume() {\n if (this.isStarted && this.isPaused) {\n this.isPaused = false;\n this.isPlaying = true;\n this.timeSincePaused.stop();\n this.timeSinceResumed.start();\n if (this._hb) {\n this._acc = this.elapsedTime.getDeltaTime();\n this._hb = false;\n } else {\n if (this.isBuffering) {\n this.bufferElapsedTime.start();\n }\n this._acc += this.elapsedTime.getDeltaTime();\n }\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goBufferStart() {\n if (this.isRequested && !this.isBuffering) {\n this.isBuffering = true;\n this.isPlaying = false;\n this.timeSinceBufferBegin.start();\n this.bufferElapsedTime.start();\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goBufferEnd() {\n if (this.isRequested && this.isBuffering) {\n this.isBuffering = false;\n this.isPlaying = true;\n this.timeSinceBufferBegin.stop();\n if (this._hb) {\n this._bufferAcc = this.bufferElapsedTime.getDeltaTime();\n this._hb = false;\n } else {\n this._bufferAcc += this.bufferElapsedTime.getDeltaTime();\n }\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goSeekStart() {\n if (this.isStarted && !this.isSeeking) {\n this.isSeeking = true;\n this.isPlaying = false;\n this.timeSinceSeekBegin.start();\n this.timeSinceSeekEnd.reset();\n\n //new\n // this.seekStartTime = Date.now();\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goSeekEnd() {\n if (this.isStarted && this.isSeeking) {\n this.isSeeking = false;\n this.isPlaying = true;\n this.timeSinceSeekBegin.stop();\n this.timeSinceSeekEnd.start();\n\n //new\n // this.seekEndTime = Date.now();\n // this.seekDuration = this.seekEndTime - this.seekStartTime;\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goAdBreakStart() {\n if (!this.isAdBreak) {\n this.isAdBreak = true;\n this.timeSinceAdBreakStart.start();\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Checks flags and changes state\n * @returns {boolean} True if the state changed.\n */\n goAdBreakEnd() {\n if (this.isAdBreak) {\n this.isRequested = false;\n this.isAdBreak = false;\n this.totalAdPlaytime = this.timeSinceAdBreakStart.getDeltaTime();\n this.timeSinceAdBreakStart.stop();\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Restarts download chrono.\n */\n goDownload() {\n this.timeSinceLastDownload.start();\n }\n\n /**\n * Restarts heartbeat chrono.\n */\n goHeartbeat() {\n this.timeSinceLastHeartbeat.start();\n }\n\n /**\n * Restarts rendition change chrono.\n */\n goRenditionChange() {\n this.timeSinceLastRenditionChange.start();\n }\n\n /**\n * Restarts ad quartile chrono.\n */\n goAdQuartile() {\n this.timeSinceLastAdQuartile.start();\n }\n\n /**\n * Increments error counter.\n */\n goError() {\n this.isError = true;\n this.numberOfErrors++;\n }\n\n /**\n * Restarts last ad chrono.\n */\n goLastAd() {\n this.timeSinceLastAd.start();\n }\n}\n\nexport default VideoTrackerState;\n","/**\n * Makes an API call with retry logic and fallback to sendBeacon for final harvests\n * @param {Object} params - Request parameters\n * @param {string} params.url - The URL to send the request to\n * @param {Object} params.payload - The payload object containing body data\n * @param {Object} params.options - Request options\n * @param {boolean} params.options.isFinalHarvest - Whether this is a final harvest on page unload\n * @param {Function} callback - Callback function to handle the response\n */\nexport function callApi({ url, payload, options = {} }, callback) {\n // Input validation\n if (!url || !payload || !callback) {\n console.error(\"callApi: Missing required parameters\");\n if (callback) callback({ retry: false, status: 0 });\n return;\n }\n\n // The Browser Agent sends the 'body' part of the payload object as the actual request body.\n let body;\n try {\n body = JSON.stringify(payload.body);\n } catch (error) {\n console.error(\"callApi: Error serializing payload\", error);\n callback({ retry: false, status: 0 });\n return;\n }\n\n // For final harvests on page unload, use sendBeacon for reliability.\n if (options.isFinalHarvest && navigator.sendBeacon) {\n try {\n const success = navigator.sendBeacon(url, body);\n // sendBeacon returns true if the request was successfully queued\n callback({ retry: !success, status: success ? 200 : 0 });\n } catch (e) {\n // sendBeacon can fail if the payload is too large.\n callback({ retry: true, status: 0 });\n }\n return;\n }\n\n fetch(url, {\n method: \"POST\",\n body: body,\n headers: {\n \"Content-Type\": \"application/json\", // More accurate content type\n },\n keepalive: options.isFinalHarvest, // Important for final harvest fallback\n })\n .then((response) => {\n // Check for statuses that indicate a retry is needed.\n const isRetry = shouldRetry(response.status);\n callback({\n retry: isRetry,\n status: response.status,\n ok: response.ok,\n });\n })\n .catch(() => {\n // Any network failure (e.g., no internet) should also trigger a retry.\n callback({ retry: true, status: 0 });\n });\n}\n\n/**\n * Determines if a request should be retried based on HTTP status code\n * @param {number} status - HTTP status code\n * @returns {boolean} - True if request should be retried\n */\nfunction shouldRetry(status) {\n switch (status) {\n case 408: // Request Timeout\n case 429: // Too Many Requests\n case 500: // Internal Server Error\n return true;\n case 401: // Unauthorized - don't retry\n case 403: // Forbidden - don't retry\n case 404: // Not Found - don't retry\n return false;\n }\n // Retry for 5xx server errors and specific ranges\n return (status >= 502 && status <= 504) || (status >= 512 && status <= 530);\n}\n\n/**\n * Calculates the size of a payload object in megabytes\n * @param {Object} obj - The object to calculate size for\n * @returns {number} - Size in megabytes, or 0 if calculation fails\n */\nexport function getPayloadSize(obj) {\n if (!obj || typeof obj !== \"object\") {\n return 0;\n }\n\n try {\n const json = JSON.stringify(obj);\n return new TextEncoder().encode(json).length / (1024 * 1024);\n } catch (error) {\n console.error(\"getPayloadSize: Error calculating payload size\", error);\n return 0;\n }\n}\n","import Log from \"./log\";\nimport { recordEvent } from \"./recordEvent\";\nimport { setAuthConfig } from \"./authConfiguration\";\n\n/**\n * Static class that sums up core functionalities of the library.\n * @static\n */\nclass Core {\n /**\n * Add a tracker to the system. Trackers added will start reporting its events to NR's backend.\n *\n * @param {(Emitter|Tracker)} tracker Tracker instance to add.\n */\n static addTracker(tracker, options) {\n setAuthConfig(options.info);\n if (tracker.on && tracker.emit) {\n trackers.push(tracker);\n tracker.on(\"*\", eventHandler);\n if (typeof tracker.trackerInit == \"function\") {\n tracker.trackerInit();\n }\n } else {\n Log.error(\"Tried to load a non-tracker.\", tracker);\n }\n }\n\n /**\n * Disposes and remove given tracker. Removes its listeners.\n *\n * @param {Tracker} tracker Tracker to remove.\n */\n static removeTracker(tracker) {\n tracker.off(\"*\", eventHandler);\n tracker.dispose();\n let index = trackers.indexOf(tracker);\n if (index !== -1) trackers.splice(index, 1);\n }\n\n /**\n * Returns the array of trackers.\n *\n * @returns {Tracker[]} Array of trackers.\n */\n static getTrackers() {\n return trackers;\n }\n\n static send(eventType, actionName, data) {\n data[\"timeSinceLoad\"] = window.performance.now() / 1000;\n recordEvent(eventType, { actionName, ...data });\n }\n\n /**\n * Sends an error event. This may be used for external errors launched by the app, the network or\n * any external factor. Note that errors within the player are normally reported with\n * tracker.sendError, so this method should not be used to report those.\n *\n * @param {object} att attributes to be sent along the error.\n */\n static sendError(att) {\n Core.send(\"ERROR\", att);\n }\n}\n\nlet trackers = [];\nlet isErrorShown = false;\n\n/**\n * Logs and sends given event.\n *\n * @private\n * @param {Event} e Event\n */\nfunction eventHandler(e) {\n let data = cleanData(e.data);\n if (Log.level <= Log.Levels.DEBUG) {\n Log.notice(\"Sent\", e.type, data);\n } else {\n Log.notice(\"Sent\", e.type);\n }\n\n Core.send(e.eventType, e.type, data);\n}\n\n/**\n * Cleans given object, removing all items with value === null.\n * @private\n * @param {Object} data Data to clean\n * @returns {Object} Cleaned object\n */\nfunction cleanData(data) {\n let ret = {};\n for (let i in data) {\n if (data[i] !== null && typeof data[i] !== \"undefined\") ret[i] = data[i];\n }\n return ret;\n}\n\nexport default Core;\n","import Constants from \"./constants\";\n\nconst { COLLECTOR } = Constants;\n\n/**\n * Validates and initializes New Relic video tracking information.\n * @param {object} info - The options object containing authentication information.\n * @param {string} info.licenseKey - The New Relic license key.\n * @param {string} [info.appName] - The name of the application (required if no applicationID).\n * @param {string} [info.region] - The region for the New Relic collector (required if no beacon).\n * @param {string} [info.beacon] - Custom beacon URL (optional, overrides region-based beacon).\n * @param {string} [info.sa] - Security attributes (optional).\n * @param {string} [info.applicationID] - Application ID for beacon-based configuration (optional).\n * @returns {boolean} True if configuration was set successfully, false otherwise.\n * @throws {Error} Throws error for invalid configuration parameters.\n */\nexport function setAuthConfig(info) {\n try {\n // Input validation\n if (!info || typeof info !== \"object\" || Array.isArray(info)) {\n throw new Error(\"setAuthConfig: info parameter must be a valid object\");\n }\n\n if (isAuthorised(info)) {\n const { licenseKey, appName, region, beacon, sa, applicationID } = info;\n\n // Initialize NRVIDEO global object\n window.NRVIDEO = window.NRVIDEO || {};\n\n // Determine beacon URL with fallback\n let beaconUrl = beacon;\n if (!beaconUrl && region) {\n if (!COLLECTOR[region]) {\n throw new Error(\n `setAuthConfig: Invalid region '${region}'. Valid regions: ${Object.keys(\n COLLECTOR\n ).join(\", \")}`\n );\n }\n beaconUrl = COLLECTOR[region];\n }\n\n window.NRVIDEO.info = {\n beacon: beaconUrl,\n licenseKey,\n applicationID: applicationID || null,\n appName: appName || null,\n sa: sa || 0,\n };\n\n return true;\n } else {\n const validationError = getValidationError(info);\n throw new Error(`setAuthConfig: ${validationError}`);\n }\n } catch (error) {\n console.error(\"setAuthConfig:\", error.message);\n return false;\n }\n}\n\n/**\n * Checks if the provided information contains valid authentication parameters.\n * @param {object} info - The options object.\n * @returns {boolean} True if authorized, false otherwise.\n */\nfunction isAuthorised(info) {\n if (!info || typeof info !== \"object\") {\n return false;\n }\n\n const { licenseKey, appName, region, applicationID, beacon } = info;\n\n // License key is always required\n if (\n !licenseKey ||\n typeof licenseKey !== \"string\" ||\n licenseKey.trim().length === 0\n ) {\n return false;\n }\n\n // Two valid configuration modes:\n // 1. applicationID + beacon (for direct beacon configuration)\n // 2. appName + region (for region-based beacon resolution)\n if (applicationID) {\n return !!(beacon && typeof beacon === \"string\" && beacon.trim().length > 0);\n }\n\n return !!(\n appName &&\n typeof appName === \"string\" &&\n appName.trim().length > 0 &&\n region &&\n typeof region === \"string\" &&\n region.trim().length > 0\n );\n}\n\n/**\n * Provides detailed validation error message for debugging.\n * @param {object} info - The options object.\n * @returns {string} Detailed error message.\n */\nfunction getValidationError(info) {\n if (!info || typeof info !== \"object\") {\n return \"info parameter must be a valid object\";\n }\n\n const { licenseKey, appName, region, applicationID, beacon } = info;\n\n if (\n !licenseKey ||\n typeof licenseKey !== \"string\" ||\n licenseKey.trim().length === 0\n ) {\n return \"licenseKey is required and must be a non-empty string\";\n }\n\n if (applicationID) {\n if (!beacon || typeof beacon !== \"string\" || beacon.trim().length === 0) {\n return \"beacon URL is required when using applicationID\";\n }\n } else {\n if (\n !appName ||\n typeof appName !== \"string\" ||\n appName.trim().length === 0\n ) {\n return \"appName is required when not using applicationID\";\n }\n if (!region || typeof region !== \"string\" || region.trim().length === 0) {\n return \"region is required when not using applicationID\";\n }\n }\n\n return \"configuration validation failed\";\n}\n","import { getPayloadSize } from \"./utils\";\nimport Constants from \"./constants\";\nconst { MAX_EVENTS_PER_BATCH, MAX_PAYLOAD_SIZE } = Constants;\n\n/**\n * A simple aggregator that queues raw events without any statistical aggregation.\n * It includes the necessary save/reload logic for the harvester's retry mechanism.\n */\nexport class NRVideoEventAggregator {\n #queue = [];\n #retryQueue = [];\n\n /**\n * Checks if the event queue is empty.\n * @returns {boolean}\n */\n isEmpty() {\n return this.#queue.length === 0 && this.#retryQueue.length === 0;\n }\n\n /**\n * Drains the entire queue and returns all events.\n * Called by the harvester to begin the chunking process.\n */\n drain() {\n const allEvents = [...this.#retryQueue, ...this.#queue];\n this.#queue = []; // Clear the active queue\n this.#retryQueue = []; // Clear the retry queue\n\n return allEvents;\n }\n\n /**\n * Adds a complete, enriched event object to the queue.\n * @param {object} eventObject - The event to queue.\n */\n add(eventObject) {\n this.#queue.push(eventObject);\n }\n\n // --- Methods for the Harvester ---\n\n /**\n * Cleans up the queue after a harvest attempt, based on the result.\n * @param {object} result - The result from the harvester, containing a 'retry' flag.\n */\n postHarvestCleanup(result) {\n if (!result.retry || !result.chunk?.length) {\n this.#retryQueue = [];\n return;\n }\n\n while (\n this.#retryQueue.length > 0 &&\n (getPayloadSize(this.#retryQueue) + getPayloadSize(result.chunk) >\n MAX_PAYLOAD_SIZE ||\n this.#retryQueue.length + result.chunk.length > MAX_EVENTS_PER_BATCH)\n ) {\n // Removes the oldest item from the retry queue to make space\n this.#retryQueue.shift();\n }\n\n // Add the entire failed chunk to the retry queue.\n this.#retryQueue.push(...result.chunk); // result.chunk will be never greater than 1mb or 1000\n }\n}\n","import { customEventAggregator } from \"./agent.js\";\nimport { getPayloadSize } from \"./utils.js\";\nimport Constants from \"./constants\";\n\nconst { VALID_EVENT_TYPES, MAX_EVENT_SIZE } = Constants;\n\n/**\n * Records a video event with the specified type and attributes\n * @param {string} eventType - The type of event to record\n * @param {Object} attributes - Additional attributes to include with the event\n * @returns {boolean} - True if event was recorded successfully, false otherwise\n */\nexport function recordEvent(eventType, attributes = {}) {\n // Input validation\n if (\n typeof eventType !== \"string\" ||\n eventType.length === 0 ||\n !VALID_EVENT_TYPES.includes(eventType)\n ) {\n console.warn(\"recordEvent: Invalid eventType provided:\", eventType);\n return false;\n }\n\n // Validate attributes parameter\n if (\n attributes !== null &&\n (typeof attributes !== \"object\" || Array.isArray(attributes))\n ) {\n console.warn(\"recordEvent: attributes must be a plain object\");\n return false;\n }\n\n // Ensure attributes is an object (handle null case)\n attributes = attributes || {};\n\n // Check if NRVIDEO is properly initialized\n if (!window.NRVIDEO || !window.NRVIDEO.info) {\n console.error(\"recordEvent: NRVIDEO not properly initialized\");\n return false;\n }\n\n try {\n const { appName } = window.NRVIDEO.info;\n\n const eventObject = {\n ...attributes,\n eventType,\n appName,\n timestamp: Date.now(),\n };\n\n // Check event size to prevent oversized payloads\n const eventSize = getPayloadSize(eventObject);\n\n if (eventSize > MAX_EVENT_SIZE) {\n console.warn(\n `recordEvent: Event size (${eventSize} bytes) exceeds maximum (${MAX_EVENT_SIZE} bytes)`\n );\n return false;\n }\n\n customEventAggregator.add(eventObject);\n return true;\n } catch (error) {\n console.error(\"recordEvent: Error recording event:\", error);\n return false;\n }\n}\n","/**\n * This class calculates time lapses between two points on time.\n */\nclass Chrono {\n /**\n * Constructor\n */\n constructor() {\n this.reset();\n }\n\n /** Reset chrono values. */\n reset() {\n /** Start time */\n this.startTime = 0;\n\n /** Stop time */\n this.stopTime = 0;\n\n /**\n * If you set an offset in a chrono, its value will be added getDeltaTime and stop.\n *\n * @example\n * let chrono = new Chrono()\n * chrono.offset = 500\n * chrono.start()\n * process.sleep(500)\n * chrono.stop() // Will return 1000\n *\n * @type {number}\n */\n this.offset = 0;\n }\n\n /**\n * Returns the time between start() and the last stop() in ms. Returns null if start wasn't\n * called.\n * @return {(number|null)} Time lapse in ms.\n */\n getDeltaTime() {\n if (this.startTime) {\n return this.offset + (new Date().getTime() - this.startTime);\n } else {\n return null;\n }\n }\n\n /**\n * Starts the chrono.\n */\n start() {\n this.startTime = new Date().getTime();\n this.stopTime = 0;\n }\n\n /**\n * Stops the timer and returns delta time.\n * @return {(number|null)} Returns the delta time\n */\n stop() {\n this.stopTime = new Date().getTime();\n return this.getDeltaTime();\n }\n\n /**\n * Creates a copy of the chrono.\n * @returns {Chrono} Cloned chrono\n */\n clone() {\n var chrono = new Chrono();\n chrono.startTime = this.startTime;\n chrono.stopTime = this.stopTime;\n chrono.offset = this.offset;\n return chrono;\n }\n}\n\nexport default Chrono;\n","import { NRVideoEventAggregator } from \"./eventAggregator.js\";\nimport { NRVideoHarvester } from \"./harvester.js\";\n\nexport const customEventAggregator = new NRVideoEventAggregator();\nconst harvester = new NRVideoHarvester(customEventAggregator);\nharvester.startTimer();\n","/**\n * This base class implements a basic behavior of listeners and events. Extend this object to have\n * this feature built-in inside your classes.\n *\n * @class Emitter\n */\nclass Emitter {\n /**\n * Sets a listener to a given event. Use {@link emit} to trigger those events.\n * Pass '*' to listen ALL events.\n *\n * @param {string} event Name of the event.\n * @param {function} callback Callback of the event. Receives event and data.\n * @return this\n */\n on(event, callback) {\n this._listeners = this._listeners || {};\n if (typeof callback === \"function\") {\n this._listeners[event] = this._listeners[event] || [];\n this._listeners[event].push(callback);\n return this;\n }\n }\n\n /**\n * Removes given callback from the listeners of this object.\n *\n * @param {string} event Name of the event.\n * @param {function} callback Callback of the event.\n * @return this\n */\n off(event, callback) {\n this._listeners = this._listeners || {};\n\n if (this._listeners[event]) {\n var index = this._listeners[event].indexOf(callback);\n if (index !== -1) {\n this._listeners[event].splice(index, 1);\n }\n }\n return this;\n }\n\n /**\n * Emits given event, triggering all the associated callbacks.\n *\n * @param {string} event Name of the event.\n * @param {object} [data] Custom data to be sent to the callbacks.\n * @return this\n */\n emit(eventType, event, data) {\n this._listeners = this._listeners || {};\n data = data || {};\n\n if (Array.isArray(this._listeners[event])) {\n this._listeners[event].forEach((callback) => {\n callback.call(this, {\n eventType,\n type: event,\n data: data,\n target: this,\n });\n });\n }\n\n if (Array.isArray(this._listeners[\"*\"])) {\n this._listeners[\"*\"].forEach((callback) => {\n callback.call(this, {\n eventType,\n type: event,\n data: data,\n target: this,\n });\n });\n }\n\n return this;\n }\n}\n\nexport default Emitter;\n","import Log from \"./log\";\nimport Tracker from \"./tracker\";\nimport TrackerState from \"./videotrackerstate\";\nimport pkg from \"../package.json\";\n\n/**\n * Base video tracker class provides extensible tracking over video elements. See {@link Tracker}.\n * Extend this class to create your own video tracker class. Override getter methods and\n * registerListeners/unregisterListeners to provide full integration with your video experience.\n *\n * @example\n * Tracker instances should be added to Core library to start sending data:\n * nrvideo.Core.addTracker(new Tracker())\n *\n * @extends Tracker\n */\nclass VideoTracker extends Tracker {\n /**\n * Constructor, receives player and options.\n * Lifecycle: constructor > {@link setOptions} > {@link setPlayer} > {@link registerListeners}.\n *\n * @param {Object} [player] Player to track. See {@link setPlayer}.\n * @param {Object} [options] Options for the tracker. See {@link setOptions}.\n */\n constructor(player, options) {\n super();\n\n /**\n * TrackerState instance. Stores the state of the view. Tracker will automatically update the\n * state of its instance, so there's no need to modify/interact with it manually.\n * @type TrackerState\n */\n this.state = new TrackerState();\n\n /**\n * Another Tracker instance to track ads.\n * @type Tracker\n */\n this.adsTracker = null;\n\n /**\n * Last bufferType value.\n * @private\n */\n this._lastBufferType = null;\n this._userId = null;\n\n options = options || {};\n this.setOptions(options);\n if (player) this.setPlayer(player, options.tag);\n\n Log.notice(\n \"Tracker \" +\n this.getTrackerName() +\n \" v\" +\n this.getTrackerVersion() +\n \" is ready.\"\n );\n }\n\n /* user can set the user Id */\n\n setUserId(userId) {\n this._userId = userId;\n }\n\n /**\n * Set options for the Tracker.\n *\n * @param {Object} [options] Options for the tracker.\n * @param {Boolean} [options.isAd] True if the tracker is tracking ads. See {@link setIsAd}.\n * @param {number} [options.heartbeat] Set time between heartbeats. See {@link heartbeat}.\n * @param {Object} [options.customData] Set custom data. See {@link customData}.\n * @param {Tracker} [options.parentTracker] Set parent tracker. See {@link parentTracker}.\n * @param {Tracker} [options.adsTracker] Set ads tracker. See {@link adsTracker}.\n * @param {Object} [options.tag] DOM element to track. See {@link setPlayer}.\n */\n setOptions(options) {\n if (options) {\n if (options.adsTracker) {\n this.setAdsTracker(options.adsTracker);\n }\n if (typeof options.isAd === \"boolean\") {\n this.setIsAd(options.isAd);\n }\n Tracker.prototype.setOptions.apply(this, arguments);\n }\n }\n\n /**\n * Set a player and/or a tag. If there was one already defined, it will call dispose() first.\n * Will call this.registerListeners() afterwards.\n *\n * @param {Object|string} player New player to save as this.player. If a string is passed,\n * document.getElementById will be called.\n * @param {DOMObject|string} [tag] Optional DOMElement to save as this.tag. If a string is passed,\n * document.getElementById will be called.\n */\n\n setPlayer(player, tag) {\n if (this.player || this.tag) this.dispose();\n\n if (typeof document !== \"undefined\" && document.getElementById) {\n if (typeof player === \"string\") player = document.getElementById(player);\n if (typeof tag === \"string\") tag = document.getElementById(tag);\n }\n\n tag = tag || player; // if no tag is passed, use player as both.\n\n this.player = player;\n this.tag = tag;\n this.registerListeners();\n }\n\n /** Returns true if the tracker is currently on ads. */\n isAd() {\n return this.state.isAd();\n }\n\n /** Sets if the tracker is currenlty tracking ads */\n setIsAd(isAd) {\n this.state.setIsAd(isAd);\n }\n\n /**\n * Use this function to set up a child ad tracker. You will be able to access it using\n * this.adsTracker.\n *\n * @param {Tracker} tracker Ad tracker to add\n */\n setAdsTracker(tracker) {\n this.disposeAdsTracker(); // dispose current one\n if (tracker) {\n this.adsTracker = tracker;\n this.adsTracker.setIsAd(true);\n this.adsTracker.parentTracker = this;\n this.adsTracker.on(\"*\", funnelAdEvents.bind(this));\n }\n }\n\n /**\n * Dispose current adsTracker.\n */\n disposeAdsTracker() {\n if (this.adsTracker) {\n this.adsTracker.off(\"*\", funnelAdEvents);\n this.adsTracker.dispose();\n }\n }\n\n /**\n * Prepares tracker to dispose. Calls unregisterListener and drops references to player and tag.\n */\n dispose() {\n this.stopHeartbeat();\n this.disposeAdsTracker();\n this.unregisterListeners();\n this.player = null;\n this.tag = null;\n }\n\n /**\n * Override this method to register listeners to player/tag.\n * @example\n * class SpecificTracker extends Tracker {\n * registerListeners() {\n * this.player.on('play', () => this.playHandler)\n * }\n *\n * playHandler() {\n * this.send(VideoTracker.Events.REQUESTED)\n * }\n * }\n */\n registerListeners() {}\n\n /**\n * Override this method to unregister listeners to player/tag created in registerListeners\n * @example\n * class SpecificTracker extends Tracker {\n * registerListeners() {\n * this.player.on('play', () => this.playHandler)\n * }\n *\n * unregisterListeners() {\n * this.player.off('play', () => this.playHandler)\n * }\n *\n * playHandler() {\n * this.send(VideoTracker.Events.REQUESTED)\n * }\n * }\n */\n unregisterListeners() {}\n\n /**\n * Trackers will generate unique id's for every new video iteration. If you have your own unique\n * view value, you can override this method to return it.\n * If the tracker has a parentTracker defined, parent viewId will be used.\n */\n getViewId() {\n if (this.parentTracker) {\n return this.parentTracker.getViewId();\n } else {\n return this.state.getViewId();\n }\n }\n\n /**\n * Trackers will generate unique id's for every new video session. If you have your own unique\n * view value, you can override this method to return it.\n * If the tracker has a parentTracker defined, parent viewId will be used.\n */\n getViewSession() {\n if (this.parentTracker) {\n return this.parentTracker.getViewSession();\n } else {\n return this.state.getViewSession();\n }\n }\n\n /** Override to return the Id of the video. */\n getVideoId() {\n return null;\n }\n\n /** Override to return Title of the video. */\n getTitle() {\n return null;\n }\n\n /** Override to return True if the video is live. */\n isLive() {\n return null;\n }\n\n /** Override to return Bitrate (in bits) of the video. */\n getBitrate() {\n return null;\n }\n\n /** Calculates consumed bitrate using webkitVideoDecodedByteCount. */\n getWebkitBitrate() {\n if (this.tag && this.tag.webkitVideoDecodedByteCount) {\n let bitrate;\n if (this._lastWebkitBitrate) {\n bitrate = this.tag.webkitVideoDecodedByteCount;\n let delta = bitrate - this._lastWebkitBitrate;\n let seconds = this.getHeartbeat() / 1000;\n bitrate = Math.round((delta / seconds) * 8);\n }\n this._lastWebkitBitrate = this.tag.webkitVideoDecodedByteCount;\n return bitrate || null;\n }\n }\n\n /** Override to return Name of the rendition (ie: 1080p). */\n getRenditionName() {\n return null;\n }\n\n /** Override to return Target Bitrate of the rendition. */\n getRenditionBitrate() {\n return null;\n }\n\n /**\n * This method will return 'up', 'down' or null depending on if the bitrate of the rendition\n * have changed from the last time it was called.\n *\n * @param {boolean} [saveNewRendition=false] If true, current rendition will be stored to be used\n * the next time this method is called. This allows you to call this.getRenditionShift() without\n * saving the current rendition and thus preventing interferences with RENDITION_CHANGE events.\n */\n getRenditionShift(saveNewRendition) {\n let current = this.getRenditionBitrate();\n let last;\n if (this.isAd()) {\n last = this._lastAdRendition;\n if (saveNewRendition) this._lastAdRendition = current;\n } else {\n last = this._lastRendition;\n if (saveNewRendition) this._lastRendition = current;\n }\n\n if (!current || !last) {\n return null;\n } else {\n if (current > last) {\n return \"up\";\n } else if (current < last) {\n return \"down\";\n } else {\n return null;\n }\n }\n }\n\n /** Override to return renidtion actual Height (before re-scaling). */\n getRenditionHeight() {\n return this.tag ? this.tag.videoHeight : null;\n }\n\n /** Override to return rendition actual Width (before re-scaling). */\n getRenditionWidth() {\n return this.tag ? this.tag.videoWidth : null;\n }\n\n /** Override to return Duration of the video, in ms. */\n getDuration() {\n return this.tag ? this.tag.duration : null;\n }\n\n /** Override to return Playhead (currentTime) of the video, in ms. */\n getPlayhead() {\n return this.tag ? this.tag.currentTime : null;\n }\n\n /**\n * Override to return Language of the video. We recommend using locale notation, ie: en_US.\n * {@see https://gist.github.com/jacobbubu/1836273}\n */\n getLanguage() {\n return null;\n }\n\n /** Override to return URL of the resource being played. */\n getSrc() {\n return this.tag ? this.tag.currentSrc : null;\n }\n\n /** Override to return Playrate (speed) of the video. ie: 1.0, 0.5, 1.25... */\n getPlayrate() {\n return this.tag ? this.tag.playbackRate : null;\n }\n\n /** Override to return True if the video is currently muted. */\n isMuted() {\n return this.tag ? this.tag.muted : null;\n }\n\n /** Override to return True if the video is currently fullscreen. */\n isFullscreen() {\n return null;\n }\n\n /** Override to return the CDN serving the content. */\n getCdn() {\n return null;\n }\n\n /** Override to return the Name of the player. */\n getPlayerName() {\n return this.getTrackerName();\n }\n\n /** Override to return the Version of the player. */\n getPlayerVersion() {\n return pkg.version;\n }\n\n /** Override to return current FPS (Frames per second). */\n getFps() {\n return null;\n }\n\n /**\n * Override to return if the player was autoplayed. By default: this.tag.autoplay\n */\n isAutoplayed() {\n return this.tag ? this.tag.autoplay : null;\n }\n\n /**\n * Override to return the player preload attribute. By default: this.tag.preload\n */\n getPreload() {\n return this.tag ? this.tag.preload : null;\n }\n\n // Only for ads\n /**\n * Override to return Quartile of the ad. 0 before first, 1 after first quartile, 2 after\n * midpoint, 3 after third quartile, 4 when completed.\n */\n getAdQuartile() {\n return null;\n }\n\n /**\n * Override to return the position of the ad. Use {@link Constants.AdPositions} enum\n * to fill this data.\n */\n getAdPosition() {\n if (this.parentTracker) {\n return this.parentTracker.state.isStarted ? \"mid\" : \"pre\";\n } else {\n return null;\n }\n }\n\n /**\n * Override to return the ad partner. ie: ima, freewheel...\n */\n getAdPartner() {\n return null;\n }\n\n /**\n * Override to return the creative id of the ad.\n */\n getAdCreativeId() {\n return null;\n }\n\n /**\n * Override to return the instrumentation of the player.\n */\n\n getInstrumentationProvider() {\n return null;\n }\n\n getInstrumentationName() {\n return null;\n }\n\n getInstrumentationVersion() {\n return null;\n }\n\n /**\n * Do NOT override. This method fills all the appropiate attributes for tracked video.\n *\n * @param {object} [att] Collection of key value attributes\n * @return {object} Filled attributes\n * @final\n */\n getAttributes(att, type) {\n att = Tracker.prototype.getAttributes.apply(this, arguments);\n\n if (typeof att.isAd === \"undefined\") att.isAd = this.isAd();\n\n att.viewSession = this.getViewSession();\n att.viewId = this.getViewId();\n att.playerName = this.getPlayerName();\n att.playerVersion = this.getPlayerVersion();\n att[\"instrumentation.provider\"] = this.getInstrumentationProvider();\n att[\"instrumentation.name\"] = this.getInstrumentationName();\n att[\"instrumentation.version\"] = this.getInstrumentationVersion();\n att[\"enduser.id\"] = this._userId;\n att[\"src\"] = \"Browser\";\n\n if (type === \"customAction\") return att;\n\n try {\n att.pageUrl = window.location.href;\n } catch (err) {\n /* skip */\n }\n\n if (this.isAd()) {\n // Ads\n att.adId = this.getVideoId();\n att.adTitle = this.getTitle();\n att.adSrc = this.getSrc();\n att.adCdn = this.getCdn();\n att.adBitrate =\n this.getBitrate() ||\n this.getWebkitBitrate() ||\n this.getRenditionBitrate();\n att.adRenditionName = this.getRenditionName();\n att.adRenditionBitrate = this.getRenditionBitrate();\n att.adRenditionHeight = this.getRenditionHeight();\n att.adRenditionWidth = this.getRenditionWidth();\n att.adDuration = this.getDuration();\n att.adPlayhead = this.getPlayhead();\n att.adLanguage = this.getLanguage();\n att.adIsMuted = this.isMuted();\n att.adFps = this.getFps();\n // ad exclusives\n //att.adQuartile = this.getAdQuartile();\n att.adPosition = this.getAdPosition();\n att.adCreativeId = this.getAdCreativeId();\n att.adPartner = this.getAdPartner();\n } else {\n // no ads\n att.contentId = this.getVideoId();\n att.contentTitle = this.getTitle();\n att.contentSrc = this.getSrc();\n att.contentCdn = this.getCdn();\n att.contentPlayhead = this.getPlayhead();\n\n att.contentIsLive = this.isLive();\n att.contentBitrate =\n this.getBitrate() ||\n this.getWebkitBitrate() ||\n this.getRenditionBitrate();\n att.contentRenditionName = this.getRenditionName();\n att.contentRenditionBitrate = this.getRenditionBitrate();\n att.contentRenditionHeight = this.getRenditionHeight();\n att.contentRenditionWidth = this.getRenditionWidth();\n att.contentDuration = this.getDuration();\n\n att.contentLanguage = this.getLanguage();\n att.contentPlayrate = this.getPlayrate();\n att.contentIsFullscreen = this.isFullscreen();\n att.contentIsMuted = this.isMuted();\n att.contentIsAutoplayed = this.isAutoplayed();\n att.contentPreload = this.getPreload();\n att.contentFps = this.getFps();\n\n if (\n this.adsTracker != null &&\n this.adsTracker.state.totalAdPlaytime > 0\n ) {\n att.totalAdPlaytime = this.adsTracker.state.totalAdPlaytime;\n }\n }\n\n this.state.getStateAttributes(att);\n\n for (let key in this.customData) {\n att[key] = this.customData[key];\n }\n\n return att;\n }\n\n /**\n * Sends custom event and registers a timeSince attribute.\n * @param {Object} [actionName] Custom action name.\n * @param {Object} [timeSinceAttName] Custom timeSince attribute name.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendCustom(actionName, timeSinceAttName, att) {\n att = att || {};\n this.sendVideoCustomAction(actionName, att);\n this.state.setTimeSinceAttribute(timeSinceAttName);\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendPlayerReady(att) {\n if (this.state.goPlayerReady()) {\n att = att || {};\n this.sendVideoAction(VideoTracker.Events.PLAYER_READY, att);\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners. Calls\n * {@link startHeartbeat}.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendRequest(att) {\n if (this.state.goRequest()) {\n let ev;\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_REQUEST;\n this.sendVideoAdAction(ev, att);\n } else {\n ev = VideoTracker.Events.CONTENT_REQUEST;\n this.sendVideoAction(ev, att);\n }\n\n // this.startHeartbeat();\n // this.state.goHeartbeat();\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendStart(att) {\n if (this.state.goStart()) {\n let ev;\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_START;\n if (this.parentTracker) this.parentTracker.state.isPlaying = false;\n this.sendVideoAdAction(ev, att);\n } else {\n ev = VideoTracker.Events.CONTENT_START;\n this.sendVideoAction(ev, att);\n }\n //this.send(ev, att);\n this.startHeartbeat();\n this.state.goHeartbeat();\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners. Calls\n * {@link stopHeartbeat}.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendEnd(att) {\n if (this.state.goEnd()) {\n att = att || {};\n let ev;\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_END;\n att.timeSinceAdRequested = this.state.timeSinceRequested.getDeltaTime();\n att.timeSinceAdStarted = this.state.timeSinceStarted.getDeltaTime();\n if (this.parentTracker) this.parentTracker.state.isPlaying = true;\n } else {\n ev = VideoTracker.Events.CONTENT_END;\n att.timeSinceRequested = this.state.timeSinceRequested.getDeltaTime();\n att.timeSinceStarted = this.state.timeSinceStarted.getDeltaTime();\n }\n this.stopHeartbeat();\n //this.send(ev, att);\n this.isAd()\n ? this.sendVideoAdAction(ev, att)\n : this.sendVideoAction(ev, att);\n\n if (this.parentTracker && this.isAd())\n this.parentTracker.state.goLastAd();\n this.state.goViewCountUp();\n this.state.totalPlaytime = 0;\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendPause(att) {\n if (this.state.goPause()) {\n let ev = this.isAd()\n ? VideoTracker.Events.AD_PAUSE\n : VideoTracker.Events.CONTENT_PAUSE;\n\n this.isAd()\n ? this.sendVideoAdAction(ev, att)\n : this.sendVideoAction(ev, att);\n\n //this.send(ev, att);\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendResume(att) {\n if (this.state.goResume()) {\n att = att || {};\n let ev;\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_RESUME;\n att.timeSinceAdPaused = this.state.timeSincePaused.getDeltaTime();\n } else {\n ev = VideoTracker.Events.CONTENT_RESUME;\n att.timeSincePaused = this.state.timeSincePaused.getDeltaTime();\n }\n //this.send(ev, att);\n this.isAd()\n ? this.sendVideoAdAction(ev, att)\n : this.sendVideoAction(ev, att);\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendBufferStart(att) {\n if (this.state.goBufferStart()) {\n att = att || {};\n let ev;\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_BUFFER_START;\n } else {\n ev = VideoTracker.Events.CONTENT_BUFFER_START;\n }\n\n att = this.buildBufferAttributes(att);\n this._lastBufferType = att.bufferType;\n\n //this.send(ev, att);\n this.isAd()\n ? this.sendVideoAdAction(ev, att)\n : this.sendVideoAction(ev, att);\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendBufferEnd(att) {\n if (this.state.goBufferEnd()) {\n att = att || {};\n let ev;\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_BUFFER_END;\n att.timeSinceAdBufferBegin =\n this.state.timeSinceBufferBegin.getDeltaTime();\n } else {\n ev = VideoTracker.Events.CONTENT_BUFFER_END;\n att.timeSinceBufferBegin =\n this.state.timeSinceBufferBegin.getDeltaTime();\n }\n\n att = this.buildBufferAttributes(att);\n // Set the bufferType attribute of the last BUFFER_START\n if (this._lastBufferType != null) {\n att.bufferType = this._lastBufferType;\n }\n\n // this.send(ev, att);\n this.isAd()\n ? this.sendVideoAdAction(ev, att)\n : this.sendVideoAction(ev, att);\n this.state.initialBufferingHappened = true;\n }\n }\n\n buildBufferAttributes(att) {\n if (att.timeSinceStarted == undefined || att.timeSinceStarted < 100) {\n att.isInitialBuffering = !this.state.initialBufferingHappened;\n } else {\n att.isInitialBuffering = false;\n }\n\n att.bufferType = this.state.calculateBufferType(att.isInitialBuffering);\n\n att.timeSinceResumed = this.state.timeSinceResumed.getDeltaTime();\n att.timeSinceSeekEnd = this.state.timeSinceSeekEnd.getDeltaTime();\n\n return att;\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendSeekStart(att) {\n if (this.state.goSeekStart()) {\n let ev;\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_SEEK_START;\n } else {\n ev = VideoTracker.Events.CONTENT_SEEK_START;\n }\n // this.send(ev, att);\n\n this.isAd()\n ? this.sendVideoAdAction(ev, att)\n : this.sendVideoAction(ev, att);\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendSeekEnd(att) {\n if (this.state.goSeekEnd()) {\n att = att || {};\n let ev;\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_SEEK_END;\n att.timeSinceAdSeekBegin = this.state.timeSinceSeekBegin.getDeltaTime();\n } else {\n ev = VideoTracker.Events.CONTENT_SEEK_END;\n att.timeSinceSeekBegin = this.state.timeSinceSeekBegin.getDeltaTime();\n }\n // this.send(ev, att);\n\n this.isAd()\n ? this.sendVideoAdAction(ev, att)\n : this.sendVideoAction(ev, att);\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n * @param {String} att.state Download requires a string to distinguish different states.\n */\n sendDownload(att) {\n att = att || {};\n if (!att.state) Log.warn(\"Called sendDownload without { state: xxxxx }.\");\n this.sendVideoAction(VideoTracker.Events.DOWNLOAD, att);\n this.state.goDownload();\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendError(att) {\n att = att || {};\n\n att.isAd = this.isAd();\n this.state.goError();\n let ev = this.isAd()\n ? VideoTracker.Events.AD_ERROR\n : VideoTracker.Events.CONTENT_ERROR;\n //this.send(ev, att);\n\n this.sendVideoErrorAction(ev, att);\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendRenditionChanged(att) {\n att = att || {};\n att.timeSinceLastRenditionChange =\n this.state.timeSinceLastRenditionChange.getDeltaTime();\n att.shift = this.getRenditionShift(true);\n let ev;\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_RENDITION_CHANGE;\n } else {\n ev = VideoTracker.Events.CONTENT_RENDITION_CHANGE;\n }\n //this.send(ev, att);\n\n this.isAd()\n ? this.sendVideoAdAction(ev, att)\n : this.sendVideoAction(ev, att);\n\n this.state.goRenditionChange();\n }\n\n /**\n * Sends associated event and changes view state. Heartbeat will automatically be sent every\n * 10 seconds. There's no need to call this manually.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n * @param {number} att.url Url of the clicked ad.\n *\n */\n sendHeartbeat(att) {\n if (this.state.isRequested) {\n let ev;\n\n let elapsedTime = this.getHeartbeat();\n this.state._hb = true;\n elapsedTime = this.adjustElapsedTimeForPause(elapsedTime);\n\n if (this.isAd()) {\n ev = VideoTracker.Events.AD_HEARTBEAT;\n if (this.getPlayerName() === \"bitmovin-ads\") {\n this.sendVideoAdAction(ev, att);\n } else {\n this.sendVideoAdAction(ev, { elapsedTime, ...att });\n }\n } else {\n ev = VideoTracker.Events.CONTENT_HEARTBEAT;\n this.sendVideoAction(ev, { elapsedTime, ...att });\n }\n this.state.goHeartbeat();\n }\n }\n\n adjustElapsedTimeForPause(elapsedTime) {\n if (this.state._acc) {\n elapsedTime -= this.state._acc;\n this.state._acc = 0;\n }\n\n if (this.state.isPaused) {\n elapsedTime -= this.state.elapsedTime.getDeltaTime();\n if (elapsedTime < 10) elapsedTime = 0;\n this.state.elapsedTime.start();\n }\n\n if (this.state._bufferAcc) {\n elapsedTime -= this.state._bufferAcc;\n this.state._bufferAcc = 0;\n } else if (this.state.isBuffering) {\n elapsedTime -= this.state.bufferElapsedTime.getDeltaTime();\n if (elapsedTime < 5) {\n elapsedTime = 0;\n }\n this.state.bufferElapsedTime.start();\n }\n\n return Math.max(0, elapsedTime);\n }\n\n // Only ads\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendAdBreakStart(att) {\n if (this.isAd() && this.state.goAdBreakStart()) {\n this.state.totalAdPlaytime = 0;\n if (this.parentTracker) this.parentTracker.state.isPlaying = false;\n // this.send(VideoTracker.Events.AD_BREAK_START, att);\n this.sendVideoAdAction(VideoTracker.Events.AD_BREAK_START, att);\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n */\n sendAdBreakEnd(att) {\n if (this.isAd() && this.state.goAdBreakEnd()) {\n att = att || {};\n att.timeSinceAdBreakBegin =\n this.state.timeSinceAdBreakStart.getDeltaTime();\n //this.send(VideoTracker.Events.AD_BREAK_END, att);\n this.sendVideoAdAction(VideoTracker.Events.AD_BREAK_END, att);\n // Just in case AD_END not arriving, because of an AD_ERROR\n if (this.parentTracker) this.parentTracker.state.isPlaying = true;\n this.stopHeartbeat();\n if (this.parentTracker && this.isAd())\n this.parentTracker.state.goLastAd();\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n * @param {number} att.quartile Number of the quartile.\n */\n sendAdQuartile(att) {\n if (this.isAd()) {\n att = att || {};\n if (!att.quartile)\n Log.warn(\"Called sendAdQuartile without { quartile: xxxxx }.\");\n att.timeSinceLastAdQuartile =\n this.state.timeSinceLastAdQuartile.getDeltaTime();\n //this.send(VideoTracker.Events.AD_QUARTILE, att);\n\n this.sendVideoAdAction(VideoTracker.Events.AD_QUARTILE, att);\n this.state.goAdQuartile();\n }\n }\n\n /**\n * Sends associated event and changes view state. An internal state machine will prevent\n * duplicated events. Should be associated to an event using registerListeners.\n * @param {Object} [att] Collection of key:value attributes to send with the request.\n * @param {number} att.url Url of the clicked ad.\n */\n sendAdClick(att) {\n if (this.isAd()) {\n att = att || {};\n if (!att.url) Log.warn(\"Called sendAdClick without { url: xxxxx }.\");\n //this.send(VideoTracker.Events.AD_CLICK, att);\n this.sendVideoAdAction(VideoTracker.Events.AD_CLICK, att);\n }\n }\n}\n\n/**\n * Enumeration of events fired by this class.\n *\n * @static\n * @memberof VideoTracker\n * @enum {String}\n */\nVideoTracker.Events = {\n // Player\n /** The player is ready to start sending events. */\n PLAYER_READY: \"PLAYER_READY\",\n /** Downloading data. */\n DOWNLOAD: \"DOWNLOAD\",\n /** An error happened */\n ERROR: \"ERROR\",\n\n // Video\n /** Content video has been requested. */\n CONTENT_REQUEST: \"CONTENT_REQUEST\",\n /** Content video started (first frame shown). */\n CONTENT_START: \"CONTENT_START\",\n /** Content video ended. */\n CONTENT_END: \"CONTENT_END\",\n /** Content video paused. */\n CONTENT_PAUSE: \"CONTENT_PAUSE\",\n /** Content video resumed. */\n CONTENT_RESUME: \"CONTENT_RESUME\",\n /** Content video seek started */\n CONTENT_SEEK_START: \"CONTENT_SEEK_START\",\n /** Content video seek ended. */\n CONTENT_SEEK_END: \"CONTENT_SEEK_END\",\n /** Content video beffering started */\n CONTENT_BUFFER_START: \"CONTENT_BUFFER_START\",\n /** Content video buffering ended */\n CONTENT_BUFFER_END: \"CONTENT_BUFFER_END\",\n /** Content video heartbeat, en event that happens once every 30 seconds while the video is playing. */\n CONTENT_HEARTBEAT: \"CONTENT_HEARTBEAT\",\n /** Content video stream qwuality changed. */\n CONTENT_RENDITION_CHANGE: \"CONTENT_RENDITION_CHANGE\",\n /** Content video error. */\n CONTENT_ERROR: \"CONTENT_ERROR\",\n\n // Ads only\n /** Ad video has been requested. */\n AD_REQUEST: \"AD_REQUEST\",\n /** Ad video started (first frame shown). */\n AD_START: \"AD_START\",\n /** Ad video ended. */\n AD_END: \"AD_END\",\n /** Ad video paused. */\n AD_PAUSE: \"AD_PAUSE\",\n /** Ad video resumed. */\n AD_RESUME: \"AD_RESUME\",\n /** Ad video seek started */\n AD_SEEK_START: \"AD_SEEK_START\",\n /** Ad video seek ended */\n AD_SEEK_END: \"AD_SEEK_END\",\n /** Ad video beffering started */\n AD_BUFFER_START: \"AD_BUFFER_START\",\n /** Ad video beffering ended */\n AD_BUFFER_END: \"AD_BUFFER_END\",\n /** Ad video heartbeat, en event that happens once every 30 seconds while the video is playing. */\n AD_HEARTBEAT: \"AD_HEARTBEAT\",\n /** Ad video stream qwuality changed. */\n AD_RENDITION_CHANGE: \"AD_RENDITION_CHANGE\",\n /** Ad video error. */\n AD_ERROR: \"AD_ERROR\",\n /** Ad break (a block of ads) started. */\n AD_BREAK_START: \"AD_BREAK_START\",\n /** Ad break ended. */\n AD_BREAK_END: \"AD_BREAK_END\",\n /** Ad quartile happened. */\n AD_QUARTILE: \"AD_QUARTILE\",\n /** Ad has been clicked. */\n AD_CLICK: \"AD_CLICK\",\n};\n\n// Private members\nfunction funnelAdEvents(e) {\n if (e.type === VideoTracker.Events.AD_ERROR) {\n this.sendVideoErrorAction(e.type, e.data);\n return;\n }\n this.sendVideoAdAction(e.type, e.data);\n}\n\nexport default VideoTracker;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","import Core from \"./core\";\nimport Constants from \"./constants\";\nimport Chrono from \"./chrono\";\nimport Log from \"./log\";\nimport Emitter from \"./emitter\";\nimport Tracker from \"./tracker\";\nimport VideoTracker from \"./videotracker\";\nimport VideoTrackerState from \"./videotrackerstate\";\nimport { version } from \"../package.json\";\n\nconst nrvideo = {\n Constants,\n Chrono,\n Log,\n Emitter,\n Tracker,\n VideoTracker,\n VideoTrackerState,\n Core,\n version,\n};\nexport default nrvideo;\n"],"names":["Constants","AdPositions","PRE","MID","POST","INTERVAL","MAX_EVENTS_PER_BATCH","MAX_PAYLOAD_SIZE","MAX_BEACON_SIZE","MAX_EVENT_SIZE","VALID_EVENT_TYPES","COLLECTOR","US","EU","Stage","GOV","exports","Log","error","msg","_report","Levels","ERROR","warn","WARNING","notice","slice","call","arguments","NOTICE","debug","DEBUG","debugCommonVideoEvents","o","extraEvents","report","level","e","type","playerEvents","shift","concat","i","length","window","on","addEventListener","addEventHandler","err","color","d","logMethod","prefix","includeTime","Date","getDate","getMinutes","getSeconds","getMilliseconds","_getCurrentTime","_letters","_level2letter","SILENT","colorful","document","documentMode","_plainReport","console","undefined","cast","log","splice","apply","Array","m","ALL","location","search","exec","_loadLevelFromUrl","_package","_interopRequireDefault","require","_emitter","_chrono","_constants","__esModule","default","Tracker","Emitter","constructor","options","super","this","customData","heartbeat","parentTracker","_trackerReadyChrono","Chrono","start","_actionTable","ACTION_TABLE","_actionAdTable","ACTION_AD_TABLE","setOptions","dispose","unregisterListeners","registerListeners","getHeartbeat","state","_isAd","startHeartbeat","_heartbeatInterval","setInterval","sendHeartbeat","bind","Math","max","stopHeartbeat","clearInterval","att","sendVideoAction","Events","HEARTBEAT","getAttributes","eventType","trackerName","getTrackerName","trackerVersion","getTrackerVersion","coreVersion","pkg","version","timeSinceTrackerReady","getDeltaTime","key","hidden","isBackgroundEvent","event","emit","sendVideoAdAction","sendVideoErrorAction","ev","isAd","sendVideoCustomAction","_utils","aggregate","triggerHarvest","isFinalHarvest","startTimer","onHarvestInterval","setTimeout","stopTimer","clearTimeout","isEmpty","allEvents","drain","maxChunkSize","chunks","chunkEvents","forEach","chunk","index","isLastChunk","sendChunk","events","currentChunk","push","getPayloadSize","ins","lastEvent","pop","url","postHarvestCleanup","retry","status","payload","body","callApi","result","NRVIDEO","info","Error","beacon","licenseKey","applicationID","sa","href","message","_log","reset","_createdAt","now","_hb","_acc","_bufferAcc","_viewSession","_viewCount","numberOfErrors","numberOfAds","numberOfVideos","totalPlaytime","totalAdPlaytime","isAdBreak","initialBufferingHappened","resetFlags","resetChronos","isPlayerReady","isRequested","isStarted","isPaused","isSeeking","isBuffering","isPlaying","timeSinceRequested","timeSinceStarted","timeSincePaused","timeSinceSeekBegin","timeSinceBufferBegin","timeSinceAdBreakStart","timeSinceLastDownload","timeSinceLastHeartbeat","timeSinceLastRenditionChange","timeSinceLastAdQuartile","timeSinceLastAd","timeSinceResumed","timeSinceSeekEnd","playtimeSinceLastEvent","customTimeSinceAttributes","elapsedTime","bufferElapsedTime","setIsAd","setTimeSinceAttribute","name","removeTimeSinceAttribute","getViewSession","time","getTime","random","toString","substring","getViewId","getStateAttributes","timeSinceAdRequested","timeSinceLastAdHeartbeat","timeSinceAdStarted","timeSinceAdPaused","timeSinceAdBufferBegin","timeSinceAdSeekBegin","timeSinceAdBreakBegin","startTime","value","Object","entries","calculateBufferType","isInitialBuffering","bufferType","goViewCountUp","goPlayerReady","goRequest","goStart","goEnd","stop","goPause","goResume","goBufferStart","goBufferEnd","goSeekStart","goSeekEnd","goAdBreakStart","goAdBreakEnd","goDownload","goHeartbeat","goRenditionChange","goAdQuartile","goError","isError","goLastAd","callback","JSON","stringify","navigator","sendBeacon","success","fetch","method","headers","keepalive","then","response","isRetry","shouldRetry","ok","catch","obj","json","TextEncoder","encode","_recordEvent","_authConfiguration","Core","addTracker","tracker","setAuthConfig","trackers","eventHandler","trackerInit","removeTracker","off","indexOf","getTrackers","send","actionName","data","performance","recordEvent","sendError","ret","cleanData","isArray","appName","region","trim","isAuthorised","beaconUrl","keys","join","validationError","getValidationError","add","eventObject","attributes","includes","timestamp","eventSize","customEventAggregator","_agent","stopTime","offset","clone","chrono","_eventAggregator","_harvester","NRVideoEventAggregator","NRVideoHarvester","_listeners","target","_tracker","_videotrackerstate","VideoTracker","player","TrackerState","adsTracker","_lastBufferType","_userId","setPlayer","tag","setUserId","userId","setAdsTracker","prototype","getElementById","disposeAdsTracker","funnelAdEvents","getVideoId","getTitle","isLive","getBitrate","getWebkitBitrate","webkitVideoDecodedByteCount","bitrate","_lastWebkitBitrate","delta","seconds","round","getRenditionName","getRenditionBitrate","getRenditionShift","saveNewRendition","last","current","_lastAdRendition","_lastRendition","getRenditionHeight","videoHeight","getRenditionWidth","videoWidth","getDuration","duration","getPlayhead","currentTime","getLanguage","getSrc","currentSrc","getPlayrate","playbackRate","isMuted","muted","isFullscreen","getCdn","getPlayerName","getPlayerVersion","getFps","isAutoplayed","autoplay","getPreload","preload","getAdQuartile","getAdPosition","getAdPartner","getAdCreativeId","getInstrumentationProvider","getInstrumentationName","getInstrumentationVersion","viewSession","viewId","playerName","playerVersion","pageUrl","adId","adTitle","adSrc","adCdn","adBitrate","adRenditionName","adRenditionBitrate","adRenditionHeight","adRenditionWidth","adDuration","adPlayhead","adLanguage","adIsMuted","adFps","adPosition","adCreativeId","adPartner","contentId","contentTitle","contentSrc","contentCdn","contentPlayhead","contentIsLive","contentBitrate","contentRenditionName","contentRenditionBitrate","contentRenditionHeight","contentRenditionWidth","contentDuration","contentLanguage","contentPlayrate","contentIsFullscreen","contentIsMuted","contentIsAutoplayed","contentPreload","contentFps","sendCustom","timeSinceAttName","sendPlayerReady","PLAYER_READY","sendRequest","AD_REQUEST","CONTENT_REQUEST","sendStart","AD_START","CONTENT_START","sendEnd","AD_END","CONTENT_END","sendPause","AD_PAUSE","CONTENT_PAUSE","sendResume","AD_RESUME","CONTENT_RESUME","sendBufferStart","AD_BUFFER_START","CONTENT_BUFFER_START","buildBufferAttributes","sendBufferEnd","AD_BUFFER_END","CONTENT_BUFFER_END","sendSeekStart","AD_SEEK_START","CONTENT_SEEK_START","sendSeekEnd","AD_SEEK_END","CONTENT_SEEK_END","sendDownload","DOWNLOAD","AD_ERROR","CONTENT_ERROR","sendRenditionChanged","AD_RENDITION_CHANGE","CONTENT_RENDITION_CHANGE","adjustElapsedTimeForPause","AD_HEARTBEAT","CONTENT_HEARTBEAT","sendAdBreakStart","AD_BREAK_START","sendAdBreakEnd","AD_BREAK_END","sendAdQuartile","quartile","AD_QUARTILE","sendAdClick","AD_CLICK","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","module","__webpack_modules__","_core","_videotracker","nrvideo","VideoTrackerState"],"sourceRoot":""}
@@ -0,0 +1,3 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ var e={51:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{}i.AdPositions={PRE:"pre",MID:"mid",POST:"post"},i.INTERVAL=1e4,i.MAX_EVENTS_PER_BATCH=1e3,i.MAX_PAYLOAD_SIZE=1,i.MAX_BEACON_SIZE=.0625,i.MAX_EVENT_SIZE=.0625,i.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],i.COLLECTOR={US:"bam-cell.nr-data.net",EU:"bam.eu01.nr-data.net",Stage:"staging-bam-cell.nr-data.net",GOV:"gov-bam.nr-data.net"},t.default=i},144:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{static error(...e){s(e,i.Levels.ERROR,"darkred")}static warn(...e){s(e,i.Levels.WARNING,"darkorange")}static notice(...e){s([].slice.call(arguments),i.Levels.NOTICE,"darkcyan")}static debug(...e){s(e,i.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(e,t,s){try{if(i.level<=i.Levels.DEBUG){s=s||function(e){i.debug("Event: "+e.type)};var n=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];t&&(null===t[0]?(t.shift(),n=t):n=n.concat(t));for(var r=0;r<n.length;r++)"function"==typeof e?e.call(window,n[r],s):e.on?e.on(n[r],s):e.addEventListener?e.addEventListener(n[r],s):e.addEventHandler?e.addEventHandler(n[r],s):i.warn("debugCommonVideoEvents: No common listener function found for ",e)}}catch(e){i.warn(e)}}}function s(e,t,s){t=t||i.Levels.NOTICE,s=s||"darkcyan";var a,o,d=i.prefix;i.includeTime&&(d+="["+("0"+(a=new Date).getDate()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)+":"+("0"+a.getSeconds()).slice(-2)+"."+("00"+a.getMilliseconds()).slice(-3)+"] "),d+=function(e){return r[e]}(t)+":",i.level<=t&&t!==i.Levels.SILENT&&(!i.colorful||"undefined"!=typeof document&&document.documentMode?n(e,d):(o=t===i.Levels.ERROR&&console.error?console.error:t===i.Levels.WARNING&&console.warn?console.warn:t===i.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,d="%c"+d,e.splice(0,0,d,"color: "+s),o.apply(console,e)))}function n(e,t){if(e instanceof Array)for(var i in e)n(e[i],t);else"string"==typeof e?console.log(t+" "+e):(console.log(t+"↵"),console.log(e))}i.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},i.level=i.Levels.ERROR,i.colorful=!0,i.includeTime=!0,i.prefix="[nrvideo]";const r={4:"e",3:"w",2:"n",1:"d"};!function(){if("undefined"!=typeof window&&window.location&&window.location.search){var e=/\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);null!==e&&("true"===e[1]?i.level=i.Levels.ALL:i.level=e[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(i.colorful=!1)}}(),t.default=i},302:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(i(330)),n=o(i(568)),r=o(i(455)),a=o(i(51));function o(e){return e&&e.__esModule?e:{default:e}}class d extends n.default{constructor(e){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new r.default,this._trackerReadyChrono.start(),this._actionTable=a.default.ACTION_TABLE,this._actionAdTable=a.default.ACTION_AD_TABLE,e=e||{},this.setOptions(e)}setOptions(e){e&&(e.parentTracker&&(this.parentTracker=e.parentTracker),e.customData&&(this.customData=e.customData),e.heartbeat&&(this.heartbeat=e.heartbeat))}dispose(){this.unregisterListeners()}registerListeners(){}unregisterListeners(){}getHeartbeat(){return this.state._isAd?2e3:this.heartbeat?this.heartbeat:this.parentTracker&&this.parentTracker.heartbeat?this.parentTracker.heartbeat:3e4}startHeartbeat(){this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),Math.max(this.getHeartbeat(),2e3))}stopHeartbeat(){this._heartbeatInterval&&clearInterval(this._heartbeatInterval)}sendHeartbeat(e){this.sendVideoAction(d.Events.HEARTBEAT,e)}getAttributes(e,t){(e=e||{}).trackerName=this.getTrackerName(),e.trackerVersion=this.getTrackerVersion(),e.coreVersion=s.default.version,e.timeSinceTrackerReady=this._trackerReadyChrono.getDeltaTime();for(let t in this.customData)e[t]=this.customData[t];return null!=document.hidden&&(e.isBackgroundEvent=document.hidden),e}getTrackerVersion(){return s.default.version}getTrackerName(){return"base-tracker"}sendVideoAction(e,t){this.emit("VideoAction",e,this.getAttributes(t))}sendVideoAdAction(e,t){this.emit("VideoAdAction",e,this.getAttributes(t))}sendVideoErrorAction(e,t){let i=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",e,this.getAttributes(t,i))}sendVideoCustomAction(e,t){this.emit("VideoCustomAction",e,this.getAttributes(t,"customAction"))}}d.Events={HEARTBEAT:"HEARTBEAT"},t.default=d},324:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NRVideoHarvester=void 0;var s=a(i(51)),n=a(i(330)),r=i(347);function a(e){return e&&e.__esModule?e:{default:e}}const{INTERVAL:o,MAX_EVENTS_PER_BATCH:d,MAX_PAYLOAD_SIZE:l,MAX_BEACON_SIZE:h}=s.default;t.NRVideoHarvester=class{#e=!1;#t;#i=null;constructor(e){this.#t=e,window.addEventListener("pagehide",(()=>this.triggerHarvest({isFinalHarvest:!0})))}startTimer(){if(this.#e)return;this.#e=!0;const e=()=>{this.triggerHarvest({}),this.#e&&(this.#i=setTimeout(e,o))};this.#i=setTimeout(e,o)}stopTimer(){this.#e=!1,this.#i&&(clearTimeout(this.#i),this.#i=null)}triggerHarvest(e={}){if(!this.#t.isEmpty())try{const t=this.#t.drain(),i=e.isFinalHarvest?h:l,s=this.chunkEvents(t,i);s.forEach(((t,i)=>{const n=i===s.length-1;this.sendChunk(t,e,n)}))}catch(e){console.error("Error during harvest:",e)}}chunkEvents(e,t){const i=[];let s=[];for(const n of e)if(s.length>=d&&(i.push(s),s=[]),s.push(n),(0,r.getPayloadSize)({ins:s})>t){const e=s.pop();s.length>0&&i.push(s),s=[e]}return s.length>0&&i.push(s),i}sendChunk(e,t,i){const s=this.#s();if(!s)return void this.#t.postHarvestCleanup({retry:!1,status:0});const n={body:{ins:e}};(0,r.callApi)({url:s,payload:n,options:t},(t=>{t.retry&&(t.chunk=e),this.#t.postHarvestCleanup(t)}))}#s(){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");const{beacon:e,licenseKey:t,applicationID:i,sa:s}=window.NRVIDEO.info;if(!e||!t||!i)throw new Error("Options object provided by New Relic is not correctly initialized");return`https://${e}/ins/1/${t}?a=${i}&v=${n.default.version}&ref=${window.location.href}&ca=VA`}catch(e){return console.error(e.message),null}}}},328:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(455)),n=r(i(144));function r(e){return e&&e.__esModule?e:{default:e}}t.default=class{constructor(){this.reset(),this._createdAt=Date.now(),this._hb=!0,this._acc=0,this._bufferAcc=0}reset(){this._viewSession=null,this._viewCount=0,this._isAd=!1,this.numberOfErrors=0,this.numberOfAds=0,this.numberOfVideos=0,this.totalPlaytime=0,this.totalAdPlaytime=0,this.isAdBreak=!1,this.initialBufferingHappened=!1,this.resetFlags(),this.resetChronos()}resetFlags(){this.isPlayerReady=!1,this.isRequested=!1,this.isStarted=!1,this.isPaused=!1,this.isSeeking=!1,this.isBuffering=!1,this.isPlaying=!1}resetChronos(){this.timeSinceRequested=new s.default,this.timeSinceStarted=new s.default,this.timeSincePaused=new s.default,this.timeSinceSeekBegin=new s.default,this.timeSinceBufferBegin=new s.default,this.timeSinceAdBreakStart=new s.default,this.timeSinceLastDownload=new s.default,this.timeSinceLastHeartbeat=new s.default,this.timeSinceLastRenditionChange=new s.default,this.timeSinceLastAdQuartile=new s.default,this.timeSinceLastAd=new s.default,this.timeSinceResumed=new s.default,this.timeSinceSeekEnd=new s.default,this.playtimeSinceLastEvent=new s.default,this.customTimeSinceAttributes={},this.elapsedTime=new s.default,this.bufferElapsedTime=new s.default}isAd(){return this._isAd}setIsAd(e){this._isAd=e}setTimeSinceAttribute(e){this.customTimeSinceAttributes[e]=new s.default,this.customTimeSinceAttributes[e].start()}removeTimeSinceAttribute(e){delete this.customTimeSinceAttributes[e]}getViewSession(){if(!this._viewSession){let e=(new Date).getTime(),t=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this._viewSession=e+"-"+t}return this._viewSession}getViewId(){return this.getViewSession()+"-"+this._viewCount}getStateAttributes(e){e=e||{},this.isAd()?(this.isRequested&&(e.timeSinceAdRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastAdHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceAdStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSinceAdPaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceAdBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceAdSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),this.isAdBreak&&(e.timeSinceAdBreakBegin=this.timeSinceAdBreakStart.getDeltaTime()),e.numberOfAds=this.numberOfAds):(this.isRequested&&(e.timeSinceRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSincePaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),e.timeSinceLastAd=this.timeSinceLastAd.getDeltaTime(),e.numberOfVideos=this.numberOfVideos),e.numberOfErrors=this.numberOfErrors,this.isAd()||(this.playtimeSinceLastEvent.startTime>0?e.playtimeSinceLastEvent=this.playtimeSinceLastEvent.getDeltaTime():e.playtimeSinceLastEvent=0,this.isPlaying?this.playtimeSinceLastEvent.start():this.playtimeSinceLastEvent.reset(),this.totalPlaytime+=e.playtimeSinceLastEvent,e.totalPlaytime=this.totalPlaytime);for(const[t,i]of Object.entries(this.customTimeSinceAttributes))e[t]=i.getDeltaTime();return e}calculateBufferType(e){let t="";return t=e?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",n.default.debug("Buffer Type = "+t),t}goViewCountUp(){this._viewCount++}goPlayerReady(){return!this.isPlayerReady&&(this.isPlayerReady=!0,!0)}goRequest(){return!this.isRequested&&(this.isRequested=!0,this.timeSinceLastAd.reset(),this.timeSinceRequested.start(),!0)}goStart(){return!(!this.isRequested||this.isStarted||(this.isAd()?this.numberOfAds++:this.numberOfVideos++,this.isStarted=!0,this.isPlaying=!0,this.timeSinceStarted.start(),this.playtimeSinceLastEvent.start(),0))}goEnd(){return!!this.isRequested&&(this.numberOfErrors=0,this.resetFlags(),this.timeSinceRequested.stop(),this.timeSinceStarted.stop(),this.playtimeSinceLastEvent.stop(),!0)}goPause(){return!(!this.isStarted||this.isPaused||(this.isPaused=!0,this.isPlaying=!1,this.timeSincePaused.start(),this.playtimeSinceLastEvent.stop(),this.timeSinceResumed.reset(),this.isBuffering&&(this._bufferAcc+=this.bufferElapsedTime.getDeltaTime()),this.elapsedTime.start(),0))}goResume(){return!(!this.isStarted||!this.isPaused||(this.isPaused=!1,this.isPlaying=!0,this.timeSincePaused.stop(),this.timeSinceResumed.start(),this._hb?(this._acc=this.elapsedTime.getDeltaTime(),this._hb=!1):(this.isBuffering&&this.bufferElapsedTime.start(),this._acc+=this.elapsedTime.getDeltaTime()),0))}goBufferStart(){return!(!this.isRequested||this.isBuffering||(this.isBuffering=!0,this.isPlaying=!1,this.timeSinceBufferBegin.start(),this.bufferElapsedTime.start(),0))}goBufferEnd(){return!(!this.isRequested||!this.isBuffering||(this.isBuffering=!1,this.isPlaying=!0,this.timeSinceBufferBegin.stop(),this._hb?(this._bufferAcc=this.bufferElapsedTime.getDeltaTime(),this._hb=!1):this._bufferAcc+=this.bufferElapsedTime.getDeltaTime(),0))}goSeekStart(){return!(!this.isStarted||this.isSeeking||(this.isSeeking=!0,this.isPlaying=!1,this.timeSinceSeekBegin.start(),this.timeSinceSeekEnd.reset(),0))}goSeekEnd(){return!(!this.isStarted||!this.isSeeking||(this.isSeeking=!1,this.isPlaying=!0,this.timeSinceSeekBegin.stop(),this.timeSinceSeekEnd.start(),0))}goAdBreakStart(){return!this.isAdBreak&&(this.isAdBreak=!0,this.timeSinceAdBreakStart.start(),!0)}goAdBreakEnd(){return!!this.isAdBreak&&(this.isRequested=!1,this.isAdBreak=!1,this.totalAdPlaytime=this.timeSinceAdBreakStart.getDeltaTime(),this.timeSinceAdBreakStart.stop(),!0)}goDownload(){this.timeSinceLastDownload.start()}goHeartbeat(){this.timeSinceLastHeartbeat.start()}goRenditionChange(){this.timeSinceLastRenditionChange.start()}goAdQuartile(){this.timeSinceLastAdQuartile.start()}goError(){this.isError=!0,this.numberOfErrors++}goLastAd(){this.timeSinceLastAd.start()}}},330:e=>{e.exports=JSON.parse('{"name":"@newrelic/video-core","version":"3.2.0-beta-1","description":"New Relic video tracking core library","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","scripts":{"build":"webpack --mode production","build:dev":"webpack --mode development","watch":"webpack --mode production --progress --color --watch","watch:dev":"webpack --progress --color --watch","clean":"rm -rf dist coverage doc","test":"nyc --reporter=html --reporter=text mocha --require @babel/register","doc":"jsdoc -c jsdoc.json -d documentation","deploy":"node scripts/deploy.js","third-party-updates":"oss third-party manifest --includeOptDeps && oss third-party notices --includeOptDeps && git add THIRD_PARTY_NOTICES.md third_party_manifest.json"},"repository":{"type":"git","url":"https://github.com/newrelic/video-core-js"},"author":"Jordi Aguilar","contributors":["Andreu Santarén Llop"],"license":"Apache-2.0","devDependencies":{"@babel/core":"^7.24.5","@babel/plugin-transform-modules-commonjs":"^7.24.1","@babel/preset-env":"^7.24.5","@babel/register":"^7.24.6","@newrelic/newrelic-oss-cli":"^0.1.2","aws-sdk":"^2.920.0","babel-loader":"^9.1.3","chai":"^4.3.4","diff":"^5.0.0","jsdom":"^25.0.1","mocha":"^10.4.0","nyc":"^15.1.0","sinon":"^2.4.1","webpack":"^5.91.0","webpack-cli":"^4.9.2"},"files":["THIRD_PARTY_NOTICES.md","dist","src","CHANGELOG.md","LICENSE","README.md","!test"],"publishConfig":{"access":"public"}}')},347:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.callApi=function({url:e,payload:t,options:i={}},s){if(!e||!t||!s)return console.error("callApi: Missing required parameters"),void(s&&s({retry:!1,status:0}));let n;try{n=JSON.stringify(t.body)}catch(e){return console.error("callApi: Error serializing payload",e),void s({retry:!1,status:0})}if(i.isFinalHarvest&&navigator.sendBeacon)try{const t=navigator.sendBeacon(e,n);s({retry:!t,status:t?200:0})}catch(e){s({retry:!0,status:0})}else fetch(e,{method:"POST",body:n,headers:{"Content-Type":"application/json"},keepalive:i.isFinalHarvest}).then((e=>{const t=function(e){switch(e){case 408:case 429:case 500:return!0;case 401:case 403:case 404:return!1}return e>=502&&e<=504||e>=512&&e<=530}(e.status);s({retry:t,status:e.status,ok:e.ok})})).catch((()=>{s({retry:!0,status:0})}))},t.getPayloadSize=function(e){if(!e||"object"!=typeof e)return 0;try{const t=JSON.stringify(e);return(new TextEncoder).encode(t).length/1048576}catch(e){return console.error("getPayloadSize: Error calculating payload size",e),0}}},399:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,n=(s=i(144))&&s.__esModule?s:{default:s},r=i(449),a=i(418);class o{static addTracker(e,t){(0,a.setAuthConfig)(t.info),e.on&&e.emit?(d.push(e),e.on("*",l),"function"==typeof e.trackerInit&&e.trackerInit()):n.default.error("Tried to load a non-tracker.",e)}static removeTracker(e){e.off("*",l),e.dispose();let t=d.indexOf(e);-1!==t&&d.splice(t,1)}static getTrackers(){return d}static send(e,t,i){i.timeSinceLoad=window.performance.now()/1e3,(0,r.recordEvent)(e,{actionName:t,...i})}static sendError(e){o.send("ERROR",e)}}let d=[];function l(e){let t=function(e){let t={};for(let i in e)null!==e[i]&&void 0!==e[i]&&(t[i]=e[i]);return t}(e.data);n.default.level<=n.default.Levels.DEBUG?n.default.notice("Sent",e.type,t):n.default.notice("Sent",e.type),o.send(e.eventType,e.type,t)}t.default=o},418:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setAuthConfig=function(e){try{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("setAuthConfig: info parameter must be a valid object");if(function(e){if(!e||"object"!=typeof e)return!1;const{licenseKey:t,appName:i,region:s,applicationID:n,beacon:r}=e;return!(!t||"string"!=typeof t||0===t.trim().length)&&(n?!!(r&&"string"==typeof r&&r.trim().length>0):!!(i&&"string"==typeof i&&i.trim().length>0&&s&&"string"==typeof s&&s.trim().length>0))}(e)){const{licenseKey:t,appName:i,region:s,beacon:n,sa:a,applicationID:o}=e;window.NRVIDEO=window.NRVIDEO||{};let d=n;if(!d&&s){if(!r[s])throw new Error(`setAuthConfig: Invalid region '${s}'. Valid regions: ${Object.keys(r).join(", ")}`);d=r[s]}return window.NRVIDEO.info={beacon:d,licenseKey:t,applicationID:o||null,appName:i||null,sa:a||0},!0}{const t=function(e){if(!e||"object"!=typeof e)return"info parameter must be a valid object";const{licenseKey:t,appName:i,region:s,applicationID:n,beacon:r}=e;if(!t||"string"!=typeof t||0===t.trim().length)return"licenseKey is required and must be a non-empty string";if(n){if(!r||"string"!=typeof r||0===r.trim().length)return"beacon URL is required when using applicationID"}else{if(!i||"string"!=typeof i||0===i.trim().length)return"appName is required when not using applicationID";if(!s||"string"!=typeof s||0===s.trim().length)return"region is required when not using applicationID"}return"configuration validation failed"}(e);throw new Error(`setAuthConfig: ${t}`)}}catch(e){return console.error("setAuthConfig:",e.message),!1}};var s,n=(s=i(51))&&s.__esModule?s:{default:s};const{COLLECTOR:r}=n.default},431:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NRVideoEventAggregator=void 0;var s,n=i(347),r=(s=i(51))&&s.__esModule?s:{default:s};const{MAX_EVENTS_PER_BATCH:a,MAX_PAYLOAD_SIZE:o}=r.default;t.NRVideoEventAggregator=class{#n=[];#r=[];isEmpty(){return 0===this.#n.length&&0===this.#r.length}drain(){const e=[...this.#r,...this.#n];return this.#n=[],this.#r=[],e}add(e){this.#n.push(e)}postHarvestCleanup(e){if(e.retry&&e.chunk?.length){for(;this.#r.length>0&&((0,n.getPayloadSize)(this.#r)+(0,n.getPayloadSize)(e.chunk)>o||this.#r.length+e.chunk.length>a);)this.#r.shift();this.#r.push(...e.chunk)}else this.#r=[]}}},449:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.recordEvent=function(e,t={}){if("string"!=typeof e||0===e.length||!o.includes(e))return console.warn("recordEvent: Invalid eventType provided:",e),!1;if(null!==t&&("object"!=typeof t||Array.isArray(t)))return console.warn("recordEvent: attributes must be a plain object"),!1;if(t=t||{},!window.NRVIDEO||!window.NRVIDEO.info)return console.error("recordEvent: NRVIDEO not properly initialized"),!1;try{const{appName:i}=window.NRVIDEO.info,s={...t,eventType:e,appName:i,timestamp:Date.now()},a=(0,r.getPayloadSize)(s);return a>d?(console.warn(`recordEvent: Event size (${a} bytes) exceeds maximum (${d} bytes)`),!1):(n.customEventAggregator.add(s),!0)}catch(e){return console.error("recordEvent: Error recording event:",e),!1}};var s,n=i(487),r=i(347),a=(s=i(51))&&s.__esModule?s:{default:s};const{VALID_EVENT_TYPES:o,MAX_EVENT_SIZE:d}=a.default},455:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(){this.reset()}reset(){this.startTime=0,this.stopTime=0,this.offset=0}getDeltaTime(){return this.startTime?this.offset+((new Date).getTime()-this.startTime):null}start(){this.startTime=(new Date).getTime(),this.stopTime=0}stop(){return this.stopTime=(new Date).getTime(),this.getDeltaTime()}clone(){var e=new i;return e.startTime=this.startTime,e.stopTime=this.stopTime,e.offset=this.offset,e}}t.default=i},487:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.customEventAggregator=void 0;var s=i(431),n=i(324);const r=t.customEventAggregator=new s.NRVideoEventAggregator;new n.NRVideoHarvester(r).startTimer()},568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,t.default=class{on(e,t){if(this._listeners=this._listeners||{},"function"==typeof t)return this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t),this}off(e,t){if(this._listeners=this._listeners||{},this._listeners[e]){var i=this._listeners[e].indexOf(t);-1!==i&&this._listeners[e].splice(i,1)}return this}emit(e,t,i){return this._listeners=this._listeners||{},i=i||{},Array.isArray(this._listeners[t])&&this._listeners[t].forEach((s=>{s.call(this,{eventType:e,type:t,data:i,target:this})})),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach((s=>{s.call(this,{eventType:e,type:t,data:i,target:this})})),this}}},793:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(i(144)),n=o(i(302)),r=o(i(328)),a=o(i(330));function o(e){return e&&e.__esModule?e:{default:e}}class d extends n.default{constructor(e,t){super(),this.state=new r.default,this.adsTracker=null,this._lastBufferType=null,this._userId=null,t=t||{},this.setOptions(t),e&&this.setPlayer(e,t.tag),s.default.notice("Tracker "+this.getTrackerName()+" v"+this.getTrackerVersion()+" is ready.")}setUserId(e){this._userId=e}setOptions(e){e&&(e.adsTracker&&this.setAdsTracker(e.adsTracker),"boolean"==typeof e.isAd&&this.setIsAd(e.isAd),n.default.prototype.setOptions.apply(this,arguments))}setPlayer(e,t){(this.player||this.tag)&&this.dispose(),"undefined"!=typeof document&&document.getElementById&&("string"==typeof e&&(e=document.getElementById(e)),"string"==typeof t&&(t=document.getElementById(t))),t=t||e,this.player=e,this.tag=t,this.registerListeners()}isAd(){return this.state.isAd()}setIsAd(e){this.state.setIsAd(e)}setAdsTracker(e){this.disposeAdsTracker(),e&&(this.adsTracker=e,this.adsTracker.setIsAd(!0),this.adsTracker.parentTracker=this,this.adsTracker.on("*",l.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",l),this.adsTracker.dispose())}dispose(){this.stopHeartbeat(),this.disposeAdsTracker(),this.unregisterListeners(),this.player=null,this.tag=null}registerListeners(){}unregisterListeners(){}getViewId(){return this.parentTracker?this.parentTracker.getViewId():this.state.getViewId()}getViewSession(){return this.parentTracker?this.parentTracker.getViewSession():this.state.getViewSession()}getVideoId(){return null}getTitle(){return null}isLive(){return null}getBitrate(){return null}getWebkitBitrate(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){let e;if(this._lastWebkitBitrate){e=this.tag.webkitVideoDecodedByteCount;let t=e-this._lastWebkitBitrate,i=this.getHeartbeat()/1e3;e=Math.round(t/i*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,e||null}}getRenditionName(){return null}getRenditionBitrate(){return null}getRenditionShift(e){let t,i=this.getRenditionBitrate();return this.isAd()?(t=this._lastAdRendition,e&&(this._lastAdRendition=i)):(t=this._lastRendition,e&&(this._lastRendition=i)),i&&t?i>t?"up":i<t?"down":null:null}getRenditionHeight(){return this.tag?this.tag.videoHeight:null}getRenditionWidth(){return this.tag?this.tag.videoWidth:null}getDuration(){return this.tag?this.tag.duration:null}getPlayhead(){return this.tag?this.tag.currentTime:null}getLanguage(){return null}getSrc(){return this.tag?this.tag.currentSrc:null}getPlayrate(){return this.tag?this.tag.playbackRate:null}isMuted(){return this.tag?this.tag.muted:null}isFullscreen(){return null}getCdn(){return null}getPlayerName(){return this.getTrackerName()}getPlayerVersion(){return a.default.version}getFps(){return null}isAutoplayed(){return this.tag?this.tag.autoplay:null}getPreload(){return this.tag?this.tag.preload:null}getAdQuartile(){return null}getAdPosition(){return this.parentTracker?this.parentTracker.state.isStarted?"mid":"pre":null}getAdPartner(){return null}getAdCreativeId(){return null}getInstrumentationProvider(){return null}getInstrumentationName(){return null}getInstrumentationVersion(){return null}getAttributes(e,t){if(void 0===(e=n.default.prototype.getAttributes.apply(this,arguments)).isAd&&(e.isAd=this.isAd()),e.viewSession=this.getViewSession(),e.viewId=this.getViewId(),e.playerName=this.getPlayerName(),e.playerVersion=this.getPlayerVersion(),e["instrumentation.provider"]=this.getInstrumentationProvider(),e["instrumentation.name"]=this.getInstrumentationName(),e["instrumentation.version"]=this.getInstrumentationVersion(),e["enduser.id"]=this._userId,e.src="Browser","customAction"===t)return e;try{e.pageUrl=window.location.href}catch(e){}this.isAd()?(e.adId=this.getVideoId(),e.adTitle=this.getTitle(),e.adSrc=this.getSrc(),e.adCdn=this.getCdn(),e.adBitrate=this.getBitrate()||this.getWebkitBitrate()||this.getRenditionBitrate(),e.adRenditionName=this.getRenditionName(),e.adRenditionBitrate=this.getRenditionBitrate(),e.adRenditionHeight=this.getRenditionHeight(),e.adRenditionWidth=this.getRenditionWidth(),e.adDuration=this.getDuration(),e.adPlayhead=this.getPlayhead(),e.adLanguage=this.getLanguage(),e.adIsMuted=this.isMuted(),e.adFps=this.getFps(),e.adPosition=this.getAdPosition(),e.adCreativeId=this.getAdCreativeId(),e.adPartner=this.getAdPartner()):(e.contentId=this.getVideoId(),e.contentTitle=this.getTitle(),e.contentSrc=this.getSrc(),e.contentCdn=this.getCdn(),e.contentPlayhead=this.getPlayhead(),e.contentIsLive=this.isLive(),e.contentBitrate=this.getBitrate()||this.getWebkitBitrate()||this.getRenditionBitrate(),e.contentRenditionName=this.getRenditionName(),e.contentRenditionBitrate=this.getRenditionBitrate(),e.contentRenditionHeight=this.getRenditionHeight(),e.contentRenditionWidth=this.getRenditionWidth(),e.contentDuration=this.getDuration(),e.contentLanguage=this.getLanguage(),e.contentPlayrate=this.getPlayrate(),e.contentIsFullscreen=this.isFullscreen(),e.contentIsMuted=this.isMuted(),e.contentIsAutoplayed=this.isAutoplayed(),e.contentPreload=this.getPreload(),e.contentFps=this.getFps(),null!=this.adsTracker&&this.adsTracker.state.totalAdPlaytime>0&&(e.totalAdPlaytime=this.adsTracker.state.totalAdPlaytime)),this.state.getStateAttributes(e);for(let t in this.customData)e[t]=this.customData[t];return e}sendCustom(e,t,i){i=i||{},this.sendVideoCustomAction(e,i),this.state.setTimeSinceAttribute(t)}sendPlayerReady(e){this.state.goPlayerReady()&&(e=e||{},this.sendVideoAction(d.Events.PLAYER_READY,e))}sendRequest(e){if(this.state.goRequest()){let t;this.isAd()?(t=d.Events.AD_REQUEST,this.sendVideoAdAction(t,e)):(t=d.Events.CONTENT_REQUEST,this.sendVideoAction(t,e))}}sendStart(e){if(this.state.goStart()){let t;this.isAd()?(t=d.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(t,e)):(t=d.Events.CONTENT_START,this.sendVideoAction(t,e)),this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(e){if(this.state.goEnd()){let t;e=e||{},this.isAd()?(t=d.Events.AD_END,e.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0)):(t=d.Events.CONTENT_END,e.timeSinceRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceStarted=this.state.timeSinceStarted.getDeltaTime()),this.stopHeartbeat(),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd(),this.state.goViewCountUp(),this.state.totalPlaytime=0}}sendPause(e){if(this.state.goPause()){let t=this.isAd()?d.Events.AD_PAUSE:d.Events.CONTENT_PAUSE;this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendResume(e){if(this.state.goResume()){let t;e=e||{},this.isAd()?(t=d.Events.AD_RESUME,e.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(t=d.Events.CONTENT_RESUME,e.timeSincePaused=this.state.timeSincePaused.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferStart(e){if(this.state.goBufferStart()){let t;e=e||{},t=this.isAd()?d.Events.AD_BUFFER_START:d.Events.CONTENT_BUFFER_START,e=this.buildBufferAttributes(e),this._lastBufferType=e.bufferType,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferEnd(e){if(this.state.goBufferEnd()){let t;e=e||{},this.isAd()?(t=d.Events.AD_BUFFER_END,e.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(t=d.Events.CONTENT_BUFFER_END,e.timeSinceBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()),e=this.buildBufferAttributes(e),null!=this._lastBufferType&&(e.bufferType=this._lastBufferType),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.initialBufferingHappened=!0}}buildBufferAttributes(e){return null==e.timeSinceStarted||e.timeSinceStarted<100?e.isInitialBuffering=!this.state.initialBufferingHappened:e.isInitialBuffering=!1,e.bufferType=this.state.calculateBufferType(e.isInitialBuffering),e.timeSinceResumed=this.state.timeSinceResumed.getDeltaTime(),e.timeSinceSeekEnd=this.state.timeSinceSeekEnd.getDeltaTime(),e}sendSeekStart(e){if(this.state.goSeekStart()){let t;t=this.isAd()?d.Events.AD_SEEK_START:d.Events.CONTENT_SEEK_START,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendSeekEnd(e){if(this.state.goSeekEnd()){let t;e=e||{},this.isAd()?(t=d.Events.AD_SEEK_END,e.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(t=d.Events.CONTENT_SEEK_END,e.timeSinceSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendDownload(e){(e=e||{}).state||s.default.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(d.Events.DOWNLOAD,e),this.state.goDownload()}sendError(e){(e=e||{}).isAd=this.isAd(),this.state.goError();let t=this.isAd()?d.Events.AD_ERROR:d.Events.CONTENT_ERROR;this.sendVideoErrorAction(t,e)}sendRenditionChanged(e){let t;(e=e||{}).timeSinceLastRenditionChange=this.state.timeSinceLastRenditionChange.getDeltaTime(),e.shift=this.getRenditionShift(!0),t=this.isAd()?d.Events.AD_RENDITION_CHANGE:d.Events.CONTENT_RENDITION_CHANGE,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.goRenditionChange()}sendHeartbeat(e){if(this.state.isRequested){let t,i=this.getHeartbeat();this.state._hb=!0,i=this.adjustElapsedTimeForPause(i),this.isAd()?(t=d.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(t,e):this.sendVideoAdAction(t,{elapsedTime:i,...e})):(t=d.Events.CONTENT_HEARTBEAT,this.sendVideoAction(t,{elapsedTime:i,...e})),this.state.goHeartbeat()}}adjustElapsedTimeForPause(e){return this.state._acc&&(e-=this.state._acc,this.state._acc=0),this.state.isPaused&&((e-=this.state.elapsedTime.getDeltaTime())<10&&(e=0),this.state.elapsedTime.start()),this.state._bufferAcc?(e-=this.state._bufferAcc,this.state._bufferAcc=0):this.state.isBuffering&&((e-=this.state.bufferElapsedTime.getDeltaTime())<5&&(e=0),this.state.bufferElapsedTime.start()),Math.max(0,e)}sendAdBreakStart(e){this.isAd()&&this.state.goAdBreakStart()&&(this.state.totalAdPlaytime=0,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(d.Events.AD_BREAK_START,e))}sendAdBreakEnd(e){this.isAd()&&this.state.goAdBreakEnd()&&((e=e||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(d.Events.AD_BREAK_END,e),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.stopHeartbeat(),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd())}sendAdQuartile(e){this.isAd()&&((e=e||{}).quartile||s.default.warn("Called sendAdQuartile without { quartile: xxxxx }."),e.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(d.Events.AD_QUARTILE,e),this.state.goAdQuartile())}sendAdClick(e){this.isAd()&&((e=e||{}).url||s.default.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(d.Events.AD_CLICK,e))}}function l(e){e.type!==d.Events.AD_ERROR?this.sendVideoAdAction(e.type,e.data):this.sendVideoErrorAction(e.type,e.data)}d.Events={PLAYER_READY:"PLAYER_READY",DOWNLOAD:"DOWNLOAD",ERROR:"ERROR",CONTENT_REQUEST:"CONTENT_REQUEST",CONTENT_START:"CONTENT_START",CONTENT_END:"CONTENT_END",CONTENT_PAUSE:"CONTENT_PAUSE",CONTENT_RESUME:"CONTENT_RESUME",CONTENT_SEEK_START:"CONTENT_SEEK_START",CONTENT_SEEK_END:"CONTENT_SEEK_END",CONTENT_BUFFER_START:"CONTENT_BUFFER_START",CONTENT_BUFFER_END:"CONTENT_BUFFER_END",CONTENT_HEARTBEAT:"CONTENT_HEARTBEAT",CONTENT_RENDITION_CHANGE:"CONTENT_RENDITION_CHANGE",CONTENT_ERROR:"CONTENT_ERROR",AD_REQUEST:"AD_REQUEST",AD_START:"AD_START",AD_END:"AD_END",AD_PAUSE:"AD_PAUSE",AD_RESUME:"AD_RESUME",AD_SEEK_START:"AD_SEEK_START",AD_SEEK_END:"AD_SEEK_END",AD_BUFFER_START:"AD_BUFFER_START",AD_BUFFER_END:"AD_BUFFER_END",AD_HEARTBEAT:"AD_HEARTBEAT",AD_RENDITION_CHANGE:"AD_RENDITION_CHANGE",AD_ERROR:"AD_ERROR",AD_BREAK_START:"AD_BREAK_START",AD_BREAK_END:"AD_BREAK_END",AD_QUARTILE:"AD_QUARTILE",AD_CLICK:"AD_CLICK"},t.default=d}},t={};function i(s){var n=t[s];if(void 0!==n)return n.exports;var r=t[s]={exports:{}};return e[s](r,r.exports,i),r.exports}var s={};(()=>{var e=s;Object.defineProperty(e,"B",{value:!0}),e.A=void 0;var t=c(i(399)),n=c(i(51)),r=c(i(455)),a=c(i(144)),o=c(i(568)),d=c(i(302)),l=c(i(793)),h=c(i(328)),u=i(330);function c(e){return e&&e.__esModule?e:{default:e}}const g={Constants:n.default,Chrono:r.default,Log:a.default,Emitter:o.default,Tracker:d.default,VideoTracker:l.default,VideoTrackerState:h.default,Core:t.default,version:u.version};e.A=g})();const n=s.B,r=s.A;export{n as __esModule,r as default};
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * @license Apache-2.0
3
+ * @newrelic/video-core 3.2.0-beta-1
4
+ * Copyright New Relic <http://newrelic.com/>
5
+ * @author Jordi Aguilar
6
+ */