@amboras-dev/snapchat-ads 2.0.0
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/chunk-PK23QMZT.mjs +30 -0
- package/dist/chunk-PK23QMZT.mjs.map +1 -0
- package/dist/get-config-DmAUgsFJ.d.mts +108 -0
- package/dist/get-config-DmAUgsFJ.d.ts +108 -0
- package/dist/get-config.d.mts +1 -0
- package/dist/get-config.d.ts +1 -0
- package/dist/get-config.js +54 -0
- package/dist/get-config.js.map +1 -0
- package/dist/get-config.mjs +7 -0
- package/dist/get-config.mjs.map +1 -0
- package/dist/index.d.mts +113 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.js +235 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +177 -0
- package/dist/index.mjs.map +1 -0
- package/dist/slot-components/index.d.mts +128 -0
- package/dist/slot-components/index.d.ts +128 -0
- package/dist/slot-components/index.js +657 -0
- package/dist/slot-components/index.js.map +1 -0
- package/dist/slot-components/index.mjs +627 -0
- package/dist/slot-components/index.mjs.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
interface SnapPixelProviderProps {
|
|
2
|
+
/** Snap Pixel ID (`snap_pixel_id`). When absent, this component is a no-op. */
|
|
3
|
+
pixelId?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Null-rendering side-effect component for the `rootProviders` plugin
|
|
7
|
+
* slot. Responsibilities:
|
|
8
|
+
*
|
|
9
|
+
* 1. Consent-gated install of the `snaptr` shim + injection of
|
|
10
|
+
* `https://sc-static.net/scevent.min.js`. Snap does NOT ship an
|
|
11
|
+
* npm-installable browser SDK (research memo Section 10) so we inline
|
|
12
|
+
* the canonical IIFE via `installSnapPixelShim`.
|
|
13
|
+
* 2. Consent-gated `snaptr('init', pixelId)` - runs at most once per
|
|
14
|
+
* pixel id even across SPA nav (guarded by `initedForPixelId`).
|
|
15
|
+
* 3. SPA PAGE_VIEW on every route change. `scevent.min.js` only fires
|
|
16
|
+
* PAGE_VIEW automatically on full page loads; SPA navs need an
|
|
17
|
+
* explicit `snaptr('track', 'PAGE_VIEW')`. Fires with an explicit
|
|
18
|
+
* `client_dedup_id` derived from the pathname so a browser retry in
|
|
19
|
+
* the same minute doesn't get counted twice.
|
|
20
|
+
*
|
|
21
|
+
* Everything is gated on `hasAnalyticsConsent()` and re-checked on the
|
|
22
|
+
* `amboras-consent-changed` event.
|
|
23
|
+
*
|
|
24
|
+
* Deliberately does NOT relay PAGE_VIEW to CAPI - the storefront has no
|
|
25
|
+
* server counterpart for a page view (no route handler dispatches it,
|
|
26
|
+
* unlike PURCHASE / ADD_CART which the checkout / cart flow triggers).
|
|
27
|
+
* Merchants who want server-side PAGE_VIEW attribution can call
|
|
28
|
+
* `trackPageView` from their app; the default here is browser-only for
|
|
29
|
+
* PAGE_VIEW parity with Snap's canonical install snippet.
|
|
30
|
+
*/
|
|
31
|
+
declare function SnapPixelProvider({ pixelId }: SnapPixelProviderProps): null;
|
|
32
|
+
|
|
33
|
+
interface SnapViewContentProps {
|
|
34
|
+
productId?: string;
|
|
35
|
+
productName?: string;
|
|
36
|
+
sku?: string;
|
|
37
|
+
/** Major-unit numeric price (already converted from Medusa's minor units by the slot host). */
|
|
38
|
+
price?: number;
|
|
39
|
+
currency?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Null-rendering component for the `pdpAnalytics` plugin slot.
|
|
43
|
+
* Fires Snap `VIEW_CONTENT` on both browser (Pixel) and server (CAPI)
|
|
44
|
+
* on PDP mount.
|
|
45
|
+
*
|
|
46
|
+
* Guarded by a productId ref so PDPs that swap variants without a full
|
|
47
|
+
* remount don't fire once per prop tick - Snap counts double fires as
|
|
48
|
+
* two events even when `client_dedup_id` matches (dedup is only across
|
|
49
|
+
* browser vs server, not within the same channel).
|
|
50
|
+
*/
|
|
51
|
+
declare function SnapViewContent({ productId, price, currency }: SnapViewContentProps): null;
|
|
52
|
+
|
|
53
|
+
interface SnapAddCartProps {
|
|
54
|
+
cartId?: string;
|
|
55
|
+
itemCount?: number;
|
|
56
|
+
/** Kept for prop-shape compatibility with the plugin slot - not used directly. */
|
|
57
|
+
total?: number;
|
|
58
|
+
currency?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Null-rendering component for the `cartUpdate` plugin slot.
|
|
62
|
+
* Fires Snap `ADD_CART` per newly-added variant, self-hydrating from
|
|
63
|
+
* Medusa's `/store/carts/:id` so `value`/`currency` are always
|
|
64
|
+
* authoritative. Per-variant sessionStorage baseline persists across
|
|
65
|
+
* cart-drawer mount cycles; a 1.5s window dedup absorbs TanStack Query
|
|
66
|
+
* refetch races.
|
|
67
|
+
*
|
|
68
|
+
* First-mount seed: on a fresh session with a hydrated cart (page
|
|
69
|
+
* refresh loads a cart with N items already in it), the baseline is
|
|
70
|
+
* seeded to the current cart state and NO events fire. Only subsequent
|
|
71
|
+
* quantity increases fire events.
|
|
72
|
+
*
|
|
73
|
+
* Values are serialised to STRINGS per Snap v3 wire spec (research memo
|
|
74
|
+
* caveat #3).
|
|
75
|
+
*/
|
|
76
|
+
declare function SnapAddCart({ cartId, itemCount: _itemCount }: SnapAddCartProps): null;
|
|
77
|
+
|
|
78
|
+
interface SnapStartCheckoutProps {
|
|
79
|
+
cartId?: string;
|
|
80
|
+
itemCount?: number;
|
|
81
|
+
total?: number;
|
|
82
|
+
currency?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Null-rendering component for the `checkoutStart` plugin slot.
|
|
86
|
+
* Fires Snap `START_CHECKOUT` exactly once per cartId. SessionStorage
|
|
87
|
+
* dedup so back-nav to the checkout page doesn't double-fire.
|
|
88
|
+
*
|
|
89
|
+
* Self-fetches the cart from Medusa so `value`/`currency` are correct
|
|
90
|
+
* even when the merchant slot context is thin. The ref is set only
|
|
91
|
+
* AFTER a successful dispatch so a StrictMode cleanup between effect-
|
|
92
|
+
* run and fetch-complete does NOT poison the ref.
|
|
93
|
+
*/
|
|
94
|
+
declare function SnapStartCheckout({ cartId, itemCount, total, currency }: SnapStartCheckoutProps): null;
|
|
95
|
+
|
|
96
|
+
interface SnapPurchaseProps {
|
|
97
|
+
orderId?: string;
|
|
98
|
+
total?: number;
|
|
99
|
+
currency?: string;
|
|
100
|
+
itemCount?: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Null-rendering component for the `checkoutComplete` plugin slot.
|
|
104
|
+
* Fires Snap `PURCHASE` exactly once per orderId. Dual-dedup semantics
|
|
105
|
+
* per research memo Section 5:
|
|
106
|
+
*
|
|
107
|
+
* - Top-level `event_id` / Pixel `client_dedup_id` shared for 48h.
|
|
108
|
+
* - `custom_data.order_id` / Pixel `transaction_id` shared for 30d.
|
|
109
|
+
*
|
|
110
|
+
* Both derive from the orderId directly so browser retries in a later
|
|
111
|
+
* minute still line up with the server event.
|
|
112
|
+
*
|
|
113
|
+
* Primary path: self-fetch from `/store/orders/:id` and derive value +
|
|
114
|
+
* currency + contentIds from the authoritative Medusa response
|
|
115
|
+
* (currency-aware `toMajorUnits`, so JPY/KWD are correct).
|
|
116
|
+
*
|
|
117
|
+
* Fallback path (fetch failed): fire a MINIMAL browser PURCHASE using
|
|
118
|
+
* the incoming `total` + `currency` props, log a dev warning, and rely
|
|
119
|
+
* on Snap's dedup with the server-side `sendSnapchatCapiEvent` to
|
|
120
|
+
* reconcile.
|
|
121
|
+
*
|
|
122
|
+
* Two-layer dedup mirrors meta-ads: `useRef` guards StrictMode double-
|
|
123
|
+
* mount within the same instance; `sessionStorage` guards page refresh
|
|
124
|
+
* + remount. Both are set only AFTER successful dispatch.
|
|
125
|
+
*/
|
|
126
|
+
declare function SnapPurchase({ orderId, total, currency, itemCount: _itemCount }: SnapPurchaseProps): null;
|
|
127
|
+
|
|
128
|
+
export { SnapAddCart, type SnapAddCartProps, SnapPixelProvider, type SnapPixelProviderProps, SnapPurchase, type SnapPurchaseProps, SnapStartCheckout, type SnapStartCheckoutProps, SnapViewContent, type SnapViewContentProps };
|