@bitmovin/player-integration-conviva
Advanced tools
Comparing version 4.0.2 to 4.0.3
@@ -9,2 +9,11 @@ # Changelog | ||
## [4.0.3] | ||
### Added | ||
- `bitmovin-player@^8.31.0` as peer dependency. | ||
- Possibility to set detailed Conviva Device Metadata via `ConvivaAnalyticsConfiguration.deviceMetadata` | ||
- Possibility to override values for internally set custom metdata keys `streamType`, `playerType` and `vrContentType` | ||
### Deprecated | ||
- `ConvivaAnalyticsConfiguration.deviceCategory` field in favour of `ConvivaAnalyticsConfiguration.deviceMetadata.category` field | ||
## [4.0.2] | ||
@@ -91,2 +100,3 @@ | ||
[4.0.2]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v4.0.2...v4.0.3 | ||
[4.0.2]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v4.0.1...v4.0.2 | ||
@@ -93,0 +103,0 @@ [4.0.1]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v4.0.0...v4.0.1 |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("bitmovin-player-analytics-conviva",[],e):"object"==typeof exports?exports["bitmovin-player-analytics-conviva"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player.analytics=e())}(window,function(){return function(t){var e={};function a(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,a),i.l=!0,i.exports}return a.m=t,a.c=e,a.d=function(t,e,n){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},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 n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)a.d(n,i,function(e){return t[e]}.bind(null,i));return n},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=0)}([function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=a(1);e.ConvivaAnalytics=n.ConvivaAnalytics},function(t,e,a){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++)for(var i in e=arguments[a])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var i=a(2),o=a(3),s=a(4),r=a(5),d=a(6),c=a(7),l=a(8),v=a(9),u=a(10),p=a(11),y=a(12),h=function(){function t(e,a,n){var u;void 0===n&&(n={});var p=this;if(this.stallTrackingTimout=new c.Timeout(t.STALL_TRACKING_DELAY_MS,function(){p.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,Conviva.Constants.PlayerState.BUFFERING)}),this.sessionEndedExternally=!1,this.internalEndSession=function(t){p.isSessionActive()&&(p.debugLog("[ ConvivaAnalytics ] end session",Conviva.Constants.NO_SESSION_KEY,t),p.convivaVideoAnalytics.release(),Conviva.Analytics.release(),p.convivaVideoAnalytics=null,p.lastSeenBitrate=null)},this.onPlaybackStateChanged=function(t){if(!p.isAd&&p.isSessionActive()){var e;switch(t.type){case p.events.Play:case p.events.Seek:case p.events.TimeShift:p.stallTrackingTimout.start();break;case p.events.StallStarted:p.stallTrackingTimout.clear(),e=Conviva.Constants.PlayerState.BUFFERING;break;case p.events.Playing:p.stallTrackingTimout.clear(),p.adBreakStartedToFire&&(p.trackAdBreakStarted(p.adBreakStartedToFire),p.adBreakStartedToFire=null),e=Conviva.Constants.PlayerState.PLAYING;break;case p.events.Paused:p.stallTrackingTimout.clear(),e=Conviva.Constants.PlayerState.PAUSED;break;case p.events.Seeked:case p.events.TimeShifted:case p.events.StallEnded:p.stallTrackingTimout.clear(),e=p.player.isPlaying()?Conviva.Constants.PlayerState.PLAYING:Conviva.Constants.PlayerState.PAUSED;break;case p.events.PlaybackFinished:p.stallTrackingTimout.clear(),p.convivaVideoAnalytics.reportPlaybackEnded()}e&&(p.debugLog("[ ConvivaAnalytics ] report playback state",e),p.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,e))}},this.onSourceLoaded=function(t){p.isSessionActive()&&(p.buildSourceRelatedMetadata(p.player.getSource()),p.updateSession())},this.onPlay=function(t){p.debugLog("[ Player Event ] play",t),p.isAd||(p.isSessionActive()||p.sessionEndedExternally||p.internalInitializeSession(),p.onPlaybackStateChanged(t))},this.onPlaying=function(t){p.contentMetadataBuilder.setPlaybackStarted(!0),p.debugLog("[ Player Event ] playing",t),p.updateSession(),p.onPlaybackStateChanged(t)},this.onPlaybackFinished=function(t){p.debugLog("[ Player Event ] playback finished",t),p.isSessionActive()&&(p.onPlaybackStateChanged(t),p.convivaVideoAnalytics.release(),p.convivaVideoAnalytics=null)},this.onVideoQualityChanged=function(t){var e=Math.round(t.targetQuality.bitrate/1e3);p.isSessionActive()?(p.lastSeenBitrate=null,p.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.BITRATE,e)):p.lastSeenBitrate=e},this.onCustomEvent=function(t){if(p.isSessionActive()){var e=v.ObjectUtils.flatten(t);p.sendCustomPlaybackEvent(t.type,e)}else p.debugLog("skip custom event, no session existing",t)},this.trackAdBreakStarted=function(t){p.debugLog("[ ConvivaAnalytics ] adbreak started",t),p.isAd=!0;var e=y.AdBreakHelper.mapAdPosition(t.adBreak,p.player);p.isSessionActive()&&p.convivaVideoAnalytics.reportAdBreakStarted(Conviva.Constants.AdType.CLIENT_SIDE,Conviva.Constants.AdPlayer.SEPARATE,e)},this.onAdBreakFinished=function(t){p.debugLog("[ ConvivaAnalytics ] adbreak finished",t),p.isAd=!1,p.isSessionActive()&&(p.convivaVideoAnalytics.reportAdBreakEnded(),p.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,Conviva.Constants.PlayerState.PLAYING))},this.onAdSkipped=function(t){p.onCustomEvent(t)},this.onAdError=function(t){p.onCustomEvent(t)},this.onSeek=function(t){p.isSessionActive()&&(p.trackSeekStart(t.seekTarget),p.onPlaybackStateChanged(t))},this.onSeeked=function(t){p.isSessionActive()&&(p.trackSeekEnd(),p.onPlaybackStateChanged(t))},this.onTimeShift=function(t){p.isSessionActive()&&(p.trackSeekStart(-1),p.onPlaybackStateChanged(t))},this.onTimeShifted=function(t){p.isSessionActive()&&(p.trackSeekEnd(),p.onPlaybackStateChanged(t))},this.onError=function(t){p.isSessionActive()||p.sessionEndedExternally||p.internalInitializeSession(),p.reportPlaybackDeficiency(String(t.code)+" "+t.name,Conviva.Constants.ErrorSeverity.FATAL)},this.onSourceUnloaded=function(t){p.isAd||(p.internalEndSession(t),p.resetContentMetadata())},this.onDestroy=function(t){p.destroy(t)},this.onAdBreakStarted=function(t){if(t.adBreak.scheduleTime===1/0)return p.debugLog("[ ConvivaAnalytics ] detected post-roll ad ... Ending session"),void p.onPlaybackFinished({timestamp:Date.now(),type:p.events.PlaybackFinished});p.isSessionActive()?p.trackAdBreakStarted(t):p.adBreakStartedToFire=t},"undefined"!=typeof Conviva)if(e.getSource())console.error("Bitmovin Conviva integration must be instantiated before calling player.load()");else{this.player=e,this.events=e.exports.PlayerEvent,this.handlers=new g(e),this.config=n,this.config.debugLoggingEnabled=this.config.debugLoggingEnabled||!1,this.config.deviceCategory=this.config.deviceCategory||Conviva.Constants.DeviceCategory.WEB,this.logger=new o.Html5Logging,this.sessionKey=Conviva.Constants.NO_SESSION_KEY,this.isAd=!1;var h=((u={})[Conviva.Constants.DeviceMetadata.CATEGORY]=this.config.deviceCategory,u);Conviva.Analytics.setDeviceMetadata(h);var f={};f[Conviva.Constants.CallbackFunctions.CONSOLE_LOG]=this.logger.consoleLog,f[Conviva.Constants.CallbackFunctions.MAKE_REQUEST]=(new i.Html5Http).makeRequest;var m=new s.Html5Storage;f[Conviva.Constants.CallbackFunctions.SAVE_DATA]=m.saveData,f[Conviva.Constants.CallbackFunctions.LOAD_DATA]=m.loadData,f[Conviva.Constants.CallbackFunctions.CREATE_TIMER]=(new d.Html5Timer).createTimer,f[Conviva.Constants.CallbackFunctions.GET_EPOCH_TIME_IN_MS]=(new r.Html5Time).getEpochTimeMs;var C={};C[Conviva.Constants.GATEWAY_URL]=n.gatewayUrl,C[Conviva.Constants.LOG_LEVEL]=this.config.debugLoggingEnabled?Conviva.Constants.LogLevel.DEBUG:Conviva.Constants.LogLevel.NONE,Conviva.Analytics.init(a,f,C),this.contentMetadataBuilder=new l.ContentMetadataBuilder(this.logger),this.registerPlayerEvents()}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 t.prototype.initializeSession=function(){if(this.isSessionActive())this.logger.consoleLog("There is already a session running.",Conviva.SystemSettings.LogLevel.WARNING);else{if(!this.player.getSource()&&!this.contentMetadataBuilder.assetName)throw"AssetName is missing. Load player source first or set assetName via updateContentMetadata";this.internalInitializeSession(),this.sessionEndedExternally=!1}},t.prototype.endSession=function(){this.isSessionActive()&&(this.convivaVideoAnalytics.reportPlaybackEnded(),this.internalEndSession(),this.resetContentMetadata(),this.sessionEndedExternally=!0)},t.prototype.sendCustomApplicationEvent=function(t,e){void 0===e&&(e={}),this.isSessionActive()?this.convivaVideoAnalytics.reportAppEvent(t,e):this.logger.consoleLog("cannot send application event, no active monitoring session",Conviva.SystemSettings.LogLevel.WARNING)},t.prototype.sendCustomPlaybackEvent=function(t,e){void 0===e&&(e={}),this.isSessionActive()?this.convivaVideoAnalytics.reportPlaybackEvent(t,e):this.logger.consoleLog("cannot send playback event, no active monitoring session",Conviva.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.convivaVideoAnalytics.reportPlaybackFailed(t),a&&(this.internalEndSession(),this.resetContentMetadata()))},t.prototype.pauseTracking=function(){this.convivaVideoAnalytics.reportAdBreakStarted(Conviva.Constants.AdType.CLIENT_SIDE,Conviva.Constants.AdPlayer.SEPARATE,Conviva.Constants.AdPosition.PREROLL),this.debugLog("Tracking paused.")},t.prototype.resumeTracking=function(){this.convivaVideoAnalytics.reportAdBreakEnded(),this.debugLog("Tracking resumed.")},t.prototype.release=function(){this.destroy()},t.prototype.destroy=function(t){this.unregisterPlayerEvents(),this.internalEndSession(t)},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("[ ConvivaAnalytics ] no active session. Content metadata will be propagated to Conviva on session initialization.",Conviva.SystemSettings.LogLevel.DEBUG)},t.prototype.internalInitializeSession=function(){var t=this;this.buildContentMetadata(),this.convivaVideoAnalytics=Conviva.Analytics.buildVideoAnalytics(),this.convivaVideoAnalytics.reportPlaybackRequested(this.contentMetadataBuilder.build()),this.sessionKey=this.convivaVideoAnalytics.getSessionId(),this.convivaVideoAnalytics.setCallback(function(){var e=1e3*t.player.getCurrentTime("relativetime");t.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAY_HEAD_TIME,e)}),this.debugLog("[ ConvivaAnalytics ] start session",this.sessionKey),this.isSessionActive()||this.logger.consoleLog("Something went wrong, could not obtain session key",Conviva.SystemSettings.LogLevel.ERROR),this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,Conviva.Constants.PlayerState.STOPPED),this.lastSeenBitrate&&this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.BITRATE,this.lastSeenBitrate)},t.prototype.buildContentMetadata=function(){this.contentMetadataBuilder.duration=this.player.getDuration(),this.contentMetadataBuilder.streamType=this.player.isLive()?Conviva.ContentMetadata.StreamType.LIVE:Conviva.ContentMetadata.StreamType.VOD,this.contentMetadataBuilder.custom={autoplay:f.getAutoplayConfig(this.player)+"",preload:f.getPreloadConfig(this.player)+"",integrationVersion:t.VERSION};var e=this.player.getSource();e&&this.buildSourceRelatedMetadata(e)},t.prototype.buildSourceRelatedMetadata=function(t){this.contentMetadataBuilder.assetName=this.getAssetNameFromSource(t),this.contentMetadataBuilder.viewerId=this.contentMetadataBuilder.viewerId,this.contentMetadataBuilder.custom=n({},this.contentMetadataBuilder.custom,{playerType:this.player.getPlayerType(),streamType:this.player.getStreamType(),vrContentType:t.vr&&t.vr.contentType}),this.contentMetadataBuilder.streamUrl=this.getUrlFromSource(t)},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.resetContentMetadata=function(){this.contentMetadataBuilder.reset()},t.prototype.isSessionActive=function(){return!!this.convivaVideoAnalytics},t.prototype.trackSeekStart=function(t){this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.SEEK_STARTED)},t.prototype.trackSeekEnd=function(){this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.SEEK_ENDED)},t.prototype.registerPlayerEvents=function(){var t=this.handlers;t.add(this.events.SourceLoaded,this.onSourceLoaded),t.add(this.events.Play,this.onPlay),t.add(this.events.Playing,this.onPlaying),t.add(this.events.Paused,this.onPlaybackStateChanged),t.add(this.events.StallStarted,this.onPlaybackStateChanged),t.add(this.events.StallEnded,this.onPlaybackStateChanged),t.add(this.events.PlaybackFinished,this.onPlaybackFinished),t.add(this.events.VideoPlaybackQualityChanged,this.onVideoQualityChanged),t.add(this.events.AudioPlaybackQualityChanged,this.onCustomEvent),t.add(this.events.Muted,this.onCustomEvent),t.add(this.events.Unmuted,this.onCustomEvent),t.add(this.events.ViewModeChanged,this.onCustomEvent),t.add(this.events.AdBreakStarted,this.onAdBreakStarted),t.add(this.events.AdBreakFinished,this.onAdBreakFinished),t.add(this.events.AdSkipped,this.onAdSkipped),t.add(this.events.AdError,this.onAdError),t.add(this.events.SourceUnloaded,this.onSourceUnloaded),t.add(this.events.Error,this.onError),t.add(this.events.Destroy,this.onDestroy),t.add(this.events.Seek,this.onSeek),t.add(this.events.Seeked,this.onSeeked),t.add(this.events.TimeShift,this.onTimeShift),t.add(this.events.TimeShifted,this.onTimeShifted),t.add(this.events.CastStarted,this.onCustomEvent),t.add(this.events.CastStopped,this.onCustomEvent)},t.prototype.unregisterPlayerEvents=function(){this.handlers.clear()},Object.defineProperty(t,"version",{get:function(){return t.VERSION},enumerable:!0,configurable:!0}),t.VERSION="4.0.2",t.STALL_TRACKING_DELAY_MS=100,t}();e.ConvivaAnalytics=h;var f=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(u.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}(),g=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]&&p.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 n=a[e];this.remove(t,n)}},t}()},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.prototype.makeRequest=function(t,e,a,n,i,o){return this.makeRequestStandard.apply(this,arguments)},t.prototype.release=function(){},t.prototype.makeRequestStandard=function(t,e,a,n,i,o){var s=new XMLHttpRequest;return s.open(t,e,!0),n&&s.overrideMimeType&&s.overrideMimeType(n),n&&s.setRequestHeader&&s.setRequestHeader("Content-Type",n),i>0&&(s.timeout=i,s.ontimeout=function(){s.ontimeout=s.onreadystatechange=null,o&&o(!1,"timeout after "+i+" ms")}),s.onreadystatechange=function(){4===s.readyState&&(s.ontimeout=s.onreadystatechange=null,200===s.status?o&&o(!0,s.responseText):o&&o(!1,"http status "+s.status))},s.send(a),null},t}();e.Html5Http=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.prototype.consoleLog=function(t,e){"undefined"!=typeof console&&(console.log&&e===Conviva.SystemSettings.LogLevel.DEBUG||e===Conviva.SystemSettings.LogLevel.INFO?console.log(t):console.warn&&e===Conviva.SystemSettings.LogLevel.WARNING?console.warn(t):console.error&&e===Conviva.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});var n=function(){function t(){}return t.prototype.saveData=function(t,e,a,n){var i=t+"."+e;try{localStorage.setItem(i,a),n(!0,null)}catch(t){n(!1,t.toString())}},t.prototype.loadData=function(t,e,a){var n=t+"."+e;try{a(!0,localStorage.getItem(n))}catch(t){a(!1,t.toString())}},t.prototype.release=function(){},t}();e.Html5Storage=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.prototype.getEpochTimeMs=function(){return(new Date).getTime()},t.prototype.release=function(){},t}();e.Html5Time=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.prototype.createTimer=function(t,e,a){var n=window.setInterval(t,e);return function(){-1!==n&&(clearInterval(n),n=-1)}},t.prototype.release=function(){},t}();e.Html5Timer=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e,a){void 0===a&&(a=!1),this.delay=t,this.callback=e,this.repeat=a,this.timeoutOrIntervalId=0}return t.prototype.start=function(){return this.reset(),this},t.prototype.clear=function(){this.clearInternal()},t.prototype.reset=function(){this.clearInternal(),this.repeat?this.timeoutOrIntervalId=setInterval(this.callback,this.delay):this.timeoutOrIntervalId=setTimeout(this.callback,this.delay)},t.prototype.clearInternal=function(){this.repeat?clearInterval(this.timeoutOrIntervalId):clearTimeout(this.timeoutOrIntervalId)},t}();e.Timeout=n},function(t,e,a){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++)for(var i in e=arguments[a])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.logger=t,this.contentMetadata=new Conviva.ContentMetadata}return t.prototype.setOverrides=function(t){this.playbackStarted&&this.logger.consoleLog("[ Conviva Analytics ] Playback has started. Only some metadata attributes will be updated",Conviva.SystemSettings.LogLevel.WARNING),this.metadataOverrides=n({},this.metadataOverrides,t)},t.prototype.getOverrides=function(){return this.metadataOverrides},t.prototype.setPlaybackStarted=function(t){this.playbackStarted=t},t.prototype.build=function(){this.playbackStarted||(this.contentMetadata.assetName||(this.contentMetadata.assetName=this.assetName),this.contentMetadata.viewerId=this.viewerId,this.contentMetadata.streamType=this.metadataOverrides.streamType||this.metadata.streamType,this.contentMetadata.applicationName=this.metadataOverrides.applicationName||this.metadata.applicationName,this.contentMetadata.duration=this.metadataOverrides.duration||this.metadata.duration,this.contentMetadata.framework=this.metadataOverrides.framework||this.metadata.framework,this.contentMetadata.frameworkVersion=this.metadataOverrides.frameworkVersion||this.metadata.frameworkVersion,this.contentMetadata.custom=this.custom),this.contentMetadata.encodedFrameRate=this.metadataOverrides.encodedFrameRate||this.metadata.encodedFrameRate,this.contentMetadata.defaultResource=this.metadataOverrides.defaultResource||this.metadata.defaultResource,this.contentMetadata.streamUrl=this.metadataOverrides.streamUrl||this.metadata.streamUrl;var t={};return t[Conviva.Constants.ASSET_NAME]=this.contentMetadata.assetName,t[Conviva.Constants.ENCODED_FRAMERATE]=this.contentMetadata.encodedFrameRate,t[Conviva.Constants.DURATION]=this.contentMetadata.duration,t[Conviva.Constants.DEFAULT_RESOURCE]=this.contentMetadata.defaultResource,t[Conviva.Constants.STREAM_URL]=this.contentMetadata.streamUrl,t[Conviva.Constants.IS_LIVE]=this.contentMetadata.streamType,t[Conviva.Constants.VIEWER_ID]=this.contentMetadata.viewerId||"GET_VIEWER_ID_FROM_PLAYER",t[Conviva.Constants.PLAYER_NAME]=this.contentMetadata.applicationName||"GET_PLAYER_NAME_OR_TYPE",t[Conviva.Constants.FRAMEWORK_NAME]=this.contentMetadata.framework,t[Conviva.Constants.FRAMEWORK_VERSION]=this.contentMetadata.frameworkVersion,n({},t,this.contentMetadata.custom)},Object.defineProperty(t.prototype,"assetName",{get:function(){return this.metadataOverrides.assetName||this.metadata.assetName},set:function(t){this.metadata.assetName=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"viewerId",{get:function(){return this.metadataOverrides.viewerId||this.metadata.viewerId},set:function(t){this.metadata.viewerId=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"streamType",{set:function(t){this.metadata.streamType=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"applicationName",{set:function(t){this.metadata.applicationName=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"custom",{get:function(){return n({},this.metadataOverrides.custom,this.metadata.custom)},set:function(t){this.metadata.custom=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"duration",{set:function(t){this.metadata.duration=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"encodedFrameRate",{set:function(t){this.metadata.encodedFrameRate=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultResource",{set:function(t){this.metadata.defaultResource=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"streamUrl",{set:function(t){this.metadata.streamUrl=t},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.contentMetadata=new Conviva.ContentMetadata},t}();e.ContentMetadataBuilder=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.flatten=function(t,e){void 0===e&&(e="");var a={},n=function(t,e){for(var i in t)if(t.hasOwnProperty(i)){var o=t[i];"object"==typeof o?n(o,e+i+"."):a[e+i]=String(o)}};return n(t,e),a}}(e.ObjectUtils||(e.ObjectUtils={}))},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=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),n=/Safari/i.test(navigator.userAgent)&&/Mobile/i.test(navigator.userAgent);return t||e||a||n},t}();e.BrowserUtils=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!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});var n=function(){function t(){}return t.mapAdPosition=function(t,e){return t.scheduleTime<=0?Conviva.Constants.AdPosition.PREROLL:t.scheduleTime>=e.getDuration()?Conviva.Constants.AdPosition.POSTROLL:Conviva.Constants.AdPosition.MIDROLL},t}();e.AdBreakHelper=n}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("bitmovin-player-analytics-conviva",[],e):"object"==typeof exports?exports["bitmovin-player-analytics-conviva"]=e():(t.bitmovin=t.bitmovin||{},t.bitmovin.player=t.bitmovin.player||{},t.bitmovin.player.analytics=e())}(window,function(){return function(t){var e={};function a(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,a),i.l=!0,i.exports}return a.m=t,a.c=e,a.d=function(t,e,n){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},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 n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)a.d(n,i,function(e){return t[e]}.bind(null,i));return n},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=0)}([function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=a(1);e.ConvivaAnalytics=n.ConvivaAnalytics},function(t,e,a){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++)for(var i in e=arguments[a])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var i=a(2),o=a(3),s=a(4),r=a(5),d=a(6),c=a(7),l=a(8),v=a(9),u=a(10),p=a(11),y=a(12),h=function(){function t(e,a,n){var u;void 0===n&&(n={});var p=this;if(this.stallTrackingTimout=new c.Timeout(t.STALL_TRACKING_DELAY_MS,function(){p.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,Conviva.Constants.PlayerState.BUFFERING)}),this.sessionEndedExternally=!1,this.internalEndSession=function(t){p.isSessionActive()&&(p.debugLog("[ ConvivaAnalytics ] end session",Conviva.Constants.NO_SESSION_KEY,t),p.convivaVideoAnalytics.release(),Conviva.Analytics.release(),p.convivaVideoAnalytics=null,p.lastSeenBitrate=null)},this.onPlaybackStateChanged=function(t){if(!p.isAd&&p.isSessionActive()){var e;switch(t.type){case p.events.Play:case p.events.Seek:case p.events.TimeShift:p.stallTrackingTimout.start();break;case p.events.StallStarted:p.stallTrackingTimout.clear(),e=Conviva.Constants.PlayerState.BUFFERING;break;case p.events.Playing:p.stallTrackingTimout.clear(),p.adBreakStartedToFire&&(p.trackAdBreakStarted(p.adBreakStartedToFire),p.adBreakStartedToFire=null),e=Conviva.Constants.PlayerState.PLAYING;break;case p.events.Paused:p.stallTrackingTimout.clear(),e=Conviva.Constants.PlayerState.PAUSED;break;case p.events.Seeked:case p.events.TimeShifted:case p.events.StallEnded:p.stallTrackingTimout.clear(),e=p.player.isPlaying()?Conviva.Constants.PlayerState.PLAYING:Conviva.Constants.PlayerState.PAUSED;break;case p.events.PlaybackFinished:p.stallTrackingTimout.clear(),p.convivaVideoAnalytics.reportPlaybackEnded()}e&&(p.debugLog("[ ConvivaAnalytics ] report playback state",e),p.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,e))}},this.onSourceLoaded=function(t){p.isSessionActive()&&(p.buildSourceRelatedMetadata(p.player.getSource()),p.updateSession())},this.onPlay=function(t){p.debugLog("[ Player Event ] play",t),p.isAd||(p.isSessionActive()||p.sessionEndedExternally||p.internalInitializeSession(),p.onPlaybackStateChanged(t))},this.onPlaying=function(t){p.contentMetadataBuilder.setPlaybackStarted(!0),p.debugLog("[ Player Event ] playing",t),p.updateSession(),p.onPlaybackStateChanged(t)},this.onPlaybackFinished=function(t){p.debugLog("[ Player Event ] playback finished",t),p.isSessionActive()&&(p.onPlaybackStateChanged(t),p.convivaVideoAnalytics.release(),p.convivaVideoAnalytics=null)},this.onVideoQualityChanged=function(t){var e=Math.round(t.targetQuality.bitrate/1e3);p.isSessionActive()?(p.lastSeenBitrate=null,p.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.BITRATE,e)):p.lastSeenBitrate=e},this.onCustomEvent=function(t){if(p.isSessionActive()){var e=v.ObjectUtils.flatten(t);p.sendCustomPlaybackEvent(t.type,e)}else p.debugLog("skip custom event, no session existing",t)},this.trackAdBreakStarted=function(t){p.debugLog("[ ConvivaAnalytics ] adbreak started",t),p.isAd=!0;var e=y.AdBreakHelper.mapAdPosition(t.adBreak,p.player);p.isSessionActive()&&p.convivaVideoAnalytics.reportAdBreakStarted(Conviva.Constants.AdType.CLIENT_SIDE,Conviva.Constants.AdPlayer.SEPARATE,e)},this.onAdBreakFinished=function(t){p.debugLog("[ ConvivaAnalytics ] adbreak finished",t),p.isAd=!1,p.isSessionActive()&&(p.convivaVideoAnalytics.reportAdBreakEnded(),p.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,Conviva.Constants.PlayerState.PLAYING))},this.onAdSkipped=function(t){p.onCustomEvent(t)},this.onAdError=function(t){p.onCustomEvent(t)},this.onSeek=function(t){p.isSessionActive()&&(p.trackSeekStart(t.seekTarget),p.onPlaybackStateChanged(t))},this.onSeeked=function(t){p.isSessionActive()&&(p.trackSeekEnd(),p.onPlaybackStateChanged(t))},this.onTimeShift=function(t){p.isSessionActive()&&(p.trackSeekStart(-1),p.onPlaybackStateChanged(t))},this.onTimeShifted=function(t){p.isSessionActive()&&(p.trackSeekEnd(),p.onPlaybackStateChanged(t))},this.onError=function(t){p.isSessionActive()||p.sessionEndedExternally||p.internalInitializeSession(),p.reportPlaybackDeficiency(String(t.code)+" "+t.name,Conviva.Constants.ErrorSeverity.FATAL)},this.onSourceUnloaded=function(t){p.isAd||(p.internalEndSession(t),p.resetContentMetadata())},this.onDestroy=function(t){p.destroy(t)},this.onAdBreakStarted=function(t){if(t.adBreak.scheduleTime===1/0)return p.debugLog("[ ConvivaAnalytics ] detected post-roll ad ... Ending session"),void p.onPlaybackFinished({timestamp:Date.now(),type:p.events.PlaybackFinished});p.isSessionActive()?p.trackAdBreakStarted(t):p.adBreakStartedToFire=t},"undefined"!=typeof Conviva)if(e.getSource())console.error("Bitmovin Conviva integration must be instantiated before calling player.load()");else{this.player=e,this.events=e.exports.PlayerEvent,this.handlers=new g(e),this.config=n,this.config.debugLoggingEnabled=this.config.debugLoggingEnabled||!1,this.logger=new o.Html5Logging,this.sessionKey=Conviva.Constants.NO_SESSION_KEY,this.isAd=!1;var h=this.config.deviceMetadata||{},f=((u={})[Conviva.Constants.DeviceMetadata.CATEGORY]=h.category||this.config.deviceCategory||Conviva.Constants.DeviceCategory.WEB,u[Conviva.Constants.DeviceMetadata.BRAND]=h.brand,u[Conviva.Constants.DeviceMetadata.MANUFACTURER]=h.manufacturer,u[Conviva.Constants.DeviceMetadata.MODEL]=h.model,u[Conviva.Constants.DeviceMetadata.TYPE]=h.type,u[Conviva.Constants.DeviceMetadata.VERSION]=h.version,u[Conviva.Constants.DeviceMetadata.OS_NAME]=h.osName,u[Conviva.Constants.DeviceMetadata.OS_VERSION]=h.osVersion,u);Conviva.Analytics.setDeviceMetadata(f);var m={};m[Conviva.Constants.CallbackFunctions.CONSOLE_LOG]=this.logger.consoleLog,m[Conviva.Constants.CallbackFunctions.MAKE_REQUEST]=(new i.Html5Http).makeRequest;var C=new s.Html5Storage;m[Conviva.Constants.CallbackFunctions.SAVE_DATA]=C.saveData,m[Conviva.Constants.CallbackFunctions.LOAD_DATA]=C.loadData,m[Conviva.Constants.CallbackFunctions.CREATE_TIMER]=(new d.Html5Timer).createTimer,m[Conviva.Constants.CallbackFunctions.GET_EPOCH_TIME_IN_MS]=(new r.Html5Time).getEpochTimeMs;var S={};S[Conviva.Constants.GATEWAY_URL]=n.gatewayUrl,S[Conviva.Constants.LOG_LEVEL]=this.config.debugLoggingEnabled?Conviva.Constants.LogLevel.DEBUG:Conviva.Constants.LogLevel.NONE,Conviva.Analytics.init(a,m,S),this.contentMetadataBuilder=new l.ContentMetadataBuilder(this.logger),this.registerPlayerEvents()}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 t.prototype.initializeSession=function(){if(this.isSessionActive())this.logger.consoleLog("There is already a session running.",Conviva.SystemSettings.LogLevel.WARNING);else{if(!this.player.getSource()&&!this.contentMetadataBuilder.assetName)throw"AssetName is missing. Load player source first or set assetName via updateContentMetadata";this.internalInitializeSession(),this.sessionEndedExternally=!1}},t.prototype.endSession=function(){this.isSessionActive()&&(this.convivaVideoAnalytics.reportPlaybackEnded(),this.internalEndSession(),this.resetContentMetadata(),this.sessionEndedExternally=!0)},t.prototype.sendCustomApplicationEvent=function(t,e){void 0===e&&(e={}),this.isSessionActive()?this.convivaVideoAnalytics.reportAppEvent(t,e):this.logger.consoleLog("cannot send application event, no active monitoring session",Conviva.SystemSettings.LogLevel.WARNING)},t.prototype.sendCustomPlaybackEvent=function(t,e){void 0===e&&(e={}),this.isSessionActive()?this.convivaVideoAnalytics.reportPlaybackEvent(t,e):this.logger.consoleLog("cannot send playback event, no active monitoring session",Conviva.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.convivaVideoAnalytics.reportPlaybackFailed(t),a&&(this.internalEndSession(),this.resetContentMetadata()))},t.prototype.pauseTracking=function(){this.convivaVideoAnalytics.reportAdBreakStarted(Conviva.Constants.AdType.CLIENT_SIDE,Conviva.Constants.AdPlayer.SEPARATE,Conviva.Constants.AdPosition.PREROLL),this.debugLog("Tracking paused.")},t.prototype.resumeTracking=function(){this.convivaVideoAnalytics.reportAdBreakEnded(),this.debugLog("Tracking resumed.")},t.prototype.release=function(){this.destroy()},t.prototype.destroy=function(t){this.unregisterPlayerEvents(),this.internalEndSession(t)},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("[ ConvivaAnalytics ] no active session. Content metadata will be propagated to Conviva on session initialization.",Conviva.SystemSettings.LogLevel.DEBUG)},t.prototype.internalInitializeSession=function(){var t=this;this.buildContentMetadata(),this.convivaVideoAnalytics=Conviva.Analytics.buildVideoAnalytics(),this.convivaVideoAnalytics.reportPlaybackRequested(this.contentMetadataBuilder.build()),this.sessionKey=this.convivaVideoAnalytics.getSessionId(),this.convivaVideoAnalytics.setCallback(function(){var e=1e3*t.player.getCurrentTime("relativetime");t.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAY_HEAD_TIME,e)}),this.debugLog("[ ConvivaAnalytics ] start session",this.sessionKey),this.isSessionActive()||this.logger.consoleLog("Something went wrong, could not obtain session key",Conviva.SystemSettings.LogLevel.ERROR),this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,Conviva.Constants.PlayerState.STOPPED),this.lastSeenBitrate&&this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.BITRATE,this.lastSeenBitrate)},t.prototype.buildContentMetadata=function(){this.contentMetadataBuilder.duration=this.player.getDuration(),this.contentMetadataBuilder.streamType=this.player.isLive()?Conviva.ContentMetadata.StreamType.LIVE:Conviva.ContentMetadata.StreamType.VOD,this.contentMetadataBuilder.custom={autoplay:f.getAutoplayConfig(this.player)+"",preload:f.getPreloadConfig(this.player)+"",integrationVersion:t.VERSION};var e=this.player.getSource();e&&this.buildSourceRelatedMetadata(e)},t.prototype.buildSourceRelatedMetadata=function(t){this.contentMetadataBuilder.assetName=this.getAssetNameFromSource(t),this.contentMetadataBuilder.viewerId=this.contentMetadataBuilder.viewerId,this.contentMetadataBuilder.custom=n({playerType:this.player.getPlayerType(),streamType:this.player.getStreamType(),vrContentType:t.vr&&t.vr.contentType},this.contentMetadataBuilder.custom),this.contentMetadataBuilder.streamUrl=this.getUrlFromSource(t)},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.resetContentMetadata=function(){this.contentMetadataBuilder.reset()},t.prototype.isSessionActive=function(){return!!this.convivaVideoAnalytics},t.prototype.trackSeekStart=function(t){this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.SEEK_STARTED)},t.prototype.trackSeekEnd=function(){this.convivaVideoAnalytics.reportPlaybackMetric(Conviva.Constants.Playback.SEEK_ENDED)},t.prototype.registerPlayerEvents=function(){var t=this.handlers;t.add(this.events.SourceLoaded,this.onSourceLoaded),t.add(this.events.Play,this.onPlay),t.add(this.events.Playing,this.onPlaying),t.add(this.events.Paused,this.onPlaybackStateChanged),t.add(this.events.StallStarted,this.onPlaybackStateChanged),t.add(this.events.StallEnded,this.onPlaybackStateChanged),t.add(this.events.PlaybackFinished,this.onPlaybackFinished),t.add(this.events.VideoPlaybackQualityChanged,this.onVideoQualityChanged),t.add(this.events.AudioPlaybackQualityChanged,this.onCustomEvent),t.add(this.events.Muted,this.onCustomEvent),t.add(this.events.Unmuted,this.onCustomEvent),t.add(this.events.ViewModeChanged,this.onCustomEvent),t.add(this.events.AdBreakStarted,this.onAdBreakStarted),t.add(this.events.AdBreakFinished,this.onAdBreakFinished),t.add(this.events.AdSkipped,this.onAdSkipped),t.add(this.events.AdError,this.onAdError),t.add(this.events.SourceUnloaded,this.onSourceUnloaded),t.add(this.events.Error,this.onError),t.add(this.events.Destroy,this.onDestroy),t.add(this.events.Seek,this.onSeek),t.add(this.events.Seeked,this.onSeeked),t.add(this.events.TimeShift,this.onTimeShift),t.add(this.events.TimeShifted,this.onTimeShifted),t.add(this.events.CastStarted,this.onCustomEvent),t.add(this.events.CastStopped,this.onCustomEvent)},t.prototype.unregisterPlayerEvents=function(){this.handlers.clear()},Object.defineProperty(t,"version",{get:function(){return t.VERSION},enumerable:!0,configurable:!0}),t.VERSION="4.0.3",t.STALL_TRACKING_DELAY_MS=100,t}();e.ConvivaAnalytics=h;var f=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(u.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}(),g=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]&&p.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 n=a[e];this.remove(t,n)}},t}()},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.prototype.makeRequest=function(t,e,a,n,i,o){return this.makeRequestStandard.apply(this,arguments)},t.prototype.release=function(){},t.prototype.makeRequestStandard=function(t,e,a,n,i,o){var s=new XMLHttpRequest;return s.open(t,e,!0),n&&s.overrideMimeType&&s.overrideMimeType(n),n&&s.setRequestHeader&&s.setRequestHeader("Content-Type",n),i>0&&(s.timeout=i,s.ontimeout=function(){s.ontimeout=s.onreadystatechange=null,o&&o(!1,"timeout after "+i+" ms")}),s.onreadystatechange=function(){4===s.readyState&&(s.ontimeout=s.onreadystatechange=null,200===s.status?o&&o(!0,s.responseText):o&&o(!1,"http status "+s.status))},s.send(a),null},t}();e.Html5Http=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.prototype.consoleLog=function(t,e){"undefined"!=typeof console&&(console.log&&e===Conviva.SystemSettings.LogLevel.DEBUG||e===Conviva.SystemSettings.LogLevel.INFO?console.log(t):console.warn&&e===Conviva.SystemSettings.LogLevel.WARNING?console.warn(t):console.error&&e===Conviva.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});var n=function(){function t(){}return t.prototype.saveData=function(t,e,a,n){var i=t+"."+e;try{localStorage.setItem(i,a),n(!0,null)}catch(t){n(!1,t.toString())}},t.prototype.loadData=function(t,e,a){var n=t+"."+e;try{a(!0,localStorage.getItem(n))}catch(t){a(!1,t.toString())}},t.prototype.release=function(){},t}();e.Html5Storage=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.prototype.getEpochTimeMs=function(){return(new Date).getTime()},t.prototype.release=function(){},t}();e.Html5Time=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.prototype.createTimer=function(t,e,a){var n=window.setInterval(t,e);return function(){-1!==n&&(clearInterval(n),n=-1)}},t.prototype.release=function(){},t}();e.Html5Timer=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e,a){void 0===a&&(a=!1),this.delay=t,this.callback=e,this.repeat=a,this.timeoutOrIntervalId=0}return t.prototype.start=function(){return this.reset(),this},t.prototype.clear=function(){this.clearInternal()},t.prototype.reset=function(){this.clearInternal(),this.repeat?this.timeoutOrIntervalId=setInterval(this.callback,this.delay):this.timeoutOrIntervalId=setTimeout(this.callback,this.delay)},t.prototype.clearInternal=function(){this.repeat?clearInterval(this.timeoutOrIntervalId):clearTimeout(this.timeoutOrIntervalId)},t}();e.Timeout=n},function(t,e,a){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++)for(var i in e=arguments[a])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.logger=t,this.contentMetadata=new Conviva.ContentMetadata}return t.prototype.setOverrides=function(t){this.playbackStarted&&this.logger.consoleLog("[ Conviva Analytics ] Playback has started. Only some metadata attributes will be updated",Conviva.SystemSettings.LogLevel.WARNING),this.metadataOverrides=n({},this.metadataOverrides,t)},t.prototype.getOverrides=function(){return this.metadataOverrides},t.prototype.setPlaybackStarted=function(t){this.playbackStarted=t},t.prototype.build=function(){this.playbackStarted||(this.contentMetadata.assetName||(this.contentMetadata.assetName=this.assetName),this.contentMetadata.viewerId=this.viewerId,this.contentMetadata.streamType=this.metadataOverrides.streamType||this.metadata.streamType,this.contentMetadata.applicationName=this.metadataOverrides.applicationName||this.metadata.applicationName,this.contentMetadata.duration=this.metadataOverrides.duration||this.metadata.duration,this.contentMetadata.framework=this.metadataOverrides.framework||this.metadata.framework,this.contentMetadata.frameworkVersion=this.metadataOverrides.frameworkVersion||this.metadata.frameworkVersion,this.contentMetadata.custom=this.custom),this.contentMetadata.encodedFrameRate=this.metadataOverrides.encodedFrameRate||this.metadata.encodedFrameRate,this.contentMetadata.defaultResource=this.metadataOverrides.defaultResource||this.metadata.defaultResource,this.contentMetadata.streamUrl=this.metadataOverrides.streamUrl||this.metadata.streamUrl;var t={};return t[Conviva.Constants.ASSET_NAME]=this.contentMetadata.assetName,t[Conviva.Constants.ENCODED_FRAMERATE]=this.contentMetadata.encodedFrameRate,t[Conviva.Constants.DURATION]=this.contentMetadata.duration,t[Conviva.Constants.DEFAULT_RESOURCE]=this.contentMetadata.defaultResource,t[Conviva.Constants.STREAM_URL]=this.contentMetadata.streamUrl,t[Conviva.Constants.IS_LIVE]=this.contentMetadata.streamType,t[Conviva.Constants.VIEWER_ID]=this.contentMetadata.viewerId||"GET_VIEWER_ID_FROM_PLAYER",t[Conviva.Constants.PLAYER_NAME]=this.contentMetadata.applicationName||"GET_PLAYER_NAME_OR_TYPE",t[Conviva.Constants.FRAMEWORK_NAME]=this.contentMetadata.framework,t[Conviva.Constants.FRAMEWORK_VERSION]=this.contentMetadata.frameworkVersion,n({},t,this.contentMetadata.custom)},Object.defineProperty(t.prototype,"assetName",{get:function(){return this.metadataOverrides.assetName||this.metadata.assetName},set:function(t){this.metadata.assetName=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"viewerId",{get:function(){return this.metadataOverrides.viewerId||this.metadata.viewerId},set:function(t){this.metadata.viewerId=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"streamType",{set:function(t){this.metadata.streamType=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"applicationName",{set:function(t){this.metadata.applicationName=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"custom",{get:function(){return n({},this.metadataOverrides.custom,this.metadata.custom)},set:function(t){this.metadata.custom=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"duration",{set:function(t){this.metadata.duration=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"encodedFrameRate",{set:function(t){this.metadata.encodedFrameRate=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultResource",{set:function(t){this.metadata.defaultResource=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"streamUrl",{set:function(t){this.metadata.streamUrl=t},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.contentMetadata=new Conviva.ContentMetadata},t}();e.ContentMetadataBuilder=i},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.flatten=function(t,e){void 0===e&&(e="");var a={},n=function(t,e){for(var i in t)if(t.hasOwnProperty(i)){var o=t[i];"object"==typeof o?n(o,e+i+"."):a[e+i]=String(o)}};return n(t,e),a}}(e.ObjectUtils||(e.ObjectUtils={}))},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=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),n=/Safari/i.test(navigator.userAgent)&&/Mobile/i.test(navigator.userAgent);return t||e||a||n},t}();e.BrowserUtils=n},function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!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});var n=function(){function t(){}return t.mapAdPosition=function(t,e){return t.scheduleTime<=0?Conviva.Constants.AdPosition.PREROLL:t.scheduleTime>=e.getDuration()?Conviva.Constants.AdPosition.POSTROLL:Conviva.Constants.AdPosition.MIDROLL},t}();e.AdBreakHelper=n}])}); | ||
//# sourceMappingURL=bitmovin-player-analytics-conviva.js.map |
@@ -17,4 +17,52 @@ import { PlayerAPI } from 'bitmovin-player'; | ||
* user agent string parsing by the Conviva SDK. (default: WEB) | ||
* @deprecated Use `deviceMetadata.category` field | ||
*/ | ||
deviceCategory?: Conviva.Constants.DeviceCategory; | ||
/** | ||
* Option to override the Conviva Device Metadata. | ||
* (Default: Auto extract all options from User Agent string) | ||
*/ | ||
deviceMetadata?: { | ||
/** | ||
* Option to set the Conviva Device Category, which is used to assist with | ||
* user agent string parsing by the Conviva SDK. | ||
* (default: The same specified in config.deviceCategory) | ||
*/ | ||
category?: Conviva.Constants.DeviceCategory; | ||
/** | ||
* Option to override the Conviva Device Brand. | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
brand?: string; | ||
/** | ||
* Option to override the Conviva Device Manufacturer. | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
manufacturer?: string; | ||
/** | ||
* Option to override the Conviva Device Model. | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
model?: string; | ||
/** | ||
* Option to override the Conviva Device Type | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
type?: Conviva.Constants.DeviceType; | ||
/** | ||
* Option to override the Conviva Device Version. | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
version?: string; | ||
/** | ||
* Option to override the Conviva Operating System Name | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
osName?: string; | ||
/** | ||
* Option to override the Conviva Operating System Version | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
osVersion?: string; | ||
}; | ||
} | ||
@@ -21,0 +69,0 @@ export interface EventAttributes { |
@@ -282,8 +282,15 @@ "use strict"; | ||
this.config.debugLoggingEnabled = this.config.debugLoggingEnabled || false; | ||
this.config.deviceCategory = this.config.deviceCategory || Conviva.Constants.DeviceCategory.WEB; | ||
this.logger = new Html5Logging_1.Html5Logging(); | ||
this.sessionKey = Conviva.Constants.NO_SESSION_KEY; | ||
this.isAd = false; | ||
var deviceMetadataFromConfig = this.config.deviceMetadata || {}; | ||
var deviceMetadata = (_a = {}, | ||
_a[Conviva.Constants.DeviceMetadata.CATEGORY] = this.config.deviceCategory, | ||
_a[Conviva.Constants.DeviceMetadata.CATEGORY] = deviceMetadataFromConfig.category || this.config.deviceCategory || Conviva.Constants.DeviceCategory.WEB, | ||
_a[Conviva.Constants.DeviceMetadata.BRAND] = deviceMetadataFromConfig.brand, | ||
_a[Conviva.Constants.DeviceMetadata.MANUFACTURER] = deviceMetadataFromConfig.manufacturer, | ||
_a[Conviva.Constants.DeviceMetadata.MODEL] = deviceMetadataFromConfig.model, | ||
_a[Conviva.Constants.DeviceMetadata.TYPE] = deviceMetadataFromConfig.type, | ||
_a[Conviva.Constants.DeviceMetadata.VERSION] = deviceMetadataFromConfig.version, | ||
_a[Conviva.Constants.DeviceMetadata.OS_NAME] = deviceMetadataFromConfig.osName, | ||
_a[Conviva.Constants.DeviceMetadata.OS_VERSION] = deviceMetadataFromConfig.osVersion, | ||
_a); | ||
@@ -534,3 +541,3 @@ Conviva.Analytics.setDeviceMetadata(deviceMetadata); | ||
this.contentMetadataBuilder.viewerId = this.contentMetadataBuilder.viewerId; | ||
this.contentMetadataBuilder.custom = __assign({}, this.contentMetadataBuilder.custom, { playerType: this.player.getPlayerType(), streamType: this.player.getStreamType(), vrContentType: source.vr && source.vr.contentType }); | ||
this.contentMetadataBuilder.custom = __assign({ playerType: this.player.getPlayerType(), streamType: this.player.getStreamType(), vrContentType: source.vr && source.vr.contentType }, this.contentMetadataBuilder.custom); | ||
this.contentMetadataBuilder.streamUrl = this.getUrlFromSource(source); | ||
@@ -537,0 +544,0 @@ }; |
{ | ||
"name": "@bitmovin/player-integration-conviva", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "Conviva analytics integration for the Bitmovin Player", | ||
@@ -27,3 +27,3 @@ "repository": { | ||
"@types/jest": "^24.0.1", | ||
"bitmovin-player": "8.31.0", | ||
"bitmovin-player": "^8.31.0", | ||
"bitmovin-player-ui": "^3.3.1", | ||
@@ -41,3 +41,6 @@ "create-file-webpack": "^1.0.2", | ||
"webpack-merge": "^4.1.5" | ||
}, | ||
"peerDependencies": { | ||
"bitmovin-player": "^8.31.0" | ||
} | ||
} |
@@ -48,3 +48,13 @@ # Bitmovin Player Conviva Analytics Integration | ||
gatewayUrl: 'https://youraccount-test.testonly.conviva.com', // optional, TOUCHSTONE_SERVICE_URL for testing | ||
deviceCategory: Conviva.Client.DeviceCategory.WEB // optional, (default: WEB) | ||
deviceCategory: Conviva.Client.DeviceCategory.WEB, // optional, deprecated (Use deviceMetadata.category) (default: WEB) | ||
deviceMetadata: { // optional (default: let Conviva backend infer these fields from User Agent sring) | ||
category: Conviva.Client.DeviceCategory.WEB, // optional (default: WEB) | ||
brand: 'Device brand', // optional | ||
manufacturer: 'Device Manufacturer', // optional | ||
model: 'Device Model', // optional | ||
type: Conviva.Client.DeviceType.DESKTOP, // optional | ||
version: 'Device version', // optional | ||
osName: 'Operating system name', // optional | ||
osVersion: 'Operating system version' // optional | ||
} | ||
}); | ||
@@ -63,6 +73,6 @@ | ||
1. Using custom Build: | ||
2. Using custom Build: | ||
1. Include `bitmovinplayer-analytics-conviva.js` **after** `conviva-core-sdk.min.js` in your HTML document | ||
1. Usage | ||
2. Usage | ||
```js | ||
@@ -95,3 +105,3 @@ var playerConfig = { | ||
1. Release the instance by calling `conviva.release()` before destroying the player by calling `player.destroy()` | ||
2. Release the instance by calling `conviva.release()` before destroying the player by calling `player.destroy()` | ||
@@ -98,0 +108,0 @@ ### Advanced Usage |
@@ -149,6 +149,10 @@ declare namespace Conviva { | ||
type DeviceMetadata = { | ||
[key: string]: Conviva.Constants.DeviceCategory | Conviva.Constants.DeviceType | string; | ||
}; | ||
class Analytics { | ||
public static init(customerKey: string, callbackFunctions: any, settings?: {[key: string]: string| number}): void; | ||
public static buildVideoAnalytics(): Conviva.ConvivaVideoAnalytics; | ||
public static setDeviceMetadata(metadata: {[key: string]: Conviva.Constants.DeviceCategory}): Conviva.Constants.DeviceCategory; | ||
public static setDeviceMetadata(metadata: DeviceMetadata): Conviva.Constants.DeviceCategory; | ||
public static release(): void; | ||
@@ -155,0 +159,0 @@ } |
@@ -7,3 +7,2 @@ import { | ||
import { Html5Logging } from './Html5Logging'; | ||
import { Html5Metadata } from './Html5Metadata'; | ||
import { Html5Storage } from './Html5Storage'; | ||
@@ -17,3 +16,2 @@ import { Html5Time } from './Html5Time'; | ||
import { ArrayUtils } from 'bitmovin-player-ui/dist/js/framework/arrayutils'; | ||
import { DeviceMetadata } from './Html5Metadata'; | ||
import { AdBreakHelper } from './helper/AdBreakHelper'; | ||
@@ -37,4 +35,60 @@ | ||
* user agent string parsing by the Conviva SDK. (default: WEB) | ||
* @deprecated Use `deviceMetadata.category` field | ||
*/ | ||
deviceCategory?: Conviva.Constants.DeviceCategory; | ||
/** | ||
* Option to override the Conviva Device Metadata. | ||
* (Default: Auto extract all options from User Agent string) | ||
*/ | ||
deviceMetadata?: { | ||
/** | ||
* Option to set the Conviva Device Category, which is used to assist with | ||
* user agent string parsing by the Conviva SDK. | ||
* (default: The same specified in config.deviceCategory) | ||
*/ | ||
category?: Conviva.Constants.DeviceCategory; | ||
/** | ||
* Option to override the Conviva Device Brand. | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
brand?: string; | ||
/** | ||
* Option to override the Conviva Device Manufacturer. | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
manufacturer?: string; | ||
/** | ||
* Option to override the Conviva Device Model. | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
model?: string; | ||
/** | ||
* Option to override the Conviva Device Type | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
type?: Conviva.Constants.DeviceType; | ||
/** | ||
* Option to override the Conviva Device Version. | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
version?: string; | ||
/** | ||
* Option to override the Conviva Operating System Name | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
osName?: string; | ||
/** | ||
* Option to override the Conviva Operating System Version | ||
* (Default: Auto extract from User Agent string) | ||
*/ | ||
osVersion?: string; | ||
}; | ||
} | ||
@@ -113,3 +167,2 @@ | ||
this.config.debugLoggingEnabled = this.config.debugLoggingEnabled || false; | ||
this.config.deviceCategory = this.config.deviceCategory || Conviva.Constants.DeviceCategory.WEB; | ||
@@ -120,4 +173,12 @@ this.logger = new Html5Logging(); | ||
const deviceMetadata: {[key: string]: Conviva.Constants.DeviceCategory} = { | ||
[Conviva.Constants.DeviceMetadata.CATEGORY]: this.config.deviceCategory, | ||
const deviceMetadataFromConfig = this.config.deviceMetadata || {}; | ||
const deviceMetadata = { | ||
[Conviva.Constants.DeviceMetadata.CATEGORY]: deviceMetadataFromConfig.category || this.config.deviceCategory || Conviva.Constants.DeviceCategory.WEB, | ||
[Conviva.Constants.DeviceMetadata.BRAND]: deviceMetadataFromConfig.brand, | ||
[Conviva.Constants.DeviceMetadata.MANUFACTURER]: deviceMetadataFromConfig.manufacturer, | ||
[Conviva.Constants.DeviceMetadata.MODEL]: deviceMetadataFromConfig.model, | ||
[Conviva.Constants.DeviceMetadata.TYPE]: deviceMetadataFromConfig.type, | ||
[Conviva.Constants.DeviceMetadata.VERSION]: deviceMetadataFromConfig.version, | ||
[Conviva.Constants.DeviceMetadata.OS_NAME]: deviceMetadataFromConfig.osName, | ||
[Conviva.Constants.DeviceMetadata.OS_VERSION]: deviceMetadataFromConfig.osVersion, | ||
}; | ||
@@ -410,6 +471,6 @@ Conviva.Analytics.setDeviceMetadata(deviceMetadata); | ||
this.contentMetadataBuilder.custom = { | ||
...this.contentMetadataBuilder.custom, | ||
playerType: this.player.getPlayerType(), | ||
streamType: this.player.getStreamType(), | ||
vrContentType: source.vr && source.vr.contentType, | ||
...this.contentMetadataBuilder.custom, | ||
}; | ||
@@ -416,0 +477,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
259332
150
1
54
2853