@vkontakte/videoplayer-statistics 1.0.49 → 1.0.50

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,169 +1,10 @@
1
- import { Kbps, RecursivePartial, Milliseconds, IObservable, ISubscription, IError, IValueObservable, Seconds, ValueSubject } from '@vkontakte/videoplayer-shared';
2
- import { IPlayer } from '@vkontakte/videoplayer-core';
3
-
4
- 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' | // Пока не поддержана
5
- 'failover' | 'play_toggle' | 'pause' | 'adv';
6
- declare enum ApiEnv {
7
- PROD = "prod",
8
- VK_ALIAS = "vk_alias",
9
- VIDEOTEST = "videotest",
10
- TEST = "test",
11
- AUTO = "auto"
12
- }
13
- declare enum Quality {
14
- Q144P = "mobile",
15
- Q240P = "lowest",
16
- Q360P = "low",
17
- Q480P = "medium",
18
- Q720P = "high",
19
- Q1080P = "fullhd",
20
- Q1440P = "quadhd",
21
- Q2160P = "ultrahd",
22
- UNKNOWN = "unknown"
23
- }
24
- declare enum ContentType {
25
- MP4 = "mp4",
26
- DASH = "dash",
27
- DASH_SEP = "dash_sep",
28
- ONDEMAND_DASH = "ondemand_dash",
29
- HLS = "hls",
30
- ONDEMAND_HLS = "ondemand_hls",
31
- WEBM = "webm",
32
- AV1 = "av1",
33
- ONDEMAND_DASH_LIVE = "ondemand_dash_live",
34
- ONDEMAND_HLS_LIVE = "ondemand_hls_live",
35
- WEBRTC = "webrtc",
36
- UNKNOWN = "unknown",
37
- /** @deprecated сдк не поддерживает RTMP, не нужно его использовать */
38
- RTMP = "rtmp"
39
- }
40
- declare enum StatType {
41
- AUTO = "auto",
42
- MANUAL = ""
43
- }
44
- declare enum ConnectionType {
45
- HTTP1 = "http1",
46
- HTTP2 = "http2",
47
- HTTP3 = "http3"
48
- }
49
- declare enum Flag {
50
- YES = 1,
51
- NO = 0
52
- }
53
- declare enum Network {
54
- EXCELLENT = "excellent",
55
- GOOD = "good",
56
- POOR = "poor"
57
- }
58
- declare enum Mode {
59
- PIP = "pip",
60
- FULLSCREEN = "fullscreen",
61
- EXTERNAL = "external",
62
- PREFETCH = "prefetch",
63
- AIRPLAY = "airplay",
64
- CHROMECAST = "chromecast",
65
- INVISIBLE = "invisible"
66
- }
67
- declare enum SeekAction {
68
- SLIDER = "slider",
69
- DOUBLE_TAP = "double_tap",
70
- TIME_CODE = "time_code",
71
- EPISODE = "episode",
72
- REWIND = "rewind",
73
- LIVE = "live",
74
- UNKNOWN = "unknown"
75
- }
76
- declare enum InteractiveInterfaceClick {
77
- GRAPH_SHOW = "iGraphShow",
78
- GRAPH_HIDE = "iGraphHide",
79
- NEXT_AREA = "iNextChapterArea",
80
- NEXT_BUTTON = "iNextChapterBtn",
81
- WATCH_AGAIN = "iWatchAgainBtn"
82
- }
83
- type InterfaceClick = InteractiveInterfaceClick;
84
-
85
- interface ILogCustomData {
86
- /**
87
- * Сессия смотрения, уникальна для пользователя, контента, экземпляра плеера и одного просмотра
88
- * См https://confluence.vk.team/display/VID/Video%20Session%20ID
89
- */
90
- vsid: string;
91
- isid?: string;
92
- vid: number;
93
- ct?: ContentType;
94
- place?: string;
95
- quality?: Quality;
96
- cdn_host?: string;
97
- stat_type?: StatType;
98
- param?: any;
99
- vk_app_id?: string;
100
- track_code?: string;
101
- connection_type?: ConnectionType;
102
- connection_reused?: Flag;
103
- cached_data?: Flag;
104
- live?: Flag;
105
- muted?: Flag;
106
- mode?: Mode;
107
- subtitles?: string;
108
- failover?: Flag;
109
- download_speed?: Kbps;
110
- manual_quality?: Flag;
111
- ref_domain?: string;
112
- direct_url?: string;
113
- rate?: string;
114
- view_360?: 1;
115
- vk_playlist_id?: string;
116
- aid?: string;
117
- }
118
-
119
- interface IConfig {
120
- apiEnv: ApiEnv;
121
- requestRetryCount: number;
122
- firstFlushTime: Milliseconds;
123
- flushDebounceTime: Milliseconds;
124
- flushMaxWait: Milliseconds;
125
- storageExpiration: Milliseconds;
126
- watchCoverageInterval: Milliseconds;
127
- disabledOperations: Operation[];
128
- disabledCustomFields: (keyof ILogCustomData)[];
129
- shorten: boolean;
130
- maxLoops: number;
131
- embedUrlParams: string[];
132
- useBeacon: boolean;
133
- synchronizeTime: boolean;
134
- debugLog: boolean;
135
- backoff: {
136
- start: Milliseconds;
137
- factor: number;
138
- max: Milliseconds;
139
- random: number;
140
- };
141
- }
142
- type IOptionalConfig = RecursivePartial<IConfig>;
143
-
144
- interface IUIEvents {
145
- actionRewind$?: IObservable<void>;
146
- actionSeek$?: IObservable<SeekAction>;
147
- inPiP$?: IObservable<boolean>;
148
- inFullscreen$?: IObservable<boolean>;
149
- actionSetSubtitle$?: IObservable<string>;
150
- nextMovie$?: IObservable<number>;
151
- }
152
- interface IAdsEvents {
153
- slotRequested$?: IObservable<void>;
154
- started$?: IObservable<string>;
155
- paused$?: IObservable<void>;
156
- resumed$?: IObservable<void>;
157
- ended$?: IObservable<void>;
158
- skipped$?: IObservable<void>;
159
- clicked$?: IObservable<void>;
160
- }
161
- interface IInteractiveEvents {
162
- click$?: IObservable<InteractiveInterfaceClick>;
163
- nextMovie$?: IObservable<number>;
164
- }
165
-
166
- interface IOneStat {
1
+ import type { IOptionalConfig } from './config';
2
+ import type { IPlayer } from '@vkontakte/videoplayer-core';
3
+ import { IError, IObservable, ISubscription, IValueObservable, Kbps, Milliseconds, Seconds, ValueSubject } from '@vkontakte/videoplayer-shared';
4
+ import { ILogCustomData } from './types';
5
+ import { IAdsEvents, IInteractiveEvents, IUIEvents } from './uiEvents';
6
+ import { ApiEnv, ConnectionType, ContentType, Mode, Network, Quality, SeekAction } from './values';
7
+ export interface IOneStat {
167
8
  /**
168
9
  * Лучше авторизоваться сразу, чтобы избежать ситуации:
169
10
  * 1. Накапливаем запросы в очереди через debounce send
@@ -308,63 +149,63 @@ interface IOneStat {
308
149
  vsid$: IValueObservable<string | undefined>;
309
150
  isid$: IValueObservable<string | undefined>;
310
151
  }
311
- interface IActionPlayPayload {
152
+ export interface IActionPlayPayload {
312
153
  /**
313
154
  * время в секундах от начала ролика
314
155
  */
315
156
  position: Seconds;
316
157
  }
317
- interface IPausePayload {
158
+ export interface IPausePayload {
318
159
  /**
319
160
  * время в секундах: сколько просмотрено от начала ролика
320
161
  */
321
162
  position: Seconds;
322
163
  }
323
- interface ISeekPayload {
164
+ export interface ISeekPayload {
324
165
  /**
325
166
  * Действие пользователя приведшее к перемотке
326
167
  */
327
168
  action: SeekAction;
328
169
  time: Seconds;
329
170
  }
330
- interface IReadyPayload {
171
+ export interface IReadyPayload {
331
172
  /**
332
173
  * время в миллисекундах с события inited
333
174
  */
334
175
  time: Milliseconds;
335
176
  }
336
- interface IFirstBytesPayload {
177
+ export interface IFirstBytesPayload {
337
178
  /**
338
179
  * время в миллисекундах с события inited
339
180
  */
340
181
  time: Milliseconds;
341
182
  }
342
- interface IFirstFramePayload {
183
+ export interface IFirstFramePayload {
343
184
  /**
344
185
  * время в миллисекундах с события inited
345
186
  */
346
187
  time: Milliseconds;
347
188
  }
348
- interface IEmptyBufferPayload {
189
+ export interface IEmptyBufferPayload {
349
190
  /**
350
191
  * время в миллисекундах которое пользователь видел застывшую картинку
351
192
  */
352
193
  duration: Milliseconds;
353
194
  }
354
- interface IDownloadSpeedPayload {
195
+ export interface IDownloadSpeedPayload {
355
196
  /**
356
197
  * Скорость в килобайтах (!) в секунду
357
198
  */
358
199
  speed: number;
359
200
  }
360
- interface IErrorPayload {
201
+ export interface IErrorPayload {
361
202
  /**
362
203
  * строка из символов(без пробелов): тип ошибки
363
204
  */
364
205
  errorType: string;
365
206
  fatal: boolean;
366
207
  }
367
- interface IStatContext {
208
+ export interface IStatContext {
368
209
  mobile: boolean;
369
210
  movieId: number;
370
211
  projectId?: number;
@@ -395,7 +236,7 @@ interface IStatContext {
395
236
  is3d?: boolean;
396
237
  refDomain?: string;
397
238
  }
398
- interface IConstructorParams {
239
+ export interface IConstructorParams {
399
240
  /** @deprecated Используете config.apiEnv */
400
241
  apiEnv?: ApiEnv;
401
242
  config?: IOptionalConfig;
@@ -404,11 +245,11 @@ interface IConstructorParams {
404
245
  useIsid?: boolean;
405
246
  refreshAuthToken?: () => Promise<string | undefined>;
406
247
  }
407
- interface IWatchCoveragePayload {
248
+ export interface IWatchCoveragePayload {
408
249
  start: number;
409
250
  end: number;
410
251
  }
411
- declare class OneStat implements IOneStat {
252
+ export declare class OneStat implements IOneStat {
412
253
  private api;
413
254
  private logger;
414
255
  private config;
@@ -446,7 +287,7 @@ declare class OneStat implements IOneStat {
446
287
  setFieldBlacklist(): void;
447
288
  logInited(): void;
448
289
  logReady(payload: IReadyPayload): void;
449
- logStarted(...args: Parameters<typeof this$1.logActionPlay>): void;
290
+ logStarted(...args: Parameters<typeof this.logActionPlay>): void;
450
291
  logPlay(): void;
451
292
  logPause(payload: IPausePayload): void;
452
293
  logSeek(payload: ISeekPayload): void;
@@ -477,7 +318,3 @@ declare class OneStat implements IOneStat {
477
318
  private log;
478
319
  private createLogItem;
479
320
  }
480
-
481
- declare const VERSION: string;
482
-
483
- export { ApiEnv, ConnectionType, ContentType, IAdsEvents, IConstructorParams, IInteractiveEvents, IOneStat, IOptionalConfig, IStatContext, IUIEvents, InteractiveInterfaceClick, InterfaceClick, OneStat, Quality, SeekAction, VERSION };
@@ -0,0 +1,29 @@
1
+ import { ILogCustomData } from './types';
2
+ import { ApiEnv, Operation } from './values';
3
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
4
+ import type { RecursivePartial } from '@vkontakte/videoplayer-shared';
5
+ export interface IConfig {
6
+ apiEnv: ApiEnv;
7
+ requestRetryCount: number;
8
+ firstFlushTime: Milliseconds;
9
+ flushDebounceTime: Milliseconds;
10
+ flushMaxWait: Milliseconds;
11
+ storageExpiration: Milliseconds;
12
+ watchCoverageInterval: Milliseconds;
13
+ disabledOperations: Operation[];
14
+ disabledCustomFields: (keyof ILogCustomData)[];
15
+ shorten: boolean;
16
+ maxLoops: number;
17
+ embedUrlParams: string[];
18
+ useBeacon: boolean;
19
+ synchronizeTime: boolean;
20
+ debugLog: boolean;
21
+ backoff: {
22
+ start: Milliseconds;
23
+ factor: number;
24
+ max: Milliseconds;
25
+ random: number;
26
+ };
27
+ }
28
+ export type IOptionalConfig = RecursivePartial<IConfig>;
29
+ export declare const fillDefault: (partial: IOptionalConfig) => IConfig;
package/types/env.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { ApiEnv } from './values';
2
+ export declare const VERSION: string;
3
+ /**
4
+ * Application ID: 512000749287.
5
+ */
6
+ export declare const API_KEY: string;
7
+ export declare const API_BASE_URLS: Record<ApiEnv, string>;
@@ -0,0 +1,6 @@
1
+ import { IOneStat, OneStat, IStatContext, IConstructorParams } from './OneStat';
2
+ import { ApiEnv, ContentType, Quality, ConnectionType, SeekAction, InterfaceClick, InteractiveInterfaceClick } from './values';
3
+ import { IUIEvents, IAdsEvents, IInteractiveEvents } from './uiEvents';
4
+ export { OneStat, IOneStat, IStatContext, IConstructorParams, ApiEnv, ContentType, Quality, ConnectionType, SeekAction, IUIEvents, IAdsEvents, IInteractiveEvents, InterfaceClick, InteractiveInterfaceClick, };
5
+ export { VERSION } from './env';
6
+ export { IOptionalConfig } from './config';
@@ -0,0 +1,43 @@
1
+ import { Kbps, Milliseconds, Seconds } from '@vkontakte/videoplayer-shared';
2
+ import { ConnectionType, ContentType, Flag, Mode, Network, Operation, Quality, StatType } from './values';
3
+ export interface ILogItem {
4
+ operation: Operation;
5
+ type: 1;
6
+ time?: Seconds | Milliseconds;
7
+ timestamp: Milliseconds;
8
+ network?: Network;
9
+ custom: ILogCustomData;
10
+ }
11
+ export interface ILogCustomData {
12
+ /**
13
+ * Сессия смотрения, уникальна для пользователя, контента, экземпляра плеера и одного просмотра
14
+ * См https://confluence.vk.team/display/VID/Video%20Session%20ID
15
+ */
16
+ vsid: string;
17
+ isid?: string;
18
+ vid: number;
19
+ ct?: ContentType;
20
+ place?: string;
21
+ quality?: Quality;
22
+ cdn_host?: string;
23
+ stat_type?: StatType;
24
+ param?: any;
25
+ vk_app_id?: string;
26
+ track_code?: string;
27
+ connection_type?: ConnectionType;
28
+ connection_reused?: Flag;
29
+ cached_data?: Flag;
30
+ live?: Flag;
31
+ muted?: Flag;
32
+ mode?: Mode;
33
+ subtitles?: string;
34
+ failover?: Flag;
35
+ download_speed?: Kbps;
36
+ manual_quality?: Flag;
37
+ ref_domain?: string;
38
+ direct_url?: string;
39
+ rate?: string;
40
+ view_360?: 1;
41
+ vk_playlist_id?: string;
42
+ aid?: string;
43
+ }
@@ -0,0 +1,24 @@
1
+ import { IObservable } from '@vkontakte/videoplayer-shared';
2
+ import { InteractiveInterfaceClick } from './values';
3
+ import type { SeekAction } from './values';
4
+ export interface IUIEvents {
5
+ actionRewind$?: IObservable<void>;
6
+ actionSeek$?: IObservable<SeekAction>;
7
+ inPiP$?: IObservable<boolean>;
8
+ inFullscreen$?: IObservable<boolean>;
9
+ actionSetSubtitle$?: IObservable<string>;
10
+ nextMovie$?: IObservable<number>;
11
+ }
12
+ export interface IAdsEvents {
13
+ slotRequested$?: IObservable<void>;
14
+ started$?: IObservable<string>;
15
+ paused$?: IObservable<void>;
16
+ resumed$?: IObservable<void>;
17
+ ended$?: IObservable<void>;
18
+ skipped$?: IObservable<void>;
19
+ clicked$?: IObservable<void>;
20
+ }
21
+ export interface IInteractiveEvents {
22
+ click$?: IObservable<InteractiveInterfaceClick>;
23
+ nextMovie$?: IObservable<number>;
24
+ }
@@ -0,0 +1,7 @@
1
+ import { HttpConnectionType as CoreConnectionType, Surface, VideoFormat, VideoQuality } from '@vkontakte/videoplayer-core';
2
+ import { ConnectionType as StatisticsConnectionType, ContentType, Mode, Network, Quality } from '../values';
3
+ export declare const quality: (coreQuality: VideoQuality | undefined) => Quality | undefined;
4
+ export declare const connectionType: (coreType: CoreConnectionType | undefined) => StatisticsConnectionType | undefined;
5
+ export declare const contentType: (format: VideoFormat | undefined) => ContentType | undefined;
6
+ export declare const surface: (surface: Surface | undefined) => Mode | undefined;
7
+ export declare const network: (effectiveType: 'slow-2g' | '2g' | '3g' | '4g' | string) => Network | undefined;
@@ -0,0 +1,2 @@
1
+ import { ILogItem } from '../types';
2
+ export declare const shorten: (item: ILogItem) => object;
@@ -0,0 +1,10 @@
1
+ import { Milliseconds } from '@vkontakte/videoplayer-shared';
2
+ export declare class TimeSynchronisation {
3
+ private offset;
4
+ constructor(initialOffset?: Milliseconds);
5
+ getOffset(): Milliseconds;
6
+ setOffset(offset: Milliseconds): void;
7
+ now(): number;
8
+ date(date?: Date): Date;
9
+ addServerTime(serverTime: Milliseconds, rtt: Milliseconds): void;
10
+ }
@@ -0,0 +1 @@
1
+ export default function uuid(): string;
@@ -0,0 +1,2 @@
1
+ export declare const generateVSID: () => string;
2
+ export declare const generateISID: () => string;
@@ -0,0 +1,6 @@
1
+ import { IPlayer } from '@vkontakte/videoplayer-core';
2
+ import { IObservable, IRange, Milliseconds, Seconds } from '@vkontakte/videoplayer-shared';
3
+ export type IParams = {
4
+ forceInterval: Milliseconds;
5
+ };
6
+ export declare const watchCoverage: (player: IPlayer, params: IParams) => IObservable<IRange<Seconds>>;
@@ -0,0 +1,85 @@
1
+ import { 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' | // Пока не поддержана
3
+ 'failover' | 'play_toggle' | 'pause' | 'adv';
4
+ export declare enum ApiEnv {
5
+ PROD = "prod",
6
+ VK_ALIAS = "vk_alias",
7
+ VIDEOTEST = "videotest",
8
+ TEST = "test",
9
+ AUTO = "auto"
10
+ }
11
+ export declare enum Quality {
12
+ Q144P = "mobile",
13
+ Q240P = "lowest",
14
+ Q360P = "low",
15
+ Q480P = "medium",
16
+ Q720P = "high",
17
+ Q1080P = "fullhd",
18
+ Q1440P = "quadhd",
19
+ Q2160P = "ultrahd",
20
+ UNKNOWN = "unknown"
21
+ }
22
+ export declare enum ContentType {
23
+ MP4 = "mp4",
24
+ DASH = "dash",
25
+ DASH_SEP = "dash_sep",
26
+ ONDEMAND_DASH = "ondemand_dash",
27
+ HLS = "hls",
28
+ ONDEMAND_HLS = "ondemand_hls",
29
+ WEBM = "webm",
30
+ AV1 = "av1",
31
+ ONDEMAND_DASH_LIVE = "ondemand_dash_live",
32
+ ONDEMAND_HLS_LIVE = "ondemand_hls_live",
33
+ WEBRTC = "webrtc",
34
+ UNKNOWN = "unknown",
35
+ /** @deprecated сдк не поддерживает RTMP, не нужно его использовать */
36
+ RTMP = "rtmp"
37
+ }
38
+ export declare enum StatType {
39
+ AUTO = "auto",
40
+ MANUAL = ""
41
+ }
42
+ export declare enum ConnectionType {
43
+ HTTP1 = "http1",
44
+ HTTP2 = "http2",
45
+ HTTP3 = "http3"
46
+ }
47
+ export declare enum Flag {
48
+ YES = 1,
49
+ NO = 0
50
+ }
51
+ export declare enum Network {
52
+ EXCELLENT = "excellent",
53
+ GOOD = "good",
54
+ POOR = "poor"
55
+ }
56
+ export declare enum Mode {
57
+ PIP = "pip",
58
+ FULLSCREEN = "fullscreen",
59
+ EXTERNAL = "external",
60
+ PREFETCH = "prefetch",
61
+ AIRPLAY = "airplay",
62
+ CHROMECAST = "chromecast",
63
+ INVISIBLE = "invisible"
64
+ }
65
+ export declare enum SeekAction {
66
+ SLIDER = "slider",
67
+ DOUBLE_TAP = "double_tap",
68
+ TIME_CODE = "time_code",
69
+ EPISODE = "episode",
70
+ REWIND = "rewind",
71
+ LIVE = "live",
72
+ UNKNOWN = "unknown"
73
+ }
74
+ export declare enum InteractiveInterfaceClick {
75
+ GRAPH_SHOW = "iGraphShow",
76
+ GRAPH_HIDE = "iGraphHide",
77
+ NEXT_AREA = "iNextChapterArea",
78
+ NEXT_BUTTON = "iNextChapterBtn",
79
+ WATCH_AGAIN = "iWatchAgainBtn"
80
+ }
81
+ export type InterfaceClick = InteractiveInterfaceClick;
82
+ export declare const OperationAliases: Partial<Record<Operation, string>>;
83
+ export declare const CustomParamAliases: Partial<Record<keyof ILogCustomData, string>>;
84
+ export declare const QualityAliases: Record<Quality, string>;
85
+ export declare const ModeAliases: Record<Mode, string>;