@24i/bigscreen-sdk 1.0.35-alpha.2586 → 1.0.35-alpha.2589

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.
Files changed (21) hide show
  1. package/package.json +1 -1
  2. package/packages/analytics/src/clients/TealiumAnalytics/TealiumAnalytics.ts +41 -59
  3. package/packages/analytics/src/clients/TealiumAnalytics/constants.ts +3 -3
  4. package/packages/analytics/src/clients/TealiumAnalytics/interface.ts +1 -1
  5. package/packages/analytics/src/clients/TealiumAnalytics/mappers/__mocks__/mediaPayload.ts +18 -1
  6. package/packages/analytics/src/clients/TealiumAnalytics/mappers/helper.ts +3 -3
  7. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppError.ts +3 -4
  8. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteAdd.ts +2 -2
  9. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteRemove.ts +2 -2
  10. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerClose.ts +2 -2
  11. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerOpen.ts +2 -2
  12. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSceneView.ts +4 -2
  13. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearch.ts +2 -2
  14. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchFailed.ts +2 -2
  15. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchSuccess.ts +2 -2
  16. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoPause.ts +2 -2
  17. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoProgress.ts +3 -3
  18. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoResume.ts +4 -4
  19. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStart.ts +2 -2
  20. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStop.ts +2 -2
  21. package/packages/analytics/src/clients/TealiumAnalytics/types.ts +68 -75
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.35-alpha.2586",
3
+ "version": "1.0.35-alpha.2589",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -12,20 +12,20 @@ import {
12
12
  import { EVENTS_MAPPING } from './interface';
13
13
  import type { AnalyticsClient, AnyPayload } from '../../interface';
14
14
  import type {
15
- BaseResult,
15
+ TeaStaticCoreResult,
16
16
  Payload,
17
- TealiumAnalyticsOptions,
18
- UtagWindow,
17
+ TealiumAnalyticsConfiguration,
18
+ TeaResult,
19
19
  } from './types';
20
20
 
21
- declare const window: Window & UtagWindow;
22
-
23
21
  // eslint-disable-next-line no-magic-numbers
24
22
  const SESSION_TIMEOUT = 30 * MINUTE_IN_MS;
25
-
26
23
  const TEALIUM_SESSION_COUNTER = 'tealium_session_counter';
24
+ const TEALIUM_BASE_URL = 'https://collect.tealiumiq.com/event';
27
25
 
28
- const DEFAULT_PAYLOAD = {
26
+ const DEFAULT_PAYLOAD: TeaStaticCoreResult = {
27
+ tealium_account: '',
28
+ tealium_profile: '',
29
29
  language: '',
30
30
  language_service: '',
31
31
  entity: '',
@@ -36,12 +36,12 @@ const DEFAULT_PAYLOAD = {
36
36
  app_type: BIGSCREEN_APP_TYPE,
37
37
  ott_type: BIGSCREEN_OTT_TYPE,
38
38
  app_id: '',
39
- };
39
+ } as const;
40
40
 
41
41
  export class TealiumAnalytics implements AnalyticsClient {
42
42
  name = 'TealiumAnalytics';
43
43
 
44
- constantPayload: BaseResult = DEFAULT_PAYLOAD;
44
+ constantPayload: TeaStaticCoreResult = DEFAULT_PAYLOAD;
45
45
 
46
46
  sessionTimeout = createTimeout();
47
47
 
@@ -49,25 +49,31 @@ export class TealiumAnalytics implements AnalyticsClient {
49
49
 
50
50
  sessionStartSent = false;
51
51
 
52
- constructor(private config: TealiumAnalyticsOptions, private appVersion: string = '') {
52
+ baseUrl: string = '';
53
+
54
+ constructor(private config: TealiumAnalyticsConfiguration, private appVersion: string = '') {
53
55
  this.init();
54
56
  }
55
57
 
56
58
  async init() {
57
- // Typically set "noview" flag to true for Single Page Apps (SPAs)
58
- window.utag_cfg_ovrd = { noview: true };
59
- window.utag_data = {};
60
- this.loadScript();
59
+ this.baseUrl = this.config.baseURL || TEALIUM_BASE_URL;
61
60
  this.prepareDatasetPayload();
62
61
  }
63
62
 
64
63
  prepareDatasetPayload() {
65
- const { entity, language } = this.config;
64
+ const { options } = this.config;
65
+ if (!options) {
66
+ console.warn(`[${this.name}] prepareDatasetPayload missing options`);
67
+ return;
68
+ }
69
+ const { entity, language, account, profile, property_id: propertyId } = options;
66
70
  this.constantPayload = {
71
+ tealium_account: account,
72
+ tealium_profile: profile,
67
73
  language,
68
74
  language_service: `${entity} ${language}`,
69
75
  entity,
70
- property_id: '',
76
+ property_id: `${propertyId}`,
71
77
  short_language_service: language,
72
78
  platform_short: BIGSCREEN_PLATFORM_SHORT,
73
79
  platform_type: BIGSCREEN_PLATFORM_TYPE,
@@ -93,42 +99,19 @@ export class TealiumAnalytics implements AnalyticsClient {
93
99
  }, SESSION_TIMEOUT);
94
100
  }
95
101
 
96
- loadScript() {
97
- const { account, profile, environment } = this.config;
98
- const url = `//tags.tiqcdn.com/utag/${account}/${profile}/${environment}/utag.js`;
99
-
100
- const script = document.createElement('script');
101
- script.type = 'text/javascript';
102
- script.async = true;
103
- script.src = url;
104
- script.addEventListener('load', async () => {
105
- console.log('Tealium was loaded.');
106
- await this.startSession();
107
- }, false);
108
- const scriptElements = document.getElementsByTagName('script');
109
- if (scriptElements.length > 0) {
110
- const scriptElement = scriptElements[0];
111
- scriptElement.parentNode!.insertBefore(script, scriptElement);
112
- } else {
113
- document.body.appendChild(script);
114
- }
115
- }
116
-
117
- track(tealiumEvent: string, payload?: AnyPayload) {
118
- if (window.utag === undefined) {
119
- console.warn('Tealium is not available');
120
- return;
102
+ async sendEvent(eventBody: TeaResult) {
103
+ try {
104
+ await fetch(this.baseUrl, {
105
+ method: 'POST',
106
+ body: JSON.stringify(eventBody),
107
+ headers: {
108
+ Accept: 'application/json',
109
+ 'Content-Type': 'application/json;charset=UTF-8',
110
+ },
111
+ });
112
+ } catch (error) {
113
+ console.warn(`[${this.name}] Error sendEvent: `, error);
121
114
  }
122
- window.utag_data = this.constantPayload;
123
- window.utag!.track(tealiumEvent, payload);
124
- }
125
-
126
- view(payload?: AnyPayload) {
127
- this.track('view', payload);
128
- }
129
-
130
- link(payload?: AnyPayload) {
131
- this.track('link', payload);
132
115
  }
133
116
 
134
117
  async onEvent(triggerName: AnalyticsTriggers, payload: AnyPayload): Promise<void> {
@@ -143,15 +126,14 @@ export class TealiumAnalytics implements AnalyticsClient {
143
126
  events.map(async (event) => {
144
127
  const mappingFunction = EVENTS_MAPPING[event];
145
128
  try {
146
- const eventBody = mappingFunction?.(triggerName, {
147
- ...this.constantPayload,
148
- ...payload,
149
- } as unknown as Payload);
150
- if ((eventBody as unknown as AnyPayload).track_event_type === 'view') {
151
- this.view(eventBody as Payload);
152
- } else {
153
- this.link(eventBody as Payload);
129
+ if (!mappingFunction) {
130
+ throw Error(`Missing mapping function for "${event}"`);
154
131
  }
132
+ const eventBody = {
133
+ ...this.constantPayload,
134
+ ...mappingFunction(triggerName, payload as Payload),
135
+ };
136
+ if (eventBody) await this.sendEvent(eventBody);
155
137
  } catch (e) {
156
138
  console.warn(`[${this.name}] Error onEvent: `, e);
157
139
  }
@@ -41,7 +41,8 @@ export const TEALIUM_TRIGGERS = [
41
41
  AnalyticsTriggers.SEARCH_FAILED,
42
42
  ];
43
43
 
44
- export const AppEvents: { [key: string]: string } = {
44
+ export const AppEvents = {
45
+ [AnalyticsTriggers.SCENE_VIEW]: '',
45
46
  [AnalyticsTriggers.PLAYBACK_10]: 'media_milestone_10_video',
46
47
  [AnalyticsTriggers.PLAYBACK_50]: 'media_milestone_50_video',
47
48
  [AnalyticsTriggers.PLAYBACK_90]: 'media_milestone_90_video',
@@ -57,8 +58,7 @@ export const AppEvents: { [key: string]: string } = {
57
58
  [AnalyticsTriggers.SELECT_CONTENT]: 'app_events',
58
59
  [AnalyticsTriggers.SEARCH_SUCCESS]: 'search_success',
59
60
  [AnalyticsTriggers.SEARCH_FAILED]: 'search_fail',
60
- unpause: 'video_resume',
61
- };
61
+ } as const;
62
62
 
63
63
  export enum EVENTS {
64
64
  SCENE_VIEW = 'scene_view',
@@ -24,9 +24,9 @@ export const EVENTS_MAPPING: Record<EVENTS, EventMappingFunction> = {
24
24
  [EVENTS.VIDEO_STOP]: mapVideoStop,
25
25
  [EVENTS.VIDEO_PROGRESS]: mapVideoProgress,
26
26
  [EVENTS.VIDEO_PAUSE]: mapVideoPause,
27
+ [EVENTS.VIDEO_UNPAUSE]: mapVideoResume,
27
28
  [EVENTS.FAVORITE_ADD]: mapFavoriteAdd,
28
29
  [EVENTS.FAVORITE_REMOVE]: mapFavoriteRemove,
29
- [EVENTS.VIDEO_UNPAUSE]: mapVideoResume,
30
30
  [EVENTS.SEARCH_SUCCESS]: mapSearchSuccess,
31
31
  [EVENTS.SEARCH_FAILED]: mapSearchFailed,
32
32
  [EVENTS.APP_ERROR]: mapAppError,
@@ -11,7 +11,7 @@ export const MEDIA_PAYLOAD: Payload = {
11
11
  provider: 'provider',
12
12
  assetId: '12345',
13
13
  app_id: 'app_id',
14
- app_type: 'app_type',
14
+ app_type: 'HTML5',
15
15
  sceneName: '',
16
16
  sceneId: '',
17
17
  sceneType: '',
@@ -24,6 +24,23 @@ export const MEDIA_PAYLOAD: Payload = {
24
24
  deviceId: 'ott',
25
25
  deviceType: 'smarttv',
26
26
  searchTerm: '',
27
+ itemId: '',
28
+ message: 'error message',
29
+ };
30
+
31
+ export const TEALIUM_STATIC_CORE_PAYLOAD = {
32
+ tealium_account: 'bbg',
33
+ tealium_profile: 'main',
34
+ app_id: 'rfe russian v1.0-test',
35
+ app_type: 'HTML5',
36
+ entity: 'rfe',
37
+ language: 'russian',
38
+ language_service: 'rfe russian',
39
+ ott_type: 'SmartTV',
40
+ platform_short: 'o',
41
+ platform_type: 'ott',
42
+ property_id: '414',
43
+ short_language_service: 'russian',
27
44
  };
28
45
 
29
46
  export const TEALIUM_MEDIA_PAYLOAD = {
@@ -1,8 +1,8 @@
1
- import { Payload, MediaResult } from '../types';
1
+ import { Payload, TeaMediaResult } from '../types';
2
2
 
3
3
  export const mapMediaPayload = (
4
4
  payload: Payload,
5
- ): MediaResult => {
5
+ ): TeaMediaResult => {
6
6
  const {
7
7
  duration, currentTime, title, url, contentType, assetId,
8
8
  } = payload;
@@ -11,7 +11,7 @@ export const mapMediaPayload = (
11
11
  video_length: duration,
12
12
  video_position: currentTime,
13
13
  media_type: contentType,
14
- canonical_url: url,
14
+ canonical_url: url || '',
15
15
  video_series_title: '',
16
16
  byline: 'N/A',
17
17
  pub_date: '',
@@ -1,14 +1,13 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { CoreResult, Payload } from '../types';
2
+ import { TeaErrorResult, Payload } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
 
5
5
  export const mapAppError = (
6
6
  triggerName: AnalyticsTriggers,
7
7
  payload: Payload,
8
- ): CoreResult => ({
8
+ ): TeaErrorResult => ({
9
9
  app_events: AppEvents.app_error,
10
10
  event_trigger: triggerName,
11
11
  track_event_type: TrackEventType.ACTIVITY,
12
- video_event: AppEvents.app_error,
13
- message: payload.message,
12
+ message: payload.message || '',
14
13
  });
@@ -1,10 +1,10 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { CoreResult } from '../types';
2
+ import { TeaCoreResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
 
5
5
  export const mapFavoriteAdd = (
6
6
  triggerName: AnalyticsTriggers,
7
- ): CoreResult => ({
7
+ ): TeaCoreResult => ({
8
8
  app_events: AppEvents.favorite_add,
9
9
  event_trigger: triggerName,
10
10
  track_event_type: TrackEventType.ACTIVITY,
@@ -1,10 +1,10 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { CoreResult } from '../types';
2
+ import { TeaCoreResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
 
5
5
  export const mapFavoriteRemove = (
6
6
  triggerName: AnalyticsTriggers,
7
- ): CoreResult => ({
7
+ ): TeaCoreResult => ({
8
8
  app_events: AppEvents.favorite_remove,
9
9
  event_trigger: triggerName,
10
10
  track_event_type: TrackEventType.ACTIVITY,
@@ -1,12 +1,12 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, VideoResult } from '../types';
2
+ import { Payload, TeaVideoResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
  import { mapMediaPayload } from './helper';
5
5
 
6
6
  export const mapPlayerClose = (
7
7
  triggerName: AnalyticsTriggers,
8
8
  payload: Payload,
9
- ): VideoResult => ({
9
+ ): TeaVideoResult => ({
10
10
  app_events: AppEvents.player_close,
11
11
  event_trigger: triggerName,
12
12
  track_event_type: TrackEventType.ACTIVITY,
@@ -1,12 +1,12 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, VideoResult } from '../types';
2
+ import { Payload, TeaVideoResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
  import { mapMediaPayload } from './helper';
5
5
 
6
6
  export const mapPlayerOpen = (
7
7
  triggerName: AnalyticsTriggers,
8
8
  payload: Payload,
9
- ): VideoResult => ({
9
+ ): TeaVideoResult => ({
10
10
  app_events: AppEvents.player_open,
11
11
  event_trigger: triggerName,
12
12
  track_event_type: TrackEventType.ACTIVITY,
@@ -1,14 +1,16 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, SceneViewResult } from '../types';
2
+ import { Payload, TeaSceneViewResult } from '../types';
3
3
  import { TrackEventType } from '../constants';
4
4
 
5
5
  export const mapSceneView = (
6
6
  triggerName: AnalyticsTriggers,
7
7
  payload: Payload,
8
- ): SceneViewResult | undefined => ({
8
+ ): TeaSceneViewResult => ({
9
+ app_events: '',
9
10
  event_trigger: AnalyticsTriggers.SCENE_VIEW,
10
11
  track_event_type: TrackEventType.VIEW,
11
12
  page_title: payload.sceneType || '',
13
+ page_name: payload.sceneName || '',
12
14
  content_type: payload.sceneType || '',
13
15
  section: payload.sceneType || '',
14
16
  categories: payload.sceneName,
@@ -1,11 +1,11 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, SearchResult } from '../types';
2
+ import { Payload, TeaSearchResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
 
5
5
  export const mapSearch = (
6
6
  triggerName: AnalyticsTriggers,
7
7
  payload: Payload,
8
- ): SearchResult => {
8
+ ): TeaSearchResult => {
9
9
  const searchEventName = payload.searchSuccess
10
10
  ? AnalyticsTriggers.SEARCH_SUCCESS
11
11
  : AnalyticsTriggers.SEARCH_FAILED;
@@ -1,8 +1,8 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, SearchResult } from '../types';
2
+ import { Payload, TeaSearchResult } from '../types';
3
3
  import { mapSearch } from './mapSearch';
4
4
 
5
5
  export const mapSearchFailed = (
6
6
  triggerName: AnalyticsTriggers,
7
7
  payload: Payload,
8
- ): SearchResult => (mapSearch(triggerName, payload));
8
+ ): TeaSearchResult => (mapSearch(triggerName, payload));
@@ -1,8 +1,8 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, SearchResult } from '../types';
2
+ import { Payload, TeaSearchResult } from '../types';
3
3
  import { mapSearch } from './mapSearch';
4
4
 
5
5
  export const mapSearchSuccess = (
6
6
  triggerName: AnalyticsTriggers,
7
7
  payload: Payload,
8
- ): SearchResult => (mapSearch(triggerName, payload));
8
+ ): TeaSearchResult => (mapSearch(triggerName, payload));
@@ -1,12 +1,12 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, VideoResult } from '../types';
2
+ import { Payload, TeaVideoResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
  import { mapMediaPayload } from './helper';
5
5
 
6
6
  export const mapVideoPause = (
7
7
  triggerName: AnalyticsTriggers,
8
8
  payload: Payload,
9
- ): VideoResult => ({
9
+ ): TeaVideoResult => ({
10
10
  app_events: AppEvents.playback_pause,
11
11
  event_trigger: triggerName,
12
12
  track_event_type: TrackEventType.ACTIVITY,
@@ -1,13 +1,13 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, VideoResult } from '../types';
2
+ import { Payload, TeaVideoResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
  import { mapMediaPayload } from './helper';
5
5
 
6
6
  export const mapVideoProgress = (
7
7
  triggerName: AnalyticsTriggers,
8
8
  payload: Payload,
9
- ): VideoResult => {
10
- const appEvent = AppEvents[triggerName.toLowerCase()];
9
+ ): TeaVideoResult => {
10
+ const appEvent = (AppEvents as any)[triggerName] ?? '';
11
11
  return {
12
12
  app_events: appEvent,
13
13
  event_trigger: triggerName,
@@ -1,15 +1,15 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, VideoResult } from '../types';
2
+ import { Payload, TeaVideoResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
  import { mapMediaPayload } from './helper';
5
5
 
6
6
  export const mapVideoResume = (
7
7
  triggerName: AnalyticsTriggers,
8
8
  payload: Payload,
9
- ): VideoResult => ({
10
- app_events: AppEvents.unpause,
9
+ ): TeaVideoResult => ({
10
+ app_events: AppEvents.playback_unpause,
11
11
  event_trigger: triggerName,
12
12
  track_event_type: TrackEventType.ACTIVITY,
13
- video_event: AppEvents.unpause,
13
+ video_event: AppEvents.playback_unpause,
14
14
  ...(mapMediaPayload(payload)),
15
15
  });
@@ -1,12 +1,12 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, VideoResult } from '../types';
2
+ import { Payload, TeaVideoResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
  import { mapMediaPayload } from './helper';
5
5
 
6
6
  export const mapVideoStart = (
7
7
  triggerName: AnalyticsTriggers,
8
8
  payload: Payload,
9
- ): VideoResult => ({
9
+ ): TeaVideoResult => ({
10
10
  app_events: AppEvents.playback_start,
11
11
  event_trigger: triggerName,
12
12
  track_event_type: TrackEventType.ACTIVITY,
@@ -1,12 +1,12 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import { Payload, VideoResult } from '../types';
2
+ import { Payload, TeaVideoResult } from '../types';
3
3
  import { AppEvents, TrackEventType } from '../constants';
4
4
  import { mapMediaPayload } from './helper';
5
5
 
6
6
  export const mapVideoStop = (
7
7
  triggerName: AnalyticsTriggers,
8
8
  payload: Payload,
9
- ): VideoResult => ({
9
+ ): TeaVideoResult => ({
10
10
  app_events: AppEvents.playback_stop,
11
11
  event_trigger: triggerName,
12
12
  track_event_type: TrackEventType.ACTIVITY,
@@ -1,21 +1,22 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
- import type { AnyPayload, UserInfo, AppInfo } from '../../interface';
3
-
4
- export interface UtagWindow {
5
- utag_cfg_ovrd?: {
6
- noview: boolean;
7
- };
8
- utag_data?: {};
9
- utag?: {
10
- track: (eventName: string, payload?: AnyPayload) => {};
11
- }
12
- }
2
+ import { AppEvents, TrackEventType as TrackEventTypeEnum } from './constants';
3
+ import type {
4
+ UserInfo, AppInfo, VideoProgress, SceneInfo, PlayerSession, ErrorInfo,
5
+ } from '../../interface';
6
+
7
+ export type TeaEventType = 'view' | 'link';
8
+ type TeaAppType = 'HTML5' | 'react' | 'native';
9
+ type TeaOttType = 'Samsung' | 'LG' | 'AndroidTV' | 'FireTV' | 'tvOS' | 'Chromecast'
10
+ | 'Roku' | 'Set-top Box' | 'Xiaomi' | 'SmartTV';
11
+ type TeaTrackEventType = `${TrackEventTypeEnum}`;
12
+ type TeaAppEventValues = typeof AppEvents[keyof typeof AppEvents];
13
+ type TeaAnalyticsTriggerValues = `${AnalyticsTriggers}`;
13
14
 
14
15
  export type TealiumAnalyticsOptions = {
15
16
  account: string, // e.g: 'bbg'
16
17
  profile: string, // e.g: 'main'
17
18
  environment: string, // e.g: 'dev'
18
- app_type: string, // e.g. 'HTML5' for bigscreen
19
+ app_type: TeaAppType, // e.g. 'HTML5' for bigscreen
19
20
  entity: string, // e.g: 'rfe'
20
21
  language: string, // e.g: 'russian'
21
22
  short_language_service: string, // e.g: 'rus'
@@ -26,114 +27,106 @@ export type TealiumAnalyticsConfiguration = {
26
27
  name: string, // Telium
27
28
  baseURL: string, // e.g: 'https://collect.tealiumiq.com/event',
28
29
  enabled: boolean,
29
- options: TealiumAnalyticsOptions,
30
+ options?: TealiumAnalyticsOptions,
30
31
  };
31
32
 
32
- export interface CorePayload {
33
+ export type CorePayload = {
33
34
  app_id: string;
34
- app_type: string;
35
- message?: string;
36
- }
37
- export interface MediaPayload {
38
- title: string;
39
- externalId: string;
40
- contentType: string;
41
- currentTime: number;
42
- duration: number;
43
- percent: number;
44
- assetId: string;
45
- provider: string,
46
- url: string;
47
- }
48
-
49
- export interface SessionInfo {
35
+ app_type: TeaAppType;
36
+ };
37
+
38
+ export type SessionInfo = {
50
39
  sessionId: number;
51
40
  sessionNumber: number;
52
- }
41
+ };
53
42
 
54
- export interface DeviceInfo {
43
+ export type DeviceInfo = {
55
44
  appVersion: string,
56
45
  manufacturer: string,
57
46
  platform: string,
58
47
  platformVersion: string,
59
48
  deviceId: string,
60
- }
61
-
62
- export interface SceneInfo {
63
- sceneName: string,
64
- sceneId: string,
65
- sceneType?: string,
66
- }
49
+ };
67
50
 
68
- export interface SearchInfo {
51
+ export type SearchInfo = {
69
52
  searchTerm?: string,
70
53
  searchSuccess?: boolean,
71
- }
54
+ };
72
55
 
73
56
  export type Payload = CorePayload &
57
+ AppInfo &
74
58
  SceneInfo &
59
+ PlayerSession &
60
+ VideoProgress &
75
61
  SessionInfo &
76
- MediaPayload &
77
62
  UserInfo &
78
- AppInfo &
79
- SearchInfo;
80
-
81
- export type EventBody = AnyPayload;
63
+ SearchInfo &
64
+ ErrorInfo;
82
65
 
83
66
  export type EventMappingFunction = (
84
67
  triggerName: AnalyticsTriggers,
85
68
  payload: Payload
86
- ) => AnyPayload | void;
69
+ ) => TeaResult;
87
70
 
88
- export type BaseResult = {
71
+ export type TeaStaticCoreResult = {
72
+ tealium_account: string,
73
+ tealium_profile: string,
74
+ app_id: string;
75
+ app_type: TeaAppType;
76
+ entity: string;
89
77
  language: string;
90
78
  language_service: string;
91
- entity: string;
79
+ ott_type: TeaOttType;
80
+ platform_short: 'o';
81
+ platform_type: 'ott';
92
82
  property_id: string;
93
83
  short_language_service: string;
94
- platform_short: string;
95
- platform_type: string;
96
- app_type: string;
97
- ott_type: string;
98
- app_id: string;
99
84
  };
100
85
 
101
- export type CoreResult = {
102
- event_trigger: string,
103
- track_event_type: string,
104
- app_events?: string,
105
- video_event?: string,
106
- message?: string,
86
+ export type TeaCoreResult = {
87
+ app_events: TeaAppEventValues | '', // '' for Scene View event
88
+ event_trigger: TeaAnalyticsTriggerValues,
89
+ track_event_type: TeaTrackEventType,
107
90
  };
108
91
 
109
- export type SceneViewResult = CoreResult & {
92
+ export type TeaMediaResult = {
93
+ video_name: string,
94
+ video_length: number,
95
+ video_position: number,
96
+ media_type: string,
97
+ canonical_url: string,
98
+ video_series_title: string,
99
+ byline: string,
100
+ pub_date: string,
101
+ article_uid: string,
102
+ tags: string,
103
+ };
104
+
105
+ export type TeaSceneViewResult = TeaCoreResult & {
110
106
  page_title: string,
107
+ page_name: string,
111
108
  content_type: string,
112
109
  section: string,
113
110
  categories: string,
114
111
  };
115
112
 
116
- export type MediaResult = {
117
- video_name: string,
118
- video_length: number,
119
- video_position: number,
120
- media_type: string,
121
- canonical_url: string,
122
- video_series_title?: string,
123
- byline?: string,
124
- pub_date?: string,
125
- article_uid?: string,
126
- tags?: string,
113
+ export type TeaVideoResult = TeaCoreResult & TeaMediaResult & {
114
+ video_event?: string,
127
115
  };
128
116
 
129
- export type VideoResult = CoreResult & MediaResult;
117
+ export type TeaErrorResult = TeaCoreResult & {
118
+ message: string,
119
+ };
130
120
 
131
- export type PlayerOpenResult = CoreResult & {
121
+ export type TeaPlayerOpenResult = TeaCoreResult & {
132
122
  thing_id: string;
133
123
  source_page: string;
134
124
  source_rail?: string | null;
135
125
  };
136
126
 
137
- export type SearchResult = CoreResult & {
127
+ export type TeaSearchResult = TeaCoreResult & {
138
128
  search_keyword?: string;
139
129
  };
130
+
131
+ export type TeaResult = TeaSceneViewResult | TeaVideoResult | TeaErrorResult
132
+ | TeaPlayerOpenResult | TeaSearchResult;