@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.
@@ -0,0 +1,30 @@
1
+ // src/get-config.ts
2
+ function resolveEnv(key) {
3
+ if (key === "NEXT_PUBLIC_MEDUSA_BACKEND_URL") return process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL;
4
+ if (key === "NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY") return process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY;
5
+ if (key === "NEXT_PUBLIC_STORE_ID") return process.env.NEXT_PUBLIC_STORE_ID;
6
+ return void 0;
7
+ }
8
+ async function getSnapchatAdsConfig(options = {}) {
9
+ const baseUrl = options.baseUrl ?? resolveEnv("NEXT_PUBLIC_MEDUSA_BACKEND_URL") ?? "http://localhost:9000";
10
+ const publishableKey = options.publishableApiKey ?? resolveEnv("NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY");
11
+ const storeId = options.storeId ?? resolveEnv("NEXT_PUBLIC_STORE_ID");
12
+ try {
13
+ const res = await fetch(`${baseUrl}/store/snapchat-ads/config`, {
14
+ headers: {
15
+ ...storeId ? { "X-Store-Environment-ID": storeId } : {},
16
+ ...publishableKey ? { "x-publishable-api-key": publishableKey } : {}
17
+ },
18
+ next: { revalidate: 60 }
19
+ });
20
+ if (!res.ok) return null;
21
+ return await res.json();
22
+ } catch {
23
+ return null;
24
+ }
25
+ }
26
+
27
+ export {
28
+ getSnapchatAdsConfig
29
+ };
30
+ //# sourceMappingURL=chunk-PK23QMZT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/get-config.ts"],"sourcesContent":["import type { SnapchatAdsPublicConfig } from './types'\n\nfunction resolveEnv(key: string): string | undefined {\n if (key === 'NEXT_PUBLIC_MEDUSA_BACKEND_URL') return process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL\n if (key === 'NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY') return process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY\n if (key === 'NEXT_PUBLIC_STORE_ID') return process.env.NEXT_PUBLIC_STORE_ID\n return undefined\n}\n\ninterface GetSnapchatAdsConfigOptions {\n baseUrl?: string\n publishableApiKey?: string\n storeId?: string\n}\n\n/**\n * Fetch the non-secret Snapchat Ads config from the Medusa Store API. Returns\n * `null` when the store isn't wired up, when the publishable key is missing,\n * or on any transport error - callers should treat `null` as \"plugin\n * off\" and skip event firing.\n *\n * NEVER surfaces `snap_conversion_api_token` or `snap_ad_account_id` -\n * those live only on the Medusa side and never leave the server.\n */\nexport async function getSnapchatAdsConfig(\n options: GetSnapchatAdsConfigOptions = {},\n): Promise<SnapchatAdsPublicConfig | null> {\n const baseUrl = options.baseUrl ?? resolveEnv('NEXT_PUBLIC_MEDUSA_BACKEND_URL') ?? 'http://localhost:9000'\n const publishableKey = options.publishableApiKey ?? resolveEnv('NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY')\n const storeId = options.storeId ?? resolveEnv('NEXT_PUBLIC_STORE_ID')\n\n try {\n // `next` is a Next.js fetch extension for cache revalidation - ignored outside Next.js\n const res = await fetch(`${baseUrl}/store/snapchat-ads/config`, {\n headers: {\n ...(storeId ? { 'X-Store-Environment-ID': storeId } : {}),\n ...(publishableKey ? { 'x-publishable-api-key': publishableKey } : {}),\n },\n next: { revalidate: 60 },\n } as RequestInit)\n if (!res.ok) return null\n return (await res.json()) as SnapchatAdsPublicConfig\n } catch {\n return null\n }\n}\n"],"mappings":";AAEA,SAAS,WAAW,KAAiC;AACnD,MAAI,QAAQ,iCAAkC,QAAO,QAAQ,IAAI;AACjE,MAAI,QAAQ,qCAAsC,QAAO,QAAQ,IAAI;AACrE,MAAI,QAAQ,uBAAwB,QAAO,QAAQ,IAAI;AACvD,SAAO;AACT;AAiBA,eAAsB,qBACpB,UAAuC,CAAC,GACC;AACzC,QAAM,UAAU,QAAQ,WAAW,WAAW,gCAAgC,KAAK;AACnF,QAAM,iBAAiB,QAAQ,qBAAqB,WAAW,oCAAoC;AACnG,QAAM,UAAU,QAAQ,WAAW,WAAW,sBAAsB;AAEpE,MAAI;AAEF,UAAM,MAAM,MAAM,MAAM,GAAG,OAAO,8BAA8B;AAAA,MAC9D,SAAS;AAAA,QACP,GAAI,UAAU,EAAE,0BAA0B,QAAQ,IAAI,CAAC;AAAA,QACvD,GAAI,iBAAiB,EAAE,yBAAyB,eAAe,IAAI,CAAC;AAAA,MACtE;AAAA,MACA,MAAM,EAAE,YAAY,GAAG;AAAA,IACzB,CAAgB;AAChB,QAAI,CAAC,IAAI,GAAI,QAAO;AACpB,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Non-secret Snapchat Ads configuration exposed to the browser via
3
+ * `/store/snapchat-ads/config`. Never contains `snap_conversion_api_token`
4
+ * or `snap_ad_account_id` - those live only on the Medusa side and never
5
+ * leave the server.
6
+ */
7
+ interface SnapchatAdsPublicConfig {
8
+ snap_pixel_id: string;
9
+ enabled: boolean;
10
+ track_page_view: boolean;
11
+ track_view_content: boolean;
12
+ track_add_cart: boolean;
13
+ track_start_checkout: boolean;
14
+ track_purchase: boolean;
15
+ test_mode?: boolean;
16
+ }
17
+ /**
18
+ * Snap Conversions API v3 canonical event names (UPPER_SNAKE_CASE).
19
+ * Sent verbatim on both the browser Pixel call (`snaptr('track', <name>, ...)`)
20
+ * and the CAPI wire body (`event_name`). Snap dedups by
21
+ * (event_name, event_id) within 48h, so the strings MUST match exactly.
22
+ */
23
+ type SnapEventName = 'PAGE_VIEW' | 'VIEW_CONTENT' | 'ADD_CART' | 'START_CHECKOUT' | 'PURCHASE';
24
+ /**
25
+ * User-identifying fields for Snap CAPI. All of `em`/`ph`/`madid`/`external_id`
26
+ * MUST be SHA-256 hex-lowercase-trimmed BEFORE being placed in the CAPI wire
27
+ * body. The Amboras plugin does hashing on the Medusa side, so the browser-
28
+ * facing payload carries raw values (or the click-id / ip / user-agent
29
+ * fields that Snap wants raw). `sc_click_id` is sent RAW - Snap matches it
30
+ * against their own click table server-side.
31
+ */
32
+ interface SnapUserData {
33
+ /** SHA-256 hex lowercase, lowercase-trimmed email BEFORE hashing. */
34
+ email?: string;
35
+ /** SHA-256 hex lowercase, E.164 digits-only phone BEFORE hashing (strip leading 00/0, whitespace, +, -, (, )). */
36
+ phone?: string;
37
+ /** SHA-256 hex lowercase, lowercase iOS IDFA / Android AAID (keep hyphens) BEFORE hashing. */
38
+ madid?: string;
39
+ /** SHA-256 hex lowercase (hash recommended by Snap, but not strictly required). */
40
+ externalId?: string;
41
+ /** Snap click id - sent RAW, never hashed. */
42
+ scClickId?: string;
43
+ /** First-party cookie id (`sc_at`) - sent RAW, never hashed. */
44
+ scCookie1?: string;
45
+ }
46
+ /**
47
+ * Snap CAPI v3 custom-data shape - `value`, `item_price`, and `quantity` are
48
+ * STRING-typed per the v3 wire spec (research memo caveat #3). Numeric-typed
49
+ * fields cause the event to silently drop or under-report. `num_items` is
50
+ * numeric though - inconsistent, but that's what Snap's docs show.
51
+ *
52
+ * Amounts are in MAJOR units (e.g. `"10.50"` INR, not `"1050"` paise). Snap
53
+ * does NOT use Stripe's cents convention.
54
+ */
55
+ interface SnapCustomData {
56
+ /** ISO 4217 3-letter uppercase (e.g. `USD`, `INR`, `EUR`). */
57
+ currency?: string;
58
+ /** Major-unit amount serialized as a STRING (e.g. `"10.50"`). */
59
+ value?: string;
60
+ /**
61
+ * Order/transaction id echoed by the PURCHASE event only. Matches the
62
+ * Pixel-side `transaction_id`; Snap dedups on this pair within a 30-day
63
+ * window on PURCHASE (separately from the 48h event_id dedup).
64
+ */
65
+ orderId?: string;
66
+ contentIds?: string[];
67
+ /** NUMBER, not string. Snap's docs show num_items as numeric. */
68
+ numItems?: number;
69
+ contents?: Array<{
70
+ id: string;
71
+ /** Quantity serialized as a STRING per v3 spec. */
72
+ quantity: string;
73
+ /** item_price serialized as a STRING per v3 spec. */
74
+ item_price?: string;
75
+ }>;
76
+ }
77
+ /**
78
+ * Payload posted from the storefront to `/api/snapchat-ads/events`. The
79
+ * storefront proxy enriches with `client_ip_address` + `client_user_agent`
80
+ * and forwards to Medusa `/store/snapchat-ads/capi` with the same
81
+ * `event_id`. Snap matches (event_name, event_id) within 48h for browser
82
+ * vs server dedup.
83
+ */
84
+ interface SnapEventPayload {
85
+ eventName: SnapEventName;
86
+ eventId: string;
87
+ eventSourceUrl: string;
88
+ userData: SnapUserData;
89
+ customData?: SnapCustomData;
90
+ }
91
+
92
+ interface GetSnapchatAdsConfigOptions {
93
+ baseUrl?: string;
94
+ publishableApiKey?: string;
95
+ storeId?: string;
96
+ }
97
+ /**
98
+ * Fetch the non-secret Snapchat Ads config from the Medusa Store API. Returns
99
+ * `null` when the store isn't wired up, when the publishable key is missing,
100
+ * or on any transport error - callers should treat `null` as "plugin
101
+ * off" and skip event firing.
102
+ *
103
+ * NEVER surfaces `snap_conversion_api_token` or `snap_ad_account_id` -
104
+ * those live only on the Medusa side and never leave the server.
105
+ */
106
+ declare function getSnapchatAdsConfig(options?: GetSnapchatAdsConfigOptions): Promise<SnapchatAdsPublicConfig | null>;
107
+
108
+ export { type SnapEventPayload as S, type SnapUserData as a, type SnapEventName as b, type SnapCustomData as c, type SnapchatAdsPublicConfig as d, getSnapchatAdsConfig as g };
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Non-secret Snapchat Ads configuration exposed to the browser via
3
+ * `/store/snapchat-ads/config`. Never contains `snap_conversion_api_token`
4
+ * or `snap_ad_account_id` - those live only on the Medusa side and never
5
+ * leave the server.
6
+ */
7
+ interface SnapchatAdsPublicConfig {
8
+ snap_pixel_id: string;
9
+ enabled: boolean;
10
+ track_page_view: boolean;
11
+ track_view_content: boolean;
12
+ track_add_cart: boolean;
13
+ track_start_checkout: boolean;
14
+ track_purchase: boolean;
15
+ test_mode?: boolean;
16
+ }
17
+ /**
18
+ * Snap Conversions API v3 canonical event names (UPPER_SNAKE_CASE).
19
+ * Sent verbatim on both the browser Pixel call (`snaptr('track', <name>, ...)`)
20
+ * and the CAPI wire body (`event_name`). Snap dedups by
21
+ * (event_name, event_id) within 48h, so the strings MUST match exactly.
22
+ */
23
+ type SnapEventName = 'PAGE_VIEW' | 'VIEW_CONTENT' | 'ADD_CART' | 'START_CHECKOUT' | 'PURCHASE';
24
+ /**
25
+ * User-identifying fields for Snap CAPI. All of `em`/`ph`/`madid`/`external_id`
26
+ * MUST be SHA-256 hex-lowercase-trimmed BEFORE being placed in the CAPI wire
27
+ * body. The Amboras plugin does hashing on the Medusa side, so the browser-
28
+ * facing payload carries raw values (or the click-id / ip / user-agent
29
+ * fields that Snap wants raw). `sc_click_id` is sent RAW - Snap matches it
30
+ * against their own click table server-side.
31
+ */
32
+ interface SnapUserData {
33
+ /** SHA-256 hex lowercase, lowercase-trimmed email BEFORE hashing. */
34
+ email?: string;
35
+ /** SHA-256 hex lowercase, E.164 digits-only phone BEFORE hashing (strip leading 00/0, whitespace, +, -, (, )). */
36
+ phone?: string;
37
+ /** SHA-256 hex lowercase, lowercase iOS IDFA / Android AAID (keep hyphens) BEFORE hashing. */
38
+ madid?: string;
39
+ /** SHA-256 hex lowercase (hash recommended by Snap, but not strictly required). */
40
+ externalId?: string;
41
+ /** Snap click id - sent RAW, never hashed. */
42
+ scClickId?: string;
43
+ /** First-party cookie id (`sc_at`) - sent RAW, never hashed. */
44
+ scCookie1?: string;
45
+ }
46
+ /**
47
+ * Snap CAPI v3 custom-data shape - `value`, `item_price`, and `quantity` are
48
+ * STRING-typed per the v3 wire spec (research memo caveat #3). Numeric-typed
49
+ * fields cause the event to silently drop or under-report. `num_items` is
50
+ * numeric though - inconsistent, but that's what Snap's docs show.
51
+ *
52
+ * Amounts are in MAJOR units (e.g. `"10.50"` INR, not `"1050"` paise). Snap
53
+ * does NOT use Stripe's cents convention.
54
+ */
55
+ interface SnapCustomData {
56
+ /** ISO 4217 3-letter uppercase (e.g. `USD`, `INR`, `EUR`). */
57
+ currency?: string;
58
+ /** Major-unit amount serialized as a STRING (e.g. `"10.50"`). */
59
+ value?: string;
60
+ /**
61
+ * Order/transaction id echoed by the PURCHASE event only. Matches the
62
+ * Pixel-side `transaction_id`; Snap dedups on this pair within a 30-day
63
+ * window on PURCHASE (separately from the 48h event_id dedup).
64
+ */
65
+ orderId?: string;
66
+ contentIds?: string[];
67
+ /** NUMBER, not string. Snap's docs show num_items as numeric. */
68
+ numItems?: number;
69
+ contents?: Array<{
70
+ id: string;
71
+ /** Quantity serialized as a STRING per v3 spec. */
72
+ quantity: string;
73
+ /** item_price serialized as a STRING per v3 spec. */
74
+ item_price?: string;
75
+ }>;
76
+ }
77
+ /**
78
+ * Payload posted from the storefront to `/api/snapchat-ads/events`. The
79
+ * storefront proxy enriches with `client_ip_address` + `client_user_agent`
80
+ * and forwards to Medusa `/store/snapchat-ads/capi` with the same
81
+ * `event_id`. Snap matches (event_name, event_id) within 48h for browser
82
+ * vs server dedup.
83
+ */
84
+ interface SnapEventPayload {
85
+ eventName: SnapEventName;
86
+ eventId: string;
87
+ eventSourceUrl: string;
88
+ userData: SnapUserData;
89
+ customData?: SnapCustomData;
90
+ }
91
+
92
+ interface GetSnapchatAdsConfigOptions {
93
+ baseUrl?: string;
94
+ publishableApiKey?: string;
95
+ storeId?: string;
96
+ }
97
+ /**
98
+ * Fetch the non-secret Snapchat Ads config from the Medusa Store API. Returns
99
+ * `null` when the store isn't wired up, when the publishable key is missing,
100
+ * or on any transport error - callers should treat `null` as "plugin
101
+ * off" and skip event firing.
102
+ *
103
+ * NEVER surfaces `snap_conversion_api_token` or `snap_ad_account_id` -
104
+ * those live only on the Medusa side and never leave the server.
105
+ */
106
+ declare function getSnapchatAdsConfig(options?: GetSnapchatAdsConfigOptions): Promise<SnapchatAdsPublicConfig | null>;
107
+
108
+ export { type SnapEventPayload as S, type SnapUserData as a, type SnapEventName as b, type SnapCustomData as c, type SnapchatAdsPublicConfig as d, getSnapchatAdsConfig as g };
@@ -0,0 +1 @@
1
+ export { g as getSnapchatAdsConfig } from './get-config-DmAUgsFJ.mjs';
@@ -0,0 +1 @@
1
+ export { g as getSnapchatAdsConfig } from './get-config-DmAUgsFJ.js';
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/get-config.ts
21
+ var get_config_exports = {};
22
+ __export(get_config_exports, {
23
+ getSnapchatAdsConfig: () => getSnapchatAdsConfig
24
+ });
25
+ module.exports = __toCommonJS(get_config_exports);
26
+ function resolveEnv(key) {
27
+ if (key === "NEXT_PUBLIC_MEDUSA_BACKEND_URL") return process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL;
28
+ if (key === "NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY") return process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY;
29
+ if (key === "NEXT_PUBLIC_STORE_ID") return process.env.NEXT_PUBLIC_STORE_ID;
30
+ return void 0;
31
+ }
32
+ async function getSnapchatAdsConfig(options = {}) {
33
+ const baseUrl = options.baseUrl ?? resolveEnv("NEXT_PUBLIC_MEDUSA_BACKEND_URL") ?? "http://localhost:9000";
34
+ const publishableKey = options.publishableApiKey ?? resolveEnv("NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY");
35
+ const storeId = options.storeId ?? resolveEnv("NEXT_PUBLIC_STORE_ID");
36
+ try {
37
+ const res = await fetch(`${baseUrl}/store/snapchat-ads/config`, {
38
+ headers: {
39
+ ...storeId ? { "X-Store-Environment-ID": storeId } : {},
40
+ ...publishableKey ? { "x-publishable-api-key": publishableKey } : {}
41
+ },
42
+ next: { revalidate: 60 }
43
+ });
44
+ if (!res.ok) return null;
45
+ return await res.json();
46
+ } catch {
47
+ return null;
48
+ }
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ getSnapchatAdsConfig
53
+ });
54
+ //# sourceMappingURL=get-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/get-config.ts"],"sourcesContent":["import type { SnapchatAdsPublicConfig } from './types'\n\nfunction resolveEnv(key: string): string | undefined {\n if (key === 'NEXT_PUBLIC_MEDUSA_BACKEND_URL') return process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL\n if (key === 'NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY') return process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY\n if (key === 'NEXT_PUBLIC_STORE_ID') return process.env.NEXT_PUBLIC_STORE_ID\n return undefined\n}\n\ninterface GetSnapchatAdsConfigOptions {\n baseUrl?: string\n publishableApiKey?: string\n storeId?: string\n}\n\n/**\n * Fetch the non-secret Snapchat Ads config from the Medusa Store API. Returns\n * `null` when the store isn't wired up, when the publishable key is missing,\n * or on any transport error - callers should treat `null` as \"plugin\n * off\" and skip event firing.\n *\n * NEVER surfaces `snap_conversion_api_token` or `snap_ad_account_id` -\n * those live only on the Medusa side and never leave the server.\n */\nexport async function getSnapchatAdsConfig(\n options: GetSnapchatAdsConfigOptions = {},\n): Promise<SnapchatAdsPublicConfig | null> {\n const baseUrl = options.baseUrl ?? resolveEnv('NEXT_PUBLIC_MEDUSA_BACKEND_URL') ?? 'http://localhost:9000'\n const publishableKey = options.publishableApiKey ?? resolveEnv('NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY')\n const storeId = options.storeId ?? resolveEnv('NEXT_PUBLIC_STORE_ID')\n\n try {\n // `next` is a Next.js fetch extension for cache revalidation - ignored outside Next.js\n const res = await fetch(`${baseUrl}/store/snapchat-ads/config`, {\n headers: {\n ...(storeId ? { 'X-Store-Environment-ID': storeId } : {}),\n ...(publishableKey ? { 'x-publishable-api-key': publishableKey } : {}),\n },\n next: { revalidate: 60 },\n } as RequestInit)\n if (!res.ok) return null\n return (await res.json()) as SnapchatAdsPublicConfig\n } catch {\n return null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,SAAS,WAAW,KAAiC;AACnD,MAAI,QAAQ,iCAAkC,QAAO,QAAQ,IAAI;AACjE,MAAI,QAAQ,qCAAsC,QAAO,QAAQ,IAAI;AACrE,MAAI,QAAQ,uBAAwB,QAAO,QAAQ,IAAI;AACvD,SAAO;AACT;AAiBA,eAAsB,qBACpB,UAAuC,CAAC,GACC;AACzC,QAAM,UAAU,QAAQ,WAAW,WAAW,gCAAgC,KAAK;AACnF,QAAM,iBAAiB,QAAQ,qBAAqB,WAAW,oCAAoC;AACnG,QAAM,UAAU,QAAQ,WAAW,WAAW,sBAAsB;AAEpE,MAAI;AAEF,UAAM,MAAM,MAAM,MAAM,GAAG,OAAO,8BAA8B;AAAA,MAC9D,SAAS;AAAA,QACP,GAAI,UAAU,EAAE,0BAA0B,QAAQ,IAAI,CAAC;AAAA,QACvD,GAAI,iBAAiB,EAAE,yBAAyB,eAAe,IAAI,CAAC;AAAA,MACtE;AAAA,MACA,MAAM,EAAE,YAAY,GAAG;AAAA,IACzB,CAAgB;AAChB,QAAI,CAAC,IAAI,GAAI,QAAO;AACpB,WAAQ,MAAM,IAAI,KAAK;AAAA,EACzB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,7 @@
1
+ import {
2
+ getSnapchatAdsConfig
3
+ } from "./chunk-PK23QMZT.mjs";
4
+ export {
5
+ getSnapchatAdsConfig
6
+ };
7
+ //# sourceMappingURL=get-config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,113 @@
1
+ import { S as SnapEventPayload, a as SnapUserData, b as SnapEventName } from './get-config-DmAUgsFJ.mjs';
2
+ export { c as SnapCustomData, d as SnapchatAdsPublicConfig, g as getSnapchatAdsConfig } from './get-config-DmAUgsFJ.mjs';
3
+
4
+ /**
5
+ * Send a server-side Snap CAPI event via the storefront's proxy. Fire-
6
+ * and-forget from the caller's perspective; internal errors are swallowed
7
+ * because analytics loss is preferable to storefront breakage.
8
+ *
9
+ * Intentionally NOT gated on analytics consent - Snap CAPI operates on a
10
+ * different legal basis (order-tracking legitimate interest) than the
11
+ * browser pixel. The `SnapPixelProvider` handles browser-side consent
12
+ * gating separately.
13
+ */
14
+ declare function sendSnapchatCapiEvent(payload: SnapEventPayload): Promise<void>;
15
+ /**
16
+ * Fire PAGE_VIEW on both sides. The `SnapPixelProvider` already fires
17
+ * this on mount + route change; this hook is exposed for callers that
18
+ * want to trigger a page-view manually (e.g. modal opens counted as
19
+ * page views).
20
+ */
21
+ declare function trackPageView(primaryKey: string, userData?: SnapUserData, eventId?: string): void;
22
+ interface TrackViewContentOptions {
23
+ currency?: string;
24
+ /** Major-unit value STRING (e.g. `"10.50"`). */
25
+ value?: string;
26
+ /** Product / variant id passed to Snap as `content_ids`. */
27
+ contentIds?: string[];
28
+ /** Optional per-line breakdown. `item_price` + `quantity` are STRINGS. */
29
+ contents?: Array<{
30
+ id: string;
31
+ quantity: string;
32
+ item_price?: string;
33
+ }>;
34
+ numItems?: number;
35
+ userData?: SnapUserData;
36
+ eventId?: string;
37
+ }
38
+ declare function trackViewContent(productId: string, options?: TrackViewContentOptions): void;
39
+ interface TrackAddCartOptions {
40
+ currency?: string;
41
+ /** Major-unit value STRING. */
42
+ value?: string;
43
+ /** Product / variant ids. */
44
+ contentIds?: string[];
45
+ contents?: Array<{
46
+ id: string;
47
+ quantity: string;
48
+ item_price?: string;
49
+ }>;
50
+ /** Top-level `num_items` - number-typed per Snap docs. */
51
+ numItems?: number;
52
+ userData?: SnapUserData;
53
+ eventId?: string;
54
+ }
55
+ declare function trackAddCart(cartId: string, options?: TrackAddCartOptions): void;
56
+ interface TrackStartCheckoutOptions {
57
+ currency?: string;
58
+ value?: string;
59
+ contentIds?: string[];
60
+ contents?: Array<{
61
+ id: string;
62
+ quantity: string;
63
+ item_price?: string;
64
+ }>;
65
+ numItems?: number;
66
+ userData?: SnapUserData;
67
+ eventId?: string;
68
+ }
69
+ declare function trackStartCheckout(cartId: string, options?: TrackStartCheckoutOptions): void;
70
+ interface TrackPurchaseOptions {
71
+ currency?: string;
72
+ value?: string;
73
+ contentIds?: string[];
74
+ contents?: Array<{
75
+ id: string;
76
+ quantity: string;
77
+ item_price?: string;
78
+ }>;
79
+ numItems?: number;
80
+ userData?: SnapUserData;
81
+ /**
82
+ * When present, pins `event_id` / `client_dedup_id` explicitly; otherwise
83
+ * a stable id is derived from `(PURCHASE, orderId, 0)` - minute-bucket 0
84
+ * so retries within a longer window still dedup against the server event.
85
+ */
86
+ eventId?: string;
87
+ }
88
+ /**
89
+ * PURCHASE gets the dual-dedup treatment:
90
+ * - Top-level `event_id` / Pixel `client_dedup_id` shared for 48h window.
91
+ * - `custom_data.order_id` / Pixel `transaction_id` shared for 30-day
92
+ * window. Reuses the Amboras order id as both.
93
+ */
94
+ declare function trackPurchase(orderId: string, options?: TrackPurchaseOptions): void;
95
+
96
+ /** Bucket a Unix millisecond timestamp into whole minutes. */
97
+ declare function deriveMinuteBucket(nowMs: number): number;
98
+ /** Convenience wrapper for `deriveMinuteBucket(Date.now())`. */
99
+ declare function minuteBucketNow(): number;
100
+ /**
101
+ * Mint a deterministic event id for `event_id` (CAPI) and
102
+ * `client_dedup_id` (Pixel). See contract above.
103
+ *
104
+ * Callers that want a stable id across a longer window (e.g. tying two
105
+ * page-view fires back to back to the same URL) can pin `minuteBucket` to
106
+ * a well-known value; the default is `minuteBucketNow()`. For PURCHASE,
107
+ * pin `minuteBucket` to a constant per order (recommend `0`) so a
108
+ * failing browser fire that retries in a later minute still dedups
109
+ * against the server event.
110
+ */
111
+ declare function makeEventId(eventName: SnapEventName, primaryKey: string, minuteBucket?: number): string;
112
+
113
+ export { SnapEventName, SnapEventPayload, SnapUserData, deriveMinuteBucket, makeEventId, minuteBucketNow, sendSnapchatCapiEvent, trackAddCart, trackPageView, trackPurchase, trackStartCheckout, trackViewContent };
@@ -0,0 +1,113 @@
1
+ import { S as SnapEventPayload, a as SnapUserData, b as SnapEventName } from './get-config-DmAUgsFJ.js';
2
+ export { c as SnapCustomData, d as SnapchatAdsPublicConfig, g as getSnapchatAdsConfig } from './get-config-DmAUgsFJ.js';
3
+
4
+ /**
5
+ * Send a server-side Snap CAPI event via the storefront's proxy. Fire-
6
+ * and-forget from the caller's perspective; internal errors are swallowed
7
+ * because analytics loss is preferable to storefront breakage.
8
+ *
9
+ * Intentionally NOT gated on analytics consent - Snap CAPI operates on a
10
+ * different legal basis (order-tracking legitimate interest) than the
11
+ * browser pixel. The `SnapPixelProvider` handles browser-side consent
12
+ * gating separately.
13
+ */
14
+ declare function sendSnapchatCapiEvent(payload: SnapEventPayload): Promise<void>;
15
+ /**
16
+ * Fire PAGE_VIEW on both sides. The `SnapPixelProvider` already fires
17
+ * this on mount + route change; this hook is exposed for callers that
18
+ * want to trigger a page-view manually (e.g. modal opens counted as
19
+ * page views).
20
+ */
21
+ declare function trackPageView(primaryKey: string, userData?: SnapUserData, eventId?: string): void;
22
+ interface TrackViewContentOptions {
23
+ currency?: string;
24
+ /** Major-unit value STRING (e.g. `"10.50"`). */
25
+ value?: string;
26
+ /** Product / variant id passed to Snap as `content_ids`. */
27
+ contentIds?: string[];
28
+ /** Optional per-line breakdown. `item_price` + `quantity` are STRINGS. */
29
+ contents?: Array<{
30
+ id: string;
31
+ quantity: string;
32
+ item_price?: string;
33
+ }>;
34
+ numItems?: number;
35
+ userData?: SnapUserData;
36
+ eventId?: string;
37
+ }
38
+ declare function trackViewContent(productId: string, options?: TrackViewContentOptions): void;
39
+ interface TrackAddCartOptions {
40
+ currency?: string;
41
+ /** Major-unit value STRING. */
42
+ value?: string;
43
+ /** Product / variant ids. */
44
+ contentIds?: string[];
45
+ contents?: Array<{
46
+ id: string;
47
+ quantity: string;
48
+ item_price?: string;
49
+ }>;
50
+ /** Top-level `num_items` - number-typed per Snap docs. */
51
+ numItems?: number;
52
+ userData?: SnapUserData;
53
+ eventId?: string;
54
+ }
55
+ declare function trackAddCart(cartId: string, options?: TrackAddCartOptions): void;
56
+ interface TrackStartCheckoutOptions {
57
+ currency?: string;
58
+ value?: string;
59
+ contentIds?: string[];
60
+ contents?: Array<{
61
+ id: string;
62
+ quantity: string;
63
+ item_price?: string;
64
+ }>;
65
+ numItems?: number;
66
+ userData?: SnapUserData;
67
+ eventId?: string;
68
+ }
69
+ declare function trackStartCheckout(cartId: string, options?: TrackStartCheckoutOptions): void;
70
+ interface TrackPurchaseOptions {
71
+ currency?: string;
72
+ value?: string;
73
+ contentIds?: string[];
74
+ contents?: Array<{
75
+ id: string;
76
+ quantity: string;
77
+ item_price?: string;
78
+ }>;
79
+ numItems?: number;
80
+ userData?: SnapUserData;
81
+ /**
82
+ * When present, pins `event_id` / `client_dedup_id` explicitly; otherwise
83
+ * a stable id is derived from `(PURCHASE, orderId, 0)` - minute-bucket 0
84
+ * so retries within a longer window still dedup against the server event.
85
+ */
86
+ eventId?: string;
87
+ }
88
+ /**
89
+ * PURCHASE gets the dual-dedup treatment:
90
+ * - Top-level `event_id` / Pixel `client_dedup_id` shared for 48h window.
91
+ * - `custom_data.order_id` / Pixel `transaction_id` shared for 30-day
92
+ * window. Reuses the Amboras order id as both.
93
+ */
94
+ declare function trackPurchase(orderId: string, options?: TrackPurchaseOptions): void;
95
+
96
+ /** Bucket a Unix millisecond timestamp into whole minutes. */
97
+ declare function deriveMinuteBucket(nowMs: number): number;
98
+ /** Convenience wrapper for `deriveMinuteBucket(Date.now())`. */
99
+ declare function minuteBucketNow(): number;
100
+ /**
101
+ * Mint a deterministic event id for `event_id` (CAPI) and
102
+ * `client_dedup_id` (Pixel). See contract above.
103
+ *
104
+ * Callers that want a stable id across a longer window (e.g. tying two
105
+ * page-view fires back to back to the same URL) can pin `minuteBucket` to
106
+ * a well-known value; the default is `minuteBucketNow()`. For PURCHASE,
107
+ * pin `minuteBucket` to a constant per order (recommend `0`) so a
108
+ * failing browser fire that retries in a later minute still dedups
109
+ * against the server event.
110
+ */
111
+ declare function makeEventId(eventName: SnapEventName, primaryKey: string, minuteBucket?: number): string;
112
+
113
+ export { SnapEventName, SnapEventPayload, SnapUserData, deriveMinuteBucket, makeEventId, minuteBucketNow, sendSnapchatCapiEvent, trackAddCart, trackPageView, trackPurchase, trackStartCheckout, trackViewContent };