@magicpixel/rn-mp-client-sdk 1.13.0 → 1.13.20
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/README.md +163 -14
- package/lib/commonjs/common/app-types.js.map +1 -1
- package/lib/commonjs/common/constants.js +11 -2
- package/lib/commonjs/common/constants.js.map +1 -1
- package/lib/commonjs/common/data-store.js +13 -30
- package/lib/commonjs/common/data-store.js.map +1 -1
- package/lib/commonjs/common/deeplink-helper.js +174 -0
- package/lib/commonjs/common/deeplink-helper.js.map +1 -0
- package/lib/commonjs/common/device-info-helper.js +168 -0
- package/lib/commonjs/common/device-info-helper.js.map +1 -0
- package/lib/commonjs/common/event-bus.js +39 -0
- package/lib/commonjs/common/event-bus.js.map +1 -1
- package/lib/commonjs/common/network-service.js +119 -15
- package/lib/commonjs/common/network-service.js.map +1 -1
- package/lib/commonjs/common/reporter.js +28 -10
- package/lib/commonjs/common/reporter.js.map +1 -1
- package/lib/commonjs/common/storage-helper.js +227 -0
- package/lib/commonjs/common/storage-helper.js.map +1 -0
- package/lib/commonjs/common/utils.js +20 -2
- package/lib/commonjs/common/utils.js.map +1 -1
- package/lib/commonjs/eedl/eedl.js +198 -44
- package/lib/commonjs/eedl/eedl.js.map +1 -1
- package/lib/commonjs/index.js +290 -48
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/mp-client-sdk.js +17 -10
- package/lib/commonjs/models/mp-client-sdk.js.map +1 -1
- package/lib/commonjs/processors/data-element.processor.js +51 -7
- package/lib/commonjs/processors/data-element.processor.js.map +1 -1
- package/lib/commonjs/processors/visit-id.processor.js +78 -15
- package/lib/commonjs/processors/visit-id.processor.js.map +1 -1
- package/lib/module/common/app-types.js.map +1 -1
- package/lib/module/common/constants.js +11 -2
- package/lib/module/common/constants.js.map +1 -1
- package/lib/module/common/data-store.js +13 -30
- package/lib/module/common/data-store.js.map +1 -1
- package/lib/module/common/deeplink-helper.js +168 -0
- package/lib/module/common/deeplink-helper.js.map +1 -0
- package/lib/module/common/device-info-helper.js +161 -0
- package/lib/module/common/device-info-helper.js.map +1 -0
- package/lib/module/common/event-bus.js +39 -0
- package/lib/module/common/event-bus.js.map +1 -1
- package/lib/module/common/network-service.js +119 -15
- package/lib/module/common/network-service.js.map +1 -1
- package/lib/module/common/reporter.js +29 -10
- package/lib/module/common/reporter.js.map +1 -1
- package/lib/module/common/storage-helper.js +221 -0
- package/lib/module/common/storage-helper.js.map +1 -0
- package/lib/module/common/utils.js +20 -2
- package/lib/module/common/utils.js.map +1 -1
- package/lib/module/eedl/eedl.js +198 -44
- package/lib/module/eedl/eedl.js.map +1 -1
- package/lib/module/index.js +279 -47
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/mp-client-sdk.js +16 -9
- package/lib/module/models/mp-client-sdk.js.map +1 -1
- package/lib/module/processors/data-element.processor.js +51 -7
- package/lib/module/processors/data-element.processor.js.map +1 -1
- package/lib/module/processors/visit-id.processor.js +78 -15
- package/lib/module/processors/visit-id.processor.js.map +1 -1
- package/lib/typescript/{common → src/common}/app-types.d.ts +29 -9
- package/lib/typescript/{common → src/common}/constants.d.ts +0 -1
- package/lib/typescript/{common → src/common}/data-store.d.ts +3 -8
- package/lib/typescript/src/common/deeplink-helper.d.ts +60 -0
- package/lib/typescript/src/common/device-info-helper.d.ts +54 -0
- package/lib/typescript/src/common/event-bus.d.ts +21 -0
- package/lib/typescript/src/common/network-service.d.ts +32 -0
- package/lib/typescript/src/common/storage-helper.d.ts +47 -0
- package/lib/typescript/{common → src/common}/utils.d.ts +7 -0
- package/lib/typescript/{eedl → src/eedl}/eedl.d.ts +43 -1
- package/lib/typescript/{index.d.ts → src/index.d.ts} +39 -5
- package/lib/typescript/{models → src/models}/mp-client-sdk.d.ts +7 -0
- package/lib/typescript/src/processors/visit-id.processor.d.ts +23 -0
- package/package.json +26 -37
- package/src/common/app-types.ts +32 -10
- package/src/common/constants.ts +0 -6
- package/src/common/data-store.ts +8 -30
- package/src/common/deeplink-helper.ts +181 -0
- package/src/common/device-info-helper.ts +190 -0
- package/src/common/event-bus.ts +39 -0
- package/src/common/network-service.ts +154 -21
- package/src/common/reporter.ts +31 -10
- package/src/common/storage-helper.ts +266 -0
- package/src/common/utils.ts +20 -2
- package/src/eedl/eedl.ts +225 -51
- package/src/index.tsx +332 -67
- package/src/models/mp-client-sdk.ts +8 -0
- package/src/processors/data-element.processor.ts +85 -7
- package/src/processors/visit-id.processor.ts +92 -22
- package/lib/commonjs/processors/trans-function.processor.js +0 -73
- package/lib/commonjs/processors/trans-function.processor.js.map +0 -1
- package/lib/module/processors/trans-function.processor.js +0 -66
- package/lib/module/processors/trans-function.processor.js.map +0 -1
- package/lib/typescript/common/event-bus.d.ts +0 -6
- package/lib/typescript/common/network-service.d.ts +0 -8
- package/lib/typescript/processors/trans-function.processor.d.ts +0 -12
- package/lib/typescript/processors/visit-id.processor.d.ts +0 -9
- package/src/processors/trans-function.processor.ts +0 -85
- /package/lib/typescript/{common → src/common}/logger.d.ts +0 -0
- /package/lib/typescript/{common → src/common}/reporter.d.ts +0 -0
- /package/lib/typescript/{models → src/models}/geo-api-response.d.ts +0 -0
- /package/lib/typescript/{processors → src/processors}/data-element.processor.d.ts +0 -0
- /package/lib/typescript/{processors → src/processors}/geo-location.processor.d.ts +0 -0
- /package/lib/typescript/{processors → src/processors}/qc.processor.d.ts +0 -0
- /package/lib/typescript/{processors → src/processors}/tag.processor.d.ts +0 -0
|
@@ -7,12 +7,35 @@ import type { VisitInfo, VisitorInfo } from '../common/app-types';
|
|
|
7
7
|
import { Utils } from '../common/utils';
|
|
8
8
|
|
|
9
9
|
export class VisitIdProcessor {
|
|
10
|
+
// Track if visitor ID fetch failed so we can retry on page_load
|
|
11
|
+
private static visitorIdFetchFailed = false;
|
|
12
|
+
|
|
10
13
|
static async init(orgId: string): Promise<void> {
|
|
11
14
|
await this.initDebugId(orgId);
|
|
12
15
|
await this.setOrResetVisitorId();
|
|
13
16
|
await this.setOrResetVisitInfo(false);
|
|
14
17
|
}
|
|
15
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Check if visitor ID needs to be retried
|
|
21
|
+
* Called on each page_load to retry if initial fetch failed
|
|
22
|
+
*/
|
|
23
|
+
static async retryVisitorIdIfNeeded(): Promise<void> {
|
|
24
|
+
if (!this.visitorIdFetchFailed) {
|
|
25
|
+
return; // No retry needed
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Logger.logDbg('Retrying visitor ID fetch on page_load...');
|
|
29
|
+
await this.setOrResetVisitorId();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Check if visitor ID is available
|
|
34
|
+
*/
|
|
35
|
+
static hasVisitorId(): boolean {
|
|
36
|
+
return !this.visitorIdFetchFailed && DataStore.getVisitorInfo() !== null;
|
|
37
|
+
}
|
|
38
|
+
|
|
16
39
|
static async isFirstOpenAfterInstall(): Promise<boolean> {
|
|
17
40
|
try {
|
|
18
41
|
const firstOpenFlag = await DataStore.getDataFromStorage<string>(
|
|
@@ -78,6 +101,7 @@ export class VisitIdProcessor {
|
|
|
78
101
|
|
|
79
102
|
if (!visitInfo) {
|
|
80
103
|
// may be first time visit, set up a new visit info object and return
|
|
104
|
+
// Initialize visitDepth to 0, will be incremented to 1 on first page_load
|
|
81
105
|
visitInfo = {
|
|
82
106
|
visitId: Utils.getUniqueID(),
|
|
83
107
|
visitCt: 1,
|
|
@@ -92,7 +116,7 @@ export class VisitIdProcessor {
|
|
|
92
116
|
visitInfo.visitDepth = (visitInfo?.visitDepth ?? 0) + 1;
|
|
93
117
|
} else {
|
|
94
118
|
visitInfo.visitCt = visitInfo.visitCt + 1;
|
|
95
|
-
visitInfo.visitDepth = 0;
|
|
119
|
+
visitInfo.visitDepth = 0; // Reset to 0, will be incremented to 1 on first page_load of new session
|
|
96
120
|
}
|
|
97
121
|
visitInfo.visitTs = Date.now();
|
|
98
122
|
visitInfo.visitVer = 1;
|
|
@@ -108,45 +132,91 @@ export class VisitIdProcessor {
|
|
|
108
132
|
}
|
|
109
133
|
}
|
|
110
134
|
|
|
111
|
-
|
|
112
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Synchronously increment visit depth in memory, persist to storage in background
|
|
137
|
+
* This prevents race conditions when multiple page_load events fire quickly
|
|
138
|
+
*/
|
|
139
|
+
static incrementVisitDepth(): void {
|
|
140
|
+
try {
|
|
141
|
+
// Read from in-memory cache (synchronous)
|
|
142
|
+
const visitInfo: VisitInfo = DataStore.getVisitInfo();
|
|
143
|
+
|
|
144
|
+
if (!visitInfo) {
|
|
145
|
+
Logger.logError('Visit info not initialized. Cannot increment depth.');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Increment depth synchronously in memory
|
|
150
|
+
visitInfo.visitDepth = (visitInfo.visitDepth ?? 0) + 1;
|
|
151
|
+
visitInfo.visitTs = Date.now();
|
|
152
|
+
|
|
153
|
+
// Update in-memory cache immediately (synchronous)
|
|
154
|
+
DataStore.setVisitInfo(visitInfo);
|
|
155
|
+
DataStore.addCommonCookie('x-mp-vid', DataStore.visitInfoToString());
|
|
156
|
+
|
|
157
|
+
Logger.logDbg('Visit depth incremented to:', visitInfo.visitDepth);
|
|
158
|
+
|
|
159
|
+
// Persist to AsyncStorage in background (fire and forget)
|
|
160
|
+
DataStore.storeData(Constants.KEY_MP_IDL_VISIT_ID_INFO, visitInfo).catch(
|
|
161
|
+
(err) => {
|
|
162
|
+
Logger.logError('Error persisting visit depth to storage:', err);
|
|
163
|
+
Reporter.reportError('incrementVisitDepth::persist', err);
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
} catch (err) {
|
|
167
|
+
Logger.logError('Error incrementing visit depth:', err);
|
|
168
|
+
Reporter.reportError('incrementVisitDepth', err);
|
|
169
|
+
}
|
|
113
170
|
}
|
|
114
171
|
|
|
115
172
|
static async setOrResetVisitorId(): Promise<void> {
|
|
116
173
|
try {
|
|
117
|
-
let visitorInfoData: VisitorInfo
|
|
118
|
-
|
|
119
|
-
|
|
174
|
+
let visitorInfoData: VisitorInfo | null =
|
|
175
|
+
await DataStore.getDataFromStorage(
|
|
176
|
+
Constants.KEY_MP_IDL_VISITOR_ID_INFO
|
|
177
|
+
);
|
|
120
178
|
|
|
121
179
|
if (
|
|
122
180
|
!visitorInfoData ||
|
|
123
181
|
(visitorInfoData && visitorInfoData?.mId.indexOf('-') === -1)
|
|
124
182
|
) {
|
|
125
|
-
Logger.logDbg('VisitorInfo not found.
|
|
183
|
+
Logger.logDbg('VisitorInfo not found. Fetching from server with retry');
|
|
126
184
|
// get a new visit id and device id from server and store it in storage
|
|
127
|
-
|
|
185
|
+
// Use retry method for better reliability
|
|
186
|
+
visitorInfoData = await NetworkService.fetchIdlInfoWithRetry(
|
|
128
187
|
DataStore.getIdlUrl()
|
|
129
188
|
);
|
|
130
189
|
}
|
|
131
190
|
|
|
132
191
|
if (!visitorInfoData) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
await DataStore.storeData(
|
|
138
|
-
Constants.KEY_MP_IDL_VISITOR_ID_INFO,
|
|
139
|
-
visitorInfoData
|
|
192
|
+
// Mark as failed so we can retry on page_load
|
|
193
|
+
this.visitorIdFetchFailed = true;
|
|
194
|
+
Logger.logError(
|
|
195
|
+
'Failed to fetch visitor ID after retries. Will retry on next page_load.'
|
|
140
196
|
);
|
|
141
|
-
|
|
142
|
-
const cookieValue = encodeURIComponent(JSON.stringify(visitorInfoData));
|
|
143
|
-
DataStore.addCommonCookie('x-mplidl', cookieValue);
|
|
144
|
-
DataStore.addCommonCookie('x-mpidl', cookieValue);
|
|
145
|
-
DataStore.addCommonCookie('x-lmid', visitorInfoData.mId);
|
|
146
|
-
DataStore.addCommonCookie('x-ldid', visitorInfoData.dId);
|
|
197
|
+
return;
|
|
147
198
|
}
|
|
199
|
+
|
|
200
|
+
// Success - clear the failure flag
|
|
201
|
+
this.visitorIdFetchFailed = false;
|
|
202
|
+
|
|
203
|
+
DataStore.setVisitorInfo(visitorInfoData);
|
|
204
|
+
// store to db as well
|
|
205
|
+
await DataStore.storeData(
|
|
206
|
+
Constants.KEY_MP_IDL_VISITOR_ID_INFO,
|
|
207
|
+
visitorInfoData
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
const cookieValue = encodeURIComponent(JSON.stringify(visitorInfoData));
|
|
211
|
+
DataStore.addCommonCookie('x-mplidl', cookieValue);
|
|
212
|
+
DataStore.addCommonCookie('x-mpidl', cookieValue);
|
|
213
|
+
DataStore.addCommonCookie('x-lmid', visitorInfoData.mId);
|
|
214
|
+
DataStore.addCommonCookie('x-ldid', visitorInfoData.dId);
|
|
215
|
+
|
|
216
|
+
Logger.logDbg('Visitor ID set successfully:', visitorInfoData.mId);
|
|
148
217
|
} catch (err) {
|
|
149
|
-
Logger.logError(err);
|
|
218
|
+
Logger.logError('Error in setOrResetVisitorId:', err);
|
|
219
|
+
this.visitorIdFetchFailed = true;
|
|
150
220
|
DataStore.setVisitorInfo(null);
|
|
151
221
|
Reporter.reportError('setOrResetVisitorId', err);
|
|
152
222
|
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TransFunctionProcessor = void 0;
|
|
7
|
-
var _dataStore = require("../common/data-store");
|
|
8
|
-
var _logger = require("../common/logger");
|
|
9
|
-
var _utils = require("../common/utils");
|
|
10
|
-
var _reporter = require("../common/reporter");
|
|
11
|
-
/**
|
|
12
|
-
* Process all the data elements at once, or if a set of keys are specified, processes only
|
|
13
|
-
* those keys and updates the dataElements object in global-fns file
|
|
14
|
-
* @param dataElements
|
|
15
|
-
* @param sdkTransFunctions
|
|
16
|
-
* @param optTfnKeys
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
class TransFunctionProcessor {
|
|
20
|
-
static processTransformationFunctions(dataElements, sdkTransFunctions, optTfnKeys) {
|
|
21
|
-
const tfn = _dataStore.DataStore.getTransFunctions();
|
|
22
|
-
const tfnKeys = optTfnKeys && optTfnKeys.length > 0 ? optTfnKeys : Object.keys(sdkTransFunctions);
|
|
23
|
-
try {
|
|
24
|
-
for (const key of tfnKeys) {
|
|
25
|
-
try {
|
|
26
|
-
const tfnItem = sdkTransFunctions[key];
|
|
27
|
-
/**
|
|
28
|
-
* How to process transformation functions
|
|
29
|
-
* 1) Find all the data elements in the resource params of trans function
|
|
30
|
-
* 2) make them into an object (key value) where key is the resourceKey and value is the value of data elements
|
|
31
|
-
* 3) Invoke the tfn and get the value and store it against the tfn key
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
if (tfnItem) {
|
|
35
|
-
if (tfnItem.rParams) {
|
|
36
|
-
const tfnFnInput = {};
|
|
37
|
-
for (const paramKey of Object.keys(tfnItem.rParams)) {
|
|
38
|
-
// tfn can have only data elements as of now.
|
|
39
|
-
const rParam = tfnItem.rParams[paramKey];
|
|
40
|
-
const deId = rParam === null || rParam === void 0 ? void 0 : rParam.de;
|
|
41
|
-
if (deId) {
|
|
42
|
-
let paramValue = dataElements[deId] || '';
|
|
43
|
-
if (rParam.rqd && !paramValue) {
|
|
44
|
-
_logger.Logger.logDbg(`Value required for: ${paramKey}, in transformation function. But not found`);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
if (rParam.tf) {
|
|
48
|
-
paramValue = _utils.Utils.applyTransformationResourceParam(paramValue, rParam.tf);
|
|
49
|
-
}
|
|
50
|
-
tfnFnInput[paramKey] = paramValue;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// invoke the function and get the value
|
|
54
|
-
tfn[key] = tfnItem.fn(tfnFnInput);
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
tfn[key] = '';
|
|
58
|
-
}
|
|
59
|
-
} catch (err) {
|
|
60
|
-
_logger.Logger.logError('Error processing transformation function: ', key, ' with error: ', err);
|
|
61
|
-
// TODO: Report as metric to client
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} catch (err) {
|
|
65
|
-
_logger.Logger.logError('Error processing transformation functions: ', err);
|
|
66
|
-
_reporter.Reporter.reportError('m::processTransformationFunctions', err);
|
|
67
|
-
}
|
|
68
|
-
_dataStore.DataStore.setTransFunctions(tfn);
|
|
69
|
-
return tfn;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.TransFunctionProcessor = TransFunctionProcessor;
|
|
73
|
-
//# sourceMappingURL=trans-function.processor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_dataStore","require","_logger","_utils","_reporter","TransFunctionProcessor","processTransformationFunctions","dataElements","sdkTransFunctions","optTfnKeys","tfn","DataStore","getTransFunctions","tfnKeys","length","Object","keys","key","tfnItem","rParams","tfnFnInput","paramKey","rParam","deId","de","paramValue","rqd","Logger","logDbg","tf","Utils","applyTransformationResourceParam","fn","err","logError","Reporter","reportError","setTransFunctions","exports"],"sources":["trans-function.processor.ts"],"sourcesContent":["/**\n * Process all the data elements at once, or if a set of keys are specified, processes only\n * those keys and updates the dataElements object in global-fns file\n * @param dataElements\n * @param sdkTransFunctions\n * @param optTfnKeys\n */\nimport type { MapLike } from '../common/app-types';\nimport type { ClientSdkTfnItem } from '../models/mp-client-sdk';\nimport { DataStore } from '../common/data-store';\nimport { Logger } from '../common/logger';\nimport { Utils } from '../common/utils';\nimport { Reporter } from '../common/reporter';\n\nexport class TransFunctionProcessor {\n static processTransformationFunctions(\n dataElements: MapLike<any>,\n sdkTransFunctions: MapLike<ClientSdkTfnItem>,\n optTfnKeys?: string[]\n ): MapLike<any> {\n const tfn = DataStore.getTransFunctions();\n const tfnKeys =\n optTfnKeys && optTfnKeys.length > 0\n ? optTfnKeys\n : Object.keys(sdkTransFunctions);\n try {\n for (const key of tfnKeys) {\n try {\n const tfnItem = sdkTransFunctions[key];\n /**\n * How to process transformation functions\n * 1) Find all the data elements in the resource params of trans function\n * 2) make them into an object (key value) where key is the resourceKey and value is the value of data elements\n * 3) Invoke the tfn and get the value and store it against the tfn key\n */\n\n if (tfnItem) {\n if (tfnItem.rParams) {\n const tfnFnInput: any = {};\n for (const paramKey of Object.keys(tfnItem.rParams)) {\n // tfn can have only data elements as of now.\n const rParam = tfnItem.rParams[paramKey];\n const deId = rParam?.de;\n if (deId) {\n let paramValue = dataElements[deId] || '';\n if (rParam.rqd && !paramValue) {\n Logger.logDbg(\n `Value required for: ${paramKey}, in transformation function. But not found`\n );\n break;\n }\n if (rParam.tf) {\n paramValue = Utils.applyTransformationResourceParam(\n paramValue,\n rParam.tf\n );\n }\n tfnFnInput[paramKey] = paramValue;\n }\n }\n // invoke the function and get the value\n tfn[key] = tfnItem.fn(tfnFnInput);\n }\n } else {\n tfn[key] = '';\n }\n } catch (err) {\n Logger.logError(\n 'Error processing transformation function: ',\n key,\n ' with error: ',\n err\n );\n // TODO: Report as metric to client\n }\n }\n } catch (err) {\n Logger.logError('Error processing transformation functions: ', err);\n Reporter.reportError('m::processTransformationFunctions', err);\n }\n\n DataStore.setTransFunctions(tfn);\n return tfn;\n }\n}\n"],"mappings":";;;;;;AASA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQO,MAAMI,sBAAsB,CAAC;EAClC,OAAOC,8BAA8BA,CACnCC,YAA0B,EAC1BC,iBAA4C,EAC5CC,UAAqB,EACP;IACd,MAAMC,GAAG,GAAGC,oBAAS,CAACC,iBAAiB,CAAC,CAAC;IACzC,MAAMC,OAAO,GACXJ,UAAU,IAAIA,UAAU,CAACK,MAAM,GAAG,CAAC,GAC/BL,UAAU,GACVM,MAAM,CAACC,IAAI,CAACR,iBAAiB,CAAC;IACpC,IAAI;MACF,KAAK,MAAMS,GAAG,IAAIJ,OAA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,CAACC,WAAW,CAAC,mCAAmC,EAAEH,GAAG,CAAC;IAChE;IAEAtB,oBAAS,CAAC0B,iBAAiB,CAAC3B,GAAG,CAAC;IAChC,OAAOA,GAAG;EACZ;AACF;AAAC4B,OAAA,CAAAjC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process all the data elements at once, or if a set of keys are specified, processes only
|
|
3
|
-
* those keys and updates the dataElements object in global-fns file
|
|
4
|
-
* @param dataElements
|
|
5
|
-
* @param sdkTransFunctions
|
|
6
|
-
* @param optTfnKeys
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { DataStore } from '../common/data-store';
|
|
10
|
-
import { Logger } from '../common/logger';
|
|
11
|
-
import { Utils } from '../common/utils';
|
|
12
|
-
import { Reporter } from '../common/reporter';
|
|
13
|
-
export class TransFunctionProcessor {
|
|
14
|
-
static processTransformationFunctions(dataElements, sdkTransFunctions, optTfnKeys) {
|
|
15
|
-
const tfn = DataStore.getTransFunctions();
|
|
16
|
-
const tfnKeys = optTfnKeys && optTfnKeys.length > 0 ? optTfnKeys : Object.keys(sdkTransFunctions);
|
|
17
|
-
try {
|
|
18
|
-
for (const key of tfnKeys) {
|
|
19
|
-
try {
|
|
20
|
-
const tfnItem = sdkTransFunctions[key];
|
|
21
|
-
/**
|
|
22
|
-
* How to process transformation functions
|
|
23
|
-
* 1) Find all the data elements in the resource params of trans function
|
|
24
|
-
* 2) make them into an object (key value) where key is the resourceKey and value is the value of data elements
|
|
25
|
-
* 3) Invoke the tfn and get the value and store it against the tfn key
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
if (tfnItem) {
|
|
29
|
-
if (tfnItem.rParams) {
|
|
30
|
-
const tfnFnInput = {};
|
|
31
|
-
for (const paramKey of Object.keys(tfnItem.rParams)) {
|
|
32
|
-
// tfn can have only data elements as of now.
|
|
33
|
-
const rParam = tfnItem.rParams[paramKey];
|
|
34
|
-
const deId = rParam === null || rParam === void 0 ? void 0 : rParam.de;
|
|
35
|
-
if (deId) {
|
|
36
|
-
let paramValue = dataElements[deId] || '';
|
|
37
|
-
if (rParam.rqd && !paramValue) {
|
|
38
|
-
Logger.logDbg(`Value required for: ${paramKey}, in transformation function. But not found`);
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
if (rParam.tf) {
|
|
42
|
-
paramValue = Utils.applyTransformationResourceParam(paramValue, rParam.tf);
|
|
43
|
-
}
|
|
44
|
-
tfnFnInput[paramKey] = paramValue;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// invoke the function and get the value
|
|
48
|
-
tfn[key] = tfnItem.fn(tfnFnInput);
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
tfn[key] = '';
|
|
52
|
-
}
|
|
53
|
-
} catch (err) {
|
|
54
|
-
Logger.logError('Error processing transformation function: ', key, ' with error: ', err);
|
|
55
|
-
// TODO: Report as metric to client
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} catch (err) {
|
|
59
|
-
Logger.logError('Error processing transformation functions: ', err);
|
|
60
|
-
Reporter.reportError('m::processTransformationFunctions', err);
|
|
61
|
-
}
|
|
62
|
-
DataStore.setTransFunctions(tfn);
|
|
63
|
-
return tfn;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=trans-function.processor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["DataStore","Logger","Utils","Reporter","TransFunctionProcessor","processTransformationFunctions","dataElements","sdkTransFunctions","optTfnKeys","tfn","getTransFunctions","tfnKeys","length","Object","keys","key","tfnItem","rParams","tfnFnInput","paramKey","rParam","deId","de","paramValue","rqd","logDbg","tf","applyTransformationResourceParam","fn","err","logError","reportError","setTransFunctions"],"sources":["trans-function.processor.ts"],"sourcesContent":["/**\n * Process all the data elements at once, or if a set of keys are specified, processes only\n * those keys and updates the dataElements object in global-fns file\n * @param dataElements\n * @param sdkTransFunctions\n * @param optTfnKeys\n */\nimport type { MapLike } from '../common/app-types';\nimport type { ClientSdkTfnItem } from '../models/mp-client-sdk';\nimport { DataStore } from '../common/data-store';\nimport { Logger } from '../common/logger';\nimport { Utils } from '../common/utils';\nimport { Reporter } from '../common/reporter';\n\nexport class TransFunctionProcessor {\n static processTransformationFunctions(\n dataElements: MapLike<any>,\n sdkTransFunctions: MapLike<ClientSdkTfnItem>,\n optTfnKeys?: string[]\n ): MapLike<any> {\n const tfn = DataStore.getTransFunctions();\n const tfnKeys =\n optTfnKeys && optTfnKeys.length > 0\n ? optTfnKeys\n : Object.keys(sdkTransFunctions);\n try {\n for (const key of tfnKeys) {\n try {\n const tfnItem = sdkTransFunctions[key];\n /**\n * How to process transformation functions\n * 1) Find all the data elements in the resource params of trans function\n * 2) make them into an object (key value) where key is the resourceKey and value is the value of data elements\n * 3) Invoke the tfn and get the value and store it against the tfn key\n */\n\n if (tfnItem) {\n if (tfnItem.rParams) {\n const tfnFnInput: any = {};\n for (const paramKey of Object.keys(tfnItem.rParams)) {\n // tfn can have only data elements as of now.\n const rParam = tfnItem.rParams[paramKey];\n const deId = rParam?.de;\n if (deId) {\n let paramValue = dataElements[deId] || '';\n if (rParam.rqd && !paramValue) {\n Logger.logDbg(\n `Value required for: ${paramKey}, in transformation function. But not found`\n );\n break;\n }\n if (rParam.tf) {\n paramValue = Utils.applyTransformationResourceParam(\n paramValue,\n rParam.tf\n );\n }\n tfnFnInput[paramKey] = paramValue;\n }\n }\n // invoke the function and get the value\n tfn[key] = tfnItem.fn(tfnFnInput);\n }\n } else {\n tfn[key] = '';\n }\n } catch (err) {\n Logger.logError(\n 'Error processing transformation function: ',\n key,\n ' with error: ',\n err\n );\n // TODO: Report as metric to client\n }\n }\n } catch (err) {\n Logger.logError('Error processing transformation functions: ', err);\n Reporter.reportError('m::processTransformationFunctions', err);\n }\n\n DataStore.setTransFunctions(tfn);\n return tfn;\n }\n}\n"],"mappings":"AAAA;AACA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ACyB,gCAAgC,CACjDJ,UAAU,EACVH,MAAM,CAACM,EACT,CAAC;kBACH;kBACAR,UAAU,CAACC,QAAQ,CAAC,GAAGI,UAAU;gBACnC;cACF;cACA;cACAd,GAAG,CAACM,GAAG,CAAC,GAAGC,OAAO,CAACY,EAAE,CAACV,UAAU,CAAC;YACnC;UACF,CAAC,MAAM;YACLT,GAAG,CAACM,GAAG,CAAC,GAAG,EAAE;UACf;QACF,CAAC,CAAC,OAAOc,GAAG,EAAE;UACZ5B,MAAM,CAAC6B,QAAQ,CACb,4CAA4C,EAC5Cf,GAAG,EACH,eAAe,EACfc,GACF,CAAC;UACD;QACF;MACF;IACF,CAAC,CAAC,OAAOA,GAAG,EAAE;MACZ5B,MAAM,CAAC6B,QAAQ,CAAC,6CAA6C,EAAED,GAAG,CAAC;MACnE1B,QAAQ,CAAC4B,WAAW,CAAC,mCAAmC,EAAEF,GAAG,CAAC;IAChE;IAEA7B,SAAS,CAACgC,iBAAiB,CAACvB,GAAG,CAAC;IAChC,OAAOA,GAAG;EACZ;AACF","ignoreList":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process all the data elements at once, or if a set of keys are specified, processes only
|
|
3
|
-
* those keys and updates the dataElements object in global-fns file
|
|
4
|
-
* @param dataElements
|
|
5
|
-
* @param sdkTransFunctions
|
|
6
|
-
* @param optTfnKeys
|
|
7
|
-
*/
|
|
8
|
-
import type { MapLike } from '../common/app-types';
|
|
9
|
-
import type { ClientSdkTfnItem } from '../models/mp-client-sdk';
|
|
10
|
-
export declare class TransFunctionProcessor {
|
|
11
|
-
static processTransformationFunctions(dataElements: MapLike<any>, sdkTransFunctions: MapLike<ClientSdkTfnItem>, optTfnKeys?: string[]): MapLike<any>;
|
|
12
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class VisitIdProcessor {
|
|
2
|
-
static init(orgId: string): Promise<void>;
|
|
3
|
-
static isFirstOpenAfterInstall(): Promise<boolean>;
|
|
4
|
-
static getFacebookFBP(): Promise<string>;
|
|
5
|
-
static initDebugId(orgId: string): Promise<void>;
|
|
6
|
-
static setOrResetVisitInfo(incrementDepth: boolean): Promise<void>;
|
|
7
|
-
static incrementVisitDepth(): Promise<void>;
|
|
8
|
-
static setOrResetVisitorId(): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process all the data elements at once, or if a set of keys are specified, processes only
|
|
3
|
-
* those keys and updates the dataElements object in global-fns file
|
|
4
|
-
* @param dataElements
|
|
5
|
-
* @param sdkTransFunctions
|
|
6
|
-
* @param optTfnKeys
|
|
7
|
-
*/
|
|
8
|
-
import type { MapLike } from '../common/app-types';
|
|
9
|
-
import type { ClientSdkTfnItem } from '../models/mp-client-sdk';
|
|
10
|
-
import { DataStore } from '../common/data-store';
|
|
11
|
-
import { Logger } from '../common/logger';
|
|
12
|
-
import { Utils } from '../common/utils';
|
|
13
|
-
import { Reporter } from '../common/reporter';
|
|
14
|
-
|
|
15
|
-
export class TransFunctionProcessor {
|
|
16
|
-
static processTransformationFunctions(
|
|
17
|
-
dataElements: MapLike<any>,
|
|
18
|
-
sdkTransFunctions: MapLike<ClientSdkTfnItem>,
|
|
19
|
-
optTfnKeys?: string[]
|
|
20
|
-
): MapLike<any> {
|
|
21
|
-
const tfn = DataStore.getTransFunctions();
|
|
22
|
-
const tfnKeys =
|
|
23
|
-
optTfnKeys && optTfnKeys.length > 0
|
|
24
|
-
? optTfnKeys
|
|
25
|
-
: Object.keys(sdkTransFunctions);
|
|
26
|
-
try {
|
|
27
|
-
for (const key of tfnKeys) {
|
|
28
|
-
try {
|
|
29
|
-
const tfnItem = sdkTransFunctions[key];
|
|
30
|
-
/**
|
|
31
|
-
* How to process transformation functions
|
|
32
|
-
* 1) Find all the data elements in the resource params of trans function
|
|
33
|
-
* 2) make them into an object (key value) where key is the resourceKey and value is the value of data elements
|
|
34
|
-
* 3) Invoke the tfn and get the value and store it against the tfn key
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
if (tfnItem) {
|
|
38
|
-
if (tfnItem.rParams) {
|
|
39
|
-
const tfnFnInput: any = {};
|
|
40
|
-
for (const paramKey of Object.keys(tfnItem.rParams)) {
|
|
41
|
-
// tfn can have only data elements as of now.
|
|
42
|
-
const rParam = tfnItem.rParams[paramKey];
|
|
43
|
-
const deId = rParam?.de;
|
|
44
|
-
if (deId) {
|
|
45
|
-
let paramValue = dataElements[deId] || '';
|
|
46
|
-
if (rParam.rqd && !paramValue) {
|
|
47
|
-
Logger.logDbg(
|
|
48
|
-
`Value required for: ${paramKey}, in transformation function. But not found`
|
|
49
|
-
);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
if (rParam.tf) {
|
|
53
|
-
paramValue = Utils.applyTransformationResourceParam(
|
|
54
|
-
paramValue,
|
|
55
|
-
rParam.tf
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
tfnFnInput[paramKey] = paramValue;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// invoke the function and get the value
|
|
62
|
-
tfn[key] = tfnItem.fn(tfnFnInput);
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
tfn[key] = '';
|
|
66
|
-
}
|
|
67
|
-
} catch (err) {
|
|
68
|
-
Logger.logError(
|
|
69
|
-
'Error processing transformation function: ',
|
|
70
|
-
key,
|
|
71
|
-
' with error: ',
|
|
72
|
-
err
|
|
73
|
-
);
|
|
74
|
-
// TODO: Report as metric to client
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
} catch (err) {
|
|
78
|
-
Logger.logError('Error processing transformation functions: ', err);
|
|
79
|
-
Reporter.reportError('m::processTransformationFunctions', err);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
DataStore.setTransFunctions(tfn);
|
|
83
|
-
return tfn;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|