@glomopay/react-native-sdk 3.0.1 → 4.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 (52) hide show
  1. package/CHANGELOG.md +38 -2
  2. package/MIGRATION.md +129 -0
  3. package/README.md +176 -126
  4. package/lib/glomo-checkout.d.ts +2 -1
  5. package/lib/glomo-checkout.d.ts.map +1 -1
  6. package/lib/glomo-checkout.js +25 -3
  7. package/lib/glomo-lrs-checkout.d.ts +1 -1
  8. package/lib/glomo-lrs-checkout.d.ts.map +1 -1
  9. package/lib/glomo-standard-checkout.d.ts +20 -0
  10. package/lib/glomo-standard-checkout.d.ts.map +1 -1
  11. package/lib/glomo-standard-checkout.js +15 -6
  12. package/lib/glomo-subscriptions-checkout.d.ts +8 -0
  13. package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
  14. package/lib/glomo-subscriptions-checkout.js +85 -0
  15. package/lib/index.d.ts +3 -3
  16. package/lib/index.d.ts.map +1 -1
  17. package/lib/index.js +5 -3
  18. package/lib/types/checkout.d.ts +33 -22
  19. package/lib/types/checkout.d.ts.map +1 -1
  20. package/lib/types/checkout.js +12 -1
  21. package/lib/types/standard-checkout.d.ts +3 -7
  22. package/lib/types/standard-checkout.d.ts.map +1 -1
  23. package/lib/types/subscriptions-checkout.d.ts +29 -0
  24. package/lib/types/subscriptions-checkout.d.ts.map +1 -0
  25. package/lib/types/subscriptions-checkout.js +3 -0
  26. package/lib/use-glomo-checkout.d.ts +34 -4
  27. package/lib/use-glomo-checkout.d.ts.map +1 -1
  28. package/lib/use-glomo-checkout.js +92 -13
  29. package/lib/use-lrs-checkout.d.ts +1 -1
  30. package/lib/use-lrs-checkout.d.ts.map +1 -1
  31. package/lib/use-standard-checkout.d.ts +14 -9
  32. package/lib/use-standard-checkout.d.ts.map +1 -1
  33. package/lib/use-standard-checkout.js +74 -85
  34. package/lib/utils/analytics.d.ts +86 -3
  35. package/lib/utils/analytics.d.ts.map +1 -1
  36. package/lib/utils/analytics.js +344 -22
  37. package/lib/utils/device-compliance.d.ts.map +1 -1
  38. package/lib/utils/device-compliance.js +0 -1
  39. package/package.json +15 -4
  40. package/src/glomo-checkout.tsx +65 -9
  41. package/src/glomo-lrs-checkout.tsx +1 -1
  42. package/src/glomo-standard-checkout.tsx +35 -10
  43. package/src/glomo-subscriptions-checkout.tsx +83 -0
  44. package/src/index.ts +5 -5
  45. package/src/types/checkout.ts +28 -20
  46. package/src/types/standard-checkout.ts +3 -5
  47. package/src/types/subscriptions-checkout.ts +31 -0
  48. package/src/use-glomo-checkout.tsx +158 -17
  49. package/src/use-lrs-checkout.tsx +1 -1
  50. package/src/use-standard-checkout.tsx +94 -153
  51. package/src/utils/analytics.ts +469 -31
  52. 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,22 +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(() => {});
885
- }
886
-
887
- export function trackStandardPayViaBankBankConnectionSuccessful(
888
- orderId: string,
889
- publicKey: string,
890
- bankIdentifier: string,
891
- devMode: boolean = false,
892
- mockMode: boolean = false,
893
- standardUrl?: string
894
- ): void {
895
- const properties = {
896
- ...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
897
- bankIdentifier,
898
- };
899
- trackEvent("Standard Pay Via Bank Bank Connection Successful", 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
+ });
900
936
  }
901
937
 
902
938
  // ---------------------------------------------------------------------------
@@ -991,3 +1027,405 @@ export function checkAnalyticsStatus(devMode: boolean = false): boolean {
991
1027
 
992
1028
  return available;
993
1029
  }
1030
+
1031
+ // ---------------------------------------------------------------------------
1032
+ // Subscription Checkout Trackers
1033
+ // ---------------------------------------------------------------------------
1034
+
1035
+ /**
1036
+ * Tracks when the subscription checkout start() method is called (attempted)
1037
+ */
1038
+ export function trackSubscriptionStartAttempt(
1039
+ status: string,
1040
+ orderId: string,
1041
+ publicKey: string,
1042
+ devMode: boolean = false,
1043
+ mockMode: boolean = false,
1044
+ checkoutUrl?: string,
1045
+ jailbreakDetectionInfo?: {
1046
+ jailbreakDetectionLibraryInstalled: boolean;
1047
+ jailbreakDetected: boolean | null;
1048
+ }
1049
+ ): void {
1050
+ const properties = {
1051
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1052
+ subscriptionId: orderId,
1053
+ status,
1054
+ ...(jailbreakDetectionInfo && {
1055
+ jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
1056
+ jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
1057
+ }),
1058
+ };
1059
+ trackEvent("Subscription Checkout Start Attempted", properties, devMode).catch((error) => {
1060
+ if (devMode) {
1061
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription start attempt:", error);
1062
+ }
1063
+ });
1064
+ }
1065
+
1066
+ /**
1067
+ * Tracks when the subscription checkout start() method has been called successfully
1068
+ */
1069
+ export function trackSubscriptionStartSuccess(
1070
+ orderId: string,
1071
+ publicKey: string,
1072
+ devMode: boolean = false,
1073
+ mockMode: boolean = false,
1074
+ checkoutUrl?: string,
1075
+ jailbreakDetectionInfo?: {
1076
+ jailbreakDetectionLibraryInstalled: boolean;
1077
+ jailbreakDetected: boolean | null;
1078
+ }
1079
+ ): void {
1080
+ const properties = {
1081
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1082
+ subscriptionId: orderId,
1083
+ ...(jailbreakDetectionInfo && {
1084
+ jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
1085
+ jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
1086
+ }),
1087
+ };
1088
+ trackEvent("Subscription Checkout Started", properties, devMode).catch((error) => {
1089
+ if (devMode) {
1090
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription start:", error);
1091
+ }
1092
+ });
1093
+ }
1094
+
1095
+ /**
1096
+ * Tracks when the subscription checkout start() method fails
1097
+ */
1098
+ export function trackSubscriptionStartFailure(
1099
+ reason: "device_forbidden" | "validation_error" | "payment_successful" | "invalid_status" | "invalid_url",
1100
+ orderId?: string,
1101
+ publicKey?: string,
1102
+ devMode: boolean = false,
1103
+ mockMode: boolean = false,
1104
+ checkoutUrl?: string,
1105
+ jailbreakDetectionInfo?: {
1106
+ jailbreakDetectionLibraryInstalled: boolean;
1107
+ jailbreakDetected: boolean | null;
1108
+ }
1109
+ ): void {
1110
+ const properties = {
1111
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1112
+ subscriptionId: orderId,
1113
+ failureReason: reason,
1114
+ ...(jailbreakDetectionInfo && {
1115
+ jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
1116
+ jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
1117
+ }),
1118
+ };
1119
+ trackEvent("Subscription Checkout Start Failed", properties, devMode).catch((error) => {
1120
+ if (devMode) {
1121
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription start failure:", error);
1122
+ }
1123
+ });
1124
+ }
1125
+
1126
+ /**
1127
+ * Tracks when window.open is intercepted from the subscription checkout WebView
1128
+ */
1129
+ export function trackSubscriptionWindowOpen(
1130
+ source: "main" | "flow",
1131
+ url: string,
1132
+ orderId: string,
1133
+ publicKey: string,
1134
+ devMode: boolean = false,
1135
+ mockMode: boolean = false,
1136
+ checkoutUrl?: string
1137
+ ): void {
1138
+ const properties = {
1139
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1140
+ subscriptionId: orderId,
1141
+ source,
1142
+ url,
1143
+ };
1144
+ trackEvent("Subscription Checkout Window Open", properties, devMode).catch((error) => {
1145
+ if (devMode) {
1146
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription window open:", error);
1147
+ }
1148
+ });
1149
+ }
1150
+
1151
+ /**
1152
+ * Tracks when window.close is intercepted from the subscription checkout WebView
1153
+ */
1154
+ export function trackSubscriptionWindowClose(
1155
+ source: "main" | "flow",
1156
+ orderId: string,
1157
+ publicKey: string,
1158
+ devMode: boolean = false,
1159
+ mockMode: boolean = false,
1160
+ checkoutUrl?: string
1161
+ ): void {
1162
+ const properties = {
1163
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1164
+ subscriptionId: orderId,
1165
+ source,
1166
+ };
1167
+ trackEvent("Subscription Checkout Window Close", properties, devMode).catch((error) => {
1168
+ if (devMode) {
1169
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription window close:", error);
1170
+ }
1171
+ });
1172
+ }
1173
+
1174
+ /**
1175
+ * Tracks when invalid message data is received from a subscription checkout WebView
1176
+ */
1177
+ export function trackSubscriptionInvalidMessageReceived(
1178
+ webviewType: "main" | "flow",
1179
+ data: unknown,
1180
+ url: string | undefined,
1181
+ orderId: string,
1182
+ publicKey: string,
1183
+ devMode: boolean = false,
1184
+ mockMode: boolean = false,
1185
+ checkoutUrl?: string
1186
+ ): void {
1187
+ let dataString: string;
1188
+ try {
1189
+ if (data === null) {
1190
+ dataString = "null";
1191
+ } else if (data === undefined) {
1192
+ dataString = "undefined";
1193
+ } else if (typeof data === "string") {
1194
+ dataString = data;
1195
+ } else if (typeof data === "object") {
1196
+ dataString = JSON.stringify(data);
1197
+ } else {
1198
+ dataString = String(data);
1199
+ }
1200
+ } catch {
1201
+ dataString = "[unable to stringify]";
1202
+ }
1203
+
1204
+ const properties = {
1205
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1206
+ subscriptionId: orderId,
1207
+ webviewType,
1208
+ data: dataString,
1209
+ dataType: data === null ? "null" : typeof data,
1210
+ ...(url && { url }),
1211
+ };
1212
+ trackEvent("Subscription Checkout Invalid Message Received", properties, devMode).catch((error) => {
1213
+ if (devMode) {
1214
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription invalid message:", error);
1215
+ }
1216
+ });
1217
+ }
1218
+
1219
+ /**
1220
+ * Tracks when subscription checkout onPaymentSuccess callback is invoked
1221
+ */
1222
+ export function trackSubscriptionPaymentSuccess(
1223
+ orderId: string,
1224
+ paymentId: string,
1225
+ publicKey: string,
1226
+ devMode: boolean = false,
1227
+ mockMode: boolean = false,
1228
+ checkoutUrl?: string
1229
+ ): void {
1230
+ const properties = {
1231
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1232
+ subscriptionId: orderId,
1233
+ paymentId,
1234
+ };
1235
+ trackEvent("Subscription Payment Success", properties, devMode).catch((error) => {
1236
+ if (devMode) {
1237
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription payment success:", error);
1238
+ }
1239
+ });
1240
+ }
1241
+
1242
+ /**
1243
+ * Tracks when subscription checkout onPaymentFailure callback is invoked
1244
+ */
1245
+ export function trackSubscriptionPaymentFailure(
1246
+ orderId: string,
1247
+ paymentId: string,
1248
+ publicKey: string,
1249
+ devMode: boolean = false,
1250
+ mockMode: boolean = false,
1251
+ checkoutUrl?: string
1252
+ ): void {
1253
+ const properties = {
1254
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1255
+ subscriptionId: orderId,
1256
+ paymentId,
1257
+ };
1258
+ trackEvent("Subscription Payment Failure", properties, devMode).catch((error) => {
1259
+ if (devMode) {
1260
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription payment failure:", error);
1261
+ }
1262
+ });
1263
+ }
1264
+
1265
+ /**
1266
+ * Tracks when subscription checkout onPaymentTerminate callback is invoked
1267
+ */
1268
+ export function trackSubscriptionPaymentTerminate(
1269
+ orderId: string,
1270
+ source: "user_dismiss" | "back_button" | "checkout_closed",
1271
+ publicKey: string,
1272
+ devMode: boolean = false,
1273
+ mockMode: boolean = false,
1274
+ checkoutUrl?: string
1275
+ ): void {
1276
+ const properties = {
1277
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1278
+ subscriptionId: orderId,
1279
+ terminationSource: source,
1280
+ };
1281
+ trackEvent("Subscription Payment Terminated", properties, devMode).catch((error) => {
1282
+ if (devMode) {
1283
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription payment terminate:", error);
1284
+ }
1285
+ });
1286
+ }
1287
+
1288
+ /**
1289
+ * Tracks when subscription checkout onConnectionError callback is invoked
1290
+ */
1291
+ export function trackSubscriptionConnectionError(
1292
+ orderId: string,
1293
+ errorCode: number | undefined,
1294
+ publicKey: string,
1295
+ devMode: boolean = false,
1296
+ mockMode: boolean = false,
1297
+ checkoutUrl?: string
1298
+ ): void {
1299
+ const properties = {
1300
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1301
+ subscriptionId: orderId,
1302
+ ...(errorCode !== undefined && { errorCode }),
1303
+ };
1304
+ trackEvent("Subscription Connection Error", properties, devMode).catch((error) => {
1305
+ if (devMode) {
1306
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription connection error:", error);
1307
+ }
1308
+ });
1309
+ }
1310
+
1311
+ /**
1312
+ * Tracks when subscription checkout onSdkError callback is invoked
1313
+ */
1314
+ export function trackSubscriptionSdkError(
1315
+ errors: Array<SdkError>,
1316
+ orderId?: string,
1317
+ publicKey?: string,
1318
+ devMode: boolean = false,
1319
+ mockMode: boolean = false,
1320
+ checkoutUrl?: string
1321
+ ): void {
1322
+ const properties = {
1323
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
1324
+ subscriptionId: orderId,
1325
+ errors,
1326
+ errorCount: errors.length,
1327
+ };
1328
+ trackEvent("Subscription SDK Error", properties, devMode).catch((error) => {
1329
+ if (devMode) {
1330
+ console.error("[Glomo-RN-SDK] Event tracking error on subscription SDK error:", error);
1331
+ }
1332
+ });
1333
+ }
1334
+
1335
+ // ---------------------------------------------------------------------------
1336
+ // Unsupported Functionality Telemetry
1337
+ // ---------------------------------------------------------------------------
1338
+
1339
+ /**
1340
+ * Internal telemetry - fires when a merchant uses functionality that is
1341
+ * unsupported in the current context or deprecated.
1342
+ * Fires at most once per detection site (callers use a ref guard).
1343
+ */
1344
+ export function trackUseOfUnsupportedFunctionality(
1345
+ name: string,
1346
+ orderId: string | undefined,
1347
+ publicKey: string,
1348
+ devMode: boolean,
1349
+ mockMode: boolean,
1350
+ checkoutUrl: string
1351
+ ): void {
1352
+ const properties = {
1353
+ ...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl),
1354
+ name,
1355
+ };
1356
+ trackEvent("Use of Unsupported Functionality", properties, devMode).catch((error) => {
1357
+ if (devMode) {
1358
+ console.error("[Glomo-RN-SDK] Event tracking error on unsupported functionality:", error);
1359
+ }
1360
+ });
1361
+ }
1362
+
1363
+ // ---------------------------------------------------------------------------
1364
+ // Checkout Analytics Tracker Map
1365
+ // ---------------------------------------------------------------------------
1366
+
1367
+ /**
1368
+ * Internal tracker map interface.
1369
+ * Each flow (standard, subscription) provides its own implementation.
1370
+ * useStandardCheckout calls through this map at every analytics call site.
1371
+ * Not exported to merchants via index.ts.
1372
+ */
1373
+ export interface CheckoutAnalyticsTrackers {
1374
+ trackStartAttempt: typeof trackStandardStartAttempt;
1375
+ trackStartSuccess: typeof trackStandardStartSuccess;
1376
+ trackStartFailure: typeof trackStandardStartFailure;
1377
+ trackWindowOpen: typeof trackStandardWindowOpen;
1378
+ trackWindowClose: typeof trackStandardWindowClose;
1379
+ trackInvalidMessageReceived: typeof trackStandardInvalidMessageReceived;
1380
+ trackPaymentSuccess: typeof trackStandardPaymentSuccess;
1381
+ trackPaymentFailure: typeof trackStandardPaymentFailure;
1382
+ trackPaymentTerminate: typeof trackStandardPaymentTerminate;
1383
+ trackConnectionError: typeof trackStandardConnectionError;
1384
+ trackSdkError: typeof trackStandardSdkError;
1385
+ trackBankTransferSubmitted: typeof trackStandardBankTransferSubmitted;
1386
+ trackPayViaBankCompleted: typeof trackStandardPayViaBankCompleted;
1387
+ }
1388
+
1389
+ /** Standard checkout tracker map - delegates to trackStandard* functions */
1390
+ export const standardCheckoutTrackers: CheckoutAnalyticsTrackers = {
1391
+ trackStartAttempt: trackStandardStartAttempt,
1392
+ trackStartSuccess: trackStandardStartSuccess,
1393
+ trackStartFailure: trackStandardStartFailure,
1394
+ trackWindowOpen: trackStandardWindowOpen,
1395
+ trackWindowClose: trackStandardWindowClose,
1396
+ trackInvalidMessageReceived: trackStandardInvalidMessageReceived,
1397
+ trackPaymentSuccess: trackStandardPaymentSuccess,
1398
+ trackPaymentFailure: trackStandardPaymentFailure,
1399
+ trackPaymentTerminate: trackStandardPaymentTerminate,
1400
+ trackConnectionError: trackStandardConnectionError,
1401
+ trackSdkError: trackStandardSdkError,
1402
+ trackBankTransferSubmitted: trackStandardBankTransferSubmitted,
1403
+ trackPayViaBankCompleted: trackStandardPayViaBankCompleted,
1404
+ };
1405
+
1406
+ /** Subscription checkout tracker map - delegates to trackSubscription* functions, no-ops for bank transfer */
1407
+ export const subscriptionCheckoutTrackers: CheckoutAnalyticsTrackers = {
1408
+ trackStartAttempt: trackSubscriptionStartAttempt,
1409
+ trackStartSuccess: trackSubscriptionStartSuccess,
1410
+ trackStartFailure: trackSubscriptionStartFailure,
1411
+ trackWindowOpen: trackSubscriptionWindowOpen,
1412
+ trackWindowClose: trackSubscriptionWindowClose,
1413
+ trackInvalidMessageReceived: trackSubscriptionInvalidMessageReceived,
1414
+ trackPaymentSuccess: trackSubscriptionPaymentSuccess,
1415
+ trackPaymentFailure: trackSubscriptionPaymentFailure,
1416
+ trackPaymentTerminate: trackSubscriptionPaymentTerminate,
1417
+ trackConnectionError: trackSubscriptionConnectionError,
1418
+ trackSdkError: trackSubscriptionSdkError,
1419
+ trackBankTransferSubmitted: (...args) => {
1420
+ const devMode = args[2];
1421
+ if (devMode) {
1422
+ console.warn("[Glomo-RN-SDK] Unexpected bank transfer event in subscription flow");
1423
+ }
1424
+ },
1425
+ trackPayViaBankCompleted: (...args) => {
1426
+ const devMode = args[3];
1427
+ if (devMode) {
1428
+ console.warn("[Glomo-RN-SDK] Unexpected pay via bank completed event in subscription flow");
1429
+ }
1430
+ },
1431
+ };
@@ -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;