@tagadapay/plugin-sdk 3.1.12 → 3.1.24
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/build-cdn.js +397 -11
- package/dist/data/iso3166.d.ts +23 -33
- package/dist/data/iso3166.js +134 -198
- package/dist/data/languages.d.ts +5 -64
- package/dist/data/languages.js +23 -143
- package/dist/external-tracker.js +623 -3426
- package/dist/external-tracker.min.js +2 -25
- package/dist/external-tracker.min.js.map +4 -4
- package/dist/react/config/payment.d.ts +14 -4
- package/dist/react/config/payment.js +47 -9
- package/dist/react/hooks/useCheckout.d.ts +3 -0
- package/dist/react/hooks/useCheckout.js +4 -1
- package/dist/react/hooks/useISOData.js +1 -1
- package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
- package/dist/react/hooks/usePluginConfig.js +9 -10
- package/dist/react/providers/TagadaProvider.js +1 -1
- package/dist/tagada-react-sdk-minimal.min.js +36 -0
- package/dist/tagada-react-sdk-minimal.min.js.map +7 -0
- package/dist/tagada-react-sdk.js +37821 -0
- package/dist/tagada-react-sdk.min.js +78 -0
- package/dist/tagada-react-sdk.min.js.map +7 -0
- package/dist/tagada-sdk.js +16044 -0
- package/dist/tagada-sdk.min.js +32 -0
- package/dist/tagada-sdk.min.js.map +7 -0
- package/dist/v2/cdn-react-minimal.d.ts +23 -0
- package/dist/v2/cdn-react-minimal.js +26 -0
- package/dist/v2/core/client.d.ts +4 -2
- package/dist/v2/core/client.js +5 -4
- package/dist/v2/core/config/environment.js +2 -1
- package/dist/v2/core/errors.d.ts +75 -0
- package/dist/v2/core/errors.js +104 -0
- package/dist/v2/core/funnelClient.d.ts +100 -10
- package/dist/v2/core/funnelClient.js +121 -27
- package/dist/v2/core/isoData.d.ts +4 -4
- package/dist/v2/core/isoData.js +7 -7
- package/dist/v2/core/pixelMapping.d.ts +49 -0
- package/dist/v2/core/pixelMapping.js +363 -0
- package/dist/v2/core/resources/apiClient.d.ts +2 -0
- package/dist/v2/core/resources/apiClient.js +52 -9
- package/dist/v2/core/resources/checkout.d.ts +99 -30
- package/dist/v2/core/resources/checkout.js +14 -0
- package/dist/v2/core/resources/customer.d.ts +20 -19
- package/dist/v2/core/resources/expressPaymentMethods.d.ts +1 -0
- package/dist/v2/core/resources/funnel.d.ts +17 -17
- package/dist/v2/core/resources/payments.d.ts +89 -13
- package/dist/v2/core/resources/payments.js +27 -9
- package/dist/v2/core/resources/postPurchases.d.ts +17 -0
- package/dist/v2/core/resources/postPurchases.js +20 -0
- package/dist/v2/core/types.d.ts +50 -12
- package/dist/v2/core/types.js +0 -3
- package/dist/v2/core/utils/checkout.d.ts +2 -2
- package/dist/v2/core/utils/checkout.js +7 -2
- package/dist/v2/core/utils/currency.d.ts +14 -0
- package/dist/v2/core/utils/currency.js +40 -0
- package/dist/v2/core/utils/deviceInfo.d.ts +0 -10
- package/dist/v2/core/utils/deviceInfo.js +152 -76
- package/dist/v2/core/utils/index.d.ts +1 -0
- package/dist/v2/core/utils/index.js +2 -0
- package/dist/v2/core/utils/order.d.ts +13 -9
- package/dist/v2/core/utils/pluginConfig.d.ts +8 -0
- package/dist/v2/core/utils/pluginConfig.js +36 -12
- package/dist/v2/index.d.ts +6 -3
- package/dist/v2/index.js +4 -2
- package/dist/v2/react/components/FunnelScriptInjector.js +166 -77
- package/dist/v2/react/components/StripeExpressButton.d.ts +13 -0
- package/dist/v2/react/components/StripeExpressButton.js +171 -0
- package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
- package/dist/v2/react/components/WhopCheckout.js +237 -0
- package/dist/v2/react/hooks/__examples__/FunnelContextExample.js +1 -1
- package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useAirwallexRadarAction.js +181 -0
- package/dist/v2/react/hooks/payment-actions/useErrorAction.d.ts +9 -0
- package/dist/v2/react/hooks/payment-actions/useErrorAction.js +21 -0
- package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useFinixRadarAction.js +187 -0
- package/dist/v2/react/hooks/payment-actions/useKessPayAction.d.ts +11 -0
- package/dist/v2/react/hooks/payment-actions/useKessPayAction.js +91 -0
- package/dist/v2/react/hooks/payment-actions/useMasterCardAction.d.ts +24 -0
- package/dist/v2/react/hooks/payment-actions/useMasterCardAction.js +221 -0
- package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.d.ts +15 -0
- package/dist/v2/react/hooks/payment-actions/usePaymentActionHandler.js +142 -0
- package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.d.ts +3 -0
- package/dist/v2/react/hooks/payment-actions/useProcessorAuthAction.js +31 -0
- package/dist/v2/react/hooks/payment-actions/useRedirectAction.d.ts +10 -0
- package/dist/v2/react/hooks/payment-actions/useRedirectAction.js +35 -0
- package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useStripeRadarAction.js +192 -0
- package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.d.ts +14 -0
- package/dist/v2/react/hooks/payment-actions/useThreedsAuthAction.js +81 -0
- package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.d.ts +11 -0
- package/dist/v2/react/hooks/payment-actions/useTrustFlowAction.js +84 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.d.ts +14 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentInstruments.js +36 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.d.ts +31 -0
- package/dist/v2/react/hooks/payment-processing/usePaymentProcessors.js +212 -0
- package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.d.ts +14 -0
- package/dist/v2/react/hooks/payment-redirect/useAirwallex3dsReturn.js +207 -0
- package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.d.ts +12 -0
- package/dist/v2/react/hooks/payment-redirect/useGenericPaymentReturn.js +101 -0
- package/dist/v2/react/hooks/useApplePayCheckout.js +8 -8
- package/dist/v2/react/hooks/useCheckoutQuery.d.ts +16 -0
- package/dist/v2/react/hooks/useCheckoutQuery.js +63 -10
- package/dist/v2/react/hooks/useFunnel.d.ts +15 -4
- package/dist/v2/react/hooks/useFunnel.js +8 -4
- package/dist/v2/react/hooks/useGeoLocation.d.ts +2 -1
- package/dist/v2/react/hooks/useGeoLocation.js +4 -2
- package/dist/v2/react/hooks/useGoogleAutocomplete.d.ts +2 -0
- package/dist/v2/react/hooks/useGoogleAutocomplete.js +29 -15
- package/dist/v2/react/hooks/useISOData.d.ts +2 -5
- package/dist/v2/react/hooks/useISOData.js +26 -27
- package/dist/v2/react/hooks/usePaymentPolling.d.ts +3 -3
- package/dist/v2/react/hooks/usePaymentQuery.d.ts +18 -5
- package/dist/v2/react/hooks/usePaymentQuery.js +63 -1015
- package/dist/v2/react/hooks/usePaymentRetrieve.d.ts +3 -2
- package/dist/v2/react/hooks/usePaymentRetrieve.js +3 -1
- package/dist/v2/react/hooks/usePixelTracking.d.ts +5 -48
- package/dist/v2/react/hooks/usePixelTracking.js +283 -504
- package/dist/v2/react/hooks/usePostPurchasesQuery.js +34 -2
- package/dist/v2/react/hooks/useRemappableParams.d.ts +2 -6
- package/dist/v2/react/hooks/useRemappableParams.js +23 -23
- package/dist/v2/react/hooks/useSetPaymentMethod.d.ts +16 -0
- package/dist/v2/react/hooks/useSetPaymentMethod.js +33 -0
- package/dist/v2/react/hooks/useShippingRatesQuery.js +13 -5
- package/dist/v2/react/hooks/useStepConfig.d.ts +23 -6
- package/dist/v2/react/hooks/useStepConfig.js +14 -7
- package/dist/v2/react/hooks/useTranslation.js +23 -8
- package/dist/v2/react/hooks/useWhopPaymentPolling.d.ts +30 -0
- package/dist/v2/react/hooks/useWhopPaymentPolling.js +61 -0
- package/dist/v2/react/index.d.ts +15 -1
- package/dist/v2/react/index.js +7 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +3 -1
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +12 -2
- package/dist/v2/react/providers/TagadaProvider.js +74 -5
- package/dist/v2/standalone/external-tracker.d.ts +52 -46
- package/dist/v2/standalone/external-tracker.js +205 -98
- package/dist/v2/standalone/index.d.ts +40 -0
- package/dist/v2/standalone/index.js +148 -1
- package/dist/v2/standalone/payment-service.d.ts +134 -0
- package/dist/v2/standalone/payment-service.js +928 -0
- package/package.json +6 -4
- package/dist/react/utils/__tests__/urlUtils.test.d.ts +0 -1
- package/dist/react/utils/__tests__/urlUtils.test.js +0 -189
- package/dist/v2/core/__tests__/pathRemapping.test.d.ts +0 -11
- package/dist/v2/core/__tests__/pathRemapping.test.js +0 -776
|
@@ -2,7 +2,7 @@ import { detectEnvironment } from './config/environment';
|
|
|
2
2
|
import { FunnelActionType, FunnelResource } from './resources/funnel';
|
|
3
3
|
import { EventDispatcher } from './utils/eventDispatcher';
|
|
4
4
|
import { getSDKParams } from './utils/previewMode';
|
|
5
|
-
|
|
5
|
+
const lazyInjectPreviewIndicator = () => import('./utils/previewModeIndicator').then(m => m.injectPreviewModeIndicator());
|
|
6
6
|
import { getFunnelSessionCookie, setFunnelSessionCookie } from './utils/sessionStorage';
|
|
7
7
|
/**
|
|
8
8
|
* Tracking providers supported by the SDK.
|
|
@@ -16,6 +16,41 @@ export var TrackingProvider;
|
|
|
16
16
|
TrackingProvider["PINTEREST"] = "pinterest";
|
|
17
17
|
TrackingProvider["GTM"] = "gtm";
|
|
18
18
|
})(TrackingProvider || (TrackingProvider = {}));
|
|
19
|
+
/** Get all enabled entries from a paymentSetupConfig */
|
|
20
|
+
export function getEnabledMethods(config) {
|
|
21
|
+
if (!config)
|
|
22
|
+
return [];
|
|
23
|
+
return Object.values(config).filter(m => m.enabled);
|
|
24
|
+
}
|
|
25
|
+
/** Get all express methods (for rendering above the payment form) */
|
|
26
|
+
export function getExpressMethods(config) {
|
|
27
|
+
return getEnabledMethods(config).filter(m => m.express);
|
|
28
|
+
}
|
|
29
|
+
/** Group enabled express methods by processorId (one Express Element per processor) */
|
|
30
|
+
export function getExpressMethodsByProcessor(config) {
|
|
31
|
+
const groups = {};
|
|
32
|
+
for (const m of getExpressMethods(config)) {
|
|
33
|
+
const key = m.processorId || m.integrationId || m.provider;
|
|
34
|
+
if (!groups[key])
|
|
35
|
+
groups[key] = [];
|
|
36
|
+
groups[key].push(m);
|
|
37
|
+
}
|
|
38
|
+
return groups;
|
|
39
|
+
}
|
|
40
|
+
/** Find a specific method entry by method name (returns first match) */
|
|
41
|
+
export function findMethod(config, method) {
|
|
42
|
+
if (!config)
|
|
43
|
+
return undefined;
|
|
44
|
+
for (const entry of Object.values(config)) {
|
|
45
|
+
if (entry.method === method && entry.enabled)
|
|
46
|
+
return entry;
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
/** Check if a specific method is enabled (any provider) */
|
|
51
|
+
export function isMethodEnabled(config, method) {
|
|
52
|
+
return !!findMethod(config, method);
|
|
53
|
+
}
|
|
19
54
|
/**
|
|
20
55
|
* Get the funnel ID from the injected HTML
|
|
21
56
|
* Returns undefined if not available
|
|
@@ -183,11 +218,14 @@ export function getLocalFunnelConfig() {
|
|
|
183
218
|
* Convert LocalFunnelConfig to RuntimeStepConfig
|
|
184
219
|
*/
|
|
185
220
|
function localConfigToStepConfig(local) {
|
|
221
|
+
const merged = { ...local.staticResources, ...local.resources };
|
|
186
222
|
return {
|
|
187
223
|
payment: local.paymentFlowId ? { paymentFlowId: local.paymentFlowId } : undefined,
|
|
188
|
-
|
|
224
|
+
resources: Object.keys(merged).length > 0 ? merged : undefined,
|
|
189
225
|
scripts: local.scripts,
|
|
190
226
|
pixels: local.pixels,
|
|
227
|
+
orderBumps: local.orderBumps,
|
|
228
|
+
upsellOffers: local.upsellOffers,
|
|
191
229
|
};
|
|
192
230
|
}
|
|
193
231
|
/**
|
|
@@ -207,7 +245,6 @@ export function getAssignedStepConfig() {
|
|
|
207
245
|
if (typeof window === 'undefined')
|
|
208
246
|
return undefined;
|
|
209
247
|
// Method 1: Local dev override (HIGHEST PRIORITY in local dev)
|
|
210
|
-
// Allows developers to test different configurations without redeploying
|
|
211
248
|
const localConfig = getLocalFunnelConfig();
|
|
212
249
|
if (localConfig) {
|
|
213
250
|
console.log('🛠️ [SDK] Using local funnel.local.json (overrides injected)');
|
|
@@ -233,22 +270,29 @@ export function getAssignedStepConfig() {
|
|
|
233
270
|
return undefined;
|
|
234
271
|
}
|
|
235
272
|
/**
|
|
236
|
-
* Get the assigned payment flow ID from step config or legacy injection
|
|
237
|
-
*
|
|
273
|
+
* Get the assigned payment flow ID from step config or legacy injection.
|
|
274
|
+
* Resolution order:
|
|
275
|
+
* 1. paymentSetupConfig.card.paymentFlowId (per-method, most specific)
|
|
276
|
+
* 2. stepConfig.payment.paymentFlowId (per-step level)
|
|
277
|
+
* 3. window.__TGD_PAYMENT_FLOW_ID__ (legacy injection)
|
|
278
|
+
* 4. meta[name="x-payment-flow-id"] (legacy meta tag)
|
|
238
279
|
*/
|
|
239
280
|
export function getAssignedPaymentFlowId() {
|
|
240
|
-
// Method 1: New stepConfig (preferred)
|
|
241
281
|
const stepConfig = getAssignedStepConfig();
|
|
282
|
+
// Method 1: Per-method config — card entry in paymentSetupConfig
|
|
283
|
+
const cardConfig = stepConfig?.paymentSetupConfig?.card;
|
|
284
|
+
if (cardConfig?.paymentFlowId) {
|
|
285
|
+
return cardConfig.paymentFlowId;
|
|
286
|
+
}
|
|
287
|
+
// Method 2: Per-step config (legacy but still supported)
|
|
242
288
|
if (stepConfig?.payment?.paymentFlowId) {
|
|
243
289
|
return stepConfig.payment.paymentFlowId;
|
|
244
290
|
}
|
|
245
|
-
// Method
|
|
291
|
+
// Method 3: Legacy direct injection (backward compatibility)
|
|
246
292
|
if (typeof window !== 'undefined') {
|
|
247
|
-
// Legacy window variable
|
|
248
293
|
if (window.__TGD_PAYMENT_FLOW_ID__) {
|
|
249
294
|
return window.__TGD_PAYMENT_FLOW_ID__;
|
|
250
295
|
}
|
|
251
|
-
// Legacy meta tag
|
|
252
296
|
if (typeof document !== 'undefined') {
|
|
253
297
|
const meta = document.querySelector('meta[name="x-payment-flow-id"]');
|
|
254
298
|
return meta?.getAttribute('content') || undefined;
|
|
@@ -257,12 +301,23 @@ export function getAssignedPaymentFlowId() {
|
|
|
257
301
|
return undefined;
|
|
258
302
|
}
|
|
259
303
|
/**
|
|
260
|
-
* Get
|
|
261
|
-
*
|
|
304
|
+
* Get resource bindings from step config.
|
|
305
|
+
* Reads from `resources` (new) with `staticResources` (legacy) as fallback, merged.
|
|
262
306
|
*/
|
|
263
|
-
export function
|
|
307
|
+
export function getAssignedResources() {
|
|
264
308
|
const stepConfig = getAssignedStepConfig();
|
|
265
|
-
|
|
309
|
+
const legacy = stepConfig?.staticResources;
|
|
310
|
+
const current = stepConfig?.resources;
|
|
311
|
+
if (!legacy && !current)
|
|
312
|
+
return undefined;
|
|
313
|
+
return { ...legacy, ...current };
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* @deprecated Use `getAssignedResources()` instead.
|
|
317
|
+
* Kept for backward compatibility — reads from both `resources` and `staticResources`.
|
|
318
|
+
*/
|
|
319
|
+
export function getAssignedStaticResources() {
|
|
320
|
+
return getAssignedResources();
|
|
266
321
|
}
|
|
267
322
|
/**
|
|
268
323
|
* Get the assigned scripts from step config
|
|
@@ -284,6 +339,21 @@ export function getAssignedScripts(position) {
|
|
|
284
339
|
* Get assigned pixel tracking configuration (normalized to arrays)
|
|
285
340
|
* Always returns arrays of PixelConfig for consistent consumption.
|
|
286
341
|
*/
|
|
342
|
+
/**
|
|
343
|
+
* Split a pixel config with semicolon/comma-separated IDs into individual configs.
|
|
344
|
+
* Handles cases where the CRM stores "ID1; ID2; ID3" as a single pixelId or containerId.
|
|
345
|
+
*/
|
|
346
|
+
function splitPixelConfig(px) {
|
|
347
|
+
// GTM configs use containerId
|
|
348
|
+
const idField = 'containerId' in px ? 'containerId' : 'pixelId';
|
|
349
|
+
const rawId = px[idField];
|
|
350
|
+
if (!rawId || !rawId.includes(';') && !rawId.includes(','))
|
|
351
|
+
return [px];
|
|
352
|
+
const ids = rawId.split(/[;,]/).map((id) => id.trim()).filter((id) => id.length > 0);
|
|
353
|
+
if (ids.length <= 1)
|
|
354
|
+
return [px];
|
|
355
|
+
return ids.map((id) => ({ ...px, [idField]: id }));
|
|
356
|
+
}
|
|
287
357
|
export function getAssignedPixels() {
|
|
288
358
|
const stepConfig = getAssignedStepConfig();
|
|
289
359
|
const rawPixels = stepConfig?.pixels;
|
|
@@ -294,17 +364,43 @@ export function getAssignedPixels() {
|
|
|
294
364
|
if (!value)
|
|
295
365
|
continue;
|
|
296
366
|
if (Array.isArray(value)) {
|
|
297
|
-
//
|
|
298
|
-
normalized[key] = value;
|
|
367
|
+
// Expand any entries with semicolon/comma-separated pixelIds into separate configs
|
|
368
|
+
normalized[key] = value.flatMap((px) => splitPixelConfig(px));
|
|
299
369
|
}
|
|
300
370
|
else if (typeof value === 'object') {
|
|
301
|
-
// Single object - wrap in array
|
|
302
|
-
normalized[key] =
|
|
371
|
+
// Single object - wrap in array, splitting if needed
|
|
372
|
+
normalized[key] = splitPixelConfig(value);
|
|
303
373
|
}
|
|
304
374
|
// Skip invalid entries
|
|
305
375
|
}
|
|
306
376
|
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
|
307
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Get the enabled order bump offer IDs from step config.
|
|
380
|
+
* Returns undefined when mode is 'inherit' (use all store bumps).
|
|
381
|
+
* Returns the explicit list when mode is 'custom'.
|
|
382
|
+
*/
|
|
383
|
+
export function getAssignedOrderBumpOfferIds() {
|
|
384
|
+
const stepConfig = getAssignedStepConfig();
|
|
385
|
+
if (!stepConfig?.orderBumps)
|
|
386
|
+
return undefined;
|
|
387
|
+
if (stepConfig.orderBumps.mode !== 'custom')
|
|
388
|
+
return undefined;
|
|
389
|
+
return stepConfig.orderBumps.enabledOfferIds;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Get the enabled upsell offer IDs from step config.
|
|
393
|
+
* Returns undefined when mode is 'inherit' (use all store upsells).
|
|
394
|
+
* Returns the explicit list when mode is 'custom'.
|
|
395
|
+
*/
|
|
396
|
+
export function getAssignedUpsellOfferIds() {
|
|
397
|
+
const stepConfig = getAssignedStepConfig();
|
|
398
|
+
if (!stepConfig?.upsellOffers)
|
|
399
|
+
return undefined;
|
|
400
|
+
if (stepConfig.upsellOffers.mode !== 'custom')
|
|
401
|
+
return undefined;
|
|
402
|
+
return stepConfig.upsellOffers.enabledUpsellIds;
|
|
403
|
+
}
|
|
308
404
|
export class FunnelClient {
|
|
309
405
|
constructor(config) {
|
|
310
406
|
this.eventDispatcher = new EventDispatcher();
|
|
@@ -444,8 +540,7 @@ export class FunnelClient {
|
|
|
444
540
|
if (response.success && response.context) {
|
|
445
541
|
const enriched = this.enrichContext(response.context);
|
|
446
542
|
this.handleSessionSuccess(enriched);
|
|
447
|
-
|
|
448
|
-
injectPreviewModeIndicator();
|
|
543
|
+
lazyInjectPreviewIndicator();
|
|
449
544
|
return enriched;
|
|
450
545
|
}
|
|
451
546
|
else {
|
|
@@ -495,8 +590,7 @@ export class FunnelClient {
|
|
|
495
590
|
if (response.success && response.context) {
|
|
496
591
|
const enriched = this.enrichContext(response.context);
|
|
497
592
|
this.handleSessionSuccess(enriched);
|
|
498
|
-
|
|
499
|
-
injectPreviewModeIndicator();
|
|
593
|
+
lazyInjectPreviewIndicator();
|
|
500
594
|
return enriched;
|
|
501
595
|
}
|
|
502
596
|
else {
|
|
@@ -608,12 +702,12 @@ export class FunnelClient {
|
|
|
608
702
|
: this.config.autoRedirect !== false; // Default to true
|
|
609
703
|
// Skip refreshSession if auto-redirecting (next page will initialize with fresh state)
|
|
610
704
|
// Only refresh if staying on same page (autoRedirect: false)
|
|
611
|
-
if (!shouldAutoRedirect) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
705
|
+
// if (!shouldAutoRedirect) {
|
|
706
|
+
// if (this.config.debugMode) {
|
|
707
|
+
// console.log('🔄 [FunnelClient] Refreshing session (no auto-redirect)');
|
|
708
|
+
// }
|
|
709
|
+
// await this.refreshSession();
|
|
710
|
+
// }
|
|
617
711
|
this.updateState({ isNavigating: false, isLoading: false });
|
|
618
712
|
// Auto-redirect if enabled and result has a URL
|
|
619
713
|
if (shouldAutoRedirect && result?.url && typeof window !== 'undefined') {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ISO Data Core
|
|
3
|
-
*
|
|
4
|
-
* Uses the existing iso3166 data functions
|
|
2
|
+
* ISO Data Core — CDN-backed country/region data (pure functions, no React).
|
|
3
|
+
* Call ensureLoaded() before using synchronous getters.
|
|
5
4
|
*/
|
|
6
5
|
import { type SupportedLanguage } from '../../data/iso3166';
|
|
7
6
|
export interface ISOCountry {
|
|
@@ -44,7 +43,8 @@ export declare class ISODataCore {
|
|
|
44
43
|
*/
|
|
45
44
|
static importLanguage(language: SupportedLanguage): Promise<void>;
|
|
46
45
|
/**
|
|
47
|
-
*
|
|
46
|
+
* Fetch countries + regions from CDN for a language (call before sync getters)
|
|
48
47
|
*/
|
|
48
|
+
static ensureLoaded(language?: SupportedLanguage): Promise<void>;
|
|
49
49
|
static getAvailableLanguages(): SupportedLanguage[];
|
|
50
50
|
}
|
package/dist/v2/core/isoData.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ISO Data Core
|
|
3
|
-
*
|
|
4
|
-
* Uses the existing iso3166 data functions
|
|
2
|
+
* ISO Data Core — CDN-backed country/region data (pure functions, no React).
|
|
3
|
+
* Call ensureLoaded() before using synchronous getters.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
import { getCountries, getStatesForCountry, importLanguage, isLanguageRegistered, getRegisteredLanguages } from '../../data/iso3166';
|
|
5
|
+
import { getCountries, getStatesForCountry, ensureGeoDataLoaded, importLanguage, isLanguageRegistered, getRegisteredLanguages } from '../../data/iso3166';
|
|
8
6
|
export class ISODataCore {
|
|
9
7
|
/**
|
|
10
8
|
* Get countries data for a specific language
|
|
@@ -94,10 +92,12 @@ export class ISODataCore {
|
|
|
94
92
|
return importLanguage(language);
|
|
95
93
|
}
|
|
96
94
|
/**
|
|
97
|
-
*
|
|
95
|
+
* Fetch countries + regions from CDN for a language (call before sync getters)
|
|
98
96
|
*/
|
|
97
|
+
static async ensureLoaded(language = 'en') {
|
|
98
|
+
return ensureGeoDataLoaded(language);
|
|
99
|
+
}
|
|
99
100
|
static getAvailableLanguages() {
|
|
100
|
-
// Return all available languages (not just registered ones)
|
|
101
101
|
return ['en', 'ru', 'de', 'fr', 'es', 'zh', 'hi', 'pt', 'ja', 'ar', 'it', 'he'];
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core pixel event mapping, parameter transformation, and event gating.
|
|
3
|
+
*
|
|
4
|
+
* This module is framework-agnostic (no React, no DOM) so it can be shared
|
|
5
|
+
* between the React `PixelTrackingProvider` and the standalone vanilla SDK.
|
|
6
|
+
*
|
|
7
|
+
* Official event name references (verified Feb 2026 against vendor docs):
|
|
8
|
+
* Meta: fbq('track', 'Purchase', { value, currency }) — developers.facebook.com/docs/meta-pixel/reference
|
|
9
|
+
* TikTok: ttq.track('Purchase', { value, currency }) — ads.tiktok.com/help/article/standard-events-parameters (Sep 2025)
|
|
10
|
+
* Snapchat: snaptr('track', 'PURCHASE', { price, currency }) — developers.snap.com/api/marketing-api/Conversions-API/Parameters
|
|
11
|
+
* Pinterest: pintrk('track', 'checkout', { value, currency }) — help.pinterest.com/en/business/article/add-event-codes
|
|
12
|
+
* GTM/GA4: gtag('event', 'purchase', { value, currency, items })
|
|
13
|
+
*/
|
|
14
|
+
import type { GTMTrackingConfig, PixelConfig, PixelsConfig } from './funnelClient';
|
|
15
|
+
export type StandardPixelEvent = 'PageView' | 'ViewContent' | 'AddToCart' | 'AddToWishlist' | 'Search' | 'InitiateCheckout' | 'AddPaymentInfo' | 'Purchase' | 'Lead' | 'CompleteRegistration' | 'Conversion';
|
|
16
|
+
export type PixelProviderKey = 'facebook' | 'tiktok' | 'snapchat' | 'pinterest' | 'gtm';
|
|
17
|
+
export interface MappedEvent {
|
|
18
|
+
name: string;
|
|
19
|
+
params: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns `true` if the given event is enabled on the pixel config.
|
|
23
|
+
* If the pixel has no `events` map (e.g. MetaConversionTrackingConfig) we allow all.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isEventEnabled(pixel: PixelConfig, eventName: StandardPixelEvent): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Filter an array of pixel configs to only those that are globally enabled
|
|
28
|
+
* AND have the specific event toggled on.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getEligiblePixels<T extends PixelConfig>(pixels: T[] | undefined, eventName: StandardPixelEvent): T[];
|
|
31
|
+
export declare function mapMetaEvent(eventName: StandardPixelEvent, parameters: Record<string, unknown>): MappedEvent;
|
|
32
|
+
export declare function mapTikTokEvent(eventName: StandardPixelEvent, parameters: Record<string, unknown>): MappedEvent;
|
|
33
|
+
export declare function mapSnapchatEvent(eventName: StandardPixelEvent, parameters: Record<string, unknown>): MappedEvent;
|
|
34
|
+
export declare function mapPinterestEvent(eventName: StandardPixelEvent, parameters: Record<string, unknown>): MappedEvent;
|
|
35
|
+
export declare function mapGTMEvent(eventName: StandardPixelEvent, parameters: Record<string, unknown>): MappedEvent;
|
|
36
|
+
/**
|
|
37
|
+
* Append Google Ads `send_to` parameter when conversion tracking is configured.
|
|
38
|
+
*/
|
|
39
|
+
export declare function applyGoogleAdsConversion(params: Record<string, unknown>, eventName: StandardPixelEvent, pixel: GTMTrackingConfig): Record<string, unknown>;
|
|
40
|
+
export interface ProviderEvent {
|
|
41
|
+
provider: PixelProviderKey;
|
|
42
|
+
mapped: MappedEvent;
|
|
43
|
+
pixel: PixelConfig;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Given a PixelsConfig and an event, return per-provider mapped events
|
|
47
|
+
* for every eligible (enabled + event-toggled-on) pixel.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolvePixelEvents(pixels: PixelsConfig, eventName: StandardPixelEvent, parameters: Record<string, unknown>): ProviderEvent[];
|