import Player from "@vimeo/player"; import { BrowserPlugin } from "@snowplow/browser-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 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; } /** Vimeo-specific events not present in {@link MediaEventType} * * These are the values a user would place in `captureEvents`, to match the * style of the existing events from the Media plugin */ declare enum VimeoEventType { CuePoint = "cue_point", ChapterChange = "chapter_change", TextTrackChange = "text_track_change", InteractiveHotSpotClicked = "interactive_hot_spot_clicked", InteractiveOverlayPanelClicked = "interactive_overlay_panel_clicked" } // Events from the Media plugin that are automatically tracked with this plugin type AvailableMediaEventType = MediaEventType.Ready | MediaEventType.Play | MediaEventType.Pause | MediaEventType.End | MediaEventType.SeekStart | MediaEventType.SeekEnd | MediaEventType.PlaybackRateChange | MediaEventType.VolumeChange | MediaEventType.FullscreenChange | MediaEventType.PictureInPictureChange | MediaEventType.Ping | MediaEventType.PercentProgress | MediaEventType.BufferStart | MediaEventType.BufferEnd | MediaEventType.QualityChange | MediaEventType.Error; // Events from the Media plugin that are automatically tracked with this plugin declare const AvailableMediaEventType: { Ready: VimeoEvent; Play: VimeoEvent; Pause: VimeoEvent; End: VimeoEvent; SeekStart: VimeoEvent; SeekEnd: VimeoEvent; PlaybackRateChange: VimeoEvent; VolumeChange: VimeoEvent; FullscreenChange: VimeoEvent; PictureInPictureChange: VimeoEvent; Ping: VimeoEvent; PercentProgress: VimeoEvent; BufferStart: VimeoEvent; BufferEnd: VimeoEvent; QualityChange: VimeoEvent; Error: VimeoEvent; }; /** Events accepted by `VimeoTrackingConfiguration.captureEvents` */ type VimeoEvent = AvailableMediaEventType | VimeoEventType; declare const VimeoEvent: { CuePoint: VimeoEventType.CuePoint; ChapterChange: VimeoEventType.ChapterChange; TextTrackChange: VimeoEventType.TextTrackChange; InteractiveHotSpotClicked: VimeoEventType.InteractiveHotSpotClicked; InteractiveOverlayPanelClicked: VimeoEventType.InteractiveOverlayPanelClicked; Ready: VimeoEvent; Play: VimeoEvent; Pause: VimeoEvent; End: VimeoEvent; SeekStart: VimeoEvent; SeekEnd: VimeoEvent; PlaybackRateChange: VimeoEvent; VolumeChange: VimeoEvent; FullscreenChange: VimeoEvent; PictureInPictureChange: VimeoEvent; Ping: VimeoEvent; PercentProgress: VimeoEvent; BufferStart: VimeoEvent; BufferEnd: VimeoEvent; QualityChange: VimeoEvent; Error: VimeoEvent; }; /** The configuration object for the Vimeo tracking plugin */ interface VimeoTrackingConfiguration extends Omit { video: HTMLIFrameElement | Player; captureEvents?: VimeoEvent[]; } declare function VimeoTrackingPlugin(): BrowserPlugin; /** Start tracking a Vimeo Iframe element or existing Vimeo {@link Player} */ declare function startVimeoTracking(args: VimeoTrackingConfiguration): void; /** * Ends media tracking with the given ID if previously started. Clears local state for the media tracking. * Clears all listeners set by the plugin on the Vimeo player. */ declare function endVimeoTracking(id: string): void; export { VimeoEvent, VimeoTrackingConfiguration, startVimeoTracking, endVimeoTracking, VimeoTrackingPlugin }; export { trackMediaAdBreakEnd, trackMediaAdBreakStart, trackMediaAdClick, trackMediaAdComplete, trackMediaAdFirstQuartile, trackMediaAdMidpoint, trackMediaAdPause, trackMediaAdResume, trackMediaAdSkip, trackMediaAdStart, trackMediaAdThirdQuartile, trackMediaSelfDescribingEvent } from '@snowplow/browser-plugin-media';