@walkeros/web-destination-pinterest 3.3.0-next-1776098542393

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,206 @@
1
+ import { DestinationWeb } from '@walkeros/web-core';
2
+ import { Flow } from '@walkeros/core';
3
+
4
+ /**
5
+ * Pinterest Tag global. The queue-based function created by the Pinterest
6
+ * snippet. Before core.js loads, calls are queued on `pintrk.queue`.
7
+ * After core.js resolves the queue, `pintrk` is replaced with the real
8
+ * implementation. Both shapes accept the same argument signatures.
9
+ */
10
+ interface Pintrk {
11
+ (command: 'load', tagId: string, identify?: IdentifyFields): void;
12
+ (command: 'page'): void;
13
+ (command: 'track', eventName: string, eventData?: EventData, callback?: (didInit: boolean, error?: unknown) => void): void;
14
+ (command: 'set', userData: IdentifyFields): void;
15
+ queue?: unknown[][];
16
+ version?: string;
17
+ }
18
+ declare global {
19
+ interface Window {
20
+ pintrk?: Pintrk;
21
+ }
22
+ }
23
+ /**
24
+ * Enhanced matching fields. Web destination strictly limits to the two
25
+ * documented client-side Pinterest Tag fields. CAPI-only fields (ph, fn,
26
+ * ln, address, country, ip, ua) belong to a future server destination
27
+ * and are intentionally not accepted here.
28
+ *
29
+ * The Pinterest JS tag auto-hashes `em` with SHA-256 before transmission —
30
+ * the destination does NOT hash.
31
+ */
32
+ interface IdentifyFields {
33
+ em?: string;
34
+ external_id?: string;
35
+ }
36
+ /**
37
+ * Event data payload for pintrk('track', ...). Pinterest has a prescribed
38
+ * set of parameter names. Common parameters across events plus an open
39
+ * `[key: string]: unknown` for event-specific fields (search_query,
40
+ * video_title, lead_type, opt_out_type, custom properties, etc.).
41
+ */
42
+ interface EventData {
43
+ value?: number;
44
+ order_quantity?: number;
45
+ currency?: string;
46
+ event_id?: string;
47
+ order_id?: string;
48
+ promo_code?: string;
49
+ property?: string;
50
+ product_name?: string;
51
+ product_id?: string;
52
+ product_category?: string;
53
+ product_brand?: string;
54
+ product_price?: number;
55
+ product_quantity?: number;
56
+ product_variant_id?: string;
57
+ product_variant?: string;
58
+ line_items?: LineItem[];
59
+ search_query?: string;
60
+ video_title?: string;
61
+ lead_type?: string;
62
+ opt_out_type?: 'LDP';
63
+ [key: string]: unknown;
64
+ }
65
+ interface LineItem {
66
+ product_name?: string;
67
+ product_id?: string;
68
+ product_category?: string;
69
+ product_brand?: string;
70
+ product_price?: number;
71
+ product_quantity?: number;
72
+ product_variant_id?: string;
73
+ product_variant?: string;
74
+ [key: string]: unknown;
75
+ }
76
+ /**
77
+ * Env — mock surface for tests. Pinterest Tag uses window.pintrk, so
78
+ * the env extends DestinationWeb.Env (which already provides window
79
+ * and document).
80
+ */
81
+ interface Env extends DestinationWeb.Env {
82
+ window: {
83
+ pintrk?: Pintrk;
84
+ };
85
+ }
86
+
87
+ /**
88
+ * Pre-init environment — pintrk is not yet on the window.
89
+ * Used to validate the init path that creates the queue function.
90
+ */
91
+ declare const init: Env;
92
+ /**
93
+ * Post-init environment — pintrk is available as a spy-able function.
94
+ * Tests clone this and replace `pintrk` with a jest.fn() to record calls.
95
+ */
96
+ declare const push: Env;
97
+ /** Simulation tracking paths for CLI --simulate. */
98
+ declare const simulation: string[];
99
+
100
+ declare const env_init: typeof init;
101
+ declare const env_push: typeof push;
102
+ declare const env_simulation: typeof simulation;
103
+ declare namespace env {
104
+ export { env_init as init, env_push as push, env_simulation as simulation };
105
+ }
106
+
107
+ /**
108
+ * Output convention:
109
+ * - Single SDK call: out = ['window.pintrk', 'track', 'checkout', { ... }]
110
+ * (flat array: first element is the dot-path, remaining elements are args)
111
+ * - Multiple SDK calls: out = [ [path, ...args], [path, ...args] ]
112
+ * - Zero SDK calls: out = []
113
+ *
114
+ * The step-examples test runner normalizes both shapes via flatten().
115
+ */
116
+ /**
117
+ * Default event forwarding — no rule. Without a mapping.name, the walkerOS
118
+ * event name is forwarded as-is. Pinterest accepts it but won't match a
119
+ * standard conversion event. event_id is auto-attached for deduplication.
120
+ */
121
+ declare const defaultForward: Flow.StepExample;
122
+ /**
123
+ * Wildcard ignore pattern — the standard walkerOS way to suppress noisy
124
+ * events. `mapping.ignore: true` at rule level produces zero SDK calls.
125
+ */
126
+ declare const wildcardIgnored: Flow.StepExample;
127
+ /**
128
+ * Standard Pinterest event rename via mapping.name. walkerOS "page view"
129
+ * → Pinterest "pagevisit". The ONLY way to get Pinterest to recognize
130
+ * a conversion event — the destination never auto-maps.
131
+ */
132
+ declare const pageViewRename: Flow.StepExample;
133
+ /**
134
+ * Search — walkerOS site search → Pinterest "search" with search_query.
135
+ * Illustrates single-field mapping.data resolution.
136
+ */
137
+ declare const siteSearch: Flow.StepExample;
138
+ /**
139
+ * Single-product viewcontent. Illustrates:
140
+ * - currency fallback via { key, value: 'EUR' }
141
+ * - flat product_* parameter names
142
+ */
143
+ declare const productViewContent: Flow.StepExample;
144
+ /**
145
+ * Add-to-cart with an inline line_items array.
146
+ *
147
+ * Pinterest sends a single track() call with line_items as an ARRAY
148
+ * INSIDE the event data — NOT a loop of N separate calls.
149
+ */
150
+ declare const productAddToCart: Flow.StepExample;
151
+ /**
152
+ * Multi-product checkout — the canonical Pinterest ecommerce pattern.
153
+ * `line_items.loop: ["nested", { condition, map }]` iterates event.nested
154
+ * and produces ONE array inside a SINGLE track() call.
155
+ *
156
+ * Default fixture has 3 nested entries: ers (420 black), cc (42, no color),
157
+ * gift (no price → filtered out by condition).
158
+ */
159
+ declare const orderCompleteCheckout: Flow.StepExample;
160
+ /**
161
+ * Lead conversion with per-event enhanced matching update.
162
+ *
163
+ * The rule-level settings.identify resolves to { em, external_id } and
164
+ * triggers pintrk('set', data) BEFORE the track() call — enhanced
165
+ * matching data is associated with the same event via event_id.
166
+ */
167
+ declare const userLoginLead: Flow.StepExample;
168
+ /**
169
+ * mapping.skip — processes side effects (identify set) but suppresses
170
+ * the default pintrk('track', ...) call. Useful when an upstream
171
+ * destination already fired the conversion and you only want to update
172
+ * enhanced matching.
173
+ */
174
+ declare const identifyOnlySkip: Flow.StepExample;
175
+ /**
176
+ * Consent revocation — walkerOS walker consent { marketing: false }.
177
+ * The destination's on('consent') handler flips the runtime state flag
178
+ * and stops calling pintrk('track', ...) for subsequent events. There
179
+ * is NO opt_out SDK call — Pinterest has no such API.
180
+ *
181
+ * Expected out: [] — no pintrk calls fire as a direct result of the
182
+ * consent dispatch.
183
+ */
184
+ declare const consentRevoke: Flow.StepExample;
185
+ /**
186
+ * Consent grant — explicit opt-in. Same behavior: the destination's
187
+ * on('consent') flips the flag. No SDK call fires.
188
+ */
189
+ declare const consentGrant: Flow.StepExample;
190
+
191
+ declare const step_consentGrant: typeof consentGrant;
192
+ declare const step_consentRevoke: typeof consentRevoke;
193
+ declare const step_defaultForward: typeof defaultForward;
194
+ declare const step_identifyOnlySkip: typeof identifyOnlySkip;
195
+ declare const step_orderCompleteCheckout: typeof orderCompleteCheckout;
196
+ declare const step_pageViewRename: typeof pageViewRename;
197
+ declare const step_productAddToCart: typeof productAddToCart;
198
+ declare const step_productViewContent: typeof productViewContent;
199
+ declare const step_siteSearch: typeof siteSearch;
200
+ declare const step_userLoginLead: typeof userLoginLead;
201
+ declare const step_wildcardIgnored: typeof wildcardIgnored;
202
+ declare namespace step {
203
+ export { step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultForward as defaultForward, step_identifyOnlySkip as identifyOnlySkip, step_orderCompleteCheckout as orderCompleteCheckout, step_pageViewRename as pageViewRename, step_productAddToCart as productAddToCart, step_productViewContent as productViewContent, step_siteSearch as siteSearch, step_userLoginLead as userLoginLead, step_wildcardIgnored as wildcardIgnored };
204
+ }
205
+
206
+ export { env, step };
@@ -0,0 +1,206 @@
1
+ import { DestinationWeb } from '@walkeros/web-core';
2
+ import { Flow } from '@walkeros/core';
3
+
4
+ /**
5
+ * Pinterest Tag global. The queue-based function created by the Pinterest
6
+ * snippet. Before core.js loads, calls are queued on `pintrk.queue`.
7
+ * After core.js resolves the queue, `pintrk` is replaced with the real
8
+ * implementation. Both shapes accept the same argument signatures.
9
+ */
10
+ interface Pintrk {
11
+ (command: 'load', tagId: string, identify?: IdentifyFields): void;
12
+ (command: 'page'): void;
13
+ (command: 'track', eventName: string, eventData?: EventData, callback?: (didInit: boolean, error?: unknown) => void): void;
14
+ (command: 'set', userData: IdentifyFields): void;
15
+ queue?: unknown[][];
16
+ version?: string;
17
+ }
18
+ declare global {
19
+ interface Window {
20
+ pintrk?: Pintrk;
21
+ }
22
+ }
23
+ /**
24
+ * Enhanced matching fields. Web destination strictly limits to the two
25
+ * documented client-side Pinterest Tag fields. CAPI-only fields (ph, fn,
26
+ * ln, address, country, ip, ua) belong to a future server destination
27
+ * and are intentionally not accepted here.
28
+ *
29
+ * The Pinterest JS tag auto-hashes `em` with SHA-256 before transmission —
30
+ * the destination does NOT hash.
31
+ */
32
+ interface IdentifyFields {
33
+ em?: string;
34
+ external_id?: string;
35
+ }
36
+ /**
37
+ * Event data payload for pintrk('track', ...). Pinterest has a prescribed
38
+ * set of parameter names. Common parameters across events plus an open
39
+ * `[key: string]: unknown` for event-specific fields (search_query,
40
+ * video_title, lead_type, opt_out_type, custom properties, etc.).
41
+ */
42
+ interface EventData {
43
+ value?: number;
44
+ order_quantity?: number;
45
+ currency?: string;
46
+ event_id?: string;
47
+ order_id?: string;
48
+ promo_code?: string;
49
+ property?: string;
50
+ product_name?: string;
51
+ product_id?: string;
52
+ product_category?: string;
53
+ product_brand?: string;
54
+ product_price?: number;
55
+ product_quantity?: number;
56
+ product_variant_id?: string;
57
+ product_variant?: string;
58
+ line_items?: LineItem[];
59
+ search_query?: string;
60
+ video_title?: string;
61
+ lead_type?: string;
62
+ opt_out_type?: 'LDP';
63
+ [key: string]: unknown;
64
+ }
65
+ interface LineItem {
66
+ product_name?: string;
67
+ product_id?: string;
68
+ product_category?: string;
69
+ product_brand?: string;
70
+ product_price?: number;
71
+ product_quantity?: number;
72
+ product_variant_id?: string;
73
+ product_variant?: string;
74
+ [key: string]: unknown;
75
+ }
76
+ /**
77
+ * Env — mock surface for tests. Pinterest Tag uses window.pintrk, so
78
+ * the env extends DestinationWeb.Env (which already provides window
79
+ * and document).
80
+ */
81
+ interface Env extends DestinationWeb.Env {
82
+ window: {
83
+ pintrk?: Pintrk;
84
+ };
85
+ }
86
+
87
+ /**
88
+ * Pre-init environment — pintrk is not yet on the window.
89
+ * Used to validate the init path that creates the queue function.
90
+ */
91
+ declare const init: Env;
92
+ /**
93
+ * Post-init environment — pintrk is available as a spy-able function.
94
+ * Tests clone this and replace `pintrk` with a jest.fn() to record calls.
95
+ */
96
+ declare const push: Env;
97
+ /** Simulation tracking paths for CLI --simulate. */
98
+ declare const simulation: string[];
99
+
100
+ declare const env_init: typeof init;
101
+ declare const env_push: typeof push;
102
+ declare const env_simulation: typeof simulation;
103
+ declare namespace env {
104
+ export { env_init as init, env_push as push, env_simulation as simulation };
105
+ }
106
+
107
+ /**
108
+ * Output convention:
109
+ * - Single SDK call: out = ['window.pintrk', 'track', 'checkout', { ... }]
110
+ * (flat array: first element is the dot-path, remaining elements are args)
111
+ * - Multiple SDK calls: out = [ [path, ...args], [path, ...args] ]
112
+ * - Zero SDK calls: out = []
113
+ *
114
+ * The step-examples test runner normalizes both shapes via flatten().
115
+ */
116
+ /**
117
+ * Default event forwarding — no rule. Without a mapping.name, the walkerOS
118
+ * event name is forwarded as-is. Pinterest accepts it but won't match a
119
+ * standard conversion event. event_id is auto-attached for deduplication.
120
+ */
121
+ declare const defaultForward: Flow.StepExample;
122
+ /**
123
+ * Wildcard ignore pattern — the standard walkerOS way to suppress noisy
124
+ * events. `mapping.ignore: true` at rule level produces zero SDK calls.
125
+ */
126
+ declare const wildcardIgnored: Flow.StepExample;
127
+ /**
128
+ * Standard Pinterest event rename via mapping.name. walkerOS "page view"
129
+ * → Pinterest "pagevisit". The ONLY way to get Pinterest to recognize
130
+ * a conversion event — the destination never auto-maps.
131
+ */
132
+ declare const pageViewRename: Flow.StepExample;
133
+ /**
134
+ * Search — walkerOS site search → Pinterest "search" with search_query.
135
+ * Illustrates single-field mapping.data resolution.
136
+ */
137
+ declare const siteSearch: Flow.StepExample;
138
+ /**
139
+ * Single-product viewcontent. Illustrates:
140
+ * - currency fallback via { key, value: 'EUR' }
141
+ * - flat product_* parameter names
142
+ */
143
+ declare const productViewContent: Flow.StepExample;
144
+ /**
145
+ * Add-to-cart with an inline line_items array.
146
+ *
147
+ * Pinterest sends a single track() call with line_items as an ARRAY
148
+ * INSIDE the event data — NOT a loop of N separate calls.
149
+ */
150
+ declare const productAddToCart: Flow.StepExample;
151
+ /**
152
+ * Multi-product checkout — the canonical Pinterest ecommerce pattern.
153
+ * `line_items.loop: ["nested", { condition, map }]` iterates event.nested
154
+ * and produces ONE array inside a SINGLE track() call.
155
+ *
156
+ * Default fixture has 3 nested entries: ers (420 black), cc (42, no color),
157
+ * gift (no price → filtered out by condition).
158
+ */
159
+ declare const orderCompleteCheckout: Flow.StepExample;
160
+ /**
161
+ * Lead conversion with per-event enhanced matching update.
162
+ *
163
+ * The rule-level settings.identify resolves to { em, external_id } and
164
+ * triggers pintrk('set', data) BEFORE the track() call — enhanced
165
+ * matching data is associated with the same event via event_id.
166
+ */
167
+ declare const userLoginLead: Flow.StepExample;
168
+ /**
169
+ * mapping.skip — processes side effects (identify set) but suppresses
170
+ * the default pintrk('track', ...) call. Useful when an upstream
171
+ * destination already fired the conversion and you only want to update
172
+ * enhanced matching.
173
+ */
174
+ declare const identifyOnlySkip: Flow.StepExample;
175
+ /**
176
+ * Consent revocation — walkerOS walker consent { marketing: false }.
177
+ * The destination's on('consent') handler flips the runtime state flag
178
+ * and stops calling pintrk('track', ...) for subsequent events. There
179
+ * is NO opt_out SDK call — Pinterest has no such API.
180
+ *
181
+ * Expected out: [] — no pintrk calls fire as a direct result of the
182
+ * consent dispatch.
183
+ */
184
+ declare const consentRevoke: Flow.StepExample;
185
+ /**
186
+ * Consent grant — explicit opt-in. Same behavior: the destination's
187
+ * on('consent') flips the flag. No SDK call fires.
188
+ */
189
+ declare const consentGrant: Flow.StepExample;
190
+
191
+ declare const step_consentGrant: typeof consentGrant;
192
+ declare const step_consentRevoke: typeof consentRevoke;
193
+ declare const step_defaultForward: typeof defaultForward;
194
+ declare const step_identifyOnlySkip: typeof identifyOnlySkip;
195
+ declare const step_orderCompleteCheckout: typeof orderCompleteCheckout;
196
+ declare const step_pageViewRename: typeof pageViewRename;
197
+ declare const step_productAddToCart: typeof productAddToCart;
198
+ declare const step_productViewContent: typeof productViewContent;
199
+ declare const step_siteSearch: typeof siteSearch;
200
+ declare const step_userLoginLead: typeof userLoginLead;
201
+ declare const step_wildcardIgnored: typeof wildcardIgnored;
202
+ declare namespace step {
203
+ export { step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultForward as defaultForward, step_identifyOnlySkip as identifyOnlySkip, step_orderCompleteCheckout as orderCompleteCheckout, step_pageViewRename as pageViewRename, step_productAddToCart as productAddToCart, step_productViewContent as productViewContent, step_siteSearch as siteSearch, step_userLoginLead as userLoginLead, step_wildcardIgnored as wildcardIgnored };
204
+ }
205
+
206
+ export { env, step };