@walkeros/web-destination-tiktok 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.
package/dist/dev.d.ts ADDED
@@ -0,0 +1,266 @@
1
+ import * as _walkeros_core_dev from '@walkeros/core/dev';
2
+ import { z } from '@walkeros/core/dev';
3
+ import { Mapping as Mapping$1, Flow } from '@walkeros/core';
4
+ import { DestinationWeb } from '@walkeros/web-core';
5
+
6
+ declare const SettingsSchema: z.ZodObject<{
7
+ apiKey: z.ZodString;
8
+ auto_config: z.ZodOptional<z.ZodBoolean>;
9
+ limited_data_use: z.ZodOptional<z.ZodBoolean>;
10
+ identify: z.ZodOptional<z.ZodUnknown>;
11
+ }, z.core.$strip>;
12
+ type Settings$1 = z.infer<typeof SettingsSchema>;
13
+
14
+ declare const MappingSchema: z.ZodObject<{
15
+ identify: z.ZodOptional<z.ZodUnknown>;
16
+ }, z.core.$strip>;
17
+ type Mapping = z.infer<typeof MappingSchema>;
18
+
19
+ declare const settings: _walkeros_core_dev.JSONSchema;
20
+ declare const mapping: _walkeros_core_dev.JSONSchema;
21
+
22
+ type index$1_Mapping = Mapping;
23
+ declare const index$1_MappingSchema: typeof MappingSchema;
24
+ declare const index$1_SettingsSchema: typeof SettingsSchema;
25
+ declare const index$1_mapping: typeof mapping;
26
+ declare const index$1_settings: typeof settings;
27
+ declare namespace index$1 {
28
+ export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
29
+ }
30
+
31
+ /**
32
+ * Settings (destination-level).
33
+ *
34
+ * apiKey is the TikTok Pixel ID. `identify` resolves to Advanced Matching
35
+ * parameters (email, phone_number, external_id) — TikTok auto-hashes these
36
+ * before sending, so raw values are safe. `include` names walkerOS event
37
+ * sections to flatten into prefixed TikTok event parameters. All other
38
+ * TikTok-native snake_case options (e.g., `auto_config`, `limited_data_use`)
39
+ * are passed through to `ttq.load(apiKey, options)`.
40
+ */
41
+ interface Settings {
42
+ /** TikTok Pixel ID — first argument to ttq.load(...). Required. */
43
+ apiKey: string;
44
+ /**
45
+ * walkerOS mapping value resolving to an Advanced Matching object with any
46
+ * of: `email`, `phone_number`, `external_id`. Applied on first push and
47
+ * re-fired only on change (runtime state in _state.lastIdentity).
48
+ */
49
+ identify?: Mapping$1.Value;
50
+ /** TikTok default: true. Enable auto-detection of form fields for Advanced Matching. */
51
+ auto_config?: boolean;
52
+ /** TikTok default: false. Restrict data use under U.S. state privacy laws. */
53
+ limited_data_use?: boolean;
54
+ /**
55
+ * Runtime state — populated by init() and mutated by push(). Not
56
+ * user-facing. Stores last-resolved identity so subsequent pushes with
57
+ * unchanged values skip redundant ttq.identify() calls.
58
+ */
59
+ _state?: RuntimeState;
60
+ /**
61
+ * Pass-through bucket: any additional TikTok Pixel init config (snake_case
62
+ * keys per TikTok's docs). Merged into ttq.load()'s second argument.
63
+ */
64
+ [key: string]: unknown;
65
+ }
66
+ interface RuntimeState {
67
+ lastIdentity?: {
68
+ email?: string;
69
+ phone_number?: string;
70
+ external_id?: string;
71
+ };
72
+ }
73
+ /**
74
+ * Advanced Matching parameter shape — what settings.identify must resolve to.
75
+ * All fields are optional; if the resolved object has no non-empty values,
76
+ * the destination skips the ttq.identify() call entirely.
77
+ */
78
+ interface IdentifyParams {
79
+ email?: string;
80
+ phone_number?: string;
81
+ external_id?: string;
82
+ }
83
+ /**
84
+ * Minimal surface of TikTok's window.ttq this destination uses. Tests mock
85
+ * this by attaching a plain object to env.window.ttq; production uses the
86
+ * real SDK created by the snippet setup() call.
87
+ */
88
+ interface TTQ {
89
+ (...args: unknown[]): void;
90
+ load: (pixelId: string, config?: Record<string, unknown>) => void;
91
+ page: () => void;
92
+ track: (event: string, params?: Record<string, unknown>, options?: {
93
+ event_id?: string;
94
+ }) => void;
95
+ identify: (params: IdentifyParams) => void;
96
+ enableCookie: () => void;
97
+ disableCookie: () => void;
98
+ /** Queue-based pattern — snippet sets this; destination does not read it. */
99
+ methods?: string[];
100
+ /** Internal queue populated before the CDN SDK loads. */
101
+ _i?: Record<string, unknown>;
102
+ /** Flag the snippet sets after the real SDK loads. */
103
+ loaded?: boolean;
104
+ }
105
+ /**
106
+ * Env — the destination reads `window.ttq` via getEnv(env). Tests attach
107
+ * a mock ttq to env.window; production reads window.ttq created by the
108
+ * SDK snippet.
109
+ */
110
+ interface Env extends DestinationWeb.Env {
111
+ window: {
112
+ ttq: TTQ;
113
+ };
114
+ document: {
115
+ createElement: (tagName: string) => Element;
116
+ head: {
117
+ appendChild: (node: unknown) => void;
118
+ };
119
+ };
120
+ }
121
+
122
+ /**
123
+ * Pre-init env — destination init() call will set up ttq and load the
124
+ * script. Tests receive this as a starting point.
125
+ */
126
+ declare const init: Env;
127
+ /**
128
+ * Post-init env — same shape; the test runner clones this and replaces
129
+ * individual ttq methods with jest.fn() so it can assert on calls.
130
+ */
131
+ declare const push: Env;
132
+ /** Simulation tracking paths for CLI --simulate. */
133
+ declare const simulation: string[];
134
+
135
+ declare const env_init: typeof init;
136
+ declare const env_push: typeof push;
137
+ declare const env_simulation: typeof simulation;
138
+ declare namespace env {
139
+ export { env_init as init, env_push as push, env_simulation as simulation };
140
+ }
141
+
142
+ /**
143
+ * Examples may optionally carry destination-level settings. The test
144
+ * runner reads `settings` from the example and merges it into the base
145
+ * destination settings on top of the fixed apiKey.
146
+ */
147
+ type TikTokStepExample = Flow.StepExample & {
148
+ settings?: Partial<Settings>;
149
+ configInclude?: string[];
150
+ };
151
+ /**
152
+ * Default event forwarding — every walkerOS event becomes a ttq.track()
153
+ * call. With no mapping and no destination-level include, the params
154
+ * object is empty. event_id is always passed as the 3rd argument (TikTok
155
+ * dedup between pixel and Events API).
156
+ *
157
+ * NOTE: The raw walkerOS event name "product view" (with space) is NOT a
158
+ * TikTok standard event. Without a mapping.name override, TikTok treats
159
+ * it as a custom event — functional for audience building, no
160
+ * optimization. The next example shows the recommended override.
161
+ */
162
+ declare const defaultEventForwarding: TikTokStepExample;
163
+ /**
164
+ * Wildcard ignore — walkerOS's standard way to drop events. The rule
165
+ * matches but does nothing. The destination fires zero SDK calls.
166
+ */
167
+ declare const wildcardIgnored: TikTokStepExample;
168
+ /**
169
+ * The canonical TikTok pattern: walkerOS "product view" → TikTok
170
+ * "ViewContent" via mapping.name. mapping.data builds the TikTok-native
171
+ * parameter shape (content_type, content_id, content_name, value,
172
+ * currency). include is explicitly set to [] so prefixed walkerOS
173
+ * properties don't leak onto the call and confuse TikTok's matcher.
174
+ */
175
+ declare const productViewContent: TikTokStepExample;
176
+ /**
177
+ * Destination-level settings.include flattens the walkerOS `data` section
178
+ * into prefixed TikTok event parameters on every push. This is the
179
+ * "dump everything" mode — useful for custom events where TikTok won't
180
+ * do optimization anyway, and no mapping.data is needed.
181
+ */
182
+ declare const destinationLevelInclude: TikTokStepExample;
183
+ /**
184
+ * Per-rule settings.include REPLACES destination-level include for the
185
+ * matched rule (design doc §6: mapping-level include replaces, not
186
+ * merges with, destination-level include).
187
+ */
188
+ declare const ruleIncludeReplaces: TikTokStepExample;
189
+ /**
190
+ * Destination-level settings.identify fires on the first push (once the
191
+ * state cache is empty). Advanced Matching parameters (email,
192
+ * phone_number, external_id) are passed to ttq.identify() which
193
+ * auto-hashes them SHA256 before sending. Subsequent pushes with
194
+ * unchanged values do NOT re-fire ttq.identify() — runtime state tracks
195
+ * the last-resolved identity.
196
+ *
197
+ * walkerOS's default user fixture has user.id='us3r' and no email/phone,
198
+ * so the example injects data and maps from there.
199
+ */
200
+ declare const destinationLevelIdentify: TikTokStepExample;
201
+ /**
202
+ * User registration → CompleteRegistration standard event with per-event
203
+ * identify. The user just provided their email + phone, so this is the
204
+ * moment to fire Advanced Matching for this session. The per-event
205
+ * identify overrides any destination-level identify for this one push.
206
+ */
207
+ declare const userRegisterCompleteRegistration: TikTokStepExample;
208
+ /**
209
+ * Multi-product order → CompletePayment standard event. The canonical
210
+ * TikTok ecommerce pattern:
211
+ * - mapping.name flips the walkerOS event to TikTok's rigid taxonomy
212
+ * - mapping.data builds the TikTok-native parameter shape
213
+ * - loop iterates event.nested to produce the `contents` array, one
214
+ * entry per product
215
+ * - { key, value: 'EUR' } provides a currency fallback if data.currency
216
+ * is absent (here data.currency is 'EUR' so the key wins)
217
+ *
218
+ * The default "order complete" fixture has 3 nested entries: two
219
+ * products (ers, cc) and one gift (Surprise — no id, no price).
220
+ */
221
+ declare const orderCompleteCompletePayment: TikTokStepExample;
222
+ /**
223
+ * Search → TikTok Search standard event. Minimal example that shows how
224
+ * a walkerOS search event flips through mapping.name with a single
225
+ * mapping.data field (the query string).
226
+ */
227
+ declare const searchSubmitSearch: TikTokStepExample;
228
+ /**
229
+ * Consent granted → ttq.enableCookie(). The destination checks the
230
+ * consent keys declared in config.consent (here "marketing" — TikTok is
231
+ * an ad platform, not analytics) and toggles cookie behavior.
232
+ *
233
+ * Uses the canonical StepExample.command='consent' pattern: the test
234
+ * runner dispatches via elb('walker consent', in) instead of pushing
235
+ * an event.
236
+ */
237
+ declare const consentGrantEnableCookie: TikTokStepExample;
238
+ /**
239
+ * Consent revoked → ttq.disableCookie(). TikTok stops setting and
240
+ * reading its first-party cookie (_ttp) for attribution.
241
+ */
242
+ declare const consentRevokeDisableCookie: TikTokStepExample;
243
+
244
+ type step_TikTokStepExample = TikTokStepExample;
245
+ declare const step_consentGrantEnableCookie: typeof consentGrantEnableCookie;
246
+ declare const step_consentRevokeDisableCookie: typeof consentRevokeDisableCookie;
247
+ declare const step_defaultEventForwarding: typeof defaultEventForwarding;
248
+ declare const step_destinationLevelIdentify: typeof destinationLevelIdentify;
249
+ declare const step_destinationLevelInclude: typeof destinationLevelInclude;
250
+ declare const step_orderCompleteCompletePayment: typeof orderCompleteCompletePayment;
251
+ declare const step_productViewContent: typeof productViewContent;
252
+ declare const step_ruleIncludeReplaces: typeof ruleIncludeReplaces;
253
+ declare const step_searchSubmitSearch: typeof searchSubmitSearch;
254
+ declare const step_userRegisterCompleteRegistration: typeof userRegisterCompleteRegistration;
255
+ declare const step_wildcardIgnored: typeof wildcardIgnored;
256
+ declare namespace step {
257
+ export { type step_TikTokStepExample as TikTokStepExample, step_consentGrantEnableCookie as consentGrantEnableCookie, step_consentRevokeDisableCookie as consentRevokeDisableCookie, step_defaultEventForwarding as defaultEventForwarding, step_destinationLevelIdentify as destinationLevelIdentify, step_destinationLevelInclude as destinationLevelInclude, step_orderCompleteCompletePayment as orderCompleteCompletePayment, step_productViewContent as productViewContent, step_ruleIncludeReplaces as ruleIncludeReplaces, step_searchSubmitSearch as searchSubmitSearch, step_userRegisterCompleteRegistration as userRegisterCompleteRegistration, step_wildcardIgnored as wildcardIgnored };
258
+ }
259
+
260
+ declare const index_env: typeof env;
261
+ declare const index_step: typeof step;
262
+ declare namespace index {
263
+ export { index_env as env, index_step as step };
264
+ }
265
+
266
+ export { index as examples, index$1 as schemas };