@bitmovin/player-integration-conviva
Advanced tools
Comparing version 6.1.1 to 6.1.2
@@ -10,2 +10,7 @@ # Changelog | ||
## [6.1.2] - 2024-12-24 | ||
### Fixed | ||
- Delayed buffering reporting on CSAI events | ||
- Reporting of ad break ended for SSAI ads | ||
## [6.1.1] - 2024-12-19 | ||
@@ -168,3 +173,4 @@ ### Fixed | ||
[Unreleased]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v6.1.1...HEAD | ||
[Unreleased]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v6.1.2...HEAD | ||
[6.1.2]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v6.1.1...v6.1.2 | ||
[6.1.1]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v6.1.0...v6.1.1 | ||
@@ -171,0 +177,0 @@ [6.1.0]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v6.0.0...v6.1.0 |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@convivainc/conviva-js-coresdk"),require("bitmovin-player")):"function"==typeof define&&define.amd?define("bitmovin-player-analytics-conviva",["@convivainc/conviva-js-coresdk","bitmovin-player"],e):"object"==typeof exports?exports["bitmovin-player-analytics-conviva"]=e(require("@convivainc/conviva-js-coresdk"),require("bitmovin-player")):(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player.analytics=e(t.Conviva,t.bitmovin.player))}(window,function(t,e){return function(t){var e={};function a(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,a),n.l=!0,n.exports}return a.m=t,a.c=e,a.d=function(t,e,i){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(a.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(i,n,function(e){return t[e]}.bind(null,n));return i},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=6)}([function(e,a){e.exports=t},function(t,a){t.exports=e},function(t,e,a){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,a=1,i=arguments.length;a<i;a++)for(var n in e=arguments[a])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.AdHelper=void 0;var n=a(0),r=a(3),o=function(){function t(){}return t.mapCsaiAdPosition=function(t,e){return t.scheduleTime<=0?n.Constants.AdPosition.PREROLL:t.scheduleTime>=e?n.Constants.AdPosition.POSTROLL:n.Constants.AdPosition.MIDROLL},t.formatCsaiAdError=function(t){var e,a,i=(null==t?void 0:t.message)||"Unknown message",n=(null==t?void 0:t.name)||"Unknown name";return["Ad error:","".concat(n,";"),(null===(e=t.data)||void 0===e?void 0:e.code)?"Ad error code: ".concat(null===(a=t.data)||void 0===a?void 0:a.code,";"):void 0,"Message:","".concat(i,";"),"Error code: ".concat(t.code,";"),t.troubleShootLink?"Troubleshoot link: ".concat(t.troubleShootLink):void 0].filter(Boolean).join(" ")},t.extractCsaiConvivaAdInfo=function(e,a,i){var r,o,s,c=i.ad,l=c.data,d="NA",v="NA",y="NA",u=c.id;l&&("adSystem"in l&&(null===(o=l.adSystem)||void 0===o?void 0:o.name)&&(d=l.adSystem.name),"creative"in l&&(null===(s=null==l?void 0:l.creative)||void 0===s?void 0:s.id)&&(v=l.creative.id),"adTitle"in l&&l.adTitle&&(y=l.adTitle),"wrapperAdIds"in l&&l.wrapperAdIds&&l.wrapperAdIds.length&&(u=l.wrapperAdIds[l.wrapperAdIds.length-1]));var A=((r={"c3.ad.id":c.id,"c3.ad.technology":n.Constants.AdType.CLIENT_SIDE,"c3.ad.position":t.mapCsaiAdPosition(e.adBreak,a),"c3.ad.system":d,"c3.ad.creativeId":v,"c3.ad.firstAdId":u})[n.Constants.ASSET_NAME]=y,r[n.Constants.STREAM_URL]=c.mediaFileUrl||"NA",r["c3.ad.mediaFileApiFramework"]="NA",r["c3.ad.firstAdSystem"]="NA",r["c3.ad.firstCreativeId"]="NA",r);return"duration"in c&&c.duration&&(A[n.Constants.DURATION]=c.duration),A},t.convertSsaiAdInfoToConvivaAdInfo=function(t,e){var a,o=[r.INTEGRATION_VERSION_CONTENT_METADATA_CUSTOM_TAG,r.STREAM_TYPE_CONTENT_METADATA_CUSTOM_TAG,n.Constants.ASSET_NAME,n.Constants.IS_LIVE,n.Constants.DEFAULT_RESOURCE,n.Constants.ENCODED_FRAMERATE,n.Constants.VIEWER_ID,n.Constants.PLAYER_NAME],s={};o.forEach(function(t){s[t]=e[t]});var c=i(i(i({},s),t.additionalMetadata),((a={"c3.ad.id":t.id,"c3.ad.technology":n.Constants.AdType.SERVER_SIDE,"c3.ad.position":t.position||"NA","c3.ad.system":t.adSystem||"NA"})[n.Constants.ASSET_NAME]=t.title||s[n.Constants.ASSET_NAME]||"NA",a["c3.ad.adStitcher"]=t.adStitcher||"NA",a["c3.ad.isSlate"]=void 0===t.isSlate?"NA":t.isSlate.toString(),a));return t.duration&&(c[n.Constants.DURATION]=t.duration),c},t}();e.AdHelper=o},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConvivaAnalyticsTracker=e.VR_CONTENT_TYPE_CONTENT_METADATA_CUSTOM_TAG=e.STREAM_TYPE_CONTENT_METADATA_CUSTOM_TAG=e.PLAYER_TYPE_CONTENT_METADATA_CUSTOM_TAG=e.INTEGRATION_VERSION_CONTENT_METADATA_CUSTOM_TAG=e.PRELOAD_CONTENT_METADATA_CUSTOM_TAG=e.AUTOPLAY_CONTENT_METADATA_CUSTOM_TAG=void 0;var i=a(0),n=a(1),r=a(10),o=a(4),s=a(11),c=a(12),l=a(13),d=a(14),v=a(15),y=a(2),u=a(5),A=a(17),p=a(19);e.AUTOPLAY_CONTENT_METADATA_CUSTOM_TAG="autoplay",e.PRELOAD_CONTENT_METADATA_CUSTOM_TAG="preload",e.INTEGRATION_VERSION_CONTENT_METADATA_CUSTOM_TAG="integrationVersion",e.PLAYER_TYPE_CONTENT_METADATA_CUSTOM_TAG="playerType",e.STREAM_TYPE_CONTENT_METADATA_CUSTOM_TAG="streamType",e.VR_CONTENT_TYPE_CONTENT_METADATA_CUSTOM_TAG="vrContentType";var h=function(){function t(e,a){var n;void 0===a&&(a={});var u=this;if(this.logger=new o.Html5Logging,this.sessionKey=i.Constants.NO_SESSION_KEY,this._isAdBreakActive=!1,this.hasPlayed=!1,this.stallTrackingTimeout=new d.Timeout(t.STALL_TRACKING_DELAY_MS,function(){u._isAdBreakActive?(u.debugLog("[ ConvivaAnalyticsTracker ] report buffering ad playback state"),u.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.PLAYER_STATE,i.Constants.PlayerState.BUFFERING)):(u.debugLog("[ ConvivaAnalyticsTracker ] report buffering playback state"),u.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.PLAYER_STATE,i.Constants.PlayerState.BUFFERING))}),this.sessionEndedExternally=!1,this.internalEndSession=function(){u.isSessionActive()&&(u.debugLog("[ ConvivaAnalyticsTracker ] end session",u.sessionKey),u.contentMetadataBuilder.reset(),u.convivaVideoAnalytics.release(),u.convivaVideoAnalytics=null,u.convivaAdAnalytics.release(),u.convivaAdAnalytics=null,u.hasPlayed=!1,u._isAdBreakActive=!1)},this.onSourceLoaded=function(t){u.debugLog("[ ConvivaAnalyticsTracker ] [ Player Event ] source loaded",t),u.isSessionActive()&&(u.buildContentMetadata(),u.updateSession())},this.onPlay=function(t){u.debugLog("[ ConvivaAnalyticsTracker ] [ Player Event ] play"),u.canTrackPlayEvent&&(u.isSessionActive()||u.sessionEndedExternally||u.internalInitializeSession(),u.hasPlayed||(u.hasPlayed=!0,u.trackUpdateAudioTrack(u.player.getAudio()),u.trackInitialSubtitles()))},this.onPlaying=function(t){u.debugLog("[ ConvivaAnalyticsTracker ] [ Player Event ] playing",t),u.isSessionActive()&&(u.contentMetadataBuilder.setPlaybackStarted(!0),u.updateSession())},this.onPlaybackFinished=function(t){u.debugLog("[ ConvivaAnalyticsTracker ] [ Player Event ] playback finished",t),u.isSessionActive()&&(u.convivaVideoAnalytics.release(),u.convivaVideoAnalytics=null,u.convivaAdAnalytics.release(),u.convivaAdAnalytics=null)},this.trackVideoQualityChanged=function(t){if(u.isSessionActive()){var e=Math.round(t.targetQuality.bitrate/1e3);u.debugLog("[ ConvivaAnalyticsTracker ] report bitrate",{event:t,bitrateKbps:e}),u.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.BITRATE,e)}},this.trackAdBreakStarted=function(t){u.isSessionActive()&&!u._isAdBreakActive&&(u._isAdBreakActive=!0,u.debugLog("[ ConvivaAnalyticsTracker ] report ad break started",{type:t}),u.convivaVideoAnalytics.reportAdBreakStarted(t,t===i.Constants.AdType.CLIENT_SIDE?i.Constants.AdPlayer.SEPARATE:i.Constants.AdPlayer.CONTENT))},this.trackAdStarted=function(t,e,a){if(u.isSessionActive()){if(u.debugLog("[ ConvivaAnalyticsTracker ] report ad started",{adInfo:t,type:e,bitrateKbps:a}),u.convivaAdAnalytics.reportAdStarted(t),u.debugLog("[ ConvivaAnalyticsTracker ] report ".concat(p.PlayerStateHelper.getPlayerState(u.player)," ad playback state")),u.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.PLAYER_STATE,p.PlayerStateHelper.getPlayerState(u.player)),e===i.Constants.AdType.SERVER_SIDE){var n=u.player.getPlaybackVideoData(),r="".concat(n.width,"x").concat(n.height);u.debugLog("[ ConvivaAnalyticsTracker ] report ad resolution",r),u.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.RESOLUTION,r),n.frameRate&&(u.debugLog("[ ConvivaAnalyticsTracker ] report framerate",n.frameRate),u.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.RENDERED_FRAMERATE,n.frameRate))}a&&(u.debugLog("[ ConvivaAnalyticsTracker ] report ad bitrate",a),u.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.BITRATE,a))}},this.trackAdFinished=function(){u.isSessionActive()&&(u.debugLog("[ ConvivaAnalyticsTracker ] report ad ended"),u.convivaAdAnalytics.reportAdEnded())},this.trackAdSkipped=function(){u.isSessionActive()&&(u.debugLog("[ ConvivaAnalyticsTracker ] report ad skipped"),u.convivaAdAnalytics.reportAdSkipped())},this.trackRestoringContent=function(){u.isSessionActive()&&(u._isAdBreakActive=!1,u.debugLog("[ ConvivaAnalyticsTracker ] report ad break ended"),u.convivaVideoAnalytics.reportAdBreakEnded())},this.trackAdBreakFinished=function(){u.isSessionActive()&&!u._isAdBreakActive&&(u.debugLog("[ ConvivaAnalyticsTracker ] report ".concat(p.PlayerStateHelper.getPlayerState(u.player)," playback state")),u.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.PLAYER_STATE,p.PlayerStateHelper.getPlayerState(u.player)))},this.trackAdError=function(t){if(u.isSessionActive()){var e=y.AdHelper.formatCsaiAdError(t);u.debugLog("[ ConvivaAnalyticsTracker ] report ad error",{event:t,formattedError:e}),u.convivaAdAnalytics.reportAdError(e,i.Constants.ErrorSeverity.WARNING)}},this.trackError=function(t){u.isSessionActive()||u.sessionEndedExternally||u.internalInitializeSession(),u.debugLog("[ ConvivaAnalyticsTracker ] report playback deficiency",t),u.reportPlaybackDeficiency(String(t.code)+" "+t.name,i.Constants.ErrorSeverity.FATAL)},this.onSourceUnloaded=function(t){u.debugLog("[ ConvivaAnalyticsTracker ] [ Player Event ] source unloaded",t),u._isAdBreakActive||u.internalEndSession()},void 0!==i){this.config=a,this.config.debugLoggingEnabled=this.config.debugLoggingEnabled||!1;var A=this.config.deviceMetadata||{},h=((n={})[i.Constants.DeviceMetadata.CATEGORY]=A.category||this.config.deviceCategory||i.Constants.DeviceCategory.WEB,n[i.Constants.DeviceMetadata.BRAND]=A.brand,n[i.Constants.DeviceMetadata.MANUFACTURER]=A.manufacturer,n[i.Constants.DeviceMetadata.MODEL]=A.model,n[i.Constants.DeviceMetadata.TYPE]=A.type,n[i.Constants.DeviceMetadata.VERSION]=A.version,n[i.Constants.DeviceMetadata.OS_NAME]=A.osName,n[i.Constants.DeviceMetadata.OS_VERSION]=A.osVersion,n);i.Analytics.setDeviceMetadata(h);var g={};g[i.Constants.CallbackFunctions.CONSOLE_LOG]=this.logger.consoleLog,g[i.Constants.CallbackFunctions.MAKE_REQUEST]=(new r.Html5Http).makeRequest;var f=new s.Html5Storage;g[i.Constants.CallbackFunctions.SAVE_DATA]=f.saveData,g[i.Constants.CallbackFunctions.LOAD_DATA]=f.loadData,g[i.Constants.CallbackFunctions.CREATE_TIMER]=(new l.Html5Timer).createTimer,g[i.Constants.CallbackFunctions.GET_EPOCH_TIME_IN_MS]=(new c.Html5Time).getEpochTimeMs;var T={};T[i.Constants.GATEWAY_URL]=a.gatewayUrl,T[i.Constants.LOG_LEVEL]=this.config.debugLoggingEnabled?i.Constants.LogLevel.DEBUG:i.Constants.LogLevel.NONE,i.Analytics.init(e,g,T),this.contentMetadataBuilder=new v.ContentMetadataBuilder(this.logger)}else console.error("Conviva script missing, cannot init ConvivaAnalytics. Please load the Conviva script (conviva-core-sdk.min.js) before Bitmovin's ConvivaAnalytics integration.")}return Object.defineProperty(t.prototype,"player",{get:function(){if(!this._player)throw new Error("Player is not initialized, either pass it to the constructor or attach it via `attachPlayer` before using the integration.");return this._player},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPlayerAttached",{get:function(){return!!this._player},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAdBreakActive",{get:function(){return this._isAdBreakActive},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canTrackPlayEvent",{get:function(){return!this._isAdBreakActive},enumerable:!1,configurable:!0}),t.prototype.canAttachPlayer=function(t){var e=void 0;return this.isPlayerAttached&&(e="Player is already attached"),t.getSource()&&(e="Player.load() has already been called (attaching player is possible only before player.load())"),{canAttach:!e,reason:e}},t.prototype.attachPlayer=function(t){this.canAttachPlayer(t).canAttach&&(this._player=t,this.handlers=new u.PlayerEventWrapper(t),this.setPlayerInfo(),this.registerPlayerEvents())},t.prototype.setPlayerInfo=function(){var t;if(this.convivaVideoAnalytics&&this.convivaAdAnalytics&&this.isPlayerAttached){var e=((t={})[i.Constants.FRAMEWORK_NAME]="Bitmovin Player",t[i.Constants.FRAMEWORK_VERSION]=this.player.version,t);this.convivaVideoAnalytics.setPlayerInfo(e),this.convivaAdAnalytics.setAdPlayerInfo(e)}},t.prototype.getContentMetadata=function(){return this.contentMetadataBuilder.build()},t.prototype.initializeSession=function(){if(this.isSessionActive())this.logger.consoleLog("[ ConvivaAnalyticsTracker ] There is already a session running.",i.SystemSettings.LogLevel.WARNING);else{if(!this.isPlayerAttached&&!this.contentMetadataBuilder.assetName)throw"Player is not attached during session initialization and `assetName` is empty in the content metadata. Either attach the player before calling `initializeSession` or set the `assetName` manually using `updateContentMetadata`.";if(this.isPlayerAttached&&!this.player.getSource()&&!this.contentMetadataBuilder.assetName)throw"Player is attached but no source is loaded and `assetName` is empty in the content metadata. Either load a source before calling `initializeSession` or set the `assetName` manually using `updateContentMetadata`.";this.internalInitializeSession(),this.sessionEndedExternally=!1}},t.prototype.ensurePlaybackFinished=function(){this.isSessionActive()&&(this._isAdBreakActive&&(this.debugLog("[ ConvivaAnalyticsTracker ] report ad skipped"),this.convivaAdAnalytics.reportAdSkipped()),this.debugLog("[ ConvivaAnalyticsTracker ] report playback ended state"),this.convivaVideoAnalytics.reportPlaybackEnded())},t.prototype.endSession=function(){this.isSessionActive()&&(this.debugLog("[ ConvivaAnalytics ] external ending session"),this.ensurePlaybackFinished(),this.internalEndSession(),this.sessionEndedExternally=!0)},t.prototype.sendCustomApplicationEvent=function(t,e){void 0===e&&(e={}),this.isSessionActive()?(this.debugLog("[ ConvivaAnalyticsTracker ] report custom app event",{eventName:t,eventAttributes:e}),this.convivaVideoAnalytics.reportAppEvent(t,e)):this.logger.consoleLog("[ ConvivaAnalyticsTracker ] cannot send application event, no active monitoring session",i.SystemSettings.LogLevel.WARNING)},t.prototype.sendCustomPlaybackEvent=function(t,e){void 0===e&&(e={}),this.isSessionActive()?(this.debugLog("[ ConvivaAnalyticsTracker ] report custom playback event",{eventName:t,eventAttributes:e}),this.convivaVideoAnalytics.reportPlaybackEvent(t,e)):this.logger.consoleLog("[ ConvivaAnalyticsTracker ] cannot send playback event, no active monitoring session",i.SystemSettings.LogLevel.WARNING)},t.prototype.updateContentMetadata=function(t){this.internalUpdateContentMetadata(t)},t.prototype.reportPlaybackDeficiency=function(t,e,a){void 0===a&&(a=!0),this.isSessionActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] report playback failed",{message:t}),this.convivaVideoAnalytics.reportPlaybackFailed(t),a&&this.internalEndSession())},t.prototype.pauseTracking=function(){this.debugLog("[ ConvivaAnalyticsTracker ] pause tracking via ad break started reporting"),this.convivaVideoAnalytics.reportAdBreakStarted(i.Constants.AdType.CLIENT_SIDE,i.Constants.AdPlayer.SEPARATE)},t.prototype.resumeTracking=function(){this.debugLog("[ ConvivaAnalyticsTracker ] resume tracking via ad break ended reporting"),this.convivaVideoAnalytics.reportAdBreakEnded()},t.prototype.release=function(t){this.debugLog("[ ConvivaAnalyticsTracker ] releasing",{isPlayerDestroyed:t}),t||this.unregisterPlayerEvents(),this._player=null,this.handlers=null,this.ensurePlaybackFinished(),this.internalEndSession(),i.Analytics.release()},t.prototype.debugLog=function(t){for(var e=[],a=1;a<arguments.length;a++)e[a-1]=arguments[a];this.config.debugLoggingEnabled&&console.log.apply(console,arguments)},t.prototype.getUrlFromSource=function(t){switch(this.player.getStreamType()){case"dash":return t.dash;case"hls":return t.hls;case"progressive":return Array.isArray(t.progressive)?t.progressive[0].url:t.progressive}},t.prototype.internalUpdateContentMetadata=function(t){this.contentMetadataBuilder.setOverrides(t),this.isSessionActive()?(this.buildContentMetadata(),this.updateSession()):this.logger.consoleLog("[ ConvivaAnalyticsTracker ] no active session. Content metadata will be propagated to Conviva on session initialization.",i.SystemSettings.LogLevel.DEBUG)},t.prototype.internalInitializeSession=function(){var t=this;this.debugLog("[ ConvivaAnalyticsTracker ] initializing session"),this.buildContentMetadata(),this.convivaVideoAnalytics=i.Analytics.buildVideoAnalytics(),this.convivaAdAnalytics=i.Analytics.buildAdAnalytics(this.convivaVideoAnalytics),this.debugLog("[ ConvivaAnalyticsTracker ] report playback requested"),this.convivaVideoAnalytics.reportPlaybackRequested(this.contentMetadataBuilder.build()),this.sessionKey=this.convivaVideoAnalytics.getSessionId(),this.debugLog("[ ConvivaAnalyticsTracker ] new session key",this.sessionKey),this.setPlayerInfo(),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.PLAYER_STATE,i.Constants.PlayerState.STOPPED),this.convivaVideoAnalytics.setCallback(function(){if(t.isPlayerAttached){var e=t.player.getCurrentTime(n.TimeMode.RelativeTime);if(Number.isFinite(e)){var a=1e3*e;t._isAdBreakActive?(t.debugLog("[ ConvivaAnalyticsTracker ] report ad player head time",a),t.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.PLAY_HEAD_TIME,a)):(t.debugLog("[ ConvivaAnalyticsTracker ] report player head time",a),t.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.PLAY_HEAD_TIME,a))}}}),this.isSessionActive()||this.logger.consoleLog("[ ConvivaAnalyticsTracker ] Something went wrong, could not obtain session key",i.SystemSettings.LogLevel.ERROR)},t.prototype.buildContentMetadata=function(){var a,n;if(this.isPlayerAttached){this.contentMetadataBuilder.duration=this.player.getDuration(),this.contentMetadataBuilder.streamType=this.player.isLive()?i.ContentMetadata.StreamType.LIVE:i.ContentMetadata.StreamType.VOD,this.contentMetadataBuilder.addToCustom(((a={})[e.AUTOPLAY_CONTENT_METADATA_CUSTOM_TAG]=A.PlayerConfigHelper.getAutoplayConfig(this.player)+"",a[e.PRELOAD_CONTENT_METADATA_CUSTOM_TAG]=A.PlayerConfigHelper.getPreloadConfig(this.player)+"",a[e.INTEGRATION_VERSION_CONTENT_METADATA_CUSTOM_TAG]=t.VERSION,a));var r=this.player.getSource();r&&(this.contentMetadataBuilder.assetName=this.getAssetNameFromSource(r),this.contentMetadataBuilder.viewerId=this.contentMetadataBuilder.viewerId,this.contentMetadataBuilder.addToCustom(((n={})[e.PLAYER_TYPE_CONTENT_METADATA_CUSTOM_TAG]=this.player.getPlayerType(),n[e.STREAM_TYPE_CONTENT_METADATA_CUSTOM_TAG]=this.player.getStreamType(),n[e.VR_CONTENT_TYPE_CONTENT_METADATA_CUSTOM_TAG]=r.vr&&r.vr.contentType,n)),this.contentMetadataBuilder.streamUrl=this.getUrlFromSource(r))}else this.debugLog("[ ConvivaAnalyticsTracker ] Player is not attached, skipping default content metadata initialization, it will be initialized on source loaded event")},t.prototype.updateSession=function(){this.isSessionActive()&&this.convivaVideoAnalytics.setContentInfo(this.contentMetadataBuilder.build())},t.prototype.getAssetNameFromSource=function(t){var e=t.title;return e||"Untitled (no source.title set)"},t.prototype.isSessionActive=function(){return!!this.convivaVideoAnalytics},t.prototype.trackPlaybackStateChanged=function(t){if(this.isSessionActive()){var e=p.PlayerStateHelper.getPlayerStateFromEvent(t,this.player),a=[n.PlayerEvent.Play,n.PlayerEvent.Seek,n.PlayerEvent.TimeShift,n.PlayerEvent.AdBreakStarted,n.PlayerEvent.AdFinished,n.PlayerEvent.RestoringContent],r=[n.PlayerEvent.StallStarted,n.PlayerEvent.Playing,n.PlayerEvent.Paused,n.PlayerEvent.Seeked,n.PlayerEvent.TimeShifted,n.PlayerEvent.StallEnded,n.PlayerEvent.PlaybackFinished,n.PlayerEvent.AdStarted];-1!==a.indexOf(t.type)?this.stallTrackingTimeout.start():-1!==r.indexOf(t.type)&&this.stallTrackingTimeout.clear(),e&&(this._isAdBreakActive?(this.debugLog("[ ConvivaAnalyticsTracker ] report ad playback state",e),this.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.PLAYER_STATE,e)):(this.debugLog("[ ConvivaAnalyticsTracker ] report playback state",e),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.PLAYER_STATE,e))),t.type===n.PlayerEvent.PlaybackFinished&&(this.debugLog("[ ConvivaAnalyticsTracker ] report playback ended"),this.convivaVideoAnalytics.reportPlaybackEnded())}},t.prototype.trackSeekStart=function(t){this.isSessionActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] report seek started"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SEEK_STARTED,t))},t.prototype.trackSeekEnd=function(){this.isSessionActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] report seek ended"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SEEK_ENDED))},t.prototype.trackUpdateAudioTrack=function(t){if(this.isSessionActive()){var e="unknown"!==t.lang?"["+t.lang+"]:"+t.label:t.label;this.debugLog("[ ConvivaAnalyticsTracker ] report audio language",{formattedAudio:e}),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.AUDIO_LANGUAGE,e)}},t.prototype.trackUpdateSubtitleTrack=function(t){if(this.isSessionActive()){var e="unknown"!==t.lang?"["+t.lang+"]:"+t.label:t.label;"subtitles"===t.kind?(this.debugLog("[ ConvivaAnalyticsTracker ] report subtitles language",{formattedSubtitle:e}),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SUBTITLES_LANGUAGE,e),this.debugLog("[ ConvivaAnalyticsTracker ] report off closed captions language"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.CLOSED_CAPTIONS_LANGUAGE,"off")):"captions"===t.kind?(this.debugLog("[ ConvivaAnalyticsTracker ] report closed captions language",{formattedSubtitle:e}),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.CLOSED_CAPTIONS_LANGUAGE,e),this.debugLog("[ ConvivaAnalyticsTracker ] report off subtitles language"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SUBTITLES_LANGUAGE,"off")):this.trackTurnOffSubtitles()}},t.prototype.trackInitialSubtitles=function(){if(this.isSessionActive()){if(void 0!==this.player.subtitles){var t=this.player.subtitles.list().filter(function(t){return t.enabled});if(1===t.length)return void this.trackUpdateSubtitleTrack(t[0])}this.trackTurnOffSubtitles()}},t.prototype.trackTurnOffSubtitles=function(){this.isSessionActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] report off subtitles language"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SUBTITLES_LANGUAGE,"off"),this.debugLog("[ ConvivaAnalyticsTracker ] report off closed captions language"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.CLOSED_CAPTIONS_LANGUAGE,"off"))},t.prototype.registerPlayerEvents=function(){this.handlers.add(n.PlayerEvent.SourceLoaded,this.onSourceLoaded),this.handlers.add(n.PlayerEvent.Play,this.onPlay),this.handlers.add(n.PlayerEvent.Playing,this.onPlaying),this.handlers.add(n.PlayerEvent.PlaybackFinished,this.onPlaybackFinished),this.handlers.add(n.PlayerEvent.SourceUnloaded,this.onSourceUnloaded)},t.prototype.unregisterPlayerEvents=function(){var t;null===(t=this.handlers)||void 0===t||t.clear()},Object.defineProperty(t,"version",{get:function(){return t.VERSION},enumerable:!1,configurable:!0}),t.VERSION="6.1.1",t.STALL_TRACKING_DELAY_MS=100,t}();e.ConvivaAnalyticsTracker=h},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Logging=void 0;var i=a(0),n=function(){function t(){}return t.prototype.consoleLog=function(t,e){"undefined"!=typeof console&&(console.log&&e===i.SystemSettings.LogLevel.DEBUG||e===i.SystemSettings.LogLevel.INFO?console.log(t):console.warn&&e===i.SystemSettings.LogLevel.WARNING?console.warn(t):console.error&&e===i.SystemSettings.LogLevel.ERROR&&console.error(t))},t.prototype.release=function(){},t}();e.Html5Logging=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PlayerEventWrapper=void 0;var i=a(16),n=function(){function t(t){this.player=t,this.eventHandlers={}}return t.prototype.add=function(t,e){this.player.on(t,e),this.eventHandlers[t]||(this.eventHandlers[t]=[]),this.eventHandlers[t].push(e)},t.prototype.remove=function(t,e){this.player.off(t,e),this.eventHandlers[t]&&i.ArrayUtils.remove(this.eventHandlers[t],e)},t.prototype.clear=function(){for(var t in this.eventHandlers)for(var e=0,a=this.eventHandlers[t];e<a.length;e++){var i=a[e];this.remove(t,i)}},t}();e.PlayerEventWrapper=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConvivaAnalytics=void 0,a(7);var i=a(8);Object.defineProperty(e,"ConvivaAnalytics",{enumerable:!0,get:function(){return i.ConvivaAnalytics}})},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConvivaAnalytics=void 0;var i=a(0),n=a(1),r=a(9),o=a(3),s=a(20),c=a(5),l=a(2),d=a(4),v=function(){function t(t,e,a){void 0===a&&(a={});var n=this;this.logger=new d.Html5Logging,this.mainContentDuration=0,this.onPlaybackStateChanged=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] playback state change related event",t),n.convivaAnalyticsTracker.trackPlaybackStateChanged(t)},this.onPlay=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] play",t),n.convivaAnalyticsTracker.canTrackPlayEvent&&n.onPlaybackStateChanged(t)},this.onPlaying=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] playing",t),n.onPlaybackStateChanged(t)},this.onPlaybackFinished=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] playback finished",t),n.onPlaybackStateChanged(t)},this.onVideoQualityChanged=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] video quality changed",t),n.convivaAnalyticsTracker.trackVideoQualityChanged(t)},this.onCustomEvent=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] custom playback related event",t);var e=r.ObjectUtils.flatten(t);n.sendCustomPlaybackEvent(t.type,e)},this.onAdBreakStarted=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] adbreak started",t),n.lastAdBreakEvent=t,n.convivaAnalyticsTracker.trackAdBreakStarted(i.Constants.AdType.CLIENT_SIDE),n.convivaAnalyticsTracker.trackPlaybackStateChanged(t)},this.onAdStarted=function(t){var e;n.debugLog("[ ConvivaAnalytics ] [ Player Event ] ad started",t);var a=l.AdHelper.extractCsaiConvivaAdInfo(n.lastAdBreakEvent,n.mainContentDuration,t),r=null===(e=t.ad.data)||void 0===e?void 0:e.bitrate;n.convivaAnalyticsTracker.trackAdStarted(a,i.Constants.AdType.CLIENT_SIDE,r),n.convivaAnalyticsTracker.trackPlaybackStateChanged(t)},this.onAdFinished=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] ad finished",t),n.convivaAnalyticsTracker.trackAdFinished(),n.convivaAnalyticsTracker.trackPlaybackStateChanged(t)},this.onAdSkipped=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] ad skipped",t),n.convivaAnalyticsTracker.trackAdSkipped(),n.onCustomEvent(t)},this.onRestoringContent=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] restoring content",t),n.convivaAnalyticsTracker.trackRestoringContent()},this.onAdBreakFinished=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] adbreak finished",t),n.convivaAnalyticsTracker.trackAdBreakFinished()},this.onAdError=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] ad error",t),n.convivaAnalyticsTracker.trackAdError(t),n.onCustomEvent(t)},this.onSeek=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] seek",t),n.convivaAnalyticsTracker.trackSeekStart(t.seekTarget),n.onPlaybackStateChanged(t)},this.onSeeked=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] seeked",t),n.convivaAnalyticsTracker.trackSeekEnd(),n.onPlaybackStateChanged(t)},this.onTimeShift=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] time shift",t),n.convivaAnalyticsTracker.trackSeekStart(-1),n.onPlaybackStateChanged(t)},this.onTimeShifted=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] time shifted",t),n.convivaAnalyticsTracker.trackSeekEnd(),n.onPlaybackStateChanged(t)},this.onAudioChanged=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] audio changed",t),n.convivaAnalyticsTracker.trackUpdateAudioTrack(t.targetAudio)},this.onSubtitleEnabled=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] subtitled enabled",t),n.convivaAnalyticsTracker.trackUpdateSubtitleTrack(t.subtitle)},this.onSubtitleDisabled=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] subtitles disabled",t),n.convivaAnalyticsTracker.trackTurnOffSubtitles()},this.onError=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] error",t),n.convivaAnalyticsTracker.trackError(t)},this.onDestroy=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] destroy",t),n.releaseInternal(t)},this.onSourceLoaded=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] onSourceLoaded",t),n.mainContentDuration=n.player.getDuration()},this.convivaAnalyticsTracker=new o.ConvivaAnalyticsTracker(e,a),this.debugLoggingEnabled=a.debugLoggingEnabled||!1,this._player=t,t&&this.attachPlayer(t),this.convivaSsaiAnalytics=new s.ConvivaAnalyticsSsai(this.convivaAnalyticsTracker),this.ssai={get isAdBreakActive(){return this.convivaSsaiAnalytics.isAdBreakActive},reportAdBreakStarted:this.convivaSsaiAnalytics.reportAdBreakStarted.bind(this.convivaSsaiAnalytics),reportAdStarted:this.convivaSsaiAnalytics.reportAdStarted.bind(this.convivaSsaiAnalytics),reportAdFinished:this.convivaSsaiAnalytics.reportAdFinished.bind(this.convivaSsaiAnalytics),reportAdSkipped:this.convivaSsaiAnalytics.reportAdSkipped.bind(this.convivaSsaiAnalytics),reportAdBreakFinished:this.convivaSsaiAnalytics.reportAdBreakFinished.bind(this.convivaSsaiAnalytics)}}return Object.defineProperty(t.prototype,"player",{get:function(){if(!this._player)throw new Error("Player is not initialized, either pass it to the constructor or attach it via `attachPlayer` before using the integration.");return this._player},enumerable:!1,configurable:!0}),t.prototype.attachPlayer=function(t){var e=this.convivaAnalyticsTracker.canAttachPlayer(t),a=e.canAttach,n=e.reason;a?(this.convivaAnalyticsTracker.attachPlayer(t),this._player=t,this.handlers=new c.PlayerEventWrapper(t),this.registerPlayerEvents()):this.logger.consoleLog("[ ConvivaAnalyticsTracker ] cannot attach player: ".concat(n),i.SystemSettings.LogLevel.WARNING)},t.prototype.initializeSession=function(){this.convivaAnalyticsTracker.initializeSession()},t.prototype.endSession=function(){this.debugLog("[ ConvivaAnalytics ] external ending session"),this.convivaSsaiAnalytics.reset(),this.convivaAnalyticsTracker.endSession()},t.prototype.sendCustomApplicationEvent=function(t,e){void 0===e&&(e={}),this.convivaAnalyticsTracker.sendCustomApplicationEvent(t,e)},t.prototype.sendCustomPlaybackEvent=function(t,e){void 0===e&&(e={}),this.convivaAnalyticsTracker.sendCustomPlaybackEvent(t,e)},t.prototype.updateContentMetadata=function(t){this.convivaAnalyticsTracker.updateContentMetadata(t)},t.prototype.reportPlaybackDeficiency=function(t,e,a){void 0===a&&(a=!0),this.convivaAnalyticsTracker.reportPlaybackDeficiency(t,e,a)},t.prototype.pauseTracking=function(){this.convivaAnalyticsTracker.pauseTracking()},t.prototype.resumeTracking=function(){this.convivaAnalyticsTracker.resumeTracking()},t.prototype.release=function(){this.releaseInternal()},t.prototype.releaseInternal=function(t){var e=(null==t?void 0:t.type)===n.PlayerEvent.Destroy;e||this.unregisterPlayerEvents(),this._player=null,this.handlers=null,this.debugLog("[ ConvivaAnalytics ] releasing",{event:t,isPlayerDestroyed:e}),this.convivaAnalyticsTracker.release(e),this.convivaSsaiAnalytics.reset(),this.lastAdBreakEvent=null},t.prototype.debugLog=function(t){for(var e=[],a=1;a<arguments.length;a++)e[a-1]=arguments[a];this.debugLoggingEnabled&&console.log.apply(console,arguments)},t.prototype.registerPlayerEvents=function(){this.handlers.add(n.PlayerEvent.SourceLoaded,this.onSourceLoaded),this.handlers.add(n.PlayerEvent.Play,this.onPlay),this.handlers.add(n.PlayerEvent.Playing,this.onPlaying),this.handlers.add(n.PlayerEvent.Paused,this.onPlaybackStateChanged),this.handlers.add(n.PlayerEvent.StallStarted,this.onPlaybackStateChanged),this.handlers.add(n.PlayerEvent.StallEnded,this.onPlaybackStateChanged),this.handlers.add(n.PlayerEvent.PlaybackFinished,this.onPlaybackFinished),this.handlers.add(n.PlayerEvent.VideoPlaybackQualityChanged,this.onVideoQualityChanged),this.handlers.add(n.PlayerEvent.AudioPlaybackQualityChanged,this.onCustomEvent),this.handlers.add(n.PlayerEvent.Muted,this.onCustomEvent),this.handlers.add(n.PlayerEvent.Unmuted,this.onCustomEvent),this.handlers.add(n.PlayerEvent.ViewModeChanged,this.onCustomEvent),this.handlers.add(n.PlayerEvent.AdStarted,this.onAdStarted),this.handlers.add(n.PlayerEvent.AdFinished,this.onAdFinished),this.handlers.add(n.PlayerEvent.AdBreakStarted,this.onAdBreakStarted),this.handlers.add(n.PlayerEvent.RestoringContent,this.onRestoringContent),this.handlers.add(n.PlayerEvent.AdBreakFinished,this.onAdBreakFinished),this.handlers.add(n.PlayerEvent.AdSkipped,this.onAdSkipped),this.handlers.add(n.PlayerEvent.AdError,this.onAdError),this.handlers.add(n.PlayerEvent.Error,this.onError),this.handlers.add(n.PlayerEvent.Destroy,this.onDestroy),this.handlers.add(n.PlayerEvent.Seek,this.onSeek),this.handlers.add(n.PlayerEvent.Seeked,this.onSeeked),this.handlers.add(n.PlayerEvent.TimeShift,this.onTimeShift),this.handlers.add(n.PlayerEvent.TimeShifted,this.onTimeShifted),this.handlers.add(n.PlayerEvent.AudioChanged,this.onAudioChanged),this.handlers.add(n.PlayerEvent.SubtitleEnabled,this.onSubtitleEnabled),this.handlers.add(n.PlayerEvent.SubtitleDisabled,this.onSubtitleDisabled),this.handlers.add(n.PlayerEvent.CastStarted,this.onCustomEvent),this.handlers.add(n.PlayerEvent.CastStopped,this.onCustomEvent)},t.prototype.unregisterPlayerEvents=function(){var t;null===(t=this.handlers)||void 0===t||t.clear()},t}();e.ConvivaAnalytics=v},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ObjectUtils=void 0,function(t){t.flatten=function(t,e){void 0===e&&(e="");var a={},i=function(t,e){for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];"object"==typeof r?i(r,e+n+"."):a[e+n]=String(r)}};return i(t,e),a}}(e.ObjectUtils||(e.ObjectUtils={}))},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Http=void 0;var i=function(){function t(){}return t.prototype.makeRequest=function(t,e,a,i,n,r){return this.makeRequestStandard.apply(this,arguments)},t.prototype.release=function(){},t.prototype.makeRequestStandard=function(t,e,a,i,n,r){var o=new XMLHttpRequest;return o.open(t,e,!0),i&&o.overrideMimeType&&o.overrideMimeType(i),i&&o.setRequestHeader&&o.setRequestHeader("Content-Type",i),n>0&&(o.timeout=n,o.ontimeout=function(){o.ontimeout=o.onreadystatechange=null,r&&r(!1,"timeout after "+n+" ms")}),o.onreadystatechange=function(){4===o.readyState&&(o.ontimeout=o.onreadystatechange=null,200===o.status?r&&r(!0,o.responseText):r&&r(!1,"http status "+o.status))},o.send(a),null},t}();e.Html5Http=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Storage=void 0;var i=function(){function t(){}return t.prototype.saveData=function(t,e,a,i){var n=t+"."+e;try{localStorage.setItem(n,a),i(!0,null)}catch(t){i(!1,t.toString())}},t.prototype.loadData=function(t,e,a){var i=t+"."+e;try{a(!0,localStorage.getItem(i))}catch(t){a(!1,t.toString())}},t.prototype.release=function(){},t}();e.Html5Storage=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Time=void 0;var i=function(){function t(){}return t.prototype.getEpochTimeMs=function(){return(new Date).getTime()},t.prototype.release=function(){},t}();e.Html5Time=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Timer=void 0;var i=function(){function t(){}return t.prototype.createTimer=function(t,e,a){var i=window.setInterval(t,e);return function(){-1!==i&&(clearInterval(i),i=-1)}},t.prototype.release=function(){},t}();e.Html5Timer=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Timeout=void 0;var i=function(){function t(t,e,a){void 0===a&&(a=!1),this.delay=t,this.callback=e,this.repeat=a,this.timeoutOrIntervalId=0,this.active=!1,this.suspended=!1}return t.prototype.start=function(){return this.reset(),this},t.prototype.clear=function(){this.clearInternal()},t.prototype.suspend=function(){return this.suspended=!0,this.clearInternal(),this},t.prototype.resume=function(t){return this.suspended=!1,t&&this.reset(),this},t.prototype.reset=function(){var t=this;this.clearInternal(),this.suspended||(this.repeat?this.timeoutOrIntervalId=setInterval(this.callback,this.delay):this.timeoutOrIntervalId=setTimeout(function(){t.active=!1,t.callback()},this.delay),this.active=!0)},t.prototype.isActive=function(){return this.active},t.prototype.clearInternal=function(){this.repeat?clearInterval(this.timeoutOrIntervalId):clearTimeout(this.timeoutOrIntervalId),this.active=!1},t}();e.Timeout=i},function(t,e,a){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,a=1,i=arguments.length;a<i;a++)for(var n in e=arguments[a])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.ContentMetadataBuilder=void 0;var n=a(0),r=function(){function t(t){this.metadataOverrides={},this.metadata={},this.latestBuiltMetadata={},this.playbackStarted=!1,this.logger=t}return t.prototype.setOverrides=function(t){this.playbackStarted&&this.logger.consoleLog("[ Conviva Analytics ] Playback has started. Only some metadata attributes will be updated",n.SystemSettings.LogLevel.WARNING),this.metadataOverrides=i(i({},this.metadataOverrides),t)},t.prototype.getOverrides=function(){return this.metadataOverrides},t.prototype.setPlaybackStarted=function(t){this.playbackStarted=t},t.prototype.getStaticMetadata=function(){var t={};return this.playbackStarted?(t.assetName=this.latestBuiltMetadata.assetName,t.viewerId=this.latestBuiltMetadata.viewerId,t.streamType=this.latestBuiltMetadata.streamType,t.applicationName=this.latestBuiltMetadata.applicationName,t.duration=this.latestBuiltMetadata.duration,t.custom=this.latestBuiltMetadata.custom):(t.assetName=this.latestBuiltMetadata.assetName||this.assetName,t.viewerId=this.viewerId,t.streamType=this.metadataOverrides.streamType||this.metadata.streamType,t.applicationName=this.metadataOverrides.applicationName||this.metadata.applicationName,t.duration=this.metadataOverrides.duration||this.metadata.duration,t.custom=i(i(i({},this.metadataOverrides.custom),this.metadataOverrides.additionalStandardTags),this.metadata.custom)),t},t.prototype.getDynamicMetadata=function(){return{encodedFrameRate:this.metadataOverrides.encodedFrameRate||this.metadata.encodedFrameRate,defaultResource:this.metadataOverrides.defaultResource||this.metadata.defaultResource,streamUrl:this.metadataOverrides.streamUrl||this.metadata.streamUrl}},t.prototype.build=function(){var t,e=i(i({},this.getStaticMetadata()),this.getDynamicMetadata());this.latestBuiltMetadata=e;var a=((t={})[n.Constants.ASSET_NAME]=e.assetName,t[n.Constants.ENCODED_FRAMERATE]=e.encodedFrameRate,t[n.Constants.DURATION]=e.duration,t[n.Constants.DEFAULT_RESOURCE]=e.defaultResource,t[n.Constants.STREAM_URL]=e.streamUrl,t[n.Constants.IS_LIVE]=e.streamType,t[n.Constants.VIEWER_ID]=e.viewerId||"GET_VIEWER_ID_FROM_PLAYER",t[n.Constants.PLAYER_NAME]=e.applicationName||"GET_PLAYER_NAME_OR_TYPE",t);return i(i({},a),e.custom)},Object.defineProperty(t.prototype,"assetName",{get:function(){return this.metadataOverrides.assetName||this.metadata.assetName},set:function(t){this.metadata.assetName=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewerId",{get:function(){return this.metadataOverrides.viewerId||this.metadata.viewerId},set:function(t){this.metadata.viewerId=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"streamType",{set:function(t){this.metadata.streamType=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"applicationName",{set:function(t){this.metadata.applicationName=t},enumerable:!1,configurable:!0}),t.prototype.addToCustom=function(t){this.metadata.custom=i(i({},this.metadata.custom),t)},Object.defineProperty(t.prototype,"duration",{set:function(t){this.metadata.duration=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"encodedFrameRate",{set:function(t){this.metadata.encodedFrameRate=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"defaultResource",{set:function(t){this.metadata.defaultResource=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"streamUrl",{set:function(t){this.metadata.streamUrl=t},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.latestBuiltMetadata={}},t}();e.ContentMetadataBuilder=r},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ArrayUtils=void 0,function(t){t.remove=function(t,e){var a=t.indexOf(e);return a>-1?t.splice(a,1)[0]:null}}(e.ArrayUtils||(e.ArrayUtils={}))},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PlayerConfigHelper=void 0;var i=a(18),n=function(){function t(){}return t.getAutoplayConfig=function(e){var a=e.getConfig();return a.playback&&void 0!==a.playback.autoplay?a.playback.autoplay:t.AUTOPLAY_DEFAULT_CONFIG},t.getPreloadConfig=function(t){var e=t.getConfig();if(i.BrowserUtils.isMobile()){if(e.adaptation&&e.adaptation.mobile&&void 0!==e.adaptation.mobile.preload)return e.adaptation.mobile.preload}else if(e.adaptation&&e.adaptation.desktop&&void 0!==e.adaptation.desktop.preload)return e.adaptation.desktop.preload;return e.adaptation&&void 0!==e.adaptation.preload?e.adaptation.preload:!t.isLive()},t.AUTOPLAY_DEFAULT_CONFIG=!1,t}();e.PlayerConfigHelper=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserUtils=void 0;var i=function(){function t(){}return t.isMobile=function(){var t=/Android/i.test(navigator.userAgent),e=/IEMobile/i.test(navigator.userAgent),a=/Windows Phone 10.0/i.test(navigator.userAgent),i=/Safari/i.test(navigator.userAgent)&&/Mobile/i.test(navigator.userAgent);return t||e||a||i},t}();e.BrowserUtils=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PlayerStateHelper=void 0;var i=a(1),n=a(0),r=function(){function t(){}return t.getPlayerStateFromEvent=function(t,e){var a;switch(t.type){case i.PlayerEvent.StallStarted:a=n.Constants.PlayerState.BUFFERING;break;case i.PlayerEvent.Playing:a=n.Constants.PlayerState.PLAYING;break;case i.PlayerEvent.Paused:a=n.Constants.PlayerState.PAUSED;break;case i.PlayerEvent.Seeked:case i.PlayerEvent.TimeShifted:case i.PlayerEvent.StallEnded:a=e.isPlaying()?n.Constants.PlayerState.PLAYING:n.Constants.PlayerState.PAUSED}return a},t.getPlayerState=function(t){return t.isStalled()?n.Constants.PlayerState.BUFFERING:t.isPlaying()?n.Constants.PlayerState.PLAYING:n.Constants.PlayerState.PAUSED},t}();e.PlayerStateHelper=r},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConvivaAnalyticsSsai=void 0;var i=a(0),n=a(2),r=function(){function t(t){this._isAdBreakActive=!1,this.convivaAnalyticsTracker=t}return Object.defineProperty(t.prototype,"isAdBreakActive",{get:function(){return this._isAdBreakActive},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this._isAdBreakActive=!1},t.prototype.reportAdBreakStarted=function(){this.convivaAnalyticsTracker.isAdBreakActive||this._isAdBreakActive||(this._isAdBreakActive=!0,this.convivaAnalyticsTracker.trackAdBreakStarted(i.Constants.AdType.SERVER_SIDE))},t.prototype.reportAdStarted=function(t){this._isAdBreakActive&&this.convivaAnalyticsTracker.trackAdStarted(n.AdHelper.convertSsaiAdInfoToConvivaAdInfo(t,this.convivaAnalyticsTracker.getContentMetadata()),i.Constants.AdType.SERVER_SIDE)},t.prototype.reportAdFinished=function(){this.isAdBreakActive&&this.convivaAnalyticsTracker.trackAdFinished()},t.prototype.reportAdSkipped=function(){this._isAdBreakActive&&this.convivaAnalyticsTracker.trackAdSkipped()},t.prototype.reportAdBreakFinished=function(){this._isAdBreakActive&&(this._isAdBreakActive=!1,this.convivaAnalyticsTracker.trackAdBreakFinished())},t}();e.ConvivaAnalyticsSsai=r}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@convivainc/conviva-js-coresdk"),require("bitmovin-player")):"function"==typeof define&&define.amd?define("bitmovin-player-analytics-conviva",["@convivainc/conviva-js-coresdk","bitmovin-player"],e):"object"==typeof exports?exports["bitmovin-player-analytics-conviva"]=e(require("@convivainc/conviva-js-coresdk"),require("bitmovin-player")):(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player.analytics=e(t.Conviva,t.bitmovin.player))}(window,function(t,e){return function(t){var e={};function a(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,a),n.l=!0,n.exports}return a.m=t,a.c=e,a.d=function(t,e,i){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(a.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(i,n,function(e){return t[e]}.bind(null,n));return i},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=6)}([function(e,a){e.exports=t},function(t,a){t.exports=e},function(t,e,a){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,a=1,i=arguments.length;a<i;a++)for(var n in e=arguments[a])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.AdHelper=void 0;var n=a(0),r=a(3),o=function(){function t(){}return t.mapCsaiAdPosition=function(t,e){return t.scheduleTime<=0?n.Constants.AdPosition.PREROLL:t.scheduleTime>=e?n.Constants.AdPosition.POSTROLL:n.Constants.AdPosition.MIDROLL},t.formatCsaiAdError=function(t){var e,a,i=(null==t?void 0:t.message)||"Unknown message",n=(null==t?void 0:t.name)||"Unknown name";return["Ad error:","".concat(n,";"),(null===(e=t.data)||void 0===e?void 0:e.code)?"Ad error code: ".concat(null===(a=t.data)||void 0===a?void 0:a.code,";"):void 0,"Message:","".concat(i,";"),"Error code: ".concat(t.code,";"),t.troubleShootLink?"Troubleshoot link: ".concat(t.troubleShootLink):void 0].filter(Boolean).join(" ")},t.extractCsaiConvivaAdInfo=function(e,a,i){var r,o,s,c=i.ad,l=c.data,d="NA",v="NA",u="NA",y=c.id;l&&("adSystem"in l&&(null===(o=l.adSystem)||void 0===o?void 0:o.name)&&(d=l.adSystem.name),"creative"in l&&(null===(s=null==l?void 0:l.creative)||void 0===s?void 0:s.id)&&(v=l.creative.id),"adTitle"in l&&l.adTitle&&(u=l.adTitle),"wrapperAdIds"in l&&l.wrapperAdIds&&l.wrapperAdIds.length&&(y=l.wrapperAdIds[l.wrapperAdIds.length-1]));var A=((r={"c3.ad.id":c.id,"c3.ad.technology":n.Constants.AdType.CLIENT_SIDE,"c3.ad.position":t.mapCsaiAdPosition(e.adBreak,a),"c3.ad.system":d,"c3.ad.creativeId":v,"c3.ad.firstAdId":y})[n.Constants.ASSET_NAME]=u,r[n.Constants.STREAM_URL]=c.mediaFileUrl||"NA",r["c3.ad.mediaFileApiFramework"]="NA",r["c3.ad.firstAdSystem"]="NA",r["c3.ad.firstCreativeId"]="NA",r);return"duration"in c&&c.duration&&(A[n.Constants.DURATION]=c.duration),A},t.convertSsaiAdInfoToConvivaAdInfo=function(t,e){var a,o=[r.INTEGRATION_VERSION_CONTENT_METADATA_CUSTOM_TAG,r.STREAM_TYPE_CONTENT_METADATA_CUSTOM_TAG,n.Constants.ASSET_NAME,n.Constants.IS_LIVE,n.Constants.DEFAULT_RESOURCE,n.Constants.ENCODED_FRAMERATE,n.Constants.VIEWER_ID,n.Constants.PLAYER_NAME],s={};o.forEach(function(t){s[t]=e[t]});var c=i(i(i({},s),t.additionalMetadata),((a={"c3.ad.id":t.id,"c3.ad.technology":n.Constants.AdType.SERVER_SIDE,"c3.ad.position":t.position||"NA","c3.ad.system":t.adSystem||"NA"})[n.Constants.ASSET_NAME]=t.title||s[n.Constants.ASSET_NAME]||"NA",a["c3.ad.adStitcher"]=t.adStitcher||"NA",a["c3.ad.isSlate"]=void 0===t.isSlate?"NA":t.isSlate.toString(),a));return t.duration&&(c[n.Constants.DURATION]=t.duration),c},t}();e.AdHelper=o},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConvivaAnalyticsTracker=e.VR_CONTENT_TYPE_CONTENT_METADATA_CUSTOM_TAG=e.STREAM_TYPE_CONTENT_METADATA_CUSTOM_TAG=e.PLAYER_TYPE_CONTENT_METADATA_CUSTOM_TAG=e.INTEGRATION_VERSION_CONTENT_METADATA_CUSTOM_TAG=e.PRELOAD_CONTENT_METADATA_CUSTOM_TAG=e.AUTOPLAY_CONTENT_METADATA_CUSTOM_TAG=void 0;var i=a(0),n=a(1),r=a(10),o=a(4),s=a(11),c=a(12),l=a(13),d=a(14),v=a(15),u=a(2),y=a(5),A=a(17),p=a(19);e.AUTOPLAY_CONTENT_METADATA_CUSTOM_TAG="autoplay",e.PRELOAD_CONTENT_METADATA_CUSTOM_TAG="preload",e.INTEGRATION_VERSION_CONTENT_METADATA_CUSTOM_TAG="integrationVersion",e.PLAYER_TYPE_CONTENT_METADATA_CUSTOM_TAG="playerType",e.STREAM_TYPE_CONTENT_METADATA_CUSTOM_TAG="streamType",e.VR_CONTENT_TYPE_CONTENT_METADATA_CUSTOM_TAG="vrContentType";var h=function(){function t(e,a){var n;void 0===a&&(a={});var y=this;if(this.logger=new o.Html5Logging,this.sessionKey=i.Constants.NO_SESSION_KEY,this._isAdBreakActive=!1,this.hasPlayed=!1,this.stallTrackingTimeout=new d.Timeout(t.STALL_TRACKING_DELAY_MS,function(){y.trackPlaybackState(i.Constants.PlayerState.BUFFERING)}),this.sessionEndedExternally=!1,this.internalEndSession=function(){y.isSessionActive()&&(y.debugLog("[ ConvivaAnalyticsTracker ] end session",y.sessionKey),y.contentMetadataBuilder.reset(),y.convivaVideoAnalytics.release(),y.convivaVideoAnalytics=null,y.convivaAdAnalytics.release(),y.convivaAdAnalytics=null,y.hasPlayed=!1,y._isAdBreakActive=!1)},this.onSourceLoaded=function(t){y.isSessionActive()&&(y.debugLog("[ ConvivaAnalyticsTracker ] building content metadata after source loaded event",t),y.buildContentMetadata(),y.updateSession())},this.onPlay=function(t){y.debugLog("[ ConvivaAnalyticsTracker ] checking if session needs to be initialized after play event"),y.canTrackPlayEvent&&(y.isSessionActive()||y.sessionEndedExternally||y.internalInitializeSession(),y.hasPlayed||(y.hasPlayed=!0,y.trackUpdateAudioTrack(y.player.getAudio()),y.trackInitialSubtitles()))},this.onPlaying=function(t){y.isSessionActive()&&(y.debugLog("[ ConvivaAnalyticsTracker ] updating session metadata after playing event",t),y.contentMetadataBuilder.setPlaybackStarted(!0),y.updateSession())},this.onPlaybackFinished=function(t){y.isSessionActive()&&(y.debugLog("[ ConvivaAnalyticsTracker ] releasing everything after playback finished event",t),y.trackPlaybackFinished(),y.convivaVideoAnalytics.release(),y.convivaVideoAnalytics=null,y.convivaAdAnalytics.release(),y.convivaAdAnalytics=null)},this.trackPlaybackFinished=function(){y.debugLog("[ ConvivaAnalyticsTracker ] report playback ended"),y.convivaVideoAnalytics.reportPlaybackEnded()},this.trackVideoQualityChanged=function(t){if(y.isSessionActive()){var e=Math.round(t.targetQuality.bitrate/1e3);y.debugLog("[ ConvivaAnalyticsTracker ] report bitrate",{event:t,bitrateKbps:e}),y.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.BITRATE,e)}},this.trackAdBreakStarted=function(t){y.isSessionActive()&&!y._isAdBreakActive&&(y._isAdBreakActive=!0,y.debugLog("[ ConvivaAnalyticsTracker ] report ad break started",{type:t}),y.convivaVideoAnalytics.reportAdBreakStarted(t,t===i.Constants.AdType.CLIENT_SIDE?i.Constants.AdPlayer.SEPARATE:i.Constants.AdPlayer.CONTENT))},this.trackAdStarted=function(t,e,a){if(y.isSessionActive()){if(y.debugLog("[ ConvivaAnalyticsTracker ] report ad started",{adInfo:t,type:e,bitrateKbps:a}),y.convivaAdAnalytics.reportAdStarted(t),y.debugLog("[ ConvivaAnalyticsTracker ] report ".concat(p.PlayerStateHelper.getPlayerState(y.player)," ad playback state on ad started event")),y.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.PLAYER_STATE,p.PlayerStateHelper.getPlayerState(y.player)),e===i.Constants.AdType.SERVER_SIDE){var n=y.player.getPlaybackVideoData(),r="".concat(n.width,"x").concat(n.height);y.debugLog("[ ConvivaAnalyticsTracker ] report ad resolution",r),y.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.RESOLUTION,r),n.frameRate&&(y.debugLog("[ ConvivaAnalyticsTracker ] report framerate",n.frameRate),y.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.RENDERED_FRAMERATE,n.frameRate))}a&&(y.debugLog("[ ConvivaAnalyticsTracker ] report ad bitrate",a),y.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.BITRATE,a))}},this.trackAdFinished=function(){y.isSessionActive()&&(y.debugLog("[ ConvivaAnalyticsTracker ] report ad ended"),y.convivaAdAnalytics.reportAdEnded())},this.trackAdSkipped=function(){y.isSessionActive()&&(y.debugLog("[ ConvivaAnalyticsTracker ] report ad skipped"),y.convivaAdAnalytics.reportAdSkipped())},this.trackRestoringContent=function(){y.isSessionActive()&&y._isAdBreakActive&&(y._isAdBreakActive=!1,y.debugLog("[ ConvivaAnalyticsTracker ] report ad break ended"),y.convivaVideoAnalytics.reportAdBreakEnded())},this.trackAdBreakFinished=function(t){var e=t===i.Constants.AdType.CLIENT_SIDE&&y._isAdBreakActive;if(y.isSessionActive()&&!e){y.trackRestoringContent();var a=p.PlayerStateHelper.getPlayerState(y.player);y.debugLog("[ ConvivaAnalyticsTracker ] report ".concat(a," playback state on ad break finished event")),y.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.PLAYER_STATE,a)}},this.trackAdError=function(t){if(y.isSessionActive()){var e=u.AdHelper.formatCsaiAdError(t);y.debugLog("[ ConvivaAnalyticsTracker ] report ad error",{event:t,formattedError:e}),y.convivaAdAnalytics.reportAdError(e,i.Constants.ErrorSeverity.WARNING)}},this.trackError=function(t){y.isSessionActive()||y.sessionEndedExternally||y.internalInitializeSession(),y.debugLog("[ ConvivaAnalyticsTracker ] report playback deficiency",t),y.reportPlaybackDeficiency(String(t.code)+" "+t.name,i.Constants.ErrorSeverity.FATAL)},this.onSourceUnloaded=function(t){y.debugLog("[ ConvivaAnalyticsTracker ] checking if seession needs to be ended after source unloaded",t),y._isAdBreakActive||y.internalEndSession()},void 0!==i){this.config=a,this.config.debugLoggingEnabled=this.config.debugLoggingEnabled||!1;var A=this.config.deviceMetadata||{},h=((n={})[i.Constants.DeviceMetadata.CATEGORY]=A.category||this.config.deviceCategory||i.Constants.DeviceCategory.WEB,n[i.Constants.DeviceMetadata.BRAND]=A.brand,n[i.Constants.DeviceMetadata.MANUFACTURER]=A.manufacturer,n[i.Constants.DeviceMetadata.MODEL]=A.model,n[i.Constants.DeviceMetadata.TYPE]=A.type,n[i.Constants.DeviceMetadata.VERSION]=A.version,n[i.Constants.DeviceMetadata.OS_NAME]=A.osName,n[i.Constants.DeviceMetadata.OS_VERSION]=A.osVersion,n);i.Analytics.setDeviceMetadata(h);var g={};g[i.Constants.CallbackFunctions.CONSOLE_LOG]=this.logger.consoleLog,g[i.Constants.CallbackFunctions.MAKE_REQUEST]=(new r.Html5Http).makeRequest;var f=new s.Html5Storage;g[i.Constants.CallbackFunctions.SAVE_DATA]=f.saveData,g[i.Constants.CallbackFunctions.LOAD_DATA]=f.loadData,g[i.Constants.CallbackFunctions.CREATE_TIMER]=(new l.Html5Timer).createTimer,g[i.Constants.CallbackFunctions.GET_EPOCH_TIME_IN_MS]=(new c.Html5Time).getEpochTimeMs;var T={};T[i.Constants.GATEWAY_URL]=a.gatewayUrl,T[i.Constants.LOG_LEVEL]=this.config.debugLoggingEnabled?i.Constants.LogLevel.DEBUG:i.Constants.LogLevel.NONE,i.Analytics.init(e,g,T),this.contentMetadataBuilder=new v.ContentMetadataBuilder(this.logger)}else console.error("Conviva script missing, cannot init ConvivaAnalytics. Please load the Conviva script (conviva-core-sdk.min.js) before Bitmovin's ConvivaAnalytics integration.")}return Object.defineProperty(t.prototype,"player",{get:function(){if(!this._player)throw new Error("Player is not initialized, either pass it to the constructor or attach it via `attachPlayer` before using the integration.");return this._player},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPlayerAttached",{get:function(){return!!this._player},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAdBreakActive",{get:function(){return this._isAdBreakActive},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canTrackPlayEvent",{get:function(){return!this._isAdBreakActive},enumerable:!1,configurable:!0}),t.prototype.canAttachPlayer=function(t){var e=void 0;return this.isPlayerAttached&&(e="Player is already attached"),t.getSource()&&(e="Player.load() has already been called (attaching player is possible only before player.load())"),{canAttach:!e,reason:e}},t.prototype.attachPlayer=function(t){this.canAttachPlayer(t).canAttach&&(this._player=t,this.handlers=new y.PlayerEventWrapper(t),this.setPlayerInfo(),this.registerPlayerEvents())},t.prototype.setPlayerInfo=function(){var t;if(this.convivaVideoAnalytics&&this.convivaAdAnalytics&&this.isPlayerAttached){var e=((t={})[i.Constants.FRAMEWORK_NAME]="Bitmovin Player",t[i.Constants.FRAMEWORK_VERSION]=this.player.version,t);this.convivaVideoAnalytics.setPlayerInfo(e),this.convivaAdAnalytics.setAdPlayerInfo(e)}},t.prototype.getContentMetadata=function(){return this.contentMetadataBuilder.build()},t.prototype.startStallTrackingTimeout=function(t){this.isSessionActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] start stall tracking after ".concat(t.type," event")),this.stallTrackingTimeout.start())},t.prototype.clearStallTrackingTimeout=function(t){this.stallTrackingTimeout.isActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] stop stall tracking after ".concat(t.type," event")),this.stallTrackingTimeout.clear())},t.prototype.initializeSession=function(){if(this.isSessionActive())this.logger.consoleLog("[ ConvivaAnalyticsTracker ] There is already a session running.",i.SystemSettings.LogLevel.WARNING);else{if(!this.isPlayerAttached&&!this.contentMetadataBuilder.assetName)throw"Player is not attached during session initialization and `assetName` is empty in the content metadata. Either attach the player before calling `initializeSession` or set the `assetName` manually using `updateContentMetadata`.";if(this.isPlayerAttached&&!this.player.getSource()&&!this.contentMetadataBuilder.assetName)throw"Player is attached but no source is loaded and `assetName` is empty in the content metadata. Either load a source before calling `initializeSession` or set the `assetName` manually using `updateContentMetadata`.";this.internalInitializeSession(),this.sessionEndedExternally=!1}},t.prototype.ensurePlaybackFinished=function(){this.isSessionActive()&&(this._isAdBreakActive&&(this.debugLog("[ ConvivaAnalyticsTracker ] report ad skipped"),this.convivaAdAnalytics.reportAdSkipped()),this.debugLog("[ ConvivaAnalyticsTracker ] report playback ended state"),this.convivaVideoAnalytics.reportPlaybackEnded())},t.prototype.endSession=function(){this.isSessionActive()&&(this.debugLog("[ ConvivaAnalytics ] external ending session"),this.ensurePlaybackFinished(),this.internalEndSession(),this.sessionEndedExternally=!0)},t.prototype.sendCustomApplicationEvent=function(t,e){void 0===e&&(e={}),this.isSessionActive()?(this.debugLog("[ ConvivaAnalyticsTracker ] report custom app event",{eventName:t,eventAttributes:e}),this.convivaVideoAnalytics.reportAppEvent(t,e)):this.logger.consoleLog("[ ConvivaAnalyticsTracker ] cannot send application event, no active monitoring session",i.SystemSettings.LogLevel.WARNING)},t.prototype.sendCustomPlaybackEvent=function(t,e){void 0===e&&(e={}),this.isSessionActive()?(this.debugLog("[ ConvivaAnalyticsTracker ] report custom playback event",{eventName:t,eventAttributes:e}),this.convivaVideoAnalytics.reportPlaybackEvent(t,e)):this.logger.consoleLog("[ ConvivaAnalyticsTracker ] cannot send playback event, no active monitoring session",i.SystemSettings.LogLevel.WARNING)},t.prototype.updateContentMetadata=function(t){this.internalUpdateContentMetadata(t)},t.prototype.reportPlaybackDeficiency=function(t,e,a){void 0===a&&(a=!0),this.isSessionActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] report playback failed",{message:t}),this.convivaVideoAnalytics.reportPlaybackFailed(t),a&&this.internalEndSession())},t.prototype.pauseTracking=function(){this.debugLog("[ ConvivaAnalyticsTracker ] pause tracking via ad break started reporting"),this.convivaVideoAnalytics.reportAdBreakStarted(i.Constants.AdType.CLIENT_SIDE,i.Constants.AdPlayer.SEPARATE)},t.prototype.resumeTracking=function(){this.debugLog("[ ConvivaAnalyticsTracker ] resume tracking via ad break ended reporting"),this.convivaVideoAnalytics.reportAdBreakEnded()},t.prototype.release=function(t){this.debugLog("[ ConvivaAnalyticsTracker ] releasing",{isPlayerDestroyed:t}),t||this.unregisterPlayerEvents(),this._player=null,this.handlers=null,this.ensurePlaybackFinished(),this.internalEndSession(),i.Analytics.release()},t.prototype.debugLog=function(t){for(var e=[],a=1;a<arguments.length;a++)e[a-1]=arguments[a];this.config.debugLoggingEnabled&&console.log.apply(console,arguments)},t.prototype.getUrlFromSource=function(t){switch(this.player.getStreamType()){case"dash":return t.dash;case"hls":return t.hls;case"progressive":return Array.isArray(t.progressive)?t.progressive[0].url:t.progressive}},t.prototype.internalUpdateContentMetadata=function(t){this.contentMetadataBuilder.setOverrides(t),this.isSessionActive()?(this.buildContentMetadata(),this.updateSession()):this.logger.consoleLog("[ ConvivaAnalyticsTracker ] no active session. Content metadata will be propagated to Conviva on session initialization.",i.SystemSettings.LogLevel.DEBUG)},t.prototype.internalInitializeSession=function(){var t=this;this.debugLog("[ ConvivaAnalyticsTracker ] initializing session"),this.buildContentMetadata(),this.convivaVideoAnalytics=i.Analytics.buildVideoAnalytics(),this.convivaAdAnalytics=i.Analytics.buildAdAnalytics(this.convivaVideoAnalytics),this.debugLog("[ ConvivaAnalyticsTracker ] report playback requested"),this.convivaVideoAnalytics.reportPlaybackRequested(this.contentMetadataBuilder.build()),this.sessionKey=this.convivaVideoAnalytics.getSessionId(),this.debugLog("[ ConvivaAnalyticsTracker ] new session key",this.sessionKey),this.setPlayerInfo(),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.PLAYER_STATE,i.Constants.PlayerState.STOPPED),this.convivaVideoAnalytics.setCallback(function(){if(t.isPlayerAttached){var e=t.player.getCurrentTime(n.TimeMode.RelativeTime);if(Number.isFinite(e)){var a=1e3*e;t._isAdBreakActive?(t.debugLog("[ ConvivaAnalyticsTracker ] report ad player head time",a),t.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.PLAY_HEAD_TIME,a)):(t.debugLog("[ ConvivaAnalyticsTracker ] report player head time",a),t.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.PLAY_HEAD_TIME,a))}}}),this.isSessionActive()||this.logger.consoleLog("[ ConvivaAnalyticsTracker ] Something went wrong, could not obtain session key",i.SystemSettings.LogLevel.ERROR)},t.prototype.buildContentMetadata=function(){var a,n;if(this.isPlayerAttached){this.contentMetadataBuilder.duration=this.player.getDuration(),this.contentMetadataBuilder.streamType=this.player.isLive()?i.ContentMetadata.StreamType.LIVE:i.ContentMetadata.StreamType.VOD,this.contentMetadataBuilder.addToCustom(((a={})[e.AUTOPLAY_CONTENT_METADATA_CUSTOM_TAG]=A.PlayerConfigHelper.getAutoplayConfig(this.player)+"",a[e.PRELOAD_CONTENT_METADATA_CUSTOM_TAG]=A.PlayerConfigHelper.getPreloadConfig(this.player)+"",a[e.INTEGRATION_VERSION_CONTENT_METADATA_CUSTOM_TAG]=t.VERSION,a));var r=this.player.getSource();r&&(this.contentMetadataBuilder.assetName=this.getAssetNameFromSource(r),this.contentMetadataBuilder.viewerId=this.contentMetadataBuilder.viewerId,this.contentMetadataBuilder.addToCustom(((n={})[e.PLAYER_TYPE_CONTENT_METADATA_CUSTOM_TAG]=this.player.getPlayerType(),n[e.STREAM_TYPE_CONTENT_METADATA_CUSTOM_TAG]=this.player.getStreamType(),n[e.VR_CONTENT_TYPE_CONTENT_METADATA_CUSTOM_TAG]=r.vr&&r.vr.contentType,n)),this.contentMetadataBuilder.streamUrl=this.getUrlFromSource(r))}else this.debugLog("[ ConvivaAnalyticsTracker ] Player is not attached, skipping default content metadata initialization, it will be initialized on source loaded event")},t.prototype.updateSession=function(){this.isSessionActive()&&this.convivaVideoAnalytics.setContentInfo(this.contentMetadataBuilder.build())},t.prototype.getAssetNameFromSource=function(t){var e=t.title;return e||"Untitled (no source.title set)"},t.prototype.isSessionActive=function(){return!!this.convivaVideoAnalytics},t.prototype.trackPlaybackStateFromEvent=function(t){var e=p.PlayerStateHelper.getPlayerStateFromEvent(t,this.player);this.debugLog("[ ConvivaAnalyticsTracker ] inferred player state ".concat(e," from ").concat(t.type," event"),{playerState:e,event:t}),e&&this.trackPlaybackState(e)},t.prototype.trackPlaybackState=function(t){this.isSessionActive()&&(this._isAdBreakActive?(this.debugLog("[ ConvivaAnalyticsTracker ] report ad playback state",t),this.convivaAdAnalytics.reportAdMetric(i.Constants.Playback.PLAYER_STATE,t)):(this.debugLog("[ ConvivaAnalyticsTracker ] report playback state",t),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.PLAYER_STATE,t)))},t.prototype.trackSeekStart=function(t){this.isSessionActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] report seek started"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SEEK_STARTED,t))},t.prototype.trackSeekEnd=function(){this.isSessionActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] report seek ended"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SEEK_ENDED))},t.prototype.trackUpdateAudioTrack=function(t){if(this.isSessionActive()){var e="unknown"!==t.lang?"["+t.lang+"]:"+t.label:t.label;this.debugLog("[ ConvivaAnalyticsTracker ] report audio language",{formattedAudio:e}),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.AUDIO_LANGUAGE,e)}},t.prototype.trackUpdateSubtitleTrack=function(t){if(this.isSessionActive()){var e="unknown"!==t.lang?"["+t.lang+"]:"+t.label:t.label;"subtitles"===t.kind?(this.debugLog("[ ConvivaAnalyticsTracker ] report subtitles language",{formattedSubtitle:e}),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SUBTITLES_LANGUAGE,e),this.debugLog("[ ConvivaAnalyticsTracker ] report off closed captions language"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.CLOSED_CAPTIONS_LANGUAGE,"off")):"captions"===t.kind?(this.debugLog("[ ConvivaAnalyticsTracker ] report closed captions language",{formattedSubtitle:e}),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.CLOSED_CAPTIONS_LANGUAGE,e),this.debugLog("[ ConvivaAnalyticsTracker ] report off subtitles language"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SUBTITLES_LANGUAGE,"off")):this.trackTurnOffSubtitles()}},t.prototype.trackInitialSubtitles=function(){if(this.isSessionActive()){if(void 0!==this.player.subtitles){var t=this.player.subtitles.list().filter(function(t){return t.enabled});if(1===t.length)return void this.trackUpdateSubtitleTrack(t[0])}this.trackTurnOffSubtitles()}},t.prototype.trackTurnOffSubtitles=function(){this.isSessionActive()&&(this.debugLog("[ ConvivaAnalyticsTracker ] report off subtitles language"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.SUBTITLES_LANGUAGE,"off"),this.debugLog("[ ConvivaAnalyticsTracker ] report off closed captions language"),this.convivaVideoAnalytics.reportPlaybackMetric(i.Constants.Playback.CLOSED_CAPTIONS_LANGUAGE,"off"))},t.prototype.registerPlayerEvents=function(){this.handlers.add(n.PlayerEvent.SourceLoaded,this.onSourceLoaded),this.handlers.add(n.PlayerEvent.Play,this.onPlay),this.handlers.add(n.PlayerEvent.Playing,this.onPlaying),this.handlers.add(n.PlayerEvent.PlaybackFinished,this.onPlaybackFinished),this.handlers.add(n.PlayerEvent.SourceUnloaded,this.onSourceUnloaded)},t.prototype.unregisterPlayerEvents=function(){var t;null===(t=this.handlers)||void 0===t||t.clear()},Object.defineProperty(t,"version",{get:function(){return t.VERSION},enumerable:!1,configurable:!0}),t.VERSION="6.1.2",t.STALL_TRACKING_DELAY_MS=100,t}();e.ConvivaAnalyticsTracker=h},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Logging=void 0;var i=a(0),n=function(){function t(){}return t.prototype.consoleLog=function(t,e){"undefined"!=typeof console&&(console.log&&e===i.SystemSettings.LogLevel.DEBUG||e===i.SystemSettings.LogLevel.INFO?console.log(t):console.warn&&e===i.SystemSettings.LogLevel.WARNING?console.warn(t):console.error&&e===i.SystemSettings.LogLevel.ERROR&&console.error(t))},t.prototype.release=function(){},t}();e.Html5Logging=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PlayerEventWrapper=void 0;var i=a(16),n=function(){function t(t){this.player=t,this.eventHandlers={}}return t.prototype.add=function(t,e){this.player.on(t,e),this.eventHandlers[t]||(this.eventHandlers[t]=[]),this.eventHandlers[t].push(e)},t.prototype.remove=function(t,e){this.player.off(t,e),this.eventHandlers[t]&&i.ArrayUtils.remove(this.eventHandlers[t],e)},t.prototype.clear=function(){for(var t in this.eventHandlers)for(var e=0,a=this.eventHandlers[t];e<a.length;e++){var i=a[e];this.remove(t,i)}},t}();e.PlayerEventWrapper=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConvivaAnalytics=void 0,a(7);var i=a(8);Object.defineProperty(e,"ConvivaAnalytics",{enumerable:!0,get:function(){return i.ConvivaAnalytics}})},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConvivaAnalytics=void 0;var i=a(0),n=a(1),r=a(9),o=a(3),s=a(20),c=a(5),l=a(2),d=a(4),v=function(){function t(t,e,a){void 0===a&&(a={});var n=this;this.logger=new d.Html5Logging,this.mainContentDuration=0,this.onPlaybackStateChanged=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] playback state change related event",t),n.convivaAnalyticsTracker.trackPlaybackStateFromEvent(t)},this.onPlaying=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] playing",t),n.onPlaybackStateChanged(t)},this.onVideoQualityChanged=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] video quality changed",t),n.convivaAnalyticsTracker.trackVideoQualityChanged(t)},this.onCustomEvent=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] custom playback related event",t);var e=r.ObjectUtils.flatten(t);n.sendCustomPlaybackEvent(t.type,e)},this.onAdBreakStarted=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] adbreak started",t),n.lastAdBreakEvent=t,n.convivaAnalyticsTracker.trackAdBreakStarted(i.Constants.AdType.CLIENT_SIDE),n.convivaAnalyticsTracker.trackPlaybackStateFromEvent(t)},this.onAdStarted=function(t){var e;if(n.lastAdBreakEvent){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] ad started",t);var a=l.AdHelper.extractCsaiConvivaAdInfo(n.lastAdBreakEvent,n.mainContentDuration,t),r=null===(e=t.ad.data)||void 0===e?void 0:e.bitrate;n.convivaAnalyticsTracker.trackAdStarted(a,i.Constants.AdType.CLIENT_SIDE,r)}else n.debugLog("[ ConvivaAnalytics ] received ad started without active ad break",t)},this.onAdFinished=function(t){n.lastAdBreakEvent?(n.debugLog("[ ConvivaAnalytics ] [ Player Event ] ad finished",t),n.convivaAnalyticsTracker.trackAdFinished(),n.convivaAnalyticsTracker.trackPlaybackStateFromEvent(t)):n.debugLog("[ ConvivaAnalytics ] received ad finished without active ad break",t)},this.onAdSkipped=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] ad skipped",t),n.convivaAnalyticsTracker.trackAdSkipped(),n.onCustomEvent(t)},this.onRestoringContent=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] restoring content",t),n.convivaAnalyticsTracker.trackRestoringContent(),n.convivaAnalyticsTracker.trackPlaybackStateFromEvent(t)},this.onAdBreakFinished=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] adbreak finished",t),n.convivaAnalyticsTracker.trackAdBreakFinished(i.Constants.AdType.CLIENT_SIDE)},this.onAdError=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] ad error",t),n.convivaAnalyticsTracker.trackAdError(t),n.onCustomEvent(t)},this.onSeek=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] seek",t),n.convivaAnalyticsTracker.trackSeekStart(t.seekTarget)},this.onSeeked=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] seeked",t),n.convivaAnalyticsTracker.trackSeekEnd(),n.onPlaybackStateChanged(t)},this.onTimeShift=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] time shift",t),n.convivaAnalyticsTracker.trackSeekStart(-1)},this.onTimeShifted=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] time shifted",t),n.convivaAnalyticsTracker.trackSeekEnd(),n.onPlaybackStateChanged(t)},this.onAudioChanged=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] audio changed",t),n.convivaAnalyticsTracker.trackUpdateAudioTrack(t.targetAudio)},this.onSubtitleEnabled=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] subtitled enabled",t),n.convivaAnalyticsTracker.trackUpdateSubtitleTrack(t.subtitle)},this.onSubtitleDisabled=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] subtitles disabled",t),n.convivaAnalyticsTracker.trackTurnOffSubtitles()},this.onError=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] error",t),n.convivaAnalyticsTracker.trackError(t)},this.onDestroy=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] destroy",t),n.releaseInternal(t)},this.onSourceLoaded=function(t){n.debugLog("[ ConvivaAnalytics ] [ Player Event ] onSourceLoaded",t),n.mainContentDuration=n.player.getDuration()},this.convivaAnalyticsTracker=new o.ConvivaAnalyticsTracker(e,a),this.debugLoggingEnabled=a.debugLoggingEnabled||!1,this._player=t,t&&this.attachPlayer(t),this.convivaSsaiAnalytics=new s.ConvivaAnalyticsSsai(this.convivaAnalyticsTracker),this.ssai={get isAdBreakActive(){return this.convivaSsaiAnalytics.isAdBreakActive},reportAdBreakStarted:this.convivaSsaiAnalytics.reportAdBreakStarted.bind(this.convivaSsaiAnalytics),reportAdStarted:this.convivaSsaiAnalytics.reportAdStarted.bind(this.convivaSsaiAnalytics),reportAdFinished:this.convivaSsaiAnalytics.reportAdFinished.bind(this.convivaSsaiAnalytics),reportAdSkipped:this.convivaSsaiAnalytics.reportAdSkipped.bind(this.convivaSsaiAnalytics),reportAdBreakFinished:this.convivaSsaiAnalytics.reportAdBreakFinished.bind(this.convivaSsaiAnalytics)}}return Object.defineProperty(t.prototype,"player",{get:function(){if(!this._player)throw new Error("Player is not initialized, either pass it to the constructor or attach it via `attachPlayer` before using the integration.");return this._player},enumerable:!1,configurable:!0}),t.prototype.attachPlayer=function(t){var e=this.convivaAnalyticsTracker.canAttachPlayer(t),a=e.canAttach,n=e.reason;a?(this.convivaAnalyticsTracker.attachPlayer(t),this._player=t,this.handlers=new c.PlayerEventWrapper(t),this.registerPlayerEvents()):this.logger.consoleLog("[ ConvivaAnalyticsTracker ] cannot attach player: ".concat(n),i.SystemSettings.LogLevel.WARNING)},t.prototype.initializeSession=function(){this.convivaAnalyticsTracker.initializeSession()},t.prototype.endSession=function(){this.debugLog("[ ConvivaAnalytics ] external ending session"),this.convivaSsaiAnalytics.reset(),this.convivaAnalyticsTracker.endSession()},t.prototype.sendCustomApplicationEvent=function(t,e){void 0===e&&(e={}),this.convivaAnalyticsTracker.sendCustomApplicationEvent(t,e)},t.prototype.sendCustomPlaybackEvent=function(t,e){void 0===e&&(e={}),this.convivaAnalyticsTracker.sendCustomPlaybackEvent(t,e)},t.prototype.updateContentMetadata=function(t){this.convivaAnalyticsTracker.updateContentMetadata(t)},t.prototype.reportPlaybackDeficiency=function(t,e,a){void 0===a&&(a=!0),this.convivaAnalyticsTracker.reportPlaybackDeficiency(t,e,a)},t.prototype.pauseTracking=function(){this.convivaAnalyticsTracker.pauseTracking()},t.prototype.resumeTracking=function(){this.convivaAnalyticsTracker.resumeTracking()},t.prototype.release=function(){this.releaseInternal()},t.prototype.releaseInternal=function(t){var e=(null==t?void 0:t.type)===n.PlayerEvent.Destroy;e||this.unregisterPlayerEvents(),this._player=null,this.handlers=null,this.debugLog("[ ConvivaAnalytics ] releasing",{event:t,isPlayerDestroyed:e}),this.convivaAnalyticsTracker.release(e),this.convivaSsaiAnalytics.reset(),this.lastAdBreakEvent=null},t.prototype.debugLog=function(t){for(var e=[],a=1;a<arguments.length;a++)e[a-1]=arguments[a];this.debugLoggingEnabled&&console.log.apply(console,arguments)},t.prototype.registerPlayerEvents=function(){var e=this;this.handlers.add(n.PlayerEvent.SourceLoaded,this.onSourceLoaded),this.handlers.add(n.PlayerEvent.Playing,this.onPlaying),this.handlers.add(n.PlayerEvent.Paused,this.onPlaybackStateChanged),this.handlers.add(n.PlayerEvent.StallStarted,this.onPlaybackStateChanged),this.handlers.add(n.PlayerEvent.StallEnded,this.onPlaybackStateChanged),this.handlers.add(n.PlayerEvent.VideoPlaybackQualityChanged,this.onVideoQualityChanged),this.handlers.add(n.PlayerEvent.AudioPlaybackQualityChanged,this.onCustomEvent),this.handlers.add(n.PlayerEvent.Muted,this.onCustomEvent),this.handlers.add(n.PlayerEvent.Unmuted,this.onCustomEvent),this.handlers.add(n.PlayerEvent.ViewModeChanged,this.onCustomEvent),this.handlers.add(n.PlayerEvent.AdStarted,this.onAdStarted),this.handlers.add(n.PlayerEvent.AdFinished,this.onAdFinished),this.handlers.add(n.PlayerEvent.AdBreakStarted,this.onAdBreakStarted),this.handlers.add(n.PlayerEvent.RestoringContent,this.onRestoringContent),this.handlers.add(n.PlayerEvent.AdBreakFinished,this.onAdBreakFinished),this.handlers.add(n.PlayerEvent.AdSkipped,this.onAdSkipped),this.handlers.add(n.PlayerEvent.AdError,this.onAdError),this.handlers.add(n.PlayerEvent.Error,this.onError),this.handlers.add(n.PlayerEvent.Destroy,this.onDestroy),this.handlers.add(n.PlayerEvent.Seek,this.onSeek),this.handlers.add(n.PlayerEvent.Seeked,this.onSeeked),this.handlers.add(n.PlayerEvent.TimeShift,this.onTimeShift),this.handlers.add(n.PlayerEvent.TimeShifted,this.onTimeShifted),this.handlers.add(n.PlayerEvent.AudioChanged,this.onAudioChanged),this.handlers.add(n.PlayerEvent.SubtitleEnabled,this.onSubtitleEnabled),this.handlers.add(n.PlayerEvent.SubtitleDisabled,this.onSubtitleDisabled),this.handlers.add(n.PlayerEvent.CastStarted,this.onCustomEvent),this.handlers.add(n.PlayerEvent.CastStopped,this.onCustomEvent),t.stallTrackingStartEvents.forEach(function(t){e.handlers.add(t,function(t){e.convivaAnalyticsTracker.startStallTrackingTimeout(t)})}),t.stallTrackingClearEvents.forEach(function(t){e.handlers.add(t,function(t){e.convivaAnalyticsTracker.clearStallTrackingTimeout(t)})})},t.prototype.unregisterPlayerEvents=function(){var t;null===(t=this.handlers)||void 0===t||t.clear()},t.stallTrackingStartEvents=[n.PlayerEvent.Play,n.PlayerEvent.Seek,n.PlayerEvent.TimeShift],t.stallTrackingClearEvents=[n.PlayerEvent.StallStarted,n.PlayerEvent.Playing,n.PlayerEvent.Paused,n.PlayerEvent.Seeked,n.PlayerEvent.TimeShifted,n.PlayerEvent.StallEnded,n.PlayerEvent.PlaybackFinished,n.PlayerEvent.AdStarted],t}();e.ConvivaAnalytics=v},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ObjectUtils=void 0,function(t){t.flatten=function(t,e){void 0===e&&(e="");var a={},i=function(t,e){for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];"object"==typeof r?i(r,e+n+"."):a[e+n]=String(r)}};return i(t,e),a}}(e.ObjectUtils||(e.ObjectUtils={}))},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Http=void 0;var i=function(){function t(){}return t.prototype.makeRequest=function(t,e,a,i,n,r){return this.makeRequestStandard.apply(this,arguments)},t.prototype.release=function(){},t.prototype.makeRequestStandard=function(t,e,a,i,n,r){var o=new XMLHttpRequest;return o.open(t,e,!0),i&&o.overrideMimeType&&o.overrideMimeType(i),i&&o.setRequestHeader&&o.setRequestHeader("Content-Type",i),n>0&&(o.timeout=n,o.ontimeout=function(){o.ontimeout=o.onreadystatechange=null,r&&r(!1,"timeout after "+n+" ms")}),o.onreadystatechange=function(){4===o.readyState&&(o.ontimeout=o.onreadystatechange=null,200===o.status?r&&r(!0,o.responseText):r&&r(!1,"http status "+o.status))},o.send(a),null},t}();e.Html5Http=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Storage=void 0;var i=function(){function t(){}return t.prototype.saveData=function(t,e,a,i){var n=t+"."+e;try{localStorage.setItem(n,a),i(!0,null)}catch(t){i(!1,t.toString())}},t.prototype.loadData=function(t,e,a){var i=t+"."+e;try{a(!0,localStorage.getItem(i))}catch(t){a(!1,t.toString())}},t.prototype.release=function(){},t}();e.Html5Storage=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Time=void 0;var i=function(){function t(){}return t.prototype.getEpochTimeMs=function(){return(new Date).getTime()},t.prototype.release=function(){},t}();e.Html5Time=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Html5Timer=void 0;var i=function(){function t(){}return t.prototype.createTimer=function(t,e,a){var i=window.setInterval(t,e);return function(){-1!==i&&(clearInterval(i),i=-1)}},t.prototype.release=function(){},t}();e.Html5Timer=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Timeout=void 0;var i=function(){function t(t,e,a){void 0===a&&(a=!1),this.delay=t,this.callback=e,this.repeat=a,this.timeoutOrIntervalId=0,this.active=!1,this.suspended=!1}return t.prototype.start=function(){return this.reset(),this},t.prototype.clear=function(){this.clearInternal()},t.prototype.suspend=function(){return this.suspended=!0,this.clearInternal(),this},t.prototype.resume=function(t){return this.suspended=!1,t&&this.reset(),this},t.prototype.reset=function(){var t=this;this.clearInternal(),this.suspended||(this.repeat?this.timeoutOrIntervalId=setInterval(this.callback,this.delay):this.timeoutOrIntervalId=setTimeout(function(){t.active=!1,t.callback()},this.delay),this.active=!0)},t.prototype.isActive=function(){return this.active},t.prototype.clearInternal=function(){this.repeat?clearInterval(this.timeoutOrIntervalId):clearTimeout(this.timeoutOrIntervalId),this.active=!1},t}();e.Timeout=i},function(t,e,a){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,a=1,i=arguments.length;a<i;a++)for(var n in e=arguments[a])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.ContentMetadataBuilder=void 0;var n=a(0),r=function(){function t(t){this.metadataOverrides={},this.metadata={},this.latestBuiltMetadata={},this.playbackStarted=!1,this.logger=t}return t.prototype.setOverrides=function(t){this.playbackStarted&&this.logger.consoleLog("[ Conviva Analytics ] Playback has started. Only some metadata attributes will be updated",n.SystemSettings.LogLevel.WARNING),this.metadataOverrides=i(i({},this.metadataOverrides),t)},t.prototype.getOverrides=function(){return this.metadataOverrides},t.prototype.setPlaybackStarted=function(t){this.playbackStarted=t},t.prototype.getStaticMetadata=function(){var t={};return this.playbackStarted?(t.assetName=this.latestBuiltMetadata.assetName,t.viewerId=this.latestBuiltMetadata.viewerId,t.streamType=this.latestBuiltMetadata.streamType,t.applicationName=this.latestBuiltMetadata.applicationName,t.duration=this.latestBuiltMetadata.duration,t.custom=this.latestBuiltMetadata.custom):(t.assetName=this.latestBuiltMetadata.assetName||this.assetName,t.viewerId=this.viewerId,t.streamType=this.metadataOverrides.streamType||this.metadata.streamType,t.applicationName=this.metadataOverrides.applicationName||this.metadata.applicationName,t.duration=this.metadataOverrides.duration||this.metadata.duration,t.custom=i(i(i({},this.metadataOverrides.custom),this.metadataOverrides.additionalStandardTags),this.metadata.custom)),t},t.prototype.getDynamicMetadata=function(){return{encodedFrameRate:this.metadataOverrides.encodedFrameRate||this.metadata.encodedFrameRate,defaultResource:this.metadataOverrides.defaultResource||this.metadata.defaultResource,streamUrl:this.metadataOverrides.streamUrl||this.metadata.streamUrl}},t.prototype.build=function(){var t,e=i(i({},this.getStaticMetadata()),this.getDynamicMetadata());this.latestBuiltMetadata=e;var a=((t={})[n.Constants.ASSET_NAME]=e.assetName,t[n.Constants.ENCODED_FRAMERATE]=e.encodedFrameRate,t[n.Constants.DURATION]=e.duration,t[n.Constants.DEFAULT_RESOURCE]=e.defaultResource,t[n.Constants.STREAM_URL]=e.streamUrl,t[n.Constants.IS_LIVE]=e.streamType,t[n.Constants.VIEWER_ID]=e.viewerId||"GET_VIEWER_ID_FROM_PLAYER",t[n.Constants.PLAYER_NAME]=e.applicationName||"GET_PLAYER_NAME_OR_TYPE",t);return i(i({},a),e.custom)},Object.defineProperty(t.prototype,"assetName",{get:function(){return this.metadataOverrides.assetName||this.metadata.assetName},set:function(t){this.metadata.assetName=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewerId",{get:function(){return this.metadataOverrides.viewerId||this.metadata.viewerId},set:function(t){this.metadata.viewerId=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"streamType",{set:function(t){this.metadata.streamType=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"applicationName",{set:function(t){this.metadata.applicationName=t},enumerable:!1,configurable:!0}),t.prototype.addToCustom=function(t){this.metadata.custom=i(i({},this.metadata.custom),t)},Object.defineProperty(t.prototype,"duration",{set:function(t){this.metadata.duration=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"encodedFrameRate",{set:function(t){this.metadata.encodedFrameRate=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"defaultResource",{set:function(t){this.metadata.defaultResource=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"streamUrl",{set:function(t){this.metadata.streamUrl=t},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.latestBuiltMetadata={}},t}();e.ContentMetadataBuilder=r},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ArrayUtils=void 0,function(t){t.remove=function(t,e){var a=t.indexOf(e);return a>-1?t.splice(a,1)[0]:null}}(e.ArrayUtils||(e.ArrayUtils={}))},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PlayerConfigHelper=void 0;var i=a(18),n=function(){function t(){}return t.getAutoplayConfig=function(e){var a=e.getConfig();return a.playback&&void 0!==a.playback.autoplay?a.playback.autoplay:t.AUTOPLAY_DEFAULT_CONFIG},t.getPreloadConfig=function(t){var e=t.getConfig();if(i.BrowserUtils.isMobile()){if(e.adaptation&&e.adaptation.mobile&&void 0!==e.adaptation.mobile.preload)return e.adaptation.mobile.preload}else if(e.adaptation&&e.adaptation.desktop&&void 0!==e.adaptation.desktop.preload)return e.adaptation.desktop.preload;return e.adaptation&&void 0!==e.adaptation.preload?e.adaptation.preload:!t.isLive()},t.AUTOPLAY_DEFAULT_CONFIG=!1,t}();e.PlayerConfigHelper=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserUtils=void 0;var i=function(){function t(){}return t.isMobile=function(){var t=/Android/i.test(navigator.userAgent),e=/IEMobile/i.test(navigator.userAgent),a=/Windows Phone 10.0/i.test(navigator.userAgent),i=/Safari/i.test(navigator.userAgent)&&/Mobile/i.test(navigator.userAgent);return t||e||a||i},t}();e.BrowserUtils=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PlayerStateHelper=void 0;var i=a(1),n=a(0),r=function(){function t(){}return t.getPlayerStateFromEvent=function(t,e){var a;switch(t.type){case i.PlayerEvent.AdBreakStarted:case i.PlayerEvent.AdFinished:case i.PlayerEvent.RestoringContent:case i.PlayerEvent.StallStarted:a=n.Constants.PlayerState.BUFFERING;break;case i.PlayerEvent.Playing:a=n.Constants.PlayerState.PLAYING;break;case i.PlayerEvent.Paused:a=n.Constants.PlayerState.PAUSED;break;case i.PlayerEvent.Seeked:case i.PlayerEvent.TimeShifted:case i.PlayerEvent.StallEnded:a=e.isPlaying()?n.Constants.PlayerState.PLAYING:n.Constants.PlayerState.PAUSED}return a},t.getPlayerState=function(t){return t.isStalled()?n.Constants.PlayerState.BUFFERING:t.isPlaying()?n.Constants.PlayerState.PLAYING:n.Constants.PlayerState.PAUSED},t}();e.PlayerStateHelper=r},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ConvivaAnalyticsSsai=void 0;var i=a(0),n=a(2),r=function(){function t(t){this._isAdBreakActive=!1,this.convivaAnalyticsTracker=t}return Object.defineProperty(t.prototype,"isAdBreakActive",{get:function(){return this._isAdBreakActive},enumerable:!1,configurable:!0}),t.prototype.reset=function(){this._isAdBreakActive=!1},t.prototype.reportAdBreakStarted=function(){this.convivaAnalyticsTracker.isAdBreakActive||this._isAdBreakActive||(this._isAdBreakActive=!0,this.convivaAnalyticsTracker.trackAdBreakStarted(i.Constants.AdType.SERVER_SIDE))},t.prototype.reportAdStarted=function(t){this._isAdBreakActive&&this.convivaAnalyticsTracker.trackAdStarted(n.AdHelper.convertSsaiAdInfoToConvivaAdInfo(t,this.convivaAnalyticsTracker.getContentMetadata()),i.Constants.AdType.SERVER_SIDE)},t.prototype.reportAdFinished=function(){this.isAdBreakActive&&this.convivaAnalyticsTracker.trackAdFinished()},t.prototype.reportAdSkipped=function(){this._isAdBreakActive&&this.convivaAnalyticsTracker.trackAdSkipped()},t.prototype.reportAdBreakFinished=function(){this._isAdBreakActive&&(this._isAdBreakActive=!1,this.convivaAnalyticsTracker.trackAdBreakFinished(i.Constants.AdType.SERVER_SIDE))},t}();e.ConvivaAnalyticsSsai=r}])}); | ||
//# sourceMappingURL=bitmovin-player-analytics-conviva.js.map |
@@ -116,5 +116,3 @@ import * as Conviva from '@convivainc/conviva-js-coresdk'; | ||
private onPlaybackStateChanged; | ||
private onPlay; | ||
private onPlaying; | ||
private onPlaybackFinished; | ||
private onVideoQualityChanged; | ||
@@ -139,4 +137,6 @@ private onCustomEvent; | ||
private onSourceLoaded; | ||
private static readonly stallTrackingStartEvents; | ||
private static readonly stallTrackingClearEvents; | ||
private registerPlayerEvents; | ||
private unregisterPlayerEvents; | ||
} |
@@ -23,11 +23,4 @@ "use strict"; | ||
_this.debugLog('[ ConvivaAnalytics ] [ Player Event ] playback state change related event', event); | ||
_this.convivaAnalyticsTracker.trackPlaybackStateChanged(event); | ||
_this.convivaAnalyticsTracker.trackPlaybackStateFromEvent(event); | ||
}; | ||
this.onPlay = function (event) { | ||
_this.debugLog('[ ConvivaAnalytics ] [ Player Event ] play', event); | ||
if (!_this.convivaAnalyticsTracker.canTrackPlayEvent) { | ||
return; | ||
} | ||
_this.onPlaybackStateChanged(event); | ||
}; | ||
this.onPlaying = function (event) { | ||
@@ -37,6 +30,2 @@ _this.debugLog('[ ConvivaAnalytics ] [ Player Event ] playing', event); | ||
}; | ||
this.onPlaybackFinished = function (event) { | ||
_this.debugLog('[ ConvivaAnalytics ] [ Player Event ] playback finished', event); | ||
_this.onPlaybackStateChanged(event); | ||
}; | ||
this.onVideoQualityChanged = function (event) { | ||
@@ -55,6 +44,10 @@ _this.debugLog('[ ConvivaAnalytics ] [ Player Event ] video quality changed', event); | ||
_this.convivaAnalyticsTracker.trackAdBreakStarted(Conviva.Constants.AdType.CLIENT_SIDE); | ||
_this.convivaAnalyticsTracker.trackPlaybackStateChanged(event); | ||
_this.convivaAnalyticsTracker.trackPlaybackStateFromEvent(event); | ||
}; | ||
this.onAdStarted = function (event) { | ||
var _a; | ||
if (!_this.lastAdBreakEvent) { | ||
_this.debugLog('[ ConvivaAnalytics ] received ad started without active ad break', event); | ||
return; | ||
} | ||
_this.debugLog('[ ConvivaAnalytics ] [ Player Event ] ad started', event); | ||
@@ -64,8 +57,12 @@ var adInfo = AdHelper_1.AdHelper.extractCsaiConvivaAdInfo(_this.lastAdBreakEvent, _this.mainContentDuration, event); | ||
_this.convivaAnalyticsTracker.trackAdStarted(adInfo, Conviva.Constants.AdType.CLIENT_SIDE, bitrateKbps); | ||
_this.convivaAnalyticsTracker.trackPlaybackStateChanged(event); | ||
// No need to call reportPlaybackStateFromEvent as this is covered by `trackAdStarted` | ||
}; | ||
this.onAdFinished = function (event) { | ||
if (!_this.lastAdBreakEvent) { | ||
_this.debugLog('[ ConvivaAnalytics ] received ad finished without active ad break', event); | ||
return; | ||
} | ||
_this.debugLog('[ ConvivaAnalytics ] [ Player Event ] ad finished', event); | ||
_this.convivaAnalyticsTracker.trackAdFinished(); | ||
_this.convivaAnalyticsTracker.trackPlaybackStateChanged(event); | ||
_this.convivaAnalyticsTracker.trackPlaybackStateFromEvent(event); | ||
}; | ||
@@ -80,6 +77,8 @@ this.onAdSkipped = function (event) { | ||
_this.convivaAnalyticsTracker.trackRestoringContent(); | ||
_this.convivaAnalyticsTracker.trackPlaybackStateFromEvent(event); | ||
}; | ||
this.onAdBreakFinished = function (event) { | ||
_this.debugLog('[ ConvivaAnalytics ] [ Player Event ] adbreak finished', event); | ||
_this.convivaAnalyticsTracker.trackAdBreakFinished(); | ||
_this.convivaAnalyticsTracker.trackAdBreakFinished(Conviva.Constants.AdType.CLIENT_SIDE); | ||
// No need to call reportPlaybackStateFromEvent as this is covered by `trackAdBreakFinished` | ||
}; | ||
@@ -94,3 +93,2 @@ this.onAdError = function (event) { | ||
_this.convivaAnalyticsTracker.trackSeekStart(event.seekTarget); | ||
_this.onPlaybackStateChanged(event); | ||
}; | ||
@@ -106,3 +104,2 @@ this.onSeeked = function (event) { | ||
_this.convivaAnalyticsTracker.trackSeekStart(-1); | ||
_this.onPlaybackStateChanged(event); | ||
}; | ||
@@ -313,4 +310,4 @@ this.onTimeShifted = function (event) { | ||
ConvivaAnalytics.prototype.registerPlayerEvents = function () { | ||
var _this = this; | ||
this.handlers.add(bitmovin_player_1.PlayerEvent.SourceLoaded, this.onSourceLoaded); | ||
this.handlers.add(bitmovin_player_1.PlayerEvent.Play, this.onPlay); | ||
this.handlers.add(bitmovin_player_1.PlayerEvent.Playing, this.onPlaying); | ||
@@ -320,3 +317,2 @@ this.handlers.add(bitmovin_player_1.PlayerEvent.Paused, this.onPlaybackStateChanged); | ||
this.handlers.add(bitmovin_player_1.PlayerEvent.StallEnded, this.onPlaybackStateChanged); | ||
this.handlers.add(bitmovin_player_1.PlayerEvent.PlaybackFinished, this.onPlaybackFinished); | ||
this.handlers.add(bitmovin_player_1.PlayerEvent.VideoPlaybackQualityChanged, this.onVideoQualityChanged); | ||
@@ -345,2 +341,12 @@ this.handlers.add(bitmovin_player_1.PlayerEvent.AudioPlaybackQualityChanged, this.onCustomEvent); | ||
this.handlers.add(bitmovin_player_1.PlayerEvent.CastStopped, this.onCustomEvent); | ||
ConvivaAnalytics.stallTrackingStartEvents.forEach(function (eventName) { | ||
_this.handlers.add(eventName, function (event) { | ||
_this.convivaAnalyticsTracker.startStallTrackingTimeout(event); | ||
}); | ||
}); | ||
ConvivaAnalytics.stallTrackingClearEvents.forEach(function (eventName) { | ||
_this.handlers.add(eventName, function (event) { | ||
_this.convivaAnalyticsTracker.clearStallTrackingTimeout(event); | ||
}); | ||
}); | ||
}; | ||
@@ -351,2 +357,17 @@ ConvivaAnalytics.prototype.unregisterPlayerEvents = function () { | ||
}; | ||
ConvivaAnalytics.stallTrackingStartEvents = [ | ||
bitmovin_player_1.PlayerEvent.Play, | ||
bitmovin_player_1.PlayerEvent.Seek, | ||
bitmovin_player_1.PlayerEvent.TimeShift, | ||
]; | ||
ConvivaAnalytics.stallTrackingClearEvents = [ | ||
bitmovin_player_1.PlayerEvent.StallStarted, | ||
bitmovin_player_1.PlayerEvent.Playing, | ||
bitmovin_player_1.PlayerEvent.Paused, | ||
bitmovin_player_1.PlayerEvent.Seeked, | ||
bitmovin_player_1.PlayerEvent.TimeShifted, | ||
bitmovin_player_1.PlayerEvent.StallEnded, | ||
bitmovin_player_1.PlayerEvent.PlaybackFinished, | ||
bitmovin_player_1.PlayerEvent.AdStarted, | ||
]; | ||
return ConvivaAnalytics; | ||
@@ -353,0 +374,0 @@ }()); |
@@ -79,3 +79,3 @@ "use strict"; | ||
this._isAdBreakActive = false; | ||
this.convivaAnalyticsTracker.trackAdBreakFinished(); | ||
this.convivaAnalyticsTracker.trackAdBreakFinished(Conviva.Constants.AdType.SERVER_SIDE); | ||
}; | ||
@@ -82,0 +82,0 @@ return ConvivaAnalyticsSsai; |
@@ -109,2 +109,4 @@ import * as Conviva from '@convivainc/conviva-js-coresdk'; | ||
private stallTrackingTimeout; | ||
startStallTrackingTimeout(event: PlayerEventBase): void; | ||
clearStallTrackingTimeout(event: PlayerEventBase): void; | ||
/** | ||
@@ -160,6 +162,8 @@ * Boolean to track whether a session was ended by an upstream caller instead of within internal session management. | ||
private onSourceLoaded; | ||
trackPlaybackStateChanged(event: PlayerEventBase): void; | ||
trackPlaybackStateFromEvent(event: PlayerEventBase): void; | ||
private trackPlaybackState; | ||
private onPlay; | ||
private onPlaying; | ||
private onPlaybackFinished; | ||
private trackPlaybackFinished; | ||
trackVideoQualityChanged: (event: VideoQualityChangedEvent) => void; | ||
@@ -171,3 +175,3 @@ trackAdBreakStarted: (type: Conviva.valueof<Conviva.ConvivaConstants['AdType']>) => void; | ||
trackRestoringContent: () => void; | ||
trackAdBreakFinished: () => void; | ||
trackAdBreakFinished: (type: Conviva.valueof<Conviva.ConvivaConstants['AdType']>) => void; | ||
trackAdError: (event: ErrorEvent) => void; | ||
@@ -174,0 +178,0 @@ trackSeekStart(target: number): void; |
@@ -39,10 +39,3 @@ "use strict"; | ||
this.stallTrackingTimeout = new timeout_1.Timeout(ConvivaAnalyticsTracker.STALL_TRACKING_DELAY_MS, function () { | ||
if (_this._isAdBreakActive) { | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] report buffering ad playback state'); | ||
_this.convivaAdAnalytics.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE, Conviva.Constants.PlayerState.BUFFERING); | ||
} | ||
else { | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] report buffering playback state'); | ||
_this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE, Conviva.Constants.PlayerState.BUFFERING); | ||
} | ||
_this.trackPlaybackState(Conviva.Constants.PlayerState.BUFFERING); | ||
}); | ||
@@ -68,6 +61,6 @@ /** | ||
this.onSourceLoaded = function (event) { | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] source loaded', event); | ||
if (!_this.isSessionActive()) { | ||
return; | ||
} | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] building content metadata after source loaded event', event); | ||
_this.buildContentMetadata(); | ||
@@ -77,3 +70,3 @@ _this.updateSession(); | ||
this.onPlay = function (event) { | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] play'); | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] checking if session needs to be initialized after play event'); | ||
if (!_this.canTrackPlayEvent) { | ||
@@ -95,6 +88,6 @@ return; | ||
this.onPlaying = function (event) { | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] playing', event); | ||
if (!_this.isSessionActive()) { | ||
return; | ||
} | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] updating session metadata after playing event', event); | ||
_this.contentMetadataBuilder.setPlaybackStarted(true); | ||
@@ -104,6 +97,7 @@ _this.updateSession(); | ||
this.onPlaybackFinished = function (event) { | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] playback finished', event); | ||
if (!_this.isSessionActive()) { | ||
return; | ||
} | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] releasing everything after playback finished event', event); | ||
_this.trackPlaybackFinished(); | ||
_this.convivaVideoAnalytics.release(); | ||
@@ -114,2 +108,6 @@ _this.convivaVideoAnalytics = null; | ||
}; | ||
this.trackPlaybackFinished = function () { | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] report playback ended'); | ||
_this.convivaVideoAnalytics.reportPlaybackEnded(); | ||
}; | ||
this.trackVideoQualityChanged = function (event) { | ||
@@ -146,3 +144,3 @@ if (!_this.isSessionActive()) { | ||
_this.convivaAdAnalytics.reportAdStarted(adInfo); | ||
_this.debugLog("[ ConvivaAnalyticsTracker ] report ".concat(PlayerStateHelper_1.PlayerStateHelper.getPlayerState(_this.player), " ad playback state")); | ||
_this.debugLog("[ ConvivaAnalyticsTracker ] report ".concat(PlayerStateHelper_1.PlayerStateHelper.getPlayerState(_this.player), " ad playback state on ad started event")); | ||
_this.convivaAdAnalytics.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE, PlayerStateHelper_1.PlayerStateHelper.getPlayerState(_this.player)); | ||
@@ -179,3 +177,3 @@ if (type === Conviva.Constants.AdType.SERVER_SIDE) { | ||
this.trackRestoringContent = function () { | ||
if (!_this.isSessionActive()) { | ||
if (!_this.isSessionActive() || !_this._isAdBreakActive) { | ||
return; | ||
@@ -187,8 +185,12 @@ } | ||
}; | ||
this.trackAdBreakFinished = function () { | ||
if (!_this.isSessionActive() || _this._isAdBreakActive) { | ||
this.trackAdBreakFinished = function (type) { | ||
var shouldExpectAnotherCsaiAd = type === Conviva.Constants.AdType.CLIENT_SIDE && _this._isAdBreakActive; | ||
if (!_this.isSessionActive() || shouldExpectAnotherCsaiAd) { | ||
// We only care to update the playback state when we are restoring main content. | ||
return; | ||
} | ||
_this.debugLog("[ ConvivaAnalyticsTracker ] report ".concat(PlayerStateHelper_1.PlayerStateHelper.getPlayerState(_this.player), " playback state")); | ||
_this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE, PlayerStateHelper_1.PlayerStateHelper.getPlayerState(_this.player)); | ||
_this.trackRestoringContent(); | ||
var playerState = PlayerStateHelper_1.PlayerStateHelper.getPlayerState(_this.player); | ||
_this.debugLog("[ ConvivaAnalyticsTracker ] report ".concat(playerState, " playback state on ad break finished event")); | ||
_this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE, playerState); | ||
}; | ||
@@ -215,3 +217,3 @@ this.trackAdError = function (event) { | ||
this.onSourceUnloaded = function (event) { | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] source unloaded', event); | ||
_this.debugLog('[ ConvivaAnalyticsTracker ] checking if seession needs to be ended after source unloaded', event); | ||
if (_this._isAdBreakActive) { | ||
@@ -332,2 +334,16 @@ // Ignore sourceUnloaded events during ads | ||
}; | ||
ConvivaAnalyticsTracker.prototype.startStallTrackingTimeout = function (event) { | ||
if (!this.isSessionActive()) { | ||
return; | ||
} | ||
this.debugLog("[ ConvivaAnalyticsTracker ] start stall tracking after ".concat(event.type, " event")); | ||
this.stallTrackingTimeout.start(); | ||
}; | ||
ConvivaAnalyticsTracker.prototype.clearStallTrackingTimeout = function (event) { | ||
if (!this.stallTrackingTimeout.isActive()) { | ||
return; | ||
} | ||
this.debugLog("[ ConvivaAnalyticsTracker ] stop stall tracking after ".concat(event.type, " event")); | ||
this.stallTrackingTimeout.clear(); | ||
}; | ||
ConvivaAnalyticsTracker.prototype.initializeSession = function () { | ||
@@ -582,45 +598,21 @@ if (this.isSessionActive()) { | ||
}; | ||
ConvivaAnalyticsTracker.prototype.trackPlaybackStateChanged = function (event) { | ||
ConvivaAnalyticsTracker.prototype.trackPlaybackStateFromEvent = function (event) { | ||
var playerState = PlayerStateHelper_1.PlayerStateHelper.getPlayerStateFromEvent(event, this.player); | ||
this.debugLog("[ ConvivaAnalyticsTracker ] inferred player state ".concat(playerState, " from ").concat(event.type, " event"), { playerState: playerState, event: event }); | ||
if (playerState) { | ||
this.trackPlaybackState(playerState); | ||
} | ||
}; | ||
ConvivaAnalyticsTracker.prototype.trackPlaybackState = function (playerState) { | ||
if (!this.isSessionActive()) { | ||
return; | ||
} | ||
var playerState = PlayerStateHelper_1.PlayerStateHelper.getPlayerStateFromEvent(event, this.player); | ||
var stallTrackingStartEvents = [ | ||
bitmovin_player_1.PlayerEvent.Play, | ||
bitmovin_player_1.PlayerEvent.Seek, | ||
bitmovin_player_1.PlayerEvent.TimeShift, | ||
bitmovin_player_1.PlayerEvent.AdBreakStarted, | ||
bitmovin_player_1.PlayerEvent.AdFinished, | ||
bitmovin_player_1.PlayerEvent.RestoringContent, | ||
]; | ||
var stallTrackingClearEvents = [ | ||
bitmovin_player_1.PlayerEvent.StallStarted, | ||
bitmovin_player_1.PlayerEvent.Playing, | ||
bitmovin_player_1.PlayerEvent.Paused, | ||
bitmovin_player_1.PlayerEvent.Seeked, | ||
bitmovin_player_1.PlayerEvent.TimeShifted, | ||
bitmovin_player_1.PlayerEvent.StallEnded, | ||
bitmovin_player_1.PlayerEvent.PlaybackFinished, | ||
bitmovin_player_1.PlayerEvent.AdStarted, | ||
]; | ||
if (stallTrackingStartEvents.indexOf(event.type) !== -1) { | ||
this.stallTrackingTimeout.start(); | ||
if (this._isAdBreakActive) { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report ad playback state', playerState); | ||
this.convivaAdAnalytics.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE, playerState); | ||
} | ||
else if (stallTrackingClearEvents.indexOf(event.type) !== -1) { | ||
this.stallTrackingTimeout.clear(); | ||
else { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report playback state', playerState); | ||
this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE, playerState); | ||
} | ||
if (playerState) { | ||
if (this._isAdBreakActive) { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report ad playback state', playerState); | ||
this.convivaAdAnalytics.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE, playerState); | ||
} | ||
else { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report playback state', playerState); | ||
this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE, playerState); | ||
} | ||
} | ||
if (event.type === bitmovin_player_1.PlayerEvent.PlaybackFinished) { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report playback ended'); | ||
this.convivaVideoAnalytics.reportPlaybackEnded(); | ||
} | ||
}; | ||
@@ -699,2 +691,3 @@ ConvivaAnalyticsTracker.prototype.trackSeekStart = function (target) { | ||
}; | ||
// These are attached earlier than the ones inside `ConvivaAnalytics` | ||
ConvivaAnalyticsTracker.prototype.registerPlayerEvents = function () { | ||
@@ -701,0 +694,0 @@ this.handlers.add(bitmovin_player_1.PlayerEvent.SourceLoaded, this.onSourceLoaded); |
@@ -12,2 +12,5 @@ "use strict"; | ||
switch (event.type) { | ||
case bitmovin_player_1.PlayerEvent.AdBreakStarted: | ||
case bitmovin_player_1.PlayerEvent.AdFinished: | ||
case bitmovin_player_1.PlayerEvent.RestoringContent: | ||
case bitmovin_player_1.PlayerEvent.StallStarted: | ||
@@ -14,0 +17,0 @@ playerState = Conviva.Constants.PlayerState.BUFFERING; |
{ | ||
"name": "@bitmovin/player-integration-conviva", | ||
"version": "6.1.1", | ||
"version": "6.1.2", | ||
"description": "Conviva analytics integration for the Bitmovin Player", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -243,15 +243,5 @@ import * as Conviva from '@convivainc/conviva-js-coresdk'; | ||
this.debugLog('[ ConvivaAnalytics ] [ Player Event ] playback state change related event', event); | ||
this.convivaAnalyticsTracker.trackPlaybackStateChanged(event); | ||
this.convivaAnalyticsTracker.trackPlaybackStateFromEvent(event); | ||
}; | ||
private onPlay = (event: PlaybackEvent) => { | ||
this.debugLog('[ ConvivaAnalytics ] [ Player Event ] play', event); | ||
if (!this.convivaAnalyticsTracker.canTrackPlayEvent) { | ||
return; | ||
} | ||
this.onPlaybackStateChanged(event); | ||
}; | ||
private onPlaying = (event: PlaybackEvent) => { | ||
@@ -262,7 +252,2 @@ this.debugLog('[ ConvivaAnalytics ] [ Player Event ] playing', event); | ||
private onPlaybackFinished = (event: PlayerEventBase) => { | ||
this.debugLog('[ ConvivaAnalytics ] [ Player Event ] playback finished', event); | ||
this.onPlaybackStateChanged(event); | ||
}; | ||
private onVideoQualityChanged = (event: VideoQualityChangedEvent) => { | ||
@@ -283,6 +268,11 @@ this.debugLog('[ ConvivaAnalytics ] [ Player Event ] video quality changed', event); | ||
this.convivaAnalyticsTracker.trackAdBreakStarted(Conviva.Constants.AdType.CLIENT_SIDE); | ||
this.convivaAnalyticsTracker.trackPlaybackStateChanged(event); | ||
this.convivaAnalyticsTracker.trackPlaybackStateFromEvent(event); | ||
}; | ||
private onAdStarted = (event: AdEvent) => { | ||
if (!this.lastAdBreakEvent) { | ||
this.debugLog('[ ConvivaAnalytics ] received ad started without active ad break', event); | ||
return; | ||
} | ||
this.debugLog('[ ConvivaAnalytics ] [ Player Event ] ad started', event); | ||
@@ -294,9 +284,14 @@ | ||
this.convivaAnalyticsTracker.trackAdStarted(adInfo, Conviva.Constants.AdType.CLIENT_SIDE, bitrateKbps); | ||
this.convivaAnalyticsTracker.trackPlaybackStateChanged(event); | ||
// No need to call reportPlaybackStateFromEvent as this is covered by `trackAdStarted` | ||
} | ||
private onAdFinished = (event: AdEvent) => { | ||
if (!this.lastAdBreakEvent) { | ||
this.debugLog('[ ConvivaAnalytics ] received ad finished without active ad break', event); | ||
return; | ||
} | ||
this.debugLog('[ ConvivaAnalytics ] [ Player Event ] ad finished', event); | ||
this.convivaAnalyticsTracker.trackAdFinished(); | ||
this.convivaAnalyticsTracker.trackPlaybackStateChanged(event); | ||
this.convivaAnalyticsTracker.trackPlaybackStateFromEvent(event); | ||
} | ||
@@ -313,2 +308,3 @@ | ||
this.convivaAnalyticsTracker.trackRestoringContent(); | ||
this.convivaAnalyticsTracker.trackPlaybackStateFromEvent(event); | ||
}; | ||
@@ -318,3 +314,4 @@ | ||
this.debugLog('[ ConvivaAnalytics ] [ Player Event ] adbreak finished', event); | ||
this.convivaAnalyticsTracker.trackAdBreakFinished(); | ||
this.convivaAnalyticsTracker.trackAdBreakFinished(Conviva.Constants.AdType.CLIENT_SIDE); | ||
// No need to call reportPlaybackStateFromEvent as this is covered by `trackAdBreakFinished` | ||
} | ||
@@ -331,3 +328,2 @@ | ||
this.convivaAnalyticsTracker.trackSeekStart(event.seekTarget); | ||
this.onPlaybackStateChanged(event); | ||
}; | ||
@@ -345,3 +341,2 @@ | ||
this.convivaAnalyticsTracker.trackSeekStart(-1); | ||
this.onPlaybackStateChanged(event); | ||
}; | ||
@@ -385,5 +380,21 @@ | ||
private static readonly stallTrackingStartEvents = [ | ||
PlayerEvent.Play, | ||
PlayerEvent.Seek, | ||
PlayerEvent.TimeShift, | ||
]; | ||
private static readonly stallTrackingClearEvents = [ | ||
PlayerEvent.StallStarted, // StallStarted is reported as BUFFERING immediately. Does not need the delayed timeout approach. | ||
PlayerEvent.Playing, | ||
PlayerEvent.Paused, | ||
PlayerEvent.Seeked, | ||
PlayerEvent.TimeShifted, | ||
PlayerEvent.StallEnded, | ||
PlayerEvent.PlaybackFinished, | ||
PlayerEvent.AdStarted, | ||
]; | ||
private registerPlayerEvents(): void { | ||
this.handlers.add(PlayerEvent.SourceLoaded, this.onSourceLoaded); | ||
this.handlers.add(PlayerEvent.Play, this.onPlay); | ||
this.handlers.add(PlayerEvent.Playing, this.onPlaying); | ||
@@ -393,3 +404,2 @@ this.handlers.add(PlayerEvent.Paused, this.onPlaybackStateChanged); | ||
this.handlers.add(PlayerEvent.StallEnded, this.onPlaybackStateChanged); | ||
this.handlers.add(PlayerEvent.PlaybackFinished, this.onPlaybackFinished); | ||
this.handlers.add(PlayerEvent.VideoPlaybackQualityChanged, this.onVideoQualityChanged); | ||
@@ -419,2 +429,14 @@ this.handlers.add(PlayerEvent.AudioPlaybackQualityChanged, this.onCustomEvent); | ||
this.handlers.add(PlayerEvent.CastStopped, this.onCustomEvent); | ||
ConvivaAnalytics.stallTrackingStartEvents.forEach((eventName) => { | ||
this.handlers.add(eventName, (event) => { | ||
this.convivaAnalyticsTracker.startStallTrackingTimeout(event); | ||
}); | ||
}); | ||
ConvivaAnalytics.stallTrackingClearEvents.forEach((eventName) => { | ||
this.handlers.add(eventName, (event) => { | ||
this.convivaAnalyticsTracker.clearStallTrackingTimeout(event); | ||
}); | ||
}); | ||
} | ||
@@ -421,0 +443,0 @@ |
@@ -92,4 +92,4 @@ import * as Conviva from '@convivainc/conviva-js-coresdk'; | ||
this._isAdBreakActive = false; | ||
this.convivaAnalyticsTracker.trackAdBreakFinished(); | ||
this.convivaAnalyticsTracker.trackAdBreakFinished(Conviva.Constants.AdType.SERVER_SIDE); | ||
} | ||
} |
@@ -208,17 +208,25 @@ import * as Conviva from '@convivainc/conviva-js-coresdk'; | ||
private stallTrackingTimeout: Timeout = new Timeout(ConvivaAnalyticsTracker.STALL_TRACKING_DELAY_MS, () => { | ||
if (this._isAdBreakActive) { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report buffering ad playback state'); | ||
this.convivaAdAnalytics.reportAdMetric( | ||
Conviva.Constants.Playback.PLAYER_STATE, | ||
Conviva.Constants.PlayerState.BUFFERING, | ||
); | ||
} else { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report buffering playback state'); | ||
this.convivaVideoAnalytics.reportPlaybackMetric( | ||
Conviva.Constants.Playback.PLAYER_STATE, | ||
Conviva.Constants.PlayerState.BUFFERING, | ||
); | ||
} | ||
this.trackPlaybackState(Conviva.Constants.PlayerState.BUFFERING); | ||
}); | ||
public startStallTrackingTimeout(event: PlayerEventBase) { | ||
if (!this.isSessionActive()) { | ||
return; | ||
} | ||
this.debugLog(`[ ConvivaAnalyticsTracker ] start stall tracking after ${event.type} event`); | ||
this.stallTrackingTimeout.start(); | ||
} | ||
public clearStallTrackingTimeout(event: PlayerEventBase) { | ||
if (!this.stallTrackingTimeout.isActive()) { | ||
return; | ||
} | ||
this.debugLog(`[ ConvivaAnalyticsTracker ] stop stall tracking after ${event.type} event`); | ||
this.stallTrackingTimeout.clear(); | ||
} | ||
/** | ||
@@ -605,4 +613,2 @@ * Boolean to track whether a session was ended by an upstream caller instead of within internal session management. | ||
private onSourceLoaded = (event: PlayerEventBase) => { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] source loaded', event); | ||
if (!this.isSessionActive()) { | ||
@@ -612,2 +618,4 @@ return; | ||
this.debugLog('[ ConvivaAnalyticsTracker ] building content metadata after source loaded event', event); | ||
this.buildContentMetadata(); | ||
@@ -617,52 +625,28 @@ this.updateSession(); | ||
public trackPlaybackStateChanged(event: PlayerEventBase) { | ||
if (!this.isSessionActive()) { | ||
return; | ||
} | ||
public trackPlaybackStateFromEvent(event: PlayerEventBase) { | ||
const playerState = PlayerStateHelper.getPlayerStateFromEvent(event, this.player); | ||
const stallTrackingStartEvents = [ | ||
PlayerEvent.Play, | ||
PlayerEvent.Seek, | ||
PlayerEvent.TimeShift, | ||
PlayerEvent.AdBreakStarted, | ||
PlayerEvent.AdFinished, | ||
PlayerEvent.RestoringContent, | ||
]; | ||
const stallTrackingClearEvents = [ | ||
PlayerEvent.StallStarted, // StallStarted is reported as BUFFERING immediately. Does not need the delayed timeout approach. | ||
PlayerEvent.Playing, | ||
PlayerEvent.Paused, | ||
PlayerEvent.Seeked, | ||
PlayerEvent.TimeShifted, | ||
PlayerEvent.StallEnded, | ||
PlayerEvent.PlaybackFinished, | ||
PlayerEvent.AdStarted, | ||
]; | ||
if (stallTrackingStartEvents.indexOf(event.type) !== -1) { | ||
this.stallTrackingTimeout.start(); | ||
} else if (stallTrackingClearEvents.indexOf(event.type) !== -1) { | ||
this.stallTrackingTimeout.clear(); | ||
} | ||
this.debugLog(`[ ConvivaAnalyticsTracker ] inferred player state ${playerState} from ${event.type} event`, {playerState, event}); | ||
if (playerState) { | ||
if (this._isAdBreakActive) { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report ad playback state', playerState); | ||
this.convivaAdAnalytics.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE, playerState); | ||
} else { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report playback state', playerState); | ||
this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE, playerState); | ||
} | ||
this.trackPlaybackState(playerState); | ||
} | ||
} | ||
if (event.type === PlayerEvent.PlaybackFinished) { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report playback ended'); | ||
this.convivaVideoAnalytics.reportPlaybackEnded(); | ||
private trackPlaybackState(playerState: Conviva.valueof<Conviva.ConvivaConstants['PlayerState']>) { | ||
if (!this.isSessionActive()) { | ||
return; | ||
} | ||
if (this._isAdBreakActive) { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report ad playback state', playerState); | ||
this.convivaAdAnalytics.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE, playerState); | ||
} else { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report playback state', playerState); | ||
this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE, playerState); | ||
} | ||
} | ||
private onPlay = (event: PlaybackEvent) => { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] play'); | ||
this.debugLog('[ ConvivaAnalyticsTracker ] checking if session needs to be initialized after play event'); | ||
@@ -688,4 +672,2 @@ if (!this.canTrackPlayEvent) { | ||
private onPlaying = (event: PlaybackEvent) => { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] playing', event); | ||
if (!this.isSessionActive()) { | ||
@@ -695,2 +677,4 @@ return; | ||
this.debugLog('[ ConvivaAnalyticsTracker ] updating session metadata after playing event', event); | ||
this.contentMetadataBuilder.setPlaybackStarted(true); | ||
@@ -701,4 +685,2 @@ this.updateSession(); | ||
private onPlaybackFinished = (event: PlayerEventBase) => { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] playback finished', event); | ||
if (!this.isSessionActive()) { | ||
@@ -708,2 +690,6 @@ return; | ||
this.debugLog('[ ConvivaAnalyticsTracker ] releasing everything after playback finished event', event); | ||
this.trackPlaybackFinished(); | ||
this.convivaVideoAnalytics.release(); | ||
@@ -716,2 +702,7 @@ this.convivaVideoAnalytics = null; | ||
private trackPlaybackFinished = () => { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] report playback ended'); | ||
this.convivaVideoAnalytics.reportPlaybackEnded(); | ||
} | ||
public trackVideoQualityChanged = (event: VideoQualityChangedEvent) => { | ||
@@ -759,3 +750,3 @@ if (!this.isSessionActive()) { | ||
this.debugLog(`[ ConvivaAnalyticsTracker ] report ${PlayerStateHelper.getPlayerState(this.player)} ad playback state`); | ||
this.debugLog(`[ ConvivaAnalyticsTracker ] report ${PlayerStateHelper.getPlayerState(this.player)} ad playback state on ad started event`); | ||
this.convivaAdAnalytics.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE, PlayerStateHelper.getPlayerState(this.player)); | ||
@@ -801,3 +792,3 @@ | ||
public trackRestoringContent = () => { | ||
if (!this.isSessionActive()) { | ||
if (!this.isSessionActive() || !this._isAdBreakActive) { | ||
return; | ||
@@ -812,11 +803,17 @@ } | ||
public trackAdBreakFinished = () => { | ||
if (!this.isSessionActive() || this._isAdBreakActive) { | ||
public trackAdBreakFinished = (type: Conviva.valueof<Conviva.ConvivaConstants['AdType']>) => { | ||
const shouldExpectAnotherCsaiAd = type === Conviva.Constants.AdType.CLIENT_SIDE && this._isAdBreakActive; | ||
if (!this.isSessionActive() || shouldExpectAnotherCsaiAd) { | ||
// We only care to update the playback state when we are restoring main content. | ||
return; | ||
} | ||
this.debugLog(`[ ConvivaAnalyticsTracker ] report ${PlayerStateHelper.getPlayerState(this.player)} playback state`); | ||
this.trackRestoringContent(); | ||
const playerState = PlayerStateHelper.getPlayerState(this.player); | ||
this.debugLog(`[ ConvivaAnalyticsTracker ] report ${playerState} playback state on ad break finished event`); | ||
this.convivaVideoAnalytics.reportPlaybackMetric( | ||
Conviva.Constants.Playback.PLAYER_STATE, | ||
PlayerStateHelper.getPlayerState(this.player), | ||
playerState, | ||
); | ||
@@ -944,3 +941,3 @@ }; | ||
private onSourceUnloaded = (event: PlayerEventBase) => { | ||
this.debugLog('[ ConvivaAnalyticsTracker ] [ Player Event ] source unloaded', event); | ||
this.debugLog('[ ConvivaAnalyticsTracker ] checking if seession needs to be ended after source unloaded', event); | ||
@@ -955,2 +952,3 @@ if (this._isAdBreakActive) { | ||
// These are attached earlier than the ones inside `ConvivaAnalytics` | ||
private registerPlayerEvents(): void { | ||
@@ -957,0 +955,0 @@ this.handlers.add(PlayerEvent.SourceLoaded, this.onSourceLoaded); |
@@ -9,2 +9,5 @@ import { PlayerAPI, PlayerEvent, PlayerEventBase } from 'bitmovin-player'; | ||
switch (event.type) { | ||
case PlayerEvent.AdBreakStarted: | ||
case PlayerEvent.AdFinished: | ||
case PlayerEvent.RestoringContent: | ||
case PlayerEvent.StallStarted: | ||
@@ -11,0 +14,0 @@ playerState = Conviva.Constants.PlayerState.BUFFERING; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
453523
4562