@tagadapay/plugin-sdk 3.1.11 → 3.1.22
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/README.md +1129 -1129
- package/build-cdn.js +231 -228
- 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 +968 -102
- package/dist/external-tracker.min.js +2 -2
- package/dist/external-tracker.min.js.map +4 -4
- package/dist/react/hooks/useISOData.js +1 -1
- package/dist/react/hooks/usePaymentPolling.d.ts +3 -3
- package/dist/react/hooks/useShippingRates.d.ts +6 -0
- package/dist/react/hooks/useShippingRates.js +38 -0
- package/dist/react/providers/TagadaProvider.js +5 -5
- package/dist/react/services/apiService.d.ts +21 -0
- package/dist/react/services/apiService.js +10 -0
- package/dist/tagada-sdk.js +2079 -179
- package/dist/tagada-sdk.min.js +4 -2
- package/dist/tagada-sdk.min.js.map +4 -4
- package/dist/v2/core/client.d.ts +4 -2
- package/dist/v2/core/client.js +4 -3
- package/dist/v2/core/errors.d.ts +75 -0
- package/dist/v2/core/errors.js +104 -0
- package/dist/v2/core/funnelClient.d.ts +16 -15
- package/dist/v2/core/funnelClient.js +1 -1
- package/dist/v2/core/index.d.ts +1 -0
- package/dist/v2/core/index.js +2 -0
- package/dist/v2/core/pixelMapping.d.ts +49 -0
- package/dist/v2/core/pixelMapping.js +325 -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 +89 -30
- package/dist/v2/core/resources/checkout.js +8 -0
- package/dist/v2/core/resources/customer.d.ts +20 -19
- package/dist/v2/core/resources/funnel.d.ts +17 -17
- package/dist/v2/core/resources/payments.d.ts +84 -13
- package/dist/v2/core/resources/payments.js +26 -9
- package/dist/v2/core/resources/shippingRates.d.ts +15 -0
- package/dist/v2/core/resources/shippingRates.js +11 -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/order.d.ts +11 -9
- package/dist/v2/core/utils/previewModeIndicator.js +101 -101
- package/dist/v2/index.d.ts +4 -2
- package/dist/v2/index.js +1 -1
- package/dist/v2/react/components/ApplePayButton.js +13 -4
- package/dist/v2/react/components/FunnelScriptInjector.js +51 -30
- package/dist/v2/react/components/WhopCheckout.d.ts +24 -0
- package/dist/v2/react/components/WhopCheckout.js +231 -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 +13 -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/useCheckoutQuery.d.ts +6 -0
- package/dist/v2/react/hooks/useCheckoutQuery.js +45 -0
- package/dist/v2/react/hooks/useFunnel.d.ts +1 -2
- 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.js +82 -33
- package/dist/v2/react/hooks/useISOData.js +1 -1
- 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 -43
- package/dist/v2/react/hooks/usePixelTracking.js +213 -407
- package/dist/v2/react/hooks/useShippingRatesQuery.d.ts +6 -0
- package/dist/v2/react/hooks/useShippingRatesQuery.js +47 -4
- package/dist/v2/react/hooks/useStepConfig.d.ts +2 -8
- package/dist/v2/react/hooks/useStepConfig.js +1 -1
- 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 +7 -0
- package/dist/v2/react/index.js +4 -0
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.d.ts +2 -1
- package/dist/v2/react/providers/ExpressPaymentMethodsProvider.js +3 -1
- package/dist/v2/react/providers/TagadaProvider.js +76 -7
- 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 +22 -0
- package/dist/v2/standalone/index.js +125 -0
- package/package.json +112 -112
- 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
package/dist/v2/core/client.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FunnelClient } from './funnelClient';
|
|
2
2
|
import { ApiClient } from './resources/apiClient';
|
|
3
|
-
import { AuthState, Currency, Customer, Environment, EnvironmentConfig, Locale, Session, Store } from './types';
|
|
3
|
+
import { AuthState, Currency, Customer, DeepPartial, Environment, EnvironmentConfig, Locale, Session, Store } from './types';
|
|
4
4
|
import { EventBus } from './utils/eventBus';
|
|
5
5
|
import { PluginConfig, RawPluginConfig } from './utils/pluginConfig';
|
|
6
6
|
export interface TagadaClientConfig {
|
|
7
7
|
environment?: Environment;
|
|
8
|
-
customApiConfig?:
|
|
8
|
+
customApiConfig?: DeepPartial<EnvironmentConfig>;
|
|
9
9
|
debugMode?: boolean;
|
|
10
10
|
localConfig?: string;
|
|
11
11
|
rawPluginConfig?: RawPluginConfig;
|
|
@@ -22,6 +22,8 @@ export interface TagadaClientConfig {
|
|
|
22
22
|
*/
|
|
23
23
|
funnel?: boolean | {
|
|
24
24
|
autoRedirect?: boolean;
|
|
25
|
+
/** Skip automatic funnel initialization (use when caller handles init explicitly) */
|
|
26
|
+
skipAutoInit?: boolean;
|
|
25
27
|
};
|
|
26
28
|
};
|
|
27
29
|
}
|
package/dist/v2/core/client.js
CHANGED
|
@@ -620,9 +620,10 @@ export class TagadaClient {
|
|
|
620
620
|
customer: response.customer ?? null,
|
|
621
621
|
auth: authState
|
|
622
622
|
});
|
|
623
|
-
// Auto-initialize funnel if enabled
|
|
624
|
-
|
|
625
|
-
|
|
623
|
+
// Auto-initialize funnel if enabled (skip when caller handles init explicitly)
|
|
624
|
+
const funnelFeature = this.config.features?.funnel;
|
|
625
|
+
const skipAutoInit = typeof funnelFeature === 'object' && funnelFeature.skipAutoInit;
|
|
626
|
+
if (this.funnel && !skipAutoInit && sessionData.customerId && response.store?.id) {
|
|
626
627
|
const accountId = response.store.accountId || this.state.pluginConfig?.accountId || sessionData.accountId || '';
|
|
627
628
|
if (accountId) {
|
|
628
629
|
// Get funnelId from URL or config
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TagadaPay SDK Error Types
|
|
3
|
+
*
|
|
4
|
+
* Structured error hierarchy for programmatic error handling.
|
|
5
|
+
* All SDK errors extend TagadaError, which extends native Error.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TagadaErrorCode: {
|
|
8
|
+
readonly NETWORK_ERROR: "network_error";
|
|
9
|
+
readonly API_ERROR: "api_error";
|
|
10
|
+
readonly AUTH_REQUIRED: "auth_required";
|
|
11
|
+
readonly TOKEN_EXPIRED: "token_expired";
|
|
12
|
+
readonly NOT_FOUND: "not_found";
|
|
13
|
+
readonly VALIDATION_ERROR: "validation_error";
|
|
14
|
+
readonly CIRCUIT_BREAKER: "circuit_breaker";
|
|
15
|
+
readonly PAYMENT_FAILED: "payment_failed";
|
|
16
|
+
readonly CARD_DECLINED: "card_declined";
|
|
17
|
+
readonly SESSION_EXPIRED: "session_expired";
|
|
18
|
+
readonly RATE_LIMITED: "rate_limited";
|
|
19
|
+
readonly TIMEOUT: "timeout";
|
|
20
|
+
readonly UNKNOWN: "unknown";
|
|
21
|
+
};
|
|
22
|
+
export type TagadaErrorCodeValue = typeof TagadaErrorCode[keyof typeof TagadaErrorCode];
|
|
23
|
+
export interface TagadaErrorOptions {
|
|
24
|
+
code: TagadaErrorCodeValue | string;
|
|
25
|
+
statusCode?: number;
|
|
26
|
+
retryable?: boolean;
|
|
27
|
+
details?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Base error class for all TagadaPay SDK errors.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* try {
|
|
35
|
+
* await checkout.applyPromotionCode(sessionId, 'SAVE10');
|
|
36
|
+
* } catch (err) {
|
|
37
|
+
* if (err instanceof TagadaError) {
|
|
38
|
+
* console.log(err.code); // 'not_found'
|
|
39
|
+
* console.log(err.statusCode); // 404
|
|
40
|
+
* console.log(err.retryable); // false
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class TagadaError extends Error {
|
|
46
|
+
readonly code: string;
|
|
47
|
+
readonly statusCode?: number;
|
|
48
|
+
readonly retryable: boolean;
|
|
49
|
+
readonly details?: Record<string, unknown>;
|
|
50
|
+
constructor(message: string, options: TagadaErrorOptions);
|
|
51
|
+
}
|
|
52
|
+
/** API returned a non-2xx response with an error body. */
|
|
53
|
+
export declare class TagadaApiError extends TagadaError {
|
|
54
|
+
constructor(message: string, statusCode: number, options?: {
|
|
55
|
+
code?: string;
|
|
56
|
+
details?: Record<string, unknown>;
|
|
57
|
+
retryable?: boolean;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** Network-level failure (no response received). */
|
|
61
|
+
export declare class TagadaNetworkError extends TagadaError {
|
|
62
|
+
constructor(message?: string);
|
|
63
|
+
}
|
|
64
|
+
/** 401/403 — authentication or authorization failure. */
|
|
65
|
+
export declare class TagadaAuthError extends TagadaError {
|
|
66
|
+
constructor(message?: string, statusCode?: number);
|
|
67
|
+
}
|
|
68
|
+
/** Input validation failed (client-side or 400 from server). */
|
|
69
|
+
export declare class TagadaValidationError extends TagadaError {
|
|
70
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
71
|
+
}
|
|
72
|
+
/** Circuit breaker tripped — too many requests in a short window. */
|
|
73
|
+
export declare class TagadaCircuitBreakerError extends TagadaError {
|
|
74
|
+
constructor(message: string);
|
|
75
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TagadaPay SDK Error Types
|
|
3
|
+
*
|
|
4
|
+
* Structured error hierarchy for programmatic error handling.
|
|
5
|
+
* All SDK errors extend TagadaError, which extends native Error.
|
|
6
|
+
*/
|
|
7
|
+
export const TagadaErrorCode = {
|
|
8
|
+
NETWORK_ERROR: 'network_error',
|
|
9
|
+
API_ERROR: 'api_error',
|
|
10
|
+
AUTH_REQUIRED: 'auth_required',
|
|
11
|
+
TOKEN_EXPIRED: 'token_expired',
|
|
12
|
+
NOT_FOUND: 'not_found',
|
|
13
|
+
VALIDATION_ERROR: 'validation_error',
|
|
14
|
+
CIRCUIT_BREAKER: 'circuit_breaker',
|
|
15
|
+
PAYMENT_FAILED: 'payment_failed',
|
|
16
|
+
CARD_DECLINED: 'card_declined',
|
|
17
|
+
SESSION_EXPIRED: 'session_expired',
|
|
18
|
+
RATE_LIMITED: 'rate_limited',
|
|
19
|
+
TIMEOUT: 'timeout',
|
|
20
|
+
UNKNOWN: 'unknown',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Base error class for all TagadaPay SDK errors.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* try {
|
|
28
|
+
* await checkout.applyPromotionCode(sessionId, 'SAVE10');
|
|
29
|
+
* } catch (err) {
|
|
30
|
+
* if (err instanceof TagadaError) {
|
|
31
|
+
* console.log(err.code); // 'not_found'
|
|
32
|
+
* console.log(err.statusCode); // 404
|
|
33
|
+
* console.log(err.retryable); // false
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export class TagadaError extends Error {
|
|
39
|
+
constructor(message, options) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = 'TagadaError';
|
|
42
|
+
this.code = options.code;
|
|
43
|
+
this.statusCode = options.statusCode;
|
|
44
|
+
this.retryable = options.retryable ?? false;
|
|
45
|
+
this.details = options.details;
|
|
46
|
+
// Maintain proper prototype chain for instanceof checks
|
|
47
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** API returned a non-2xx response with an error body. */
|
|
51
|
+
export class TagadaApiError extends TagadaError {
|
|
52
|
+
constructor(message, statusCode, options) {
|
|
53
|
+
super(message, {
|
|
54
|
+
code: options?.code ?? TagadaErrorCode.API_ERROR,
|
|
55
|
+
statusCode,
|
|
56
|
+
retryable: options?.retryable ?? (statusCode >= 500),
|
|
57
|
+
details: options?.details,
|
|
58
|
+
});
|
|
59
|
+
this.name = 'TagadaApiError';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Network-level failure (no response received). */
|
|
63
|
+
export class TagadaNetworkError extends TagadaError {
|
|
64
|
+
constructor(message = 'Network request failed') {
|
|
65
|
+
super(message, {
|
|
66
|
+
code: TagadaErrorCode.NETWORK_ERROR,
|
|
67
|
+
retryable: true,
|
|
68
|
+
});
|
|
69
|
+
this.name = 'TagadaNetworkError';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** 401/403 — authentication or authorization failure. */
|
|
73
|
+
export class TagadaAuthError extends TagadaError {
|
|
74
|
+
constructor(message = 'Authentication required', statusCode = 401) {
|
|
75
|
+
super(message, {
|
|
76
|
+
code: TagadaErrorCode.AUTH_REQUIRED,
|
|
77
|
+
statusCode,
|
|
78
|
+
retryable: false,
|
|
79
|
+
});
|
|
80
|
+
this.name = 'TagadaAuthError';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Input validation failed (client-side or 400 from server). */
|
|
84
|
+
export class TagadaValidationError extends TagadaError {
|
|
85
|
+
constructor(message, details) {
|
|
86
|
+
super(message, {
|
|
87
|
+
code: TagadaErrorCode.VALIDATION_ERROR,
|
|
88
|
+
statusCode: 400,
|
|
89
|
+
retryable: false,
|
|
90
|
+
details,
|
|
91
|
+
});
|
|
92
|
+
this.name = 'TagadaValidationError';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Circuit breaker tripped — too many requests in a short window. */
|
|
96
|
+
export class TagadaCircuitBreakerError extends TagadaError {
|
|
97
|
+
constructor(message) {
|
|
98
|
+
super(message, {
|
|
99
|
+
code: TagadaErrorCode.CIRCUIT_BREAKER,
|
|
100
|
+
retryable: false,
|
|
101
|
+
});
|
|
102
|
+
this.name = 'TagadaCircuitBreakerError';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -9,7 +9,7 @@ export declare enum TrackingProvider {
|
|
|
9
9
|
FACEBOOK = "facebook",
|
|
10
10
|
TIKTOK = "tiktok",
|
|
11
11
|
SNAPCHAT = "snapchat",
|
|
12
|
-
|
|
12
|
+
PINTEREST = "pinterest",
|
|
13
13
|
GTM = "gtm"
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -65,12 +65,25 @@ export interface GTMTrackingConfig extends BaseTrackingConfig {
|
|
|
65
65
|
AddToCart: boolean;
|
|
66
66
|
ViewContent: boolean;
|
|
67
67
|
};
|
|
68
|
+
googleAdsConversionId?: string;
|
|
69
|
+
googleAdsConversionLabel?: string;
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
72
|
* Union of all tracking configs.
|
|
71
73
|
* This mirrors `TrackingFormValues` from the CRM.
|
|
72
74
|
*/
|
|
73
75
|
export type PixelConfig = PixelTrackingConfig | SnapchatTrackingConfig | MetaConversionTrackingConfig | GTMTrackingConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Pixels configuration keyed by provider.
|
|
78
|
+
* Used in RuntimeStepConfig and getAssignedPixels().
|
|
79
|
+
*/
|
|
80
|
+
export type PixelsConfig = {
|
|
81
|
+
[TrackingProvider.FACEBOOK]?: PixelTrackingConfig[];
|
|
82
|
+
[TrackingProvider.TIKTOK]?: PixelTrackingConfig[];
|
|
83
|
+
[TrackingProvider.SNAPCHAT]?: SnapchatTrackingConfig[];
|
|
84
|
+
[TrackingProvider.PINTEREST]?: PixelTrackingConfig[];
|
|
85
|
+
[TrackingProvider.GTM]?: GTMTrackingConfig[];
|
|
86
|
+
};
|
|
74
87
|
/**
|
|
75
88
|
* Runtime step configuration injected from the CRM
|
|
76
89
|
* Contains payment flows, static resources, scripts, and tracking configs
|
|
@@ -86,13 +99,7 @@ export interface RuntimeStepConfig {
|
|
|
86
99
|
content: string;
|
|
87
100
|
position?: 'head-start' | 'head-end' | 'body-start' | 'body-end';
|
|
88
101
|
}>;
|
|
89
|
-
pixels?:
|
|
90
|
-
[TrackingProvider.FACEBOOK]?: PixelTrackingConfig[];
|
|
91
|
-
[TrackingProvider.TIKTOK]?: PixelTrackingConfig[];
|
|
92
|
-
[TrackingProvider.SNAPCHAT]?: SnapchatTrackingConfig[];
|
|
93
|
-
[TrackingProvider.META_CONVERSION]?: MetaConversionTrackingConfig[];
|
|
94
|
-
[TrackingProvider.GTM]?: GTMTrackingConfig[];
|
|
95
|
-
};
|
|
102
|
+
pixels?: PixelsConfig;
|
|
96
103
|
}
|
|
97
104
|
/**
|
|
98
105
|
* Local funnel configuration for development
|
|
@@ -165,13 +172,7 @@ export declare function getAssignedScripts(position?: 'head-start' | 'head-end'
|
|
|
165
172
|
* Get assigned pixel tracking configuration (normalized to arrays)
|
|
166
173
|
* Always returns arrays of PixelConfig for consistent consumption.
|
|
167
174
|
*/
|
|
168
|
-
export declare function getAssignedPixels():
|
|
169
|
-
[TrackingProvider.FACEBOOK]?: PixelTrackingConfig[];
|
|
170
|
-
[TrackingProvider.TIKTOK]?: PixelTrackingConfig[];
|
|
171
|
-
[TrackingProvider.SNAPCHAT]?: SnapchatTrackingConfig[];
|
|
172
|
-
[TrackingProvider.META_CONVERSION]?: MetaConversionTrackingConfig[];
|
|
173
|
-
[TrackingProvider.GTM]?: GTMTrackingConfig[];
|
|
174
|
-
} | undefined;
|
|
175
|
+
export declare function getAssignedPixels(): PixelsConfig | undefined;
|
|
175
176
|
export interface FunnelClientConfig {
|
|
176
177
|
apiClient: ApiClient;
|
|
177
178
|
debugMode?: boolean;
|
|
@@ -13,7 +13,7 @@ export var TrackingProvider;
|
|
|
13
13
|
TrackingProvider["FACEBOOK"] = "facebook";
|
|
14
14
|
TrackingProvider["TIKTOK"] = "tiktok";
|
|
15
15
|
TrackingProvider["SNAPCHAT"] = "snapchat";
|
|
16
|
-
TrackingProvider["
|
|
16
|
+
TrackingProvider["PINTEREST"] = "pinterest";
|
|
17
17
|
TrackingProvider["GTM"] = "gtm";
|
|
18
18
|
})(TrackingProvider || (TrackingProvider = {}));
|
|
19
19
|
/**
|
package/dist/v2/core/index.d.ts
CHANGED
package/dist/v2/core/index.js
CHANGED
|
@@ -11,6 +11,8 @@ export * from './client';
|
|
|
11
11
|
export * from './funnelClient';
|
|
12
12
|
// Export path remapping helpers (framework-agnostic)
|
|
13
13
|
export * from './pathRemapping';
|
|
14
|
+
// Export pixel mapping (framework-agnostic, shared by React + standalone)
|
|
15
|
+
export * from './pixelMapping';
|
|
14
16
|
// Export legacy files that are still needed
|
|
15
17
|
export * from './googleAutocomplete';
|
|
16
18
|
export * from './isoData';
|
|
@@ -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[];
|