@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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Manages express payment methods (Apple Pay, Google Pay, PayPal, Klarna)
|
|
4
4
|
*/
|
|
5
5
|
import React, { ReactNode } from 'react';
|
|
6
|
+
import { TagadaError } from '../../core/errors';
|
|
6
7
|
import { CheckoutData } from '../../core/resources/checkout';
|
|
7
8
|
import { Address, PaymentMethod } from '../../core/resources/expressPaymentMethods';
|
|
8
9
|
type ExpressOrderLineItem = {
|
|
@@ -21,6 +22,7 @@ interface ExpressPaymentMethodsContextType {
|
|
|
21
22
|
googlePayPaymentMethod?: PaymentMethod;
|
|
22
23
|
paypalPaymentMethod?: PaymentMethod;
|
|
23
24
|
klarnaPaymentMethod?: PaymentMethod;
|
|
25
|
+
stripeExpressPaymentMethod?: PaymentMethod;
|
|
24
26
|
availableExpressPaymentMethodIds: string[];
|
|
25
27
|
setAvailableExpressPaymentMethodIds: (value: string[]) => void;
|
|
26
28
|
handleAddExpressId: (id: string) => void;
|
|
@@ -47,7 +49,7 @@ interface ExpressPaymentMethodsContextType {
|
|
|
47
49
|
};
|
|
48
50
|
}) => Promise<void>;
|
|
49
51
|
loading?: boolean;
|
|
50
|
-
error:
|
|
52
|
+
error: TagadaError | null;
|
|
51
53
|
setError: (error: string | null) => void;
|
|
52
54
|
}
|
|
53
55
|
interface ExpressPaymentMethodsProviderProps {
|
|
@@ -5,6 +5,7 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
7
7
|
import { createContext, useCallback, useMemo, useState } from 'react';
|
|
8
|
+
import { TagadaError, TagadaErrorCode } from '../../core/errors';
|
|
8
9
|
import { ExpressPaymentMethodsResource, } from '../../core/resources/expressPaymentMethods';
|
|
9
10
|
import { getGlobalApiClient } from '../hooks/useApiQuery';
|
|
10
11
|
import { useShippingRatesQuery } from '../hooks/useShippingRatesQuery';
|
|
@@ -169,7 +170,15 @@ export const ExpressPaymentMethodsProvider = ({ children, customerId, checkout,
|
|
|
169
170
|
const googlePayPaymentMethod = useMemo(() => paymentMethods?.find((p) => p.type === 'google_pay'), [paymentMethods]);
|
|
170
171
|
const paypalPaymentMethod = useMemo(() => paymentMethods?.find((p) => p.type === 'paypal'), [paymentMethods]);
|
|
171
172
|
const klarnaPaymentMethod = useMemo(() => paymentMethods?.find((p) => p.type === 'klarna'), [paymentMethods]);
|
|
173
|
+
// Find a stripe_apm or tagadapay_apm integration with any express method enabled in any processor group.
|
|
174
|
+
// Backward compatible: existing configs with only apple_pay/google_pay continue to match.
|
|
175
|
+
const stripeExpressPaymentMethod = useMemo(() => {
|
|
176
|
+
const EXPRESS_METHOD_KEYS = ['apple_pay', 'google_pay', 'paypal', 'link', 'klarna_express'];
|
|
177
|
+
return paymentMethods?.find((p) => (p.type === 'stripe_apm' || p.type === 'tagadapay_apm') &&
|
|
178
|
+
p.settings?.processors?.some((g) => EXPRESS_METHOD_KEYS.some((key) => g?.methods?.[key]?.enabled === true)));
|
|
179
|
+
}, [paymentMethods]);
|
|
172
180
|
const loading = !paymentMethods || isLoadingPaymentMethods;
|
|
181
|
+
const tagadaError = useMemo(() => error ? new TagadaError(error, { code: TagadaErrorCode.PAYMENT_FAILED }) : null, [error]);
|
|
173
182
|
const contextValue = {
|
|
174
183
|
paymentMethods,
|
|
175
184
|
availableExpressPaymentMethodIds,
|
|
@@ -178,6 +187,7 @@ export const ExpressPaymentMethodsProvider = ({ children, customerId, checkout,
|
|
|
178
187
|
googlePayPaymentMethod,
|
|
179
188
|
paypalPaymentMethod,
|
|
180
189
|
klarnaPaymentMethod,
|
|
190
|
+
stripeExpressPaymentMethod,
|
|
181
191
|
shippingMethods,
|
|
182
192
|
lineItems,
|
|
183
193
|
reComputeOrderSummary,
|
|
@@ -185,9 +195,9 @@ export const ExpressPaymentMethodsProvider = ({ children, customerId, checkout,
|
|
|
185
195
|
handleAddExpressId,
|
|
186
196
|
updateCheckoutSessionValues,
|
|
187
197
|
updateCustomerEmail,
|
|
188
|
-
error,
|
|
198
|
+
error: tagadaError,
|
|
189
199
|
setError,
|
|
190
200
|
};
|
|
191
|
-
const hasAnyEnabled = Boolean(applePayPaymentMethod || googlePayPaymentMethod || paypalPaymentMethod || klarnaPaymentMethod);
|
|
201
|
+
const hasAnyEnabled = Boolean(applePayPaymentMethod || googlePayPaymentMethod || paypalPaymentMethod || klarnaPaymentMethod || stripeExpressPaymentMethod);
|
|
192
202
|
return (_jsx(ExpressPaymentMethodsContext.Provider, { value: contextValue, children: hasAnyEnabled ? _jsx(_Fragment, { children: children }) : _jsx(_Fragment, {}) }));
|
|
193
203
|
};
|
|
@@ -4,14 +4,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
4
4
|
* TagadaProvider - Main provider component for the Tagada Pay React SDK
|
|
5
5
|
*/
|
|
6
6
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
7
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
7
|
+
import { Suspense, createContext, lazy, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
8
8
|
import { ApiService } from '../../../react/services/apiService';
|
|
9
9
|
import { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits, } from '../../../react/utils/money';
|
|
10
10
|
import { TagadaClient } from '../../core/client';
|
|
11
|
-
import { default as DebugDrawer } from '../components/DebugDrawer';
|
|
12
|
-
import { FunnelScriptInjector } from '../components/FunnelScriptInjector';
|
|
13
11
|
import { setGlobalApiClient } from '../hooks/useApiQuery';
|
|
14
12
|
import { PixelTrackingProvider } from '../hooks/usePixelTracking';
|
|
13
|
+
const FunnelScriptInjector = lazy(() => import('../components/FunnelScriptInjector').then(m => ({ default: m.FunnelScriptInjector })));
|
|
14
|
+
const DebugDrawer = lazy(() => import('../components/DebugDrawer'));
|
|
15
15
|
// Professional, subtle loading component for initialization
|
|
16
16
|
const InitializationLoader = () => (_jsxs("div", { style: {
|
|
17
17
|
position: 'fixed',
|
|
@@ -213,6 +213,75 @@ export function TagadaProvider({ children, environment, customApiConfig, debugMo
|
|
|
213
213
|
formatSimpleMoney,
|
|
214
214
|
}), []);
|
|
215
215
|
const [isDebugDrawerOpen, setIsDebugDrawerOpen] = useState(false);
|
|
216
|
+
// Track last injected script to prevent duplicate execution
|
|
217
|
+
/**
|
|
218
|
+
* Editor Element Click Bridge (Iframe → Parent)
|
|
219
|
+
*
|
|
220
|
+
* When running inside the CRM config editor iframe, elements can declare an `editor-id`
|
|
221
|
+
* attribute (e.g. <h1 editor-id="config.texts.checkoutTitle">Title</h1>).
|
|
222
|
+
*
|
|
223
|
+
* This effect sets up a delegated click listener on `document` that:
|
|
224
|
+
* - Finds the closest ancestor with an `editor-id`
|
|
225
|
+
* - Sends a `postMessage` to `window.parent` with the editorId and text content
|
|
226
|
+
*
|
|
227
|
+
* The parent (ConfigEditor) can then map this back to the corresponding config field.
|
|
228
|
+
*/
|
|
229
|
+
useEffect(() => {
|
|
230
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const handleClick = (event) => {
|
|
234
|
+
if (!(event.target instanceof Element))
|
|
235
|
+
return;
|
|
236
|
+
const targetWithEditorId = event.target.closest('[editor-id]');
|
|
237
|
+
if (!targetWithEditorId)
|
|
238
|
+
return;
|
|
239
|
+
const editorId = targetWithEditorId.getAttribute('editor-id');
|
|
240
|
+
if (!editorId)
|
|
241
|
+
return;
|
|
242
|
+
const textContent = targetWithEditorId.textContent ?? '';
|
|
243
|
+
// Only attempt cross-window messaging when inside an iframe
|
|
244
|
+
const isInIframe = window.parent && window.parent !== window;
|
|
245
|
+
if (!isInIframe) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const message = {
|
|
249
|
+
type: 'TAGADAPAY_EDITOR_ELEMENT_CLICK',
|
|
250
|
+
editorId,
|
|
251
|
+
textContent,
|
|
252
|
+
};
|
|
253
|
+
try {
|
|
254
|
+
// Derive parent origin from document.referrer when possible; fall back to '*'
|
|
255
|
+
// This avoids postMessage origin mismatch errors in dev (e.g. 3001 ↔ 5173)
|
|
256
|
+
let targetOrigin = '*';
|
|
257
|
+
try {
|
|
258
|
+
if (typeof document !== 'undefined' && document.referrer) {
|
|
259
|
+
const url = new URL(document.referrer);
|
|
260
|
+
targetOrigin = url.origin;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
// Fallback to '*'
|
|
265
|
+
targetOrigin = '*';
|
|
266
|
+
}
|
|
267
|
+
window.parent.postMessage(message, targetOrigin);
|
|
268
|
+
if (state.debugMode) {
|
|
269
|
+
// eslint-disable-next-line no-console
|
|
270
|
+
console.log('[TagadaProvider] Sent editor element click to parent:', message);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
if (state.debugMode) {
|
|
275
|
+
// eslint-disable-next-line no-console
|
|
276
|
+
console.error('[TagadaProvider] Failed to post editor element click message:', error);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
document.addEventListener('click', handleClick, true);
|
|
281
|
+
return () => {
|
|
282
|
+
document.removeEventListener('click', handleClick, true);
|
|
283
|
+
};
|
|
284
|
+
}, [state.debugMode]);
|
|
216
285
|
// Funnel Methods
|
|
217
286
|
const funnelMethods = useMemo(() => {
|
|
218
287
|
if (!client.funnel) {
|
|
@@ -320,7 +389,7 @@ export function TagadaProvider({ children, environment, customApiConfig, debugMo
|
|
|
320
389
|
// Loading State Logic
|
|
321
390
|
const shouldShowLoading = state.isLoading || state.pluginConfigLoading || (blockUntilSessionReady && !state.isSessionInitialized);
|
|
322
391
|
const canRenderChildren = !state.pluginConfigLoading && (!blockUntilSessionReady || state.isSessionInitialized);
|
|
323
|
-
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(TagadaContext.Provider, { value: contextValue, children: _jsxs(PixelTrackingProvider, { children: [_jsx(FunnelScriptInjector, { ...funnelState }), shouldShowLoading && _jsx(InitializationLoader, {}), state.debugMode && canRenderChildren && (_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => setIsDebugDrawerOpen(true), style: {
|
|
392
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(TagadaContext.Provider, { value: contextValue, children: _jsxs(PixelTrackingProvider, { children: [_jsx(Suspense, { fallback: null, children: _jsx(FunnelScriptInjector, { ...funnelState }) }), shouldShowLoading && _jsx(InitializationLoader, {}), state.debugMode && canRenderChildren && (_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => setIsDebugDrawerOpen(true), style: {
|
|
324
393
|
position: 'fixed',
|
|
325
394
|
bottom: '16px',
|
|
326
395
|
right: '16px',
|
|
@@ -335,7 +404,7 @@ export function TagadaProvider({ children, environment, customApiConfig, debugMo
|
|
|
335
404
|
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.3)',
|
|
336
405
|
zIndex: 999997,
|
|
337
406
|
transition: 'all 0.2s ease',
|
|
338
|
-
}, title: "Open TagadaPay SDK Debug Panel", children: "\uD83D\uDC1B" }), _jsx(DebugDrawer, { isOpen: isDebugDrawerOpen, onClose: () => setIsDebugDrawerOpen(false) })] })), canRenderChildren && children] }) }) }));
|
|
407
|
+
}, title: "Open TagadaPay SDK Debug Panel", children: "\uD83D\uDC1B" }), _jsx(Suspense, { fallback: null, children: _jsx(DebugDrawer, { isOpen: isDebugDrawerOpen, onClose: () => setIsDebugDrawerOpen(false) }) })] })), canRenderChildren && children] }) }) }));
|
|
339
408
|
}
|
|
340
409
|
export function useTagadaContext() {
|
|
341
410
|
const context = useContext(TagadaContext);
|
|
@@ -1,59 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TagadaPay External Page Tracker
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Standalone script for tracking users on external pages that are part of a
|
|
5
|
+
* TagadaPay funnel but not hosted on the TagadaPay platform.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Use cases:
|
|
8
|
+
* - WooCommerce / WordPress storefronts
|
|
9
|
+
* - Custom landing pages
|
|
10
|
+
* - Any external page that is a funnel step
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* @example CDN usage
|
|
13
|
+
* ```html
|
|
13
14
|
* <script src="https://cdn.jsdelivr.net/npm/@tagadapay/plugin-sdk/dist/external-tracker.min.js"></script>
|
|
14
15
|
* <script>
|
|
15
16
|
* TagadaTracker.init({
|
|
16
17
|
* storeId: 'store_xxx',
|
|
17
18
|
* accountId: 'acc_xxx',
|
|
18
|
-
* funnelId: 'funnel_xxx', // Optional: detected from URL
|
|
19
19
|
* stepId: 'step_xxx',
|
|
20
|
-
* stepName: 'External Offer Page',
|
|
21
|
-
* stepType: 'external'
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* // Navigate to next step (tracking automatic)
|
|
25
|
-
* TagadaTracker.navigate({
|
|
26
|
-
* eventType: 'form.submitted',
|
|
27
|
-
* eventData: { email: 'user@example.com' }
|
|
28
20
|
* });
|
|
29
21
|
* </script>
|
|
22
|
+
* ```
|
|
30
23
|
*/
|
|
31
24
|
import type { TagadaClient } from '../core/client';
|
|
25
|
+
export declare const TRACKER_VERSION = "1.0.0";
|
|
32
26
|
export interface TagadaTrackerConfig {
|
|
33
27
|
/** Store ID (required) */
|
|
34
28
|
storeId: string;
|
|
35
|
-
/** Account ID (required
|
|
36
|
-
accountId
|
|
37
|
-
/** Funnel ID (optional
|
|
29
|
+
/** Account ID (required — session init will fail without it) */
|
|
30
|
+
accountId: string;
|
|
31
|
+
/** Funnel ID (optional — can be extracted from URL param) */
|
|
38
32
|
funnelId?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Step ID (REQUIRED for external pages)
|
|
41
|
-
*
|
|
42
|
-
* External URLs cannot be mapped to steps via URL matching (only works for Tagadapay-hosted pages).
|
|
43
|
-
* You must explicitly specify which step this external page represents.
|
|
44
|
-
*/
|
|
33
|
+
/** Step ID (required for external pages — URL-to-step mapping only works for TagadaPay-hosted pages) */
|
|
45
34
|
stepId: string;
|
|
46
|
-
/** Step name (optional
|
|
35
|
+
/** Step name (optional — for analytics/debugging) */
|
|
47
36
|
stepName?: string;
|
|
48
|
-
/** Step type (optional
|
|
37
|
+
/** Step type (optional — e.g., 'landing', 'offer', 'external') */
|
|
49
38
|
stepType?: string;
|
|
50
|
-
/** API base URL (defaults to
|
|
39
|
+
/** API base URL (defaults to https://app.tagadapay.com) */
|
|
51
40
|
apiBaseUrl?: string;
|
|
52
41
|
/** Enable debug logging */
|
|
53
42
|
debug?: boolean;
|
|
54
43
|
/** Callback when session is ready */
|
|
55
44
|
onReady?: (session: ExternalTrackerSession) => void;
|
|
56
|
-
/** Callback on error */
|
|
45
|
+
/** Callback on error — when provided, init() will NOT throw */
|
|
57
46
|
onError?: (error: Error) => void;
|
|
58
47
|
}
|
|
59
48
|
export interface ExternalTrackerSession {
|
|
@@ -71,49 +60,66 @@ export interface NavigateOptions {
|
|
|
71
60
|
eventData?: Record<string, unknown>;
|
|
72
61
|
/** Override return URL */
|
|
73
62
|
returnUrl?: string;
|
|
74
|
-
/**
|
|
63
|
+
/** Whether to auto-redirect after navigation (default: true) */
|
|
75
64
|
autoRedirect?: boolean;
|
|
76
65
|
}
|
|
66
|
+
export interface TrackEventOptions {
|
|
67
|
+
/** Event name (e.g., 'button_click', 'scroll_depth', 'video_play') */
|
|
68
|
+
name: string;
|
|
69
|
+
/** Arbitrary event data */
|
|
70
|
+
data?: Record<string, unknown>;
|
|
71
|
+
}
|
|
77
72
|
declare class TagadaExternalTracker {
|
|
78
73
|
private config;
|
|
79
74
|
private client;
|
|
80
75
|
private initialized;
|
|
81
76
|
private initializing;
|
|
77
|
+
private unsubscribe;
|
|
78
|
+
/** Tracker version */
|
|
79
|
+
readonly version = "1.0.0";
|
|
82
80
|
/**
|
|
83
|
-
* Initialize the tracker
|
|
81
|
+
* Initialize the tracker.
|
|
82
|
+
* When `onError` is provided, errors are passed to the callback and init()
|
|
83
|
+
* resolves to `null` instead of throwing.
|
|
84
84
|
*/
|
|
85
85
|
init(config: TagadaTrackerConfig): Promise<ExternalTrackerSession | null>;
|
|
86
|
-
/**
|
|
87
|
-
* Get current session from SDK state
|
|
88
|
-
*/
|
|
86
|
+
/** Get current session data. */
|
|
89
87
|
getSession(): ExternalTrackerSession | null;
|
|
90
|
-
/**
|
|
91
|
-
* Check if tracker is ready
|
|
92
|
-
*/
|
|
88
|
+
/** Whether the tracker is fully initialized and ready. */
|
|
93
89
|
isReady(): boolean;
|
|
94
90
|
/**
|
|
95
|
-
* Navigate to next step in
|
|
91
|
+
* Navigate to the next step in the funnel.
|
|
92
|
+
* By default, auto-redirects the browser window.
|
|
96
93
|
*/
|
|
97
94
|
navigate(options: NavigateOptions): Promise<{
|
|
98
95
|
url: string;
|
|
99
96
|
} | null>;
|
|
100
97
|
/**
|
|
101
|
-
*
|
|
98
|
+
* Track a custom event (e.g., button click, scroll depth, video play).
|
|
99
|
+
* Events are sent through the funnel orchestrator for unified analytics.
|
|
102
100
|
*/
|
|
101
|
+
trackEvent(options: TrackEventOptions): Promise<void>;
|
|
102
|
+
/** Get customer ID. */
|
|
103
103
|
getCustomerId(): string | null;
|
|
104
|
-
/**
|
|
105
|
-
* Get funnel session ID
|
|
106
|
-
*/
|
|
104
|
+
/** Get funnel session ID. */
|
|
107
105
|
getFunnelSessionId(): string | null;
|
|
108
106
|
/**
|
|
109
|
-
* Build a URL
|
|
110
|
-
*
|
|
107
|
+
* Build a URL that preserves funnel session context.
|
|
108
|
+
* Use this to link to other external pages within the same funnel.
|
|
111
109
|
*/
|
|
112
110
|
buildUrl(baseUrl: string, additionalParams?: Record<string, string>): string;
|
|
111
|
+
/** Get the underlying SDK client (advanced usage). */
|
|
112
|
+
getClient(): TagadaClient | null;
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* Reset the tracker to a new step without re-creating the session.
|
|
115
|
+
* Useful for SPAs that navigate between funnel steps client-side.
|
|
115
116
|
*/
|
|
116
|
-
|
|
117
|
+
reset(newStepId: string): Promise<ExternalTrackerSession | null>;
|
|
118
|
+
/**
|
|
119
|
+
* Destroy the tracker, clean up event listeners and state.
|
|
120
|
+
* Call this when the tracker is no longer needed (e.g., SPA teardown).
|
|
121
|
+
*/
|
|
122
|
+
destroy(): void;
|
|
117
123
|
private waitForClientReady;
|
|
118
124
|
private initializeFunnel;
|
|
119
125
|
}
|