@tagadapay/plugin-sdk 2.8.1 → 2.8.4

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.
@@ -3,34 +3,43 @@
3
3
  */
4
4
  import { ApiClient } from './apiClient';
5
5
  /**
6
- * Funnel event types enum
6
+ * Funnel action types enum
7
7
  *
8
8
  * Special types:
9
9
  * - DIRECT_NAVIGATION: Bypasses step conditions, navigates directly to targetStepId
10
10
  * - BACK_NAVIGATION: Similar to direct_navigation, used for backward navigation
11
11
  *
12
12
  * Common types (for logging/tracking):
13
- * - Any string value is accepted, but these are commonly used examples
13
+ * - These are commonly used action types that align with funnel orchestrator conditions
14
+ * - Navigation logic is based on step conditions.from, action types are primarily for analytics
14
15
  */
15
- export declare enum FunnelEventType {
16
+ export declare enum FunnelActionType {
16
17
  DIRECT_NAVIGATION = "direct_navigation",
17
18
  BACK_NAVIGATION = "back_navigation",
19
+ CONTINUE_CLICKED = "continue_clicked",
20
+ BUTTON_CLICK = "button_click",
21
+ FORM_SUBMIT = "form_submit",
18
22
  PAYMENT_SUCCESS = "payment_success",
23
+ PAYMENT_FAILED = "payment_failed",
24
+ OFFER_ACCEPTED = "offer_accepted",
25
+ OFFER_DECLINED = "offer_declined",
26
+ CART_UPDATED = "cart_updated",
27
+ CART_ITEM_ADDED = "cart_item_added",
19
28
  CUSTOM = "custom"
20
29
  }
21
30
  /**
22
- * Data structures for specific event types
31
+ * Data structures for specific action types
23
32
  */
24
- export type NextEvent<T> = T & {
33
+ export type NextAction<T> = T & {
25
34
  [key: string]: any;
26
35
  };
27
- export interface DirectNavigationEventData {
36
+ export interface DirectNavigationActionData {
28
37
  targetStepId: string;
29
38
  }
30
- export interface BackNavigationEventData {
39
+ export interface BackNavigationActionData {
31
40
  targetStepId: string;
32
41
  }
33
- export interface PaymentSuccessEventData {
42
+ export interface PaymentSuccessActionData {
34
43
  payment: {
35
44
  id: string;
36
45
  status: string;
@@ -46,12 +55,53 @@ export interface PaymentSuccessEventData {
46
55
  };
47
56
  [key: string]: any;
48
57
  }
58
+ export interface PaymentFailedActionData {
59
+ payment: {
60
+ id: string;
61
+ status: string;
62
+ error?: string;
63
+ [key: string]: any;
64
+ };
65
+ [key: string]: any;
66
+ }
67
+ export interface OfferAcceptedActionData {
68
+ offer: {
69
+ accepted: boolean;
70
+ offerId?: string;
71
+ [key: string]: any;
72
+ };
73
+ [key: string]: any;
74
+ }
75
+ export interface OfferDeclinedActionData {
76
+ offer: {
77
+ declined: boolean;
78
+ offerId?: string;
79
+ [key: string]: any;
80
+ };
81
+ [key: string]: any;
82
+ }
83
+ export interface CartUpdatedActionData {
84
+ cart: {
85
+ hasSpecificItem?: boolean;
86
+ itemIds?: string[];
87
+ variantIds?: string[];
88
+ total?: number;
89
+ [key: string]: any;
90
+ };
91
+ [key: string]: any;
92
+ }
93
+ export interface FormSubmitActionData {
94
+ form?: {
95
+ [key: string]: any;
96
+ };
97
+ [key: string]: any;
98
+ }
49
99
  /**
50
- * Base properties shared by all FunnelEvent types
100
+ * Base properties shared by all FunnelAction types
51
101
  */
52
- interface BaseFunnelEvent {
102
+ interface BaseFunnelAction {
53
103
  /**
54
- * Event timestamp (ISO string format)
104
+ * Action timestamp (ISO string format)
55
105
  */
56
106
  timestamp?: string;
57
107
  /**
@@ -62,20 +112,44 @@ interface BaseFunnelEvent {
62
112
  currentUrl?: string;
63
113
  }
64
114
  /**
65
- * Discriminated union for FunnelEvent based on event type
115
+ * Discriminated union for FunnelAction based on action type
66
116
  */
67
- export type FunnelAction = BaseFunnelEvent & (({
68
- type: FunnelEventType.DIRECT_NAVIGATION;
69
- data: NextEvent<DirectNavigationEventData>;
117
+ export type FunnelAction = BaseFunnelAction & (({
118
+ type: FunnelActionType.DIRECT_NAVIGATION;
119
+ data: NextAction<DirectNavigationActionData>;
120
+ }) | ({
121
+ type: FunnelActionType.BACK_NAVIGATION;
122
+ data: NextAction<BackNavigationActionData>;
123
+ }) | ({
124
+ type: FunnelActionType.CONTINUE_CLICKED;
125
+ data?: NextAction<any>;
126
+ }) | ({
127
+ type: FunnelActionType.BUTTON_CLICK;
128
+ data?: NextAction<any>;
129
+ }) | ({
130
+ type: FunnelActionType.FORM_SUBMIT;
131
+ data?: NextAction<FormSubmitActionData>;
132
+ }) | ({
133
+ type: FunnelActionType.PAYMENT_SUCCESS;
134
+ data: NextAction<PaymentSuccessActionData>;
135
+ }) | ({
136
+ type: FunnelActionType.PAYMENT_FAILED;
137
+ data?: NextAction<PaymentFailedActionData>;
138
+ }) | ({
139
+ type: FunnelActionType.OFFER_ACCEPTED;
140
+ data?: NextAction<OfferAcceptedActionData>;
141
+ }) | ({
142
+ type: FunnelActionType.OFFER_DECLINED;
143
+ data?: NextAction<OfferDeclinedActionData>;
70
144
  }) | ({
71
- type: FunnelEventType.BACK_NAVIGATION;
72
- data: NextEvent<BackNavigationEventData>;
145
+ type: FunnelActionType.CART_UPDATED;
146
+ data?: NextAction<CartUpdatedActionData>;
73
147
  }) | ({
74
- type: FunnelEventType.PAYMENT_SUCCESS;
75
- data: NextEvent<PaymentSuccessEventData>;
148
+ type: FunnelActionType.CART_ITEM_ADDED;
149
+ data?: NextAction<CartUpdatedActionData>;
76
150
  }) | ({
77
- type: FunnelEventType.CUSTOM;
78
- data?: NextEvent<any>;
151
+ type: FunnelActionType.CUSTOM;
152
+ data?: NextAction<any>;
79
153
  }));
80
154
  export interface FunnelNavigationAction {
81
155
  type: 'redirect' | 'replace' | 'push' | 'external' | 'none';
@@ -2,23 +2,37 @@
2
2
  * Funnel Resource - API client for funnel navigation and session management
3
3
  */
4
4
  /**
5
- * Funnel event types enum
5
+ * Funnel action types enum
6
6
  *
7
7
  * Special types:
8
8
  * - DIRECT_NAVIGATION: Bypasses step conditions, navigates directly to targetStepId
9
9
  * - BACK_NAVIGATION: Similar to direct_navigation, used for backward navigation
10
10
  *
11
11
  * Common types (for logging/tracking):
12
- * - Any string value is accepted, but these are commonly used examples
12
+ * - These are commonly used action types that align with funnel orchestrator conditions
13
+ * - Navigation logic is based on step conditions.from, action types are primarily for analytics
13
14
  */
14
- export var FunnelEventType;
15
- (function (FunnelEventType) {
16
- // Special navigation types
17
- FunnelEventType["DIRECT_NAVIGATION"] = "direct_navigation";
18
- FunnelEventType["BACK_NAVIGATION"] = "back_navigation";
19
- FunnelEventType["PAYMENT_SUCCESS"] = "payment_success";
20
- FunnelEventType["CUSTOM"] = "custom";
21
- })(FunnelEventType || (FunnelEventType = {}));
15
+ export var FunnelActionType;
16
+ (function (FunnelActionType) {
17
+ // Special navigation types (bypass step conditions)
18
+ FunnelActionType["DIRECT_NAVIGATION"] = "direct_navigation";
19
+ FunnelActionType["BACK_NAVIGATION"] = "back_navigation";
20
+ // User interaction types
21
+ FunnelActionType["CONTINUE_CLICKED"] = "continue_clicked";
22
+ FunnelActionType["BUTTON_CLICK"] = "button_click";
23
+ FunnelActionType["FORM_SUBMIT"] = "form_submit";
24
+ // Payment actions
25
+ FunnelActionType["PAYMENT_SUCCESS"] = "payment_success";
26
+ FunnelActionType["PAYMENT_FAILED"] = "payment_failed";
27
+ // Offer actions
28
+ FunnelActionType["OFFER_ACCEPTED"] = "offer_accepted";
29
+ FunnelActionType["OFFER_DECLINED"] = "offer_declined";
30
+ // Cart actions
31
+ FunnelActionType["CART_UPDATED"] = "cart_updated";
32
+ FunnelActionType["CART_ITEM_ADDED"] = "cart_item_added";
33
+ // Generic/custom actions
34
+ FunnelActionType["CUSTOM"] = "custom";
35
+ })(FunnelActionType || (FunnelActionType = {}));
22
36
  export class FunnelResource {
23
37
  constructor(apiClient) {
24
38
  this.apiClient = apiClient;
@@ -21,8 +21,8 @@ export type { ShippingRate, ShippingRatesResponse } from './core/resources/shipp
21
21
  export type { ApplyDiscountResponse, Discount, DiscountCodeValidation, RemoveDiscountResponse } from './core/resources/discounts';
22
22
  export type { ToggleOrderBumpResponse, VipOffer, VipPreviewResponse } from './core/resources/vipOffers';
23
23
  export type { StoreConfig } from './core/resources/storeConfig';
24
- export { FunnelEventType } from './core/resources/funnel';
25
- export type { BackNavigationEventData, DirectNavigationEventData, FunnelContextUpdateRequest, FunnelContextUpdateResponse, FunnelAction as FunnelEvent, FunnelInitializeRequest, FunnelInitializeResponse, FunnelNavigateRequest, FunnelNavigateResponse, FunnelNavigationAction, FunnelNavigationResult, NextEvent, PaymentSuccessEventData, SimpleFunnelContext } from './core/resources/funnel';
24
+ export { FunnelActionType } from './core/resources/funnel';
25
+ export type { BackNavigationActionData, CartUpdatedActionData, DirectNavigationActionData, FormSubmitActionData, FunnelContextUpdateRequest, FunnelContextUpdateResponse, FunnelAction as FunnelEvent, FunnelInitializeRequest, FunnelInitializeResponse, FunnelNavigateRequest, FunnelNavigateResponse, FunnelNavigationAction, FunnelNavigationResult, NextAction, OfferAcceptedActionData, OfferDeclinedActionData, PaymentFailedActionData, PaymentSuccessActionData, SimpleFunnelContext } from './core/resources/funnel';
26
26
  export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffers, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
27
27
  export type { TranslateFunction, TranslationText, UseTranslationOptions, UseTranslationResult } from './react/hooks/useTranslation';
28
28
  export type { ClubOffer, ClubOfferItem, ClubOfferLineItem, ClubOfferSummary, UseClubOffersOptions, UseClubOffersResult } from './react/hooks/useClubOffers';
package/dist/v2/index.js CHANGED
@@ -13,6 +13,6 @@ export * from './core/utils/pluginConfig';
13
13
  export * from './core/utils/products';
14
14
  // Path remapping helpers (framework-agnostic)
15
15
  export * from './core/pathRemapping';
16
- export { FunnelEventType } from './core/resources/funnel';
16
+ export { FunnelActionType } from './core/resources/funnel';
17
17
  // React exports (hooks and components only, types are exported above)
18
18
  export { ApplePayButton, ExpressPaymentMethodsProvider, formatMoney, getAvailableLanguages, GooglePayButton, queryKeys, TagadaProvider, useApiMutation, useApiQuery, useAuth, useCheckout, useCheckoutToken, useClubOffers, useCountryOptions, useCurrency, useCustomer, useCustomerInfos, useCustomerOrders, useCustomerSubscriptions, useDiscounts, useExpressPaymentMethods, useFunnel, useGeoLocation, useGoogleAutocomplete, useInvalidateQuery, useISOData, useLanguageImport, useLogin, useOffers, useOrder, useOrderBump, usePayment, usePluginConfig, usePostPurchases, usePreloadQuery, useProducts, usePromotions, useRegionOptions, useRemappableParams, useShippingRates, useSimpleFunnel, useStoreConfig, useTagadaContext, useThreeds, useThreedsModal, useTranslation, useVipOffers } from './react';
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
8
8
  import { useCallback, useEffect, useMemo, useState } from 'react';
9
- import { FunnelEventType, FunnelResource } from '../../core/resources/funnel';
9
+ import { FunnelActionType, FunnelResource } from '../../core/resources/funnel';
10
10
  import { useTagadaContext } from '../providers/TagadaProvider';
11
11
  import { getGlobalApiClient } from './useApiQuery';
12
12
  // Query keys for funnel operations
@@ -405,7 +405,7 @@ export function useFunnel(options) {
405
405
  }, [navigateMutation]);
406
406
  const goToStep = useCallback(async (stepId) => {
407
407
  return next({
408
- type: FunnelEventType.DIRECT_NAVIGATION,
408
+ type: FunnelActionType.DIRECT_NAVIGATION,
409
409
  data: { targetStepId: stepId },
410
410
  timestamp: new Date().toISOString()
411
411
  });
@@ -8,7 +8,6 @@ import { PostPurchasesResource } from '../../core/resources/postPurchases';
8
8
  import { useTagadaContext } from '../providers/TagadaProvider';
9
9
  import { getGlobalApiClient, getGlobalApiClientOrNull } from './useApiQuery';
10
10
  export function usePostPurchasesQuery(options) {
11
- console.log('usePostPurchasesQuery');
12
11
  const { orderId, enabled = true, autoInitializeCheckout = false } = options;
13
12
  const queryClient = useQueryClient();
14
13
  const { session, isSessionInitialized, apiService } = useTagadaContext();
@@ -55,7 +55,7 @@ export type { ExtractedAddress, GooglePlaceDetails, GooglePrediction, UseGoogleA
55
55
  export type { ISOCountry, ISORegion, UseISODataResult } from './hooks/useISOData';
56
56
  export type { UsePluginConfigOptions, UsePluginConfigResult } from './hooks/usePluginConfig';
57
57
  export type { TranslateFunction, UseTranslationOptions, UseTranslationResult } from './hooks/useTranslation';
58
- export { FunnelEventType } from '../core/resources/funnel';
58
+ export { FunnelActionType } from '../core/resources/funnel';
59
59
  export type { UseCheckoutQueryOptions as UseCheckoutOptions, UseCheckoutQueryResult as UseCheckoutResult } from './hooks/useCheckoutQuery';
60
60
  export type { UseDiscountsQueryOptions as UseDiscountsOptions, UseDiscountsQueryResult as UseDiscountsResult } from './hooks/useDiscountsQuery';
61
61
  export type { FunnelEvent, FunnelNavigationAction, FunnelNavigationResult, SimpleFunnelContext, UseFunnelOptions, UseFunnelResult } from './hooks/useFunnel';
@@ -45,6 +45,6 @@ export { useVipOffersQuery as useVipOffers } from './hooks/useVipOffersQuery';
45
45
  // Funnel hooks
46
46
  export { useFunnel, useSimpleFunnel } from './hooks/useFunnel';
47
47
  // TanStack Query types
48
- export { FunnelEventType } from '../core/resources/funnel';
48
+ export { FunnelActionType } from '../core/resources/funnel';
49
49
  // Re-export utilities from main react
50
50
  export { formatMoney } from '../../react/utils/money';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagadapay/plugin-sdk",
3
- "version": "2.8.1",
3
+ "version": "2.8.4",
4
4
  "description": "Modern React SDK for building Tagada Pay plugins",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",