@vkontakte/videoplayer-statistics 1.0.113-dev.9dd0ca0bc.0 → 1.0.113-dev.fc8d8316c.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- import type { IOneStatPlayerAdapter } from "../playerAdapter";
1
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
2
2
  import type { IObservable, IRange, Milliseconds, Seconds } from "@vkontakte/videoplayer-shared";
3
3
  export type IParams = {
4
4
  forceInterval: Milliseconds;
5
5
  watchCoverageTimeoutFix: boolean;
6
6
  watchCoverageExactTime: boolean;
7
7
  };
8
- export declare const watchCoverage: (player: IOneStatPlayerAdapter, params: IParams) => IObservable<IRange<Seconds>>;
8
+ export declare const watchCoverage: (player: IPlayer, params: IParams) => IObservable<IRange<Seconds>>;
@@ -1,5 +1,9 @@
1
1
  import type { ILogCustomData } from "./types";
2
- export type Operation = "action_play" | "action_play_interactive" | "first_bytes" | "player_ready" | "first_frame" | "seek" | "watch_coverage_record" | "watch_coverage_live" | "empty_buffer" | "action_stop" | "close_at_empty_buffer" | "content_error" | "player_interface_click" | "next_movie" | "track_switch" | "failover" | "quality" | "play_toggle" | "pause" | "adv" | "playing";
2
+ export type Operation = CommonOperation | AdvOperation;
3
+ export declare const COMMON_OPERATIONS: readonly ["action_play", "action_play_interactive", "first_bytes", "player_ready", "first_frame", "seek", "watch_coverage_record", "watch_coverage_live", "empty_buffer", "action_stop", "close_at_empty_buffer", "content_error", "player_interface_click", "next_movie", "track_switch", "failover", "quality", "play_toggle", "pause", "playing"];
4
+ export type CommonOperation = (typeof COMMON_OPERATIONS)[number];
5
+ export declare const ADV_OPERATIONS: readonly ["adv"];
6
+ export type AdvOperation = (typeof ADV_OPERATIONS)[number];
3
7
  export declare enum ApiEnv {
4
8
  PROD = "prod",
5
9
  VK_ALIAS = "vk_alias",
@@ -54,7 +58,7 @@ export declare enum Network {
54
58
  GOOD = "good",
55
59
  POOR = "poor"
56
60
  }
57
- export declare enum Mode {
61
+ export declare enum SurfaceMode {
58
62
  PIP = "pip",
59
63
  FULLSCREEN = "fullscreen",
60
64
  EXTERNAL = "external",
@@ -64,6 +68,15 @@ export declare enum Mode {
64
68
  INVISIBLE = "invisible",
65
69
  MINIMAL = "minimal"
66
70
  }
71
+ /**
72
+ * Режим отправки статистики
73
+ * `COMMON` - обычная отправка всех событий
74
+ * `ADV` - играется реклама, отправляются только рекламные события
75
+ */
76
+ export declare enum SessionMode {
77
+ ADV = "adv",
78
+ COMMON = "common"
79
+ }
67
80
  export declare enum SeekAction {
68
81
  SLIDER = "slider",
69
82
  RICH = "rich",
@@ -85,4 +98,4 @@ export type InterfaceClick = InteractiveInterfaceClick;
85
98
  export declare const OperationAliases: Partial<Record<Operation, string>>;
86
99
  export declare const CustomParamAliases: Partial<Record<keyof ILogCustomData, string>>;
87
100
  export declare const QualityAliases: Record<Quality, string>;
88
- export declare const ModeAliases: Record<Mode, string>;
101
+ export declare const SurfaceModeAliases: Record<SurfaceMode, string>;
@@ -1,16 +1,13 @@
1
1
  import type { IUIEvents as IUIEventsOneStat } from "../oneStat";
2
2
  import type { IUIEvents as IUIEventsThinOneStat } from "../thinOneStat";
3
- import type { IPlayerInfo } from "@vkontakte/videoplayer-core";
3
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
4
4
  import { Surface } from "@vkontakte/videoplayer-core";
5
5
  import type { IListener, IObservable } from "@vkontakte/videoplayer-shared";
6
- export interface IModeControllerPlayerAdapter {
7
- info: Pick<IPlayerInfo, "surface$">;
8
- }
9
- export interface ModeControllerDependencies {
6
+ export interface SurfaceModeControllerDependencies {
10
7
  uiEvents: IUIEventsOneStat | IUIEventsThinOneStat;
11
8
  initExternalSubscribers: (surfaceObservable$: IObservable<Surface | undefined>) => void;
12
9
  subscribe: <T>(observable: IObservable<T> | undefined, logger: IListener<T>) => void;
13
- player?: IModeControllerPlayerAdapter;
10
+ player?: IPlayer;
14
11
  }
15
12
  /** конроллер для состояния mode плеера */
16
- export declare const useModeController: ({ uiEvents, initExternalSubscribers, subscribe, player }: ModeControllerDependencies) => void;
13
+ export declare const useSurfaceModeController: ({ uiEvents, initExternalSubscribers, subscribe, player }: SurfaceModeControllerDependencies) => void;
@@ -1,9 +1,9 @@
1
1
  import type { IError, IObservable, ISubject, ISubscription, IValueObservable, IValueSubject, Milliseconds } from "@vkontakte/videoplayer-shared";
2
2
  import { ErrorCategory } from "@vkontakte/videoplayer-shared";
3
- import type { IThinOneStatPlayerAdapter } from "./playerAdapter";
3
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
4
4
  import type { IOptionalConfig } from "./config";
5
- import type { Mode, Quality, Visibility, ConnectionType, ContentType } from "./values";
6
- import { ActionSeekType, AutoQuality } from "./values";
5
+ import type { SurfaceMode, Quality, Visibility, ConnectionType, ContentType } from "./values";
6
+ import { ActionSeekType, AutoQuality, SessionMode } from "./values";
7
7
  import type { IAdsEvents, IUIEvents } from "./events";
8
8
  export interface IThinOneStat {
9
9
  vsid$: IValueObservable<string | undefined>;
@@ -25,9 +25,21 @@ export interface IThinOneStat {
25
25
  */
26
26
  updateContext(context: Partial<IStatContext>): void;
27
27
  /**
28
+ * Устанавливает режим отправки статистики
29
+ */
30
+ setSessionMode(mode: SessionMode): void;
31
+ /**
32
+ * Ставит отправку событий на паузу. Они будут накапливаться до вызова `resume()`
33
+ */
34
+ pause(): void;
35
+ /**
36
+ * Снимает паузу отправки событий и отправляет все накопленные события
37
+ */
38
+ resume(): void;
39
+ /**
28
40
  * Привязываемся к событиям и разным изменениям состояний плеера
29
41
  */
30
- attachTo(player: IThinOneStatPlayerAdapter, adsEvents: IAdsEvents): ISubscription;
42
+ attachTo(player: IPlayer, adsEvents: IAdsEvents): ISubscription;
31
43
  attachToUi(uiEvents: IUIEvents): ISubscription;
32
44
  attachToAds(adsEvents: IAdsEvents): ISubscription;
33
45
  /**
@@ -123,7 +135,7 @@ export interface IPlaybackStartedPayload {
123
135
  muted?: boolean;
124
136
  sound_volume?: number;
125
137
  buffer_time?: Milliseconds;
126
- mode?: Mode;
138
+ mode?: SurfaceMode;
127
139
  visibility?: Visibility;
128
140
  subtitles_enabled?: boolean;
129
141
  auto_subtitles?: boolean;
@@ -210,7 +222,7 @@ export interface IViewPortChangedPayload {
210
222
  player_height?: number;
211
223
  }
212
224
  export interface IModeChangedPayload {
213
- mode?: Mode;
225
+ mode?: SurfaceMode;
214
226
  }
215
227
  export interface IVisibilityChangedPayload {
216
228
  visibility?: Visibility;
@@ -318,6 +330,7 @@ export declare class ThinOneStat implements IThinOneStat {
318
330
  private readonly onceEvents;
319
331
  private sentOnceEvents;
320
332
  private eventNumber;
333
+ private sessionMode;
321
334
  private isStarted?;
322
335
  private isSeeking?;
323
336
  private inBufferStarvation?;
@@ -349,9 +362,12 @@ export declare class ThinOneStat implements IThinOneStat {
349
362
  authorize(authToken?: string): void;
350
363
  reportError(payload: IReportErrorPayload): void;
351
364
  updateContext(newContext: Partial<IStatContext>): void;
352
- attachTo(player: IThinOneStatPlayerAdapter, adsEvents: IAdsEvents): ISubscription;
365
+ attachTo(player: IPlayer, adsEvents: IAdsEvents): ISubscription;
353
366
  attachToUi(events: IUIEvents): ISubscription;
354
367
  attachToAds(events: IAdsEvents): ISubscription;
368
+ setSessionMode(mode: SessionMode): void;
369
+ pause(): void;
370
+ resume(): void;
355
371
  getDeviceId(): string;
356
372
  resetViewSession(): void;
357
373
  destroy(): Promise<void>;
@@ -1,7 +1,6 @@
1
1
  export { ThinOneStat } from "./ThinOneStat";
2
2
  export type { IThinOneStat, IStatContext } from "./ThinOneStat";
3
- export type { IThinOneStatPlayerAdapter } from "./playerAdapter";
4
- export { ActionSeekType } from "./values";
3
+ export { ActionSeekType, SessionMode } from "./values";
5
4
  export type { ActionQualityType } from "./values";
6
5
  export type { IUIEvents } from "./events";
7
6
  export { VERSION } from "../env";
@@ -1,6 +1,5 @@
1
1
  import type { Milliseconds } from "@vkontakte/videoplayer-shared";
2
- import type { IObservable } from "@vkontakte/videoplayer-core";
3
- import type { IThinOneStatPlayerAdapter } from "../playerAdapter";
2
+ import type { IPlayer, IObservable } from "@vkontakte/videoplayer-core";
4
3
  type GetTotalViewTime = () => Milliseconds;
5
- export declare const calculateTotalViewTime: (player: IThinOneStatPlayerAdapter) => IObservable<GetTotalViewTime>;
4
+ export declare const calculateTotalViewTime: (player: IPlayer) => IObservable<GetTotalViewTime>;
6
5
  export {};
@@ -1,7 +1,7 @@
1
- import type { IThinOneStatPlayerAdapter } from "../playerAdapter";
1
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
2
2
  import type { IObservable } from "@vkontakte/videoplayer-shared";
3
3
  import type { IDownloadBytesPayload } from "../ThinOneStat";
4
4
  export type IParams = {
5
5
  maxTimeWindow: number;
6
6
  };
7
- export declare const downloadBytes: (player: IThinOneStatPlayerAdapter, { maxTimeWindow }: IParams) => IObservable<IDownloadBytesPayload>;
7
+ export declare const downloadBytes: (player: IPlayer, { maxTimeWindow }: IParams) => IObservable<IDownloadBytesPayload>;
@@ -0,0 +1,2 @@
1
+ import type { EventName, AdvEventName } from "../values";
2
+ export declare const isAdvEvent: (eventName: EventName) => eventName is AdvEventName;
@@ -1,11 +1,11 @@
1
1
  import type { ISources } from "@vkontakte/videoplayer-core";
2
2
  import { HttpConnectionType as CoreConnectionType, Surface, VideoFormat, VideoQuality } from "@vkontakte/videoplayer-core";
3
- import { ConnectionType as StatisticsConnectionType, ContentType, Mode, Quality, StreamingProfile, Visibility } from "../values";
3
+ import { ConnectionType as StatisticsConnectionType, ContentType, SurfaceMode, Quality, StreamingProfile, Visibility } from "../values";
4
4
  export declare const errorTrace: (data: unknown) => string | undefined;
5
5
  export declare const connectionType: (coreType?: CoreConnectionType) => StatisticsConnectionType | undefined;
6
6
  export declare const contentType: (format?: VideoFormat) => ContentType | undefined;
7
7
  export declare const quality: (coreQuality?: VideoQuality) => Quality | undefined;
8
8
  export declare const streamingProfile: (contentType?: ContentType) => StreamingProfile | undefined;
9
9
  export declare const formatUrl: (format?: VideoFormat, sources?: ISources, quality?: VideoQuality) => string | undefined;
10
- export declare const mode: (surface?: Surface, isPreviewPlayerView?: boolean) => Mode | undefined;
10
+ export declare const mode: (surface?: Surface, isPreviewPlayerView?: boolean) => SurfaceMode | undefined;
11
11
  export declare const visibility: (surface?: Surface) => Visibility | undefined;
@@ -1,7 +1,7 @@
1
- import type { IThinOneStatPlayerAdapter } from "../playerAdapter";
1
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
2
2
  import type { IObservable, Milliseconds } from "@vkontakte/videoplayer-shared";
3
3
  export type IParams = {
4
4
  interval: number;
5
5
  getTotalViewTime: () => Milliseconds;
6
6
  };
7
- export declare const telemetry: (player: IThinOneStatPlayerAdapter, params: IParams) => IObservable<void>;
7
+ export declare const telemetry: (player: IPlayer, params: IParams) => IObservable<void>;
@@ -1,8 +1,8 @@
1
- import type { IThinOneStatPlayerAdapter } from "../playerAdapter";
1
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
2
2
  import type { Seconds, IObservable, IRange } from "@vkontakte/videoplayer-shared";
3
3
  import type { IAdsEvents } from "../events";
4
4
  export type IParams = {
5
5
  heartbeatInterval?: Seconds;
6
6
  exactTime: boolean;
7
7
  };
8
- export declare const watchCoverage: (player: IThinOneStatPlayerAdapter, adsEvents: IAdsEvents, params: IParams) => IObservable<IRange<Seconds>>;
8
+ export declare const watchCoverage: (player: IPlayer, adsEvents: IAdsEvents, params: IParams) => IObservable<IRange<Seconds>>;
@@ -1,8 +1,8 @@
1
- import type { IThinOneStatPlayerAdapter } from "../playerAdapter";
1
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
2
2
  import type { IObservable, Milliseconds } from "@vkontakte/videoplayer-shared";
3
3
  import type { IWatchedNPayload } from "../ThinOneStat";
4
4
  export type IParams = {
5
5
  targetDuration: Milliseconds;
6
6
  getTotalViewTime: () => Milliseconds;
7
7
  };
8
- export declare const watchedN: (player: IThinOneStatPlayerAdapter, params: IParams) => IObservable<IWatchedNPayload>;
8
+ export declare const watchedN: (player: IPlayer, params: IParams) => IObservable<IWatchedNPayload>;
@@ -1,5 +1,9 @@
1
1
  import type { VideoQuality } from "@vkontakte/videoplayer-shared";
2
- export type EventName = "watch_coverage" | "watch_coverage_live" | "watched_n" | "start_session" | "preload_started" | "preload_ended" | "preload_error" | "playback_started" | "play" | "manifest_request" | "first_media_request" | "first_byte_manifest" | "first_byte_media" | "manifest_received" | "connection_established" | "first_video_frame_decoded" | "ready" | "playing" | "pause" | "resume" | "seeking" | "seeked" | "content_end_reached" | "stop" | "buffer_starvation" | "show_loader" | "quality_change_requested" | "quality_changed" | "cdn_host_changed" | "view_port_changed" | "mode_changed" | "visibility_changed" | "audio_track_switched" | "video_track_switched" | "subtitles_switched" | "sound_changed" | "failover" | "content_type_change" | "error" | "cannot_play" | "download_bytes" | "telemetry" | "adv_configuration" | "adv_request" | "adv_break_started" | "adv_break_ended" | "adv_error";
2
+ export type EventName = CommonEventName | AdvEventName;
3
+ export declare const COMMON_EVENT_NAMES: readonly ["watch_coverage", "watch_coverage_live", "watched_n", "start_session", "preload_started", "preload_ended", "preload_error", "playback_started", "play", "manifest_request", "first_media_request", "first_byte_manifest", "first_byte_media", "manifest_received", "connection_established", "first_video_frame_decoded", "ready", "playing", "pause", "resume", "seeking", "seeked", "content_end_reached", "stop", "buffer_starvation", "show_loader", "quality_change_requested", "quality_changed", "cdn_host_changed", "view_port_changed", "mode_changed", "visibility_changed", "audio_track_switched", "video_track_switched", "subtitles_switched", "sound_changed", "failover", "content_type_change", "error", "cannot_play", "download_bytes", "telemetry"];
4
+ export type CommonEventName = (typeof COMMON_EVENT_NAMES)[number];
5
+ export declare const ADV_EVENT_NAMES: readonly ["adv_configuration", "adv_request", "adv_break_started", "adv_break_ended", "adv_error"];
6
+ export type AdvEventName = (typeof ADV_EVENT_NAMES)[number];
3
7
  export declare const onceEvents: EventName[];
4
8
  export declare enum ApiEnv {
5
9
  PROD = "prod",
@@ -60,7 +64,7 @@ export declare enum StreamingProfile {
60
64
  LIVE = "live",
61
65
  VOD = "vod"
62
66
  }
63
- export declare enum Mode {
67
+ export declare enum SurfaceMode {
64
68
  INLINE = "inline",
65
69
  FULLSCREEN = "fullscreen",
66
70
  PIP_EXTERNAL = "pip_external",
@@ -74,6 +78,15 @@ export declare enum Visibility {
74
78
  FOREGROUND = "foreground",
75
79
  BACKGROUND = "background"
76
80
  }
81
+ /**
82
+ * Режим отправки статистики
83
+ * `COMMON` - обычная отправка всех событий
84
+ * `ADV` - играется реклама, отправляются только рекламные события
85
+ */
86
+ export declare enum SessionMode {
87
+ ADV = "adv",
88
+ COMMON = "common"
89
+ }
77
90
  export declare enum ActionSeekType {
78
91
  SLIDER = "slider",
79
92
  RICH = "rich",
@@ -1,7 +0,0 @@
1
- import type { IPlayer, IPlayerInfo, IPlayerEvents } from "@vkontakte/videoplayer-core";
2
- export interface IOneStatPlayerAdapter {
3
- info: Pick<IPlayerInfo, "atLiveEdge$" | "availableTextTracks$" | "currentAudioStream$" | "currentBuffer$" | "currentFormat$" | "currentPlaybackRate$" | "currentQuality$" | "currentTextTrack$" | "currentVideoStream$" | "hostname$" | "httpConnectionReused$" | "httpConnectionType$" | "isAutoQualityEnabled$" | "isBuffering$" | "isLive$" | "liveBufferTime$" | "liveLatency$" | "liveTime$" | "muted$" | "playbackState$" | "position$" | "stallStartTime$" | "surface$" | "throughputEstimation$" | "volume$">;
4
- events: Pick<IPlayerEvents, "willStart$" | "willResume$" | "willSeek$" | "willStop$" | "willDestruct$" | "started$" | "playing$" | "paused$" | "seeked$" | "looped$" | "firstBytes$" | "firstFrame$" | "managedError$" | "fatalError$">;
5
- getExactTime: IPlayer["getExactTime"];
6
- getExactLiveTime: IPlayer["getExactLiveTime"];
7
- }
@@ -1,8 +0,0 @@
1
- import type { IPlayer, IPlayerInfo, IPlayerEvents } from "@vkontakte/videoplayer-core";
2
- export interface IThinOneStatPlayerAdapter {
3
- info: Pick<IPlayerInfo, "atLiveEdge$" | "availableSources$" | "availableTextTracks$" | "currentAudioStream$" | "currentBuffer$" | "currentFormat$" | "currentPlaybackRate$" | "currentQuality$" | "currentTextTrack$" | "currentVideoStream$" | "hostname$" | "httpConnectionMetrics$" | "httpConnectionReused$" | "httpConnectionType$" | "httpDownloadMetrics$" | "isAutoQualityEnabled$" | "isLive$" | "isStalled$" | "liveTime$" | "muted$" | "playbackState$" | "position$" | "rttEstimation$" | "stallStartTime$" | "surface$" | "videoBitrate$" | "volume$">;
4
- events: Pick<IPlayerEvents, "willStart$" | "willReady$" | "willSeek$" | "willStop$" | "willDestruct$" | "started$" | "playing$" | "paused$" | "seeked$" | "ended$" | "looped$" | "firstBytes$" | "firstBytesManifest$" | "firstBytesRequested$" | "firstFrame$" | "manifestRequested$" | "manifestReceived$" | "managedError$" | "fatalError$" | "fetcherRecoverableError$">;
5
- experimental: Pick<IPlayer["experimental"], "element$">;
6
- getExactTime: IPlayer["getExactTime"];
7
- getExactLiveTime: IPlayer["getExactLiveTime"];
8
- }