@tagadapay/plugin-sdk 3.0.14 → 3.0.15
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/dist/external-tracker.js +53 -5
- package/dist/external-tracker.min.js +2 -2
- package/dist/external-tracker.min.js.map +3 -3
- package/dist/v2/core/client.d.ts +1 -0
- package/dist/v2/core/client.js +25 -0
- package/dist/v2/core/funnelClient.d.ts +9 -0
- package/dist/v2/core/funnelClient.js +34 -6
- package/dist/v2/core/resources/checkout.d.ts +32 -0
- package/dist/v2/core/resources/checkout.js +38 -0
- package/dist/v2/core/resources/funnel.d.ts +1 -0
- package/dist/v2/react/providers/TagadaProvider.js +61 -1
- package/package.json +1 -1
package/dist/external-tracker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TagadaPay External Tracker v3.0.
|
|
2
|
+
* TagadaPay External Tracker v3.0.15
|
|
3
3
|
* CDN Bundle - Standalone tracking for external pages (Debug Build)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -635,6 +635,32 @@ var TagadaTrackerBundle = (() => {
|
|
|
635
635
|
getState() {
|
|
636
636
|
return this.state;
|
|
637
637
|
}
|
|
638
|
+
/**
|
|
639
|
+
* Get the session ID that would be used for initialization (URL params or cookie)
|
|
640
|
+
* This allows getting the session ID even before the client is fully initialized.
|
|
641
|
+
*/
|
|
642
|
+
getDetectedSessionId() {
|
|
643
|
+
var _a;
|
|
644
|
+
if ((_a = this.state.context) == null ? void 0 : _a.sessionId) {
|
|
645
|
+
return this.state.context.sessionId;
|
|
646
|
+
}
|
|
647
|
+
if (typeof window === "undefined") return null;
|
|
648
|
+
const params = new URLSearchParams(window.location.search);
|
|
649
|
+
const urlSessionId = params.get("funnelSessionId");
|
|
650
|
+
if (urlSessionId) return urlSessionId;
|
|
651
|
+
return getFunnelSessionCookie() || null;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Reset initialization state (used for back-button restores)
|
|
655
|
+
*/
|
|
656
|
+
resetInitialization() {
|
|
657
|
+
this.initializationAttempted = false;
|
|
658
|
+
this.isInitializing = false;
|
|
659
|
+
this.updateState({
|
|
660
|
+
context: null,
|
|
661
|
+
isInitialized: false
|
|
662
|
+
});
|
|
663
|
+
}
|
|
638
664
|
/**
|
|
639
665
|
* Initialize session with automatic detection (cookies, URL, etc.)
|
|
640
666
|
*/
|
|
@@ -646,13 +672,10 @@ var TagadaTrackerBundle = (() => {
|
|
|
646
672
|
this.isInitializing = true;
|
|
647
673
|
this.updateState({ isLoading: true, error: null });
|
|
648
674
|
try {
|
|
675
|
+
const existingSessionId = this.getDetectedSessionId();
|
|
649
676
|
const params = new URLSearchParams(typeof window !== "undefined" ? window.location.search : "");
|
|
650
677
|
const urlFunnelId = params.get("funnelId");
|
|
651
678
|
const effectiveFunnelId = urlFunnelId || funnelId;
|
|
652
|
-
let existingSessionId = params.get("funnelSessionId");
|
|
653
|
-
if (!existingSessionId) {
|
|
654
|
-
existingSessionId = getFunnelSessionCookie() || null;
|
|
655
|
-
}
|
|
656
679
|
const injectedFunnelId = getAssignedFunnelId();
|
|
657
680
|
const funnelVariantId = getAssignedFunnelVariant();
|
|
658
681
|
const injectedStepId = getAssignedFunnelStep();
|
|
@@ -7502,6 +7525,29 @@ var TagadaTrackerBundle = (() => {
|
|
|
7502
7525
|
this.config = config;
|
|
7503
7526
|
this.instanceId = Math.random().toString(36).substr(2, 9);
|
|
7504
7527
|
this.boundHandleStorageChange = this.handleStorageChange.bind(this);
|
|
7528
|
+
this.boundHandlePageshow = (event) => {
|
|
7529
|
+
if (event.persisted) {
|
|
7530
|
+
if (this.state.debugMode) {
|
|
7531
|
+
console.log("[TagadaClient ".concat(this.instanceId, "] Page restored from BFcache (back button), re-initializing funnel..."));
|
|
7532
|
+
}
|
|
7533
|
+
if (this.funnel && this.state.session && this.state.store) {
|
|
7534
|
+
this.funnel.resetInitialization();
|
|
7535
|
+
const accountId = this.getAccountId();
|
|
7536
|
+
const urlParams = new URLSearchParams(typeof window !== "undefined" ? window.location.search : "");
|
|
7537
|
+
const funnelId = urlParams.get("funnelId") || void 0;
|
|
7538
|
+
this.funnel.autoInitialize(
|
|
7539
|
+
{ customerId: this.state.session.customerId, sessionId: this.state.session.sessionId },
|
|
7540
|
+
{ id: this.state.store.id, accountId },
|
|
7541
|
+
funnelId
|
|
7542
|
+
).catch((err) => {
|
|
7543
|
+
console.error("[TagadaClient] Funnel re-initialization failed:", err);
|
|
7544
|
+
});
|
|
7545
|
+
} else {
|
|
7546
|
+
this.sessionInitRetryCount = 0;
|
|
7547
|
+
this.initialize();
|
|
7548
|
+
}
|
|
7549
|
+
}
|
|
7550
|
+
};
|
|
7505
7551
|
console.log("[TagadaClient ".concat(this.instanceId, "] Initializing..."));
|
|
7506
7552
|
console.log("[TagadaClient ".concat(this.instanceId, "] Config:"), {
|
|
7507
7553
|
debugMode: config.debugMode,
|
|
@@ -7579,6 +7625,7 @@ var TagadaTrackerBundle = (() => {
|
|
|
7579
7625
|
this.apiClient.setTokenProvider(this.waitForToken.bind(this));
|
|
7580
7626
|
if (typeof window !== "undefined") {
|
|
7581
7627
|
window.addEventListener("storage", this.boundHandleStorageChange);
|
|
7628
|
+
window.addEventListener("pageshow", this.boundHandlePageshow);
|
|
7582
7629
|
}
|
|
7583
7630
|
this.setupConfigHotReload();
|
|
7584
7631
|
this.initialize();
|
|
@@ -7589,6 +7636,7 @@ var TagadaTrackerBundle = (() => {
|
|
|
7589
7636
|
destroy() {
|
|
7590
7637
|
if (typeof window !== "undefined") {
|
|
7591
7638
|
window.removeEventListener("storage", this.boundHandleStorageChange);
|
|
7639
|
+
window.removeEventListener("pageshow", this.boundHandlePageshow);
|
|
7592
7640
|
}
|
|
7593
7641
|
if (this.state.debugMode) {
|
|
7594
7642
|
console.log("[TagadaClient ".concat(this.instanceId, "] Destroyed"));
|