@24i/bigscreen-sdk 1.0.43-alpha.2726 → 1.0.43

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.43-alpha.2726",
3
+ "version": "1.0.43",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,7 +2,7 @@ import { Storage } from '@24i/bigscreen-sdk/storage';
2
2
  import { MINUTE_IN_MS } from '@24i/bigscreen-sdk/utils/timeConstants';
3
3
  import { createTimeout } from '@24i/bigscreen-sdk/utils/timers';
4
4
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
5
- import { findIdForLanguage } from './findIdForLanguage';
5
+ import { findForLanguage } from './findForLanguage';
6
6
  import {
7
7
  BIGSCREEN_APP_TYPE,
8
8
  BIGSCREEN_OTT_TYPE,
@@ -20,6 +20,7 @@ import type {
20
20
  TealiumDataMapper,
21
21
  TealiumCustomConfiguration,
22
22
  CustomMappers,
23
+ TeaDynamicCoreResult,
23
24
  } from './types';
24
25
 
25
26
  // eslint-disable-next-line no-magic-numbers
@@ -30,11 +31,7 @@ const TEALIUM_BASE_URL = 'https://collect.tealiumiq.com/event';
30
31
  const DEFAULT_PAYLOAD: TeaStaticCoreResult = {
31
32
  tealium_account: '',
32
33
  tealium_profile: '',
33
- language: '',
34
- language_service: '',
35
34
  entity: '',
36
- property_id: '',
37
- short_language_service: '',
38
35
  platform_short: BIGSCREEN_PLATFORM_SHORT,
39
36
  platform_type: BIGSCREEN_PLATFORM_TYPE,
40
37
  app_type: BIGSCREEN_APP_TYPE,
@@ -79,26 +76,14 @@ export class TealiumAnalytics implements AnalyticsClient {
79
76
  customMappers,
80
77
  dataMapper = {} as TealiumDataMapper,
81
78
  } = this.config || {} as TealiumCustomConfiguration;
82
- const {
83
- entity,
84
- property_ids: propertyIds,
85
- language,
86
- short_language_service: shortLanguageService,
87
- platform_short: platformShort,
88
- platform_type: platformType,
89
- app_type: appType,
90
- } = dataMapper || {} as TealiumDataMapper;
79
+ const { entity, platformShort, platformType, appType } = dataMapper;
91
80
  this.customMappers = customMappers;
92
81
  this.constantPayload = {
93
82
  tealium_account: account,
94
83
  tealium_profile: profile,
95
84
  tealium_environment: environment,
96
- ...(datasource && { tealium_datasource: datasource }),
97
- language: language || '',
98
- language_service: `${entity} ${language}`,
99
85
  entity,
100
- property_id: findIdForLanguage(propertyIds, language || '').toString(),
101
- short_language_service: shortLanguageService || '',
86
+ ...(datasource && { tealium_datasource: datasource }),
102
87
  platform_short: platformShort ?? BIGSCREEN_PLATFORM_SHORT,
103
88
  platform_type: platformType ?? BIGSCREEN_PLATFORM_TYPE,
104
89
  app_type: appType ?? BIGSCREEN_APP_TYPE,
@@ -107,6 +92,24 @@ export class TealiumAnalytics implements AnalyticsClient {
107
92
  };
108
93
  }
109
94
 
95
+ getDynamicPayload({ language: payloadLanguage }: AnyPayload): TeaDynamicCoreResult {
96
+ if (!this.config || !this.config.dataMapper) {
97
+ console.warn(`[${this.name}] getDynamicPayload missing configuration`);
98
+ return {
99
+ language: '', language_service: '', property_id: '', short_language_service: '',
100
+ };
101
+ }
102
+ const { dataMapper } = this.config;
103
+ const { entity, languageMap, propertyIdsMap, shortLanguageServiceMap } = dataMapper;
104
+ const tealiumLanguage = findForLanguage(languageMap, payloadLanguage) || '';
105
+ return {
106
+ language: tealiumLanguage || '',
107
+ language_service: `${entity} ${tealiumLanguage}`,
108
+ property_id: findForLanguage(propertyIdsMap, payloadLanguage) || '',
109
+ short_language_service: findForLanguage(shortLanguageServiceMap, payloadLanguage) || '',
110
+ };
111
+ }
112
+
110
113
  async startSession() {
111
114
  const sessionNumber = parseInt(
112
115
  await Storage.getItem(TEALIUM_SESSION_COUNTER) ?? '0', 10,
@@ -157,6 +160,7 @@ export class TealiumAnalytics implements AnalyticsClient {
157
160
  }
158
161
  const eventBody = {
159
162
  ...this.constantPayload,
163
+ ...this.getDynamicPayload(payload),
160
164
  ...mappingFunction(triggerName, payload as Payload, this.config),
161
165
  };
162
166
  const filteredEventBody: TeaResult = Object.entries(eventBody).reduce(
@@ -0,0 +1,9 @@
1
+ import { LanguageMapper } from '@24i/bigscreen-sdk/analytics/TealiumAnalytics';
2
+
3
+ export const findForLanguage = (
4
+ languageMapper: LanguageMapper = {},
5
+ language: string = '',
6
+ ) => {
7
+ const languageKey = Object.keys(languageMapper).find((key) => key === language);
8
+ return languageKey ? languageMapper[languageKey] : null;
9
+ };
@@ -1,4 +1,4 @@
1
1
  export { TealiumAnalytics } from './TealiumAnalytics';
2
- export { findIdForLanguage } from './findIdForLanguage';
2
+ export { findForLanguage } from './findForLanguage';
3
3
  export * from './constants';
4
4
  export * from './types';
@@ -29,6 +29,8 @@ export const MEDIA_PAYLOAD: Payload = {
29
29
  section: 'BROWSE',
30
30
  subcontentType: 'section',
31
31
  seriesTitle: 'section',
32
+ language: 'en',
33
+ resolution: '1920x1080',
32
34
  };
33
35
 
34
36
  export const TEALIUM_PAGEINFO_PAYLOAD = {
@@ -1,7 +1,7 @@
1
1
  import { AnalyticsTriggers } from '@24i/appstage-shared-analytics';
2
2
  import { AppEvents, EVENTS, TrackEventType as TrackEventTypeEnum } from './constants';
3
3
  import type {
4
- UserInfo, AppInfo, VideoProgress, SceneInfo, PlayerSession, ErrorInfo,
4
+ UserInfo, GeneralAppData, AppInfo, VideoProgress, SceneInfo, PlayerSession, ErrorInfo,
5
5
  } from '../../interface';
6
6
 
7
7
  export type TeaEventType = 'view' | 'link';
@@ -12,20 +12,20 @@ type TeaTrackEventType = `${TrackEventTypeEnum}`;
12
12
  type TeaAppEventValues = typeof AppEvents[keyof typeof AppEvents];
13
13
  type TeaAnalyticsTriggerValues = `${AnalyticsTriggers}`;
14
14
 
15
- export interface PropertyIds {
16
- [key: string]: number;
15
+ export interface LanguageMapper {
16
+ [key: string]: string;
17
17
  }
18
18
 
19
19
  export type CustomMappers = Partial<Record<EVENTS, EventMappingFunction>>;
20
20
 
21
21
  export type TealiumDataMapper = {
22
- app_type: TeaAppType, // e.g. 'html5' for bigscreen
22
+ appType: TeaAppType,
23
23
  entity: string, // e.g: 'rfe'
24
- property_ids: PropertyIds, // e.g: 414
25
- language?: string, // e.g: 'english'
26
- platform_short?: string,
27
- platform_type?: string,
28
- short_language_service?: string, // e.g: 'eng'
24
+ platformShort?: string,
25
+ platformType?: string,
26
+ languageMap: LanguageMapper, // e.g: 'english'
27
+ propertyIdsMap: LanguageMapper, // e.g: 414
28
+ shortLanguageServiceMap: LanguageMapper, // e.g: 'eng'
29
29
  };
30
30
 
31
31
  export type TealiumCustomConfiguration = {
@@ -71,6 +71,7 @@ export type SubPageInfo = {
71
71
  };
72
72
 
73
73
  export type Payload = CorePayload &
74
+ GeneralAppData &
74
75
  AppInfo &
75
76
  SceneInfo &
76
77
  SubPageInfo &
@@ -87,6 +88,13 @@ export type EventMappingFunction = (
87
88
  config?: TealiumAnalyticsConfiguration,
88
89
  ) => TeaResult;
89
90
 
91
+ export type TeaDynamicCoreResult = {
92
+ language: string;
93
+ language_service: string;
94
+ property_id: string;
95
+ short_language_service: string;
96
+ };
97
+
90
98
  export type TeaStaticCoreResult = {
91
99
  tealium_account: string,
92
100
  tealium_profile: string,
@@ -96,13 +104,9 @@ export type TeaStaticCoreResult = {
96
104
  app_id: string;
97
105
  app_type: TeaAppType;
98
106
  entity: string;
99
- language: string;
100
- language_service: string;
101
107
  ott_type: TeaOttType;
102
108
  platform_short: string;
103
109
  platform_type: string;
104
- property_id: string;
105
- short_language_service: string;
106
110
  };
107
111
 
108
112
  export type TeaCoreResult = {
@@ -1,9 +0,0 @@
1
- import { PropertyIds } from '@24i/bigscreen-sdk/analytics/TealiumAnalytics';
2
-
3
- export const findIdForLanguage = (
4
- property_ids: PropertyIds = {},
5
- language: string,
6
- ): number => {
7
- const languageKey = Object.keys(property_ids).find((key) => key.endsWith(language));
8
- return languageKey ? property_ids[languageKey] : -1;
9
- };