@24i/bigscreen-sdk 1.0.37-alpha.2648 → 1.0.37-alpha.2649
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 +2 -2
- package/packages/analytics/src/clients/TealiumAnalytics/TealiumAnalytics.ts +31 -21
- package/packages/analytics/src/clients/TealiumAnalytics/constants.ts +1 -1
- package/packages/analytics/src/clients/TealiumAnalytics/findIdForLanguage.ts +9 -0
- package/packages/analytics/src/clients/TealiumAnalytics/index.ts +1 -0
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/__mocks__/mediaPayload.ts +9 -10
- package/packages/analytics/src/clients/TealiumAnalytics/types.ts +30 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/bigscreen-sdk",
|
|
3
|
-
"version": "1.0.37-alpha.
|
|
3
|
+
"version": "1.0.37-alpha.2649",
|
|
4
4
|
"description": "SmartApps BIGscreen SDK monorepo",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/24i/smartapps-bigscreen-sdk#readme",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@24i/appstage-shared-analytics": "1.0.20-alpha.
|
|
41
|
+
"@24i/appstage-shared-analytics": "1.0.20-alpha.72",
|
|
42
42
|
"@24i/appstage-shared-events-manager": "1.0.11",
|
|
43
43
|
"@24i/appstage-shared-perf-utils": "1.0.11",
|
|
44
44
|
"@24i/bigscreen-players-engine-base": "4.0.4",
|
|
@@ -2,6 +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
6
|
import {
|
|
6
7
|
BIGSCREEN_APP_TYPE,
|
|
7
8
|
BIGSCREEN_OTT_TYPE,
|
|
@@ -16,11 +17,13 @@ import type {
|
|
|
16
17
|
Payload,
|
|
17
18
|
TealiumAnalyticsConfiguration,
|
|
18
19
|
TeaResult,
|
|
20
|
+
TealiumDataMapper,
|
|
21
|
+
TealiumCustomConfiguration,
|
|
22
|
+
CustomMappers,
|
|
19
23
|
} from './types';
|
|
20
24
|
|
|
21
25
|
// eslint-disable-next-line no-magic-numbers
|
|
22
26
|
const SESSION_TIMEOUT = 30 * MINUTE_IN_MS;
|
|
23
|
-
const TEALIUM_INSTANCE = 'tealium_analytics_bigscreen';
|
|
24
27
|
const TEALIUM_SESSION_COUNTER = 'tealium_session_counter';
|
|
25
28
|
const TEALIUM_BASE_URL = 'https://collect.tealiumiq.com/event';
|
|
26
29
|
|
|
@@ -52,6 +55,8 @@ export class TealiumAnalytics implements AnalyticsClient {
|
|
|
52
55
|
|
|
53
56
|
baseUrl: string = '';
|
|
54
57
|
|
|
58
|
+
customMappers: CustomMappers | undefined = undefined;
|
|
59
|
+
|
|
55
60
|
constructor(private config: TealiumAnalyticsConfiguration, private appVersion: string = '') {
|
|
56
61
|
this.init();
|
|
57
62
|
}
|
|
@@ -62,37 +67,43 @@ export class TealiumAnalytics implements AnalyticsClient {
|
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
prepareDatasetPayload() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
console.warn(`[${this.name}] prepareDatasetPayload missing options`);
|
|
70
|
+
if (!this.config) {
|
|
71
|
+
console.warn(`[${this.name}] prepareDatasetPayload missing configuration`);
|
|
68
72
|
return;
|
|
69
73
|
}
|
|
70
74
|
const {
|
|
71
|
-
datasource,
|
|
72
|
-
entity,
|
|
73
|
-
language,
|
|
74
75
|
account,
|
|
75
76
|
profile,
|
|
76
77
|
environment,
|
|
77
|
-
|
|
78
|
+
datasource,
|
|
79
|
+
customMappers,
|
|
80
|
+
dataMapper = {} as TealiumDataMapper,
|
|
81
|
+
} = this.config || {} as TealiumCustomConfiguration;
|
|
82
|
+
const {
|
|
83
|
+
entity,
|
|
84
|
+
property_ids: propertyIds,
|
|
85
|
+
language,
|
|
78
86
|
short_language_service: shortLanguageService,
|
|
79
|
-
|
|
87
|
+
platform_short: platformShort,
|
|
88
|
+
platform_type: platformType,
|
|
89
|
+
app_type: appType,
|
|
90
|
+
} = dataMapper || {} as TealiumDataMapper;
|
|
91
|
+
this.customMappers = customMappers;
|
|
80
92
|
this.constantPayload = {
|
|
81
93
|
tealium_account: account,
|
|
82
94
|
tealium_profile: profile,
|
|
83
95
|
tealium_environment: environment,
|
|
84
|
-
tealium_datasource: datasource,
|
|
85
|
-
|
|
86
|
-
language,
|
|
96
|
+
...(datasource && { tealium_datasource: datasource }),
|
|
97
|
+
language: language || '',
|
|
87
98
|
language_service: `${entity} ${language}`,
|
|
88
99
|
entity,
|
|
89
|
-
property_id:
|
|
90
|
-
short_language_service: shortLanguageService,
|
|
91
|
-
platform_short: BIGSCREEN_PLATFORM_SHORT,
|
|
92
|
-
platform_type: BIGSCREEN_PLATFORM_TYPE,
|
|
93
|
-
app_type: BIGSCREEN_APP_TYPE,
|
|
100
|
+
property_id: findIdForLanguage(propertyIds, language || '').toString(),
|
|
101
|
+
short_language_service: shortLanguageService || '',
|
|
102
|
+
platform_short: platformShort ?? BIGSCREEN_PLATFORM_SHORT,
|
|
103
|
+
platform_type: platformType ?? BIGSCREEN_PLATFORM_TYPE,
|
|
104
|
+
app_type: appType ?? BIGSCREEN_APP_TYPE,
|
|
94
105
|
ott_type: BIGSCREEN_OTT_TYPE,
|
|
95
|
-
app_id: `${entity} ${language}
|
|
106
|
+
app_id: `${entity} ${language}:${this.appVersion}`,
|
|
96
107
|
};
|
|
97
108
|
}
|
|
98
109
|
|
|
@@ -135,11 +146,10 @@ export class TealiumAnalytics implements AnalyticsClient {
|
|
|
135
146
|
await this.startSession();
|
|
136
147
|
}
|
|
137
148
|
if (!events) return;
|
|
138
|
-
const { config } = this;
|
|
139
149
|
await Promise.all(
|
|
140
150
|
events.map(async (event) => {
|
|
141
|
-
const mappingFunction =
|
|
142
|
-
?
|
|
151
|
+
const mappingFunction = this.customMappers && this.customMappers[event]
|
|
152
|
+
? this.customMappers[event]
|
|
143
153
|
: EVENTS_MAPPING[event];
|
|
144
154
|
try {
|
|
145
155
|
if (!mappingFunction) {
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
};
|
|
@@ -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: '
|
|
14
|
+
app_type: 'html5',
|
|
15
15
|
sceneName: '',
|
|
16
16
|
sceneId: '',
|
|
17
17
|
sceneType: '',
|
|
@@ -40,21 +40,20 @@ export const TEALIUM_PAGEINFO_PAYLOAD = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export const TEALIUM_STATIC_CORE_PAYLOAD = {
|
|
43
|
-
tealium_account: '
|
|
43
|
+
tealium_account: 'test',
|
|
44
44
|
tealium_profile: 'main',
|
|
45
45
|
tealium_environment: 'dev',
|
|
46
46
|
tealium_datasource: 'abc',
|
|
47
|
-
app_id: '
|
|
48
|
-
app_type: '
|
|
49
|
-
entity: '
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
language_service: 'rfe russian',
|
|
47
|
+
app_id: 'auto english:v1.0-test',
|
|
48
|
+
app_type: 'html5',
|
|
49
|
+
entity: 'auto',
|
|
50
|
+
language: 'english',
|
|
51
|
+
language_service: 'auto english',
|
|
53
52
|
ott_type: 'SmartTV',
|
|
54
53
|
platform_short: 'o',
|
|
55
54
|
platform_type: 'ott',
|
|
56
|
-
property_id: '
|
|
57
|
-
short_language_service: '
|
|
55
|
+
property_id: '1',
|
|
56
|
+
short_language_service: 'eng',
|
|
58
57
|
};
|
|
59
58
|
|
|
60
59
|
export const TEALIUM_MEDIA_PAYLOAD = {
|
|
@@ -5,34 +5,42 @@ import type {
|
|
|
5
5
|
} from '../../interface';
|
|
6
6
|
|
|
7
7
|
export type TeaEventType = 'view' | 'link';
|
|
8
|
-
type TeaAppType = '
|
|
8
|
+
type TeaAppType = 'html5' | 'react' | 'native';
|
|
9
9
|
type TeaOttType = 'Samsung' | 'LG' | 'AndroidTV' | 'FireTV' | 'tvOS' | 'Chromecast'
|
|
10
10
|
| 'Roku' | 'Set-top Box' | 'Xiaomi' | 'SmartTV';
|
|
11
11
|
type TeaTrackEventType = `${TrackEventTypeEnum}`;
|
|
12
12
|
type TeaAppEventValues = typeof AppEvents[keyof typeof AppEvents];
|
|
13
13
|
type TeaAnalyticsTriggerValues = `${AnalyticsTriggers}`;
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export interface PropertyIds {
|
|
16
|
+
[key: string]: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type CustomMappers = Partial<Record<EVENTS, EventMappingFunction>>;
|
|
20
|
+
|
|
21
|
+
export type TealiumDataMapper = {
|
|
22
|
+
app_type: TeaAppType, // e.g. 'html5' for bigscreen
|
|
20
23
|
entity: string, // e.g: 'rfe'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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'
|
|
26
29
|
};
|
|
27
30
|
|
|
28
|
-
export type
|
|
29
|
-
|
|
30
|
-
baseURL: string, // e.g: 'https://collect.tealiumiq.com/event',
|
|
31
|
-
enabled: boolean,
|
|
32
|
-
options?: TealiumAnalyticsOptions,
|
|
33
|
-
customMappers?: Record<EVENTS, EventMappingFunction>,
|
|
31
|
+
export type TealiumCustomConfiguration = {
|
|
32
|
+
customMappers?: CustomMappers,
|
|
34
33
|
};
|
|
35
34
|
|
|
35
|
+
export type TealiumAnalyticsConfiguration = {
|
|
36
|
+
account: string, // e.g: 'bbg'
|
|
37
|
+
profile: string, // e.g: 'main'
|
|
38
|
+
environment: string, // e.g: 'dev'
|
|
39
|
+
dataMapper?: TealiumDataMapper,
|
|
40
|
+
datasource?: string, // e.g: '6g2fzf'
|
|
41
|
+
baseURL?: string, // e.g: 'https://collect.tealiumiq.com/event',
|
|
42
|
+
} & TealiumCustomConfiguration;
|
|
43
|
+
|
|
36
44
|
export type CorePayload = {
|
|
37
45
|
app_id: string;
|
|
38
46
|
app_type: TeaAppType;
|
|
@@ -90,23 +98,23 @@ export type TeaStaticCoreResult = {
|
|
|
90
98
|
language: string;
|
|
91
99
|
language_service: string;
|
|
92
100
|
ott_type: TeaOttType;
|
|
93
|
-
platform_short:
|
|
94
|
-
platform_type:
|
|
101
|
+
platform_short: string;
|
|
102
|
+
platform_type: string;
|
|
95
103
|
property_id: string;
|
|
96
104
|
short_language_service: string;
|
|
97
105
|
};
|
|
98
106
|
|
|
99
107
|
export type TeaCoreResult = {
|
|
100
|
-
app_events
|
|
108
|
+
app_events?: TeaAppEventValues | '', // '' for Scene View event
|
|
101
109
|
event_trigger: TeaAnalyticsTriggerValues,
|
|
102
110
|
track_event_type: TeaTrackEventType,
|
|
103
111
|
};
|
|
104
112
|
|
|
105
113
|
export type TeaPageResult = {
|
|
106
|
-
page_title: string,
|
|
107
114
|
page_name: string,
|
|
115
|
+
page_title?: string,
|
|
108
116
|
content_type: string,
|
|
109
|
-
section
|
|
117
|
+
section?: string,
|
|
110
118
|
categories: string,
|
|
111
119
|
subcontent_type?: string;
|
|
112
120
|
};
|