@magicpixel/rn-mp-client-sdk 0.12.0 → 1.12.1
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/lib/commonjs/common/app-types.js.map +1 -1
- package/lib/commonjs/common/constants.js +5 -26
- package/lib/commonjs/common/constants.js.map +1 -1
- package/lib/commonjs/common/data-store.js +36 -117
- package/lib/commonjs/common/data-store.js.map +1 -1
- package/lib/commonjs/common/event-bus.js +3 -10
- package/lib/commonjs/common/event-bus.js.map +1 -1
- package/lib/commonjs/common/logger.js +9 -18
- package/lib/commonjs/common/logger.js.map +1 -1
- package/lib/commonjs/common/network-service.js +6 -21
- package/lib/commonjs/common/network-service.js.map +1 -1
- package/lib/commonjs/common/reporter.js +8 -31
- package/lib/commonjs/common/reporter.js.map +1 -1
- package/lib/commonjs/common/utils.js +64 -65
- package/lib/commonjs/common/utils.js.map +1 -1
- package/lib/commonjs/coverage/lcov-report/block-navigation.js +6 -19
- package/lib/commonjs/coverage/lcov-report/block-navigation.js.map +1 -1
- package/lib/commonjs/coverage/lcov-report/prettify.js +2 -182
- package/lib/commonjs/coverage/lcov-report/prettify.js.map +1 -1
- package/lib/commonjs/coverage/lcov-report/sorter.js +64 -94
- package/lib/commonjs/coverage/lcov-report/sorter.js.map +1 -1
- package/lib/commonjs/eedl/eedl.js +207 -84
- package/lib/commonjs/eedl/eedl.js.map +1 -1
- package/lib/commonjs/index.js +104 -95
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/geo-api-response.js +2 -0
- package/lib/commonjs/models/geo-api-response.js.map +1 -0
- package/lib/commonjs/models/mp-client-sdk.js +3 -11
- package/lib/commonjs/models/mp-client-sdk.js.map +1 -1
- package/lib/commonjs/processors/data-element.processor.js +85 -80
- package/lib/commonjs/processors/data-element.processor.js.map +1 -1
- package/lib/commonjs/processors/geo-location.processor.js +70 -0
- package/lib/commonjs/processors/geo-location.processor.js.map +1 -0
- package/lib/commonjs/processors/qc.processor.js +2 -25
- package/lib/commonjs/processors/qc.processor.js.map +1 -1
- package/lib/commonjs/processors/tag.processor.js +17 -86
- package/lib/commonjs/processors/tag.processor.js.map +1 -1
- package/lib/commonjs/processors/trans-function.processor.js +5 -23
- package/lib/commonjs/processors/trans-function.processor.js.map +1 -1
- package/lib/commonjs/processors/visit-id.processor.js +4 -50
- 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 +4 -22
- package/lib/module/common/constants.js.map +1 -1
- package/lib/module/common/data-store.js +35 -108
- package/lib/module/common/data-store.js.map +1 -1
- package/lib/module/common/event-bus.js +3 -6
- package/lib/module/common/event-bus.js.map +1 -1
- package/lib/module/common/logger.js +9 -16
- package/lib/module/common/logger.js.map +1 -1
- package/lib/module/common/network-service.js +6 -11
- package/lib/module/common/network-service.js.map +1 -1
- package/lib/module/common/reporter.js +8 -19
- package/lib/module/common/reporter.js.map +1 -1
- package/lib/module/common/utils.js +63 -56
- package/lib/module/common/utils.js.map +1 -1
- package/lib/module/coverage/lcov-report/block-navigation.js +6 -19
- package/lib/module/coverage/lcov-report/block-navigation.js.map +1 -1
- package/lib/module/coverage/lcov-report/prettify.js +2 -182
- package/lib/module/coverage/lcov-report/prettify.js.map +1 -1
- package/lib/module/coverage/lcov-report/sorter.js +64 -94
- package/lib/module/coverage/lcov-report/sorter.js.map +1 -1
- package/lib/module/eedl/eedl.js +206 -76
- package/lib/module/eedl/eedl.js.map +1 -1
- package/lib/module/index.js +102 -57
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/geo-api-response.js +2 -0
- package/lib/module/models/geo-api-response.js.map +1 -0
- package/lib/module/models/mp-client-sdk.js +0 -5
- package/lib/module/models/mp-client-sdk.js.map +1 -1
- package/lib/module/processors/data-element.processor.js +82 -71
- package/lib/module/processors/data-element.processor.js.map +1 -1
- package/lib/module/processors/geo-location.processor.js +63 -0
- package/lib/module/processors/geo-location.processor.js.map +1 -0
- package/lib/module/processors/qc.processor.js +2 -11
- package/lib/module/processors/qc.processor.js.map +1 -1
- package/lib/module/processors/tag.processor.js +17 -57
- package/lib/module/processors/tag.processor.js.map +1 -1
- package/lib/module/processors/trans-function.processor.js +5 -12
- package/lib/module/processors/trans-function.processor.js.map +1 -1
- package/lib/module/processors/visit-id.processor.js +4 -27
- package/lib/module/processors/visit-id.processor.js.map +1 -1
- package/lib/typescript/common/app-types.d.ts +3 -0
- package/lib/typescript/common/constants.d.ts +1 -0
- package/lib/typescript/common/data-store.d.ts +8 -0
- package/lib/typescript/common/utils.d.ts +19 -0
- package/lib/typescript/eedl/eedl.d.ts +16 -5
- package/lib/typescript/index.d.ts +53 -0
- package/lib/typescript/models/geo-api-response.d.ts +12 -0
- package/lib/typescript/processors/data-element.processor.d.ts +10 -1
- package/lib/typescript/processors/geo-location.processor.d.ts +10 -0
- package/package.json +25 -10
- package/src/common/app-types.ts +3 -0
- package/src/common/constants.ts +2 -0
- package/src/common/data-store.ts +38 -0
- package/src/common/network-service.ts +2 -0
- package/src/common/utils.ts +58 -0
- package/src/eedl/eedl.ts +241 -18
- package/src/index.tsx +98 -3
- package/src/models/geo-api-response.ts +13 -0
- package/src/processors/data-element.processor.ts +140 -70
- package/src/processors/geo-location.processor.ts +91 -0
|
@@ -10,11 +10,9 @@ export class VisitIdProcessor {
|
|
|
10
10
|
await this.setOrResetVisitorId();
|
|
11
11
|
await this.setOrResetVisitInfo(false);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
13
|
static async isFirstOpenAfterInstall() {
|
|
15
14
|
try {
|
|
16
15
|
const firstOpenFlag = await DataStore.getDataFromStorage(Constants.KEY_FIRST_OPEN);
|
|
17
|
-
|
|
18
16
|
if (!firstOpenFlag) {
|
|
19
17
|
await DataStore.storeData(Constants.KEY_FIRST_OPEN, 'No');
|
|
20
18
|
return true;
|
|
@@ -22,52 +20,41 @@ export class VisitIdProcessor {
|
|
|
22
20
|
} catch (err) {
|
|
23
21
|
Logger.logError('Unable to determine first open after install flag', err);
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
return false;
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
static async getFacebookFBP() {
|
|
30
26
|
try {
|
|
31
27
|
let fbp = await DataStore.getDataFromStorage(Constants.KEY_FBP);
|
|
32
|
-
|
|
33
28
|
if (!fbp) {
|
|
34
29
|
fbp = `fb.1.${Date.now()}.${Date.now()}`;
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
await DataStore.storeData(Constants.KEY_FBP, fbp);
|
|
38
32
|
DataStore.addCommonCookie('x-fbp', fbp);
|
|
39
33
|
return fbp;
|
|
40
34
|
} catch (err) {
|
|
41
35
|
Logger.logError('Error initializing debug id.', err);
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
return '';
|
|
45
38
|
}
|
|
46
|
-
|
|
47
39
|
static async initDebugId(orgId) {
|
|
48
40
|
try {
|
|
49
41
|
let debugId = await DataStore.getDataFromStorage(Constants.KEY_MP_DEBUG_ID);
|
|
50
|
-
|
|
51
42
|
if (debugId && debugId.indexOf(orgId) !== 0) {
|
|
52
43
|
// re-generate debug id if it is not of the simple variety
|
|
53
44
|
debugId = undefined;
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
if (!debugId) {
|
|
57
47
|
debugId = Utils.getSimpleDebugId(orgId);
|
|
58
48
|
}
|
|
59
|
-
|
|
60
49
|
await DataStore.storeData(Constants.KEY_MP_DEBUG_ID, debugId);
|
|
61
50
|
DataStore.setDebugId(debugId);
|
|
62
51
|
} catch (err) {
|
|
63
52
|
Logger.logError('Error initializing debug id.', err);
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
|
-
|
|
67
55
|
static async setOrResetVisitInfo(incrementDepth) {
|
|
68
56
|
try {
|
|
69
57
|
let visitInfo = await DataStore.getDataFromStorage(Constants.KEY_MP_IDL_VISIT_ID_INFO);
|
|
70
|
-
|
|
71
58
|
if (!visitInfo) {
|
|
72
59
|
// may be first time visit, set up a new visit info object and return
|
|
73
60
|
visitInfo = {
|
|
@@ -80,20 +67,16 @@ export class VisitIdProcessor {
|
|
|
80
67
|
} else {
|
|
81
68
|
// reset visit id anyway, but retain the visitCt and depth setting
|
|
82
69
|
visitInfo.visitId = Utils.getUniqueID();
|
|
83
|
-
|
|
84
70
|
if (incrementDepth) {
|
|
85
71
|
var _visitInfo;
|
|
86
|
-
|
|
87
72
|
visitInfo.visitDepth = (((_visitInfo = visitInfo) === null || _visitInfo === void 0 ? void 0 : _visitInfo.visitDepth) ?? 0) + 1;
|
|
88
73
|
} else {
|
|
89
74
|
visitInfo.visitCt = visitInfo.visitCt + 1;
|
|
90
75
|
visitInfo.visitDepth = 0;
|
|
91
76
|
}
|
|
92
|
-
|
|
93
77
|
visitInfo.visitTs = Date.now();
|
|
94
78
|
visitInfo.visitVer = 1;
|
|
95
79
|
}
|
|
96
|
-
|
|
97
80
|
DataStore.setVisitInfo(visitInfo);
|
|
98
81
|
await DataStore.storeData(Constants.KEY_MP_IDL_VISIT_ID_INFO, visitInfo);
|
|
99
82
|
DataStore.addCommonCookie('x-mp-vid', DataStore.visitInfoToString());
|
|
@@ -103,28 +86,23 @@ export class VisitIdProcessor {
|
|
|
103
86
|
Reporter.reportError('setOrResetVisitInfo', err);
|
|
104
87
|
}
|
|
105
88
|
}
|
|
106
|
-
|
|
107
89
|
static async incrementVisitDepth() {
|
|
108
90
|
return this.setOrResetVisitInfo(true);
|
|
109
91
|
}
|
|
110
|
-
|
|
111
92
|
static async setOrResetVisitorId() {
|
|
112
93
|
try {
|
|
113
94
|
var _visitorInfoData;
|
|
114
|
-
|
|
115
95
|
let visitorInfoData = await DataStore.getDataFromStorage(Constants.KEY_MP_IDL_VISITOR_ID_INFO);
|
|
116
|
-
|
|
117
96
|
if (!visitorInfoData || visitorInfoData && ((_visitorInfoData = visitorInfoData) === null || _visitorInfoData === void 0 ? void 0 : _visitorInfoData.mId.indexOf('-')) === -1) {
|
|
118
|
-
Logger.logDbg('VisitorInfo not found. Refreshing from server');
|
|
119
|
-
|
|
97
|
+
Logger.logDbg('VisitorInfo not found. Refreshing from server');
|
|
98
|
+
// get a new visit id and device id from server and store it in storage
|
|
120
99
|
visitorInfoData = await NetworkService.fetchIdlInfo(DataStore.getIdlUrl());
|
|
121
100
|
}
|
|
122
|
-
|
|
123
101
|
if (!visitorInfoData) {
|
|
124
102
|
return;
|
|
125
103
|
} else {
|
|
126
|
-
DataStore.setVisitorInfo(visitorInfoData);
|
|
127
|
-
|
|
104
|
+
DataStore.setVisitorInfo(visitorInfoData);
|
|
105
|
+
// store to db as well
|
|
128
106
|
await DataStore.storeData(Constants.KEY_MP_IDL_VISITOR_ID_INFO, visitorInfoData);
|
|
129
107
|
const cookieValue = encodeURIComponent(JSON.stringify(visitorInfoData));
|
|
130
108
|
DataStore.addCommonCookie('x-mplidl', cookieValue);
|
|
@@ -138,6 +116,5 @@ export class VisitIdProcessor {
|
|
|
138
116
|
Reporter.reportError('setOrResetVisitorId', err);
|
|
139
117
|
}
|
|
140
118
|
}
|
|
141
|
-
|
|
142
119
|
}
|
|
143
120
|
//# sourceMappingURL=visit-id.processor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Logger","DataStore","Constants","Reporter","NetworkService","Utils","VisitIdProcessor","init","orgId","initDebugId","setOrResetVisitorId","setOrResetVisitInfo","isFirstOpenAfterInstall","firstOpenFlag","getDataFromStorage","KEY_FIRST_OPEN","storeData","err","logError","getFacebookFBP","fbp","KEY_FBP","Date","now","addCommonCookie","debugId","KEY_MP_DEBUG_ID","indexOf","undefined","getSimpleDebugId","setDebugId","incrementDepth","visitInfo","KEY_MP_IDL_VISIT_ID_INFO","visitId","getUniqueID","visitCt","visitDepth","visitTs","visitVer","setVisitInfo","visitInfoToString","reportError","incrementVisitDepth","visitorInfoData","KEY_MP_IDL_VISITOR_ID_INFO","mId","logDbg","fetchIdlInfo","getIdlUrl","setVisitorInfo","cookieValue","encodeURIComponent","JSON","stringify","dId"],"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';\n\nexport class VisitIdProcessor {\n static async init(orgId: string): Promise<void> {\n await this.initDebugId(orgId);\n await this.setOrResetVisitorId();\n await this.setOrResetVisitInfo(false);\n }\n\n static async isFirstOpenAfterInstall(): Promise<boolean> {\n try {\n const firstOpenFlag = await DataStore.getDataFromStorage<string>(\n Constants.KEY_FIRST_OPEN\n );\n\n if (!firstOpenFlag) {\n await DataStore.storeData(Constants.KEY_FIRST_OPEN, 'No');\n return true;\n }\n } catch (err) {\n Logger.logError('Unable to determine first open after install flag', err);\n }\n return false;\n }\n\n static async getFacebookFBP(): Promise<string> {\n try {\n let fbp = await DataStore.getDataFromStorage<string>(Constants.KEY_FBP);\n\n if (!fbp) {\n fbp = `fb.1.${Date.now()}.${Date.now()}`;\n }\n\n await DataStore.storeData(Constants.KEY_FBP, fbp);\n\n DataStore.addCommonCookie('x-fbp', fbp);\n\n return fbp;\n } catch (err) {\n Logger.logError('Error initializing debug id.', err);\n }\n return '';\n }\n\n static async initDebugId(orgId: string): Promise<void> {\n try {\n let debugId = await DataStore.getDataFromStorage<string>(\n Constants.KEY_MP_DEBUG_ID\n );\n\n if (debugId && debugId.indexOf(orgId) !== 0) {\n // re-generate debug id if it is not of the simple variety\n debugId = undefined;\n }\n\n if (!debugId) {\n debugId = Utils.getSimpleDebugId(orgId);\n }\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(incrementDepth: boolean): Promise<void> {\n try {\n let visitInfo: VisitInfo = await DataStore.getDataFromStorage(\n Constants.KEY_MP_IDL_VISIT_ID_INFO\n );\n\n if (!visitInfo) {\n // may be first time visit, set up a new visit info object and return\n visitInfo = {\n visitId: Utils.getUniqueID(),\n visitCt: 1,\n visitDepth: 0,\n visitTs: Date.now(),\n visitVer: 1,\n };\n } else {\n // reset visit id anyway, but retain the visitCt and depth setting\n visitInfo.visitId = Utils.getUniqueID();\n if (incrementDepth) {\n visitInfo.visitDepth = (visitInfo?.visitDepth ?? 0) + 1;\n } else {\n visitInfo.visitCt = visitInfo.visitCt + 1;\n visitInfo.visitDepth = 0;\n }\n visitInfo.visitTs = Date.now();\n visitInfo.visitVer = 1;\n }\n\n DataStore.setVisitInfo(visitInfo);\n await DataStore.storeData(Constants.KEY_MP_IDL_VISIT_ID_INFO, visitInfo);\n DataStore.addCommonCookie('x-mp-vid', DataStore.visitInfoToString());\n } catch (err) {\n Logger.logError(err);\n DataStore.setVisitInfo(null);\n Reporter.reportError('setOrResetVisitInfo', err);\n }\n }\n\n static async incrementVisitDepth(): Promise<void> {\n return this.setOrResetVisitInfo(true);\n }\n\n static async setOrResetVisitorId(): Promise<void> {\n try {\n let visitorInfoData: VisitorInfo = await DataStore.getDataFromStorage(\n Constants.KEY_MP_IDL_VISITOR_ID_INFO\n );\n\n if (\n !visitorInfoData ||\n (visitorInfoData && visitorInfoData?.mId.indexOf('-') === -1)\n ) {\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 visitorInfoData = await NetworkService.fetchIdlInfo(\n DataStore.getIdlUrl()\n );\n }\n\n if (!visitorInfoData) {\n return;\n } else {\n DataStore.setVisitorInfo(visitorInfoData);\n // store to db as well\n await DataStore.storeData(\n Constants.KEY_MP_IDL_VISITOR_ID_INFO,\n visitorInfoData\n );\n\n const cookieValue = encodeURIComponent(JSON.stringify(visitorInfoData));\n DataStore.addCommonCookie('x-mplidl', cookieValue);\n DataStore.addCommonCookie('x-mpidl', cookieValue);\n DataStore.addCommonCookie('x-lmid', visitorInfoData.mId);\n DataStore.addCommonCookie('x-ldid', visitorInfoData.dId);\n }\n } catch (err) {\n Logger.logError(err);\n DataStore.setVisitorInfo(null);\n Reporter.reportError('setOrResetVisitorId', err);\n }\n }\n}\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"names":["Logger","DataStore","Constants","Reporter","NetworkService","Utils","VisitIdProcessor","init","orgId","initDebugId","setOrResetVisitorId","setOrResetVisitInfo","isFirstOpenAfterInstall","firstOpenFlag","getDataFromStorage","KEY_FIRST_OPEN","storeData","err","logError","getFacebookFBP","fbp","KEY_FBP","Date","now","addCommonCookie","debugId","KEY_MP_DEBUG_ID","indexOf","undefined","getSimpleDebugId","setDebugId","incrementDepth","visitInfo","KEY_MP_IDL_VISIT_ID_INFO","visitId","getUniqueID","visitCt","visitDepth","visitTs","visitVer","_visitInfo","setVisitInfo","visitInfoToString","reportError","incrementVisitDepth","_visitorInfoData","visitorInfoData","KEY_MP_IDL_VISITOR_ID_INFO","mId","logDbg","fetchIdlInfo","getIdlUrl","setVisitorInfo","cookieValue","encodeURIComponent","JSON","stringify","dId"],"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';\n\nexport class VisitIdProcessor {\n static async init(orgId: string): Promise<void> {\n await this.initDebugId(orgId);\n await this.setOrResetVisitorId();\n await this.setOrResetVisitInfo(false);\n }\n\n static async isFirstOpenAfterInstall(): Promise<boolean> {\n try {\n const firstOpenFlag = await DataStore.getDataFromStorage<string>(\n Constants.KEY_FIRST_OPEN\n );\n\n if (!firstOpenFlag) {\n await DataStore.storeData(Constants.KEY_FIRST_OPEN, 'No');\n return true;\n }\n } catch (err) {\n Logger.logError('Unable to determine first open after install flag', err);\n }\n return false;\n }\n\n static async getFacebookFBP(): Promise<string> {\n try {\n let fbp = await DataStore.getDataFromStorage<string>(Constants.KEY_FBP);\n\n if (!fbp) {\n fbp = `fb.1.${Date.now()}.${Date.now()}`;\n }\n\n await DataStore.storeData(Constants.KEY_FBP, fbp);\n\n DataStore.addCommonCookie('x-fbp', fbp);\n\n return fbp;\n } catch (err) {\n Logger.logError('Error initializing debug id.', err);\n }\n return '';\n }\n\n static async initDebugId(orgId: string): Promise<void> {\n try {\n let debugId = await DataStore.getDataFromStorage<string>(\n Constants.KEY_MP_DEBUG_ID\n );\n\n if (debugId && debugId.indexOf(orgId) !== 0) {\n // re-generate debug id if it is not of the simple variety\n debugId = undefined;\n }\n\n if (!debugId) {\n debugId = Utils.getSimpleDebugId(orgId);\n }\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(incrementDepth: boolean): Promise<void> {\n try {\n let visitInfo: VisitInfo = await DataStore.getDataFromStorage(\n Constants.KEY_MP_IDL_VISIT_ID_INFO\n );\n\n if (!visitInfo) {\n // may be first time visit, set up a new visit info object and return\n visitInfo = {\n visitId: Utils.getUniqueID(),\n visitCt: 1,\n visitDepth: 0,\n visitTs: Date.now(),\n visitVer: 1,\n };\n } else {\n // reset visit id anyway, but retain the visitCt and depth setting\n visitInfo.visitId = Utils.getUniqueID();\n if (incrementDepth) {\n visitInfo.visitDepth = (visitInfo?.visitDepth ?? 0) + 1;\n } else {\n visitInfo.visitCt = visitInfo.visitCt + 1;\n visitInfo.visitDepth = 0;\n }\n visitInfo.visitTs = Date.now();\n visitInfo.visitVer = 1;\n }\n\n DataStore.setVisitInfo(visitInfo);\n await DataStore.storeData(Constants.KEY_MP_IDL_VISIT_ID_INFO, visitInfo);\n DataStore.addCommonCookie('x-mp-vid', DataStore.visitInfoToString());\n } catch (err) {\n Logger.logError(err);\n DataStore.setVisitInfo(null);\n Reporter.reportError('setOrResetVisitInfo', err);\n }\n }\n\n static async incrementVisitDepth(): Promise<void> {\n return this.setOrResetVisitInfo(true);\n }\n\n static async setOrResetVisitorId(): Promise<void> {\n try {\n let visitorInfoData: VisitorInfo = await DataStore.getDataFromStorage(\n Constants.KEY_MP_IDL_VISITOR_ID_INFO\n );\n\n if (\n !visitorInfoData ||\n (visitorInfoData && visitorInfoData?.mId.indexOf('-') === -1)\n ) {\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 visitorInfoData = await NetworkService.fetchIdlInfo(\n DataStore.getIdlUrl()\n );\n }\n\n if (!visitorInfoData) {\n return;\n } else {\n DataStore.setVisitorInfo(visitorInfoData);\n // store to db as well\n await DataStore.storeData(\n Constants.KEY_MP_IDL_VISITOR_ID_INFO,\n visitorInfoData\n );\n\n const cookieValue = encodeURIComponent(JSON.stringify(visitorInfoData));\n DataStore.addCommonCookie('x-mplidl', cookieValue);\n DataStore.addCommonCookie('x-mpidl', cookieValue);\n DataStore.addCommonCookie('x-lmid', visitorInfoData.mId);\n DataStore.addCommonCookie('x-ldid', visitorInfoData.dId);\n }\n } catch (err) {\n Logger.logError(err);\n DataStore.setVisitorInfo(null);\n Reporter.reportError('setOrResetVisitorId', err);\n }\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,kBAAkB;AACzC,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,cAAc,QAAQ,2BAA2B;AAE1D,SAASC,KAAK,QAAQ,iBAAiB;AAEvC,OAAO,MAAMC,gBAAgB,CAAC;EAC5B,aAAaC,IAAIA,CAACC,KAAa,EAAiB;IAC9C,MAAM,IAAI,CAACC,WAAW,CAACD,KAAK,CAAC;IAC7B,MAAM,IAAI,CAACE,mBAAmB,CAAC,CAAC;IAChC,MAAM,IAAI,CAACC,mBAAmB,CAAC,KAAK,CAAC;EACvC;EAEA,aAAaC,uBAAuBA,CAAA,EAA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AClDpD,SAAS,CAACuB,eAAe,CAAC,SAAS,EAAE6B,WAAW,CAAC;QACjDpD,SAAS,CAACuB,eAAe,CAAC,QAAQ,EAAEsB,eAAe,CAACE,GAAG,CAAC;QACxD/C,SAAS,CAACuB,eAAe,CAAC,QAAQ,EAAEsB,eAAe,CAACW,GAAG,CAAC;MAC1D;IACF,CAAC,CAAC,OAAOxC,GAAG,EAAE;MACZjB,MAAM,CAACkB,QAAQ,CAACD,GAAG,CAAC;MACpBhB,SAAS,CAACmD,cAAc,CAAC,IAAI,CAAC;MAC9BjD,QAAQ,CAACwC,WAAW,CAAC,qBAAqB,EAAE1B,GAAG,CAAC;IAClD;EACF;AACF","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DeJsvHelper, MapLike, MpDeviceInfo, QcInfoItem, RunQueueModel, SdkInitOptions, UrlInfo, VisitInfo, VisitorInfo } from './app-types';
|
|
2
|
+
import type { GeoResponse } from '../models/geo-api-response';
|
|
2
3
|
import type { ClientSdkDeItem, ClientSdkPrItem, ClientSdkQcItem, ClientSdkTagItem, MpClientSdk } from '../models/mp-client-sdk';
|
|
3
4
|
export declare class DataStore {
|
|
4
5
|
private static isDataStoreInitialized;
|
|
@@ -20,6 +21,7 @@ export declare class DataStore {
|
|
|
20
21
|
private static isProcessing;
|
|
21
22
|
private static sdkInitOptions;
|
|
22
23
|
private static deviceInfo;
|
|
24
|
+
private static geoInfo;
|
|
23
25
|
private static interestedClientSideEvents;
|
|
24
26
|
private static interestedServerSideEvents;
|
|
25
27
|
private static interestedAllEvents;
|
|
@@ -91,4 +93,10 @@ export declare class DataStore {
|
|
|
91
93
|
static getCoreVersion(): string;
|
|
92
94
|
static getMpEnv(): 'stg' | 'prd';
|
|
93
95
|
static setMpEnv(shortEnv: 'stg' | 'prd'): void;
|
|
96
|
+
static setGeoInfo(geoInfo: GeoResponse): void;
|
|
97
|
+
static getGeoInfo(): GeoResponse | undefined;
|
|
98
|
+
static isGeoLocationEnabledInSdk(): boolean;
|
|
99
|
+
static getVisitInfo(): VisitInfo | undefined;
|
|
100
|
+
static getBrowser(): string;
|
|
101
|
+
static getMpUserStatus(): number;
|
|
94
102
|
}
|
|
@@ -34,6 +34,25 @@ export declare class Utils {
|
|
|
34
34
|
static convertToRegex(input: string, ignoreCase: boolean, fullMatch: boolean): RegExp;
|
|
35
35
|
static safeExecute(fn: (payload: any) => any, payload: any): any;
|
|
36
36
|
static getUniqueID(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Make HTTP GET request - React Native implementation
|
|
39
|
+
* @param url URL to fetch
|
|
40
|
+
* @returns Promise with response data
|
|
41
|
+
*/
|
|
42
|
+
static getHttp<T>(url: string): Promise<T>;
|
|
43
|
+
/**
|
|
44
|
+
* Get value from AsyncStorage (React Native equivalent of sessionStorage)
|
|
45
|
+
* @param key Storage key
|
|
46
|
+
* @param defaultValue Default value if key not found
|
|
47
|
+
* @returns Promise with stored value or default
|
|
48
|
+
*/
|
|
49
|
+
static getValueFromAsyncStorage<T>(key: string, defaultValue: T): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Set value to AsyncStorage (React Native equivalent of sessionStorage)
|
|
52
|
+
* @param key Storage key
|
|
53
|
+
* @param value Value to store
|
|
54
|
+
*/
|
|
55
|
+
static setValueToAsyncStorage(key: string, value: any): Promise<void>;
|
|
37
56
|
static getSimpleDebugId(prefix?: string): string;
|
|
38
57
|
static randomNumber(min: number, max: number): number;
|
|
39
58
|
static unFlattenResourceParams<T extends BaseResourceParamType>(input: T[]): MapLike<T>;
|
|
@@ -2,29 +2,38 @@ import type { EventProcessorFn, MapLike, TypedAny } from '../common/app-types';
|
|
|
2
2
|
export declare class MpDataLayerHelper {
|
|
3
3
|
private readonly dlEventName;
|
|
4
4
|
private readonly dlInitMode;
|
|
5
|
+
private readonly storageKeyName;
|
|
5
6
|
isReady: boolean;
|
|
6
7
|
_masterDataLayer: MapLike;
|
|
8
|
+
_persistedVars: MapLike;
|
|
7
9
|
eventProcessors: Record<string, any>;
|
|
8
10
|
stateTracker: Array<any>;
|
|
9
11
|
dlInitEvent: string;
|
|
10
12
|
receivedInitialEvent: boolean;
|
|
11
13
|
eventQueue: Array<any>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
private isEntryPoint;
|
|
15
|
+
constructor(dlEventName: string, dlInitMode: string, dlInitEvent: string, storageKeyName?: string);
|
|
16
|
+
init(globalEventListeners: Record<string, EventProcessorFn>): Promise<void>;
|
|
14
17
|
pushEvent(eventName: string, payload: MapLike): void;
|
|
15
|
-
processQItems(eventName: string, payload: MapLike): void
|
|
18
|
+
processQItems(eventName: string, payload: MapLike): Promise<void>;
|
|
16
19
|
/**
|
|
17
20
|
* Private Processor for 'set' command object
|
|
18
21
|
*/
|
|
19
22
|
setDl(obj: TypedAny | undefined): boolean;
|
|
20
23
|
getDl(): TypedAny;
|
|
24
|
+
private setUserData;
|
|
25
|
+
private deleteData;
|
|
26
|
+
private storeData;
|
|
27
|
+
private reloadPersistedVars;
|
|
28
|
+
private getFullData;
|
|
29
|
+
private storeFullData;
|
|
21
30
|
/**
|
|
22
31
|
* Private event processor. Idea is that whenever an event is detected, we create a copy of the master data layer,
|
|
23
32
|
* add the event variables, and trigger the event requested when initializing the data layer helper
|
|
24
33
|
* @param eventName
|
|
25
34
|
* @param model
|
|
26
35
|
*/
|
|
27
|
-
eventProcessor(eventName: string, model: TypedAny | undefined): void
|
|
36
|
+
eventProcessor(eventName: string, model: TypedAny | undefined): Promise<void>;
|
|
28
37
|
overrideDlInitEvent(eventName: string): string;
|
|
29
38
|
/**
|
|
30
39
|
* Exposed method for registering custom processors for events
|
|
@@ -42,5 +51,7 @@ export declare class MpDataLayerHelper {
|
|
|
42
51
|
hasEventHappened(key: string): boolean;
|
|
43
52
|
reset(): boolean;
|
|
44
53
|
ready(): void;
|
|
45
|
-
drainQueue(): void
|
|
54
|
+
drainQueue(): Promise<void>;
|
|
55
|
+
getIsEntryPointValue(): number;
|
|
56
|
+
resetEntryPointInfo(): void;
|
|
46
57
|
}
|
|
@@ -21,6 +21,59 @@ declare class MagicPixelImpl {
|
|
|
21
21
|
static setFacebookClientId(fbp: string): void;
|
|
22
22
|
private static setAppVersion;
|
|
23
23
|
static recordPageLoad(pageLoadInfo: AppPageLoad): void;
|
|
24
|
+
/**
|
|
25
|
+
* Set user information for tracking
|
|
26
|
+
* @param userInfo User information object
|
|
27
|
+
*/
|
|
28
|
+
static setUserInfo(userInfo: {
|
|
29
|
+
pid?: string;
|
|
30
|
+
email?: string;
|
|
31
|
+
phone?: string;
|
|
32
|
+
country?: string;
|
|
33
|
+
city?: string;
|
|
34
|
+
state?: string;
|
|
35
|
+
fName?: string;
|
|
36
|
+
lName?: string;
|
|
37
|
+
zip?: string;
|
|
38
|
+
}): void;
|
|
39
|
+
/**
|
|
40
|
+
* Persist custom data to storage
|
|
41
|
+
* @param key Storage key
|
|
42
|
+
* @param value Value to store
|
|
43
|
+
*/
|
|
44
|
+
static persistData(key: string, value: any): void;
|
|
45
|
+
/**
|
|
46
|
+
* Clear specific persisted data
|
|
47
|
+
* @param keys Array of keys to clear
|
|
48
|
+
*/
|
|
49
|
+
static clearPersistedData(keys: string[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* Set data layer variables
|
|
52
|
+
* @param data Data to set in the data layer
|
|
53
|
+
*/
|
|
54
|
+
static setDataLayer(data: MapLike): void;
|
|
55
|
+
/**
|
|
56
|
+
* Register a custom event processor
|
|
57
|
+
* @param eventType Event type to listen for
|
|
58
|
+
* @param processor Function to process the event
|
|
59
|
+
*/
|
|
60
|
+
static registerEventProcessor(eventType: string, processor: (payload: any) => void): void;
|
|
61
|
+
/**
|
|
62
|
+
* Get current data layer state
|
|
63
|
+
* @returns Current data layer object
|
|
64
|
+
*/
|
|
65
|
+
static getDataLayer(): MapLike;
|
|
66
|
+
/**
|
|
67
|
+
* Get event state tracker
|
|
68
|
+
* @returns Array of all tracked events
|
|
69
|
+
*/
|
|
70
|
+
static getEventState(): any[];
|
|
71
|
+
/**
|
|
72
|
+
* Check if a specific event has happened
|
|
73
|
+
* @param eventName Event name to check
|
|
74
|
+
* @returns True if event has occurred
|
|
75
|
+
*/
|
|
76
|
+
static hasEventHappened(eventName: string): boolean;
|
|
24
77
|
}
|
|
25
78
|
export declare const MagicPixelEventBus: typeof EventBus;
|
|
26
79
|
export declare const MagicPixel: typeof MagicPixelImpl;
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { MapLike } from '../common/app-types';
|
|
2
2
|
import type { ClientSdkDeItem } from '../models/mp-client-sdk';
|
|
3
|
+
export declare function processOneDataElement(_sdkDataElements: MapLike<ClientSdkDeItem>, deItem: ClientSdkDeItem, deHelper: any, eventData?: Record<string, any>, _optDeKeys?: string[]): Promise<any>;
|
|
4
|
+
/**
|
|
5
|
+
* Process all the data elements at once, or if a set of keys are specified, processes only
|
|
6
|
+
* those keys and updates the dataElements object in DataStore
|
|
7
|
+
* @param sdkDataElements
|
|
8
|
+
* @param eventData
|
|
9
|
+
* @param optDeKeys
|
|
10
|
+
*/
|
|
11
|
+
export declare function processDataElements(sdkDataElements: MapLike<ClientSdkDeItem>, eventData?: Record<string, any>, optDeKeys?: string[]): Promise<MapLike<any>>;
|
|
3
12
|
export declare class DataElementProcessor {
|
|
4
13
|
/**
|
|
5
14
|
* Process all the data elements at once, or if a set of keys are specified, processes only
|
|
6
|
-
* those keys and updates the dataElements object in
|
|
15
|
+
* those keys and updates the dataElements object in DataStore
|
|
7
16
|
* @param sdkDataElements
|
|
8
17
|
* @param eventData
|
|
9
18
|
* @param optDeKeys
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GeoResponse } from '../models/geo-api-response';
|
|
2
|
+
export declare class GeoLocationProcessor {
|
|
3
|
+
/**
|
|
4
|
+
* Always going to make the call if it's enabled in the sdk, because visit info cookie is passed on to the
|
|
5
|
+
* collector, and it's easier to make changes on the collector end when to make the
|
|
6
|
+
* ip info call or return with an updated cookie expiry
|
|
7
|
+
*/
|
|
8
|
+
static shouldMakeGeoLocationCall(): boolean;
|
|
9
|
+
static makeGeoLocationApiCall(): Promise<GeoResponse | null>;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicpixel/rn-mp-client-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "test",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -51,13 +51,14 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@arkweid/lefthook": "0.7.7",
|
|
53
53
|
"@babel/eslint-parser": "7.19.1",
|
|
54
|
+
"@babel/runtime": "7.26.10",
|
|
54
55
|
"@commitlint/config-conventional": "17.1.0",
|
|
55
56
|
"@react-native-community/eslint-config": "3.1.0",
|
|
56
|
-
"@release-it/conventional-changelog": "
|
|
57
|
+
"@release-it/conventional-changelog": "8.0.1",
|
|
57
58
|
"@types/flat": "5.0.2",
|
|
58
59
|
"@types/jest": "29.0.3",
|
|
59
60
|
"@types/react": "~17.0.21",
|
|
60
|
-
"@types/react-native": "0.
|
|
61
|
+
"@types/react-native": "0.72.8",
|
|
61
62
|
"@types/uuid": "9.0.0",
|
|
62
63
|
"commitlint": "17.1.2",
|
|
63
64
|
"eslint": "8.23.1",
|
|
@@ -66,17 +67,31 @@
|
|
|
66
67
|
"jest": "29.1.1",
|
|
67
68
|
"pod-install": "0.1.38",
|
|
68
69
|
"prettier": "2.7.1",
|
|
69
|
-
"react": "
|
|
70
|
-
"react-native": "0.
|
|
70
|
+
"react": "18.2.0",
|
|
71
|
+
"react-native": "0.72.17",
|
|
71
72
|
"react-native-builder-bob": "0.18.3",
|
|
72
|
-
"release-it": "
|
|
73
|
+
"release-it": "17.1.1",
|
|
73
74
|
"ts-jest": "29.0.2",
|
|
74
75
|
"tsconfig-paths": "4.1.0",
|
|
75
76
|
"typescript": "4.8.3",
|
|
76
|
-
"ts-node": "10.9.1"
|
|
77
|
+
"ts-node": "10.9.1",
|
|
78
|
+
"@octokit/plugin-paginate-rest": "9.2.2",
|
|
79
|
+
"@octokit/request": "8.4.1",
|
|
80
|
+
"@octokit/request-error": "5.1.1",
|
|
81
|
+
"braces": "3.0.3",
|
|
82
|
+
"cross-spawn": "7.0.5",
|
|
83
|
+
"micromatch": "4.0.8",
|
|
84
|
+
"ws": "7.5.10"
|
|
77
85
|
},
|
|
78
86
|
"resolutions": {
|
|
79
|
-
"@types/react": "17.0.21"
|
|
87
|
+
"@types/react": "17.0.21",
|
|
88
|
+
"ip": "2.0.2",
|
|
89
|
+
"pac-resolver": "7.0.1",
|
|
90
|
+
"socks": "2.7.3",
|
|
91
|
+
"proxy-agent": "6.3.1",
|
|
92
|
+
"pac-proxy-agent": "7.0.1",
|
|
93
|
+
"socks-proxy-agent": "8.0.2",
|
|
94
|
+
"agent-base": "7.1.0"
|
|
80
95
|
},
|
|
81
96
|
"peerDependencies": {
|
|
82
97
|
"react": "*",
|
|
@@ -160,9 +175,9 @@
|
|
|
160
175
|
]
|
|
161
176
|
},
|
|
162
177
|
"dependencies": {
|
|
163
|
-
"@react-native-async-storage/async-storage": "1.
|
|
178
|
+
"@react-native-async-storage/async-storage": "1.21.0",
|
|
164
179
|
"flat": "5.0.2",
|
|
165
|
-
"nanoid": "
|
|
180
|
+
"nanoid": "5.1.5",
|
|
166
181
|
"performant-array-to-tree": "1.11.0",
|
|
167
182
|
"react-native-url-polyfill": "1.3.0",
|
|
168
183
|
"uuid": "9.0.0"
|
package/src/common/app-types.ts
CHANGED
package/src/common/constants.ts
CHANGED
package/src/common/data-store.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
VisitInfo,
|
|
11
11
|
VisitorInfo,
|
|
12
12
|
} from './app-types';
|
|
13
|
+
import type { GeoResponse } from '../models/geo-api-response';
|
|
13
14
|
import { Logger } from './logger';
|
|
14
15
|
import type {
|
|
15
16
|
ClientSdkDeItem,
|
|
@@ -43,6 +44,7 @@ export class DataStore {
|
|
|
43
44
|
private static isProcessing = false;
|
|
44
45
|
private static sdkInitOptions: SdkInitOptions;
|
|
45
46
|
private static deviceInfo: MpDeviceInfo;
|
|
47
|
+
private static geoInfo: GeoResponse;
|
|
46
48
|
|
|
47
49
|
private static interestedClientSideEvents: string[] = [];
|
|
48
50
|
private static interestedServerSideEvents: string[] = [];
|
|
@@ -108,6 +110,9 @@ export class DataStore {
|
|
|
108
110
|
idlUrl:
|
|
109
111
|
baseCollectorUrl +
|
|
110
112
|
`/idl/${vendorId}/idl${sdkEnv === 'staging' ? '-staging' : ''}`,
|
|
113
|
+
geoUrl: '/geo',
|
|
114
|
+
baseUrlV4: baseCollectorUrl,
|
|
115
|
+
baseUrlV6: baseCollectorUrl, // For React Native, we'll use the same URL for both IPv4 and IPv6
|
|
111
116
|
};
|
|
112
117
|
return true;
|
|
113
118
|
}
|
|
@@ -385,4 +390,37 @@ export class DataStore {
|
|
|
385
390
|
static setMpEnv(shortEnv: 'stg' | 'prd'): void {
|
|
386
391
|
this.mpEnvShort = shortEnv;
|
|
387
392
|
}
|
|
393
|
+
|
|
394
|
+
static setGeoInfo(geoInfo: GeoResponse): void {
|
|
395
|
+
this.geoInfo = geoInfo;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
static getGeoInfo(): GeoResponse | undefined {
|
|
399
|
+
return this.geoInfo;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
static isGeoLocationEnabledInSdk(): boolean {
|
|
403
|
+
// TODO: Add geo location configuration to SDK settings
|
|
404
|
+
// For now, return true to enable geo location by default
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
static getVisitInfo(): VisitInfo | undefined {
|
|
409
|
+
return this.visitInfo;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
static getBrowser(): string {
|
|
413
|
+
// In React Native, we return the platform as browser equivalent
|
|
414
|
+
return this.devicePlatform;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
static getMpUserStatus(): number {
|
|
418
|
+
// Return user status based on visit count
|
|
419
|
+
// 1 = new user (first visit), 0 = returning user
|
|
420
|
+
const visitInfo = this.getVisitInfo();
|
|
421
|
+
if (!visitInfo) {
|
|
422
|
+
return 1; // Default to new user if no visit info
|
|
423
|
+
}
|
|
424
|
+
return visitInfo.visitCt === 1 ? 1 : 0;
|
|
425
|
+
}
|
|
388
426
|
}
|
|
@@ -67,6 +67,7 @@ export class NetworkService {
|
|
|
67
67
|
headers: {
|
|
68
68
|
'Content-Type': 'text/plain',
|
|
69
69
|
'cache-control': 'no-store',
|
|
70
|
+
'user-agent': 'sajith/123',
|
|
70
71
|
// 'x-dbg': 'trace',
|
|
71
72
|
...DataStore.getCommonCookies(),
|
|
72
73
|
},
|
|
@@ -77,6 +78,7 @@ export class NetworkService {
|
|
|
77
78
|
headers: {
|
|
78
79
|
'Content-Type': 'text/plain',
|
|
79
80
|
'cache-control': 'no-store',
|
|
81
|
+
'user-agent': 'sajith/123',
|
|
80
82
|
// 'x-dbg': 'trace',
|
|
81
83
|
...DataStore.getCommonCookies(),
|
|
82
84
|
},
|
package/src/common/utils.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { flatten, unflatten } from 'flat';
|
|
|
10
10
|
import { EventBus } from './event-bus';
|
|
11
11
|
import { Dimensions, ScaledSize } from 'react-native';
|
|
12
12
|
import { URL } from 'react-native-url-polyfill';
|
|
13
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
13
14
|
|
|
14
15
|
export class Utils {
|
|
15
16
|
static triggerEvent(eventName: string, payload: any): void {
|
|
@@ -207,6 +208,63 @@ export class Utils {
|
|
|
207
208
|
return Constants.LARGE_RANDOM_POOL();
|
|
208
209
|
}
|
|
209
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Make HTTP GET request - React Native implementation
|
|
213
|
+
* @param url URL to fetch
|
|
214
|
+
* @returns Promise with response data
|
|
215
|
+
*/
|
|
216
|
+
static async getHttp<T>(url: string): Promise<T> {
|
|
217
|
+
try {
|
|
218
|
+
const response = await fetch(url, {
|
|
219
|
+
method: 'GET',
|
|
220
|
+
headers: {
|
|
221
|
+
'Content-Type': 'application/json',
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
if (!response.ok) {
|
|
226
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return await response.json();
|
|
230
|
+
} catch (error) {
|
|
231
|
+
Logger.logError('HTTP GET request failed:', error);
|
|
232
|
+
throw error;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Get value from AsyncStorage (React Native equivalent of sessionStorage)
|
|
238
|
+
* @param key Storage key
|
|
239
|
+
* @param defaultValue Default value if key not found
|
|
240
|
+
* @returns Promise with stored value or default
|
|
241
|
+
*/
|
|
242
|
+
static async getValueFromAsyncStorage<T>(
|
|
243
|
+
key: string,
|
|
244
|
+
defaultValue: T
|
|
245
|
+
): Promise<T> {
|
|
246
|
+
try {
|
|
247
|
+
const value = await AsyncStorage.getItem(key);
|
|
248
|
+
return value ? JSON.parse(value) : defaultValue;
|
|
249
|
+
} catch (error) {
|
|
250
|
+
Logger.logError('Error getting value from AsyncStorage:', error);
|
|
251
|
+
return defaultValue;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Set value to AsyncStorage (React Native equivalent of sessionStorage)
|
|
257
|
+
* @param key Storage key
|
|
258
|
+
* @param value Value to store
|
|
259
|
+
*/
|
|
260
|
+
static async setValueToAsyncStorage(key: string, value: any): Promise<void> {
|
|
261
|
+
try {
|
|
262
|
+
await AsyncStorage.setItem(key, JSON.stringify(value));
|
|
263
|
+
} catch (error) {
|
|
264
|
+
Logger.logError('Error setting value to AsyncStorage:', error);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
210
268
|
static getSimpleDebugId(prefix?: string): string {
|
|
211
269
|
return `${prefix ?? ''}${this.randomNumber(100000000, 99999999999)}`;
|
|
212
270
|
}
|