@magicpixel/rn-mp-client-sdk 0.2.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.
- package/LICENSE +20 -0
- package/README.md +29 -0
- package/lib/commonjs/common/app-types.js +6 -0
- package/lib/commonjs/common/app-types.js.map +1 -0
- package/lib/commonjs/common/constants.js +51 -0
- package/lib/commonjs/common/constants.js.map +1 -0
- package/lib/commonjs/common/data-store.js +361 -0
- package/lib/commonjs/common/data-store.js.map +1 -0
- package/lib/commonjs/common/event-bus.js +42 -0
- package/lib/commonjs/common/event-bus.js.map +1 -0
- package/lib/commonjs/common/logger.js +30 -0
- package/lib/commonjs/common/logger.js.map +1 -0
- package/lib/commonjs/common/network-service.js +90 -0
- package/lib/commonjs/common/network-service.js.map +1 -0
- package/lib/commonjs/common/reporter.js +107 -0
- package/lib/commonjs/common/reporter.js.map +1 -0
- package/lib/commonjs/common/utils.js +276 -0
- package/lib/commonjs/common/utils.js.map +1 -0
- package/lib/commonjs/coverage/clover.xml +6 -0
- package/lib/commonjs/coverage/coverage-final.json +1 -0
- package/lib/commonjs/coverage/lcov-report/base.css +224 -0
- package/lib/commonjs/coverage/lcov-report/block-navigation.js +83 -0
- package/lib/commonjs/coverage/lcov-report/block-navigation.js.map +1 -0
- package/lib/commonjs/coverage/lcov-report/favicon.png +0 -0
- package/lib/commonjs/coverage/lcov-report/index.html +101 -0
- package/lib/commonjs/coverage/lcov-report/prettify.css +1 -0
- package/lib/commonjs/coverage/lcov-report/prettify.js +995 -0
- package/lib/commonjs/coverage/lcov-report/prettify.js.map +1 -0
- package/lib/commonjs/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/lib/commonjs/coverage/lcov-report/sorter.js +212 -0
- package/lib/commonjs/coverage/lcov-report/sorter.js.map +1 -0
- package/lib/commonjs/coverage/lcov.info +0 -0
- package/lib/commonjs/eedl/eedl.js +262 -0
- package/lib/commonjs/eedl/eedl.js.map +1 -0
- package/lib/commonjs/index.js +214 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/models/mp-client-sdk.js +33 -0
- package/lib/commonjs/models/mp-client-sdk.js.map +1 -0
- package/lib/commonjs/processors/data-element.processor.js +191 -0
- package/lib/commonjs/processors/data-element.processor.js.map +1 -0
- package/lib/commonjs/processors/qc.processor.js +111 -0
- package/lib/commonjs/processors/qc.processor.js.map +1 -0
- package/lib/commonjs/processors/tag.processor.js +432 -0
- package/lib/commonjs/processors/tag.processor.js.map +1 -0
- package/lib/commonjs/processors/trans-function.processor.js +91 -0
- package/lib/commonjs/processors/trans-function.processor.js.map +1 -0
- package/lib/commonjs/processors/visit-id.processor.js +172 -0
- package/lib/commonjs/processors/visit-id.processor.js.map +1 -0
- package/lib/module/common/app-types.js +2 -0
- package/lib/module/common/app-types.js.map +1 -0
- package/lib/module/common/constants.js +41 -0
- package/lib/module/common/constants.js.map +1 -0
- package/lib/module/common/data-store.js +346 -0
- package/lib/module/common/data-store.js.map +1 -0
- package/lib/module/common/event-bus.js +31 -0
- package/lib/module/common/event-bus.js.map +1 -0
- package/lib/module/common/logger.js +21 -0
- package/lib/module/common/logger.js.map +1 -0
- package/lib/module/common/network-service.js +73 -0
- package/lib/module/common/network-service.js.map +1 -0
- package/lib/module/common/reporter.js +88 -0
- package/lib/module/common/reporter.js.map +1 -0
- package/lib/module/common/utils.js +263 -0
- package/lib/module/common/utils.js.map +1 -0
- package/lib/module/coverage/clover.xml +6 -0
- package/lib/module/coverage/coverage-final.json +1 -0
- package/lib/module/coverage/lcov-report/base.css +224 -0
- package/lib/module/coverage/lcov-report/block-navigation.js +81 -0
- package/lib/module/coverage/lcov-report/block-navigation.js.map +1 -0
- package/lib/module/coverage/lcov-report/favicon.png +0 -0
- package/lib/module/coverage/lcov-report/index.html +101 -0
- package/lib/module/coverage/lcov-report/prettify.css +1 -0
- package/lib/module/coverage/lcov-report/prettify.js +993 -0
- package/lib/module/coverage/lcov-report/prettify.js.map +1 -0
- package/lib/module/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/lib/module/coverage/lcov-report/sorter.js +210 -0
- package/lib/module/coverage/lcov-report/sorter.js.map +1 -0
- package/lib/module/coverage/lcov.info +0 -0
- package/lib/module/eedl/eedl.js +246 -0
- package/lib/module/eedl/eedl.js.map +1 -0
- package/lib/module/index.js +176 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/models/mp-client-sdk.js +24 -0
- package/lib/module/models/mp-client-sdk.js.map +1 -0
- package/lib/module/processors/data-element.processor.js +176 -0
- package/lib/module/processors/data-element.processor.js.map +1 -0
- package/lib/module/processors/qc.processor.js +90 -0
- package/lib/module/processors/qc.processor.js.map +1 -0
- package/lib/module/processors/tag.processor.js +396 -0
- package/lib/module/processors/tag.processor.js.map +1 -0
- package/lib/module/processors/trans-function.processor.js +73 -0
- package/lib/module/processors/trans-function.processor.js.map +1 -0
- package/lib/module/processors/visit-id.processor.js +144 -0
- package/lib/module/processors/visit-id.processor.js.map +1 -0
- package/lib/typescript/common/app-types.d.ts +101 -0
- package/lib/typescript/common/constants.d.ts +21 -0
- package/lib/typescript/common/data-store.d.ts +81 -0
- package/lib/typescript/common/event-bus.d.ts +6 -0
- package/lib/typescript/common/logger.d.ts +5 -0
- package/lib/typescript/common/network-service.d.ts +8 -0
- package/lib/typescript/common/reporter.d.ts +12 -0
- package/lib/typescript/common/utils.d.ts +38 -0
- package/lib/typescript/eedl/eedl.d.ts +46 -0
- package/lib/typescript/index.d.ts +18 -0
- package/lib/typescript/models/mp-client-sdk.d.ts +157 -0
- package/lib/typescript/processors/data-element.processor.d.ts +12 -0
- package/lib/typescript/processors/qc.processor.d.ts +4 -0
- package/lib/typescript/processors/tag.processor.d.ts +27 -0
- package/lib/typescript/processors/trans-function.processor.d.ts +12 -0
- package/lib/typescript/processors/visit-id.processor.d.ts +7 -0
- package/package.json +170 -0
- package/src/common/app-types.ts +128 -0
- package/src/common/constants.ts +43 -0
- package/src/common/data-store.ts +333 -0
- package/src/common/event-bus.ts +35 -0
- package/src/common/logger.ts +19 -0
- package/src/common/network-service.ts +85 -0
- package/src/common/reporter.ts +110 -0
- package/src/common/utils.ts +281 -0
- package/src/coverage/clover.xml +6 -0
- package/src/coverage/coverage-final.json +1 -0
- package/src/coverage/lcov-report/base.css +224 -0
- package/src/coverage/lcov-report/block-navigation.js +87 -0
- package/src/coverage/lcov-report/favicon.png +0 -0
- package/src/coverage/lcov-report/index.html +101 -0
- package/src/coverage/lcov-report/prettify.css +1 -0
- package/src/coverage/lcov-report/prettify.js +2 -0
- package/src/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/src/coverage/lcov-report/sorter.js +196 -0
- package/src/coverage/lcov.info +0 -0
- package/src/eedl/eedl.ts +233 -0
- package/src/index.tsx +258 -0
- package/src/models/mp-client-sdk.ts +174 -0
- package/src/processors/data-element.processor.ts +249 -0
- package/src/processors/qc.processor.ts +115 -0
- package/src/processors/tag.processor.ts +527 -0
- package/src/processors/trans-function.processor.ts +85 -0
- package/src/processors/visit-id.processor.ts +164 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VisitIdProcessor = void 0;
|
|
7
|
+
|
|
8
|
+
var _logger = require("../common/logger");
|
|
9
|
+
|
|
10
|
+
var _dataStore = require("../common/data-store");
|
|
11
|
+
|
|
12
|
+
var _constants = require("../common/constants");
|
|
13
|
+
|
|
14
|
+
var _reporter = require("../common/reporter");
|
|
15
|
+
|
|
16
|
+
var _networkService = require("../common/network-service");
|
|
17
|
+
|
|
18
|
+
var _utils = require("../common/utils");
|
|
19
|
+
|
|
20
|
+
var _eventBus = require("../common/event-bus");
|
|
21
|
+
|
|
22
|
+
class VisitIdProcessor {
|
|
23
|
+
static async init() {
|
|
24
|
+
await this.initIdlEventListener();
|
|
25
|
+
await this.initDebugId();
|
|
26
|
+
await this.setOrResetVisitorId();
|
|
27
|
+
await this.setOrResetVisitInfo();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static async initIdlEventListener() {
|
|
31
|
+
_eventBus.EventBus.on('mp_idl_app_event', (channelName, eventPayload) => {
|
|
32
|
+
try {
|
|
33
|
+
if (!channelName || !eventPayload) {
|
|
34
|
+
_logger.Logger.logError('Both event name and event payload is mandatory for processing idl events');
|
|
35
|
+
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const eventName = eventPayload.client_ev_name;
|
|
40
|
+
const attrInfoPayload = eventPayload.client_ev_payload ?? {};
|
|
41
|
+
const deepPayload = (attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.payload) ?? {}; // is_entry, app_type,
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
deepPayload['org_id'] = eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.org_id;
|
|
45
|
+
deepPayload['event_id'] = eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.event_id;
|
|
46
|
+
deepPayload['event_ts'] = eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.event_ts;
|
|
47
|
+
} catch (e) {
|
|
48
|
+
_logger.Logger.logError('Error enhancing internal attr payload');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const attrPayload = {
|
|
52
|
+
pu: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.page_url,
|
|
53
|
+
ru: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.campaign_ref,
|
|
54
|
+
pt: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.page_title,
|
|
55
|
+
en: attrInfoPayload.event_name,
|
|
56
|
+
cid: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.campaign_id,
|
|
57
|
+
rs: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.report_suite,
|
|
58
|
+
v: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.client_sdk_version,
|
|
59
|
+
vidl: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.idl_version,
|
|
60
|
+
ev: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.event_val,
|
|
61
|
+
ep: deepPayload,
|
|
62
|
+
at: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.app_type,
|
|
63
|
+
evId: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.event_id,
|
|
64
|
+
evTs: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.event_ts,
|
|
65
|
+
orgId: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.org_id,
|
|
66
|
+
_mp_vid: _dataStore.DataStore.visitInfoToString(),
|
|
67
|
+
_lmid: _dataStore.DataStore.getMpId(),
|
|
68
|
+
_ldid: _dataStore.DataStore.getDeviceId(),
|
|
69
|
+
_mpidl: JSON.stringify(_dataStore.DataStore.getVisitorInfoAsString()),
|
|
70
|
+
is_entry: attrInfoPayload.is_entry ?? 0,
|
|
71
|
+
app_type: attrInfoPayload.app_type
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
if (eventName === 'al') {
|
|
75
|
+
attrPayload.pid = eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.profile_id;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_reporter.Reporter.postAttrInfo(attrPayload);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
_logger.Logger.logError('Error processing idl event: ', err);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static async initDebugId() {
|
|
86
|
+
try {
|
|
87
|
+
let debugId = await _dataStore.DataStore.getDataFromStorage(_constants.Constants.KEY_MP_DEBUG_ID);
|
|
88
|
+
|
|
89
|
+
if (!debugId) {
|
|
90
|
+
debugId = _utils.Utils.getUniqueID();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await _dataStore.DataStore.storeData(_constants.Constants.KEY_MP_DEBUG_ID, debugId);
|
|
94
|
+
|
|
95
|
+
_dataStore.DataStore.setDebugId(debugId);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
_logger.Logger.logError('Error initializing debug id.', err);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static async setOrResetVisitInfo() {
|
|
102
|
+
try {
|
|
103
|
+
const visitInfo = await _dataStore.DataStore.getDataFromStorage(_constants.Constants.KEY_MP_IDL_VISIT_ID_INFO);
|
|
104
|
+
|
|
105
|
+
if (!visitInfo) {
|
|
106
|
+
// may be first time visit, setup a new visit info object and return
|
|
107
|
+
const newVisitInfo = {
|
|
108
|
+
visitId: _utils.Utils.getUniqueID(),
|
|
109
|
+
visitCt: 1,
|
|
110
|
+
visitDepth: 1,
|
|
111
|
+
visitTs: Date.now(),
|
|
112
|
+
visitVer: 1
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
_dataStore.DataStore.setVisitInfo(newVisitInfo);
|
|
116
|
+
|
|
117
|
+
await _dataStore.DataStore.storeData(_constants.Constants.KEY_MP_IDL_VISIT_ID_INFO, newVisitInfo);
|
|
118
|
+
} else {
|
|
119
|
+
// reset visit id anyway, but retain the visitCt and depth setting
|
|
120
|
+
visitInfo.visitId = _utils.Utils.getUniqueID();
|
|
121
|
+
visitInfo.visitCt = visitInfo.visitCt + 1;
|
|
122
|
+
visitInfo.visitDepth = 1;
|
|
123
|
+
visitInfo.visitTs = Date.now();
|
|
124
|
+
visitInfo.visitVer = 1;
|
|
125
|
+
|
|
126
|
+
_dataStore.DataStore.setVisitInfo(visitInfo);
|
|
127
|
+
|
|
128
|
+
await _dataStore.DataStore.storeData(_constants.Constants.KEY_MP_IDL_VISIT_ID_INFO, visitInfo);
|
|
129
|
+
}
|
|
130
|
+
} catch (err) {
|
|
131
|
+
_logger.Logger.logError(err);
|
|
132
|
+
|
|
133
|
+
_dataStore.DataStore.setVisitInfo(null);
|
|
134
|
+
|
|
135
|
+
_reporter.Reporter.reportError('setOrResetVisitInfo', err);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static async setOrResetVisitorId() {
|
|
140
|
+
try {
|
|
141
|
+
const visitorInfoData = await _dataStore.DataStore.getDataFromStorage(_constants.Constants.KEY_MP_IDL_VISITOR_ID_INFO);
|
|
142
|
+
|
|
143
|
+
if (!visitorInfoData) {
|
|
144
|
+
_logger.Logger.logDbg('VisitorInfo not found. Refreshing from server'); // get a new visit id and device id from server and store it in storage
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
const apiVisitInfo = await _networkService.NetworkService.fetchIdlInfo(_dataStore.DataStore.getIdlUrl());
|
|
148
|
+
|
|
149
|
+
if (!apiVisitInfo) {
|
|
150
|
+
return;
|
|
151
|
+
} else {
|
|
152
|
+
_dataStore.DataStore.setVisitorInfo(apiVisitInfo); // store to db as well
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
await _dataStore.DataStore.storeData(_constants.Constants.KEY_MP_IDL_VISITOR_ID_INFO, apiVisitInfo);
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
_dataStore.DataStore.setVisitorInfo(visitorInfoData);
|
|
159
|
+
}
|
|
160
|
+
} catch (err) {
|
|
161
|
+
_logger.Logger.logError(err);
|
|
162
|
+
|
|
163
|
+
_dataStore.DataStore.setVisitorInfo(null);
|
|
164
|
+
|
|
165
|
+
_reporter.Reporter.reportError('setOrResetVisitorId', err);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
exports.VisitIdProcessor = VisitIdProcessor;
|
|
172
|
+
//# sourceMappingURL=visit-id.processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["VisitIdProcessor","init","initIdlEventListener","initDebugId","setOrResetVisitorId","setOrResetVisitInfo","EventBus","on","channelName","eventPayload","Logger","logError","eventName","client_ev_name","attrInfoPayload","client_ev_payload","deepPayload","payload","org_id","event_id","event_ts","e","attrPayload","pu","page_url","ru","campaign_ref","pt","page_title","en","event_name","cid","campaign_id","rs","report_suite","v","client_sdk_version","vidl","idl_version","ev","event_val","ep","at","app_type","evId","evTs","orgId","_mp_vid","DataStore","visitInfoToString","_lmid","getMpId","_ldid","getDeviceId","_mpidl","JSON","stringify","getVisitorInfoAsString","is_entry","pid","profile_id","Reporter","postAttrInfo","err","debugId","getDataFromStorage","Constants","KEY_MP_DEBUG_ID","Utils","getUniqueID","storeData","setDebugId","visitInfo","KEY_MP_IDL_VISIT_ID_INFO","newVisitInfo","visitId","visitCt","visitDepth","visitTs","Date","now","visitVer","setVisitInfo","reportError","visitorInfoData","KEY_MP_IDL_VISITOR_ID_INFO","logDbg","apiVisitInfo","NetworkService","fetchIdlInfo","getIdlUrl","setVisitorInfo"],"sources":["visit-id.processor.ts"],"sourcesContent":["import { Logger } from '../common/logger';\nimport { DataStore } from '../common/data-store';\nimport { Constants } from '../common/constants';\nimport { Reporter } from '../common/reporter';\nimport { NetworkService } from '../common/network-service';\nimport type { VisitInfo, VisitorInfo } from '../common/app-types';\nimport { Utils } from '../common/utils';\nimport { EventBus } from '../common/event-bus';\n\nexport class VisitIdProcessor {\n static async init(): Promise<void> {\n await this.initIdlEventListener();\n await this.initDebugId();\n await this.setOrResetVisitorId();\n await this.setOrResetVisitInfo();\n }\n\n static async initIdlEventListener(): Promise<void> {\n EventBus.on(\n 'mp_idl_app_event',\n (channelName: string, eventPayload: Record<string, string>) => {\n try {\n if (!channelName || !eventPayload) {\n Logger.logError(\n 'Both event name and event payload is mandatory for processing idl events'\n );\n return;\n }\n\n const eventName = eventPayload.client_ev_name;\n const attrInfoPayload: any = eventPayload.client_ev_payload ?? {};\n const deepPayload: any = attrInfoPayload?.payload ?? {};\n\n // is_entry, app_type,\n try {\n deepPayload['org_id'] = eventPayload?.org_id;\n deepPayload['event_id'] = eventPayload?.event_id;\n deepPayload['event_ts'] = eventPayload?.event_ts;\n } catch (e) {\n Logger.logError('Error enhancing internal attr payload');\n }\n\n const attrPayload: any = {\n pu: attrInfoPayload?.page_url,\n ru: attrInfoPayload?.campaign_ref,\n pt: attrInfoPayload?.page_title,\n en: attrInfoPayload.event_name,\n cid: attrInfoPayload?.campaign_id,\n rs: attrInfoPayload?.report_suite,\n v: attrInfoPayload?.client_sdk_version,\n vidl: attrInfoPayload?.idl_version,\n ev: attrInfoPayload?.event_val,\n ep: deepPayload,\n at: attrInfoPayload?.app_type,\n evId: attrInfoPayload?.event_id,\n evTs: attrInfoPayload?.event_ts,\n orgId: attrInfoPayload?.org_id,\n _mp_vid: DataStore.visitInfoToString(),\n _lmid: DataStore.getMpId(),\n _ldid: DataStore.getDeviceId(),\n _mpidl: JSON.stringify(DataStore.getVisitorInfoAsString()),\n is_entry: attrInfoPayload.is_entry ?? 0,\n app_type: attrInfoPayload.app_type,\n };\n\n if (eventName === 'al') {\n attrPayload.pid = eventPayload?.profile_id;\n }\n\n Reporter.postAttrInfo(attrPayload);\n } catch (err) {\n Logger.logError('Error processing idl event: ', err);\n }\n }\n );\n }\n\n static async initDebugId(): Promise<void> {\n try {\n let debugId = await DataStore.getDataFromStorage<string>(\n Constants.KEY_MP_DEBUG_ID\n );\n if (!debugId) {\n debugId = Utils.getUniqueID();\n }\n await DataStore.storeData(Constants.KEY_MP_DEBUG_ID, debugId);\n DataStore.setDebugId(debugId);\n } catch (err) {\n Logger.logError('Error initializing debug id.', err);\n }\n }\n\n static async setOrResetVisitInfo(): Promise<void> {\n try {\n const visitInfo: VisitInfo = await DataStore.getDataFromStorage(\n Constants.KEY_MP_IDL_VISIT_ID_INFO\n );\n\n if (!visitInfo) {\n // may be first time visit, setup a new visit info object and return\n const newVisitInfo: VisitInfo = {\n visitId: Utils.getUniqueID(),\n visitCt: 1,\n visitDepth: 1,\n visitTs: Date.now(),\n visitVer: 1,\n };\n DataStore.setVisitInfo(newVisitInfo);\n await DataStore.storeData(\n Constants.KEY_MP_IDL_VISIT_ID_INFO,\n newVisitInfo\n );\n } else {\n // reset visit id anyway, but retain the visitCt and depth setting\n visitInfo.visitId = Utils.getUniqueID();\n visitInfo.visitCt = visitInfo.visitCt + 1;\n visitInfo.visitDepth = 1;\n visitInfo.visitTs = Date.now();\n visitInfo.visitVer = 1;\n DataStore.setVisitInfo(visitInfo);\n await DataStore.storeData(\n Constants.KEY_MP_IDL_VISIT_ID_INFO,\n visitInfo\n );\n }\n } catch (err) {\n Logger.logError(err);\n DataStore.setVisitInfo(null);\n Reporter.reportError('setOrResetVisitInfo', err);\n }\n }\n\n static async setOrResetVisitorId(): Promise<void> {\n try {\n const visitorInfoData: VisitorInfo = await DataStore.getDataFromStorage(\n Constants.KEY_MP_IDL_VISITOR_ID_INFO\n );\n\n if (!visitorInfoData) {\n Logger.logDbg('VisitorInfo not found. Refreshing from server');\n // get a new visit id and device id from server and store it in storage\n const apiVisitInfo = await NetworkService.fetchIdlInfo(\n DataStore.getIdlUrl()\n );\n if (!apiVisitInfo) {\n return;\n } else {\n DataStore.setVisitorInfo(apiVisitInfo);\n // store to db as well\n await DataStore.storeData(\n Constants.KEY_MP_IDL_VISITOR_ID_INFO,\n apiVisitInfo\n );\n }\n } else {\n DataStore.setVisitorInfo(visitorInfoData);\n }\n } catch (err) {\n Logger.logError(err);\n DataStore.setVisitorInfo(null);\n Reporter.reportError('setOrResetVisitorId', err);\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEO,MAAMA,gBAAN,CAAuB;EACX,aAAJC,IAAI,GAAkB;IACjC,MAAM,KAAKC,oBAAL,EAAN;IACA,MAAM,KAAKC,WAAL,EAAN;IACA,MAAM,KAAKC,mBAAL,EAAN;IACA,MAAM,KAAKC,mBAAL,EAAN;EACD;;EAEgC,aAApBH,oBAAoB,GAAkB;IACjDI,kBAAA,C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UO,wBADN,EAEJD,SAFI,CAAN;MAID;IACF,CAhCD,CAgCE,OAAOT,GAAP,EAAY;MACZrD,cAAA,CAAOC,QAAP,CAAgBoD,GAAhB;;MACAf,oBAAA,CAAUkC,YAAV,CAAuB,IAAvB;;MACArB,kBAAA,CAASsB,WAAT,CAAqB,qBAArB,EAA4CpB,GAA5C;IACD;EACF;;EAE+B,aAAnB3D,mBAAmB,GAAkB;IAChD,IAAI;MACF,MAAMgF,eAA4B,GAAG,MAAMpC,oBAAA,CAAUiB,kBAAV,CACzCC,oBAAA,CAAUmB,0BAD+B,CAA3C;;MAIA,IAAI,CAACD,eAAL,EAAsB;QACpB1E,cAAA,CAAO4E,MAAP,CAAc,+CAAd,EADoB,CAEpB;;;QACA,MAAMC,YAAY,GAAG,MAAMC,8BAAA,CAAeC,YAAf,CACzBzC,oBAAA,CAAU0C,SAAV,EADyB,CAA3B;;QAGA,IAAI,CAACH,YAAL,EAAmB;UACjB;QACD,CAFD,MAEO;UACLvC,oBAAA,CAAU2C,cAAV,CAAyBJ,YAAzB,EADK,CAEL;;;UACA,MAAMvC,oBAAA,CAAUsB,SAAV,CACJJ,oBAAA,CAAUmB,0BADN,EAEJE,YAFI,CAAN;QAID;MACF,CAhBD,MAgBO;QACLvC,oBAAA,CAAU2C,cAAV,CAAyBP,eAAzB;MACD;IACF,CAxBD,CAwBE,OAAOrB,GAAP,EAAY;MACZrD,cAAA,CAAOC,QAAP,CAAgBoD,GAAhB;;MACAf,oBAAA,CAAU2C,cAAV,CAAyB,IAAzB;;MACA9B,kBAAA,CAASsB,WAAT,CAAqB,qBAArB,EAA4CpB,GAA5C;IACD;EACF;;AAzJ2B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["app-types.ts"],"sourcesContent":["import type { Logger } from './logger';\n\nexport interface MapLike<T = any> {\n [key: string]: T;\n}\n\nexport interface RunQueueModel {\n sseOnly: boolean;\n name: string;\n dcrName: string;\n eventId: string;\n dcrPayload?: Record<string, any>;\n}\n\nexport type TypedAny = Record<\n string,\n | string\n | number\n | boolean\n | string[]\n | boolean[]\n | number[]\n | Record<string, string | number | boolean | string[] | boolean[] | number[]>\n>;\n\nexport type EventProcessorFn = (payload: TypedAny) => void;\n\nexport interface AppCustomerInfo {\n first_name?: string;\n last_name?: string;\n email?: string;\n phone_number: number;\n country_code: number;\n city?: string;\n state?: string;\n country?: string;\n}\n\nexport interface AppPageLoad {\n page_name: string;\n is_entry?: number;\n}\n\nexport interface DeJsvHelper {\n log: typeof Logger.logDbg;\n err: typeof Logger.logError;\n}\n\nexport interface QcInfoItem {\n nm: string;\n id: string;\n st: boolean;\n}\n\nexport interface TagInfoItem {\n id: string;\n nm: string;\n pr: string;\n prNm: string;\n status: boolean;\n qc: string | string[];\n}\n\nexport type ReplaceMode = 'kph' | 'rph';\n\nexport interface HydrateTagInfo {\n isInError: boolean;\n content: string | number | null;\n errCd: string; // error code\n errMsg: string; // any descriptive error message\n}\n\nexport interface ReportTagItem {\n st: 200 | 900 | 1000 | number; // what happened to this tag?\n t: string; // tag id\n p: string; // provider id\n tNm: string;\n req: any; // request payload\n}\n\nexport interface Report {\n envName: string; // environment name inside magic pixel\n envId: string; // environment id inside magic pixel\n pname?: string; // page name\n evt: string; // dcr event if that triggered this report\n evtId: string; // event id\n dt?: number; // device type (converted to int)\n ln?: number; // language (converted to int)\n bw?: number; // browser name (converted to int)\n dm?: string; // clean domain name\n items: ReportTagItem[]; // list of tag items fired on that page for that condition\n tagCt: number; // expected tag count on this page\n dws: 'j' | 'n'; // down stream configuration. java or node\n v: string; // client sdk version for this call\n}\n\nexport interface UrlInfo {\n tfUrl: string;\n errUrl: string;\n rptUrl: string;\n infoUrl: string;\n baseUrl: string;\n attrInfoUrl: string;\n idlUrl: string;\n}\n\nexport interface VisitInfo {\n visitId: string;\n visitTs: number;\n visitCt: number;\n visitDepth: number;\n visitVer: number;\n}\n\nexport interface VisitorInfo {\n dId: string;\n mId: string;\n st: number;\n}\n\nexport interface SdkInitOptions {\n orgId: string;\n env: string;\n projectId: string;\n baseUrl: string;\n}\n\nexport type EventBusCallback = (event: string, payload: any) => void;\n"],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import { customAlphabet } from 'nanoid/non-secure';
|
|
4
|
+
export class Constants {}
|
|
5
|
+
|
|
6
|
+
_defineProperty(Constants, "PLACEHOLDER_REGEX", new RegExp(/({{)([A-Z_0-9 -]+)(}})/gi));
|
|
7
|
+
|
|
8
|
+
_defineProperty(Constants, "LARGE_RANDOM_POOL", customAlphabet('1234567090abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 21));
|
|
9
|
+
|
|
10
|
+
_defineProperty(Constants, "MP_DL_EVT", 'mp_dl_event');
|
|
11
|
+
|
|
12
|
+
_defineProperty(Constants, "CUST_EVT", 'custom_event');
|
|
13
|
+
|
|
14
|
+
_defineProperty(Constants, "ST_OK", 200);
|
|
15
|
+
|
|
16
|
+
_defineProperty(Constants, "ST_VAL_FAIL", 400);
|
|
17
|
+
|
|
18
|
+
_defineProperty(Constants, "ST_ERR", 500);
|
|
19
|
+
|
|
20
|
+
_defineProperty(Constants, "ST_DEP_FAIL", 1000);
|
|
21
|
+
|
|
22
|
+
_defineProperty(Constants, "ST_PR_BL", 1002);
|
|
23
|
+
|
|
24
|
+
_defineProperty(Constants, "ST_PR_EXC", 1001);
|
|
25
|
+
|
|
26
|
+
_defineProperty(Constants, "PR_TYP_JS", 'js');
|
|
27
|
+
|
|
28
|
+
_defineProperty(Constants, "PR_TYP_IMG", 'img');
|
|
29
|
+
|
|
30
|
+
_defineProperty(Constants, "PR_TYP_APP", 'app');
|
|
31
|
+
|
|
32
|
+
_defineProperty(Constants, "PR_S_TYP_R", 'r');
|
|
33
|
+
|
|
34
|
+
_defineProperty(Constants, "sortAscending", (a, b) => a.o > b.o ? 1 : -1);
|
|
35
|
+
|
|
36
|
+
_defineProperty(Constants, "KEY_MP_IDL_VISITOR_ID_INFO", 'mp_idl_visitor_info');
|
|
37
|
+
|
|
38
|
+
_defineProperty(Constants, "KEY_MP_IDL_VISIT_ID_INFO", 'mp_idl_visit_info');
|
|
39
|
+
|
|
40
|
+
_defineProperty(Constants, "KEY_MP_DEBUG_ID", 'mp_debug_id');
|
|
41
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["customAlphabet","Constants","RegExp","a","b","o"],"sources":["constants.ts"],"sourcesContent":["import { customAlphabet } from 'nanoid/non-secure';\nimport type { BaseResourceParamType } from '../models/mp-client-sdk';\n\nexport class Constants {\n static PLACEHOLDER_REGEX = new RegExp(/({{)([A-Z_0-9 -]+)(}})/gi);\n\n static LARGE_RANDOM_POOL = customAlphabet(\n '1234567090abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n 21\n );\n\n static MP_DL_EVT = 'mp_dl_event';\n static CUST_EVT = 'custom_event';\n\n // Tag Report - Status Constants\n static ST_OK = 200; // tag fired successfully\n static ST_VAL_FAIL = 400; // tag validation failed - meaning one of the items marked as mandatory was found empty\n static ST_ERR = 500; // tag was ok, but provider side failure. may be url is constructed wrong, or provider is down\n static ST_DEP_FAIL = 1000; // processing tag dependencies failed - may be missing parameters or attributes\n static ST_PR_BL = 1002; // provider is black listed in the data governance screen\n static ST_PR_EXC = 1001; // tag was found, but no provider was bundled. SDK build issue. Report with high importance\n\n static PR_TYP_JS = 'js';\n static PR_TYP_IMG = 'img';\n static PR_TYP_APP = 'app';\n\n static PR_S_TYP_R = 'r';\n\n static sortAscending = (\n a: BaseResourceParamType,\n b: BaseResourceParamType\n ): number => (a.o > b.o ? 1 : -1);\n\n // this data structure is returned by the api and stored in this key\n // {\"dId\":\"VNiBG7JNfoGAyvqxhxMqd\",\"mId\":\"JW0FRrCtAj9K7uyNmL1ht\",\"st\":0}\n static KEY_MP_IDL_VISITOR_ID_INFO = 'mp_idl_visitor_info';\n\n // visitor info data structure\n // {\"visitId\": \"123123sdfsf\", \"visitCt\": 1, \"visitDepth\": 1, visitVer: 1}\n static KEY_MP_IDL_VISIT_ID_INFO = 'mp_idl_visit_info';\n\n static KEY_MP_DEBUG_ID = 'mp_debug_id';\n}\n"],"mappings":";;AAAA,SAASA,cAAT,QAA+B,mBAA/B;AAGA,OAAO,MAAMC,SAAN,CAAgB;;gBAAVA,S,uBACgB,IAAIC,MAAJ,CAAW,0BAAX,C;;gBADhBD,S,uBAGgBD,cAAc,CACvC,gEADuC,EAEvC,EAFuC,C;;gBAH9BC,S,eAQQ,a;;gBARRA,S,cASO,c;;gBATPA,S,WAYI,G;;gBAZJA,S,iBAaU,G;;gBAbVA,S,YAcK,G;;gBAdLA,S,iBAeU,I;;gBAfVA,S,cAgBO,I;;gBAhBPA,S,eAiBQ,I;;gBAjBRA,S,eAmBQ,I;;gBAnBRA,S,gBAoBS,K;;gBApBTA,S,gBAqBS,K;;gBArBTA,S,gBAuBS,G;;gBAvBTA,S,mBAyBY,CACrBE,CADqB,EAErBC,CAFqB,KAGTD,CAAC,CAACE,CAAF,GAAMD,CAAC,CAACC,CAAR,GAAY,CAAZ,GAAgB,CAAC,C;;gBA5BpBJ,S,gCAgCyB,qB;;gBAhCzBA,S,8BAoCuB,mB;;gBApCvBA,S,qBAsCc,a"}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
|
+
import { Logger } from './logger';
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
|
+
import { DeviceType, getDeviceTypeAsync } from 'expo-device';
|
|
7
|
+
export class DataStore {
|
|
8
|
+
static async init(clientSdk) {
|
|
9
|
+
var _clientSdk$s;
|
|
10
|
+
|
|
11
|
+
this.clientSdk = clientSdk;
|
|
12
|
+
this.setMpEnv((clientSdk === null || clientSdk === void 0 ? void 0 : (_clientSdk$s = clientSdk.s) === null || _clientSdk$s === void 0 ? void 0 : _clientSdk$s.ev) === 'staging' ? 'stg' : 'prd');
|
|
13
|
+
|
|
14
|
+
if (typeof Platform !== 'undefined' && typeof Platform.OS !== 'undefined') {
|
|
15
|
+
this.devicePlatform = Platform.OS.toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const dType = await getDeviceTypeAsync();
|
|
19
|
+
|
|
20
|
+
if (dType === DeviceType.PHONE) {
|
|
21
|
+
this.deviceType = 'mobile';
|
|
22
|
+
} else if (dType === DeviceType.TABLET) {
|
|
23
|
+
this.deviceType = 'tablet';
|
|
24
|
+
} else {
|
|
25
|
+
this.deviceType = 'unknown';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.resetCollectorUrl(clientSdk.s.c_url, clientSdk.s.ev, clientSdk.s.v_id, clientSdk.s.p_id);
|
|
29
|
+
this.isDataStoreInitialized = true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static resetCollectorUrl(baseCollectorUrl, sdkEnv, vendorId, projectId) {
|
|
33
|
+
const tagsBaseUrl = `${baseCollectorUrl}/${sdkEnv === 'staging' ? 's' : 'p'}/${vendorId}/${projectId}`;
|
|
34
|
+
this.urls = {
|
|
35
|
+
tfUrl: tagsBaseUrl + '/sst',
|
|
36
|
+
errUrl: tagsBaseUrl + '/err',
|
|
37
|
+
rptUrl: tagsBaseUrl + '/report',
|
|
38
|
+
infoUrl: tagsBaseUrl + '/info',
|
|
39
|
+
baseUrl: baseCollectorUrl,
|
|
40
|
+
attrInfoUrl: baseCollectorUrl + `/idl/${vendorId}/attrInfo`,
|
|
41
|
+
idlUrl: baseCollectorUrl + `/idl/${vendorId}/idl${sdkEnv === 'staging' ? '-staging' : ''}`
|
|
42
|
+
};
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static enQueueTMFire(sseOnly, name, dcrName, eventId, dcrPayload) {
|
|
47
|
+
this.runQueue.push({
|
|
48
|
+
sseOnly,
|
|
49
|
+
name,
|
|
50
|
+
dcrName,
|
|
51
|
+
eventId,
|
|
52
|
+
dcrPayload
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static isDataStoreReady() {
|
|
57
|
+
return this.isDataStoreInitialized;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static getSdkPcKey() {
|
|
61
|
+
return this.clientSdk.pcKey;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static getSdkInitOptions() {
|
|
65
|
+
return this.sdkInitOptions;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static setSdkInitOptions(options) {
|
|
69
|
+
this.sdkInitOptions = options;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static deQueueTMFire() {
|
|
73
|
+
return this.runQueue.length > 0 ? this.runQueue.pop() : null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static isTagManagerProcessing() {
|
|
77
|
+
return this.isProcessing;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static setTagManagerProcessing(status) {
|
|
81
|
+
this.isProcessing = status;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static getSdkDataElements() {
|
|
85
|
+
var _this$clientSdk;
|
|
86
|
+
|
|
87
|
+
return ((_this$clientSdk = this.clientSdk) === null || _this$clientSdk === void 0 ? void 0 : _this$clientSdk.d) || {};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static getSdkQC() {
|
|
91
|
+
var _this$clientSdk2;
|
|
92
|
+
|
|
93
|
+
return ((_this$clientSdk2 = this.clientSdk) === null || _this$clientSdk2 === void 0 ? void 0 : _this$clientSdk2.qc) || [];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static hasOneSSTTag() {
|
|
97
|
+
return this.clientSdk.s.sst;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static getSSTDownStream() {
|
|
101
|
+
return this.clientSdk.s.dws_s_t;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static getClientDownStream() {
|
|
105
|
+
return this.clientSdk.s.dws_c_t;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static getClientSdk() {
|
|
109
|
+
return this.clientSdk;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static getSSTUrl() {
|
|
113
|
+
return this.urls.tfUrl;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static getAttrInfoUrl() {
|
|
117
|
+
return this.urls.attrInfoUrl;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static setVisitInfo(visitInfo) {
|
|
121
|
+
this.visitInfo = visitInfo;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static visitInfoToString() {
|
|
125
|
+
return this.visitInfo ? `${this.visitInfo.visitVer}|${this.visitInfo.visitId}|${this.visitInfo.visitTs}|${this.visitInfo.visitCt}|${this.visitInfo.visitDepth}` : undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static setVisitorInfo(visitorInfo) {
|
|
129
|
+
this.visitorInfo = visitorInfo;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static getDebugId() {
|
|
133
|
+
return this.debugId;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static getErrorReportUrl() {
|
|
137
|
+
return this.urls.errUrl;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static getIdlUrl() {
|
|
141
|
+
var _this$urls;
|
|
142
|
+
|
|
143
|
+
return (_this$urls = this.urls) === null || _this$urls === void 0 ? void 0 : _this$urls.idlUrl;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static getSdkVersion() {
|
|
147
|
+
// TODO: Fix this
|
|
148
|
+
return 'na';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static setDebugId(dbgId) {
|
|
152
|
+
this.debugId = dbgId;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static shouldFireSstForEvent(eventName) {
|
|
156
|
+
var _this$clientSdk3, _this$clientSdk3$sseM;
|
|
157
|
+
|
|
158
|
+
return ((_this$clientSdk3 = this.clientSdk) === null || _this$clientSdk3 === void 0 ? void 0 : (_this$clientSdk3$sseM = _this$clientSdk3.sseMpDlE) === null || _this$clientSdk3$sseM === void 0 ? void 0 : _this$clientSdk3$sseM.indexOf(eventName)) > -1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static getUrlInfo() {
|
|
162
|
+
return this.urls;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static getSdkTags() {
|
|
166
|
+
var _this$clientSdk4;
|
|
167
|
+
|
|
168
|
+
return (this === null || this === void 0 ? void 0 : (_this$clientSdk4 = this.clientSdk) === null || _this$clientSdk4 === void 0 ? void 0 : _this$clientSdk4.t) ?? {};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
static getSdkProviders() {
|
|
172
|
+
var _this$clientSdk5;
|
|
173
|
+
|
|
174
|
+
return (this === null || this === void 0 ? void 0 : (_this$clientSdk5 = this.clientSdk) === null || _this$clientSdk5 === void 0 ? void 0 : _this$clientSdk5.p) ?? {};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static getPrivacyCompliance() {
|
|
178
|
+
return this.prStatus;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
static setPrivacyCompliance(status) {
|
|
182
|
+
this.prStatus = status;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
static async storeData(key, value) {
|
|
186
|
+
await AsyncStorage.setItem(key, JSON.stringify(value));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
static async getDataFromStorage(key) {
|
|
190
|
+
const value = await AsyncStorage.getItem(key);
|
|
191
|
+
return value ? JSON.parse(value) : value;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static getDataElements() {
|
|
195
|
+
return this.dataElements;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static setDataElements(de) {
|
|
199
|
+
this.dataElements = de;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
static getPageLang() {
|
|
203
|
+
return this.pageLang;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static getDeviceOs() {
|
|
207
|
+
return this.devicePlatform;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static getDataElementHelpers() {
|
|
211
|
+
return {
|
|
212
|
+
log: Logger.logDbg,
|
|
213
|
+
err: Logger.logError
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
static getPageName() {
|
|
218
|
+
return this.getDataElementValue('page_name') || 'none';
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
static getDataElementValue(param) {
|
|
222
|
+
return this.dataElements[param];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
static setPageLang(lang) {
|
|
226
|
+
this.pageLang = lang || 'en';
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
static getSdkPageLangKey() {
|
|
230
|
+
return this.clientSdk.langKey;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
static setDataElement(key, value) {
|
|
234
|
+
this.dataElements[key] = value;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static setValidQc(qcList, qcInfo) {
|
|
238
|
+
this.validQcList = qcList;
|
|
239
|
+
this.validQcInfoList = qcInfo;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
static getValidQcList() {
|
|
243
|
+
return this.validQcList || [];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
static getValidQcInfo() {
|
|
247
|
+
return this.validQcInfoList || [];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
static setTransFunctions(elements) {
|
|
251
|
+
this.transFunctions = elements;
|
|
252
|
+
return this.transFunctions;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
static getTransFunctions() {
|
|
256
|
+
return this.transFunctions;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
static getOperatingSystem() {
|
|
260
|
+
return this.devicePlatform;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
static getVisitId() {
|
|
264
|
+
var _this$visitInfo;
|
|
265
|
+
|
|
266
|
+
return (_this$visitInfo = this.visitInfo) === null || _this$visitInfo === void 0 ? void 0 : _this$visitInfo.visitId;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
static getDeviceType() {
|
|
270
|
+
return this.deviceType;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
static getDeviceId() {
|
|
274
|
+
var _this$visitorInfo;
|
|
275
|
+
|
|
276
|
+
return (_this$visitorInfo = this.visitorInfo) === null || _this$visitorInfo === void 0 ? void 0 : _this$visitorInfo.dId;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
static getMpId() {
|
|
280
|
+
var _this$visitorInfo2;
|
|
281
|
+
|
|
282
|
+
return (_this$visitorInfo2 = this.visitorInfo) === null || _this$visitorInfo2 === void 0 ? void 0 : _this$visitorInfo2.mId;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
static getVisitorInfoAsString() {
|
|
286
|
+
return this.visitorInfo ? JSON.stringify(this.visitorInfo) : undefined;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
static getOrgId() {
|
|
290
|
+
var _this$clientSdk6, _this$clientSdk6$s;
|
|
291
|
+
|
|
292
|
+
return this === null || this === void 0 ? void 0 : (_this$clientSdk6 = this.clientSdk) === null || _this$clientSdk6 === void 0 ? void 0 : (_this$clientSdk6$s = _this$clientSdk6.s) === null || _this$clientSdk6$s === void 0 ? void 0 : _this$clientSdk6$s.v_id;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
static getCoreVersion() {
|
|
296
|
+
var _this$clientSdk7, _this$clientSdk7$s;
|
|
297
|
+
|
|
298
|
+
return this === null || this === void 0 ? void 0 : (_this$clientSdk7 = this.clientSdk) === null || _this$clientSdk7 === void 0 ? void 0 : (_this$clientSdk7$s = _this$clientSdk7.s) === null || _this$clientSdk7$s === void 0 ? void 0 : _this$clientSdk7$s.v;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
static getMpEnv() {
|
|
302
|
+
return this.mpEnvShort;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
static setMpEnv(shortEnv) {
|
|
306
|
+
this.mpEnvShort = shortEnv;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
_defineProperty(DataStore, "isDataStoreInitialized", false);
|
|
312
|
+
|
|
313
|
+
_defineProperty(DataStore, "dataElements", {});
|
|
314
|
+
|
|
315
|
+
_defineProperty(DataStore, "validQcList", void 0);
|
|
316
|
+
|
|
317
|
+
_defineProperty(DataStore, "validQcInfoList", []);
|
|
318
|
+
|
|
319
|
+
_defineProperty(DataStore, "transFunctions", {});
|
|
320
|
+
|
|
321
|
+
_defineProperty(DataStore, "prStatus", true);
|
|
322
|
+
|
|
323
|
+
_defineProperty(DataStore, "clientSdk", void 0);
|
|
324
|
+
|
|
325
|
+
_defineProperty(DataStore, "urls", void 0);
|
|
326
|
+
|
|
327
|
+
_defineProperty(DataStore, "debugId", void 0);
|
|
328
|
+
|
|
329
|
+
_defineProperty(DataStore, "visitorInfo", void 0);
|
|
330
|
+
|
|
331
|
+
_defineProperty(DataStore, "visitInfo", void 0);
|
|
332
|
+
|
|
333
|
+
_defineProperty(DataStore, "pageLang", 'en');
|
|
334
|
+
|
|
335
|
+
_defineProperty(DataStore, "mpEnvShort", void 0);
|
|
336
|
+
|
|
337
|
+
_defineProperty(DataStore, "devicePlatform", 'unknown');
|
|
338
|
+
|
|
339
|
+
_defineProperty(DataStore, "deviceType", 'mobile');
|
|
340
|
+
|
|
341
|
+
_defineProperty(DataStore, "runQueue", []);
|
|
342
|
+
|
|
343
|
+
_defineProperty(DataStore, "isProcessing", false);
|
|
344
|
+
|
|
345
|
+
_defineProperty(DataStore, "sdkInitOptions", void 0);
|
|
346
|
+
//# sourceMappingURL=data-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AsyncStorage","Logger","Platform","DeviceType","getDeviceTypeAsync","DataStore","init","clientSdk","setMpEnv","s","ev","OS","devicePlatform","toLowerCase","dType","PHONE","deviceType","TABLET","resetCollectorUrl","c_url","v_id","p_id","isDataStoreInitialized","baseCollectorUrl","sdkEnv","vendorId","projectId","tagsBaseUrl","urls","tfUrl","errUrl","rptUrl","infoUrl","baseUrl","attrInfoUrl","idlUrl","enQueueTMFire","sseOnly","name","dcrName","eventId","dcrPayload","runQueue","push","isDataStoreReady","getSdkPcKey","pcKey","getSdkInitOptions","sdkInitOptions","setSdkInitOptions","options","deQueueTMFire","length","pop","isTagManagerProcessing","isProcessing","setTagManagerProcessing","status","getSdkDataElements","d","getSdkQC","qc","hasOneSSTTag","sst","getSSTDownStream","dws_s_t","getClientDownStream","dws_c_t","getClientSdk","getSSTUrl","getAttrInfoUrl","setVisitInfo","visitInfo","visitInfoToString","visitVer","visitId","visitTs","visitCt","visitDepth","undefined","setVisitorInfo","visitorInfo","getDebugId","debugId","getErrorReportUrl","getIdlUrl","getSdkVersion","setDebugId","dbgId","shouldFireSstForEvent","eventName","sseMpDlE","indexOf","getUrlInfo","getSdkTags","t","getSdkProviders","p","getPrivacyCompliance","prStatus","setPrivacyCompliance","storeData","key","value","setItem","JSON","stringify","getDataFromStorage","getItem","parse","getDataElements","dataElements","setDataElements","de","getPageLang","pageLang","getDeviceOs","getDataElementHelpers","log","logDbg","err","logError","getPageName","getDataElementValue","param","setPageLang","lang","getSdkPageLangKey","langKey","setDataElement","setValidQc","qcList","qcInfo","validQcList","validQcInfoList","getValidQcList","getValidQcInfo","setTransFunctions","elements","transFunctions","getTransFunctions","getOperatingSystem","getVisitId","getDeviceType","getDeviceId","dId","getMpId","mId","getVisitorInfoAsString","getOrgId","getCoreVersion","v","getMpEnv","mpEnvShort","shortEnv"],"sources":["data-store.ts"],"sourcesContent":["import AsyncStorage from '@react-native-async-storage/async-storage';\nimport type {\n DeJsvHelper,\n MapLike,\n QcInfoItem,\n RunQueueModel,\n SdkInitOptions,\n UrlInfo,\n VisitInfo,\n VisitorInfo,\n} from './app-types';\nimport { Logger } from './logger';\nimport type {\n ClientSdkDeItem,\n ClientSdkPrItem,\n ClientSdkQcItem,\n ClientSdkTagItem,\n MpClientSdk,\n} from '../models/mp-client-sdk';\nimport { Platform } from 'react-native';\nimport { DeviceType, getDeviceTypeAsync } from 'expo-device';\n\nexport class DataStore {\n private static isDataStoreInitialized = false;\n private static dataElements: MapLike = {};\n private static validQcList: string[];\n private static validQcInfoList: Array<QcInfoItem> = [];\n private static transFunctions: MapLike = {};\n private static prStatus = true;\n private static clientSdk: MpClientSdk;\n private static urls: UrlInfo;\n private static debugId: string;\n private static visitorInfo: VisitorInfo;\n private static visitInfo: VisitInfo;\n private static pageLang = 'en';\n private static mpEnvShort: 'stg' | 'prd';\n private static devicePlatform = 'unknown';\n private static deviceType = 'mobile';\n private static runQueue: RunQueueModel[] = [];\n private static isProcessing = false;\n private static sdkInitOptions: SdkInitOptions;\n\n static async init(clientSdk: MpClientSdk): Promise<void> {\n this.clientSdk = clientSdk;\n this.setMpEnv(clientSdk?.s?.ev === 'staging' ? 'stg' : 'prd');\n if (typeof Platform !== 'undefined' && typeof Platform.OS !== 'undefined') {\n this.devicePlatform = Platform.OS.toLowerCase();\n }\n\n const dType = await getDeviceTypeAsync();\n if (dType === DeviceType.PHONE) {\n this.deviceType = 'mobile';\n } else if (dType === DeviceType.TABLET) {\n this.deviceType = 'tablet';\n } else {\n this.deviceType = 'unknown';\n }\n\n this.resetCollectorUrl(\n clientSdk.s.c_url,\n clientSdk.s.ev,\n clientSdk.s.v_id,\n clientSdk.s.p_id\n );\n this.isDataStoreInitialized = true;\n }\n\n static resetCollectorUrl(\n baseCollectorUrl: string,\n sdkEnv: string,\n vendorId: string,\n projectId: string\n ): boolean {\n const tagsBaseUrl = `${baseCollectorUrl}/${\n sdkEnv === 'staging' ? 's' : 'p'\n }/${vendorId}/${projectId}`;\n this.urls = {\n tfUrl: tagsBaseUrl + '/sst',\n errUrl: tagsBaseUrl + '/err',\n rptUrl: tagsBaseUrl + '/report',\n infoUrl: tagsBaseUrl + '/info',\n baseUrl: baseCollectorUrl,\n attrInfoUrl: baseCollectorUrl + `/idl/${vendorId}/attrInfo`,\n idlUrl:\n baseCollectorUrl +\n `/idl/${vendorId}/idl${sdkEnv === 'staging' ? '-staging' : ''}`,\n };\n return true;\n }\n\n static enQueueTMFire(\n sseOnly: boolean,\n name: string,\n dcrName: string,\n eventId: string,\n dcrPayload?: Record<string, any>\n ): void {\n this.runQueue.push({ sseOnly, name, dcrName, eventId, dcrPayload });\n }\n\n static isDataStoreReady(): boolean {\n return this.isDataStoreInitialized;\n }\n\n static getSdkPcKey(): string {\n return this.clientSdk.pcKey;\n }\n\n static getSdkInitOptions(): SdkInitOptions {\n return this.sdkInitOptions;\n }\n\n static setSdkInitOptions(options: SdkInitOptions): void {\n this.sdkInitOptions = options;\n }\n\n static deQueueTMFire(): RunQueueModel {\n return this.runQueue.length > 0 ? this.runQueue.pop() : null;\n }\n\n static isTagManagerProcessing(): boolean {\n return this.isProcessing;\n }\n\n static setTagManagerProcessing(status: boolean): void {\n this.isProcessing = status;\n }\n\n static getSdkDataElements(): MapLike<ClientSdkDeItem> {\n return this.clientSdk?.d || {};\n }\n\n static getSdkQC(): ClientSdkQcItem[] {\n return this.clientSdk?.qc || [];\n }\n\n static hasOneSSTTag(): boolean {\n return this.clientSdk.s.sst;\n }\n\n static getSSTDownStream(): 'j' | 'n' {\n return this.clientSdk.s.dws_s_t;\n }\n\n static getClientDownStream(): 'j' | 'n' {\n return this.clientSdk.s.dws_c_t;\n }\n\n static getClientSdk(): MpClientSdk {\n return this.clientSdk;\n }\n\n static getSSTUrl(): string {\n return this.urls.tfUrl;\n }\n\n static getAttrInfoUrl(): string {\n return this.urls.attrInfoUrl;\n }\n\n static setVisitInfo(visitInfo: VisitInfo): void {\n this.visitInfo = visitInfo;\n }\n\n static visitInfoToString(): string {\n return this.visitInfo\n ? `${this.visitInfo.visitVer}|${this.visitInfo.visitId}|${this.visitInfo.visitTs}|${this.visitInfo.visitCt}|${this.visitInfo.visitDepth}`\n : undefined;\n }\n\n static setVisitorInfo(visitorInfo: VisitorInfo): void {\n this.visitorInfo = visitorInfo;\n }\n\n static getDebugId(): string {\n return this.debugId;\n }\n\n static getErrorReportUrl(): string {\n return this.urls.errUrl;\n }\n\n static getIdlUrl(): string {\n return this.urls?.idlUrl;\n }\n\n static getSdkVersion(): string {\n // TODO: Fix this\n return 'na';\n }\n\n static setDebugId(dbgId: string): void {\n this.debugId = dbgId;\n }\n\n static shouldFireSstForEvent(eventName: string): boolean {\n return this.clientSdk?.sseMpDlE?.indexOf(eventName) > -1;\n }\n\n static getUrlInfo(): UrlInfo {\n return this.urls;\n }\n\n static getSdkTags(): MapLike<ClientSdkTagItem> {\n return this?.clientSdk?.t ?? {};\n }\n\n static getSdkProviders(): MapLike<ClientSdkPrItem> {\n return this?.clientSdk?.p ?? {};\n }\n\n static getPrivacyCompliance(): boolean {\n return this.prStatus;\n }\n\n static setPrivacyCompliance(status: boolean): void {\n this.prStatus = status;\n }\n\n static async storeData(key: string, value: any): Promise<void> {\n await AsyncStorage.setItem(key, JSON.stringify(value));\n }\n\n static async getDataFromStorage<T>(key: string): Promise<T> {\n const value = await AsyncStorage.getItem(key);\n return value ? JSON.parse(value) : value;\n }\n\n static getDataElements(): MapLike {\n return this.dataElements;\n }\n\n static setDataElements(de: MapLike): void {\n this.dataElements = de;\n }\n\n static getPageLang(): string {\n return this.pageLang;\n }\n\n static getDeviceOs(): string {\n return this.devicePlatform;\n }\n\n static getDataElementHelpers(): DeJsvHelper {\n return {\n log: Logger.logDbg,\n err: Logger.logError,\n };\n }\n\n static getPageName(): string {\n return (this.getDataElementValue('page_name') as string) || 'none';\n }\n\n static getDataElementValue(param: string): string | boolean | number {\n return this.dataElements[param];\n }\n\n static setPageLang(lang: string): void {\n this.pageLang = lang || 'en';\n }\n\n static getSdkPageLangKey(): string {\n return this.clientSdk.langKey;\n }\n\n static setDataElement(key: string, value: any): void {\n this.dataElements[key] = value;\n }\n\n static setValidQc(qcList: string[], qcInfo: QcInfoItem[]): void {\n this.validQcList = qcList;\n this.validQcInfoList = qcInfo;\n }\n\n static getValidQcList(): string[] {\n return this.validQcList || [];\n }\n\n static getValidQcInfo(): QcInfoItem[] {\n return this.validQcInfoList || [];\n }\n\n static setTransFunctions(elements: MapLike): MapLike {\n this.transFunctions = elements;\n return this.transFunctions;\n }\n\n static getTransFunctions(): MapLike {\n return this.transFunctions;\n }\n\n static getOperatingSystem(): string {\n return this.devicePlatform;\n }\n\n static getVisitId(): string {\n return this.visitInfo?.visitId;\n }\n\n static getDeviceType(): string {\n return this.deviceType;\n }\n\n static getDeviceId(): string {\n return this.visitorInfo?.dId;\n }\n\n static getMpId(): string {\n return this.visitorInfo?.mId;\n }\n\n static getVisitorInfoAsString(): string | undefined {\n return this.visitorInfo ? JSON.stringify(this.visitorInfo) : undefined;\n }\n\n static getOrgId(): string {\n return this?.clientSdk?.s?.v_id;\n }\n\n static getCoreVersion(): string {\n return this?.clientSdk?.s?.v;\n }\n\n static getMpEnv(): 'stg' | 'prd' {\n return this.mpEnvShort;\n }\n\n static setMpEnv(shortEnv: 'stg' | 'prd'): void {\n this.mpEnvShort = shortEnv;\n }\n}\n"],"mappings":";;AAAA,OAAOA,YAAP,MAAyB,2CAAzB;AAWA,SAASC,MAAT,QAAuB,UAAvB;AAQA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,EAAqBC,kBAArB,QAA+C,aAA/C;AAEA,OAAO,MAAMC,SAAN,CAAgB;EAoBJ,aAAJC,IAAI,CAACC,SAAD,EAAwC;IAAA;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