PillarboxMonitoring

The PillarboxMonitoring class retrieves data about media playback.

This data can be used to :

  • help investigate playback problems
  • measure the quality of our service

The sending of this data tries to respect as much as possible the specification described in the link below.

However, some platforms may have certain limitations. In this case, only the data available will be sent.

Constructor

new PillarboxMonitoring(player, optionsopt)

Creates an instance of PillarboxMonitoring.

Parameters:
NameTypeAttributesDefaultDescription
playerPlayer

The player instance to be monitored

optionsPillarboxMonitoringOptions<optional>
{}

Configuration options for the monitoring

Properties
NameTypeAttributesDefaultDescription
playerNamestring<optional>
'none'

The name of the player

playerVersionstring<optional>
'none'

The version of the player

platformstring<optional>
'Web'

The platform on which the player is running

schemaVersionnumber<optional>
1

The version of the schema used for monitoring

heartbeatIntervalnumber<optional>
30000

The interval in milliseconds for sending heartbeat signals

beaconUrlstring<optional>
'https://monitoring.pillarbox.ch/api/events'

The URL for the monitoring beacon

Members

beaconUrl :string

Type:
  • string

currentSessionId :string

Type:
  • string

heartbeatInterval :Number

Type:
  • Number

lastPlaybackDuration :Number

Type:
  • Number

lastPlaybackStartTimestamp :Number

Type:
  • Number

lastStallCount :Number

Type:
  • Number

lastStallDuration :Number

Type:
  • Number

loadStartTimestamp :Number

Type:
  • Number

mediaAssetUrl :string

Type:
  • string

mediaId :string

Type:
  • string

mediaMetadataUrl :string

Type:
  • string

mediaOrigin :string

Type:
  • string

metadataRequestTime :Number

Type:
  • Number

platform :string

Type:
  • string

player :module:video.js/dist/types/player~default

Type:
  • module:video.js/dist/types/player~default

playerName :string

Type:
  • string

playerVersion :string

Type:
  • string

schemaVersion :string

Type:
  • string

tokenRequestTime :Number

Type:
  • Number

Methods

addListeners()

Adds event listeners to the player and the window.

bandwidth() → {number|undefined}

The current bandwidth of the last segment download.

Returns:

The current bandwidth in bits per second, undefined otherwise.

Type: 
number | undefined

bindCallBacks()

Binds the callback functions to the current instance.

bufferDuration() → {Number}

Get the buffer duration in milliseconds.

Returns:

The buffer duration

Type: 
Number

currentSourceMediaData() → {Object}

The media data of the current source.

Returns:

The media data of the current source, or an empty object if no media data is available.

Type: 
Object

error()

Handles player errors by sending an ERROR event, then resets the session.

getDrmRequestDuration() → {number|undefined}

Get the DRM license request duration from performance API.

Returns:

The request duration

Type: 
number | undefined

getTokenRequestDuration() → {number|undefined}

Get the Akamai token request duration from performance API.

Returns:

The request duration

Type: 
number | undefined

heartbeat()

Send an 'HEARTBEAT' event with the date of the current playback state at regular intervals.

isTrackerDisabled() → {Boolean}

Check if the tracker is disabled.

Returns:

true if disabled false otherwise.

Type: 
Boolean

loadStart()

Handles loadstart event and captures the current timestamp. Will be used to calculate the media loading time.

loadedData()

Handles the session start by sending a START event immediately followed by a HEARTBEAT when the loadeddata event is triggered.

playbackDuration() → {number}

The total playback duration for the current session.

Returns:

The total playback duration in milliseconds.

Type: 
number

playbackStart()

Assign the timestamp each time the playback starts.

playbackStop()

Calculates and accumulates the duration of the playback session each time the playback stops for the current media.

removeListeners()

Removes all event listeners from the player and the window.

removeTokenFromAssetUrl(assetUrl) → {string|undefined}

Remove the token from the asset URL.

Parameters:
NameTypeDescription
assetUrlstring

The URL of the asset

Returns:

The URL without the token, or undefined if the input URL is invalid

Type: 
string | undefined

reset(event)

Resets the playback session and clears relevant properties.

Parameters:
NameTypeDescription
eventEvent

The event that triggered the reset. If the event type is not 'ended' or 'playerreset', listeners will be removed.

sendEvent(eventName, dataopt)

Sends an event to the server using the Beacon API.

Parameters:
NameTypeAttributesDefaultDescription
eventNamestring

Either START, STOP, ERROR, HEARTBEAT

dataObject<optional>
{}

The payload object to be sent. Defaults to an empty object if not provided

sessionStart()

Starts a new session by first stopping the previous session, then resetting the session start timestamp and media ID to their new values.

sessionStop(eventopt)

Stops the current session by sending a STOP event and resetting the session.

Parameters:
NameTypeAttributesDescription
eventEvent<optional>

The event that triggered the stop. This is passed to the reset function.

stalled()

Handles the stalled state of the player. Sets the stalled state and listens for the event that indicates the player is no longer stalled.

(static) deviceId() → {string|undefined}

Retrieve or generate a unique device ID and stores it in localStorage.

Returns:

The device ID if localStorage is available, otherwise undefined

Type: 
string | undefined

(static) errorKeyCode(code) → {string}

Returns a string representing the error key combined with its error code.

If the error code doesn't exist the error key undefined.

Parameters:
NameTypeDescription
codenumber

The error code

Returns:

The error key combined with its error code

Type: 
string

(static) randomUUID() → {string}

Generate a cryptographically secure random UUID.

Returns:
Type: 
string

(static) secondsToMilliseconds(seconds) → {number}

converts seconds into milliseconds.

Parameters:
NameTypeDescription
secondsnumber
Returns:

milliseconds as an integer value

Type: 
number

(static) sessionId() → {string}

Generates a new session ID.

Returns:

random UUID

Type: 
string

(static) timestamp() → {number}

The timestamp in milliseconds.

Returns:

milliseconds as an integer value

Type: 
number

(static) userAgent() → {string}

The browser's user agent.

Returns:
Type: 
string