@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,144 @@
|
|
|
1
|
+
import { Logger } from '../common/logger';
|
|
2
|
+
import { DataStore } from '../common/data-store';
|
|
3
|
+
import { Constants } from '../common/constants';
|
|
4
|
+
import { Reporter } from '../common/reporter';
|
|
5
|
+
import { NetworkService } from '../common/network-service';
|
|
6
|
+
import { Utils } from '../common/utils';
|
|
7
|
+
import { EventBus } from '../common/event-bus';
|
|
8
|
+
export class VisitIdProcessor {
|
|
9
|
+
static async init() {
|
|
10
|
+
await this.initIdlEventListener();
|
|
11
|
+
await this.initDebugId();
|
|
12
|
+
await this.setOrResetVisitorId();
|
|
13
|
+
await this.setOrResetVisitInfo();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static async initIdlEventListener() {
|
|
17
|
+
EventBus.on('mp_idl_app_event', (channelName, eventPayload) => {
|
|
18
|
+
try {
|
|
19
|
+
if (!channelName || !eventPayload) {
|
|
20
|
+
Logger.logError('Both event name and event payload is mandatory for processing idl events');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const eventName = eventPayload.client_ev_name;
|
|
25
|
+
const attrInfoPayload = eventPayload.client_ev_payload ?? {};
|
|
26
|
+
const deepPayload = (attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.payload) ?? {}; // is_entry, app_type,
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
deepPayload['org_id'] = eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.org_id;
|
|
30
|
+
deepPayload['event_id'] = eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.event_id;
|
|
31
|
+
deepPayload['event_ts'] = eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.event_ts;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
Logger.logError('Error enhancing internal attr payload');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const attrPayload = {
|
|
37
|
+
pu: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.page_url,
|
|
38
|
+
ru: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.campaign_ref,
|
|
39
|
+
pt: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.page_title,
|
|
40
|
+
en: attrInfoPayload.event_name,
|
|
41
|
+
cid: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.campaign_id,
|
|
42
|
+
rs: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.report_suite,
|
|
43
|
+
v: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.client_sdk_version,
|
|
44
|
+
vidl: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.idl_version,
|
|
45
|
+
ev: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.event_val,
|
|
46
|
+
ep: deepPayload,
|
|
47
|
+
at: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.app_type,
|
|
48
|
+
evId: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.event_id,
|
|
49
|
+
evTs: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.event_ts,
|
|
50
|
+
orgId: attrInfoPayload === null || attrInfoPayload === void 0 ? void 0 : attrInfoPayload.org_id,
|
|
51
|
+
_mp_vid: DataStore.visitInfoToString(),
|
|
52
|
+
_lmid: DataStore.getMpId(),
|
|
53
|
+
_ldid: DataStore.getDeviceId(),
|
|
54
|
+
_mpidl: JSON.stringify(DataStore.getVisitorInfoAsString()),
|
|
55
|
+
is_entry: attrInfoPayload.is_entry ?? 0,
|
|
56
|
+
app_type: attrInfoPayload.app_type
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if (eventName === 'al') {
|
|
60
|
+
attrPayload.pid = eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.profile_id;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Reporter.postAttrInfo(attrPayload);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
Logger.logError('Error processing idl event: ', err);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async initDebugId() {
|
|
71
|
+
try {
|
|
72
|
+
let debugId = await DataStore.getDataFromStorage(Constants.KEY_MP_DEBUG_ID);
|
|
73
|
+
|
|
74
|
+
if (!debugId) {
|
|
75
|
+
debugId = Utils.getUniqueID();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
await DataStore.storeData(Constants.KEY_MP_DEBUG_ID, debugId);
|
|
79
|
+
DataStore.setDebugId(debugId);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
Logger.logError('Error initializing debug id.', err);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static async setOrResetVisitInfo() {
|
|
86
|
+
try {
|
|
87
|
+
const visitInfo = await DataStore.getDataFromStorage(Constants.KEY_MP_IDL_VISIT_ID_INFO);
|
|
88
|
+
|
|
89
|
+
if (!visitInfo) {
|
|
90
|
+
// may be first time visit, setup a new visit info object and return
|
|
91
|
+
const newVisitInfo = {
|
|
92
|
+
visitId: Utils.getUniqueID(),
|
|
93
|
+
visitCt: 1,
|
|
94
|
+
visitDepth: 1,
|
|
95
|
+
visitTs: Date.now(),
|
|
96
|
+
visitVer: 1
|
|
97
|
+
};
|
|
98
|
+
DataStore.setVisitInfo(newVisitInfo);
|
|
99
|
+
await DataStore.storeData(Constants.KEY_MP_IDL_VISIT_ID_INFO, newVisitInfo);
|
|
100
|
+
} else {
|
|
101
|
+
// reset visit id anyway, but retain the visitCt and depth setting
|
|
102
|
+
visitInfo.visitId = Utils.getUniqueID();
|
|
103
|
+
visitInfo.visitCt = visitInfo.visitCt + 1;
|
|
104
|
+
visitInfo.visitDepth = 1;
|
|
105
|
+
visitInfo.visitTs = Date.now();
|
|
106
|
+
visitInfo.visitVer = 1;
|
|
107
|
+
DataStore.setVisitInfo(visitInfo);
|
|
108
|
+
await DataStore.storeData(Constants.KEY_MP_IDL_VISIT_ID_INFO, visitInfo);
|
|
109
|
+
}
|
|
110
|
+
} catch (err) {
|
|
111
|
+
Logger.logError(err);
|
|
112
|
+
DataStore.setVisitInfo(null);
|
|
113
|
+
Reporter.reportError('setOrResetVisitInfo', err);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static async setOrResetVisitorId() {
|
|
118
|
+
try {
|
|
119
|
+
const visitorInfoData = await DataStore.getDataFromStorage(Constants.KEY_MP_IDL_VISITOR_ID_INFO);
|
|
120
|
+
|
|
121
|
+
if (!visitorInfoData) {
|
|
122
|
+
Logger.logDbg('VisitorInfo not found. Refreshing from server'); // get a new visit id and device id from server and store it in storage
|
|
123
|
+
|
|
124
|
+
const apiVisitInfo = await NetworkService.fetchIdlInfo(DataStore.getIdlUrl());
|
|
125
|
+
|
|
126
|
+
if (!apiVisitInfo) {
|
|
127
|
+
return;
|
|
128
|
+
} else {
|
|
129
|
+
DataStore.setVisitorInfo(apiVisitInfo); // store to db as well
|
|
130
|
+
|
|
131
|
+
await DataStore.storeData(Constants.KEY_MP_IDL_VISITOR_ID_INFO, apiVisitInfo);
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
DataStore.setVisitorInfo(visitorInfoData);
|
|
135
|
+
}
|
|
136
|
+
} catch (err) {
|
|
137
|
+
Logger.logError(err);
|
|
138
|
+
DataStore.setVisitorInfo(null);
|
|
139
|
+
Reporter.reportError('setOrResetVisitorId', err);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=visit-id.processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Logger","DataStore","Constants","Reporter","NetworkService","Utils","EventBus","VisitIdProcessor","init","initIdlEventListener","initDebugId","setOrResetVisitorId","setOrResetVisitInfo","on","channelName","eventPayload","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","visitInfoToString","_lmid","getMpId","_ldid","getDeviceId","_mpidl","JSON","stringify","getVisitorInfoAsString","is_entry","pid","profile_id","postAttrInfo","err","debugId","getDataFromStorage","KEY_MP_DEBUG_ID","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","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,SAASA,MAAT,QAAuB,kBAAvB;AACA,SAASC,SAAT,QAA0B,sBAA1B;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,cAAT,QAA+B,2BAA/B;AAEA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,QAAT,QAAyB,qBAAzB;AAEA,OAAO,MAAMC,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;IACjDH,QAAQ,CAACO,EAAT,CACE,kBADF,EAEE,CAACC,WAAD,EAAsBC,YAAtB,KAA+D;MAC7D,IAAI;QACF,IAAI,CAACD,WAAD,IAAgB,CAACC,YAArB,EAAmC;UACjCf,MAAM,CAACgB,QAAP,CACE,0EADF;UAGA;QACD;;QAED,MAAMC,SAAS,GAAGF,YAAY,CAACG,cAA/B;QACA,MAAMC,eAAoB,GAAGJ,YAAY,CAACK,iBAAb,IAAkC,EAA/D;QACA,MAAMC,WAAgB,GAAG,CAAAF,eAAe,SAAf,IAAAA,eAAe,WAAf,YAAAA,eAAe,CAAEG,OAAjB,KAA4B,EAArD,CAVE,CAYF;;QACA,IAAI;UACFD,WAAW,CAAC,QAAD,CAAX,GAAwBN,YAAxB,aAAwBA,YAAxB,uBAAwBA,YAA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xF,SAAS,CAACyF,SAAV,EADyB,CAA3B;;QAGA,IAAI,CAACF,YAAL,EAAmB;UACjB;QACD,CAFD,MAEO;UACLvF,SAAS,CAAC0F,cAAV,CAAyBH,YAAzB,EADK,CAEL;;UACA,MAAMvF,SAAS,CAACsE,SAAV,CACJrE,SAAS,CAACoF,0BADN,EAEJE,YAFI,CAAN;QAID;MACF,CAhBD,MAgBO;QACLvF,SAAS,CAAC0F,cAAV,CAAyBN,eAAzB;MACD;IACF,CAxBD,CAwBE,OAAOnB,GAAP,EAAY;MACZlE,MAAM,CAACgB,QAAP,CAAgBkD,GAAhB;MACAjE,SAAS,CAAC0F,cAAV,CAAyB,IAAzB;MACAxF,QAAQ,CAACiF,WAAT,CAAqB,qBAArB,EAA4ClB,GAA5C;IACD;EACF;;AAzJ2B"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Logger } from './logger';
|
|
2
|
+
export interface MapLike<T = any> {
|
|
3
|
+
[key: string]: T;
|
|
4
|
+
}
|
|
5
|
+
export interface RunQueueModel {
|
|
6
|
+
sseOnly: boolean;
|
|
7
|
+
name: string;
|
|
8
|
+
dcrName: string;
|
|
9
|
+
eventId: string;
|
|
10
|
+
dcrPayload?: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
export declare type TypedAny = Record<string, string | number | boolean | string[] | boolean[] | number[] | Record<string, string | number | boolean | string[] | boolean[] | number[]>>;
|
|
13
|
+
export declare type EventProcessorFn = (payload: TypedAny) => void;
|
|
14
|
+
export interface AppCustomerInfo {
|
|
15
|
+
first_name?: string;
|
|
16
|
+
last_name?: string;
|
|
17
|
+
email?: string;
|
|
18
|
+
phone_number: number;
|
|
19
|
+
country_code: number;
|
|
20
|
+
city?: string;
|
|
21
|
+
state?: string;
|
|
22
|
+
country?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AppPageLoad {
|
|
25
|
+
page_name: string;
|
|
26
|
+
is_entry?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface DeJsvHelper {
|
|
29
|
+
log: typeof Logger.logDbg;
|
|
30
|
+
err: typeof Logger.logError;
|
|
31
|
+
}
|
|
32
|
+
export interface QcInfoItem {
|
|
33
|
+
nm: string;
|
|
34
|
+
id: string;
|
|
35
|
+
st: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface TagInfoItem {
|
|
38
|
+
id: string;
|
|
39
|
+
nm: string;
|
|
40
|
+
pr: string;
|
|
41
|
+
prNm: string;
|
|
42
|
+
status: boolean;
|
|
43
|
+
qc: string | string[];
|
|
44
|
+
}
|
|
45
|
+
export declare type ReplaceMode = 'kph' | 'rph';
|
|
46
|
+
export interface HydrateTagInfo {
|
|
47
|
+
isInError: boolean;
|
|
48
|
+
content: string | number | null;
|
|
49
|
+
errCd: string;
|
|
50
|
+
errMsg: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ReportTagItem {
|
|
53
|
+
st: 200 | 900 | 1000 | number;
|
|
54
|
+
t: string;
|
|
55
|
+
p: string;
|
|
56
|
+
tNm: string;
|
|
57
|
+
req: any;
|
|
58
|
+
}
|
|
59
|
+
export interface Report {
|
|
60
|
+
envName: string;
|
|
61
|
+
envId: string;
|
|
62
|
+
pname?: string;
|
|
63
|
+
evt: string;
|
|
64
|
+
evtId: string;
|
|
65
|
+
dt?: number;
|
|
66
|
+
ln?: number;
|
|
67
|
+
bw?: number;
|
|
68
|
+
dm?: string;
|
|
69
|
+
items: ReportTagItem[];
|
|
70
|
+
tagCt: number;
|
|
71
|
+
dws: 'j' | 'n';
|
|
72
|
+
v: string;
|
|
73
|
+
}
|
|
74
|
+
export interface UrlInfo {
|
|
75
|
+
tfUrl: string;
|
|
76
|
+
errUrl: string;
|
|
77
|
+
rptUrl: string;
|
|
78
|
+
infoUrl: string;
|
|
79
|
+
baseUrl: string;
|
|
80
|
+
attrInfoUrl: string;
|
|
81
|
+
idlUrl: string;
|
|
82
|
+
}
|
|
83
|
+
export interface VisitInfo {
|
|
84
|
+
visitId: string;
|
|
85
|
+
visitTs: number;
|
|
86
|
+
visitCt: number;
|
|
87
|
+
visitDepth: number;
|
|
88
|
+
visitVer: number;
|
|
89
|
+
}
|
|
90
|
+
export interface VisitorInfo {
|
|
91
|
+
dId: string;
|
|
92
|
+
mId: string;
|
|
93
|
+
st: number;
|
|
94
|
+
}
|
|
95
|
+
export interface SdkInitOptions {
|
|
96
|
+
orgId: string;
|
|
97
|
+
env: string;
|
|
98
|
+
projectId: string;
|
|
99
|
+
baseUrl: string;
|
|
100
|
+
}
|
|
101
|
+
export declare type EventBusCallback = (event: string, payload: any) => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BaseResourceParamType } from '../models/mp-client-sdk';
|
|
2
|
+
export declare class Constants {
|
|
3
|
+
static PLACEHOLDER_REGEX: RegExp;
|
|
4
|
+
static LARGE_RANDOM_POOL: (size?: number) => string;
|
|
5
|
+
static MP_DL_EVT: string;
|
|
6
|
+
static CUST_EVT: string;
|
|
7
|
+
static ST_OK: number;
|
|
8
|
+
static ST_VAL_FAIL: number;
|
|
9
|
+
static ST_ERR: number;
|
|
10
|
+
static ST_DEP_FAIL: number;
|
|
11
|
+
static ST_PR_BL: number;
|
|
12
|
+
static ST_PR_EXC: number;
|
|
13
|
+
static PR_TYP_JS: string;
|
|
14
|
+
static PR_TYP_IMG: string;
|
|
15
|
+
static PR_TYP_APP: string;
|
|
16
|
+
static PR_S_TYP_R: string;
|
|
17
|
+
static sortAscending: (a: BaseResourceParamType, b: BaseResourceParamType) => number;
|
|
18
|
+
static KEY_MP_IDL_VISITOR_ID_INFO: string;
|
|
19
|
+
static KEY_MP_IDL_VISIT_ID_INFO: string;
|
|
20
|
+
static KEY_MP_DEBUG_ID: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { DeJsvHelper, MapLike, QcInfoItem, RunQueueModel, SdkInitOptions, UrlInfo, VisitInfo, VisitorInfo } from './app-types';
|
|
2
|
+
import type { ClientSdkDeItem, ClientSdkPrItem, ClientSdkQcItem, ClientSdkTagItem, MpClientSdk } from '../models/mp-client-sdk';
|
|
3
|
+
export declare class DataStore {
|
|
4
|
+
private static isDataStoreInitialized;
|
|
5
|
+
private static dataElements;
|
|
6
|
+
private static validQcList;
|
|
7
|
+
private static validQcInfoList;
|
|
8
|
+
private static transFunctions;
|
|
9
|
+
private static prStatus;
|
|
10
|
+
private static clientSdk;
|
|
11
|
+
private static urls;
|
|
12
|
+
private static debugId;
|
|
13
|
+
private static visitorInfo;
|
|
14
|
+
private static visitInfo;
|
|
15
|
+
private static pageLang;
|
|
16
|
+
private static mpEnvShort;
|
|
17
|
+
private static devicePlatform;
|
|
18
|
+
private static deviceType;
|
|
19
|
+
private static runQueue;
|
|
20
|
+
private static isProcessing;
|
|
21
|
+
private static sdkInitOptions;
|
|
22
|
+
static init(clientSdk: MpClientSdk): Promise<void>;
|
|
23
|
+
static resetCollectorUrl(baseCollectorUrl: string, sdkEnv: string, vendorId: string, projectId: string): boolean;
|
|
24
|
+
static enQueueTMFire(sseOnly: boolean, name: string, dcrName: string, eventId: string, dcrPayload?: Record<string, any>): void;
|
|
25
|
+
static isDataStoreReady(): boolean;
|
|
26
|
+
static getSdkPcKey(): string;
|
|
27
|
+
static getSdkInitOptions(): SdkInitOptions;
|
|
28
|
+
static setSdkInitOptions(options: SdkInitOptions): void;
|
|
29
|
+
static deQueueTMFire(): RunQueueModel;
|
|
30
|
+
static isTagManagerProcessing(): boolean;
|
|
31
|
+
static setTagManagerProcessing(status: boolean): void;
|
|
32
|
+
static getSdkDataElements(): MapLike<ClientSdkDeItem>;
|
|
33
|
+
static getSdkQC(): ClientSdkQcItem[];
|
|
34
|
+
static hasOneSSTTag(): boolean;
|
|
35
|
+
static getSSTDownStream(): 'j' | 'n';
|
|
36
|
+
static getClientDownStream(): 'j' | 'n';
|
|
37
|
+
static getClientSdk(): MpClientSdk;
|
|
38
|
+
static getSSTUrl(): string;
|
|
39
|
+
static getAttrInfoUrl(): string;
|
|
40
|
+
static setVisitInfo(visitInfo: VisitInfo): void;
|
|
41
|
+
static visitInfoToString(): string;
|
|
42
|
+
static setVisitorInfo(visitorInfo: VisitorInfo): void;
|
|
43
|
+
static getDebugId(): string;
|
|
44
|
+
static getErrorReportUrl(): string;
|
|
45
|
+
static getIdlUrl(): string;
|
|
46
|
+
static getSdkVersion(): string;
|
|
47
|
+
static setDebugId(dbgId: string): void;
|
|
48
|
+
static shouldFireSstForEvent(eventName: string): boolean;
|
|
49
|
+
static getUrlInfo(): UrlInfo;
|
|
50
|
+
static getSdkTags(): MapLike<ClientSdkTagItem>;
|
|
51
|
+
static getSdkProviders(): MapLike<ClientSdkPrItem>;
|
|
52
|
+
static getPrivacyCompliance(): boolean;
|
|
53
|
+
static setPrivacyCompliance(status: boolean): void;
|
|
54
|
+
static storeData(key: string, value: any): Promise<void>;
|
|
55
|
+
static getDataFromStorage<T>(key: string): Promise<T>;
|
|
56
|
+
static getDataElements(): MapLike;
|
|
57
|
+
static setDataElements(de: MapLike): void;
|
|
58
|
+
static getPageLang(): string;
|
|
59
|
+
static getDeviceOs(): string;
|
|
60
|
+
static getDataElementHelpers(): DeJsvHelper;
|
|
61
|
+
static getPageName(): string;
|
|
62
|
+
static getDataElementValue(param: string): string | boolean | number;
|
|
63
|
+
static setPageLang(lang: string): void;
|
|
64
|
+
static getSdkPageLangKey(): string;
|
|
65
|
+
static setDataElement(key: string, value: any): void;
|
|
66
|
+
static setValidQc(qcList: string[], qcInfo: QcInfoItem[]): void;
|
|
67
|
+
static getValidQcList(): string[];
|
|
68
|
+
static getValidQcInfo(): QcInfoItem[];
|
|
69
|
+
static setTransFunctions(elements: MapLike): MapLike;
|
|
70
|
+
static getTransFunctions(): MapLike;
|
|
71
|
+
static getOperatingSystem(): string;
|
|
72
|
+
static getVisitId(): string;
|
|
73
|
+
static getDeviceType(): string;
|
|
74
|
+
static getDeviceId(): string;
|
|
75
|
+
static getMpId(): string;
|
|
76
|
+
static getVisitorInfoAsString(): string | undefined;
|
|
77
|
+
static getOrgId(): string;
|
|
78
|
+
static getCoreVersion(): string;
|
|
79
|
+
static getMpEnv(): 'stg' | 'prd';
|
|
80
|
+
static setMpEnv(shortEnv: 'stg' | 'prd'): void;
|
|
81
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MapLike, SdkInitOptions, VisitorInfo } from './app-types';
|
|
2
|
+
export declare class NetworkService {
|
|
3
|
+
static fetchIdlInfo(url: string): Promise<VisitorInfo>;
|
|
4
|
+
static refreshClientSdkJson(sdkInitOptions: SdkInitOptions): Promise<void>;
|
|
5
|
+
static sendPostRequest(url: string, body: MapLike): void;
|
|
6
|
+
static sendGetRequest(url: string): void;
|
|
7
|
+
private static sendNetworkRequest;
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MapLike, Report, ReportTagItem } from './app-types';
|
|
2
|
+
export declare class Reporter {
|
|
3
|
+
static reportMap: MapLike<Report>;
|
|
4
|
+
static initReporter(envName: string, envId: string, deviceType: string, language: string, deviceOs: string, // device os is being used as a browser proxy
|
|
5
|
+
pageName: string, evtName: string, evtId: string, clientTagsDownStream: 'j' | 'n', clientSdkVersion: string, initialItems?: ReportTagItem[]): void;
|
|
6
|
+
static setExpectedTagCount(ct: number, evtId: string): void;
|
|
7
|
+
static reportItem(item: ReportTagItem, evtId: string): void;
|
|
8
|
+
static publishReport(evtId: string): void;
|
|
9
|
+
static reportError(methodMetaData: string, err: any): void;
|
|
10
|
+
static postSST(data: MapLike, envName: string, envId: string, serverTagDownStream: 'j' | 'n', eventName: string, evtId: string): Promise<void>;
|
|
11
|
+
static postAttrInfo(payload: MapLike): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BaseResourceParamType, TFType } from '../models/mp-client-sdk';
|
|
2
|
+
import type { MapLike } from './app-types';
|
|
3
|
+
export declare class Utils {
|
|
4
|
+
static triggerEvent(eventName: string, payload: any): void;
|
|
5
|
+
static sleep(delay?: number): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* deviceTypesMappings = {'1':'Desktop Web','2':'Mobile Web','3':'Tablet','4':'Other'};
|
|
8
|
+
* @param deviceType
|
|
9
|
+
*/
|
|
10
|
+
static dtToNum(deviceType: string): number;
|
|
11
|
+
/**
|
|
12
|
+
* static browserToOsMappings = {'101': 'ios','102': 'android', '7': 'Other'};
|
|
13
|
+
* @param browser
|
|
14
|
+
*/
|
|
15
|
+
static bwToNum(browser: string): number;
|
|
16
|
+
static langToNum(language: string): number;
|
|
17
|
+
static mergeMaps<T>(input: MapLike<T>, ...toMerge: Array<MapLike<T>>): MapLike<T>;
|
|
18
|
+
static applyTransformationResourceParam(paramValue: string, tf: TFType | undefined): any;
|
|
19
|
+
/**
|
|
20
|
+
* Verifies if the given 'toTest' string exists in any of the input array of strings.
|
|
21
|
+
* By default, this method does a case sensitive match unless specified by the ignoreCase param.
|
|
22
|
+
* @param toTest
|
|
23
|
+
* @param inputs
|
|
24
|
+
* @param ignoreCase - pass a value of 'true' to perform case-insensitive matching.
|
|
25
|
+
* @param fullMatch
|
|
26
|
+
*/
|
|
27
|
+
static isMatch(toTest: string, inputs: string[], ignoreCase: boolean, fullMatch: boolean): boolean;
|
|
28
|
+
static regExpEscape(input: string): string;
|
|
29
|
+
static convertToRegex(input: string, ignoreCase: boolean, fullMatch: boolean): RegExp;
|
|
30
|
+
static safeExecute(fn: (payload: any) => any, payload: any): any;
|
|
31
|
+
static getUniqueID(): string;
|
|
32
|
+
static unFlattenResourceParams<T extends BaseResourceParamType>(input: T[]): MapLike<T>;
|
|
33
|
+
static unflattenObject(obj: Record<string, any>): Record<string, any>;
|
|
34
|
+
static flattenObject(obj: any): Record<string, any>;
|
|
35
|
+
private static flatten;
|
|
36
|
+
static keyIdentity(key: any): any;
|
|
37
|
+
static isBuffer(obj: any): boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { EventProcessorFn, MapLike, TypedAny } from '../common/app-types';
|
|
2
|
+
export declare class MpDataLayerHelper {
|
|
3
|
+
private readonly dlEventName;
|
|
4
|
+
private readonly dlInitMode;
|
|
5
|
+
isReady: boolean;
|
|
6
|
+
_masterDataLayer: MapLike;
|
|
7
|
+
eventProcessors: Record<string, any>;
|
|
8
|
+
stateTracker: Array<any>;
|
|
9
|
+
dlInitEvent: string;
|
|
10
|
+
receivedInitialEvent: boolean;
|
|
11
|
+
eventQueue: Array<any>;
|
|
12
|
+
constructor(dlEventName: string, dlInitMode: string, dlInitEvent: string);
|
|
13
|
+
init(globalEventListeners: Record<string, EventProcessorFn>): void;
|
|
14
|
+
pushEvent(eventName: string, payload: MapLike): void;
|
|
15
|
+
processQItems(eventName: string, payload: MapLike): void;
|
|
16
|
+
/**
|
|
17
|
+
* Private Processor for 'set' command object
|
|
18
|
+
*/
|
|
19
|
+
setDl(obj: TypedAny | undefined): boolean;
|
|
20
|
+
getDl(): TypedAny;
|
|
21
|
+
/**
|
|
22
|
+
* Private event processor. Idea is that whenever an event is detected, we create a copy of the master data layer,
|
|
23
|
+
* add the event variables, and trigger the event requested when initializing the data layer helper
|
|
24
|
+
* @param eventName
|
|
25
|
+
* @param model
|
|
26
|
+
*/
|
|
27
|
+
eventProcessor(eventName: string, model: TypedAny | undefined): void;
|
|
28
|
+
overrideDlInitEvent(eventName: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Exposed method for registering custom processors for events
|
|
31
|
+
* @param eventType
|
|
32
|
+
* @param fn
|
|
33
|
+
*/
|
|
34
|
+
registerProcessor(eventType: string, fn: EventProcessorFn): void;
|
|
35
|
+
/**
|
|
36
|
+
* Exposed getter for getting values from data layer
|
|
37
|
+
* @param key
|
|
38
|
+
* @returns {*|undefined}
|
|
39
|
+
*/
|
|
40
|
+
get(key: string): MapLike | undefined;
|
|
41
|
+
getState(): TypedAny[];
|
|
42
|
+
hasEventHappened(key: string): boolean;
|
|
43
|
+
reset(): boolean;
|
|
44
|
+
ready(): void;
|
|
45
|
+
drainQueue(): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AppCustomerInfo, AppPageLoad, MapLike, SdkInitOptions } from './common/app-types';
|
|
2
|
+
import { EventBus } from './common/event-bus';
|
|
3
|
+
declare class MagicPixelImpl {
|
|
4
|
+
private static dl;
|
|
5
|
+
private static customerInfo;
|
|
6
|
+
private static firstAppLaunch;
|
|
7
|
+
static init(options: SdkInitOptions): Promise<void>;
|
|
8
|
+
static recordEvent(eventName: string, payload: MapLike): void;
|
|
9
|
+
static ready(): void;
|
|
10
|
+
static checkAndFireTM(): Promise<void>;
|
|
11
|
+
static runTM(sseOnly: boolean, triggerName: string, evtName: string, evtId: string, eventData?: Record<string, any>): Promise<void>;
|
|
12
|
+
static _fireTM(envName: string, envId: string, evtName: string, evtId: string): void;
|
|
13
|
+
static setCustomerInfo(customerInfo: AppCustomerInfo): void;
|
|
14
|
+
static recordPageLoad(pageLoadInfo: AppPageLoad): void;
|
|
15
|
+
}
|
|
16
|
+
export declare const MagicPixelEventBus: typeof EventBus;
|
|
17
|
+
export declare const MagicPixel: typeof MagicPixelImpl;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { MapLike } from '../common/app-types';
|
|
2
|
+
export interface ClientSdkDeItem {
|
|
3
|
+
nm: string;
|
|
4
|
+
typ: string;
|
|
5
|
+
key?: string;
|
|
6
|
+
def?: any;
|
|
7
|
+
cl?: boolean;
|
|
8
|
+
lwcase?: boolean;
|
|
9
|
+
fn?: (deHelper: any, input: any) => any;
|
|
10
|
+
isAsync?: boolean;
|
|
11
|
+
fnTOut?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare enum ParamResourceEncodingType {
|
|
14
|
+
URL_ENC = "URL_ENC",
|
|
15
|
+
BASE64 = "BASE64"
|
|
16
|
+
}
|
|
17
|
+
export declare enum ParamResourceHashType {
|
|
18
|
+
SHA256 = "SHA256",
|
|
19
|
+
SHA512 = "SHA512"
|
|
20
|
+
}
|
|
21
|
+
export declare enum ParamResourceValSrc {
|
|
22
|
+
STATIC = "STATIC",
|
|
23
|
+
DE = "DE",
|
|
24
|
+
TRANS_FUNC = "TRANS_FUNC",
|
|
25
|
+
CHILDREN = "CHILDREN",
|
|
26
|
+
TG_JSON_PATH = "TG_JSON_PATH"
|
|
27
|
+
}
|
|
28
|
+
export interface SdkParamEncodingTransformer {
|
|
29
|
+
nm: string;
|
|
30
|
+
eTyp: 'URL_ENC' | 'BASE64';
|
|
31
|
+
o?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface SdkParamHashingTransformer {
|
|
34
|
+
nm: string;
|
|
35
|
+
hTyp: ParamResourceHashType;
|
|
36
|
+
o?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface SdkParamIgnoreEmptyTransformer {
|
|
39
|
+
nm: string;
|
|
40
|
+
igEmpty: boolean;
|
|
41
|
+
o?: number;
|
|
42
|
+
}
|
|
43
|
+
export declare type TFType = (SdkParamHashingTransformer | SdkParamEncodingTransformer | SdkParamIgnoreEmptyTransformer)[];
|
|
44
|
+
export interface ClientSdkParamItem {
|
|
45
|
+
id: string;
|
|
46
|
+
nm: string;
|
|
47
|
+
rqd?: boolean;
|
|
48
|
+
tf?: TFType;
|
|
49
|
+
prLvl?: boolean;
|
|
50
|
+
pId?: string;
|
|
51
|
+
sv?: string;
|
|
52
|
+
de?: string;
|
|
53
|
+
tfId?: string;
|
|
54
|
+
children?: ClientSdkParamItem[];
|
|
55
|
+
exclude_from_req_body?: boolean;
|
|
56
|
+
fKey: string;
|
|
57
|
+
val_src: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ClientSdkQcCondition {
|
|
60
|
+
param: string;
|
|
61
|
+
i?: string[];
|
|
62
|
+
e?: string[];
|
|
63
|
+
i_ect: boolean;
|
|
64
|
+
i_cs?: boolean;
|
|
65
|
+
e_ect?: boolean;
|
|
66
|
+
e_cs?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface ClientSdkPrItem {
|
|
69
|
+
nm: string;
|
|
70
|
+
url?: string;
|
|
71
|
+
typ: string;
|
|
72
|
+
sTyp: string;
|
|
73
|
+
rParams?: MapLike<ClientSdkParamItem>;
|
|
74
|
+
hrs?: MapLike<string>;
|
|
75
|
+
ext?: string;
|
|
76
|
+
src?: string;
|
|
77
|
+
sync?: boolean;
|
|
78
|
+
pr: string;
|
|
79
|
+
chld?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface ClientSdkTfnItem {
|
|
82
|
+
nm: string;
|
|
83
|
+
fn: (input: any) => any;
|
|
84
|
+
rParams: MapLike<ClientSdkParamItem>;
|
|
85
|
+
}
|
|
86
|
+
export interface ClientSdkQcItem {
|
|
87
|
+
nm: string;
|
|
88
|
+
id: string;
|
|
89
|
+
c: ClientSdkQcCondition[];
|
|
90
|
+
}
|
|
91
|
+
export interface ClientSdkTagItem {
|
|
92
|
+
nm: string;
|
|
93
|
+
p: string;
|
|
94
|
+
url: string;
|
|
95
|
+
rParams?: MapLike<ClientSdkParamItem>;
|
|
96
|
+
st: number;
|
|
97
|
+
ex: number;
|
|
98
|
+
qc: string[];
|
|
99
|
+
img?: boolean;
|
|
100
|
+
wrk?: boolean;
|
|
101
|
+
chld?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface ClientSdkSettingsItem {
|
|
104
|
+
dbg: boolean;
|
|
105
|
+
err: boolean;
|
|
106
|
+
c_dom: string;
|
|
107
|
+
v_dur: number;
|
|
108
|
+
c_url: string;
|
|
109
|
+
bare_c_url?: string;
|
|
110
|
+
wh_idl?: string[];
|
|
111
|
+
wh_domains?: string[];
|
|
112
|
+
c_url_lkp?: MapLike<{
|
|
113
|
+
v: string;
|
|
114
|
+
ig: boolean;
|
|
115
|
+
ect: boolean;
|
|
116
|
+
}>;
|
|
117
|
+
v_id: string;
|
|
118
|
+
p_id: string;
|
|
119
|
+
ev: string;
|
|
120
|
+
ev_id: string;
|
|
121
|
+
dly: number;
|
|
122
|
+
sst: boolean;
|
|
123
|
+
idl: boolean;
|
|
124
|
+
c_typ?: string;
|
|
125
|
+
c_src?: string;
|
|
126
|
+
c_key?: string;
|
|
127
|
+
v: string;
|
|
128
|
+
bld_dt: string;
|
|
129
|
+
p_view?: boolean;
|
|
130
|
+
dws_c_t: 'j' | 'n';
|
|
131
|
+
dws_s_t: 'j' | 'n';
|
|
132
|
+
}
|
|
133
|
+
export interface BaseResourceParamType {
|
|
134
|
+
id: string;
|
|
135
|
+
nm: string;
|
|
136
|
+
o?: number;
|
|
137
|
+
pId?: string;
|
|
138
|
+
children?: BaseResourceParamType[];
|
|
139
|
+
}
|
|
140
|
+
export interface MpClientSdk {
|
|
141
|
+
langKey: string;
|
|
142
|
+
pcKey: string;
|
|
143
|
+
cDomKey?: string;
|
|
144
|
+
domWListKey?: string;
|
|
145
|
+
d: MapLike<ClientSdkDeItem>;
|
|
146
|
+
qc?: ClientSdkQcItem[];
|
|
147
|
+
t?: MapLike<ClientSdkTagItem>;
|
|
148
|
+
p?: MapLike<ClientSdkPrItem>;
|
|
149
|
+
tfn?: MapLike<ClientSdkTfnItem>;
|
|
150
|
+
s: ClientSdkSettingsItem;
|
|
151
|
+
dtmE: string[];
|
|
152
|
+
ctmE: string[];
|
|
153
|
+
mpDlE: string[];
|
|
154
|
+
sseDtmE: string[];
|
|
155
|
+
sseCtmE: string[];
|
|
156
|
+
sseMpDlE: string[];
|
|
157
|
+
}
|