import { BrowserPlugin } from "@snowplow/browser-tracker-core"; import { CommonEventProperties, DynamicContext, SelfDescribingJson } from "@snowplow/tracker-core"; /** Type of media player event */ declare enum MediaEventType { // Controlling the playback /** Media player event fired when the media tracking is successfully attached to the player and can track events. */ Ready = "ready", /** Media player event sent when the player changes state to playing from previously being paused. */ Play = "play", /** Media player event sent when the user pauses the playback. */ Pause = "pause", /** Media player event sent when playback stops when end of the media is reached or because no further data is available. */ End = "end", /** Media player event sent when a seek operation begins. */ SeekStart = "seek_start", /** Media player event sent when a seek operation completes. */ SeekEnd = "seek_end", // Changes in playback settings /** Media player event sent when the playback rate has changed. */ PlaybackRateChange = "playback_rate_change", /** Media player event sent when the volume has changed. */ VolumeChange = "volume_change", /** Media player event fired immediately after the browser switches into or out of full-screen mode. */ FullscreenChange = "fullscreen_change", /** Media player event fired immediately after the browser switches into or out of picture-in-picture mode. */ PictureInPictureChange = "picture_in_picture_change", // Tracking playback progress /** Media player event fired periodically during main content playback, regardless of other API events that have been sent. */ Ping = "ping", /** Media player event fired when a percentage boundary set inĀ options.boundariesĀ is reached */ PercentProgress = "percent_progress", // Ad events /** Media player event that signals the start of an ad break. */ AdBreakStart = "ad_break_start", /** Media player event that signals the end of an ad break. */ AdBreakEnd = "ad_break_end", /** Media player event that signals the start of an ad. */ AdStart = "ad_start", /** Media player event fired when a quartile of ad is reached after continuous ad playback at normal speed. */ AdFirstQuartile = "ad_first_quartile", /** Media player event fired when a midpoint of ad is reached after continuous ad playback at normal speed. */ AdMidpoint = "ad_midpoint", /** Media player event fired when a quartile of ad is reached after continuous ad playback at normal speed. */ AdThirdQuartile = "ad_third_quartile", /** Media player event that signals the ad creative was played to the end at normal speed. */ AdComplete = "ad_complete", /** Media player event fired when the user activated a skip control to skip the ad creative. */ AdSkip = "ad_skip", /** Media player event fired when the user clicked on the ad. */ AdClick = "ad_click", /** Media player event fired when the user clicked the pause control and stopped the ad creative. */ AdPause = "ad_pause", /** Media player event fired when the user resumed playing the ad creative after it had been stopped or paused. */ AdResume = "ad_resume", // Data quality events /** Media player event fired when the player goes into the buffering state and begins to buffer content. */ BufferStart = "buffer_start", /** Media player event fired when the the player finishes buffering content and resumes playback. */ BufferEnd = "buffer_end", /** Media player event tracked when the video playback quality changes automatically. */ QualityChange = "quality_change", /** Media player event tracked when the resource could not be loaded due to an error. */ Error = "error" } /** * Configuration for filtering out repeated events of the same type tracked after each other. * By default, the seek start, seek end and volume change events are filtered out. */ type FilterOutRepeatedEvents = { /** * Whether to filter out seek start and end events tracked after each other. */ seekEvents?: boolean; /** * Whether to filter out volume change events tracked after each other. */ volumeChangeEvents?: boolean; /** * Timeout in milliseconds after which to send the events that are queued for filtering. * Defaults to 5000 ms. */ flushTimeoutMs?: number; } | boolean; type MediaTrackingConfiguration = { /** Unique ID of the media tracking. The same ID will be used for media player session if enabled. */ id: string; /** Attributes for the media player context entity */ player?: MediaPlayerUpdate; /** Attributes for the media player session context entity or false to disable it. Enabled by default. */ session?: { /** Local date-time timestamp of when the session started. Automatically set to current time if not given. */ startedAt?: Date; } | false; /** Configuration for sending ping events. Enabled by default. */ pings?: { /** Interval in seconds for sending ping events. Defaults to 30s. */ pingInterval?: number; /** Maximum number of consecutive ping events to send when playback is paused. Defaults to 1. */ maxPausedPings?: number; } | boolean; /** Update page activity in order to keep sending page ping events while playing. Enabled by default. */ updatePageActivityWhilePlaying?: boolean; /** Percentage boundaries when to send percent progress events. Disabled by default. */ boundaries?: number[]; /** * List of event types to allow tracking. * If not specified, all tracked events will be allowed and tracked. * Otherwise, tracked event types not present in the list will be discarded. */ captureEvents?: MediaEventType[]; /** * Whether to filter out repeated events of the same type tracked after each other. * Useful to filter out repeated seek and volume change events tracked when the user holds down the seek or volume control. * Only applies to seek and volume change events. * Defaults to true. */ filterOutRepeatedEvents?: FilterOutRepeatedEvents; }; type MediaTrackPlaybackRateChangeArguments = { /** Playback rate before the change (1 is normal) */ previousRate?: number; /** Playback rate after the change (1 is normal) */ newRate: number; }; type MediaTrackVolumeChangeArguments = { /** Volume percentage before the change. */ previousVolume?: number; /** Volume percentage after the change. */ newVolume: number; }; type MediaTrackFullscreenChangeArguments = { /** Whether the video element is fullscreen after the change. */ fullscreen: boolean; }; type MediaTrackPictureInPictureChangeArguments = { /** Whether the video element is showing picture-in-picture after the change. */ pictureInPicture: boolean; }; type MediaTrackAdPercentProgressArguments = { /** The percent of the way through the ad. */ percentProgress?: number; }; type MediaTrackQualityChangeArguments = { /** Quality level before the change (e.g., 1080p). */ previousQuality?: string; /** Quality level after the change (e.g., 1080p). */ newQuality?: string; /** The current bitrate in bits per second. */ bitrate?: number; /** The current number of frames per second. */ framesPerSecond?: number; /** Whether the change was automatic or triggered by the user. */ automatic?: boolean; }; type MediaTrackErrorArguments = { /** Error-identifying code for the playback issue. E.g. E522 */ errorCode?: string; /** Name for the type of error that occurred in the playback. E.g. forbidden */ errorName?: string; /** Longer description for the error occurred in the playback. */ errorDescription?: string; }; type MediaTrackArguments = { /** ID of the media tracking */ id: string; /** Attributes for the media player context entity */ player?: MediaPlayerUpdate; }; type MediaTrackAdArguments = { /** Attributes for the media player ad context entity */ ad?: MediaAdUpdate; }; type MediaTrackAdBreakArguments = { /** Attributes for the media player ad break context entity */ adBreak?: MediaPlayerAdBreakUpdate; }; type MediaTrackSelfDescribingEventArguments = { /** Self-describing event */ event: SelfDescribingJson; }; /** Type of media content. */ declare enum MediaType { /** Audio content. */ Audio = "audio", /** Video content. */ Video = "video" } /** Partial type/schema for a context entity for media player events with information about the current state of the media player */ interface MediaPlayerUpdate { /** The current playback time position within the media in seconds */ currentTime?: number; /** A double-precision floating-point value indicating the duration of the media in seconds */ duration?: number | null; /** If playback of the media has ended */ ended?: boolean; /** Whether the video element is fullscreen */ fullscreen?: boolean; /** Whether the media is a live stream */ livestream?: boolean; /** Human readable name given to tracked media content. */ label?: string; /** If the video should restart after ending */ loop?: boolean; /** Type of media content. */ mediaType?: MediaType; /** If the media element is muted */ muted?: boolean; /** If the media element is paused */ paused?: boolean; /** Whether the video element is showing picture-in-picture */ pictureInPicture?: boolean; /** Type of the media player (e.g., com.youtube-youtube, com.vimeo-vimeo, org.whatwg-media_element) */ playerType?: string; /** Playback rate (1 is normal) */ playbackRate?: number; /** Quality level of the playback (e.g., 1080p). */ quality?: string; /** Volume level */ volume?: number; } /** Partial type/schema for a context entity with information about the currently played ad */ interface MediaAdUpdate { /** Friendly name of the ad */ name?: string; /** Unique identifier for the ad */ adId: string; /** The ID of the ad creative */ creativeId?: string; /** The position of the ad within the ad break, starting with 1 */ podPosition?: number; /** Length of the video ad in seconds */ duration?: number; /** Indicating whether skip controls are made available to the end user */ skippable?: boolean; } /** Type of ads within the break */ declare enum MediaAdBreakType { /** Take full control of the video for a period of time. */ Linear = "linear", /** Run concurrently to the video. */ NonLinear = "nonlinear", /** Accompany the video but placed outside the player. */ Companion = "companion" } /** Partial type/schema for a context entity, shared with all media_player_ad events belonging to the ad break */ interface MediaPlayerAdBreakUpdate { /** Ad break name (e.g., pre-roll, mid-roll, and post-roll) */ name?: string; /** An identifier for the ad break */ breakId: string; /** Playback time in seconds at the start of the ad break. */ startTime?: number; /** * Type of ads within the break: * - linear (take full control of the video for a period of time), * - nonlinear (run concurrently to the video), * - companion (accompany the video but placed outside the player) */ breakType?: MediaAdBreakType; /** The number of ads to be played within the ad break */ podSize?: number; } interface CommonMediaEventProperties extends Omit { /** Add context entities to an event by setting an Array of Self Describing JSON */ context?: DynamicContext; } /** * Adds media tracking */ declare function SnowplowMediaPlugin(): BrowserPlugin; /** * Starts media tracking for a single media content tracked in a media player. * The tracking instance is uniquely identified by a given ID. * All subsequent media track calls will be processed within this media tracking if given the same ID. * * @param config Configuration for setting up media tracking * @param trackers The tracker identifiers which ping events will be sent to */ declare function startMediaTracking(config: MediaTrackingConfiguration & CommonMediaEventProperties, trackers?: Array): void; /** * Ends media tracking with the given ID if previously started. * Clears local state for the media tracking and sends any events waiting to be sent. * * @param configuration Configuration with the media tracking ID */ declare function endMediaTracking(configuration: { id: string; }): void; /** * Updates stored attributes of the media tracking such as the current playback. * Use this function to continually update the player attributes so that they * can be sent in the background ping events. * * @param args The attributes for the media entities * @param trackers The tracker identifiers which any resulting event will be sent to */ declare function updateMediaTracking(args: MediaTrackArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ready event that is fired when the media tracking is successfully * attached to the player and can track events. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaReady(args: MediaTrackArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player play event sent when the player changes state to playing from * previously being paused. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaPlay(args: MediaTrackArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player pause event sent when the user pauses the playback. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaPause(args: MediaTrackArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player end event sent when playback stops when end of the media * is reached or because no further data is available. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaEnd(args: MediaTrackArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player seek start event sent when a seek operation begins. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaSeekStart(args: MediaTrackArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player seek end event sent when a seek operation completes. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaSeekEnd(args: MediaTrackArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player playback rate change event sent when the playback rate has changed. * * If not passed here, the previous rate is taken from the last setting in media player. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaPlaybackRateChange(args: MediaTrackArguments & MediaTrackPlaybackRateChangeArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player volume change event sent when the volume has changed. * * If not passed here, the previous volume is taken from the last setting in media player. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaVolumeChange(args: MediaTrackArguments & MediaTrackVolumeChangeArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player fullscreen change event fired immediately after * the browser switches into or out of full-screen mode. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaFullscreenChange(args: MediaTrackArguments & MediaTrackFullscreenChangeArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player picture-in-picture change event fired immediately * after the browser switches into or out of picture-in-picture mode. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaPictureInPictureChange(args: MediaTrackArguments & MediaTrackPictureInPictureChangeArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad break start event that signals the start of an ad break. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdBreakStart(args: MediaTrackArguments & MediaTrackAdBreakArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad break end event that signals the end of an ad break. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdBreakEnd(args: MediaTrackArguments & MediaTrackAdBreakArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad start event that signals the start of an ad. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdStart(args: MediaTrackArguments & MediaTrackAdBreakArguments & MediaTrackAdArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad skip event fired when the user activated * a skip control to skip the ad creative. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdSkip(args: MediaTrackArguments & MediaTrackAdPercentProgressArguments & MediaTrackAdBreakArguments & MediaTrackAdArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad first quartile played event fired when * a quartile of ad is reached after continuous ad playback at normal speed. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdFirstQuartile(args: MediaTrackArguments & MediaTrackAdBreakArguments & MediaTrackAdArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad midpoint played event fired when a midpoint of ad is * reached after continuous ad playback at normal speed. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdMidpoint(args: MediaTrackArguments & MediaTrackAdBreakArguments & MediaTrackAdArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks media player ad third quartile played event fired when a quartile * of ad is reached after continuous ad playback at normal speed. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdThirdQuartile(args: MediaTrackArguments & MediaTrackAdBreakArguments & MediaTrackAdArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad complete event that signals the ad creative * was played to the end at normal speed. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdComplete(args: MediaTrackArguments & MediaTrackAdBreakArguments & MediaTrackAdArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad click event fired when the user clicked on the ad. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdClick(args: MediaTrackArguments & MediaTrackAdPercentProgressArguments & MediaTrackAdBreakArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad pause event fired when the user clicked the pause * control and stopped the ad creative. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdPause(args: MediaTrackArguments & MediaTrackAdPercentProgressArguments & MediaTrackAdBreakArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player ad resume event fired when the user resumed playing the * ad creative after it had been stopped or paused. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaAdResume(args: MediaTrackArguments & MediaTrackAdPercentProgressArguments & MediaTrackAdBreakArguments & MediaTrackAdArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player buffering start event fired when the player goes * into the buffering state and begins to buffer content. * * End of buffering can be tracked using `trackMediaBufferEnd` or `trackMediaPlay` or * by updating the `currentTime` property. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaBufferStart(args: MediaTrackArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player buffering end event fired when the the player * finishes buffering content and resumes playback. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaBufferEnd(args: MediaTrackArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player quality change event tracked when the video * playback quality changes automatically. * * If not passed here, the previous quality is taken from the last setting in media player. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaQualityChange(args: MediaTrackArguments & MediaTrackQualityChangeArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a media player error event tracked when the resource could not be loaded due to an error. * * @param args The attributes for the media player event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaError(args: MediaTrackArguments & MediaTrackErrorArguments & CommonMediaEventProperties, trackers?: Array): void; /** * Tracks a custom self-describing event within the context of the media tracking. * It will attach the context entities managed by the media tracking to the event (e.g. player, session, ad). * * @param args The attributes for the event and entities * @param trackers The tracker identifiers which the event will be sent to */ declare function trackMediaSelfDescribingEvent(args: MediaTrackSelfDescribingEventArguments & MediaTrackArguments & MediaTrackAdArguments & MediaTrackAdBreakArguments & CommonMediaEventProperties, trackers?: Array): void; export { MediaAdBreakType as MediaPlayerAdBreakType, MediaEventType, SnowplowMediaPlugin, startMediaTracking, endMediaTracking, updateMediaTracking, trackMediaReady, trackMediaPlay, trackMediaPause, trackMediaEnd, trackMediaSeekStart, trackMediaSeekEnd, trackMediaPlaybackRateChange, trackMediaVolumeChange, trackMediaFullscreenChange, trackMediaPictureInPictureChange, trackMediaAdBreakStart, trackMediaAdBreakEnd, trackMediaAdStart, trackMediaAdSkip, trackMediaAdFirstQuartile, trackMediaAdMidpoint, trackMediaAdThirdQuartile, trackMediaAdComplete, trackMediaAdClick, trackMediaAdPause, trackMediaAdResume, trackMediaBufferStart, trackMediaBufferEnd, trackMediaQualityChange, trackMediaError, trackMediaSelfDescribingEvent };