Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bitmovin/player-integration-conviva

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitmovin/player-integration-conviva - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

dist/lib/helper/AdBreakHelper.d.ts

8

CHANGELOG.md

@@ -7,4 +7,10 @@ # Changelog

## [3.0.4]
### Fixed
- Send playing event after an ad break has finished.
## [3.0.3]
### Added
- Added a configuration option to set the Conviva Device Category.

@@ -14,2 +20,3 @@

### Added
- `endSession` will now prevent a new session from being initialized via internal event handling

@@ -55,2 +62,3 @@

[3.0.4]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v3.0.3...v3.0.4
[3.0.3]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v3.0.2...v3.0.3

@@ -57,0 +65,0 @@ [3.0.2]: https://github.com/bitmovin/bitmovin-player-analytics-conviva/compare/v3.0.1...v3.0.2

2

dist/bitmovin-player-analytics-conviva.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("bitmovin-player-analytics-conviva",[],t):"object"==typeof exports?exports["bitmovin-player-analytics-conviva"]=t():(e.bitmovin=e.bitmovin||{},e.bitmovin.player=e.bitmovin.player||{},e.bitmovin.player.analytics=t())}(window,function(){return function(e){var t={};function n(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(a,i,function(t){return e[t]}.bind(null,i));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=n(1);t.ConvivaAnalytics=a.ConvivaAnalytics},function(e,t,n){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),o=n(3),s=n(4),r=n(5),l=n(6),d=n(7),c=n(8),u=n(9),v=n(10),y=function(){function e(t,n,a){void 0===a&&(a={});var v=this;if(this.stallTrackingTimout=new c.Timeout(e.STALL_TRACKING_DELAY_MS,function(){v.playerStateManager.setPlayerState(Conviva.PlayerStateManager.PlayerState.BUFFERING)}),this.sessionEndedExternally=!1,this.internalEndSession=function(e){v.debugLog("[ ConvivaAnalytics ] end session",v.sessionKey,e),v.client.detachPlayer(v.sessionKey),v.client.cleanupSession(v.sessionKey),v.client.releasePlayerStateManager(v.playerStateManager),v.sessionKey=Conviva.Client.NO_SESSION_KEY,v.contentMetadataBuilder.reset(),v.lastSeenBitrate=null},this.onPlaybackStateChanged=function(e){if(!v.isAd&&v.isSessionActive()){var t;switch(e.type){case v.events.Play:case v.events.Seek:case v.events.TimeShift:v.stallTrackingTimout.start();break;case v.events.StallStarted:v.stallTrackingTimout.clear(),t=Conviva.PlayerStateManager.PlayerState.BUFFERING;break;case v.events.Playing:v.stallTrackingTimout.clear(),v.adBreakStartedToFire&&(v.trackAdBreakStarted(v.adBreakStartedToFire),v.adBreakStartedToFire=null),t=Conviva.PlayerStateManager.PlayerState.PLAYING;break;case v.events.Paused:v.stallTrackingTimout.clear(),t=Conviva.PlayerStateManager.PlayerState.PAUSED;break;case v.events.Seeked:case v.events.TimeShifted:case v.events.StallEnded:v.stallTrackingTimout.clear(),t=v.player.isPlaying()?Conviva.PlayerStateManager.PlayerState.PLAYING:Conviva.PlayerStateManager.PlayerState.PAUSED;break;case v.events.PlaybackFinished:v.stallTrackingTimout.clear(),t=Conviva.PlayerStateManager.PlayerState.STOPPED}t&&(v.debugLog("[ ConvivaAnalytics ] report playback state",t),v.playerStateManager.setPlayerState(t))}},this.onSourceLoaded=function(e){v.isSessionActive()&&(v.buildSourceRelatedMetadata(v.player.getSource()),v.updateSession())},this.onPlay=function(e){v.debugLog("[ Player Event ] play",e),v.isAd||(v.isSessionActive()||v.sessionEndedExternally||v.internalInitializeSession(),v.onPlaybackStateChanged(e))},this.onPlaying=function(e){v.contentMetadataBuilder.setPlaybackStarted(!0),v.debugLog("[ Player Event ] playing",e),v.updateSession(),v.onPlaybackStateChanged(e)},this.onPlaybackFinished=function(e){v.debugLog("[ Player Event ] playback finished",e),v.isSessionActive()&&(v.onPlaybackStateChanged(e),v.internalEndSession(e))},this.onVideoQualityChanged=function(e){var t=Math.round(e.targetQuality.bitrate/1e3);v.isSessionActive()?(v.lastSeenBitrate=null,v.playerStateManager.setBitrateKbps(t)):v.lastSeenBitrate=t},this.onCustomEvent=function(e){if(v.isSessionActive()){var t=h.flatten(e);v.sendCustomPlaybackEvent(e.type,t)}else v.debugLog("skip custom event, no session existing",e)},this.trackAdBreakStarted=function(e){v.debugLog("[ ConvivaAnalytics ] adbreak started",e),v.isAd=!0;var t=v.mapAdPosition(e.adBreak);v.isSessionActive()&&v.client.adStart(v.sessionKey,Conviva.Client.AdStream.SEPARATE,Conviva.Client.AdPlayer.CONTENT,t)},this.onAdBreakFinished=function(e){v.debugLog("[ ConvivaAnalytics ] adbreak finished",e),v.isAd=!1,v.isSessionActive()&&v.client.adEnd(v.sessionKey)},this.onAdSkipped=function(e){v.onCustomEvent(e)},this.onAdError=function(e){v.onCustomEvent(e)},this.onSeek=function(e){v.isSessionActive()&&(v.trackSeekStart(e.seekTarget),v.onPlaybackStateChanged(e))},this.onSeeked=function(e){v.isSessionActive()&&(v.trackSeekEnd(),v.onPlaybackStateChanged(e))},this.onTimeShift=function(e){v.isSessionActive()&&(v.trackSeekStart(-1),v.onPlaybackStateChanged(e))},this.onTimeShifted=function(e){v.isSessionActive()&&(v.trackSeekEnd(),v.onPlaybackStateChanged(e))},this.onError=function(e){v.isSessionActive()||v.sessionEndedExternally||v.internalInitializeSession(),v.reportPlaybackDeficiency(String(e.code)+" "+e.name,Conviva.Client.ErrorSeverity.FATAL)},this.onSourceUnloaded=function(e){v.isAd||v.internalEndSession(e)},this.onDestroy=function(e){v.destroy(e)},this.onAdBreakStarted=function(e){if(e.adBreak.scheduleTime===1/0)return v.debugLog("[ ConvivaAnalytics ] detected post-roll ad ... Ending session"),void v.onPlaybackFinished({timestamp:Date.now(),type:v.events.PlaybackFinished});v.isSessionActive()?v.trackAdBreakStarted(e):v.adBreakStartedToFire=e},"undefined"!=typeof Conviva)if(t.getSource())console.error("Bitmovin Conviva integration must be instantiated before calling player.load()");else{this.player=t,this.events=t.exports.PlayerEvent,this.handlers=new f(t),this.config=a,this.config.debugLoggingEnabled=this.config.debugLoggingEnabled||!1,this.config.deviceCategory=this.config.deviceCategory||Conviva.Client.DeviceCategory.WEB,this.logger=new o.Html5Logging,this.sessionKey=Conviva.Client.NO_SESSION_KEY,this.isAd=!1;var y={deviceCategory:this.config.deviceCategory},p=new Conviva.SystemInterface(new l.Html5Time,new d.Html5Timer,new i.Html5Http,new r.Html5Storage,new s.Html5Metadata(y),this.logger),g=new Conviva.SystemSettings;this.systemFactory=new Conviva.SystemFactory(p,g);var S=new Conviva.ClientSettings(n);a.gatewayUrl&&(S.gatewayUrl=a.gatewayUrl),this.client=new Conviva.Client(S,this.systemFactory),this.contentMetadataBuilder=new u.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 e.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}},e.prototype.endSession=function(){this.isSessionActive()&&(this.internalEndSession(),this.sessionEndedExternally=!0)},e.prototype.sendCustomApplicationEvent=function(e,t){void 0===t&&(t={}),this.client.sendCustomEvent(Conviva.Client.NO_SESSION_KEY,e,t)},e.prototype.sendCustomPlaybackEvent=function(e,t){void 0===t&&(t={}),this.isSessionActive()?this.client.sendCustomEvent(this.sessionKey,e,t):this.logger.consoleLog("cannot send playback event, no active monitoring session",Conviva.SystemSettings.LogLevel.WARNING)},e.prototype.updateContentMetadata=function(e){this.contentMetadataBuilder.setOverrides(e),this.isSessionActive()?(this.buildContentMetadata(),this.updateSession()):this.logger.consoleLog("[ ConvivaAnalytics ] no active session; Don't propagate content metadata to conviva.",Conviva.SystemSettings.LogLevel.WARNING)},e.prototype.reportPlaybackDeficiency=function(e,t,n){void 0===n&&(n=!0),this.isSessionActive()&&(this.client.reportError(this.sessionKey,e,t),n&&this.internalEndSession())},e.prototype.pauseTracking=function(){this.client.adStart(this.sessionKey,Conviva.Client.AdStream.SEPARATE,Conviva.Client.AdPlayer.SEPARATE,Conviva.Client.AdPosition.PREROLL),this.client.detachPlayer(this.sessionKey),this.debugLog("Tracking paused.")},e.prototype.resumeTracking=function(){this.client.attachPlayer(this.sessionKey,this.playerStateManager),this.client.adEnd(this.sessionKey),this.debugLog("Tracking resumed.")},e.prototype.release=function(){this.destroy()},e.prototype.destroy=function(e){this.unregisterPlayerEvents(),this.internalEndSession(e),this.client.release(),this.systemFactory.release()},e.prototype.debugLog=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this.config.debugLoggingEnabled&&console.log.apply(console,arguments)},e.prototype.getUrlFromSource=function(e){switch(this.player.getStreamType()){case"dash":return e.dash;case"hls":return e.hls;case"progressive":return Array.isArray(e.progressive)?e.progressive[0].url:e.progressive}},e.prototype.internalInitializeSession=function(){this.playerStateManager=this.client.getPlayerStateManager(),this.playerStateManager.setPlayerType("Bitmovin Player"),this.playerStateManager.setPlayerVersion(this.player.version),this.buildContentMetadata(),this.sessionKey=this.client.createSession(this.contentMetadataBuilder.build()),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.playerStateManager.setPlayerState(Conviva.PlayerStateManager.PlayerState.STOPPED),this.client.attachPlayer(this.sessionKey,this.playerStateManager),this.lastSeenBitrate&&this.playerStateManager.setBitrateKbps(this.lastSeenBitrate)},e.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:g.getAutoplayConfig(this.player)+"",preload:g.getPreloadConfig(this.player)+"",integrationVersion:e.VERSION};var t=this.player.getSource();t&&this.buildSourceRelatedMetadata(t)},e.prototype.buildSourceRelatedMetadata=function(e){this.contentMetadataBuilder.assetName=this.getAssetNameFromSource(e),this.contentMetadataBuilder.viewerId=this.contentMetadataBuilder.viewerId,this.contentMetadataBuilder.custom=a({},this.contentMetadataBuilder.custom,{playerType:this.player.getPlayerType(),streamType:this.player.getStreamType(),vrContentType:e.vr&&e.vr.contentType}),this.contentMetadataBuilder.streamUrl=this.getUrlFromSource(e)},e.prototype.updateSession=function(){this.isSessionActive()&&this.client.updateContentMetadata(this.sessionKey,this.contentMetadataBuilder.build())},e.prototype.getAssetNameFromSource=function(e){var t=e.title;return t||"Untitled (no source.title set)"},e.prototype.isSessionActive=function(){return this.sessionKey!==Conviva.Client.NO_SESSION_KEY},e.prototype.mapAdPosition=function(e){return e.scheduleTime<=0?Conviva.Client.AdPosition.PREROLL:e.scheduleTime>=this.player.getDuration()?Conviva.Client.AdPosition.POSTROLL:Conviva.Client.AdPosition.MIDROLL},e.prototype.trackSeekStart=function(e){this.playerStateManager.setPlayerSeekStart(Math.round(e))},e.prototype.trackSeekEnd=function(){this.playerStateManager.setPlayerSeekEnd()},e.prototype.registerPlayerEvents=function(){var e=this.handlers;e.add(this.events.SourceLoaded,this.onSourceLoaded),e.add(this.events.Play,this.onPlay),e.add(this.events.Playing,this.onPlaying),e.add(this.events.Paused,this.onPlaybackStateChanged),e.add(this.events.StallStarted,this.onPlaybackStateChanged),e.add(this.events.StallEnded,this.onPlaybackStateChanged),e.add(this.events.PlaybackFinished,this.onPlaybackFinished),e.add(this.events.VideoPlaybackQualityChanged,this.onVideoQualityChanged),e.add(this.events.AudioPlaybackQualityChanged,this.onCustomEvent),e.add(this.events.Muted,this.onCustomEvent),e.add(this.events.Unmuted,this.onCustomEvent),e.add(this.events.ViewModeChanged,this.onCustomEvent),e.add(this.events.CastStarted,this.onCustomEvent),e.add(this.events.CastStopped,this.onCustomEvent),e.add(this.events.AdBreakStarted,this.onAdBreakStarted),e.add(this.events.AdBreakFinished,this.onAdBreakFinished),e.add(this.events.AdSkipped,this.onAdSkipped),e.add(this.events.AdError,this.onAdError),e.add(this.events.SourceUnloaded,this.onSourceUnloaded),e.add(this.events.Error,this.onError),e.add(this.events.Destroy,this.onDestroy),e.add(this.events.Seek,this.onSeek),e.add(this.events.Seeked,this.onSeeked),e.add(this.events.TimeShift,this.onTimeShift),e.add(this.events.TimeShifted,this.onTimeShifted)},e.prototype.unregisterPlayerEvents=function(){this.handlers.clear()},Object.defineProperty(e,"version",{get:function(){return e.VERSION},enumerable:!0,configurable:!0}),e.VERSION="3.0.3",e.STALL_TRACKING_DELAY_MS=100,e}();t.ConvivaAnalytics=y;var p,h,g=function(){function e(){}return e.getAutoplayConfig=function(t){var n=t.getConfig();return n.playback&&void 0!==n.playback.autoplay?n.playback.autoplay:e.AUTOPLAY_DEFAULT_CONFIG},e.getPreloadConfig=function(e){var t=e.getConfig();if(v.BrowserUtils.isMobile()){if(t.adaptation&&t.adaptation.mobile&&void 0!==t.adaptation.mobile.preload)return t.adaptation.mobile.preload}else if(t.adaptation&&t.adaptation.desktop&&void 0!==t.adaptation.desktop.preload)return t.adaptation.desktop.preload;return t.adaptation&&void 0!==t.adaptation.preload?t.adaptation.preload:!e.isLive()},e.AUTOPLAY_DEFAULT_CONFIG=!1,e}(),f=function(){function e(e){this.player=e,this.eventHandlers={}}return e.prototype.add=function(e,t){this.player.on(e,t),this.eventHandlers[e]||(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t)},e.prototype.remove=function(e,t){this.player.off(e,t),this.eventHandlers[e]&&p.remove(this.eventHandlers[e],t)},e.prototype.clear=function(){for(var e in this.eventHandlers)for(var t=0,n=this.eventHandlers[e];t<n.length;t++){var a=n[t];this.remove(e,a)}},e}();!function(e){e.remove=function(e,t){var n=e.indexOf(t);return n>-1?e.splice(n,1)[0]:null}}(p||(p={})),function(e){e.flatten=function(e,t){void 0===t&&(t="");var n={};return n}}(h||(h={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.makeRequest=function(e,t,n,a,i,o){return this.makeRequestStandard.apply(this,arguments)},e.prototype.release=function(){},e.prototype.makeRequestStandard=function(e,t,n,a,i,o){var s=new XMLHttpRequest;return s.open(e,t,!0),a&&s.overrideMimeType&&s.overrideMimeType(a),a&&s.setRequestHeader&&s.setRequestHeader("Content-Type",a),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(n),null},e}();t.Html5Http=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.consoleLog=function(e,t){"undefined"!=typeof console&&(console.log&&t===Conviva.SystemSettings.LogLevel.DEBUG||t===Conviva.SystemSettings.LogLevel.INFO?console.log(e):console.warn&&t===Conviva.SystemSettings.LogLevel.WARNING?console.warn(e):console.error&&t===Conviva.SystemSettings.LogLevel.ERROR&&console.error(e))},e.prototype.release=function(){},e}();t.Html5Logging=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e){this.metadata=e}return e.prototype.getBrowserName=function(){return null},e.prototype.getBrowserVersion=function(){return null},e.prototype.getDeviceBrand=function(){return null},e.prototype.getDeviceManufacturer=function(){return null},e.prototype.getDeviceModel=function(){return null},e.prototype.getDeviceType=function(){return null},e.prototype.getDeviceVersion=function(){return null},e.prototype.getFrameworkName=function(){return"HTML5"},e.prototype.getFrameworkVersion=function(){return null},e.prototype.getOperatingSystemName=function(){return null},e.prototype.getOperatingSystemVersion=function(){return null},e.prototype.getDeviceCategory=function(){return this.metadata.deviceCategory},e.prototype.release=function(){},e}();t.Html5Metadata=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.saveData=function(e,t,n,a){var i=e+"."+t;try{localStorage.setItem(i,n),a(!0,null)}catch(e){a(!1,e.toString())}},e.prototype.loadData=function(e,t,n){var a=e+"."+t;try{n(!0,localStorage.getItem(a))}catch(e){n(!1,e.toString())}},e.prototype.release=function(){},e}();t.Html5Storage=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.getEpochTimeMs=function(){return(new Date).getTime()},e.prototype.release=function(){},e}();t.Html5Time=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.createTimer=function(e,t,n){var a=setInterval(e,t);return function(){-1!==a&&(clearInterval(a),a=-1)}},e.prototype.release=function(){},e}();t.Html5Timer=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t,n){void 0===n&&(n=!1),this.delay=e,this.callback=t,this.repeat=n,this.timeoutOrIntervalId=0}return e.prototype.start=function(){return this.reset(),this},e.prototype.clear=function(){this.clearInternal()},e.prototype.reset=function(){this.clearInternal(),this.repeat?this.timeoutOrIntervalId=setInterval(this.callback,this.delay):this.timeoutOrIntervalId=setTimeout(this.callback,this.delay)},e.prototype.clearInternal=function(){this.repeat?clearInterval(this.timeoutOrIntervalId):clearTimeout(this.timeoutOrIntervalId)},e}();t.Timeout=a},function(e,t,n){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.logger=e,this.contentMetadata=new Conviva.ContentMetadata}return e.prototype.setOverrides=function(e){this.playbackStarted&&this.logger.consoleLog("[ Conviva Analytics ] Playback has started. Only some metadata attributes will be updated",Conviva.SystemSettings.LogLevel.WARNING),this.metadataOverrides=e},e.prototype.setPlaybackStarted=function(e){this.playbackStarted=e},e.prototype.build=function(){return 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.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,this.contentMetadata},Object.defineProperty(e.prototype,"assetName",{get:function(){return this.metadataOverrides.assetName||this.metadata.assetName},set:function(e){this.metadata.assetName=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewerId",{get:function(){return this.metadataOverrides.viewerId||this.metadata.viewerId},set:function(e){this.metadata.viewerId=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"streamType",{set:function(e){this.metadata.streamType=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"applicationName",{set:function(e){this.metadata.applicationName=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"custom",{get:function(){return a({},this.metadataOverrides.custom,this.metadata.custom)},set:function(e){this.metadata.custom=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"duration",{set:function(e){this.metadata.duration=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"encodedFrameRate",{set:function(e){this.metadata.encodedFrameRate=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultResource",{set:function(e){this.metadata.defaultResource=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"streamUrl",{set:function(e){this.metadata.streamUrl=e},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.contentMetadata=new Conviva.ContentMetadata},e}();t.ContentMetadataBuilder=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.isMobile=function(){var e=/Android/i.test(navigator.userAgent),t=/IEMobile/i.test(navigator.userAgent),n=/Windows Phone 10.0/i.test(navigator.userAgent),a=/Safari/i.test(navigator.userAgent)&&/Mobile/i.test(navigator.userAgent);return e||t||n||a},e}();t.BrowserUtils=a}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("bitmovin-player-analytics-conviva",[],t):"object"==typeof exports?exports["bitmovin-player-analytics-conviva"]=t():(e.bitmovin=e.bitmovin||{},e.bitmovin.player=e.bitmovin.player||{},e.bitmovin.player.analytics=t())}(window,function(){return function(e){var t={};function n(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(a,i,function(t){return e[t]}.bind(null,i));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=n(1);t.ConvivaAnalytics=a.ConvivaAnalytics},function(e,t,n){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),o=n(3),r=n(4),s=n(5),l=n(6),d=n(7),c=n(8),u=n(9),v=n(10),y=n(11),p=n(12),h=n(13),f=function(){function e(t,n,a){void 0===a&&(a={});var y=this;if(this.stallTrackingTimout=new c.Timeout(e.STALL_TRACKING_DELAY_MS,function(){y.playerStateManager.setPlayerState(Conviva.PlayerStateManager.PlayerState.BUFFERING)}),this.sessionEndedExternally=!1,this.internalEndSession=function(e){y.isSessionActive()&&(y.debugLog("[ ConvivaAnalytics ] end session",y.sessionKey,e),y.client.detachPlayer(y.sessionKey),y.client.cleanupSession(y.sessionKey),y.client.releasePlayerStateManager(y.playerStateManager),y.sessionKey=Conviva.Client.NO_SESSION_KEY,y.lastSeenBitrate=null)},this.onPlaybackStateChanged=function(e){if(!y.isAd&&y.isSessionActive()){var t;switch(e.type){case y.events.Play:case y.events.Seek:case y.events.TimeShift:y.stallTrackingTimout.start();break;case y.events.StallStarted:y.stallTrackingTimout.clear(),t=Conviva.PlayerStateManager.PlayerState.BUFFERING;break;case y.events.Playing:y.stallTrackingTimout.clear(),y.adBreakStartedToFire&&(y.trackAdBreakStarted(y.adBreakStartedToFire),y.adBreakStartedToFire=null),t=Conviva.PlayerStateManager.PlayerState.PLAYING;break;case y.events.Paused:y.stallTrackingTimout.clear(),t=Conviva.PlayerStateManager.PlayerState.PAUSED;break;case y.events.Seeked:case y.events.TimeShifted:case y.events.StallEnded:y.stallTrackingTimout.clear(),t=y.player.isPlaying()?Conviva.PlayerStateManager.PlayerState.PLAYING:Conviva.PlayerStateManager.PlayerState.PAUSED;break;case y.events.PlaybackFinished:y.stallTrackingTimout.clear(),t=Conviva.PlayerStateManager.PlayerState.STOPPED}t&&(y.debugLog("[ ConvivaAnalytics ] report playback state",t),y.playerStateManager.setPlayerState(t))}},this.onSourceLoaded=function(e){y.isSessionActive()&&(y.buildSourceRelatedMetadata(y.player.getSource()),y.updateSession())},this.onPlay=function(e){y.debugLog("[ Player Event ] play",e),y.isAd||(y.isSessionActive()||y.sessionEndedExternally||y.internalInitializeSession(),y.onPlaybackStateChanged(e))},this.onPlaying=function(e){y.contentMetadataBuilder.setPlaybackStarted(!0),y.debugLog("[ Player Event ] playing",e),y.updateSession(),y.onPlaybackStateChanged(e)},this.onPlaybackFinished=function(e){y.debugLog("[ Player Event ] playback finished",e),y.isSessionActive()&&(y.onPlaybackStateChanged(e),y.internalEndSession(e),y.resetContentMetadata())},this.onVideoQualityChanged=function(e){var t=Math.round(e.targetQuality.bitrate/1e3);y.isSessionActive()?(y.lastSeenBitrate=null,y.playerStateManager.setBitrateKbps(t)):y.lastSeenBitrate=t},this.onCustomEvent=function(e){if(y.isSessionActive()){var t=v.ObjectUtils.flatten(e);y.sendCustomPlaybackEvent(e.type,t)}else y.debugLog("skip custom event, no session existing",e)},this.trackAdBreakStarted=function(e){y.debugLog("[ ConvivaAnalytics ] adbreak started",e),y.isAd=!0;var t=h.AdBreakHelper.mapAdPosition(e.adBreak,y.player);y.isSessionActive()&&y.client.adStart(y.sessionKey,Conviva.Client.AdStream.SEPARATE,Conviva.Client.AdPlayer.CONTENT,t)},this.onAdBreakFinished=function(e){y.debugLog("[ ConvivaAnalytics ] adbreak finished",e),y.isAd=!1,y.isSessionActive()&&(y.client.adEnd(y.sessionKey),y.playerStateManager.setPlayerState(Conviva.PlayerStateManager.PlayerState.PLAYING))},this.onAdSkipped=function(e){y.onCustomEvent(e)},this.onAdError=function(e){y.onCustomEvent(e)},this.onSeek=function(e){y.isSessionActive()&&(y.trackSeekStart(e.seekTarget),y.onPlaybackStateChanged(e))},this.onSeeked=function(e){y.isSessionActive()&&(y.trackSeekEnd(),y.onPlaybackStateChanged(e))},this.onTimeShift=function(e){y.isSessionActive()&&(y.trackSeekStart(-1),y.onPlaybackStateChanged(e))},this.onTimeShifted=function(e){y.isSessionActive()&&(y.trackSeekEnd(),y.onPlaybackStateChanged(e))},this.onError=function(e){y.isSessionActive()||y.sessionEndedExternally||y.internalInitializeSession(),y.reportPlaybackDeficiency(String(e.code)+" "+e.name,Conviva.Client.ErrorSeverity.FATAL)},this.onSourceUnloaded=function(e){y.isAd||(y.internalEndSession(e),y.resetContentMetadata())},this.onDestroy=function(e){y.destroy(e)},this.onAdBreakStarted=function(e){if(e.adBreak.scheduleTime===1/0)return y.debugLog("[ ConvivaAnalytics ] detected post-roll ad ... Ending session"),void y.onPlaybackFinished({timestamp:Date.now(),type:y.events.PlaybackFinished});y.isSessionActive()?y.trackAdBreakStarted(e):y.adBreakStartedToFire=e},"undefined"!=typeof Conviva)if(t.getSource())console.error("Bitmovin Conviva integration must be instantiated before calling player.load()");else{this.player=t,this.events=t.exports.PlayerEvent,this.handlers=new S(t),this.config=a,this.config.debugLoggingEnabled=this.config.debugLoggingEnabled||!1,this.config.deviceCategory=this.config.deviceCategory||Conviva.Client.DeviceCategory.WEB,this.logger=new o.Html5Logging,this.sessionKey=Conviva.Client.NO_SESSION_KEY,this.isAd=!1;var p={deviceCategory:this.config.deviceCategory},f=new Conviva.SystemInterface(new l.Html5Time,new d.Html5Timer,new i.Html5Http,new s.Html5Storage,new r.Html5Metadata(p),this.logger),g=new Conviva.SystemSettings;this.systemFactory=new Conviva.SystemFactory(f,g);var m=new Conviva.ClientSettings(n);a.gatewayUrl&&(m.gatewayUrl=a.gatewayUrl),this.client=new Conviva.Client(m,this.systemFactory),this.contentMetadataBuilder=new u.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 e.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}},e.prototype.endSession=function(){this.isSessionActive()&&(this.internalEndSession(),this.resetContentMetadata(),this.sessionEndedExternally=!0)},e.prototype.sendCustomApplicationEvent=function(e,t){void 0===t&&(t={}),this.client.sendCustomEvent(Conviva.Client.NO_SESSION_KEY,e,t)},e.prototype.sendCustomPlaybackEvent=function(e,t){void 0===t&&(t={}),this.isSessionActive()?this.client.sendCustomEvent(this.sessionKey,e,t):this.logger.consoleLog("cannot send playback event, no active monitoring session",Conviva.SystemSettings.LogLevel.WARNING)},e.prototype.updateContentMetadata=function(e){this.internalUpdateContentMetadata(e)},e.prototype.reportPlaybackDeficiency=function(e,t,n){void 0===n&&(n=!0),this.isSessionActive()&&(this.client.reportError(this.sessionKey,e,t),n&&(this.internalEndSession(),this.resetContentMetadata()))},e.prototype.pauseTracking=function(){this.client.adStart(this.sessionKey,Conviva.Client.AdStream.SEPARATE,Conviva.Client.AdPlayer.SEPARATE,Conviva.Client.AdPosition.PREROLL),this.client.detachPlayer(this.sessionKey),this.debugLog("Tracking paused.")},e.prototype.resumeTracking=function(){this.client.attachPlayer(this.sessionKey,this.playerStateManager),this.client.adEnd(this.sessionKey),this.debugLog("Tracking resumed.")},e.prototype.release=function(){this.destroy()},e.prototype.destroy=function(e){this.unregisterPlayerEvents(),this.internalEndSession(e),this.client.release(),this.systemFactory.release()},e.prototype.debugLog=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];this.config.debugLoggingEnabled&&console.log.apply(console,arguments)},e.prototype.getUrlFromSource=function(e){switch(this.player.getStreamType()){case"dash":return e.dash;case"hls":return e.hls;case"progressive":return Array.isArray(e.progressive)?e.progressive[0].url:e.progressive}},e.prototype.internalUpdateContentMetadata=function(e){this.contentMetadataBuilder.setOverrides(e),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)},e.prototype.internalInitializeSession=function(){this.playerStateManager=this.client.getPlayerStateManager(),this.playerStateManager.setPlayerType("Bitmovin Player"),this.playerStateManager.setPlayerVersion(this.player.version),this.buildContentMetadata(),this.sessionKey=this.client.createSession(this.contentMetadataBuilder.build()),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.playerStateManager.setPlayerState(Conviva.PlayerStateManager.PlayerState.STOPPED),this.client.attachPlayer(this.sessionKey,this.playerStateManager),this.lastSeenBitrate&&this.playerStateManager.setBitrateKbps(this.lastSeenBitrate)},e.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:g.getAutoplayConfig(this.player)+"",preload:g.getPreloadConfig(this.player)+"",integrationVersion:e.VERSION};var t=this.player.getSource();t&&this.buildSourceRelatedMetadata(t)},e.prototype.buildSourceRelatedMetadata=function(e){this.contentMetadataBuilder.assetName=this.getAssetNameFromSource(e),this.contentMetadataBuilder.viewerId=this.contentMetadataBuilder.viewerId,this.contentMetadataBuilder.custom=a({},this.contentMetadataBuilder.custom,{playerType:this.player.getPlayerType(),streamType:this.player.getStreamType(),vrContentType:e.vr&&e.vr.contentType}),this.contentMetadataBuilder.streamUrl=this.getUrlFromSource(e)},e.prototype.updateSession=function(){this.isSessionActive()&&this.client.updateContentMetadata(this.sessionKey,this.contentMetadataBuilder.build())},e.prototype.getAssetNameFromSource=function(e){var t=e.title;return t||"Untitled (no source.title set)"},e.prototype.resetContentMetadata=function(){this.contentMetadataBuilder.reset()},e.prototype.isSessionActive=function(){return this.sessionKey!==Conviva.Client.NO_SESSION_KEY},e.prototype.trackSeekStart=function(e){this.playerStateManager.setPlayerSeekStart(Math.round(e))},e.prototype.trackSeekEnd=function(){this.playerStateManager.setPlayerSeekEnd()},e.prototype.registerPlayerEvents=function(){var e=this.handlers;e.add(this.events.SourceLoaded,this.onSourceLoaded),e.add(this.events.Play,this.onPlay),e.add(this.events.Playing,this.onPlaying),e.add(this.events.Paused,this.onPlaybackStateChanged),e.add(this.events.StallStarted,this.onPlaybackStateChanged),e.add(this.events.StallEnded,this.onPlaybackStateChanged),e.add(this.events.PlaybackFinished,this.onPlaybackFinished),e.add(this.events.VideoPlaybackQualityChanged,this.onVideoQualityChanged),e.add(this.events.AudioPlaybackQualityChanged,this.onCustomEvent),e.add(this.events.Muted,this.onCustomEvent),e.add(this.events.Unmuted,this.onCustomEvent),e.add(this.events.ViewModeChanged,this.onCustomEvent),e.add(this.events.AdBreakStarted,this.onAdBreakStarted),e.add(this.events.AdBreakFinished,this.onAdBreakFinished),e.add(this.events.AdSkipped,this.onAdSkipped),e.add(this.events.AdError,this.onAdError),e.add(this.events.SourceUnloaded,this.onSourceUnloaded),e.add(this.events.Error,this.onError),e.add(this.events.Destroy,this.onDestroy),e.add(this.events.Seek,this.onSeek),e.add(this.events.Seeked,this.onSeeked),e.add(this.events.TimeShift,this.onTimeShift),e.add(this.events.TimeShifted,this.onTimeShifted),e.add(this.events.CastStarted,this.onCustomEvent),e.add(this.events.CastStopped,this.onCustomEvent)},e.prototype.unregisterPlayerEvents=function(){this.handlers.clear()},Object.defineProperty(e,"version",{get:function(){return e.VERSION},enumerable:!0,configurable:!0}),e.VERSION="3.0.4",e.STALL_TRACKING_DELAY_MS=100,e}();t.ConvivaAnalytics=f;var g=function(){function e(){}return e.getAutoplayConfig=function(t){var n=t.getConfig();return n.playback&&void 0!==n.playback.autoplay?n.playback.autoplay:e.AUTOPLAY_DEFAULT_CONFIG},e.getPreloadConfig=function(e){var t=e.getConfig();if(y.BrowserUtils.isMobile()){if(t.adaptation&&t.adaptation.mobile&&void 0!==t.adaptation.mobile.preload)return t.adaptation.mobile.preload}else if(t.adaptation&&t.adaptation.desktop&&void 0!==t.adaptation.desktop.preload)return t.adaptation.desktop.preload;return t.adaptation&&void 0!==t.adaptation.preload?t.adaptation.preload:!e.isLive()},e.AUTOPLAY_DEFAULT_CONFIG=!1,e}(),S=function(){function e(e){this.player=e,this.eventHandlers={}}return e.prototype.add=function(e,t){this.player.on(e,t),this.eventHandlers[e]||(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t)},e.prototype.remove=function(e,t){this.player.off(e,t),this.eventHandlers[e]&&p.ArrayUtils.remove(this.eventHandlers[e],t)},e.prototype.clear=function(){for(var e in this.eventHandlers)for(var t=0,n=this.eventHandlers[e];t<n.length;t++){var a=n[t];this.remove(e,a)}},e}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.makeRequest=function(e,t,n,a,i,o){return this.makeRequestStandard.apply(this,arguments)},e.prototype.release=function(){},e.prototype.makeRequestStandard=function(e,t,n,a,i,o){var r=new XMLHttpRequest;return r.open(e,t,!0),a&&r.overrideMimeType&&r.overrideMimeType(a),a&&r.setRequestHeader&&r.setRequestHeader("Content-Type",a),i>0&&(r.timeout=i,r.ontimeout=function(){r.ontimeout=r.onreadystatechange=null,o&&o(!1,"timeout after "+i+" ms")}),r.onreadystatechange=function(){4===r.readyState&&(r.ontimeout=r.onreadystatechange=null,200===r.status?o&&o(!0,r.responseText):o&&o(!1,"http status "+r.status))},r.send(n),null},e}();t.Html5Http=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.consoleLog=function(e,t){"undefined"!=typeof console&&(console.log&&t===Conviva.SystemSettings.LogLevel.DEBUG||t===Conviva.SystemSettings.LogLevel.INFO?console.log(e):console.warn&&t===Conviva.SystemSettings.LogLevel.WARNING?console.warn(e):console.error&&t===Conviva.SystemSettings.LogLevel.ERROR&&console.error(e))},e.prototype.release=function(){},e}();t.Html5Logging=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e){this.metadata=e}return e.prototype.getBrowserName=function(){return null},e.prototype.getBrowserVersion=function(){return null},e.prototype.getDeviceBrand=function(){return null},e.prototype.getDeviceManufacturer=function(){return null},e.prototype.getDeviceModel=function(){return null},e.prototype.getDeviceType=function(){return null},e.prototype.getDeviceVersion=function(){return null},e.prototype.getFrameworkName=function(){return"HTML5"},e.prototype.getFrameworkVersion=function(){return null},e.prototype.getOperatingSystemName=function(){return null},e.prototype.getOperatingSystemVersion=function(){return null},e.prototype.getDeviceCategory=function(){return this.metadata.deviceCategory},e.prototype.release=function(){},e}();t.Html5Metadata=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.saveData=function(e,t,n,a){var i=e+"."+t;try{localStorage.setItem(i,n),a(!0,null)}catch(e){a(!1,e.toString())}},e.prototype.loadData=function(e,t,n){var a=e+"."+t;try{n(!0,localStorage.getItem(a))}catch(e){n(!1,e.toString())}},e.prototype.release=function(){},e}();t.Html5Storage=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.getEpochTimeMs=function(){return(new Date).getTime()},e.prototype.release=function(){},e}();t.Html5Time=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.prototype.createTimer=function(e,t,n){var a=setInterval(e,t);return function(){-1!==a&&(clearInterval(a),a=-1)}},e.prototype.release=function(){},e}();t.Html5Timer=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t,n){void 0===n&&(n=!1),this.delay=e,this.callback=t,this.repeat=n,this.timeoutOrIntervalId=0}return e.prototype.start=function(){return this.reset(),this},e.prototype.clear=function(){this.clearInternal()},e.prototype.reset=function(){this.clearInternal(),this.repeat?this.timeoutOrIntervalId=setInterval(this.callback,this.delay):this.timeoutOrIntervalId=setTimeout(this.callback,this.delay)},e.prototype.clearInternal=function(){this.repeat?clearInterval(this.timeoutOrIntervalId):clearTimeout(this.timeoutOrIntervalId)},e}();t.Timeout=a},function(e,t,n){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.logger=e,this.contentMetadata=new Conviva.ContentMetadata}return e.prototype.setOverrides=function(e){this.playbackStarted&&this.logger.consoleLog("[ Conviva Analytics ] Playback has started. Only some metadata attributes will be updated",Conviva.SystemSettings.LogLevel.WARNING),this.metadataOverrides=a({},this.metadataOverrides,e)},e.prototype.getOverrides=function(){return this.metadataOverrides},e.prototype.setPlaybackStarted=function(e){this.playbackStarted=e},e.prototype.build=function(){return 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.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,this.contentMetadata},Object.defineProperty(e.prototype,"assetName",{get:function(){return this.metadataOverrides.assetName||this.metadata.assetName},set:function(e){this.metadata.assetName=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewerId",{get:function(){return this.metadataOverrides.viewerId||this.metadata.viewerId},set:function(e){this.metadata.viewerId=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"streamType",{set:function(e){this.metadata.streamType=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"applicationName",{set:function(e){this.metadata.applicationName=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"custom",{get:function(){return a({},this.metadataOverrides.custom,this.metadata.custom)},set:function(e){this.metadata.custom=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"duration",{set:function(e){this.metadata.duration=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"encodedFrameRate",{set:function(e){this.metadata.encodedFrameRate=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultResource",{set:function(e){this.metadata.defaultResource=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"streamUrl",{set:function(e){this.metadata.streamUrl=e},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.metadataOverrides={},this.metadata={},this.playbackStarted=!1,this.contentMetadata=new Conviva.ContentMetadata},e}();t.ContentMetadataBuilder=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.flatten=function(e,t){void 0===t&&(t="");var n={},a=function(e,t){for(var i in e)if(e.hasOwnProperty(i)){var o=e[i];"object"==typeof o?a(o,t+i+"."):n[t+i]=String(o)}};return a(e,t),n}}(t.ObjectUtils||(t.ObjectUtils={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.isMobile=function(){var e=/Android/i.test(navigator.userAgent),t=/IEMobile/i.test(navigator.userAgent),n=/Windows Phone 10.0/i.test(navigator.userAgent),a=/Safari/i.test(navigator.userAgent)&&/Mobile/i.test(navigator.userAgent);return e||t||n||a},e}();t.BrowserUtils=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.remove=function(e,t){var n=e.indexOf(t);return n>-1?e.splice(n,1)[0]:null}}(t.ArrayUtils||(t.ArrayUtils={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(){}return e.mapAdPosition=function(e,t){return e.scheduleTime<=0?Conviva.Client.AdPosition.PREROLL:e.scheduleTime>=t.getDuration()?Conviva.Client.AdPosition.POSTROLL:Conviva.Client.AdPosition.MIDROLL},e}();t.AdBreakHelper=a}])});
//# sourceMappingURL=bitmovin-player-analytics-conviva.js.map

@@ -27,2 +27,3 @@ export interface Metadata {

setOverrides(newValue: Metadata): void;
getOverrides(): Metadata;
setPlaybackStarted(value: boolean): void;

@@ -29,0 +30,0 @@ build(): Conviva.ContentMetadata;

@@ -31,4 +31,7 @@ "use strict";

}
this.metadataOverrides = newValue;
this.metadataOverrides = __assign({}, this.metadataOverrides, newValue);
};
ContentMetadataBuilder.prototype.getOverrides = function () {
return this.metadataOverrides;
};
ContentMetadataBuilder.prototype.setPlaybackStarted = function (value) {

@@ -35,0 +38,0 @@ this.playbackStarted = value;

@@ -15,5 +15,5 @@ import { PlayerAPI } from 'bitmovin-player';

/**
* Option to set the Conviva Device Category, which is used to assist with
* user agent string parsing by the Conviva SDK. (default: WEB)
*/
* Option to set the Conviva Device Category, which is used to assist with
* user agent string parsing by the Conviva SDK. (default: WEB)
*/
deviceCategory?: Conviva.Client.DeviceCategory;

@@ -126,2 +126,3 @@ }

private getUrlFromSource;
private internalUpdateContentMetadata;
/**

@@ -157,2 +158,3 @@ * A Conviva Session should only be initialized when there is a source provided in the player because

private internalEndSession;
private resetContentMetadata;
private isSessionActive;

@@ -167,3 +169,2 @@ private onPlaybackStateChanged;

private trackAdBreakStarted;
private mapAdPosition;
private onAdBreakFinished;

@@ -170,0 +171,0 @@ private onAdSkipped;

@@ -22,3 +22,6 @@ "use strict";

var ContentMetadataBuilder_1 = require("./ContentMetadataBuilder");
var BrowserUtils_1 = require("./BrowserUtils");
var ObjectUtils_1 = require("./helper/ObjectUtils");
var BrowserUtils_1 = require("./helper/BrowserUtils");
var arrayutils_1 = require("bitmovin-player-ui/dist/js/framework/arrayutils");
var AdBreakHelper_1 = require("./helper/AdBreakHelper");
var ConvivaAnalytics = /** @class */ (function () {

@@ -39,2 +42,5 @@ function ConvivaAnalytics(player, customerKey, config) {

this.internalEndSession = function (event) {
if (!_this.isSessionActive()) {
return;
}
_this.debugLog('[ ConvivaAnalytics ] end session', _this.sessionKey, event);

@@ -45,3 +51,2 @@ _this.client.detachPlayer(_this.sessionKey);

_this.sessionKey = Conviva.Client.NO_SESSION_KEY;
_this.contentMetadataBuilder.reset();
_this.lastSeenBitrate = null;

@@ -134,2 +139,3 @@ };

_this.internalEndSession(event);
_this.resetContentMetadata();
};

@@ -155,3 +161,3 @@ this.onVideoQualityChanged = function (event) {

}
var eventAttributes = ObjectUtils.flatten(event);
var eventAttributes = ObjectUtils_1.ObjectUtils.flatten(event);
_this.sendCustomPlaybackEvent(event.type, eventAttributes);

@@ -162,3 +168,3 @@ };

_this.isAd = true;
var adPosition = _this.mapAdPosition(event.adBreak);
var adPosition = AdBreakHelper_1.AdBreakHelper.mapAdPosition(event.adBreak, _this.player);
if (!_this.isSessionActive()) {

@@ -178,2 +184,3 @@ // Don't report without a valid session (e.g., in case of a pre-roll, or post-roll ad)

_this.client.adEnd(_this.sessionKey);
_this.playerStateManager.setPlayerState(Conviva.PlayerStateManager.PlayerState.PLAYING);
};

@@ -232,3 +239,6 @@ this.onAdSkipped = function (event) {

}
_this.internalEndSession(event);
else {
_this.internalEndSession(event);
_this.resetContentMetadata();
}
};

@@ -336,2 +346,3 @@ this.onDestroy = function (event) {

this.internalEndSession();
this.resetContentMetadata();
this.sessionEndedExternally = true;

@@ -375,9 +386,3 @@ };

ConvivaAnalytics.prototype.updateContentMetadata = function (metadataOverrides) {
this.contentMetadataBuilder.setOverrides(metadataOverrides);
if (!this.isSessionActive()) {
this.logger.consoleLog('[ ConvivaAnalytics ] no active session; Don\'t propagate content metadata to conviva.', Conviva.SystemSettings.LogLevel.WARNING);
return;
}
this.buildContentMetadata();
this.updateSession();
this.internalUpdateContentMetadata(metadataOverrides);
};

@@ -400,2 +405,3 @@ /**

this.internalEndSession();
this.resetContentMetadata();
}

@@ -456,2 +462,11 @@ };

};
ConvivaAnalytics.prototype.internalUpdateContentMetadata = function (metadataOverrides) {
this.contentMetadataBuilder.setOverrides(metadataOverrides);
if (!this.isSessionActive()) {
this.logger.consoleLog('[ ConvivaAnalytics ] no active session. Content metadata will be propagated to Conviva on session initialization.', Conviva.SystemSettings.LogLevel.DEBUG);
return;
}
this.buildContentMetadata();
this.updateSession();
};
/**

@@ -538,14 +553,8 @@ * A Conviva Session should only be initialized when there is a source provided in the player because

};
ConvivaAnalytics.prototype.resetContentMetadata = function () {
this.contentMetadataBuilder.reset();
};
ConvivaAnalytics.prototype.isSessionActive = function () {
return this.sessionKey !== Conviva.Client.NO_SESSION_KEY;
};
ConvivaAnalytics.prototype.mapAdPosition = function (adBreak) {
if (adBreak.scheduleTime <= 0) {
return Conviva.Client.AdPosition.PREROLL;
}
if (adBreak.scheduleTime >= this.player.getDuration()) {
return Conviva.Client.AdPosition.POSTROLL;
}
return Conviva.Client.AdPosition.MIDROLL;
};
ConvivaAnalytics.prototype.trackSeekStart = function (target) {

@@ -571,4 +580,2 @@ this.playerStateManager.setPlayerSeekStart(Math.round(target));

playerEvents.add(this.events.ViewModeChanged, this.onCustomEvent);
playerEvents.add(this.events.CastStarted, this.onCustomEvent);
playerEvents.add(this.events.CastStopped, this.onCustomEvent);
playerEvents.add(this.events.AdBreakStarted, this.onAdBreakStarted);

@@ -585,2 +592,4 @@ playerEvents.add(this.events.AdBreakFinished, this.onAdBreakFinished);

playerEvents.add(this.events.TimeShifted, this.onTimeShifted);
playerEvents.add(this.events.CastStarted, this.onCustomEvent);
playerEvents.add(this.events.CastStopped, this.onCustomEvent);
};

@@ -672,3 +681,3 @@ ConvivaAnalytics.prototype.unregisterPlayerEvents = function () {

if (this.eventHandlers[eventType]) {
ArrayUtils.remove(this.eventHandlers[eventType], callback);
arrayutils_1.ArrayUtils.remove(this.eventHandlers[eventType], callback);
}

@@ -686,47 +695,2 @@ };

}());
/**
* Extracted from bitmovin-player-ui
*/
var ArrayUtils;
(function (ArrayUtils) {
/**
* Removes an item from an array.
* @param array the array that may contain the item to remove
* @param item the item to remove from the array
* @returns {any} the removed item or null if it wasn't part of the array
*/
function remove(array, item) {
var index = array.indexOf(item);
if (index > -1) {
return array.splice(index, 1)[0];
}
else {
return null;
}
}
ArrayUtils.remove = remove;
})(ArrayUtils || (ArrayUtils = {}));
var ObjectUtils;
(function (ObjectUtils) {
function flatten(object, prefix) {
if (prefix === void 0) { prefix = ''; }
var eventAttributes = {};
// Flatten the event object into a string-to-string dictionary with the object property hierarchy in dot notation
var objectWalker = function (object, prefix) {
for (var key in object) {
if (object.hasOwnProperty(key)) {
var value = object[key];
if (typeof value === 'object') {
objectWalker(value, prefix + key + '.');
}
else {
eventAttributes[prefix + key] = String(value);
}
}
}
};
return eventAttributes;
}
ObjectUtils.flatten = flatten;
})(ObjectUtils || (ObjectUtils = {}));
//# sourceMappingURL=ConvivaAnalytics.js.map
{
"name": "@bitmovin/player-integration-conviva",
"version": "3.0.3",
"version": "3.0.4",
"description": "Conviva analytics integration for the Bitmovin Player",

@@ -27,3 +27,3 @@ "repository": {

"@types/jest": "^24.0.1",
"bitmovin-player": "8.2.0",
"bitmovin-player": "8.6.0",
"bitmovin-player-ui": "^3.3.1",

@@ -30,0 +30,0 @@ "create-file-webpack": "^1.0.2",

# Bitmovin Player Conviva Analytics Integration
## Compatibility

@@ -8,3 +7,13 @@ **This version of the Conviva Analytics Integration works only with Player Version >= 8.2.x.

## Getting Started
### Installation
#### Using NPM
Install the npm package:
```
npm i @bitmovin/player-integration-conviva --save-dev
```
#### Using custom build
Build the JS file by running `npm run build`
### Developing
1. Clone Git repository

@@ -19,41 +28,72 @@ 2. Install node.js

## Usage
1. Include `conviva-core-sdk.min.js` as **first** of all scripts in your HTML document
1. Build the script by running `npm run build`
1. Create an instance of `ConvivaAnalytics` **before** calling `player.load(...)` and pass in your Conviva `CUSTOMER_KEY` and optional configuration properties:
2. Include `bitmovinplayer-analytics-conviva.js` **after** `conviva-core-sdk.min.js` in your HTML document
1. Using NPM import:
1. Import ConvivaAnalytics:
```typescript
import { ConvivaAnalytics } from '@bitmovin/player-integration-conviva';
```
3. Create an instance of `ConvivaAnalytics` **before** calling `player.load(...)` and pass in your Conviva `CUSTOMER_KEY` and optional configuration properties:
```js
var playerConfig = {
key: 'YOUR-PLAYER-KEY',
// ...
};
1. Usage
```typescript
const playerConfig = {
key: 'YOUR-PLAYER-KEY',
// ...
};
var container = document.getElementById('player');
var player = new bitmovin.player.Player(container, playerConfig);
const player = new Player(document.getElementById('player'), playerConfig);
const conviva = new ConvivaAnalytics(player, 'CUSTOMER_KEY', {
debugLoggingEnabled: true, // optional
gatewayUrl: 'https://youraccount-test.testonly.conviva.com', // optional, TOUCHSTONE_SERVICE_URL for testing
deviceCategory: Conviva.Client.DeviceCategory.WEB // optional, (default: WEB)
});
var sourceConfig = {
// ...
};
player.load(sourceConfig).then(function() {
console.log('player loaded');
}, function(reason) {
console.error('player setup failed', reason);
});
```
// A ConvivaAnalytics instance is always tied to one player instance
var conviva = new bitmovin.player.analytics.ConvivaAnalytics(player, 'CUSTOMER_KEY', {
debugLoggingEnabled: true, // optional
gatewayUrl: 'https://youraccount-test.testonly.conviva.com', // optional, TOUCHSTONE_SERVICE_URL for testing
deviceCategory: Conviva.Client.DeviceCategory.WEB // optional, (default: WEB)
});
var sourceConfig = {
// ...
};
player.load(sourceConfig).then(function() {
console.log('player loaded');
}, function(reason) {
console.error('player setup failed', reason);
});
```
1. Using custom Build:
1. Include `bitmovinplayer-analytics-conviva.js` **after** `conviva-core-sdk.min.js` in your HTML document
4. Release the instance by calling `conviva.release()` before destroying the player by calling `player.destroy()`
1. Usage
```js
var playerConfig = {
key: 'YOUR-PLAYER-KEY',
// ...
};
var container = document.getElementById('player');
var player = new bitmovin.player.Player(container, playerConfig);
// A ConvivaAnalytics instance is always tied to one player instance
var conviva = new bitmovin.player.analytics.ConvivaAnalytics(player, 'CUSTOMER_KEY', {
debugLoggingEnabled: true, // optional
gatewayUrl: 'https://youraccount-test.testonly.conviva.com', // optional, TOUCHSTONE_SERVICE_URL for testing
deviceCategory: Conviva.Client.DeviceCategory.WEB // optional, (default: WEB)
});
var sourceConfig = {
// ...
};
player.load(sourceConfig).then(function() {
console.log('player loaded');
}, function(reason) {
console.error('player setup failed', reason);
});
```
1. Release the instance by calling `conviva.release()` before destroying the player by calling `player.destroy()`
### Advanced Usage
#### VPF tracking
If you would like to track custom VPF (Video Playback Failures) events when no actual player error happens (e.g.

@@ -71,3 +111,2 @@ the server closes the connection and return `net::ERR_EMPTY_RESPONSE` or after a certain time of stalling)

#### Content Metadata handling
If you want to override some content metadata attributes you can do so by adding the following:

@@ -98,3 +137,2 @@

#### Consecutive playback
If you want to use the same player instance for multiple playback, just load a new source with `player.load(…)`.

@@ -101,0 +139,0 @@ The integration will close the active session.

@@ -49,5 +49,9 @@ export interface Metadata {

this.metadataOverrides = newValue;
this.metadataOverrides = { ...this.metadataOverrides, ...newValue };
}
getOverrides(): Metadata {
return this.metadataOverrides;
}
setPlaybackStarted(value: boolean) {

@@ -54,0 +58,0 @@ this.playbackStarted = value;

import {
AdBreak, AdBreakEvent, AdEvent, ErrorEvent, PlaybackEvent, PlayerAPI, PlayerEvent, PlayerEventBase, SeekEvent,
SourceConfig, TimeShiftEvent, VideoQualityChangedEvent,
AdBreak, AdBreakEvent, AdEvent, ErrorEvent, PlaybackEvent, PlayerAPI, PlayerEvent, PlayerEventBase,
SeekEvent, SourceConfig, TimeShiftEvent, VideoQualityChangedEvent,
} from 'bitmovin-player';

@@ -13,4 +13,7 @@ import { Html5Http } from './Html5Http';

import { ContentMetadataBuilder, Metadata } from './ContentMetadataBuilder';
import { BrowserUtils } from './BrowserUtils';
import { ObjectUtils } from './helper/ObjectUtils';
import { BrowserUtils } from './helper/BrowserUtils';
import { ArrayUtils } from 'bitmovin-player-ui/dist/js/framework/arrayutils';
import { DeviceMetadata } from './Html5Metadata';
import { AdBreakHelper } from './helper/AdBreakHelper';

@@ -29,3 +32,4 @@ type Player = PlayerAPI;

gatewayUrl?: string;
/**
/**
* Option to set the Conviva Device Category, which is used to assist with

@@ -186,2 +190,3 @@ * user agent string parsing by the Conviva SDK. (default: WEB)

this.internalEndSession();
this.resetContentMetadata();
this.sessionEndedExternally = true;

@@ -228,14 +233,3 @@ }

public updateContentMetadata(metadataOverrides: Metadata) {
this.contentMetadataBuilder.setOverrides(metadataOverrides);
if (!this.isSessionActive()) {
this.logger.consoleLog(
'[ ConvivaAnalytics ] no active session; Don\'t propagate content metadata to conviva.',
Conviva.SystemSettings.LogLevel.WARNING,
);
return;
}
this.buildContentMetadata();
this.updateSession();
this.internalUpdateContentMetadata(metadataOverrides);
}

@@ -259,2 +253,3 @@

this.internalEndSession();
this.resetContentMetadata();
}

@@ -322,2 +317,17 @@ }

private internalUpdateContentMetadata(metadataOverrides: Metadata) {
this.contentMetadataBuilder.setOverrides(metadataOverrides);
if (!this.isSessionActive()) {
this.logger.consoleLog(
'[ ConvivaAnalytics ] no active session. Content metadata will be propagated to Conviva on session initialization.',
Conviva.SystemSettings.LogLevel.DEBUG,
);
return;
}
this.buildContentMetadata();
this.updateSession();
}
/**

@@ -427,2 +437,6 @@ * A Conviva Session should only be initialized when there is a source provided in the player because

private internalEndSession = (event?: PlayerEventBase) => {
if (!this.isSessionActive()) {
return;
}
this.debugLog('[ ConvivaAnalytics ] end session', this.sessionKey, event);

@@ -434,7 +448,9 @@ this.client.detachPlayer(this.sessionKey);

this.sessionKey = Conviva.Client.NO_SESSION_KEY;
this.contentMetadataBuilder.reset();
this.lastSeenBitrate = null;
};
private resetContentMetadata(): void {
this.contentMetadataBuilder.reset();
}
private isSessionActive(): boolean {

@@ -543,2 +559,3 @@ return this.sessionKey !== Conviva.Client.NO_SESSION_KEY;

this.internalEndSession(event);
this.resetContentMetadata();
};

@@ -577,3 +594,3 @@

const adPosition = this.mapAdPosition(event.adBreak);
const adPosition = AdBreakHelper.mapAdPosition(event.adBreak, this.player);

@@ -588,14 +605,2 @@ if (!this.isSessionActive()) {

private mapAdPosition(adBreak: AdBreak): Conviva.Client.AdPosition {
if (adBreak.scheduleTime <= 0) {
return Conviva.Client.AdPosition.PREROLL;
}
if (adBreak.scheduleTime >= this.player.getDuration()) {
return Conviva.Client.AdPosition.POSTROLL;
}
return Conviva.Client.AdPosition.MIDROLL;
}
private onAdBreakFinished = (event: AdBreakEvent | ErrorEvent) => {

@@ -605,3 +610,2 @@ this.debugLog('[ ConvivaAnalytics ] adbreak finished', event);

if (!this.isSessionActive()) {

@@ -613,2 +617,3 @@ // Don't report without a valid session (e.g., in case of a pre-roll, or post-roll ad)

this.client.adEnd(this.sessionKey);
this.playerStateManager.setPlayerState(Conviva.PlayerStateManager.PlayerState.PLAYING);
};

@@ -687,5 +692,6 @@

return;
} else {
this.internalEndSession(event);
this.resetContentMetadata();
}
this.internalEndSession(event);
};

@@ -712,4 +718,2 @@

playerEvents.add(this.events.ViewModeChanged, this.onCustomEvent);
playerEvents.add(this.events.CastStarted, this.onCustomEvent);
playerEvents.add(this.events.CastStopped, this.onCustomEvent);
playerEvents.add(this.events.AdBreakStarted, this.onAdBreakStarted);

@@ -726,2 +730,5 @@ playerEvents.add(this.events.AdBreakFinished, this.onAdBreakFinished);

playerEvents.add(this.events.TimeShifted, this.onTimeShifted);
playerEvents.add(this.events.CastStarted, this.onCustomEvent);
playerEvents.add(this.events.CastStopped, this.onCustomEvent);
}

@@ -861,44 +868,1 @@

}
/**
* Extracted from bitmovin-player-ui
*/
namespace ArrayUtils {
/**
* Removes an item from an array.
* @param array the array that may contain the item to remove
* @param item the item to remove from the array
* @returns {any} the removed item or null if it wasn't part of the array
*/
export function remove<T>(array: T[], item: T): T | null {
const index = array.indexOf(item);
if (index > -1) {
return array.splice(index, 1)[0];
} else {
return null;
}
}
}
namespace ObjectUtils {
export function flatten(object: any, prefix: string = '') {
const eventAttributes: EventAttributes = {};
// Flatten the event object into a string-to-string dictionary with the object property hierarchy in dot notation
const objectWalker = (object: any, prefix: string) => {
for (const key in object) {
if (object.hasOwnProperty(key)) {
const value = object[key];
if (typeof value === 'object') {
objectWalker(value, prefix + key + '.');
} else {
eventAttributes[prefix + key] = String(value);
}
}
}
};
return eventAttributes;
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc