@glomopay/react-native-sdk 2.0.2 → 3.1.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/CHANGELOG.md +79 -0
- package/MIGRATION.md +50 -0
- package/README.md +348 -316
- package/lib/config/base.d.ts +17 -11
- package/lib/config/base.d.ts.map +1 -1
- package/lib/config/base.js +19 -7
- package/lib/config/segment.js +3 -3
- package/lib/glomo-checkout.d.ts +8 -0
- package/lib/glomo-checkout.d.ts.map +1 -0
- package/lib/glomo-checkout.js +106 -0
- package/lib/glomo-lrs-checkout.js +9 -9
- package/lib/glomo-standard-checkout.d.ts +25 -0
- package/lib/glomo-standard-checkout.d.ts.map +1 -0
- package/lib/glomo-standard-checkout.js +229 -0
- package/lib/glomo-subscriptions-checkout.d.ts +8 -0
- package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
- package/lib/glomo-subscriptions-checkout.js +85 -0
- package/lib/index.d.ts +5 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -5
- package/lib/injections/index.d.ts +1 -0
- package/lib/injections/index.d.ts.map +1 -1
- package/lib/injections/index.js +2 -0
- package/lib/injections/webview-flow.injection.d.ts.map +1 -1
- package/lib/injections/webview-flow.injection.js +106 -69
- package/lib/injections/webview-main.injection.d.ts.map +1 -1
- package/lib/injections/webview-main.injection.js +112 -77
- package/lib/injections/webview-standard.injection.d.ts +3 -0
- package/lib/injections/webview-standard.injection.d.ts.map +1 -0
- package/lib/injections/webview-standard.injection.js +214 -0
- package/lib/services/order-type-fetcher.d.ts +28 -0
- package/lib/services/order-type-fetcher.d.ts.map +1 -0
- package/lib/services/order-type-fetcher.js +99 -0
- package/lib/types/checkout.d.ts +65 -0
- package/lib/types/checkout.d.ts.map +1 -0
- package/lib/types/checkout.js +3 -0
- package/lib/types/standard-checkout.d.ts +40 -0
- package/lib/types/standard-checkout.d.ts.map +1 -0
- package/lib/types/standard-checkout.js +3 -0
- package/lib/types/subscriptions-checkout.d.ts +29 -0
- package/lib/types/subscriptions-checkout.d.ts.map +1 -0
- package/lib/types/subscriptions-checkout.js +3 -0
- package/lib/use-glomo-checkout.d.ts +54 -0
- package/lib/use-glomo-checkout.d.ts.map +1 -0
- package/lib/use-glomo-checkout.js +261 -0
- package/lib/use-lrs-checkout.d.ts +9 -4
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-lrs-checkout.js +76 -93
- package/lib/use-standard-checkout.d.ts +74 -0
- package/lib/use-standard-checkout.d.ts.map +1 -0
- package/lib/use-standard-checkout.js +849 -0
- package/lib/utils/analytics.d.ts +188 -2
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +636 -22
- package/lib/utils/device-compliance.d.ts.map +1 -1
- package/lib/utils/device-compliance.js +3 -4
- package/lib/utils/validation.d.ts.map +1 -1
- package/lib/utils/validation.js +7 -6
- package/package.json +17 -5
- package/src/config/base.ts +36 -17
- package/src/config/segment.ts +3 -3
- package/src/glomo-checkout.tsx +147 -0
- package/src/glomo-lrs-checkout.tsx +9 -9
- package/src/glomo-standard-checkout.tsx +353 -0
- package/src/glomo-subscriptions-checkout.tsx +83 -0
- package/src/index.ts +13 -7
- package/src/injections/index.ts +2 -0
- package/src/injections/webview-flow.injection.ts +106 -69
- package/src/injections/webview-main.injection.ts +112 -77
- package/src/injections/webview-standard.injection.ts +211 -0
- package/src/services/order-type-fetcher.ts +86 -0
- package/src/types/checkout.ts +72 -0
- package/src/types/standard-checkout.ts +49 -0
- package/src/types/subscriptions-checkout.ts +31 -0
- package/src/use-glomo-checkout.tsx +369 -0
- package/src/use-lrs-checkout.tsx +91 -111
- package/src/use-standard-checkout.tsx +1203 -0
- package/src/utils/analytics.ts +908 -34
- package/src/utils/device-compliance.ts +3 -4
- package/src/utils/validation.ts +7 -8
package/lib/utils/analytics.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* Analytics failures never break the SDK.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.subscriptionCheckoutTrackers = exports.standardCheckoutTrackers = void 0;
|
|
14
15
|
exports.trackStartSuccess = trackStartSuccess;
|
|
15
16
|
exports.trackStartAttempt = trackStartAttempt;
|
|
16
17
|
exports.trackStartFailure = trackStartFailure;
|
|
@@ -22,8 +23,39 @@ exports.trackPaymentFailure = trackPaymentFailure;
|
|
|
22
23
|
exports.trackPaymentTerminate = trackPaymentTerminate;
|
|
23
24
|
exports.trackConnectionError = trackConnectionError;
|
|
24
25
|
exports.trackEducationStepsShown = trackEducationStepsShown;
|
|
26
|
+
exports.trackEducationStepsFailedToShow = trackEducationStepsFailedToShow;
|
|
25
27
|
exports.trackSdkError = trackSdkError;
|
|
28
|
+
exports.trackStandardStartSuccess = trackStandardStartSuccess;
|
|
29
|
+
exports.trackStandardStartAttempt = trackStandardStartAttempt;
|
|
30
|
+
exports.trackStandardStartFailure = trackStandardStartFailure;
|
|
31
|
+
exports.trackStandardWindowOpen = trackStandardWindowOpen;
|
|
32
|
+
exports.trackStandardWindowClose = trackStandardWindowClose;
|
|
33
|
+
exports.trackStandardInvalidMessageReceived = trackStandardInvalidMessageReceived;
|
|
34
|
+
exports.trackStandardPaymentSuccess = trackStandardPaymentSuccess;
|
|
35
|
+
exports.trackStandardPaymentFailure = trackStandardPaymentFailure;
|
|
36
|
+
exports.trackStandardPaymentTerminate = trackStandardPaymentTerminate;
|
|
37
|
+
exports.trackStandardConnectionError = trackStandardConnectionError;
|
|
38
|
+
exports.trackStandardSdkError = trackStandardSdkError;
|
|
39
|
+
exports.trackStandardBankTransferSubmitted = trackStandardBankTransferSubmitted;
|
|
40
|
+
exports.trackStandardPayViaBankCompleted = trackStandardPayViaBankCompleted;
|
|
41
|
+
exports.trackStandardPayViaBankBankConnectionSuccessful = trackStandardPayViaBankBankConnectionSuccessful;
|
|
42
|
+
exports.trackOrderTypeDetectionStarted = trackOrderTypeDetectionStarted;
|
|
43
|
+
exports.trackOrderTypeDetectionResolved = trackOrderTypeDetectionResolved;
|
|
44
|
+
exports.trackOrderTypeDetectionFailed = trackOrderTypeDetectionFailed;
|
|
26
45
|
exports.checkAnalyticsStatus = checkAnalyticsStatus;
|
|
46
|
+
exports.trackSubscriptionStartAttempt = trackSubscriptionStartAttempt;
|
|
47
|
+
exports.trackSubscriptionStartSuccess = trackSubscriptionStartSuccess;
|
|
48
|
+
exports.trackSubscriptionStartFailure = trackSubscriptionStartFailure;
|
|
49
|
+
exports.trackSubscriptionWindowOpen = trackSubscriptionWindowOpen;
|
|
50
|
+
exports.trackSubscriptionWindowClose = trackSubscriptionWindowClose;
|
|
51
|
+
exports.trackSubscriptionInvalidMessageReceived = trackSubscriptionInvalidMessageReceived;
|
|
52
|
+
exports.trackSubscriptionPaymentSuccess = trackSubscriptionPaymentSuccess;
|
|
53
|
+
exports.trackSubscriptionPaymentFailure = trackSubscriptionPaymentFailure;
|
|
54
|
+
exports.trackSubscriptionPaymentTerminate = trackSubscriptionPaymentTerminate;
|
|
55
|
+
exports.trackSubscriptionConnectionError = trackSubscriptionConnectionError;
|
|
56
|
+
exports.trackSubscriptionSdkError = trackSubscriptionSdkError;
|
|
57
|
+
exports.trackUseOfUnsupportedFunctionality = trackUseOfUnsupportedFunctionality;
|
|
58
|
+
const react_native_1 = require("react-native");
|
|
27
59
|
const segment_1 = require("../config/segment");
|
|
28
60
|
/**
|
|
29
61
|
* Gets the SDK version from package.json
|
|
@@ -34,7 +66,6 @@ const segment_1 = require("../config/segment");
|
|
|
34
66
|
function getSdkVersion() {
|
|
35
67
|
try {
|
|
36
68
|
// Using require to dynamically import package.json
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
38
69
|
const packageJson = require("../../package.json");
|
|
39
70
|
return packageJson.version || "unknown";
|
|
40
71
|
}
|
|
@@ -50,18 +81,23 @@ function getSdkVersion() {
|
|
|
50
81
|
* @param publicKey - The public key of the merchant
|
|
51
82
|
* @param devMode - Whether dev mode is enabled
|
|
52
83
|
* @param mockMode - Whether mock mode is enabled
|
|
53
|
-
* @param
|
|
84
|
+
* @param checkoutUrl - The checkout URL
|
|
85
|
+
* @param flowType - The flow type
|
|
54
86
|
* @returns Common properties object
|
|
55
87
|
*/
|
|
56
|
-
function buildCommonProperties(orderId, publicKey, devMode = false, mockMode = false,
|
|
88
|
+
function buildCommonProperties(orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, flowType) {
|
|
57
89
|
return {
|
|
58
90
|
orderId,
|
|
59
91
|
publicKey,
|
|
60
|
-
|
|
92
|
+
checkoutUrl,
|
|
61
93
|
devMode,
|
|
62
94
|
mockMode,
|
|
95
|
+
platform: "react-native",
|
|
96
|
+
deviceOS: react_native_1.Platform.OS,
|
|
97
|
+
deviceOSVersion: String(react_native_1.Platform.Version),
|
|
63
98
|
sdkVersion: getSdkVersion(),
|
|
64
99
|
timestamp: new Date().toISOString(),
|
|
100
|
+
...(flowType && { flowType }),
|
|
65
101
|
};
|
|
66
102
|
}
|
|
67
103
|
/**
|
|
@@ -78,7 +114,7 @@ async function trackEvent(eventName, properties = {}, devMode = false) {
|
|
|
78
114
|
// Returning early if GlomoPay Segment is not available
|
|
79
115
|
if (!(0, segment_1.isSegmentAvailable)()) {
|
|
80
116
|
if (devMode) {
|
|
81
|
-
console.log(`[
|
|
117
|
+
console.log(`[Glomo-RN-SDK] Segment not available. Event "${eventName}" not tracked.`, properties);
|
|
82
118
|
}
|
|
83
119
|
return;
|
|
84
120
|
}
|
|
@@ -88,7 +124,7 @@ async function trackEvent(eventName, properties = {}, devMode = false) {
|
|
|
88
124
|
// Double-checking if the client exists (TypeScript safety)
|
|
89
125
|
if (!client || !anonymousId) {
|
|
90
126
|
if (devMode) {
|
|
91
|
-
console.log(`[
|
|
127
|
+
console.log(`[Glomo-RN-SDK] Segment client is null. Event "${eventName}" not tracked.`);
|
|
92
128
|
}
|
|
93
129
|
return;
|
|
94
130
|
}
|
|
@@ -114,13 +150,13 @@ async function trackEvent(eventName, properties = {}, devMode = false) {
|
|
|
114
150
|
// Sending event via REST API
|
|
115
151
|
await client.post("/track", payload);
|
|
116
152
|
if (devMode) {
|
|
117
|
-
console.log(`[
|
|
153
|
+
console.log(`[Glomo-RN-SDK] Tracked event: ${eventName}`, eventProperties);
|
|
118
154
|
}
|
|
119
155
|
}
|
|
120
156
|
catch (error) {
|
|
121
157
|
if (devMode) {
|
|
122
158
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
123
|
-
console.error(`[
|
|
159
|
+
console.error(`[Glomo-RN-SDK] Error tracking event ${eventName}:`, errorMessage);
|
|
124
160
|
}
|
|
125
161
|
// Silently failing - GlomoPay analytics should never break the SDK
|
|
126
162
|
}
|
|
@@ -146,7 +182,7 @@ function trackStartSuccess(orderId, publicKey, devMode = false, mockMode = false
|
|
|
146
182
|
// Async tracking to avoid blocking the main thread
|
|
147
183
|
trackEvent("LRS Checkout Started", properties, devMode).catch((error) => {
|
|
148
184
|
if (devMode) {
|
|
149
|
-
console.error(`[
|
|
185
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on start() success:`, error);
|
|
150
186
|
}
|
|
151
187
|
});
|
|
152
188
|
}
|
|
@@ -173,7 +209,7 @@ function trackStartAttempt(status, orderId, publicKey, devMode = false, mockMode
|
|
|
173
209
|
// Async tracking to avoid blocking the main thread
|
|
174
210
|
trackEvent("LRS Checkout Start Attempted", properties, devMode).catch((error) => {
|
|
175
211
|
if (devMode) {
|
|
176
|
-
console.error(`[
|
|
212
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on start() attempt:`, error);
|
|
177
213
|
}
|
|
178
214
|
});
|
|
179
215
|
}
|
|
@@ -200,7 +236,7 @@ function trackStartFailure(reason, orderId, publicKey, devMode = false, mockMode
|
|
|
200
236
|
// Async tracking to avoid blocking the main thread
|
|
201
237
|
trackEvent("LRS Checkout Start Failed", properties, devMode).catch((error) => {
|
|
202
238
|
if (devMode) {
|
|
203
|
-
console.error(`[
|
|
239
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on start() failure:`, error);
|
|
204
240
|
}
|
|
205
241
|
});
|
|
206
242
|
}
|
|
@@ -224,7 +260,7 @@ function trackWindowOpen(source, url, orderId, publicKey, devMode = false, mockM
|
|
|
224
260
|
// Async tracking to avoid blocking the main thread
|
|
225
261
|
trackEvent("LRS Checkout Window Open", properties, devMode).catch((error) => {
|
|
226
262
|
if (devMode) {
|
|
227
|
-
console.error(`[
|
|
263
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on window.open:`, error);
|
|
228
264
|
}
|
|
229
265
|
});
|
|
230
266
|
}
|
|
@@ -246,7 +282,7 @@ function trackWindowClose(source, orderId, publicKey, devMode = false, mockMode
|
|
|
246
282
|
// Async tracking to avoid blocking the main thread
|
|
247
283
|
trackEvent("LRS Checkout Window Close", properties, devMode).catch((error) => {
|
|
248
284
|
if (devMode) {
|
|
249
|
-
console.error(`[
|
|
285
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on window.close:`, error);
|
|
250
286
|
}
|
|
251
287
|
});
|
|
252
288
|
}
|
|
@@ -295,7 +331,7 @@ function trackInvalidMessageReceived(webviewType, data, url, orderId, publicKey,
|
|
|
295
331
|
// Async tracking to avoid blocking the main thread
|
|
296
332
|
trackEvent("LRS Checkout Invalid Message Received", properties, devMode).catch((error) => {
|
|
297
333
|
if (devMode) {
|
|
298
|
-
console.error(`[
|
|
334
|
+
console.error(`[Glomo-RN-SDK] Event tracking error for invalid message received event:`, error);
|
|
299
335
|
}
|
|
300
336
|
});
|
|
301
337
|
}
|
|
@@ -317,7 +353,7 @@ function trackPaymentSuccess(orderId, paymentId, publicKey, devMode = false, moc
|
|
|
317
353
|
// Async tracking to avoid blocking the main thread
|
|
318
354
|
trackEvent("LRS Payment Success", properties, devMode).catch((error) => {
|
|
319
355
|
if (devMode) {
|
|
320
|
-
console.error(`[
|
|
356
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on payment success callback:`, error);
|
|
321
357
|
}
|
|
322
358
|
});
|
|
323
359
|
}
|
|
@@ -339,7 +375,7 @@ function trackPaymentFailure(orderId, paymentId, publicKey, devMode = false, moc
|
|
|
339
375
|
// Async tracking to avoid blocking the main thread
|
|
340
376
|
trackEvent("LRS Payment Failure", properties, devMode).catch((error) => {
|
|
341
377
|
if (devMode) {
|
|
342
|
-
console.error(`[
|
|
378
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on payment failure callback:`, error);
|
|
343
379
|
}
|
|
344
380
|
});
|
|
345
381
|
}
|
|
@@ -361,7 +397,7 @@ function trackPaymentTerminate(orderId, source, publicKey, devMode = false, mock
|
|
|
361
397
|
// Async tracking to avoid blocking the main thread
|
|
362
398
|
trackEvent("LRS Payment Terminated", properties, devMode).catch((error) => {
|
|
363
399
|
if (devMode) {
|
|
364
|
-
console.error(`[
|
|
400
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on payment terminate callback:`, error);
|
|
365
401
|
}
|
|
366
402
|
});
|
|
367
403
|
}
|
|
@@ -383,7 +419,7 @@ function trackConnectionError(orderId, errorCode, publicKey, devMode = false, mo
|
|
|
383
419
|
// Async tracking to avoid blocking the main thread
|
|
384
420
|
trackEvent("LRS Connection Error", properties, devMode).catch((error) => {
|
|
385
421
|
if (devMode) {
|
|
386
|
-
console.error(`[
|
|
422
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on connection error callback:`, error);
|
|
387
423
|
}
|
|
388
424
|
});
|
|
389
425
|
}
|
|
@@ -404,7 +440,28 @@ function trackEducationStepsShown(orderId, publicKey, devMode = false, mockMode
|
|
|
404
440
|
};
|
|
405
441
|
trackEvent("LRS Has Education Steps", properties, devMode).catch((error) => {
|
|
406
442
|
if (devMode) {
|
|
407
|
-
console.error(`[
|
|
443
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on education steps shown event:`, error);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Tracks when the education carousel URL is invalid and the carousel cannot be shown
|
|
449
|
+
*
|
|
450
|
+
* @param orderId - The order ID
|
|
451
|
+
* @param publicKey - The public key of the merchant
|
|
452
|
+
* @param devMode - Whether dev mode is enabled
|
|
453
|
+
* @param mockMode - Whether mock mode is enabled
|
|
454
|
+
* @param lrsUrl - The LRS checkout URL
|
|
455
|
+
* @param reason - Why the carousel failed to show
|
|
456
|
+
*/
|
|
457
|
+
function trackEducationStepsFailedToShow(orderId, publicKey, devMode = false, mockMode = false, lrsUrl, reason) {
|
|
458
|
+
const properties = {
|
|
459
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, lrsUrl),
|
|
460
|
+
...(reason && { reason }),
|
|
461
|
+
};
|
|
462
|
+
trackEvent("LRS Education Steps Failed To Show", properties, devMode).catch((error) => {
|
|
463
|
+
if (devMode) {
|
|
464
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on education steps failed to show event:`, error);
|
|
408
465
|
}
|
|
409
466
|
});
|
|
410
467
|
}
|
|
@@ -427,7 +484,291 @@ function trackSdkError(errors, orderId, publicKey, devMode = false, mockMode = f
|
|
|
427
484
|
// Async tracking to avoid blocking the main thread
|
|
428
485
|
trackEvent("LRS SDK Error", properties, devMode).catch((error) => {
|
|
429
486
|
if (devMode) {
|
|
430
|
-
console.error(`[
|
|
487
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on SDK error callback:`, error);
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
// ---------------------------------------------------------------------------
|
|
492
|
+
// Standard Checkout Trackers
|
|
493
|
+
// ---------------------------------------------------------------------------
|
|
494
|
+
/**
|
|
495
|
+
* Tracks when the standard checkout start() method has been called successfully
|
|
496
|
+
*/
|
|
497
|
+
function trackStandardStartSuccess(orderId, publicKey, devMode = false, mockMode = false, standardUrl, jailbreakDetectionInfo) {
|
|
498
|
+
const properties = {
|
|
499
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
500
|
+
...(jailbreakDetectionInfo && {
|
|
501
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
502
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
503
|
+
}),
|
|
504
|
+
};
|
|
505
|
+
trackEvent("Standard Checkout Started", properties, devMode).catch((error) => {
|
|
506
|
+
if (devMode) {
|
|
507
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard start:", error);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Tracks when the standard checkout start() method is called (attempted)
|
|
513
|
+
*/
|
|
514
|
+
function trackStandardStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, standardUrl, jailbreakDetectionInfo) {
|
|
515
|
+
const properties = {
|
|
516
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
517
|
+
status,
|
|
518
|
+
...(jailbreakDetectionInfo && {
|
|
519
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
520
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
521
|
+
}),
|
|
522
|
+
};
|
|
523
|
+
trackEvent("Standard Checkout Start Attempted", properties, devMode).catch((error) => {
|
|
524
|
+
if (devMode) {
|
|
525
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard start attempt:", error);
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Tracks when the standard checkout start() method fails
|
|
531
|
+
*/
|
|
532
|
+
function trackStandardStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, standardUrl, jailbreakDetectionInfo) {
|
|
533
|
+
const properties = {
|
|
534
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
535
|
+
failureReason: reason,
|
|
536
|
+
...(jailbreakDetectionInfo && {
|
|
537
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
538
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
539
|
+
}),
|
|
540
|
+
};
|
|
541
|
+
trackEvent("Standard Checkout Start Failed", properties, devMode).catch((error) => {
|
|
542
|
+
if (devMode) {
|
|
543
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard start failure:", error);
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Tracks when window.open is intercepted from the standard checkout WebView
|
|
549
|
+
*/
|
|
550
|
+
function trackStandardWindowOpen(source, url, orderId, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
551
|
+
const properties = {
|
|
552
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
553
|
+
source,
|
|
554
|
+
url,
|
|
555
|
+
};
|
|
556
|
+
trackEvent("Standard Checkout Window Open", properties, devMode).catch((error) => {
|
|
557
|
+
if (devMode) {
|
|
558
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard window open:", error);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Tracks when window.close is intercepted from the standard checkout WebView
|
|
564
|
+
*/
|
|
565
|
+
function trackStandardWindowClose(source, orderId, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
566
|
+
const properties = {
|
|
567
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
568
|
+
source,
|
|
569
|
+
};
|
|
570
|
+
trackEvent("Standard Checkout Window Close", properties, devMode).catch((error) => {
|
|
571
|
+
if (devMode) {
|
|
572
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard window close:", error);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Tracks when invalid message data is received from a standard checkout WebView
|
|
578
|
+
*/
|
|
579
|
+
function trackStandardInvalidMessageReceived(webviewType, data, url, orderId, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
580
|
+
let dataString;
|
|
581
|
+
try {
|
|
582
|
+
if (data === null) {
|
|
583
|
+
dataString = "null";
|
|
584
|
+
}
|
|
585
|
+
else if (data === undefined) {
|
|
586
|
+
dataString = "undefined";
|
|
587
|
+
}
|
|
588
|
+
else if (typeof data === "string") {
|
|
589
|
+
dataString = data;
|
|
590
|
+
}
|
|
591
|
+
else if (typeof data === "object") {
|
|
592
|
+
dataString = JSON.stringify(data);
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
dataString = String(data);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
catch (_a) {
|
|
599
|
+
dataString = "[unable to stringify]";
|
|
600
|
+
}
|
|
601
|
+
const properties = {
|
|
602
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
603
|
+
webviewType,
|
|
604
|
+
data: dataString,
|
|
605
|
+
dataType: data === null ? "null" : typeof data,
|
|
606
|
+
...(url && { url }),
|
|
607
|
+
};
|
|
608
|
+
trackEvent("Standard Checkout Invalid Message Received", properties, devMode).catch((error) => {
|
|
609
|
+
if (devMode) {
|
|
610
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard invalid message:", error);
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Tracks when standard checkout onPaymentSuccess callback is invoked
|
|
616
|
+
*/
|
|
617
|
+
function trackStandardPaymentSuccess(orderId, paymentId, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
618
|
+
const properties = {
|
|
619
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
620
|
+
paymentId,
|
|
621
|
+
};
|
|
622
|
+
trackEvent("Standard Payment Success", properties, devMode).catch((error) => {
|
|
623
|
+
if (devMode) {
|
|
624
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard payment success:", error);
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Tracks when standard checkout onPaymentFailure callback is invoked
|
|
630
|
+
*/
|
|
631
|
+
function trackStandardPaymentFailure(orderId, paymentId, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
632
|
+
const properties = {
|
|
633
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
634
|
+
paymentId,
|
|
635
|
+
};
|
|
636
|
+
trackEvent("Standard Payment Failure", properties, devMode).catch((error) => {
|
|
637
|
+
if (devMode) {
|
|
638
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard payment failure:", error);
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Tracks when standard checkout onPaymentTerminate callback is invoked
|
|
644
|
+
*/
|
|
645
|
+
function trackStandardPaymentTerminate(orderId, source, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
646
|
+
const properties = {
|
|
647
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
648
|
+
terminationSource: source,
|
|
649
|
+
};
|
|
650
|
+
trackEvent("Standard Payment Terminated", properties, devMode).catch((error) => {
|
|
651
|
+
if (devMode) {
|
|
652
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard payment terminate:", error);
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Tracks when standard checkout onConnectionError callback is invoked
|
|
658
|
+
*/
|
|
659
|
+
function trackStandardConnectionError(orderId, errorCode, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
660
|
+
const properties = {
|
|
661
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
662
|
+
...(errorCode !== undefined && { errorCode }),
|
|
663
|
+
};
|
|
664
|
+
trackEvent("Standard Connection Error", properties, devMode).catch((error) => {
|
|
665
|
+
if (devMode) {
|
|
666
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard connection error:", error);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Tracks when standard checkout onSdkError callback is invoked
|
|
672
|
+
*/
|
|
673
|
+
function trackStandardSdkError(errors, orderId, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
674
|
+
const properties = {
|
|
675
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
676
|
+
errors,
|
|
677
|
+
errorCount: errors.length,
|
|
678
|
+
};
|
|
679
|
+
trackEvent("Standard SDK Error", properties, devMode).catch((error) => {
|
|
680
|
+
if (devMode) {
|
|
681
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard SDK error:", error);
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
function trackStandardBankTransferSubmitted(orderId, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
686
|
+
const properties = {
|
|
687
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
688
|
+
};
|
|
689
|
+
trackEvent("Standard Bank Transfer Submitted", properties, devMode).catch((error) => {
|
|
690
|
+
if (devMode) {
|
|
691
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard bank transfer submitted:", error);
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
function trackStandardPayViaBankCompleted(orderId, publicKey, status, devMode = false, mockMode = false, standardUrl) {
|
|
696
|
+
const properties = {
|
|
697
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
698
|
+
payViaBankStatus: status,
|
|
699
|
+
};
|
|
700
|
+
trackEvent("Standard Pay Via Bank Completed", properties, devMode).catch((error) => {
|
|
701
|
+
if (devMode) {
|
|
702
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard pay via bank completed:", error);
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
function trackStandardPayViaBankBankConnectionSuccessful(orderId, publicKey, bankIdentifier, devMode = false, mockMode = false, standardUrl) {
|
|
707
|
+
const properties = {
|
|
708
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
709
|
+
bankIdentifier,
|
|
710
|
+
};
|
|
711
|
+
trackEvent("Standard Pay Via Bank Bank Connection Successful", properties, devMode).catch((error) => {
|
|
712
|
+
if (devMode) {
|
|
713
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard pay via bank connection:", error);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
// ---------------------------------------------------------------------------
|
|
718
|
+
// Order Type Detection Trackers (Unified Flow)
|
|
719
|
+
// ---------------------------------------------------------------------------
|
|
720
|
+
/**
|
|
721
|
+
* Tracks when order type detection starts
|
|
722
|
+
*
|
|
723
|
+
* @param orderId - The order ID
|
|
724
|
+
* @param publicKey - The public key of the merchant
|
|
725
|
+
* @param devMode - Whether dev mode is enabled
|
|
726
|
+
*/
|
|
727
|
+
function trackOrderTypeDetectionStarted(orderId, publicKey, devMode = false) {
|
|
728
|
+
const properties = {
|
|
729
|
+
...buildCommonProperties(orderId, publicKey, devMode, false, undefined, "unified"),
|
|
730
|
+
};
|
|
731
|
+
trackEvent("Order Type Detection Started", properties, devMode).catch((error) => {
|
|
732
|
+
if (devMode) {
|
|
733
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on order type detection started:`, error);
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Tracks when order type detection resolves successfully
|
|
739
|
+
*
|
|
740
|
+
* @param orderId - The order ID
|
|
741
|
+
* @param publicKey - The public key of the merchant
|
|
742
|
+
* @param resolvedType - The resolved order type ("lrs" or "standard")
|
|
743
|
+
* @param devMode - Whether dev mode is enabled
|
|
744
|
+
*/
|
|
745
|
+
function trackOrderTypeDetectionResolved(orderId, publicKey, resolvedType, devMode = false) {
|
|
746
|
+
const eventName = resolvedType === "lrs" ? "Order Type Resolved LRS" : "Order Type Resolved Standard";
|
|
747
|
+
const properties = {
|
|
748
|
+
...buildCommonProperties(orderId, publicKey, devMode, false, undefined, "unified"),
|
|
749
|
+
};
|
|
750
|
+
trackEvent(eventName, properties, devMode).catch((error) => {
|
|
751
|
+
if (devMode) {
|
|
752
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on order type detection resolved:`, error);
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Tracks when order type detection fails
|
|
758
|
+
*
|
|
759
|
+
* @param orderId - The order ID
|
|
760
|
+
* @param publicKey - The public key of the merchant
|
|
761
|
+
* @param error - The error message
|
|
762
|
+
* @param devMode - Whether dev mode is enabled
|
|
763
|
+
*/
|
|
764
|
+
function trackOrderTypeDetectionFailed(orderId, publicKey, error, devMode = false) {
|
|
765
|
+
const properties = {
|
|
766
|
+
...buildCommonProperties(orderId, publicKey, devMode, false, undefined, "unified"),
|
|
767
|
+
error,
|
|
768
|
+
};
|
|
769
|
+
trackEvent("Order Type Detection Failed", properties, devMode).catch((trackError) => {
|
|
770
|
+
if (devMode) {
|
|
771
|
+
console.error(`[Glomo-RN-SDK] Event tracking error on order type detection failed:`, trackError);
|
|
431
772
|
}
|
|
432
773
|
});
|
|
433
774
|
}
|
|
@@ -442,11 +783,284 @@ function checkAnalyticsStatus(devMode = false) {
|
|
|
442
783
|
const available = (0, segment_1.isSegmentAvailable)();
|
|
443
784
|
if (devMode) {
|
|
444
785
|
if (available) {
|
|
445
|
-
console.log("[
|
|
786
|
+
console.log("[Glomo-RN-SDK] Analytics: ENABLED");
|
|
446
787
|
}
|
|
447
788
|
else {
|
|
448
|
-
console.log("[
|
|
789
|
+
console.log("[Glomo-RN-SDK] Analytics: DISABLED");
|
|
449
790
|
}
|
|
450
791
|
}
|
|
451
792
|
return available;
|
|
452
793
|
}
|
|
794
|
+
// ---------------------------------------------------------------------------
|
|
795
|
+
// Subscription Checkout Trackers
|
|
796
|
+
// ---------------------------------------------------------------------------
|
|
797
|
+
/**
|
|
798
|
+
* Tracks when the subscription checkout start() method is called (attempted)
|
|
799
|
+
*/
|
|
800
|
+
function trackSubscriptionStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
|
|
801
|
+
const properties = {
|
|
802
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
803
|
+
subscriptionId: orderId,
|
|
804
|
+
status,
|
|
805
|
+
...(jailbreakDetectionInfo && {
|
|
806
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
807
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
808
|
+
}),
|
|
809
|
+
};
|
|
810
|
+
trackEvent("Subscription Checkout Start Attempted", properties, devMode).catch((error) => {
|
|
811
|
+
if (devMode) {
|
|
812
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription start attempt:", error);
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Tracks when the subscription checkout start() method has been called successfully
|
|
818
|
+
*/
|
|
819
|
+
function trackSubscriptionStartSuccess(orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
|
|
820
|
+
const properties = {
|
|
821
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
822
|
+
subscriptionId: orderId,
|
|
823
|
+
...(jailbreakDetectionInfo && {
|
|
824
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
825
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
826
|
+
}),
|
|
827
|
+
};
|
|
828
|
+
trackEvent("Subscription Checkout Started", properties, devMode).catch((error) => {
|
|
829
|
+
if (devMode) {
|
|
830
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription start:", error);
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Tracks when the subscription checkout start() method fails
|
|
836
|
+
*/
|
|
837
|
+
function trackSubscriptionStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
|
|
838
|
+
const properties = {
|
|
839
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
840
|
+
subscriptionId: orderId,
|
|
841
|
+
failureReason: reason,
|
|
842
|
+
...(jailbreakDetectionInfo && {
|
|
843
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
844
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
845
|
+
}),
|
|
846
|
+
};
|
|
847
|
+
trackEvent("Subscription Checkout Start Failed", properties, devMode).catch((error) => {
|
|
848
|
+
if (devMode) {
|
|
849
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription start failure:", error);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Tracks when window.open is intercepted from the subscription checkout WebView
|
|
855
|
+
*/
|
|
856
|
+
function trackSubscriptionWindowOpen(source, url, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
857
|
+
const properties = {
|
|
858
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
859
|
+
subscriptionId: orderId,
|
|
860
|
+
source,
|
|
861
|
+
url,
|
|
862
|
+
};
|
|
863
|
+
trackEvent("Subscription Checkout Window Open", properties, devMode).catch((error) => {
|
|
864
|
+
if (devMode) {
|
|
865
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription window open:", error);
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Tracks when window.close is intercepted from the subscription checkout WebView
|
|
871
|
+
*/
|
|
872
|
+
function trackSubscriptionWindowClose(source, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
873
|
+
const properties = {
|
|
874
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
875
|
+
subscriptionId: orderId,
|
|
876
|
+
source,
|
|
877
|
+
};
|
|
878
|
+
trackEvent("Subscription Checkout Window Close", properties, devMode).catch((error) => {
|
|
879
|
+
if (devMode) {
|
|
880
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription window close:", error);
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Tracks when invalid message data is received from a subscription checkout WebView
|
|
886
|
+
*/
|
|
887
|
+
function trackSubscriptionInvalidMessageReceived(webviewType, data, url, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
888
|
+
let dataString;
|
|
889
|
+
try {
|
|
890
|
+
if (data === null) {
|
|
891
|
+
dataString = "null";
|
|
892
|
+
}
|
|
893
|
+
else if (data === undefined) {
|
|
894
|
+
dataString = "undefined";
|
|
895
|
+
}
|
|
896
|
+
else if (typeof data === "string") {
|
|
897
|
+
dataString = data;
|
|
898
|
+
}
|
|
899
|
+
else if (typeof data === "object") {
|
|
900
|
+
dataString = JSON.stringify(data);
|
|
901
|
+
}
|
|
902
|
+
else {
|
|
903
|
+
dataString = String(data);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
catch (_a) {
|
|
907
|
+
dataString = "[unable to stringify]";
|
|
908
|
+
}
|
|
909
|
+
const properties = {
|
|
910
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
911
|
+
subscriptionId: orderId,
|
|
912
|
+
webviewType,
|
|
913
|
+
data: dataString,
|
|
914
|
+
dataType: data === null ? "null" : typeof data,
|
|
915
|
+
...(url && { url }),
|
|
916
|
+
};
|
|
917
|
+
trackEvent("Subscription Checkout Invalid Message Received", properties, devMode).catch((error) => {
|
|
918
|
+
if (devMode) {
|
|
919
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription invalid message:", error);
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Tracks when subscription checkout onPaymentSuccess callback is invoked
|
|
925
|
+
*/
|
|
926
|
+
function trackSubscriptionPaymentSuccess(orderId, paymentId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
927
|
+
const properties = {
|
|
928
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
929
|
+
subscriptionId: orderId,
|
|
930
|
+
paymentId,
|
|
931
|
+
};
|
|
932
|
+
trackEvent("Subscription Payment Success", properties, devMode).catch((error) => {
|
|
933
|
+
if (devMode) {
|
|
934
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription payment success:", error);
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Tracks when subscription checkout onPaymentFailure callback is invoked
|
|
940
|
+
*/
|
|
941
|
+
function trackSubscriptionPaymentFailure(orderId, paymentId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
942
|
+
const properties = {
|
|
943
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
944
|
+
subscriptionId: orderId,
|
|
945
|
+
paymentId,
|
|
946
|
+
};
|
|
947
|
+
trackEvent("Subscription Payment Failure", properties, devMode).catch((error) => {
|
|
948
|
+
if (devMode) {
|
|
949
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription payment failure:", error);
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Tracks when subscription checkout onPaymentTerminate callback is invoked
|
|
955
|
+
*/
|
|
956
|
+
function trackSubscriptionPaymentTerminate(orderId, source, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
957
|
+
const properties = {
|
|
958
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
959
|
+
subscriptionId: orderId,
|
|
960
|
+
terminationSource: source,
|
|
961
|
+
};
|
|
962
|
+
trackEvent("Subscription Payment Terminated", properties, devMode).catch((error) => {
|
|
963
|
+
if (devMode) {
|
|
964
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription payment terminate:", error);
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Tracks when subscription checkout onConnectionError callback is invoked
|
|
970
|
+
*/
|
|
971
|
+
function trackSubscriptionConnectionError(orderId, errorCode, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
972
|
+
const properties = {
|
|
973
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
974
|
+
subscriptionId: orderId,
|
|
975
|
+
...(errorCode !== undefined && { errorCode }),
|
|
976
|
+
};
|
|
977
|
+
trackEvent("Subscription Connection Error", properties, devMode).catch((error) => {
|
|
978
|
+
if (devMode) {
|
|
979
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription connection error:", error);
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Tracks when subscription checkout onSdkError callback is invoked
|
|
985
|
+
*/
|
|
986
|
+
function trackSubscriptionSdkError(errors, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
987
|
+
const properties = {
|
|
988
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
989
|
+
subscriptionId: orderId,
|
|
990
|
+
errors,
|
|
991
|
+
errorCount: errors.length,
|
|
992
|
+
};
|
|
993
|
+
trackEvent("Subscription SDK Error", properties, devMode).catch((error) => {
|
|
994
|
+
if (devMode) {
|
|
995
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription SDK error:", error);
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
// ---------------------------------------------------------------------------
|
|
1000
|
+
// Unsupported Functionality Telemetry
|
|
1001
|
+
// ---------------------------------------------------------------------------
|
|
1002
|
+
/**
|
|
1003
|
+
* Internal telemetry - fires when a merchant uses functionality that is
|
|
1004
|
+
* unsupported in the current context or deprecated.
|
|
1005
|
+
* Fires at most once per detection site (callers use a ref guard).
|
|
1006
|
+
*/
|
|
1007
|
+
function trackUseOfUnsupportedFunctionality(name, orderId, publicKey, devMode, mockMode, checkoutUrl) {
|
|
1008
|
+
const properties = {
|
|
1009
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl),
|
|
1010
|
+
name,
|
|
1011
|
+
};
|
|
1012
|
+
trackEvent("Use of Unsupported Functionality", properties, devMode).catch((error) => {
|
|
1013
|
+
if (devMode) {
|
|
1014
|
+
console.error("[Glomo-RN-SDK] Event tracking error on unsupported functionality:", error);
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
/** Standard checkout tracker map - delegates to trackStandard* functions */
|
|
1019
|
+
exports.standardCheckoutTrackers = {
|
|
1020
|
+
trackStartAttempt: trackStandardStartAttempt,
|
|
1021
|
+
trackStartSuccess: trackStandardStartSuccess,
|
|
1022
|
+
trackStartFailure: trackStandardStartFailure,
|
|
1023
|
+
trackWindowOpen: trackStandardWindowOpen,
|
|
1024
|
+
trackWindowClose: trackStandardWindowClose,
|
|
1025
|
+
trackInvalidMessageReceived: trackStandardInvalidMessageReceived,
|
|
1026
|
+
trackPaymentSuccess: trackStandardPaymentSuccess,
|
|
1027
|
+
trackPaymentFailure: trackStandardPaymentFailure,
|
|
1028
|
+
trackPaymentTerminate: trackStandardPaymentTerminate,
|
|
1029
|
+
trackConnectionError: trackStandardConnectionError,
|
|
1030
|
+
trackSdkError: trackStandardSdkError,
|
|
1031
|
+
trackBankTransferSubmitted: trackStandardBankTransferSubmitted,
|
|
1032
|
+
trackPayViaBankCompleted: trackStandardPayViaBankCompleted,
|
|
1033
|
+
trackPayViaBankBankConnectionSuccessful: trackStandardPayViaBankBankConnectionSuccessful,
|
|
1034
|
+
};
|
|
1035
|
+
/** Subscription checkout tracker map - delegates to trackSubscription* functions, no-ops for bank transfer */
|
|
1036
|
+
exports.subscriptionCheckoutTrackers = {
|
|
1037
|
+
trackStartAttempt: trackSubscriptionStartAttempt,
|
|
1038
|
+
trackStartSuccess: trackSubscriptionStartSuccess,
|
|
1039
|
+
trackStartFailure: trackSubscriptionStartFailure,
|
|
1040
|
+
trackWindowOpen: trackSubscriptionWindowOpen,
|
|
1041
|
+
trackWindowClose: trackSubscriptionWindowClose,
|
|
1042
|
+
trackInvalidMessageReceived: trackSubscriptionInvalidMessageReceived,
|
|
1043
|
+
trackPaymentSuccess: trackSubscriptionPaymentSuccess,
|
|
1044
|
+
trackPaymentFailure: trackSubscriptionPaymentFailure,
|
|
1045
|
+
trackPaymentTerminate: trackSubscriptionPaymentTerminate,
|
|
1046
|
+
trackConnectionError: trackSubscriptionConnectionError,
|
|
1047
|
+
trackSdkError: trackSubscriptionSdkError,
|
|
1048
|
+
trackBankTransferSubmitted: (...args) => {
|
|
1049
|
+
const devMode = args[2];
|
|
1050
|
+
if (devMode) {
|
|
1051
|
+
console.warn("[Glomo-RN-SDK] Unexpected bank transfer event in subscription flow");
|
|
1052
|
+
}
|
|
1053
|
+
},
|
|
1054
|
+
trackPayViaBankCompleted: (...args) => {
|
|
1055
|
+
const devMode = args[3];
|
|
1056
|
+
if (devMode) {
|
|
1057
|
+
console.warn("[Glomo-RN-SDK] Unexpected pay via bank completed event in subscription flow");
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
trackPayViaBankBankConnectionSuccessful: (...args) => {
|
|
1061
|
+
const devMode = args[3];
|
|
1062
|
+
if (devMode) {
|
|
1063
|
+
console.warn("[Glomo-RN-SDK] Unexpected pay via bank connection event in subscription flow");
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
};
|