import { startMediaTracking, MediaEventType, trackMediaSelfDescribingEvent } from "@snowplow/browser-plugin-media"; import { BrowserPlugin } from "@snowplow/browser-tracker-core"; declare const LEGACY_EVENTS: { readonly play: MediaEventType.Play; readonly pause: MediaEventType.Pause; readonly seek: MediaEventType.SeekEnd; readonly volumechange: MediaEventType.VolumeChange; readonly ended: MediaEventType.End; readonly error: MediaEventType.Error; readonly percentprogress: MediaEventType.PercentProgress; readonly playbackratechange: MediaEventType.PlaybackRateChange; readonly playbackqualitychange: MediaEventType.QualityChange; }; type EventGroup = "AllEvents" | "DefaultEvents"; type CapturableEvents = (MediaEventType | EventGroup | keyof typeof LEGACY_EVENTS)[]; type MediaTrackingConfiguration = Parameters[0]; type VideoLocation = YT.Player | HTMLIFrameElement | string; /** * YouTubeTrackingPlugin configuration values. * * Similar to the base Media Tracking plugin configuration, but with handling for a custom `label` and specifying the player to track. */ type YouTubeMediaTrackingConfiguration = Omit & { /** * The DOM ID for the element that hosts the YouTube video player to bind to. * You can also pass the DOM element or `YT.Player` instance directly. */ video: VideoLocation; /** * List of events or event groups to include tracking for if possible. * Not all MediaEventType values are supported by the Player API and will be ignored. */ captureEvents?: `${CapturableEvents[number]}`[]; /** * This plugin generates the `player` data automatically; use this to specify a `label` for inclusion in that entity. */ label?: string; }; /** * YouTubeTrackingPlugin configuration values. * * v3 API compatible definition to ease migration. */ type LegacyYouTubeMediaTrackingConfiguration = { /** * The DOM ID for the element that hosts the YouTube video player to bind to. * You can also pass the DOM element or `YT.Player` instance directly. */ id: VideoLocation; /** * Media Tracking options configuration; most of these options will be passed to the base Media Tracking plugin. */ options: Omit & { /** * This plugin generates the `player` data automatically; use this to specify a `label` for inclusion in that entity. */ label?: string; /** * List of events or event groups to include tracking for if possible. * Not all MediaEventType values are supported by the Player API and will be ignored. */ captureEvents?: `${CapturableEvents[number]}`[]; }; } & Pick; /** * Create a YouTubeTrackingPlugin instance. * @returns The created YouTubeTrackingPlugin instance */ declare function YouTubeTrackingPlugin(): BrowserPlugin; /** * Start media tracking for the given player and configuration. * @param args Tracking configuration * @returns The media session ID for the player * @since 4.0.0 */ declare function startYouTubeTracking(args: YouTubeMediaTrackingConfiguration): string | void; /** * Disable tracking for a previously enabled player's media session. * @param id The media session ID to disable tracking for * @since 4.0.0 */ declare function endYouTubeTracking(id: string): void; /** * Start media tracking for the given player and configuration. * This is a legacy v3 API that wraps the newer `startYouTubeTracking` API. * @param args Tracking configuration * @returns The media session ID for the player * @deprecated since v4.0.0; use {@link startYouTubeTracking} */ declare function enableYouTubeTracking(args: LegacyYouTubeMediaTrackingConfiguration): string | void; /** * Disable tracking for a previously enabled player's media session. * This is a legacy v3 API that wraps the newer `endYouTubeTracking` API. * @param id The media session ID to disable tracking for, or the oldest known session ID if not provided * @since 4.0.0 * @deprecated since v4.0.0; use {@link endYouTubeTracking} */ declare function disableYouTubeTracking(id?: string): void; /** * Track a custom Self Describing Event with the Media plugin's entities included, like the events generated by the plugin directly. * @param event The tracking options, including the custom Self Describing Event to track and optional media configuration such as `ad` data. */ declare function trackYouTubeSelfDescribingEvent(event: Omit[0], "player">): void; export type { YouTubeMediaTrackingConfiguration }; export { YouTubeTrackingPlugin, startYouTubeTracking, endYouTubeTracking, enableYouTubeTracking, disableYouTubeTracking, trackYouTubeSelfDescribingEvent };