@glomopay/react-native-sdk 4.0.0 → 5.0.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.
Files changed (127) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/MIGRATION.md +112 -0
  3. package/README.md +173 -36
  4. package/lib/bridge/file-input-handler.d.ts +25 -0
  5. package/lib/bridge/file-input-handler.d.ts.map +1 -0
  6. package/lib/bridge/file-input-handler.js +38 -0
  7. package/lib/bridge/file-save-handler.d.ts +32 -0
  8. package/lib/bridge/file-save-handler.d.ts.map +1 -0
  9. package/lib/bridge/file-save-handler.js +92 -0
  10. package/lib/bridge/message-router.d.ts +44 -0
  11. package/lib/bridge/message-router.d.ts.map +1 -0
  12. package/lib/bridge/message-router.js +48 -0
  13. package/lib/bridge/payment-payload.d.ts +18 -0
  14. package/lib/bridge/payment-payload.d.ts.map +1 -0
  15. package/lib/bridge/payment-payload.js +31 -0
  16. package/lib/capabilities/file-save.d.ts +40 -0
  17. package/lib/capabilities/file-save.d.ts.map +1 -0
  18. package/lib/capabilities/file-save.js +101 -0
  19. package/lib/capabilities/index.d.ts +22 -0
  20. package/lib/capabilities/index.d.ts.map +1 -0
  21. package/lib/capabilities/index.js +34 -0
  22. package/lib/capabilities/use-capability-reporting.d.ts +24 -0
  23. package/lib/capabilities/use-capability-reporting.d.ts.map +1 -0
  24. package/lib/capabilities/use-capability-reporting.js +44 -0
  25. package/lib/config/base.d.ts +12 -0
  26. package/lib/config/base.d.ts.map +1 -1
  27. package/lib/config/base.js +13 -1
  28. package/lib/glomo-checkout.d.ts +9 -1
  29. package/lib/glomo-checkout.d.ts.map +1 -1
  30. package/lib/glomo-checkout.js +14 -5
  31. package/lib/glomo-lrs-checkout.d.ts +3 -0
  32. package/lib/glomo-lrs-checkout.d.ts.map +1 -1
  33. package/lib/glomo-lrs-checkout.js +34 -11
  34. package/lib/glomo-standard-checkout.d.ts +4 -1
  35. package/lib/glomo-standard-checkout.d.ts.map +1 -1
  36. package/lib/glomo-standard-checkout.js +21 -13
  37. package/lib/glomo-subscriptions-checkout.d.ts.map +1 -1
  38. package/lib/glomo-subscriptions-checkout.js +1 -1
  39. package/lib/index.d.ts +2 -2
  40. package/lib/index.d.ts.map +1 -1
  41. package/lib/index.js +4 -3
  42. package/lib/injections/index.d.ts +24 -0
  43. package/lib/injections/index.d.ts.map +1 -1
  44. package/lib/injections/index.js +41 -0
  45. package/lib/injections/webview-flow.injection.d.ts.map +1 -1
  46. package/lib/injections/webview-flow.injection.js +76 -0
  47. package/lib/injections/webview-main.injection.d.ts.map +1 -1
  48. package/lib/injections/webview-main.injection.js +31 -0
  49. package/lib/injections/webview-standard.injection.d.ts.map +1 -1
  50. package/lib/injections/webview-standard.injection.js +31 -0
  51. package/lib/services/file-saver.d.ts +109 -0
  52. package/lib/services/file-saver.d.ts.map +1 -0
  53. package/lib/services/file-saver.js +416 -0
  54. package/lib/types/checkout.d.ts +67 -6
  55. package/lib/types/checkout.d.ts.map +1 -1
  56. package/lib/types/checkout.js +24 -2
  57. package/lib/types/standard-checkout.d.ts +6 -6
  58. package/lib/types/standard-checkout.d.ts.map +1 -1
  59. package/lib/types/subscriptions-checkout.d.ts +5 -3
  60. package/lib/types/subscriptions-checkout.d.ts.map +1 -1
  61. package/lib/use-glomo-checkout.d.ts +2 -2
  62. package/lib/use-glomo-checkout.d.ts.map +1 -1
  63. package/lib/use-glomo-checkout.js +25 -4
  64. package/lib/use-lrs-checkout.d.ts +18 -6
  65. package/lib/use-lrs-checkout.d.ts.map +1 -1
  66. package/lib/use-lrs-checkout.js +330 -171
  67. package/lib/use-standard-checkout.d.ts +18 -13
  68. package/lib/use-standard-checkout.d.ts.map +1 -1
  69. package/lib/use-standard-checkout.js +282 -206
  70. package/lib/utils/analytics.d.ts +177 -51
  71. package/lib/utils/analytics.d.ts.map +1 -1
  72. package/lib/utils/analytics.js +299 -81
  73. package/lib/utils/device-compliance.d.ts +57 -12
  74. package/lib/utils/device-compliance.d.ts.map +1 -1
  75. package/lib/utils/device-compliance.js +101 -37
  76. package/lib/utils/event-projections.d.ts +56 -0
  77. package/lib/utils/event-projections.d.ts.map +1 -0
  78. package/lib/utils/event-projections.js +42 -0
  79. package/lib/utils/file-metadata.d.ts +52 -0
  80. package/lib/utils/file-metadata.d.ts.map +1 -0
  81. package/lib/utils/file-metadata.js +134 -0
  82. package/lib/utils/use-sdk-session.d.ts +12 -0
  83. package/lib/utils/use-sdk-session.d.ts.map +1 -0
  84. package/lib/utils/use-sdk-session.js +37 -0
  85. package/lib/utils/validation.d.ts +37 -3
  86. package/lib/utils/validation.d.ts.map +1 -1
  87. package/lib/utils/validation.js +64 -8
  88. package/lib/webview/capability-props.d.ts +27 -0
  89. package/lib/webview/capability-props.d.ts.map +1 -0
  90. package/lib/webview/capability-props.js +61 -0
  91. package/lib/webview/use-permission-request.d.ts +33 -0
  92. package/lib/webview/use-permission-request.d.ts.map +1 -0
  93. package/lib/webview/use-permission-request.js +89 -0
  94. package/package.json +13 -3
  95. package/src/bridge/file-input-handler.ts +66 -0
  96. package/src/bridge/file-save-handler.ts +141 -0
  97. package/src/bridge/message-router.ts +92 -0
  98. package/src/bridge/payment-payload.ts +31 -0
  99. package/src/capabilities/file-save.ts +124 -0
  100. package/src/capabilities/index.ts +34 -0
  101. package/src/capabilities/use-capability-reporting.ts +55 -0
  102. package/src/config/base.ts +13 -0
  103. package/src/glomo-checkout.tsx +28 -11
  104. package/src/glomo-lrs-checkout.tsx +49 -27
  105. package/src/glomo-standard-checkout.tsx +33 -34
  106. package/src/glomo-subscriptions-checkout.tsx +1 -0
  107. package/src/index.ts +4 -2
  108. package/src/injections/index.ts +43 -0
  109. package/src/injections/webview-flow.injection.ts +76 -0
  110. package/src/injections/webview-main.injection.ts +31 -0
  111. package/src/injections/webview-standard.injection.ts +31 -0
  112. package/src/services/file-saver.ts +497 -0
  113. package/src/types/checkout.ts +72 -6
  114. package/src/types/standard-checkout.ts +6 -6
  115. package/src/types/subscriptions-checkout.ts +9 -3
  116. package/src/use-glomo-checkout.tsx +32 -7
  117. package/src/use-lrs-checkout.tsx +684 -366
  118. package/src/use-standard-checkout.tsx +731 -465
  119. package/src/utils/analytics.ts +422 -117
  120. package/src/utils/device-compliance.ts +148 -38
  121. package/src/utils/event-projections.ts +74 -0
  122. package/src/utils/file-metadata.ts +140 -0
  123. package/src/utils/use-sdk-session.ts +41 -0
  124. package/src/utils/validation.ts +70 -10
  125. package/src/webview/capability-props.ts +86 -0
  126. package/src/webview/use-permission-request.ts +114 -0
  127. package/src/jail-monkey.d.ts +0 -19
@@ -12,6 +12,9 @@
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.subscriptionCheckoutTrackers = exports.standardCheckoutTrackers = void 0;
15
+ exports.setSdkSession = setSdkSession;
16
+ exports.bindCheckoutStatus = bindCheckoutStatus;
17
+ exports.releaseSdkSession = releaseSdkSession;
15
18
  exports.trackStartSuccess = trackStartSuccess;
16
19
  exports.trackStartAttempt = trackStartAttempt;
17
20
  exports.trackStartFailure = trackStartFailure;
@@ -54,8 +57,72 @@ exports.trackSubscriptionPaymentTerminate = trackSubscriptionPaymentTerminate;
54
57
  exports.trackSubscriptionConnectionError = trackSubscriptionConnectionError;
55
58
  exports.trackSubscriptionSdkError = trackSubscriptionSdkError;
56
59
  exports.trackUseOfUnsupportedFunctionality = trackUseOfUnsupportedFunctionality;
60
+ exports.trackBackNavigationViaSdkBackButton = trackBackNavigationViaSdkBackButton;
61
+ exports.trackDevicePermissionRefused = trackDevicePermissionRefused;
62
+ exports.trackIncompletePaymentPayload = trackIncompletePaymentPayload;
63
+ exports.trackDroppedPaymentPayload = trackDroppedPaymentPayload;
64
+ exports.trackFileUploadRequested = trackFileUploadRequested;
65
+ exports.trackFileSaveRequested = trackFileSaveRequested;
66
+ exports.trackFileSaveCompleted = trackFileSaveCompleted;
57
67
  const react_native_1 = require("react-native");
58
68
  const segment_1 = require("../config/segment");
69
+ /**
70
+ * The current checkout attempt, and how to read its status.
71
+ *
72
+ * Module scope because `buildCommonProperties` is spread into every event and takes no context
73
+ * argument. Installed by useSdkSession for as long as a checkout component is mounted, so nothing
74
+ * here survives a merchant's screen being torn down.
75
+ */
76
+ let activeSessionId;
77
+ let readCheckoutStatus;
78
+ /**
79
+ * Installs the id that correlates every event from one checkout attempt.
80
+ *
81
+ * Nothing else does: joining on `orderId` fails the moment a merchant retries `start()`, which
82
+ * produces two attempts that are indistinguishable without this. Scoped per mount rather than per
83
+ * `start()`, so a retry reads as two start_attempted events inside one session - which is the signal
84
+ * worth having.
85
+ */
86
+ function setSdkSession(sessionId) {
87
+ activeSessionId = sessionId;
88
+ }
89
+ /**
90
+ * Binds a getter for the checkout status, resolved at capture time.
91
+ *
92
+ * A getter rather than a value, deliberately. Pushing the status per call would mean touching every
93
+ * tracker and would go stale between transitions - which is exactly the bug the Flutter SDK fixed in
94
+ * KAN-8085, where `checkout_status` was null on every real event.
95
+ */
96
+ function bindCheckoutStatus(read) {
97
+ readCheckoutStatus = read;
98
+ }
99
+ /**
100
+ * Releases the session a mount installed, and only if it is still the active one.
101
+ *
102
+ * Clearing unconditionally is wrong whenever two checkout components overlap - a merchant who keeps
103
+ * a previous screen mounted, or renders one per row in a list. The component unmounting would strip
104
+ * `sessionId` and `checkoutStatus` off every later event of a sibling that is still mid-payment, and
105
+ * an event missing them is indistinguishable from one sent by a pre-v5 build.
106
+ *
107
+ * It does not make the singletons safe for concurrent mounts - the last mount still wins while both
108
+ * are alive. It removes the case where the survivor is left reporting nothing at all.
109
+ */
110
+ function releaseSdkSession(sessionId) {
111
+ if (activeSessionId !== sessionId) {
112
+ return;
113
+ }
114
+ activeSessionId = undefined;
115
+ readCheckoutStatus = undefined;
116
+ }
117
+ /** Never lets a merchant's status getter break an event */
118
+ function currentCheckoutStatus() {
119
+ try {
120
+ return readCheckoutStatus === null || readCheckoutStatus === void 0 ? void 0 : readCheckoutStatus();
121
+ }
122
+ catch (_a) {
123
+ return undefined;
124
+ }
125
+ }
59
126
  /**
60
127
  * Gets the SDK version from package.json
61
128
  * Falls back to a default value if package.json cannot be read
@@ -97,6 +164,8 @@ function buildCommonProperties(orderId, publicKey, devMode = false, mockMode = f
97
164
  sdkVersion: getSdkVersion(),
98
165
  timestamp: new Date().toISOString(),
99
166
  ...(flowType && { flowType }),
167
+ ...(activeSessionId && { sessionId: activeSessionId }),
168
+ ...(currentCheckoutStatus() !== undefined && { checkoutStatus: currentCheckoutStatus() }),
100
169
  };
101
170
  }
102
171
  /**
@@ -168,15 +237,12 @@ async function trackEvent(eventName, properties = {}, devMode = false) {
168
237
  * @param devMode - Whether dev mode is enabled
169
238
  * @param mockMode - Whether mock mode is enabled
170
239
  * @param lrsUrl - The LRS checkout URL
171
- * @param jailbreakDetectionInfo - Optional jailbreak detection information
240
+ * @param dependencyInfo - Optional inventory of what this build could and could not load
172
241
  */
173
- function trackStartSuccess(orderId, publicKey, devMode = false, mockMode = false, lrsUrl, jailbreakDetectionInfo) {
242
+ function trackStartSuccess(orderId, publicKey, devMode = false, mockMode = false, lrsUrl, dependencyInfo) {
174
243
  const properties = {
175
244
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, lrsUrl),
176
- ...(jailbreakDetectionInfo && {
177
- jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
178
- jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
179
- }),
245
+ ...dependencyInfo,
180
246
  };
181
247
  // Async tracking to avoid blocking the main thread
182
248
  trackEvent("LRS Checkout Started", properties, devMode).catch((error) => {
@@ -194,16 +260,13 @@ function trackStartSuccess(orderId, publicKey, devMode = false, mockMode = false
194
260
  * @param devMode - Whether dev mode is enabled
195
261
  * @param mockMode - Whether mock mode is enabled
196
262
  * @param lrsUrl - The LRS checkout URL
197
- * @param jailbreakDetectionInfo - Optional jailbreak detection information
263
+ * @param dependencyInfo - Optional inventory of what this build could and could not load
198
264
  */
199
- function trackStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, lrsUrl, jailbreakDetectionInfo) {
265
+ function trackStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, lrsUrl, dependencyInfo) {
200
266
  const properties = {
201
267
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, lrsUrl),
202
268
  status,
203
- ...(jailbreakDetectionInfo && {
204
- jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
205
- jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
206
- }),
269
+ ...dependencyInfo,
207
270
  };
208
271
  // Async tracking to avoid blocking the main thread
209
272
  trackEvent("LRS Checkout Start Attempted", properties, devMode).catch((error) => {
@@ -221,16 +284,13 @@ function trackStartAttempt(status, orderId, publicKey, devMode = false, mockMode
221
284
  * @param devMode - Whether dev mode is enabled
222
285
  * @param mockMode - Whether mock mode is enabled
223
286
  * @param lrsUrl - The LRS checkout URL
224
- * @param jailbreakDetectionInfo - Optional jailbreak detection information
287
+ * @param dependencyInfo - Optional inventory of what this build could and could not load
225
288
  */
226
- function trackStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, lrsUrl, jailbreakDetectionInfo) {
289
+ function trackStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, lrsUrl, dependencyInfo) {
227
290
  const properties = {
228
291
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, lrsUrl),
229
292
  failureReason: reason,
230
- ...(jailbreakDetectionInfo && {
231
- jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
232
- jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
233
- }),
293
+ ...dependencyInfo,
234
294
  };
235
295
  // Async tracking to avoid blocking the main thread
236
296
  trackEvent("LRS Checkout Start Failed", properties, devMode).catch((error) => {
@@ -344,10 +404,10 @@ function trackInvalidMessageReceived(webviewType, data, url, orderId, publicKey,
344
404
  * @param mockMode - Whether mock mode is enabled
345
405
  * @param lrsUrl - The LRS checkout URL
346
406
  */
347
- function trackPaymentSuccess(orderId, paymentId, publicKey, devMode = false, mockMode = false, lrsUrl) {
407
+ function trackPaymentSuccess(payment, publicKey, devMode = false, mockMode = false, lrsUrl) {
348
408
  const properties = {
349
- ...buildCommonProperties(orderId, publicKey, devMode, mockMode, lrsUrl),
350
- paymentId,
409
+ ...buildCommonProperties(payment.orderId, publicKey, devMode, mockMode, lrsUrl),
410
+ ...payment,
351
411
  };
352
412
  // Async tracking to avoid blocking the main thread
353
413
  trackEvent("LRS Payment Success", properties, devMode).catch((error) => {
@@ -366,10 +426,10 @@ function trackPaymentSuccess(orderId, paymentId, publicKey, devMode = false, moc
366
426
  * @param mockMode - Whether mock mode is enabled
367
427
  * @param lrsUrl - The LRS checkout URL
368
428
  */
369
- function trackPaymentFailure(orderId, paymentId, publicKey, devMode = false, mockMode = false, lrsUrl) {
429
+ function trackPaymentFailure(payment, publicKey, devMode = false, mockMode = false, lrsUrl) {
370
430
  const properties = {
371
- ...buildCommonProperties(orderId, publicKey, devMode, mockMode, lrsUrl),
372
- paymentId,
431
+ ...buildCommonProperties(payment.orderId, publicKey, devMode, mockMode, lrsUrl),
432
+ ...payment,
373
433
  };
374
434
  // Async tracking to avoid blocking the main thread
375
435
  trackEvent("LRS Payment Failure", properties, devMode).catch((error) => {
@@ -388,10 +448,10 @@ function trackPaymentFailure(orderId, paymentId, publicKey, devMode = false, moc
388
448
  * @param mockMode - Whether mock mode is enabled
389
449
  * @param lrsUrl - The LRS checkout URL
390
450
  */
391
- function trackPaymentTerminate(orderId, source, publicKey, devMode = false, mockMode = false, lrsUrl) {
451
+ function trackPaymentTerminate(orderId, termination, publicKey, devMode = false, mockMode = false, lrsUrl) {
392
452
  const properties = {
393
453
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, lrsUrl),
394
- terminationSource: source,
454
+ ...termination,
395
455
  };
396
456
  // Async tracking to avoid blocking the main thread
397
457
  trackEvent("LRS Payment Terminated", properties, devMode).catch((error) => {
@@ -493,13 +553,10 @@ function trackSdkError(errors, orderId, publicKey, devMode = false, mockMode = f
493
553
  /**
494
554
  * Tracks when the standard checkout start() method has been called successfully
495
555
  */
496
- function trackStandardStartSuccess(orderId, publicKey, devMode = false, mockMode = false, standardUrl, jailbreakDetectionInfo) {
556
+ function trackStandardStartSuccess(orderId, publicKey, devMode = false, mockMode = false, standardUrl, dependencyInfo) {
497
557
  const properties = {
498
558
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
499
- ...(jailbreakDetectionInfo && {
500
- jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
501
- jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
502
- }),
559
+ ...dependencyInfo,
503
560
  };
504
561
  trackEvent("Standard Checkout Started", properties, devMode).catch((error) => {
505
562
  if (devMode) {
@@ -510,14 +567,11 @@ function trackStandardStartSuccess(orderId, publicKey, devMode = false, mockMode
510
567
  /**
511
568
  * Tracks when the standard checkout start() method is called (attempted)
512
569
  */
513
- function trackStandardStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, standardUrl, jailbreakDetectionInfo) {
570
+ function trackStandardStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, standardUrl, dependencyInfo) {
514
571
  const properties = {
515
572
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
516
573
  status,
517
- ...(jailbreakDetectionInfo && {
518
- jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
519
- jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
520
- }),
574
+ ...dependencyInfo,
521
575
  };
522
576
  trackEvent("Standard Checkout Start Attempted", properties, devMode).catch((error) => {
523
577
  if (devMode) {
@@ -528,14 +582,11 @@ function trackStandardStartAttempt(status, orderId, publicKey, devMode = false,
528
582
  /**
529
583
  * Tracks when the standard checkout start() method fails
530
584
  */
531
- function trackStandardStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, standardUrl, jailbreakDetectionInfo) {
585
+ function trackStandardStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, standardUrl, dependencyInfo) {
532
586
  const properties = {
533
587
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
534
588
  failureReason: reason,
535
- ...(jailbreakDetectionInfo && {
536
- jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
537
- jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
538
- }),
589
+ ...dependencyInfo,
539
590
  };
540
591
  trackEvent("Standard Checkout Start Failed", properties, devMode).catch((error) => {
541
592
  if (devMode) {
@@ -613,10 +664,10 @@ function trackStandardInvalidMessageReceived(webviewType, data, url, orderId, pu
613
664
  /**
614
665
  * Tracks when standard checkout onPaymentSuccess callback is invoked
615
666
  */
616
- function trackStandardPaymentSuccess(orderId, paymentId, publicKey, devMode = false, mockMode = false, standardUrl) {
667
+ function trackStandardPaymentSuccess(payment, publicKey, devMode = false, mockMode = false, standardUrl) {
617
668
  const properties = {
618
- ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
619
- paymentId,
669
+ ...buildCommonProperties(payment.orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
670
+ ...payment,
620
671
  };
621
672
  trackEvent("Standard Payment Success", properties, devMode).catch((error) => {
622
673
  if (devMode) {
@@ -627,10 +678,10 @@ function trackStandardPaymentSuccess(orderId, paymentId, publicKey, devMode = fa
627
678
  /**
628
679
  * Tracks when standard checkout onPaymentFailure callback is invoked
629
680
  */
630
- function trackStandardPaymentFailure(orderId, paymentId, publicKey, devMode = false, mockMode = false, standardUrl) {
681
+ function trackStandardPaymentFailure(payment, publicKey, devMode = false, mockMode = false, standardUrl) {
631
682
  const properties = {
632
- ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
633
- paymentId,
683
+ ...buildCommonProperties(payment.orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
684
+ ...payment,
634
685
  };
635
686
  trackEvent("Standard Payment Failure", properties, devMode).catch((error) => {
636
687
  if (devMode) {
@@ -641,10 +692,10 @@ function trackStandardPaymentFailure(orderId, paymentId, publicKey, devMode = fa
641
692
  /**
642
693
  * Tracks when standard checkout onPaymentTerminate callback is invoked
643
694
  */
644
- function trackStandardPaymentTerminate(orderId, source, publicKey, devMode = false, mockMode = false, standardUrl) {
695
+ function trackStandardPaymentTerminate(orderId, termination, publicKey, devMode = false, mockMode = false, standardUrl) {
645
696
  const properties = {
646
697
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
647
- terminationSource: source,
698
+ ...termination,
648
699
  };
649
700
  trackEvent("Standard Payment Terminated", properties, devMode).catch((error) => {
650
701
  if (devMode) {
@@ -681,9 +732,10 @@ function trackStandardSdkError(errors, orderId, publicKey, devMode = false, mock
681
732
  }
682
733
  });
683
734
  }
684
- function trackStandardBankTransferSubmitted(orderId, publicKey, devMode = false, mockMode = false, standardUrl) {
735
+ function trackStandardBankTransferSubmitted(orderId, journey, publicKey, devMode = false, mockMode = false, standardUrl) {
685
736
  const properties = {
686
737
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
738
+ ...journey,
687
739
  };
688
740
  trackEvent("Standard Bank Transfer Submitted", properties, devMode).catch((error) => {
689
741
  if (devMode) {
@@ -691,10 +743,10 @@ function trackStandardBankTransferSubmitted(orderId, publicKey, devMode = false,
691
743
  }
692
744
  });
693
745
  }
694
- function trackStandardPayViaBankCompleted(orderId, publicKey, status, devMode = false, mockMode = false, standardUrl) {
746
+ function trackStandardPayViaBankCompleted(orderId, journey, publicKey, devMode = false, mockMode = false, standardUrl) {
695
747
  const properties = {
696
748
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
697
- payViaBankStatus: status,
749
+ ...journey,
698
750
  };
699
751
  trackEvent("Standard Pay Via Bank Completed", properties, devMode).catch((error) => {
700
752
  if (devMode) {
@@ -785,15 +837,12 @@ function checkAnalyticsStatus(devMode = false) {
785
837
  /**
786
838
  * Tracks when the subscription checkout start() method is called (attempted)
787
839
  */
788
- function trackSubscriptionStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
840
+ function trackSubscriptionStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, dependencyInfo) {
789
841
  const properties = {
790
842
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
791
843
  subscriptionId: orderId,
792
844
  status,
793
- ...(jailbreakDetectionInfo && {
794
- jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
795
- jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
796
- }),
845
+ ...dependencyInfo,
797
846
  };
798
847
  trackEvent("Subscription Checkout Start Attempted", properties, devMode).catch((error) => {
799
848
  if (devMode) {
@@ -804,14 +853,11 @@ function trackSubscriptionStartAttempt(status, orderId, publicKey, devMode = fal
804
853
  /**
805
854
  * Tracks when the subscription checkout start() method has been called successfully
806
855
  */
807
- function trackSubscriptionStartSuccess(orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
856
+ function trackSubscriptionStartSuccess(orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, dependencyInfo) {
808
857
  const properties = {
809
858
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
810
859
  subscriptionId: orderId,
811
- ...(jailbreakDetectionInfo && {
812
- jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
813
- jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
814
- }),
860
+ ...dependencyInfo,
815
861
  };
816
862
  trackEvent("Subscription Checkout Started", properties, devMode).catch((error) => {
817
863
  if (devMode) {
@@ -822,15 +868,12 @@ function trackSubscriptionStartSuccess(orderId, publicKey, devMode = false, mock
822
868
  /**
823
869
  * Tracks when the subscription checkout start() method fails
824
870
  */
825
- function trackSubscriptionStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
871
+ function trackSubscriptionStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, dependencyInfo) {
826
872
  const properties = {
827
873
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
828
874
  subscriptionId: orderId,
829
875
  failureReason: reason,
830
- ...(jailbreakDetectionInfo && {
831
- jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
832
- jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
833
- }),
876
+ ...dependencyInfo,
834
877
  };
835
878
  trackEvent("Subscription Checkout Start Failed", properties, devMode).catch((error) => {
836
879
  if (devMode) {
@@ -911,11 +954,11 @@ function trackSubscriptionInvalidMessageReceived(webviewType, data, url, orderId
911
954
  /**
912
955
  * Tracks when subscription checkout onPaymentSuccess callback is invoked
913
956
  */
914
- function trackSubscriptionPaymentSuccess(orderId, paymentId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
957
+ function trackSubscriptionPaymentSuccess(payment, publicKey, devMode = false, mockMode = false, checkoutUrl) {
915
958
  const properties = {
916
- ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
917
- subscriptionId: orderId,
918
- paymentId,
959
+ ...buildCommonProperties(payment.orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
960
+ subscriptionId: payment.orderId,
961
+ ...payment,
919
962
  };
920
963
  trackEvent("Subscription Payment Success", properties, devMode).catch((error) => {
921
964
  if (devMode) {
@@ -926,11 +969,11 @@ function trackSubscriptionPaymentSuccess(orderId, paymentId, publicKey, devMode
926
969
  /**
927
970
  * Tracks when subscription checkout onPaymentFailure callback is invoked
928
971
  */
929
- function trackSubscriptionPaymentFailure(orderId, paymentId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
972
+ function trackSubscriptionPaymentFailure(payment, publicKey, devMode = false, mockMode = false, checkoutUrl) {
930
973
  const properties = {
931
- ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
932
- subscriptionId: orderId,
933
- paymentId,
974
+ ...buildCommonProperties(payment.orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
975
+ subscriptionId: payment.orderId,
976
+ ...payment,
934
977
  };
935
978
  trackEvent("Subscription Payment Failure", properties, devMode).catch((error) => {
936
979
  if (devMode) {
@@ -941,11 +984,11 @@ function trackSubscriptionPaymentFailure(orderId, paymentId, publicKey, devMode
941
984
  /**
942
985
  * Tracks when subscription checkout onPaymentTerminate callback is invoked
943
986
  */
944
- function trackSubscriptionPaymentTerminate(orderId, source, publicKey, devMode = false, mockMode = false, checkoutUrl) {
987
+ function trackSubscriptionPaymentTerminate(orderId, termination, publicKey, devMode = false, mockMode = false, checkoutUrl) {
945
988
  const properties = {
946
989
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
947
990
  subscriptionId: orderId,
948
- terminationSource: source,
991
+ ...termination,
949
992
  };
950
993
  trackEvent("Subscription Payment Terminated", properties, devMode).catch((error) => {
951
994
  if (devMode) {
@@ -1003,6 +1046,183 @@ function trackUseOfUnsupportedFunctionality(name, orderId, publicKey, devMode, m
1003
1046
  }
1004
1047
  });
1005
1048
  }
1049
+ // ---------------------------------------------------------------------------
1050
+ // SDK Navigation Telemetry
1051
+ // ---------------------------------------------------------------------------
1052
+ /**
1053
+ * Internal telemetry - fires when the user taps the SDK's back chevron over a bank flow.
1054
+ *
1055
+ * Its own event rather than `window.close`, which it used to reuse. The chevron is back-navigation:
1056
+ * it returns the user to the main checkout with the session intact and the ability to pay, where
1057
+ * `window.close` means something actually closed. Reusing it made a user pressing back
1058
+ * indistinguishable in Segment from the page closing a window.
1059
+ *
1060
+ * This is the only host-invisible interaction the SDK has - the chevron deliberately does not reach
1061
+ * onPaymentTerminate, because a merchant who cancels the order on terminate would cancel live
1062
+ * orders every time a user backed out of one bank to try another. This event is how it stays
1063
+ * visible to us without becoming a termination.
1064
+ */
1065
+ function trackBackNavigationViaSdkBackButton(orderId, publicKey, devMode, mockMode, checkoutUrl, flowType) {
1066
+ const properties = buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, flowType);
1067
+ trackEvent("Back Navigation Via SDK Back Button", properties, devMode).catch((error) => {
1068
+ if (devMode) {
1069
+ console.error("[Glomo-RN-SDK] Event tracking error on SDK back navigation:", error);
1070
+ }
1071
+ });
1072
+ }
1073
+ // ---------------------------------------------------------------------------
1074
+ // Device Permission Telemetry
1075
+ // ---------------------------------------------------------------------------
1076
+ /**
1077
+ * Internal telemetry - fires when the user refuses a device permission the bank's page asked for.
1078
+ *
1079
+ * This was the one callback in the SDK with no tracker at all, so a refusal was invisible: there was
1080
+ * no way to answer how often it happens or on which flows.
1081
+ *
1082
+ * `source` says where the observation came from, and the two are not equivalent:
1083
+ *
1084
+ * - `permission_request` is the Android WebView asking us, which is also what drives
1085
+ * `onUserRefusedDevicePermissions`. Android only - iOS raises its own prompt inside WKWebView and
1086
+ * never reports the answer back.
1087
+ * - `get_user_media` is the flow injection watching `getUserMedia` reject with `NotAllowedError`.
1088
+ * It reaches iOS, and it fires no callback: coverage depends on whether a given bank uses
1089
+ * `getUserMedia` at all, and a callback with partial coverage is a contract we cannot hold.
1090
+ *
1091
+ * So an absent event still means "not observable" rather than "did not happen", and `source` plus
1092
+ * the `deviceOS` already on every event is what separates the cases.
1093
+ */
1094
+ function trackDevicePermissionRefused(resource, source, orderId, publicKey, devMode, mockMode, checkoutUrl, flowType) {
1095
+ const properties = {
1096
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, flowType),
1097
+ resource,
1098
+ source,
1099
+ };
1100
+ trackEvent("Device Permission Refused", properties, devMode).catch((error) => {
1101
+ if (devMode) {
1102
+ console.error("[Glomo-RN-SDK] Event tracking error on device permission refused:", error);
1103
+ }
1104
+ });
1105
+ }
1106
+ // ---------------------------------------------------------------------------
1107
+ // Payment Payload Integrity Telemetry
1108
+ // ---------------------------------------------------------------------------
1109
+ /**
1110
+ * Internal telemetry - fires when a terminal payment payload arrives without `paymentId` or
1111
+ * `signature`.
1112
+ *
1113
+ * The callback still fires; this measures how often the page reports an outcome before the backend
1114
+ * has resolved ids, which is the thing that made the old strict validation drop real payments.
1115
+ * Names the missing fields, never their values.
1116
+ */
1117
+ function trackIncompletePaymentPayload(event, missingFields, source, orderId, publicKey, devMode, mockMode, checkoutUrl, flowType) {
1118
+ const properties = {
1119
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, flowType),
1120
+ event,
1121
+ source,
1122
+ missingFields,
1123
+ missingFieldCount: missingFields.length,
1124
+ };
1125
+ trackEvent("Incomplete Payment Payload", properties, devMode).catch((error) => {
1126
+ if (devMode) {
1127
+ console.error("[Glomo-RN-SDK] Event tracking error on incomplete payment payload:", error);
1128
+ }
1129
+ });
1130
+ }
1131
+ /**
1132
+ * Internal telemetry - fires when a payment payload cannot be routed at all.
1133
+ *
1134
+ * Reached only when `orderId` is absent or the optional fields carry the wrong type, so there is no
1135
+ * outcome to report to the merchant without fabricating one. Before v5 this path was a
1136
+ * devMode-only `console.error`, which meant a dropped payment left no trace in a release build.
1137
+ *
1138
+ * Carries the payload's **key names** and nothing else - the values are payment identifiers.
1139
+ */
1140
+ function trackDroppedPaymentPayload(event, payloadKeys, source, orderId, publicKey, devMode, mockMode, checkoutUrl, flowType) {
1141
+ const properties = {
1142
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, flowType),
1143
+ event,
1144
+ source,
1145
+ payloadKeys,
1146
+ };
1147
+ trackEvent("Payment Payload Dropped", properties, devMode).catch((error) => {
1148
+ if (devMode) {
1149
+ console.error("[Glomo-RN-SDK] Event tracking error on dropped payment payload:", error);
1150
+ }
1151
+ });
1152
+ }
1153
+ // ---------------------------------------------------------------------------
1154
+ // File Upload Telemetry
1155
+ // ---------------------------------------------------------------------------
1156
+ /**
1157
+ * Internal telemetry - fires when the user taps a file input on a bank's page.
1158
+ *
1159
+ * **The attempt only.** react-native-webview runs the whole chooser natively through
1160
+ * `onShowFileChooser` and `startPhotoPickerIntent`, so no outcome - picked, cancelled or failed -
1161
+ * ever reaches JavaScript. Getting one would need either a patched rnw or a page-side `change`
1162
+ * listener reporting over the bridge, and the page here is a third party's.
1163
+ *
1164
+ * So an absent follow-up event means "not observable", never "the upload failed". Do not build a
1165
+ * success rate on this.
1166
+ */
1167
+ function trackFileUploadRequested(acceptTypes, hasCapture, orderId, publicKey, devMode, mockMode, checkoutUrl, flowType) {
1168
+ const properties = {
1169
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, flowType),
1170
+ acceptTypes,
1171
+ hasCapture,
1172
+ };
1173
+ trackEvent("File Upload Requested", properties, devMode).catch((error) => {
1174
+ if (devMode) {
1175
+ console.error("[Glomo-RN-SDK] Event tracking error on file upload requested:", error);
1176
+ }
1177
+ });
1178
+ }
1179
+ // ---------------------------------------------------------------------------
1180
+ // File Save Telemetry
1181
+ // ---------------------------------------------------------------------------
1182
+ /**
1183
+ * Event names carry no flow prefix, unlike every payment event above.
1184
+ *
1185
+ * Saving a document is not owned by a flow - the capability is advertised to every WebView the SDK
1186
+ * opens - so a prefix would assert a distinction that does not exist. `flowType` rides the common
1187
+ * properties for anyone who wants to slice by it. The names match the Flutter SDK's so one query
1188
+ * spans both.
1189
+ */
1190
+ /**
1191
+ * Internal telemetry - fires when the page asks the SDK to put a document on the device.
1192
+ *
1193
+ * Paired with trackFileSaveCompleted by `saveId`, which fires for every request that got this far,
1194
+ * including the failures and the dismissals. A requested with no completion means the handler died.
1195
+ */
1196
+ function trackFileSaveRequested(saveId, orderId, publicKey, devMode, mockMode, checkoutUrl, flowType) {
1197
+ const properties = {
1198
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, flowType),
1199
+ saveId,
1200
+ };
1201
+ trackEvent("File Save Requested", properties, devMode).catch((error) => {
1202
+ if (devMode) {
1203
+ console.error("[Glomo-RN-SDK] Event tracking error on file save requested:", error);
1204
+ }
1205
+ });
1206
+ }
1207
+ /**
1208
+ * Internal telemetry - fires once per request, whatever the outcome.
1209
+ *
1210
+ * `eventData` is the projection the saver builds, never the result object itself. The inputs to a
1211
+ * save are a signed URL and a filename; the projection is what is safe to send, and taking it
1212
+ * pre-built keeps the decision about what that means in one place next to the values it excludes.
1213
+ */
1214
+ function trackFileSaveCompleted(saveId, eventData, orderId, publicKey, devMode, mockMode, checkoutUrl, flowType) {
1215
+ const properties = {
1216
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, flowType),
1217
+ ...eventData,
1218
+ saveId,
1219
+ };
1220
+ trackEvent("File Save Completed", properties, devMode).catch((error) => {
1221
+ if (devMode) {
1222
+ console.error("[Glomo-RN-SDK] Event tracking error on file save completed:", error);
1223
+ }
1224
+ });
1225
+ }
1006
1226
  /** Standard checkout tracker map - delegates to trackStandard* functions */
1007
1227
  exports.standardCheckoutTrackers = {
1008
1228
  trackStartAttempt: trackStandardStartAttempt,
@@ -1032,14 +1252,12 @@ exports.subscriptionCheckoutTrackers = {
1032
1252
  trackPaymentTerminate: trackSubscriptionPaymentTerminate,
1033
1253
  trackConnectionError: trackSubscriptionConnectionError,
1034
1254
  trackSdkError: trackSubscriptionSdkError,
1035
- trackBankTransferSubmitted: (...args) => {
1036
- const devMode = args[2];
1255
+ trackBankTransferSubmitted: (_orderId, _journey, _publicKey, devMode) => {
1037
1256
  if (devMode) {
1038
1257
  console.warn("[Glomo-RN-SDK] Unexpected bank transfer event in subscription flow");
1039
1258
  }
1040
1259
  },
1041
- trackPayViaBankCompleted: (...args) => {
1042
- const devMode = args[3];
1260
+ trackPayViaBankCompleted: (_orderId, _journey, _publicKey, devMode) => {
1043
1261
  if (devMode) {
1044
1262
  console.warn("[Glomo-RN-SDK] Unexpected pay via bank completed event in subscription flow");
1045
1263
  }