@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.
- package/CHANGELOG.md +38 -2
- package/MIGRATION.md +129 -0
- package/README.md +176 -126
- package/lib/glomo-checkout.d.ts +2 -1
- package/lib/glomo-checkout.d.ts.map +1 -1
- package/lib/glomo-checkout.js +25 -3
- package/lib/glomo-lrs-checkout.d.ts +1 -1
- package/lib/glomo-lrs-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.d.ts +20 -0
- package/lib/glomo-standard-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.js +15 -6
- package/lib/glomo-subscriptions-checkout.d.ts +8 -0
- package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
- package/lib/glomo-subscriptions-checkout.js +85 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -3
- package/lib/types/checkout.d.ts +33 -22
- package/lib/types/checkout.d.ts.map +1 -1
- package/lib/types/checkout.js +12 -1
- package/lib/types/standard-checkout.d.ts +3 -7
- package/lib/types/standard-checkout.d.ts.map +1 -1
- package/lib/types/subscriptions-checkout.d.ts +29 -0
- package/lib/types/subscriptions-checkout.d.ts.map +1 -0
- package/lib/types/subscriptions-checkout.js +3 -0
- package/lib/use-glomo-checkout.d.ts +34 -4
- package/lib/use-glomo-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.js +92 -13
- package/lib/use-lrs-checkout.d.ts +1 -1
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.d.ts +14 -9
- package/lib/use-standard-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.js +74 -85
- package/lib/utils/analytics.d.ts +86 -3
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +344 -22
- package/lib/utils/device-compliance.d.ts.map +1 -1
- package/lib/utils/device-compliance.js +0 -1
- package/package.json +15 -4
- package/src/glomo-checkout.tsx +65 -9
- package/src/glomo-lrs-checkout.tsx +1 -1
- package/src/glomo-standard-checkout.tsx +35 -10
- package/src/glomo-subscriptions-checkout.tsx +83 -0
- package/src/index.ts +5 -5
- package/src/types/checkout.ts +28 -20
- package/src/types/standard-checkout.ts +3 -5
- package/src/types/subscriptions-checkout.ts +31 -0
- package/src/use-glomo-checkout.tsx +158 -17
- package/src/use-lrs-checkout.tsx +1 -1
- package/src/use-standard-checkout.tsx +94 -153
- package/src/utils/analytics.ts +469 -31
- package/src/utils/device-compliance.ts +0 -1
package/lib/utils/analytics.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* Analytics failures never break the SDK.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.subscriptionCheckoutTrackers = exports.standardCheckoutTrackers = void 0;
|
|
14
15
|
exports.trackStartSuccess = trackStartSuccess;
|
|
15
16
|
exports.trackStartAttempt = trackStartAttempt;
|
|
16
17
|
exports.trackStartFailure = trackStartFailure;
|
|
@@ -37,11 +38,22 @@ exports.trackStandardConnectionError = trackStandardConnectionError;
|
|
|
37
38
|
exports.trackStandardSdkError = trackStandardSdkError;
|
|
38
39
|
exports.trackStandardBankTransferSubmitted = trackStandardBankTransferSubmitted;
|
|
39
40
|
exports.trackStandardPayViaBankCompleted = trackStandardPayViaBankCompleted;
|
|
40
|
-
exports.trackStandardPayViaBankBankConnectionSuccessful = trackStandardPayViaBankBankConnectionSuccessful;
|
|
41
41
|
exports.trackOrderTypeDetectionStarted = trackOrderTypeDetectionStarted;
|
|
42
42
|
exports.trackOrderTypeDetectionResolved = trackOrderTypeDetectionResolved;
|
|
43
43
|
exports.trackOrderTypeDetectionFailed = trackOrderTypeDetectionFailed;
|
|
44
44
|
exports.checkAnalyticsStatus = checkAnalyticsStatus;
|
|
45
|
+
exports.trackSubscriptionStartAttempt = trackSubscriptionStartAttempt;
|
|
46
|
+
exports.trackSubscriptionStartSuccess = trackSubscriptionStartSuccess;
|
|
47
|
+
exports.trackSubscriptionStartFailure = trackSubscriptionStartFailure;
|
|
48
|
+
exports.trackSubscriptionWindowOpen = trackSubscriptionWindowOpen;
|
|
49
|
+
exports.trackSubscriptionWindowClose = trackSubscriptionWindowClose;
|
|
50
|
+
exports.trackSubscriptionInvalidMessageReceived = trackSubscriptionInvalidMessageReceived;
|
|
51
|
+
exports.trackSubscriptionPaymentSuccess = trackSubscriptionPaymentSuccess;
|
|
52
|
+
exports.trackSubscriptionPaymentFailure = trackSubscriptionPaymentFailure;
|
|
53
|
+
exports.trackSubscriptionPaymentTerminate = trackSubscriptionPaymentTerminate;
|
|
54
|
+
exports.trackSubscriptionConnectionError = trackSubscriptionConnectionError;
|
|
55
|
+
exports.trackSubscriptionSdkError = trackSubscriptionSdkError;
|
|
56
|
+
exports.trackUseOfUnsupportedFunctionality = trackUseOfUnsupportedFunctionality;
|
|
45
57
|
const react_native_1 = require("react-native");
|
|
46
58
|
const segment_1 = require("../config/segment");
|
|
47
59
|
/**
|
|
@@ -53,7 +65,6 @@ const segment_1 = require("../config/segment");
|
|
|
53
65
|
function getSdkVersion() {
|
|
54
66
|
try {
|
|
55
67
|
// Using require to dynamically import package.json
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
57
68
|
const packageJson = require("../../package.json");
|
|
58
69
|
return packageJson.version || "unknown";
|
|
59
70
|
}
|
|
@@ -490,7 +501,11 @@ function trackStandardStartSuccess(orderId, publicKey, devMode = false, mockMode
|
|
|
490
501
|
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
491
502
|
}),
|
|
492
503
|
};
|
|
493
|
-
trackEvent("Standard Checkout Started", properties, devMode).catch(() => {
|
|
504
|
+
trackEvent("Standard Checkout Started", properties, devMode).catch((error) => {
|
|
505
|
+
if (devMode) {
|
|
506
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard start:", error);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
494
509
|
}
|
|
495
510
|
/**
|
|
496
511
|
* Tracks when the standard checkout start() method is called (attempted)
|
|
@@ -504,7 +519,11 @@ function trackStandardStartAttempt(status, orderId, publicKey, devMode = false,
|
|
|
504
519
|
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
505
520
|
}),
|
|
506
521
|
};
|
|
507
|
-
trackEvent("Standard Checkout Start Attempted", properties, devMode).catch(() => {
|
|
522
|
+
trackEvent("Standard Checkout Start Attempted", properties, devMode).catch((error) => {
|
|
523
|
+
if (devMode) {
|
|
524
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard start attempt:", error);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
508
527
|
}
|
|
509
528
|
/**
|
|
510
529
|
* Tracks when the standard checkout start() method fails
|
|
@@ -518,7 +537,11 @@ function trackStandardStartFailure(reason, orderId, publicKey, devMode = false,
|
|
|
518
537
|
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
519
538
|
}),
|
|
520
539
|
};
|
|
521
|
-
trackEvent("Standard Checkout Start Failed", properties, devMode).catch(() => {
|
|
540
|
+
trackEvent("Standard Checkout Start Failed", properties, devMode).catch((error) => {
|
|
541
|
+
if (devMode) {
|
|
542
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard start failure:", error);
|
|
543
|
+
}
|
|
544
|
+
});
|
|
522
545
|
}
|
|
523
546
|
/**
|
|
524
547
|
* Tracks when window.open is intercepted from the standard checkout WebView
|
|
@@ -529,7 +552,11 @@ function trackStandardWindowOpen(source, url, orderId, publicKey, devMode = fals
|
|
|
529
552
|
source,
|
|
530
553
|
url,
|
|
531
554
|
};
|
|
532
|
-
trackEvent("Standard Checkout Window Open", properties, devMode).catch(() => {
|
|
555
|
+
trackEvent("Standard Checkout Window Open", properties, devMode).catch((error) => {
|
|
556
|
+
if (devMode) {
|
|
557
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard window open:", error);
|
|
558
|
+
}
|
|
559
|
+
});
|
|
533
560
|
}
|
|
534
561
|
/**
|
|
535
562
|
* Tracks when window.close is intercepted from the standard checkout WebView
|
|
@@ -539,7 +566,11 @@ function trackStandardWindowClose(source, orderId, publicKey, devMode = false, m
|
|
|
539
566
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
540
567
|
source,
|
|
541
568
|
};
|
|
542
|
-
trackEvent("Standard Checkout Window Close", properties, devMode).catch(() => {
|
|
569
|
+
trackEvent("Standard Checkout Window Close", properties, devMode).catch((error) => {
|
|
570
|
+
if (devMode) {
|
|
571
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard window close:", error);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
543
574
|
}
|
|
544
575
|
/**
|
|
545
576
|
* Tracks when invalid message data is received from a standard checkout WebView
|
|
@@ -573,7 +604,11 @@ function trackStandardInvalidMessageReceived(webviewType, data, url, orderId, pu
|
|
|
573
604
|
dataType: data === null ? "null" : typeof data,
|
|
574
605
|
...(url && { url }),
|
|
575
606
|
};
|
|
576
|
-
trackEvent("Standard Checkout Invalid Message Received", properties, devMode).catch(() => {
|
|
607
|
+
trackEvent("Standard Checkout Invalid Message Received", properties, devMode).catch((error) => {
|
|
608
|
+
if (devMode) {
|
|
609
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard invalid message:", error);
|
|
610
|
+
}
|
|
611
|
+
});
|
|
577
612
|
}
|
|
578
613
|
/**
|
|
579
614
|
* Tracks when standard checkout onPaymentSuccess callback is invoked
|
|
@@ -583,7 +618,11 @@ function trackStandardPaymentSuccess(orderId, paymentId, publicKey, devMode = fa
|
|
|
583
618
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
584
619
|
paymentId,
|
|
585
620
|
};
|
|
586
|
-
trackEvent("Standard Payment Success", properties, devMode).catch(() => {
|
|
621
|
+
trackEvent("Standard Payment Success", properties, devMode).catch((error) => {
|
|
622
|
+
if (devMode) {
|
|
623
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard payment success:", error);
|
|
624
|
+
}
|
|
625
|
+
});
|
|
587
626
|
}
|
|
588
627
|
/**
|
|
589
628
|
* Tracks when standard checkout onPaymentFailure callback is invoked
|
|
@@ -593,7 +632,11 @@ function trackStandardPaymentFailure(orderId, paymentId, publicKey, devMode = fa
|
|
|
593
632
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
594
633
|
paymentId,
|
|
595
634
|
};
|
|
596
|
-
trackEvent("Standard Payment Failure", properties, devMode).catch(() => {
|
|
635
|
+
trackEvent("Standard Payment Failure", properties, devMode).catch((error) => {
|
|
636
|
+
if (devMode) {
|
|
637
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard payment failure:", error);
|
|
638
|
+
}
|
|
639
|
+
});
|
|
597
640
|
}
|
|
598
641
|
/**
|
|
599
642
|
* Tracks when standard checkout onPaymentTerminate callback is invoked
|
|
@@ -603,7 +646,11 @@ function trackStandardPaymentTerminate(orderId, source, publicKey, devMode = fal
|
|
|
603
646
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
604
647
|
terminationSource: source,
|
|
605
648
|
};
|
|
606
|
-
trackEvent("Standard Payment Terminated", properties, devMode).catch(() => {
|
|
649
|
+
trackEvent("Standard Payment Terminated", properties, devMode).catch((error) => {
|
|
650
|
+
if (devMode) {
|
|
651
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard payment terminate:", error);
|
|
652
|
+
}
|
|
653
|
+
});
|
|
607
654
|
}
|
|
608
655
|
/**
|
|
609
656
|
* Tracks when standard checkout onConnectionError callback is invoked
|
|
@@ -613,7 +660,11 @@ function trackStandardConnectionError(orderId, errorCode, publicKey, devMode = f
|
|
|
613
660
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
614
661
|
...(errorCode !== undefined && { errorCode }),
|
|
615
662
|
};
|
|
616
|
-
trackEvent("Standard Connection Error", properties, devMode).catch(() => {
|
|
663
|
+
trackEvent("Standard Connection Error", properties, devMode).catch((error) => {
|
|
664
|
+
if (devMode) {
|
|
665
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard connection error:", error);
|
|
666
|
+
}
|
|
667
|
+
});
|
|
617
668
|
}
|
|
618
669
|
/**
|
|
619
670
|
* Tracks when standard checkout onSdkError callback is invoked
|
|
@@ -624,27 +675,32 @@ function trackStandardSdkError(errors, orderId, publicKey, devMode = false, mock
|
|
|
624
675
|
errors,
|
|
625
676
|
errorCount: errors.length,
|
|
626
677
|
};
|
|
627
|
-
trackEvent("Standard SDK Error", properties, devMode).catch(() => {
|
|
678
|
+
trackEvent("Standard SDK Error", properties, devMode).catch((error) => {
|
|
679
|
+
if (devMode) {
|
|
680
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard SDK error:", error);
|
|
681
|
+
}
|
|
682
|
+
});
|
|
628
683
|
}
|
|
629
684
|
function trackStandardBankTransferSubmitted(orderId, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
630
685
|
const properties = {
|
|
631
686
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
632
687
|
};
|
|
633
|
-
trackEvent("Standard Bank Transfer Submitted", properties, devMode).catch(() => {
|
|
688
|
+
trackEvent("Standard Bank Transfer Submitted", properties, devMode).catch((error) => {
|
|
689
|
+
if (devMode) {
|
|
690
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard bank transfer submitted:", error);
|
|
691
|
+
}
|
|
692
|
+
});
|
|
634
693
|
}
|
|
635
694
|
function trackStandardPayViaBankCompleted(orderId, publicKey, status, devMode = false, mockMode = false, standardUrl) {
|
|
636
695
|
const properties = {
|
|
637
696
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
638
697
|
payViaBankStatus: status,
|
|
639
698
|
};
|
|
640
|
-
trackEvent("Standard Pay Via Bank Completed", properties, devMode).catch(() => {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
bankIdentifier,
|
|
646
|
-
};
|
|
647
|
-
trackEvent("Standard Pay Via Bank Bank Connection Successful", properties, devMode).catch(() => { });
|
|
699
|
+
trackEvent("Standard Pay Via Bank Completed", properties, devMode).catch((error) => {
|
|
700
|
+
if (devMode) {
|
|
701
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard pay via bank completed:", error);
|
|
702
|
+
}
|
|
703
|
+
});
|
|
648
704
|
}
|
|
649
705
|
// ---------------------------------------------------------------------------
|
|
650
706
|
// Order Type Detection Trackers (Unified Flow)
|
|
@@ -723,3 +779,269 @@ function checkAnalyticsStatus(devMode = false) {
|
|
|
723
779
|
}
|
|
724
780
|
return available;
|
|
725
781
|
}
|
|
782
|
+
// ---------------------------------------------------------------------------
|
|
783
|
+
// Subscription Checkout Trackers
|
|
784
|
+
// ---------------------------------------------------------------------------
|
|
785
|
+
/**
|
|
786
|
+
* Tracks when the subscription checkout start() method is called (attempted)
|
|
787
|
+
*/
|
|
788
|
+
function trackSubscriptionStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
|
|
789
|
+
const properties = {
|
|
790
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
791
|
+
subscriptionId: orderId,
|
|
792
|
+
status,
|
|
793
|
+
...(jailbreakDetectionInfo && {
|
|
794
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
795
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
796
|
+
}),
|
|
797
|
+
};
|
|
798
|
+
trackEvent("Subscription Checkout Start Attempted", properties, devMode).catch((error) => {
|
|
799
|
+
if (devMode) {
|
|
800
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription start attempt:", error);
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Tracks when the subscription checkout start() method has been called successfully
|
|
806
|
+
*/
|
|
807
|
+
function trackSubscriptionStartSuccess(orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
|
|
808
|
+
const properties = {
|
|
809
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
810
|
+
subscriptionId: orderId,
|
|
811
|
+
...(jailbreakDetectionInfo && {
|
|
812
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
813
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
814
|
+
}),
|
|
815
|
+
};
|
|
816
|
+
trackEvent("Subscription Checkout Started", properties, devMode).catch((error) => {
|
|
817
|
+
if (devMode) {
|
|
818
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription start:", error);
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Tracks when the subscription checkout start() method fails
|
|
824
|
+
*/
|
|
825
|
+
function trackSubscriptionStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
|
|
826
|
+
const properties = {
|
|
827
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
828
|
+
subscriptionId: orderId,
|
|
829
|
+
failureReason: reason,
|
|
830
|
+
...(jailbreakDetectionInfo && {
|
|
831
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
832
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
833
|
+
}),
|
|
834
|
+
};
|
|
835
|
+
trackEvent("Subscription Checkout Start Failed", properties, devMode).catch((error) => {
|
|
836
|
+
if (devMode) {
|
|
837
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription start failure:", error);
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Tracks when window.open is intercepted from the subscription checkout WebView
|
|
843
|
+
*/
|
|
844
|
+
function trackSubscriptionWindowOpen(source, url, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
845
|
+
const properties = {
|
|
846
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
847
|
+
subscriptionId: orderId,
|
|
848
|
+
source,
|
|
849
|
+
url,
|
|
850
|
+
};
|
|
851
|
+
trackEvent("Subscription Checkout Window Open", properties, devMode).catch((error) => {
|
|
852
|
+
if (devMode) {
|
|
853
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription window open:", error);
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Tracks when window.close is intercepted from the subscription checkout WebView
|
|
859
|
+
*/
|
|
860
|
+
function trackSubscriptionWindowClose(source, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
861
|
+
const properties = {
|
|
862
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
863
|
+
subscriptionId: orderId,
|
|
864
|
+
source,
|
|
865
|
+
};
|
|
866
|
+
trackEvent("Subscription Checkout Window Close", properties, devMode).catch((error) => {
|
|
867
|
+
if (devMode) {
|
|
868
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription window close:", error);
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Tracks when invalid message data is received from a subscription checkout WebView
|
|
874
|
+
*/
|
|
875
|
+
function trackSubscriptionInvalidMessageReceived(webviewType, data, url, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
876
|
+
let dataString;
|
|
877
|
+
try {
|
|
878
|
+
if (data === null) {
|
|
879
|
+
dataString = "null";
|
|
880
|
+
}
|
|
881
|
+
else if (data === undefined) {
|
|
882
|
+
dataString = "undefined";
|
|
883
|
+
}
|
|
884
|
+
else if (typeof data === "string") {
|
|
885
|
+
dataString = data;
|
|
886
|
+
}
|
|
887
|
+
else if (typeof data === "object") {
|
|
888
|
+
dataString = JSON.stringify(data);
|
|
889
|
+
}
|
|
890
|
+
else {
|
|
891
|
+
dataString = String(data);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
catch (_a) {
|
|
895
|
+
dataString = "[unable to stringify]";
|
|
896
|
+
}
|
|
897
|
+
const properties = {
|
|
898
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
899
|
+
subscriptionId: orderId,
|
|
900
|
+
webviewType,
|
|
901
|
+
data: dataString,
|
|
902
|
+
dataType: data === null ? "null" : typeof data,
|
|
903
|
+
...(url && { url }),
|
|
904
|
+
};
|
|
905
|
+
trackEvent("Subscription Checkout Invalid Message Received", properties, devMode).catch((error) => {
|
|
906
|
+
if (devMode) {
|
|
907
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription invalid message:", error);
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Tracks when subscription checkout onPaymentSuccess callback is invoked
|
|
913
|
+
*/
|
|
914
|
+
function trackSubscriptionPaymentSuccess(orderId, paymentId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
915
|
+
const properties = {
|
|
916
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
917
|
+
subscriptionId: orderId,
|
|
918
|
+
paymentId,
|
|
919
|
+
};
|
|
920
|
+
trackEvent("Subscription Payment Success", properties, devMode).catch((error) => {
|
|
921
|
+
if (devMode) {
|
|
922
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription payment success:", error);
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Tracks when subscription checkout onPaymentFailure callback is invoked
|
|
928
|
+
*/
|
|
929
|
+
function trackSubscriptionPaymentFailure(orderId, paymentId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
930
|
+
const properties = {
|
|
931
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
932
|
+
subscriptionId: orderId,
|
|
933
|
+
paymentId,
|
|
934
|
+
};
|
|
935
|
+
trackEvent("Subscription Payment Failure", properties, devMode).catch((error) => {
|
|
936
|
+
if (devMode) {
|
|
937
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription payment failure:", error);
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Tracks when subscription checkout onPaymentTerminate callback is invoked
|
|
943
|
+
*/
|
|
944
|
+
function trackSubscriptionPaymentTerminate(orderId, source, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
945
|
+
const properties = {
|
|
946
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
947
|
+
subscriptionId: orderId,
|
|
948
|
+
terminationSource: source,
|
|
949
|
+
};
|
|
950
|
+
trackEvent("Subscription Payment Terminated", properties, devMode).catch((error) => {
|
|
951
|
+
if (devMode) {
|
|
952
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription payment terminate:", error);
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Tracks when subscription checkout onConnectionError callback is invoked
|
|
958
|
+
*/
|
|
959
|
+
function trackSubscriptionConnectionError(orderId, errorCode, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
960
|
+
const properties = {
|
|
961
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
962
|
+
subscriptionId: orderId,
|
|
963
|
+
...(errorCode !== undefined && { errorCode }),
|
|
964
|
+
};
|
|
965
|
+
trackEvent("Subscription Connection Error", properties, devMode).catch((error) => {
|
|
966
|
+
if (devMode) {
|
|
967
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription connection error:", error);
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Tracks when subscription checkout onSdkError callback is invoked
|
|
973
|
+
*/
|
|
974
|
+
function trackSubscriptionSdkError(errors, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
975
|
+
const properties = {
|
|
976
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
977
|
+
subscriptionId: orderId,
|
|
978
|
+
errors,
|
|
979
|
+
errorCount: errors.length,
|
|
980
|
+
};
|
|
981
|
+
trackEvent("Subscription SDK Error", properties, devMode).catch((error) => {
|
|
982
|
+
if (devMode) {
|
|
983
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription SDK error:", error);
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
// ---------------------------------------------------------------------------
|
|
988
|
+
// Unsupported Functionality Telemetry
|
|
989
|
+
// ---------------------------------------------------------------------------
|
|
990
|
+
/**
|
|
991
|
+
* Internal telemetry - fires when a merchant uses functionality that is
|
|
992
|
+
* unsupported in the current context or deprecated.
|
|
993
|
+
* Fires at most once per detection site (callers use a ref guard).
|
|
994
|
+
*/
|
|
995
|
+
function trackUseOfUnsupportedFunctionality(name, orderId, publicKey, devMode, mockMode, checkoutUrl) {
|
|
996
|
+
const properties = {
|
|
997
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl),
|
|
998
|
+
name,
|
|
999
|
+
};
|
|
1000
|
+
trackEvent("Use of Unsupported Functionality", properties, devMode).catch((error) => {
|
|
1001
|
+
if (devMode) {
|
|
1002
|
+
console.error("[Glomo-RN-SDK] Event tracking error on unsupported functionality:", error);
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
/** Standard checkout tracker map - delegates to trackStandard* functions */
|
|
1007
|
+
exports.standardCheckoutTrackers = {
|
|
1008
|
+
trackStartAttempt: trackStandardStartAttempt,
|
|
1009
|
+
trackStartSuccess: trackStandardStartSuccess,
|
|
1010
|
+
trackStartFailure: trackStandardStartFailure,
|
|
1011
|
+
trackWindowOpen: trackStandardWindowOpen,
|
|
1012
|
+
trackWindowClose: trackStandardWindowClose,
|
|
1013
|
+
trackInvalidMessageReceived: trackStandardInvalidMessageReceived,
|
|
1014
|
+
trackPaymentSuccess: trackStandardPaymentSuccess,
|
|
1015
|
+
trackPaymentFailure: trackStandardPaymentFailure,
|
|
1016
|
+
trackPaymentTerminate: trackStandardPaymentTerminate,
|
|
1017
|
+
trackConnectionError: trackStandardConnectionError,
|
|
1018
|
+
trackSdkError: trackStandardSdkError,
|
|
1019
|
+
trackBankTransferSubmitted: trackStandardBankTransferSubmitted,
|
|
1020
|
+
trackPayViaBankCompleted: trackStandardPayViaBankCompleted,
|
|
1021
|
+
};
|
|
1022
|
+
/** Subscription checkout tracker map - delegates to trackSubscription* functions, no-ops for bank transfer */
|
|
1023
|
+
exports.subscriptionCheckoutTrackers = {
|
|
1024
|
+
trackStartAttempt: trackSubscriptionStartAttempt,
|
|
1025
|
+
trackStartSuccess: trackSubscriptionStartSuccess,
|
|
1026
|
+
trackStartFailure: trackSubscriptionStartFailure,
|
|
1027
|
+
trackWindowOpen: trackSubscriptionWindowOpen,
|
|
1028
|
+
trackWindowClose: trackSubscriptionWindowClose,
|
|
1029
|
+
trackInvalidMessageReceived: trackSubscriptionInvalidMessageReceived,
|
|
1030
|
+
trackPaymentSuccess: trackSubscriptionPaymentSuccess,
|
|
1031
|
+
trackPaymentFailure: trackSubscriptionPaymentFailure,
|
|
1032
|
+
trackPaymentTerminate: trackSubscriptionPaymentTerminate,
|
|
1033
|
+
trackConnectionError: trackSubscriptionConnectionError,
|
|
1034
|
+
trackSdkError: trackSubscriptionSdkError,
|
|
1035
|
+
trackBankTransferSubmitted: (...args) => {
|
|
1036
|
+
const devMode = args[2];
|
|
1037
|
+
if (devMode) {
|
|
1038
|
+
console.warn("[Glomo-RN-SDK] Unexpected bank transfer event in subscription flow");
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
trackPayViaBankCompleted: (...args) => {
|
|
1042
|
+
const devMode = args[3];
|
|
1043
|
+
if (devMode) {
|
|
1044
|
+
console.warn("[Glomo-RN-SDK] Unexpected pay via bank completed event in subscription flow");
|
|
1045
|
+
}
|
|
1046
|
+
},
|
|
1047
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-compliance.d.ts","sourceRoot":"","sources":["../../src/utils/device-compliance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"device-compliance.d.ts","sourceRoot":"","sources":["../../src/utils/device-compliance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,OAAe,GAAG,OAAO,GAAG,IAAI,CA+B9E;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD"}
|
|
@@ -16,7 +16,6 @@ exports.isComplianceCheckAvailable = isComplianceCheckAvailable;
|
|
|
16
16
|
*/
|
|
17
17
|
function getJailMonkey() {
|
|
18
18
|
try {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
20
19
|
const JailMonkey = require("jail-monkey");
|
|
21
20
|
if (JailMonkey && typeof JailMonkey.isJailBroken === "function") {
|
|
22
21
|
return JailMonkey;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glomopay/react-native-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "The React Native SDK for GlomoPay",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"test": "jest",
|
|
22
22
|
"prettier:check": "prettier --check \"**/*.{js,ts,jsx,tsx,json}\"",
|
|
23
23
|
"prettier:format": "prettier --write \"**/*.{js,ts,jsx,tsx,json}\"",
|
|
24
|
+
"lint": "eslint src/",
|
|
24
25
|
"clean": "rm -rf lib",
|
|
25
26
|
"prepublishOnly": "npm run clean && tsc --noEmit && npm run build"
|
|
26
27
|
},
|
|
@@ -51,26 +52,36 @@
|
|
|
51
52
|
"dependencies": {
|
|
52
53
|
"axios": "1.13.2"
|
|
53
54
|
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"jail-monkey": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
54
60
|
"peerDependencies": {
|
|
61
|
+
"jail-monkey": "^2.6.0",
|
|
55
62
|
"react": ">=17.0.0",
|
|
56
63
|
"react-native": ">=0.68.0",
|
|
57
|
-
"react-native-webview": "^13.0.0"
|
|
58
|
-
"jail-monkey": "^2.6.0"
|
|
64
|
+
"react-native-webview": "^13.0.0"
|
|
59
65
|
},
|
|
60
66
|
"devDependencies": {
|
|
61
67
|
"@types/react": "^18.0.0",
|
|
62
68
|
"@types/react-native": "^0.73.0",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^8.60.1",
|
|
70
|
+
"eslint": "^9.39.4",
|
|
71
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
63
72
|
"jest": "^29.6.3",
|
|
64
73
|
"prettier": "^3.0.0",
|
|
65
74
|
"react": "18.2.0",
|
|
66
75
|
"react-native": "0.73.5",
|
|
67
|
-
"typescript": "^5.0.0"
|
|
76
|
+
"typescript": "^5.0.0",
|
|
77
|
+
"typescript-eslint": "^8.60.1"
|
|
68
78
|
},
|
|
69
79
|
"files": [
|
|
70
80
|
"lib",
|
|
71
81
|
"src",
|
|
72
82
|
"README.md",
|
|
73
83
|
"CHANGELOG.md",
|
|
84
|
+
"MIGRATION.md",
|
|
74
85
|
"LICENSE"
|
|
75
86
|
],
|
|
76
87
|
"engines": {
|
package/src/glomo-checkout.tsx
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The unified GlomoPay Checkout Component (
|
|
2
|
+
* The unified GlomoPay Checkout Component (v4).
|
|
3
3
|
* Detects order type (LRS vs Standard) and delegates rendering to the appropriate inner component.
|
|
4
|
+
* Enforces error handling via `onSdkError()` as a mandatory prop.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
import React, { useImperativeHandle, forwardRef } from "react";
|
|
7
|
+
import React, { useImperativeHandle, useRef, useEffect, useMemo, forwardRef } from "react";
|
|
7
8
|
|
|
8
|
-
import { useGlomoCheckout } from "./use-glomo-checkout";
|
|
9
|
+
import { useGlomoCheckout, type UseGlomoCheckoutInternalReturn } from "./use-glomo-checkout";
|
|
9
10
|
import { type GlomoCheckoutRef, type GlomoCheckoutProps } from "./types/checkout";
|
|
11
|
+
import { trackUseOfUnsupportedFunctionality } from "./utils/analytics";
|
|
10
12
|
import { GlomoLrsCheckout } from "./glomo-lrs-checkout";
|
|
11
13
|
import { GlomoStandardCheckout } from "./glomo-standard-checkout";
|
|
14
|
+
import { GlomoSubscriptionsCheckout } from "./glomo-subscriptions-checkout";
|
|
12
15
|
|
|
13
16
|
function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedRef<GlomoCheckoutRef>) {
|
|
14
17
|
// useGlomoCheckout handles order type detection and exposes start/getStatus for the ref
|
|
15
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
orderType,
|
|
20
|
+
start,
|
|
21
|
+
getStatus,
|
|
22
|
+
innerLrsRef,
|
|
23
|
+
innerStandardRef,
|
|
24
|
+
innerSubscriptionsRef,
|
|
25
|
+
props: passedProps,
|
|
26
|
+
}: UseGlomoCheckoutInternalReturn = useGlomoCheckout(props, { _suppressDeprecationWarning: true });
|
|
16
27
|
|
|
17
28
|
// Exposing start() and getStatus() via the forwarded ref for the merchant to call
|
|
18
29
|
useImperativeHandle(ref, () => ({
|
|
@@ -20,6 +31,33 @@ function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedR
|
|
|
20
31
|
getStatus,
|
|
21
32
|
}));
|
|
22
33
|
|
|
34
|
+
// Tracking unsupported callback props on subscription flows (fires once per mount)
|
|
35
|
+
const hasTrackedUnsupportedRef = useRef(false);
|
|
36
|
+
const devMode = passedProps.devMode ?? false;
|
|
37
|
+
const mockMode = useMemo(
|
|
38
|
+
() => passedProps.publicKey?.toLowerCase().startsWith("test_") ?? false,
|
|
39
|
+
[passedProps.publicKey]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Extracting stable boolean for the tracking effect to avoid depending on passedProps object
|
|
43
|
+
const hasUserJourneyCallback = !!passedProps.onUserJourneyCompleted;
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (orderType !== "subscriptions" || hasTrackedUnsupportedRef.current) return;
|
|
47
|
+
hasTrackedUnsupportedRef.current = true;
|
|
48
|
+
|
|
49
|
+
if (hasUserJourneyCallback) {
|
|
50
|
+
trackUseOfUnsupportedFunctionality(
|
|
51
|
+
"onUserJourneyCompleted",
|
|
52
|
+
passedProps.subscriptionId,
|
|
53
|
+
passedProps.publicKey,
|
|
54
|
+
devMode,
|
|
55
|
+
mockMode,
|
|
56
|
+
""
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}, [orderType, hasUserJourneyCallback, passedProps.subscriptionId, passedProps.publicKey, devMode, mockMode]);
|
|
60
|
+
|
|
23
61
|
// Delegating to the LRS checkout component once order type is resolved as LRS
|
|
24
62
|
if (orderType === "lrs") {
|
|
25
63
|
return (
|
|
@@ -27,7 +65,7 @@ function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedR
|
|
|
27
65
|
ref={innerLrsRef}
|
|
28
66
|
server={passedProps.server}
|
|
29
67
|
publicKey={passedProps.publicKey}
|
|
30
|
-
orderId={passedProps.orderId}
|
|
68
|
+
orderId={passedProps.orderId!}
|
|
31
69
|
onPaymentSuccess={passedProps.onPaymentSuccess}
|
|
32
70
|
onPaymentFailure={passedProps.onPaymentFailure}
|
|
33
71
|
onConnectionError={passedProps.onConnectionError}
|
|
@@ -45,15 +83,33 @@ function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedR
|
|
|
45
83
|
ref={innerStandardRef}
|
|
46
84
|
server={passedProps.server}
|
|
47
85
|
publicKey={passedProps.publicKey}
|
|
48
|
-
orderId={passedProps.orderId}
|
|
86
|
+
orderId={passedProps.orderId!}
|
|
87
|
+
onPaymentSuccess={passedProps.onPaymentSuccess}
|
|
88
|
+
onPaymentFailure={passedProps.onPaymentFailure}
|
|
89
|
+
onConnectionError={passedProps.onConnectionError}
|
|
90
|
+
onPaymentTerminate={passedProps.onPaymentTerminate}
|
|
91
|
+
onSdkError={passedProps.onSdkError}
|
|
92
|
+
onUserJourneyCompleted={passedProps.onUserJourneyCompleted}
|
|
93
|
+
onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions}
|
|
94
|
+
devMode={passedProps.devMode}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Delegating to the Subscriptions checkout component when subscriptionId is provided (no API call)
|
|
100
|
+
if (orderType === "subscriptions") {
|
|
101
|
+
return (
|
|
102
|
+
<GlomoSubscriptionsCheckout
|
|
103
|
+
ref={innerSubscriptionsRef}
|
|
104
|
+
server={passedProps.server}
|
|
105
|
+
publicKey={passedProps.publicKey}
|
|
106
|
+
subscriptionId={passedProps.subscriptionId!}
|
|
49
107
|
onPaymentSuccess={passedProps.onPaymentSuccess}
|
|
50
108
|
onPaymentFailure={passedProps.onPaymentFailure}
|
|
51
109
|
onConnectionError={passedProps.onConnectionError}
|
|
52
110
|
onPaymentTerminate={passedProps.onPaymentTerminate}
|
|
53
111
|
onSdkError={passedProps.onSdkError}
|
|
54
|
-
|
|
55
|
-
onPayViaBankCompleted={passedProps.onPayViaBankCompleted}
|
|
56
|
-
onPayViaBankBankConnectionSuccessful={passedProps.onPayViaBankBankConnectionSuccessful}
|
|
112
|
+
onUserJourneyCompleted={passedProps.onUserJourneyCompleted}
|
|
57
113
|
onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions}
|
|
58
114
|
devMode={passedProps.devMode}
|
|
59
115
|
/>
|
|
@@ -10,7 +10,7 @@ import { isValidUrl } from "./utils/validation";
|
|
|
10
10
|
|
|
11
11
|
export interface GlomoLrsCheckoutProps extends UseLrsCheckoutOptions {
|
|
12
12
|
visible?: boolean;
|
|
13
|
-
onSdkError
|
|
13
|
+
onSdkError: (error: Array<SdkError>) => void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface GlomoLrsCheckoutRef {
|