@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.
- package/CHANGELOG.md +15 -0
- package/MIGRATION.md +50 -0
- package/README.md +131 -50
- package/lib/glomo-checkout.d.ts.map +1 -1
- package/lib/glomo-checkout.js +38 -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 +14 -3
- 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 +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/types/checkout.d.ts +15 -3
- package/lib/types/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-standard-checkout.d.ts +11 -2
- package/lib/use-standard-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.js +52 -35
- package/lib/utils/analytics.d.ts +87 -2
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +356 -15
- 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 +79 -5
- package/src/glomo-standard-checkout.tsx +33 -4
- package/src/glomo-subscriptions-checkout.tsx +83 -0
- package/src/index.ts +1 -1
- package/src/types/checkout.ts +10 -3
- package/src/types/subscriptions-checkout.ts +31 -0
- package/src/use-glomo-checkout.tsx +158 -17
- package/src/use-standard-checkout.tsx +70 -52
- package/src/utils/analytics.ts +482 -17
- 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;
|
|
@@ -42,6 +43,18 @@ exports.trackOrderTypeDetectionStarted = trackOrderTypeDetectionStarted;
|
|
|
42
43
|
exports.trackOrderTypeDetectionResolved = trackOrderTypeDetectionResolved;
|
|
43
44
|
exports.trackOrderTypeDetectionFailed = trackOrderTypeDetectionFailed;
|
|
44
45
|
exports.checkAnalyticsStatus = checkAnalyticsStatus;
|
|
46
|
+
exports.trackSubscriptionStartAttempt = trackSubscriptionStartAttempt;
|
|
47
|
+
exports.trackSubscriptionStartSuccess = trackSubscriptionStartSuccess;
|
|
48
|
+
exports.trackSubscriptionStartFailure = trackSubscriptionStartFailure;
|
|
49
|
+
exports.trackSubscriptionWindowOpen = trackSubscriptionWindowOpen;
|
|
50
|
+
exports.trackSubscriptionWindowClose = trackSubscriptionWindowClose;
|
|
51
|
+
exports.trackSubscriptionInvalidMessageReceived = trackSubscriptionInvalidMessageReceived;
|
|
52
|
+
exports.trackSubscriptionPaymentSuccess = trackSubscriptionPaymentSuccess;
|
|
53
|
+
exports.trackSubscriptionPaymentFailure = trackSubscriptionPaymentFailure;
|
|
54
|
+
exports.trackSubscriptionPaymentTerminate = trackSubscriptionPaymentTerminate;
|
|
55
|
+
exports.trackSubscriptionConnectionError = trackSubscriptionConnectionError;
|
|
56
|
+
exports.trackSubscriptionSdkError = trackSubscriptionSdkError;
|
|
57
|
+
exports.trackUseOfUnsupportedFunctionality = trackUseOfUnsupportedFunctionality;
|
|
45
58
|
const react_native_1 = require("react-native");
|
|
46
59
|
const segment_1 = require("../config/segment");
|
|
47
60
|
/**
|
|
@@ -53,7 +66,6 @@ const segment_1 = require("../config/segment");
|
|
|
53
66
|
function getSdkVersion() {
|
|
54
67
|
try {
|
|
55
68
|
// Using require to dynamically import package.json
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
57
69
|
const packageJson = require("../../package.json");
|
|
58
70
|
return packageJson.version || "unknown";
|
|
59
71
|
}
|
|
@@ -490,7 +502,11 @@ function trackStandardStartSuccess(orderId, publicKey, devMode = false, mockMode
|
|
|
490
502
|
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
491
503
|
}),
|
|
492
504
|
};
|
|
493
|
-
trackEvent("Standard Checkout Started", properties, devMode).catch(() => {
|
|
505
|
+
trackEvent("Standard Checkout Started", properties, devMode).catch((error) => {
|
|
506
|
+
if (devMode) {
|
|
507
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard start:", error);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
494
510
|
}
|
|
495
511
|
/**
|
|
496
512
|
* Tracks when the standard checkout start() method is called (attempted)
|
|
@@ -504,7 +520,11 @@ function trackStandardStartAttempt(status, orderId, publicKey, devMode = false,
|
|
|
504
520
|
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
505
521
|
}),
|
|
506
522
|
};
|
|
507
|
-
trackEvent("Standard Checkout Start Attempted", properties, devMode).catch(() => {
|
|
523
|
+
trackEvent("Standard Checkout Start Attempted", properties, devMode).catch((error) => {
|
|
524
|
+
if (devMode) {
|
|
525
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard start attempt:", error);
|
|
526
|
+
}
|
|
527
|
+
});
|
|
508
528
|
}
|
|
509
529
|
/**
|
|
510
530
|
* Tracks when the standard checkout start() method fails
|
|
@@ -518,7 +538,11 @@ function trackStandardStartFailure(reason, orderId, publicKey, devMode = false,
|
|
|
518
538
|
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
519
539
|
}),
|
|
520
540
|
};
|
|
521
|
-
trackEvent("Standard Checkout Start Failed", properties, devMode).catch(() => {
|
|
541
|
+
trackEvent("Standard Checkout Start Failed", properties, devMode).catch((error) => {
|
|
542
|
+
if (devMode) {
|
|
543
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard start failure:", error);
|
|
544
|
+
}
|
|
545
|
+
});
|
|
522
546
|
}
|
|
523
547
|
/**
|
|
524
548
|
* Tracks when window.open is intercepted from the standard checkout WebView
|
|
@@ -529,7 +553,11 @@ function trackStandardWindowOpen(source, url, orderId, publicKey, devMode = fals
|
|
|
529
553
|
source,
|
|
530
554
|
url,
|
|
531
555
|
};
|
|
532
|
-
trackEvent("Standard Checkout Window Open", properties, devMode).catch(() => {
|
|
556
|
+
trackEvent("Standard Checkout Window Open", properties, devMode).catch((error) => {
|
|
557
|
+
if (devMode) {
|
|
558
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard window open:", error);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
533
561
|
}
|
|
534
562
|
/**
|
|
535
563
|
* Tracks when window.close is intercepted from the standard checkout WebView
|
|
@@ -539,7 +567,11 @@ function trackStandardWindowClose(source, orderId, publicKey, devMode = false, m
|
|
|
539
567
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
540
568
|
source,
|
|
541
569
|
};
|
|
542
|
-
trackEvent("Standard Checkout Window Close", properties, devMode).catch(() => {
|
|
570
|
+
trackEvent("Standard Checkout Window Close", properties, devMode).catch((error) => {
|
|
571
|
+
if (devMode) {
|
|
572
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard window close:", error);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
543
575
|
}
|
|
544
576
|
/**
|
|
545
577
|
* Tracks when invalid message data is received from a standard checkout WebView
|
|
@@ -573,7 +605,11 @@ function trackStandardInvalidMessageReceived(webviewType, data, url, orderId, pu
|
|
|
573
605
|
dataType: data === null ? "null" : typeof data,
|
|
574
606
|
...(url && { url }),
|
|
575
607
|
};
|
|
576
|
-
trackEvent("Standard Checkout Invalid Message Received", properties, devMode).catch(() => {
|
|
608
|
+
trackEvent("Standard Checkout Invalid Message Received", properties, devMode).catch((error) => {
|
|
609
|
+
if (devMode) {
|
|
610
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard invalid message:", error);
|
|
611
|
+
}
|
|
612
|
+
});
|
|
577
613
|
}
|
|
578
614
|
/**
|
|
579
615
|
* Tracks when standard checkout onPaymentSuccess callback is invoked
|
|
@@ -583,7 +619,11 @@ function trackStandardPaymentSuccess(orderId, paymentId, publicKey, devMode = fa
|
|
|
583
619
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
584
620
|
paymentId,
|
|
585
621
|
};
|
|
586
|
-
trackEvent("Standard Payment Success", properties, devMode).catch(() => {
|
|
622
|
+
trackEvent("Standard Payment Success", properties, devMode).catch((error) => {
|
|
623
|
+
if (devMode) {
|
|
624
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard payment success:", error);
|
|
625
|
+
}
|
|
626
|
+
});
|
|
587
627
|
}
|
|
588
628
|
/**
|
|
589
629
|
* Tracks when standard checkout onPaymentFailure callback is invoked
|
|
@@ -593,7 +633,11 @@ function trackStandardPaymentFailure(orderId, paymentId, publicKey, devMode = fa
|
|
|
593
633
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
594
634
|
paymentId,
|
|
595
635
|
};
|
|
596
|
-
trackEvent("Standard Payment Failure", properties, devMode).catch(() => {
|
|
636
|
+
trackEvent("Standard Payment Failure", properties, devMode).catch((error) => {
|
|
637
|
+
if (devMode) {
|
|
638
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard payment failure:", error);
|
|
639
|
+
}
|
|
640
|
+
});
|
|
597
641
|
}
|
|
598
642
|
/**
|
|
599
643
|
* Tracks when standard checkout onPaymentTerminate callback is invoked
|
|
@@ -603,7 +647,11 @@ function trackStandardPaymentTerminate(orderId, source, publicKey, devMode = fal
|
|
|
603
647
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
604
648
|
terminationSource: source,
|
|
605
649
|
};
|
|
606
|
-
trackEvent("Standard Payment Terminated", properties, devMode).catch(() => {
|
|
650
|
+
trackEvent("Standard Payment Terminated", properties, devMode).catch((error) => {
|
|
651
|
+
if (devMode) {
|
|
652
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard payment terminate:", error);
|
|
653
|
+
}
|
|
654
|
+
});
|
|
607
655
|
}
|
|
608
656
|
/**
|
|
609
657
|
* Tracks when standard checkout onConnectionError callback is invoked
|
|
@@ -613,7 +661,11 @@ function trackStandardConnectionError(orderId, errorCode, publicKey, devMode = f
|
|
|
613
661
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
614
662
|
...(errorCode !== undefined && { errorCode }),
|
|
615
663
|
};
|
|
616
|
-
trackEvent("Standard Connection Error", properties, devMode).catch(() => {
|
|
664
|
+
trackEvent("Standard Connection Error", properties, devMode).catch((error) => {
|
|
665
|
+
if (devMode) {
|
|
666
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard connection error:", error);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
617
669
|
}
|
|
618
670
|
/**
|
|
619
671
|
* Tracks when standard checkout onSdkError callback is invoked
|
|
@@ -624,27 +676,43 @@ function trackStandardSdkError(errors, orderId, publicKey, devMode = false, mock
|
|
|
624
676
|
errors,
|
|
625
677
|
errorCount: errors.length,
|
|
626
678
|
};
|
|
627
|
-
trackEvent("Standard SDK Error", properties, devMode).catch(() => {
|
|
679
|
+
trackEvent("Standard SDK Error", properties, devMode).catch((error) => {
|
|
680
|
+
if (devMode) {
|
|
681
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard SDK error:", error);
|
|
682
|
+
}
|
|
683
|
+
});
|
|
628
684
|
}
|
|
629
685
|
function trackStandardBankTransferSubmitted(orderId, publicKey, devMode = false, mockMode = false, standardUrl) {
|
|
630
686
|
const properties = {
|
|
631
687
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
632
688
|
};
|
|
633
|
-
trackEvent("Standard Bank Transfer Submitted", properties, devMode).catch(() => {
|
|
689
|
+
trackEvent("Standard Bank Transfer Submitted", properties, devMode).catch((error) => {
|
|
690
|
+
if (devMode) {
|
|
691
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard bank transfer submitted:", error);
|
|
692
|
+
}
|
|
693
|
+
});
|
|
634
694
|
}
|
|
635
695
|
function trackStandardPayViaBankCompleted(orderId, publicKey, status, devMode = false, mockMode = false, standardUrl) {
|
|
636
696
|
const properties = {
|
|
637
697
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
638
698
|
payViaBankStatus: status,
|
|
639
699
|
};
|
|
640
|
-
trackEvent("Standard Pay Via Bank Completed", properties, devMode).catch(() => {
|
|
700
|
+
trackEvent("Standard Pay Via Bank Completed", properties, devMode).catch((error) => {
|
|
701
|
+
if (devMode) {
|
|
702
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard pay via bank completed:", error);
|
|
703
|
+
}
|
|
704
|
+
});
|
|
641
705
|
}
|
|
642
706
|
function trackStandardPayViaBankBankConnectionSuccessful(orderId, publicKey, bankIdentifier, devMode = false, mockMode = false, standardUrl) {
|
|
643
707
|
const properties = {
|
|
644
708
|
...buildCommonProperties(orderId, publicKey, devMode, mockMode, standardUrl, "standard"),
|
|
645
709
|
bankIdentifier,
|
|
646
710
|
};
|
|
647
|
-
trackEvent("Standard Pay Via Bank Bank Connection Successful", properties, devMode).catch(() => {
|
|
711
|
+
trackEvent("Standard Pay Via Bank Bank Connection Successful", properties, devMode).catch((error) => {
|
|
712
|
+
if (devMode) {
|
|
713
|
+
console.error("[Glomo-RN-SDK] Event tracking error on standard pay via bank connection:", error);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
648
716
|
}
|
|
649
717
|
// ---------------------------------------------------------------------------
|
|
650
718
|
// Order Type Detection Trackers (Unified Flow)
|
|
@@ -723,3 +791,276 @@ function checkAnalyticsStatus(devMode = false) {
|
|
|
723
791
|
}
|
|
724
792
|
return available;
|
|
725
793
|
}
|
|
794
|
+
// ---------------------------------------------------------------------------
|
|
795
|
+
// Subscription Checkout Trackers
|
|
796
|
+
// ---------------------------------------------------------------------------
|
|
797
|
+
/**
|
|
798
|
+
* Tracks when the subscription checkout start() method is called (attempted)
|
|
799
|
+
*/
|
|
800
|
+
function trackSubscriptionStartAttempt(status, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
|
|
801
|
+
const properties = {
|
|
802
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
803
|
+
subscriptionId: orderId,
|
|
804
|
+
status,
|
|
805
|
+
...(jailbreakDetectionInfo && {
|
|
806
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
807
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
808
|
+
}),
|
|
809
|
+
};
|
|
810
|
+
trackEvent("Subscription Checkout Start Attempted", properties, devMode).catch((error) => {
|
|
811
|
+
if (devMode) {
|
|
812
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription start attempt:", error);
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Tracks when the subscription checkout start() method has been called successfully
|
|
818
|
+
*/
|
|
819
|
+
function trackSubscriptionStartSuccess(orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
|
|
820
|
+
const properties = {
|
|
821
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
822
|
+
subscriptionId: orderId,
|
|
823
|
+
...(jailbreakDetectionInfo && {
|
|
824
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
825
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
826
|
+
}),
|
|
827
|
+
};
|
|
828
|
+
trackEvent("Subscription Checkout Started", properties, devMode).catch((error) => {
|
|
829
|
+
if (devMode) {
|
|
830
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription start:", error);
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Tracks when the subscription checkout start() method fails
|
|
836
|
+
*/
|
|
837
|
+
function trackSubscriptionStartFailure(reason, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl, jailbreakDetectionInfo) {
|
|
838
|
+
const properties = {
|
|
839
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
840
|
+
subscriptionId: orderId,
|
|
841
|
+
failureReason: reason,
|
|
842
|
+
...(jailbreakDetectionInfo && {
|
|
843
|
+
jailbreakDetectionLibraryInstalled: jailbreakDetectionInfo.jailbreakDetectionLibraryInstalled,
|
|
844
|
+
jailbreakDetected: jailbreakDetectionInfo.jailbreakDetected,
|
|
845
|
+
}),
|
|
846
|
+
};
|
|
847
|
+
trackEvent("Subscription Checkout Start Failed", properties, devMode).catch((error) => {
|
|
848
|
+
if (devMode) {
|
|
849
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription start failure:", error);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Tracks when window.open is intercepted from the subscription checkout WebView
|
|
855
|
+
*/
|
|
856
|
+
function trackSubscriptionWindowOpen(source, url, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
857
|
+
const properties = {
|
|
858
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
859
|
+
subscriptionId: orderId,
|
|
860
|
+
source,
|
|
861
|
+
url,
|
|
862
|
+
};
|
|
863
|
+
trackEvent("Subscription Checkout Window Open", properties, devMode).catch((error) => {
|
|
864
|
+
if (devMode) {
|
|
865
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription window open:", error);
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Tracks when window.close is intercepted from the subscription checkout WebView
|
|
871
|
+
*/
|
|
872
|
+
function trackSubscriptionWindowClose(source, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
873
|
+
const properties = {
|
|
874
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
875
|
+
subscriptionId: orderId,
|
|
876
|
+
source,
|
|
877
|
+
};
|
|
878
|
+
trackEvent("Subscription Checkout Window Close", properties, devMode).catch((error) => {
|
|
879
|
+
if (devMode) {
|
|
880
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription window close:", error);
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Tracks when invalid message data is received from a subscription checkout WebView
|
|
886
|
+
*/
|
|
887
|
+
function trackSubscriptionInvalidMessageReceived(webviewType, data, url, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
888
|
+
let dataString;
|
|
889
|
+
try {
|
|
890
|
+
if (data === null) {
|
|
891
|
+
dataString = "null";
|
|
892
|
+
}
|
|
893
|
+
else if (data === undefined) {
|
|
894
|
+
dataString = "undefined";
|
|
895
|
+
}
|
|
896
|
+
else if (typeof data === "string") {
|
|
897
|
+
dataString = data;
|
|
898
|
+
}
|
|
899
|
+
else if (typeof data === "object") {
|
|
900
|
+
dataString = JSON.stringify(data);
|
|
901
|
+
}
|
|
902
|
+
else {
|
|
903
|
+
dataString = String(data);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
catch (_a) {
|
|
907
|
+
dataString = "[unable to stringify]";
|
|
908
|
+
}
|
|
909
|
+
const properties = {
|
|
910
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
911
|
+
subscriptionId: orderId,
|
|
912
|
+
webviewType,
|
|
913
|
+
data: dataString,
|
|
914
|
+
dataType: data === null ? "null" : typeof data,
|
|
915
|
+
...(url && { url }),
|
|
916
|
+
};
|
|
917
|
+
trackEvent("Subscription Checkout Invalid Message Received", properties, devMode).catch((error) => {
|
|
918
|
+
if (devMode) {
|
|
919
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription invalid message:", error);
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Tracks when subscription checkout onPaymentSuccess callback is invoked
|
|
925
|
+
*/
|
|
926
|
+
function trackSubscriptionPaymentSuccess(orderId, paymentId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
927
|
+
const properties = {
|
|
928
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
929
|
+
subscriptionId: orderId,
|
|
930
|
+
paymentId,
|
|
931
|
+
};
|
|
932
|
+
trackEvent("Subscription Payment Success", properties, devMode).catch((error) => {
|
|
933
|
+
if (devMode) {
|
|
934
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription payment success:", error);
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Tracks when subscription checkout onPaymentFailure callback is invoked
|
|
940
|
+
*/
|
|
941
|
+
function trackSubscriptionPaymentFailure(orderId, paymentId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
942
|
+
const properties = {
|
|
943
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
944
|
+
subscriptionId: orderId,
|
|
945
|
+
paymentId,
|
|
946
|
+
};
|
|
947
|
+
trackEvent("Subscription Payment Failure", properties, devMode).catch((error) => {
|
|
948
|
+
if (devMode) {
|
|
949
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription payment failure:", error);
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Tracks when subscription checkout onPaymentTerminate callback is invoked
|
|
955
|
+
*/
|
|
956
|
+
function trackSubscriptionPaymentTerminate(orderId, source, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
957
|
+
const properties = {
|
|
958
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
959
|
+
subscriptionId: orderId,
|
|
960
|
+
terminationSource: source,
|
|
961
|
+
};
|
|
962
|
+
trackEvent("Subscription Payment Terminated", properties, devMode).catch((error) => {
|
|
963
|
+
if (devMode) {
|
|
964
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription payment terminate:", error);
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Tracks when subscription checkout onConnectionError callback is invoked
|
|
970
|
+
*/
|
|
971
|
+
function trackSubscriptionConnectionError(orderId, errorCode, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
972
|
+
const properties = {
|
|
973
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
974
|
+
subscriptionId: orderId,
|
|
975
|
+
...(errorCode !== undefined && { errorCode }),
|
|
976
|
+
};
|
|
977
|
+
trackEvent("Subscription Connection Error", properties, devMode).catch((error) => {
|
|
978
|
+
if (devMode) {
|
|
979
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription connection error:", error);
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Tracks when subscription checkout onSdkError callback is invoked
|
|
985
|
+
*/
|
|
986
|
+
function trackSubscriptionSdkError(errors, orderId, publicKey, devMode = false, mockMode = false, checkoutUrl) {
|
|
987
|
+
const properties = {
|
|
988
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl, "subscriptions"),
|
|
989
|
+
subscriptionId: orderId,
|
|
990
|
+
errors,
|
|
991
|
+
errorCount: errors.length,
|
|
992
|
+
};
|
|
993
|
+
trackEvent("Subscription SDK Error", properties, devMode).catch((error) => {
|
|
994
|
+
if (devMode) {
|
|
995
|
+
console.error("[Glomo-RN-SDK] Event tracking error on subscription SDK error:", error);
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
// ---------------------------------------------------------------------------
|
|
1000
|
+
// Unsupported Functionality Telemetry
|
|
1001
|
+
// ---------------------------------------------------------------------------
|
|
1002
|
+
/**
|
|
1003
|
+
* Internal telemetry - fires when a merchant uses functionality that is
|
|
1004
|
+
* unsupported in the current context or deprecated.
|
|
1005
|
+
* Fires at most once per detection site (callers use a ref guard).
|
|
1006
|
+
*/
|
|
1007
|
+
function trackUseOfUnsupportedFunctionality(name, orderId, publicKey, devMode, mockMode, checkoutUrl) {
|
|
1008
|
+
const properties = {
|
|
1009
|
+
...buildCommonProperties(orderId, publicKey, devMode, mockMode, checkoutUrl),
|
|
1010
|
+
name,
|
|
1011
|
+
};
|
|
1012
|
+
trackEvent("Use of Unsupported Functionality", properties, devMode).catch((error) => {
|
|
1013
|
+
if (devMode) {
|
|
1014
|
+
console.error("[Glomo-RN-SDK] Event tracking error on unsupported functionality:", error);
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
/** Standard checkout tracker map - delegates to trackStandard* functions */
|
|
1019
|
+
exports.standardCheckoutTrackers = {
|
|
1020
|
+
trackStartAttempt: trackStandardStartAttempt,
|
|
1021
|
+
trackStartSuccess: trackStandardStartSuccess,
|
|
1022
|
+
trackStartFailure: trackStandardStartFailure,
|
|
1023
|
+
trackWindowOpen: trackStandardWindowOpen,
|
|
1024
|
+
trackWindowClose: trackStandardWindowClose,
|
|
1025
|
+
trackInvalidMessageReceived: trackStandardInvalidMessageReceived,
|
|
1026
|
+
trackPaymentSuccess: trackStandardPaymentSuccess,
|
|
1027
|
+
trackPaymentFailure: trackStandardPaymentFailure,
|
|
1028
|
+
trackPaymentTerminate: trackStandardPaymentTerminate,
|
|
1029
|
+
trackConnectionError: trackStandardConnectionError,
|
|
1030
|
+
trackSdkError: trackStandardSdkError,
|
|
1031
|
+
trackBankTransferSubmitted: trackStandardBankTransferSubmitted,
|
|
1032
|
+
trackPayViaBankCompleted: trackStandardPayViaBankCompleted,
|
|
1033
|
+
trackPayViaBankBankConnectionSuccessful: trackStandardPayViaBankBankConnectionSuccessful,
|
|
1034
|
+
};
|
|
1035
|
+
/** Subscription checkout tracker map - delegates to trackSubscription* functions, no-ops for bank transfer */
|
|
1036
|
+
exports.subscriptionCheckoutTrackers = {
|
|
1037
|
+
trackStartAttempt: trackSubscriptionStartAttempt,
|
|
1038
|
+
trackStartSuccess: trackSubscriptionStartSuccess,
|
|
1039
|
+
trackStartFailure: trackSubscriptionStartFailure,
|
|
1040
|
+
trackWindowOpen: trackSubscriptionWindowOpen,
|
|
1041
|
+
trackWindowClose: trackSubscriptionWindowClose,
|
|
1042
|
+
trackInvalidMessageReceived: trackSubscriptionInvalidMessageReceived,
|
|
1043
|
+
trackPaymentSuccess: trackSubscriptionPaymentSuccess,
|
|
1044
|
+
trackPaymentFailure: trackSubscriptionPaymentFailure,
|
|
1045
|
+
trackPaymentTerminate: trackSubscriptionPaymentTerminate,
|
|
1046
|
+
trackConnectionError: trackSubscriptionConnectionError,
|
|
1047
|
+
trackSdkError: trackSubscriptionSdkError,
|
|
1048
|
+
trackBankTransferSubmitted: (...args) => {
|
|
1049
|
+
const devMode = args[2];
|
|
1050
|
+
if (devMode) {
|
|
1051
|
+
console.warn("[Glomo-RN-SDK] Unexpected bank transfer event in subscription flow");
|
|
1052
|
+
}
|
|
1053
|
+
},
|
|
1054
|
+
trackPayViaBankCompleted: (...args) => {
|
|
1055
|
+
const devMode = args[3];
|
|
1056
|
+
if (devMode) {
|
|
1057
|
+
console.warn("[Glomo-RN-SDK] Unexpected pay via bank completed event in subscription flow");
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
trackPayViaBankBankConnectionSuccessful: (...args) => {
|
|
1061
|
+
const devMode = args[3];
|
|
1062
|
+
if (devMode) {
|
|
1063
|
+
console.warn("[Glomo-RN-SDK] Unexpected pay via bank connection event in subscription flow");
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
};
|
|
@@ -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.0
|
|
3
|
+
"version": "3.1.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
|
@@ -3,16 +3,26 @@
|
|
|
3
3
|
* Detects order type (LRS vs Standard) and delegates rendering to the appropriate inner component.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { useImperativeHandle, forwardRef } from "react";
|
|
6
|
+
import React, { useImperativeHandle, useRef, useEffect, useMemo, forwardRef } from "react";
|
|
7
7
|
|
|
8
|
-
import { useGlomoCheckout } from "./use-glomo-checkout";
|
|
8
|
+
import { useGlomoCheckout, type UseGlomoCheckoutInternalReturn } from "./use-glomo-checkout";
|
|
9
9
|
import { type GlomoCheckoutRef, type GlomoCheckoutProps } from "./types/checkout";
|
|
10
|
+
import { trackUseOfUnsupportedFunctionality } from "./utils/analytics";
|
|
10
11
|
import { GlomoLrsCheckout } from "./glomo-lrs-checkout";
|
|
11
12
|
import { GlomoStandardCheckout } from "./glomo-standard-checkout";
|
|
13
|
+
import { GlomoSubscriptionsCheckout } from "./glomo-subscriptions-checkout";
|
|
12
14
|
|
|
13
15
|
function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedRef<GlomoCheckoutRef>) {
|
|
14
16
|
// useGlomoCheckout handles order type detection and exposes start/getStatus for the ref
|
|
15
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
orderType,
|
|
19
|
+
start,
|
|
20
|
+
getStatus,
|
|
21
|
+
innerLrsRef,
|
|
22
|
+
innerStandardRef,
|
|
23
|
+
innerSubscriptionsRef,
|
|
24
|
+
props: passedProps,
|
|
25
|
+
}: UseGlomoCheckoutInternalReturn = useGlomoCheckout(props, { _suppressDeprecationWarning: true });
|
|
16
26
|
|
|
17
27
|
// Exposing start() and getStatus() via the forwarded ref for the merchant to call
|
|
18
28
|
useImperativeHandle(ref, () => ({
|
|
@@ -20,6 +30,50 @@ function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedR
|
|
|
20
30
|
getStatus,
|
|
21
31
|
}));
|
|
22
32
|
|
|
33
|
+
// Tracking unsupported callback props on subscription flows (fires once per mount)
|
|
34
|
+
const hasTrackedUnsupportedRef = useRef(false);
|
|
35
|
+
const devMode = passedProps.devMode ?? false;
|
|
36
|
+
const mockMode = useMemo(
|
|
37
|
+
() => passedProps.publicKey?.toLowerCase().startsWith("test_") ?? false,
|
|
38
|
+
[passedProps.publicKey]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// Extracting stable booleans for the tracking effect to avoid depending on passedProps object
|
|
42
|
+
const hasBankTransferCallback = !!passedProps.onBankTransferSubmitted;
|
|
43
|
+
const hasPayViaBankCallback = !!passedProps.onPayViaBankCompleted;
|
|
44
|
+
const hasBankConnectionCallback = !!passedProps.onPayViaBankBankConnectionSuccessful;
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (orderType !== "subscriptions" || hasTrackedUnsupportedRef.current) return;
|
|
48
|
+
hasTrackedUnsupportedRef.current = true;
|
|
49
|
+
|
|
50
|
+
const unsupported = [
|
|
51
|
+
hasBankTransferCallback && "onBankTransferSubmitted",
|
|
52
|
+
hasPayViaBankCallback && "onPayViaBankCompleted",
|
|
53
|
+
hasBankConnectionCallback && "onPayViaBankBankConnectionSuccessful",
|
|
54
|
+
].filter(Boolean) as string[];
|
|
55
|
+
|
|
56
|
+
for (const name of unsupported) {
|
|
57
|
+
trackUseOfUnsupportedFunctionality(
|
|
58
|
+
name,
|
|
59
|
+
passedProps.subscriptionId,
|
|
60
|
+
passedProps.publicKey,
|
|
61
|
+
devMode,
|
|
62
|
+
mockMode,
|
|
63
|
+
""
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}, [
|
|
67
|
+
orderType,
|
|
68
|
+
hasBankTransferCallback,
|
|
69
|
+
hasPayViaBankCallback,
|
|
70
|
+
hasBankConnectionCallback,
|
|
71
|
+
passedProps.subscriptionId,
|
|
72
|
+
passedProps.publicKey,
|
|
73
|
+
devMode,
|
|
74
|
+
mockMode,
|
|
75
|
+
]);
|
|
76
|
+
|
|
23
77
|
// Delegating to the LRS checkout component once order type is resolved as LRS
|
|
24
78
|
if (orderType === "lrs") {
|
|
25
79
|
return (
|
|
@@ -27,7 +81,7 @@ function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedR
|
|
|
27
81
|
ref={innerLrsRef}
|
|
28
82
|
server={passedProps.server}
|
|
29
83
|
publicKey={passedProps.publicKey}
|
|
30
|
-
orderId={passedProps.orderId}
|
|
84
|
+
orderId={passedProps.orderId!}
|
|
31
85
|
onPaymentSuccess={passedProps.onPaymentSuccess}
|
|
32
86
|
onPaymentFailure={passedProps.onPaymentFailure}
|
|
33
87
|
onConnectionError={passedProps.onConnectionError}
|
|
@@ -45,7 +99,7 @@ function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedR
|
|
|
45
99
|
ref={innerStandardRef}
|
|
46
100
|
server={passedProps.server}
|
|
47
101
|
publicKey={passedProps.publicKey}
|
|
48
|
-
orderId={passedProps.orderId}
|
|
102
|
+
orderId={passedProps.orderId!}
|
|
49
103
|
onPaymentSuccess={passedProps.onPaymentSuccess}
|
|
50
104
|
onPaymentFailure={passedProps.onPaymentFailure}
|
|
51
105
|
onConnectionError={passedProps.onConnectionError}
|
|
@@ -60,6 +114,26 @@ function GlomoCheckoutComponent(props: GlomoCheckoutProps, ref: React.ForwardedR
|
|
|
60
114
|
);
|
|
61
115
|
}
|
|
62
116
|
|
|
117
|
+
// Delegating to the Subscriptions checkout component when subscriptionId is provided (no API call)
|
|
118
|
+
if (orderType === "subscriptions") {
|
|
119
|
+
return (
|
|
120
|
+
<GlomoSubscriptionsCheckout
|
|
121
|
+
ref={innerSubscriptionsRef}
|
|
122
|
+
server={passedProps.server}
|
|
123
|
+
publicKey={passedProps.publicKey}
|
|
124
|
+
subscriptionId={passedProps.subscriptionId!}
|
|
125
|
+
onPaymentSuccess={passedProps.onPaymentSuccess}
|
|
126
|
+
onPaymentFailure={passedProps.onPaymentFailure}
|
|
127
|
+
onConnectionError={passedProps.onConnectionError}
|
|
128
|
+
onPaymentTerminate={passedProps.onPaymentTerminate}
|
|
129
|
+
onSdkError={passedProps.onSdkError}
|
|
130
|
+
onPayViaBankBankConnectionSuccessful={passedProps.onPayViaBankBankConnectionSuccessful}
|
|
131
|
+
onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions}
|
|
132
|
+
devMode={passedProps.devMode}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
63
137
|
/**
|
|
64
138
|
* No modal for detecting state - avoids iOS pageSheet conflict where
|
|
65
139
|
* dismissing the detecting modal interferes with the checkout modal presentation.
|