@glomopay/react-native-sdk 3.0.1 → 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.
Files changed (40) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/MIGRATION.md +50 -0
  3. package/README.md +131 -50
  4. package/lib/glomo-checkout.d.ts.map +1 -1
  5. package/lib/glomo-checkout.js +38 -1
  6. package/lib/glomo-standard-checkout.d.ts +20 -0
  7. package/lib/glomo-standard-checkout.d.ts.map +1 -1
  8. package/lib/glomo-standard-checkout.js +14 -3
  9. package/lib/glomo-subscriptions-checkout.d.ts +8 -0
  10. package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
  11. package/lib/glomo-subscriptions-checkout.js +85 -0
  12. package/lib/index.d.ts +1 -1
  13. package/lib/index.d.ts.map +1 -1
  14. package/lib/types/checkout.d.ts +15 -3
  15. package/lib/types/checkout.d.ts.map +1 -1
  16. package/lib/types/subscriptions-checkout.d.ts +29 -0
  17. package/lib/types/subscriptions-checkout.d.ts.map +1 -0
  18. package/lib/types/subscriptions-checkout.js +3 -0
  19. package/lib/use-glomo-checkout.d.ts +34 -4
  20. package/lib/use-glomo-checkout.d.ts.map +1 -1
  21. package/lib/use-glomo-checkout.js +92 -13
  22. package/lib/use-standard-checkout.d.ts +11 -2
  23. package/lib/use-standard-checkout.d.ts.map +1 -1
  24. package/lib/use-standard-checkout.js +52 -35
  25. package/lib/utils/analytics.d.ts +87 -2
  26. package/lib/utils/analytics.d.ts.map +1 -1
  27. package/lib/utils/analytics.js +356 -15
  28. package/lib/utils/device-compliance.d.ts.map +1 -1
  29. package/lib/utils/device-compliance.js +0 -1
  30. package/package.json +15 -4
  31. package/src/glomo-checkout.tsx +79 -5
  32. package/src/glomo-standard-checkout.tsx +33 -4
  33. package/src/glomo-subscriptions-checkout.tsx +83 -0
  34. package/src/index.ts +1 -1
  35. package/src/types/checkout.ts +10 -3
  36. package/src/types/subscriptions-checkout.ts +31 -0
  37. package/src/use-glomo-checkout.tsx +158 -17
  38. package/src/use-standard-checkout.tsx +70 -52
  39. package/src/utils/analytics.ts +482 -17
  40. package/src/utils/device-compliance.ts +0 -1
@@ -16,7 +16,7 @@ import { getSegmentClient, isSegmentAvailable, getAnonymousId, getSegmentWriteKe
16
16
  /**
17
17
  * Flow type for checkout
18
18
  */
19
- export type FlowType = "lrs" | "standard" | "unified";
19
+ export type FlowType = "lrs" | "standard" | "unified" | "subscriptions";
20
20
 
21
21
  /**
22
22
  * Common properties that should be included with every event
@@ -40,7 +40,7 @@ export interface CommonEventProperties {
40
40
  export interface SdkError {
41
41
  type: "validation_error" | "device_forbidden";
42
42
  message: string;
43
- field?: "publicKey" | "orderId" | "baseCheckoutUrl" | "generatedCheckoutUrl";
43
+ field?: "publicKey" | "orderId" | "subscriptionId" | "baseCheckoutUrl" | "generatedCheckoutUrl";
44
44
  }
45
45
 
46
46
  /**
@@ -52,7 +52,6 @@ export interface SdkError {
52
52
  function getSdkVersion(): string {
53
53
  try {
54
54
  // Using require to dynamically import package.json
55
- // eslint-disable-next-line @typescript-eslint/no-require-imports
56
55
  const packageJson = require("../../package.json");
57
56
  return packageJson.version || "unknown";
58
57
  } catch {
@@ -632,7 +631,11 @@ export function trackStandardStartSuccess(
632
631
  jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
633
632
  }),
634
633
  };
635
- trackEvent("Standard Checkout Started", properties, devMode).catch(() => {});
634
+ trackEvent("Standard Checkout Started", properties, devMode).catch((error) => {
635
+ if (devMode) {
636
+ console.error("[Glomo-RN-SDK] Event tracking error on standard start:", error);
637
+ }
638
+ });
636
639
  }
637
640
 
638
641
  /**
@@ -658,7 +661,11 @@ export function trackStandardStartAttempt(
658
661
  jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
659
662
  }),
660
663
  };
661
- trackEvent("Standard Checkout Start Attempted", properties, devMode).catch(() => {});
664
+ trackEvent("Standard Checkout Start Attempted", properties, devMode).catch((error) => {
665
+ if (devMode) {
666
+ console.error("[Glomo-RN-SDK] Event tracking error on standard start attempt:", error);
667
+ }
668
+ });
662
669
  }
663
670
 
664
671
  /**
@@ -684,7 +691,11 @@ export function trackStandardStartFailure(
684
691
  jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
685
692
  }),
686
693
  };
687
- trackEvent("Standard Checkout Start Failed", properties, devMode).catch(() => {});
694
+ trackEvent("Standard Checkout Start Failed", properties, devMode).catch((error) => {
695
+ if (devMode) {
696
+ console.error("[Glomo-RN-SDK] Event tracking error on standard start failure:", error);
697
+ }
698
+ });
688
699
  }
689
700
 
690
701
  /**
@@ -704,7 +715,11 @@ export function trackStandardWindowOpen(
704
715
  source,
705
716
  url,
706
717
  };
707
- trackEvent("Standard Checkout Window Open", properties, devMode).catch(() => {});
718
+ trackEvent("Standard Checkout Window Open", properties, devMode).catch((error) => {
719
+ if (devMode) {
720
+ console.error("[Glomo-RN-SDK] Event tracking error on standard window open:", error);
721
+ }
722
+ });
708
723
  }
709
724
 
710
725
  /**
@@ -722,7 +737,11 @@ export function trackStandardWindowClose(
722
737
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
723
738
  source,
724
739
  };
725
- trackEvent("Standard Checkout Window Close", properties, devMode).catch(() => {});
740
+ trackEvent("Standard Checkout Window Close", properties, devMode).catch((error) => {
741
+ if (devMode) {
742
+ console.error("[Glomo-RN-SDK] Event tracking error on standard window close:", error);
743
+ }
744
+ });
726
745
  }
727
746
 
728
747
  /**
@@ -762,7 +781,11 @@ export function trackStandardInvalidMessageReceived(
762
781
  dataType: data === null ? "null" : typeof data,
763
782
  ...(url && { url }),
764
783
  };
765
- trackEvent("Standard Checkout Invalid Message Received", properties, devMode).catch(() => {});
784
+ trackEvent("Standard Checkout Invalid Message Received", properties, devMode).catch((error) => {
785
+ if (devMode) {
786
+ console.error("[Glomo-RN-SDK] Event tracking error on standard invalid message:", error);
787
+ }
788
+ });
766
789
  }
767
790
 
768
791
  /**
@@ -780,7 +803,11 @@ export function trackStandardPaymentSuccess(
780
803
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
781
804
  paymentId,
782
805
  };
783
- trackEvent("Standard Payment Success", properties, devMode).catch(() => {});
806
+ trackEvent("Standard Payment Success", properties, devMode).catch((error) => {
807
+ if (devMode) {
808
+ console.error("[Glomo-RN-SDK] Event tracking error on standard payment success:", error);
809
+ }
810
+ });
784
811
  }
785
812
 
786
813
  /**
@@ -798,7 +825,11 @@ export function trackStandardPaymentFailure(
798
825
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
799
826
  paymentId,
800
827
  };
801
- trackEvent("Standard Payment Failure", properties, devMode).catch(() => {});
828
+ trackEvent("Standard Payment Failure", properties, devMode).catch((error) => {
829
+ if (devMode) {
830
+ console.error("[Glomo-RN-SDK] Event tracking error on standard payment failure:", error);
831
+ }
832
+ });
802
833
  }
803
834
 
804
835
  /**
@@ -816,7 +847,11 @@ export function trackStandardPaymentTerminate(
816
847
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
817
848
  terminationSource: source,
818
849
  };
819
- trackEvent("Standard Payment Terminated", properties, devMode).catch(() => {});
850
+ trackEvent("Standard Payment Terminated", properties, devMode).catch((error) => {
851
+ if (devMode) {
852
+ console.error("[Glomo-RN-SDK] Event tracking error on standard payment terminate:", error);
853
+ }
854
+ });
820
855
  }
821
856
 
822
857
  /**
@@ -834,7 +869,11 @@ export function trackStandardConnectionError(
834
869
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
835
870
  ...(errorCode !== undefined && { errorCode }),
836
871
  };
837
- trackEvent("Standard Connection Error", properties, devMode).catch(() => {});
872
+ trackEvent("Standard Connection Error", properties, devMode).catch((error) => {
873
+ if (devMode) {
874
+ console.error("[Glomo-RN-SDK] Event tracking error on standard connection error:", error);
875
+ }
876
+ });
838
877
  }
839
878
 
840
879
  /**
@@ -853,7 +892,11 @@ export function trackStandardSdkError(
853
892
  errors,
854
893
  errorCount: errors.length,
855
894
  };
856
- trackEvent("Standard SDK Error", properties, devMode).catch(() => {});
895
+ trackEvent("Standard SDK Error", properties, devMode).catch((error) => {
896
+ if (devMode) {
897
+ console.error("[Glomo-RN-SDK] Event tracking error on standard SDK error:", error);
898
+ }
899
+ });
857
900
  }
858
901
 
859
902
  export function trackStandardBankTransferSubmitted(
@@ -866,7 +909,11 @@ export function trackStandardBankTransferSubmitted(
866
909
  const properties = {
867
910
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
868
911
  };
869
- trackEvent("Standard Bank Transfer Submitted", properties, devMode).catch(() => {});
912
+ trackEvent("Standard Bank Transfer Submitted", properties, devMode).catch((error) => {
913
+ if (devMode) {
914
+ console.error("[Glomo-RN-SDK] Event tracking error on standard bank transfer submitted:", error);
915
+ }
916
+ });
870
917
  }
871
918
 
872
919
  export function trackStandardPayViaBankCompleted(
@@ -881,7 +928,11 @@ export function trackStandardPayViaBankCompleted(
881
928
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
882
929
  payViaBankStatus: status,
883
930
  };
884
- trackEvent("Standard Pay Via Bank Completed", properties, devMode).catch(() => {});
931
+ trackEvent("Standard Pay Via Bank Completed", properties, devMode).catch((error) => {
932
+ if (devMode) {
933
+ console.error("[Glomo-RN-SDK] Event tracking error on standard pay via bank completed:", error);
934
+ }
935
+ });
885
936
  }
886
937
 
887
938
  export function trackStandardPayViaBankBankConnectionSuccessful(
@@ -896,7 +947,11 @@ export function trackStandardPayViaBankBankConnectionSuccessful(
896
947
  ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
897
948
  bankIdentifier,
898
949
  };
899
- trackEvent("Standard Pay Via Bank Bank Connection Successful", properties, devMode).catch(() => {});
950
+ trackEvent("Standard Pay Via Bank Bank Connection Successful", properties, devMode).catch((error) => {
951
+ if (devMode) {
952
+ console.error("[Glomo-RN-SDK] Event tracking error on standard pay via bank connection:", error);
953
+ }
954
+ });
900
955
  }
901
956
 
902
957
  // ---------------------------------------------------------------------------
@@ -991,3 +1046,413 @@ export function checkAnalyticsStatus(devMode: boolean = false): boolean {
991
1046
 
992
1047
  return available;
993
1048
  }
1049
+
1050
+ // ---------------------------------------------------------------------------
1051
+ // Subscription Checkout Trackers
1052
+ // ---------------------------------------------------------------------------
1053
+
1054
+ /**
1055
+ * Tracks when the subscription checkout start() method is called (attempted)
1056
+ */
1057
+ export function trackSubscriptionStartAttempt(
1058
+ status: string,
1059
+ orderId: string,
1060
+ publicKey: string,
1061
+ devMode: boolean = false,
1062
+ mockMode: boolean = false,
1063
+ checkoutUrl?: string,
1064
+ jailbreakDetectionInfo?: {
1065
+ jailbreakDetectionLibraryInstalled: boolean;
1066
+ jailbreakDetected: boolean | null;
1067
+ }
1068
+ ): void {
1069
+ const properties = {
1070
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1071
+ subscriptionId: orderId,
1072
+ status,
1073
+ ...(jailbreakDetectionInfo && {
1074
+ jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
1075
+ jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
1076
+ }),
1077
+ };
1078
+ trackEvent("Subscription Checkout Start Attempted", properties, devMode).catch((error) => {
1079
+ if (devMode) {
1080
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription start attempt:", error);
1081
+ }
1082
+ });
1083
+ }
1084
+
1085
+ /**
1086
+ * Tracks when the subscription checkout start() method has been called successfully
1087
+ */
1088
+ export function trackSubscriptionStartSuccess(
1089
+ orderId: string,
1090
+ publicKey: string,
1091
+ devMode: boolean = false,
1092
+ mockMode: boolean = false,
1093
+ checkoutUrl?: string,
1094
+ jailbreakDetectionInfo?: {
1095
+ jailbreakDetectionLibraryInstalled: boolean;
1096
+ jailbreakDetected: boolean | null;
1097
+ }
1098
+ ): void {
1099
+ const properties = {
1100
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1101
+ subscriptionId: orderId,
1102
+ ...(jailbreakDetectionInfo && {
1103
+ jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
1104
+ jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
1105
+ }),
1106
+ };
1107
+ trackEvent("Subscription Checkout Started", properties, devMode).catch((error) => {
1108
+ if (devMode) {
1109
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription start:", error);
1110
+ }
1111
+ });
1112
+ }
1113
+
1114
+ /**
1115
+ * Tracks when the subscription checkout start() method fails
1116
+ */
1117
+ export function trackSubscriptionStartFailure(
1118
+ reason: "device_forbidden" | "validation_error" | "payment_successful" | "invalid_status" | "invalid_url",
1119
+ orderId?: string,
1120
+ publicKey?: string,
1121
+ devMode: boolean = false,
1122
+ mockMode: boolean = false,
1123
+ checkoutUrl?: string,
1124
+ jailbreakDetectionInfo?: {
1125
+ jailbreakDetectionLibraryInstalled: boolean;
1126
+ jailbreakDetected: boolean | null;
1127
+ }
1128
+ ): void {
1129
+ const properties = {
1130
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1131
+ subscriptionId: orderId,
1132
+ failureReason: reason,
1133
+ ...(jailbreakDetectionInfo && {
1134
+ jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
1135
+ jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
1136
+ }),
1137
+ };
1138
+ trackEvent("Subscription Checkout Start Failed", properties, devMode).catch((error) => {
1139
+ if (devMode) {
1140
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription start failure:", error);
1141
+ }
1142
+ });
1143
+ }
1144
+
1145
+ /**
1146
+ * Tracks when window.open is intercepted from the subscription checkout WebView
1147
+ */
1148
+ export function trackSubscriptionWindowOpen(
1149
+ source: "main" | "flow",
1150
+ url: string,
1151
+ orderId: string,
1152
+ publicKey: string,
1153
+ devMode: boolean = false,
1154
+ mockMode: boolean = false,
1155
+ checkoutUrl?: string
1156
+ ): void {
1157
+ const properties = {
1158
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1159
+ subscriptionId: orderId,
1160
+ source,
1161
+ url,
1162
+ };
1163
+ trackEvent("Subscription Checkout Window Open", properties, devMode).catch((error) => {
1164
+ if (devMode) {
1165
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription window open:", error);
1166
+ }
1167
+ });
1168
+ }
1169
+
1170
+ /**
1171
+ * Tracks when window.close is intercepted from the subscription checkout WebView
1172
+ */
1173
+ export function trackSubscriptionWindowClose(
1174
+ source: "main" | "flow",
1175
+ orderId: string,
1176
+ publicKey: string,
1177
+ devMode: boolean = false,
1178
+ mockMode: boolean = false,
1179
+ checkoutUrl?: string
1180
+ ): void {
1181
+ const properties = {
1182
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1183
+ subscriptionId: orderId,
1184
+ source,
1185
+ };
1186
+ trackEvent("Subscription Checkout Window Close", properties, devMode).catch((error) => {
1187
+ if (devMode) {
1188
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription window close:", error);
1189
+ }
1190
+ });
1191
+ }
1192
+
1193
+ /**
1194
+ * Tracks when invalid message data is received from a subscription checkout WebView
1195
+ */
1196
+ export function trackSubscriptionInvalidMessageReceived(
1197
+ webviewType: "main" | "flow",
1198
+ data: unknown,
1199
+ url: string | undefined,
1200
+ orderId: string,
1201
+ publicKey: string,
1202
+ devMode: boolean = false,
1203
+ mockMode: boolean = false,
1204
+ checkoutUrl?: string
1205
+ ): void {
1206
+ let dataString: string;
1207
+ try {
1208
+ if (data === null) {
1209
+ dataString = "null";
1210
+ } else if (data === undefined) {
1211
+ dataString = "undefined";
1212
+ } else if (typeof data === "string") {
1213
+ dataString = data;
1214
+ } else if (typeof data === "object") {
1215
+ dataString = JSON.stringify(data);
1216
+ } else {
1217
+ dataString = String(data);
1218
+ }
1219
+ } catch {
1220
+ dataString = "[unable to stringify]";
1221
+ }
1222
+
1223
+ const properties = {
1224
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1225
+ subscriptionId: orderId,
1226
+ webviewType,
1227
+ data: dataString,
1228
+ dataType: data === null ? "null" : typeof data,
1229
+ ...(url && { url }),
1230
+ };
1231
+ trackEvent("Subscription Checkout Invalid Message Received", properties, devMode).catch((error) => {
1232
+ if (devMode) {
1233
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription invalid message:", error);
1234
+ }
1235
+ });
1236
+ }
1237
+
1238
+ /**
1239
+ * Tracks when subscription checkout onPaymentSuccess callback is invoked
1240
+ */
1241
+ export function trackSubscriptionPaymentSuccess(
1242
+ orderId: string,
1243
+ paymentId: string,
1244
+ publicKey: string,
1245
+ devMode: boolean = false,
1246
+ mockMode: boolean = false,
1247
+ checkoutUrl?: string
1248
+ ): void {
1249
+ const properties = {
1250
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1251
+ subscriptionId: orderId,
1252
+ paymentId,
1253
+ };
1254
+ trackEvent("Subscription Payment Success", properties, devMode).catch((error) => {
1255
+ if (devMode) {
1256
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription payment success:", error);
1257
+ }
1258
+ });
1259
+ }
1260
+
1261
+ /**
1262
+ * Tracks when subscription checkout onPaymentFailure callback is invoked
1263
+ */
1264
+ export function trackSubscriptionPaymentFailure(
1265
+ orderId: string,
1266
+ paymentId: string,
1267
+ publicKey: string,
1268
+ devMode: boolean = false,
1269
+ mockMode: boolean = false,
1270
+ checkoutUrl?: string
1271
+ ): void {
1272
+ const properties = {
1273
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1274
+ subscriptionId: orderId,
1275
+ paymentId,
1276
+ };
1277
+ trackEvent("Subscription Payment Failure", properties, devMode).catch((error) => {
1278
+ if (devMode) {
1279
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription payment failure:", error);
1280
+ }
1281
+ });
1282
+ }
1283
+
1284
+ /**
1285
+ * Tracks when subscription checkout onPaymentTerminate callback is invoked
1286
+ */
1287
+ export function trackSubscriptionPaymentTerminate(
1288
+ orderId: string,
1289
+ source: "user_dismiss" | "back_button" | "checkout_closed",
1290
+ publicKey: string,
1291
+ devMode: boolean = false,
1292
+ mockMode: boolean = false,
1293
+ checkoutUrl?: string
1294
+ ): void {
1295
+ const properties = {
1296
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1297
+ subscriptionId: orderId,
1298
+ terminationSource: source,
1299
+ };
1300
+ trackEvent("Subscription Payment Terminated", properties, devMode).catch((error) => {
1301
+ if (devMode) {
1302
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription payment terminate:", error);
1303
+ }
1304
+ });
1305
+ }
1306
+
1307
+ /**
1308
+ * Tracks when subscription checkout onConnectionError callback is invoked
1309
+ */
1310
+ export function trackSubscriptionConnectionError(
1311
+ orderId: string,
1312
+ errorCode: number | undefined,
1313
+ publicKey: string,
1314
+ devMode: boolean = false,
1315
+ mockMode: boolean = false,
1316
+ checkoutUrl?: string
1317
+ ): void {
1318
+ const properties = {
1319
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1320
+ subscriptionId: orderId,
1321
+ ...(errorCode !== undefined && { errorCode }),
1322
+ };
1323
+ trackEvent("Subscription Connection Error", properties, devMode).catch((error) => {
1324
+ if (devMode) {
1325
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription connection error:", error);
1326
+ }
1327
+ });
1328
+ }
1329
+
1330
+ /**
1331
+ * Tracks when subscription checkout onSdkError callback is invoked
1332
+ */
1333
+ export function trackSubscriptionSdkError(
1334
+ errors: Array<SdkError>,
1335
+ orderId?: string,
1336
+ publicKey?: string,
1337
+ devMode: boolean = false,
1338
+ mockMode: boolean = false,
1339
+ checkoutUrl?: string
1340
+ ): void {
1341
+ const properties = {
1342
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1343
+ subscriptionId: orderId,
1344
+ errors,
1345
+ errorCount: errors.length,
1346
+ };
1347
+ trackEvent("Subscription SDK Error", properties, devMode).catch((error) => {
1348
+ if (devMode) {
1349
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription SDK error:", error);
1350
+ }
1351
+ });
1352
+ }
1353
+
1354
+ // ---------------------------------------------------------------------------
1355
+ // Unsupported Functionality Telemetry
1356
+ // ---------------------------------------------------------------------------
1357
+
1358
+ /**
1359
+ * Internal telemetry - fires when a merchant uses functionality that is
1360
+ * unsupported in the current context or deprecated.
1361
+ * Fires at most once per detection site (callers use a ref guard).
1362
+ */
1363
+ export function trackUseOfUnsupportedFunctionality(
1364
+ name: string,
1365
+ orderId: string | undefined,
1366
+ publicKey: string,
1367
+ devMode: boolean,
1368
+ mockMode: boolean,
1369
+ checkoutUrl: string
1370
+ ): void {
1371
+ const properties = {
1372
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl),
1373
+ name,
1374
+ };
1375
+ trackEvent("Use of Unsupported Functionality", properties, devMode).catch((error) => {
1376
+ if (devMode) {
1377
+ console.error("[Glomo-RN-SDK] Event tracking error on unsupported functionality:", error);
1378
+ }
1379
+ });
1380
+ }
1381
+
1382
+ // ---------------------------------------------------------------------------
1383
+ // Checkout Analytics Tracker Map
1384
+ // ---------------------------------------------------------------------------
1385
+
1386
+ /**
1387
+ * Internal tracker map interface.
1388
+ * Each flow (standard, subscription) provides its own implementation.
1389
+ * useStandardCheckout calls through this map at every analytics call site.
1390
+ * Not exported to merchants via index.ts.
1391
+ */
1392
+ export interface CheckoutAnalyticsTrackers {
1393
+ trackStartAttempt: typeof trackStandardStartAttempt;
1394
+ trackStartSuccess: typeof trackStandardStartSuccess;
1395
+ trackStartFailure: typeof trackStandardStartFailure;
1396
+ trackWindowOpen: typeof trackStandardWindowOpen;
1397
+ trackWindowClose: typeof trackStandardWindowClose;
1398
+ trackInvalidMessageReceived: typeof trackStandardInvalidMessageReceived;
1399
+ trackPaymentSuccess: typeof trackStandardPaymentSuccess;
1400
+ trackPaymentFailure: typeof trackStandardPaymentFailure;
1401
+ trackPaymentTerminate: typeof trackStandardPaymentTerminate;
1402
+ trackConnectionError: typeof trackStandardConnectionError;
1403
+ trackSdkError: typeof trackStandardSdkError;
1404
+ trackBankTransferSubmitted: typeof trackStandardBankTransferSubmitted;
1405
+ trackPayViaBankCompleted: typeof trackStandardPayViaBankCompleted;
1406
+ trackPayViaBankBankConnectionSuccessful: typeof trackStandardPayViaBankBankConnectionSuccessful;
1407
+ }
1408
+
1409
+ /** Standard checkout tracker map - delegates to trackStandard* functions */
1410
+ export const standardCheckoutTrackers: CheckoutAnalyticsTrackers = {
1411
+ trackStartAttempt: trackStandardStartAttempt,
1412
+ trackStartSuccess: trackStandardStartSuccess,
1413
+ trackStartFailure: trackStandardStartFailure,
1414
+ trackWindowOpen: trackStandardWindowOpen,
1415
+ trackWindowClose: trackStandardWindowClose,
1416
+ trackInvalidMessageReceived: trackStandardInvalidMessageReceived,
1417
+ trackPaymentSuccess: trackStandardPaymentSuccess,
1418
+ trackPaymentFailure: trackStandardPaymentFailure,
1419
+ trackPaymentTerminate: trackStandardPaymentTerminate,
1420
+ trackConnectionError: trackStandardConnectionError,
1421
+ trackSdkError: trackStandardSdkError,
1422
+ trackBankTransferSubmitted: trackStandardBankTransferSubmitted,
1423
+ trackPayViaBankCompleted: trackStandardPayViaBankCompleted,
1424
+ trackPayViaBankBankConnectionSuccessful: trackStandardPayViaBankBankConnectionSuccessful,
1425
+ };
1426
+
1427
+ /** Subscription checkout tracker map - delegates to trackSubscription* functions, no-ops for bank transfer */
1428
+ export const subscriptionCheckoutTrackers: CheckoutAnalyticsTrackers = {
1429
+ trackStartAttempt: trackSubscriptionStartAttempt,
1430
+ trackStartSuccess: trackSubscriptionStartSuccess,
1431
+ trackStartFailure: trackSubscriptionStartFailure,
1432
+ trackWindowOpen: trackSubscriptionWindowOpen,
1433
+ trackWindowClose: trackSubscriptionWindowClose,
1434
+ trackInvalidMessageReceived: trackSubscriptionInvalidMessageReceived,
1435
+ trackPaymentSuccess: trackSubscriptionPaymentSuccess,
1436
+ trackPaymentFailure: trackSubscriptionPaymentFailure,
1437
+ trackPaymentTerminate: trackSubscriptionPaymentTerminate,
1438
+ trackConnectionError: trackSubscriptionConnectionError,
1439
+ trackSdkError: trackSubscriptionSdkError,
1440
+ trackBankTransferSubmitted: (...args) => {
1441
+ const devMode = args[2];
1442
+ if (devMode) {
1443
+ console.warn("[Glomo-RN-SDK] Unexpected bank transfer event in subscription flow");
1444
+ }
1445
+ },
1446
+ trackPayViaBankCompleted: (...args) => {
1447
+ const devMode = args[3];
1448
+ if (devMode) {
1449
+ console.warn("[Glomo-RN-SDK] Unexpected pay via bank completed event in subscription flow");
1450
+ }
1451
+ },
1452
+ trackPayViaBankBankConnectionSuccessful: (...args) => {
1453
+ const devMode = args[3];
1454
+ if (devMode) {
1455
+ console.warn("[Glomo-RN-SDK] Unexpected pay via bank connection event in subscription flow");
1456
+ }
1457
+ },
1458
+ };
@@ -13,7 +13,6 @@
13
13
  */
14
14
  function getJailMonkey(): { isJailBroken: () => boolean } | null {
15
15
  try {
16
- // eslint-disable-next-line @typescript-eslint/no-require-imports
17
16
  const JailMonkey = require("jail-monkey");
18
17
  if (JailMonkey && typeof JailMonkey.isJailBroken === "function") {
19
18
  return JailMonkey;