@walkeros/web-destination-posthog 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,269 @@
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
+ import { PostHogConfig, Properties } from 'posthog-js';
6
+
7
+ declare const SettingsSchema: z.ZodObject<{
8
+ apiKey: z.ZodString;
9
+ api_host: z.ZodOptional<z.ZodString>;
10
+ ui_host: z.ZodOptional<z.ZodString>;
11
+ persistence: z.ZodOptional<z.ZodEnum<{
12
+ "localStorage+cookie": "localStorage+cookie";
13
+ cookie: "cookie";
14
+ localStorage: "localStorage";
15
+ sessionStorage: "sessionStorage";
16
+ memory: "memory";
17
+ }>>;
18
+ person_profiles: z.ZodOptional<z.ZodEnum<{
19
+ always: "always";
20
+ never: "never";
21
+ identified_only: "identified_only";
22
+ }>>;
23
+ autocapture: z.ZodOptional<z.ZodBoolean>;
24
+ capture_pageview: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"history_change">]>>;
25
+ capture_pageleave: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"if_capture_pageview">]>>;
26
+ capture_heatmaps: z.ZodOptional<z.ZodBoolean>;
27
+ capture_exceptions: z.ZodOptional<z.ZodBoolean>;
28
+ disable_surveys: z.ZodOptional<z.ZodBoolean>;
29
+ disable_session_recording: z.ZodOptional<z.ZodBoolean>;
30
+ advanced_disable_flags: z.ZodOptional<z.ZodBoolean>;
31
+ cookieless_mode: z.ZodOptional<z.ZodEnum<{
32
+ always: "always";
33
+ on_reject: "on_reject";
34
+ }>>;
35
+ debug: z.ZodOptional<z.ZodBoolean>;
36
+ session_recording: z.ZodOptional<z.ZodUnknown>;
37
+ bootstrap: z.ZodOptional<z.ZodUnknown>;
38
+ identify: z.ZodOptional<z.ZodUnknown>;
39
+ group: z.ZodOptional<z.ZodUnknown>;
40
+ }, z.core.$strip>;
41
+ type Settings$1 = z.infer<typeof SettingsSchema>;
42
+
43
+ declare const MappingSchema: z.ZodObject<{
44
+ identify: z.ZodOptional<z.ZodUnknown>;
45
+ group: z.ZodOptional<z.ZodUnknown>;
46
+ reset: z.ZodOptional<z.ZodUnknown>;
47
+ }, z.core.$strip>;
48
+ type Mapping = z.infer<typeof MappingSchema>;
49
+
50
+ declare const settings: _walkeros_core_dev.JSONSchema;
51
+ declare const mapping: _walkeros_core_dev.JSONSchema;
52
+
53
+ type index$1_Mapping = Mapping;
54
+ declare const index$1_MappingSchema: typeof MappingSchema;
55
+ declare const index$1_SettingsSchema: typeof SettingsSchema;
56
+ declare const index$1_mapping: typeof mapping;
57
+ declare const index$1_settings: typeof settings;
58
+ declare namespace index$1 {
59
+ 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 };
60
+ }
61
+
62
+ /**
63
+ * Destination-level settings.
64
+ *
65
+ * PostHog's `PostHogConfig` interface has ~80 fields — extending the SDK type
66
+ * directly keeps IntelliSense complete and prevents drift. The destination adds:
67
+ * - `apiKey` (required) — first arg to `posthog.init(...)`, NOT an init option
68
+ * - `identify` — destination-level identity mapping
69
+ * - `include` — event sections flattened into `capture()` properties
70
+ * - `group` — destination-level group association
71
+ * - `_state` — runtime state (not user-facing, mutated by init/push)
72
+ *
73
+ * All other walkerOS-specific mapping features live under mapping.settings
74
+ * (see Mapping interface below). Built-in PostHog features (session_recording,
75
+ * advanced_disable_flags, disable_surveys, capture_heatmaps, capture_exceptions,
76
+ * bootstrap, cookieless_mode, ...) are passthrough via PostHogConfig.
77
+ */
78
+ interface Settings extends Partial<PostHogConfig> {
79
+ /** PostHog project API key (e.g. "phc_XXX"). First arg to posthog.init(). */
80
+ apiKey: string;
81
+ /** Destination-level identity mapping, resolved on first push. */
82
+ identify?: Mapping$1.Value;
83
+ /** Destination-level group association, resolved on first push. */
84
+ group?: Mapping$1.Value;
85
+ /** Runtime state — populated by init() and mutated by push(). Not user-facing. */
86
+ _state?: RuntimeState;
87
+ }
88
+ interface RuntimeState {
89
+ /** Last-resolved identity values, used to skip redundant identify/group calls. */
90
+ lastIdentity?: {
91
+ distinctId?: string;
92
+ };
93
+ lastGroup?: {
94
+ type?: string;
95
+ key?: string;
96
+ };
97
+ }
98
+ /**
99
+ * PostHog SDK surface — the subset of `posthog-js` the destination actually
100
+ * uses. Mirrors the real module's default singleton export shape. Tests mock
101
+ * via env.posthog to intercept every call.
102
+ */
103
+ interface PostHogSDK {
104
+ init: (token: string, config?: Partial<PostHogConfig> & {
105
+ loaded?: (posthog: PostHogSDK) => void;
106
+ }, name?: string) => PostHogSDK;
107
+ capture: (eventName: string, properties?: Properties) => void;
108
+ identify: (distinctId?: string, userPropertiesToSet?: Properties, userPropertiesToSetOnce?: Properties) => void;
109
+ setPersonProperties: (userPropertiesToSet?: Properties, userPropertiesToSetOnce?: Properties) => void;
110
+ group: (groupType: string, groupKey: string, groupPropertiesToSet?: Properties) => void;
111
+ reset: (resetDeviceId?: boolean) => void;
112
+ opt_in_capturing: (options?: {
113
+ captureEventName?: string | null | false;
114
+ captureProperties?: Properties;
115
+ }) => void;
116
+ opt_out_capturing: () => void;
117
+ }
118
+ /**
119
+ * Env — optional SDK override. Production leaves this undefined and the
120
+ * destination falls back to the real `posthog-js` default export. Tests
121
+ * provide a mock via env.posthog = { ... }.
122
+ */
123
+ interface Env extends DestinationWeb.Env {
124
+ posthog?: PostHogSDK;
125
+ }
126
+
127
+ /**
128
+ * Pre-init env — all methods are no-ops until the test runner wires spies.
129
+ */
130
+ declare const init: Env | undefined;
131
+ /**
132
+ * Post-init env — same shape. The test runner clones this and replaces
133
+ * individual methods with jest.fn() so it can assert on calls.
134
+ */
135
+ declare const push: Env;
136
+ /** Simulation tracking paths for CLI --simulate. */
137
+ declare const simulation: string[];
138
+
139
+ declare const env_init: typeof init;
140
+ declare const env_push: typeof push;
141
+ declare const env_simulation: typeof simulation;
142
+ declare namespace env {
143
+ export { env_init as init, env_push as push, env_simulation as simulation };
144
+ }
145
+
146
+ /**
147
+ * Examples may optionally carry destination-level settings.
148
+ * The test runner reads `settings` from the example and merges them
149
+ * into the base destination settings on top of the fixed apiKey.
150
+ */
151
+ type PostHogStepExample = Flow.StepExample & {
152
+ settings?: Partial<Settings>;
153
+ configInclude?: string[];
154
+ };
155
+ /**
156
+ * Default event forwarding — every walkerOS event becomes
157
+ * posthog.capture(event.name, properties). With no mapping and no
158
+ * destination-level include, properties is `{}`.
159
+ */
160
+ declare const defaultEventForwarding: PostHogStepExample;
161
+ /**
162
+ * Wildcard ignore — walkerOS's standard way to drop events. The rule
163
+ * matches but does nothing. The destination fires zero SDK calls.
164
+ */
165
+ declare const wildcardIgnored: PostHogStepExample;
166
+ /**
167
+ * Destination-level settings.include flattens the walkerOS `data` section
168
+ * into prefixed capture() properties on every push.
169
+ */
170
+ declare const destinationLevelInclude: PostHogStepExample;
171
+ /**
172
+ * Per-rule settings.include REPLACES destination-level include for the
173
+ * matched rule. Here destination-level sends `data`, but the rule
174
+ * overrides it with `globals` only.
175
+ */
176
+ declare const ruleIncludeReplaces: PostHogStepExample;
177
+ /**
178
+ * Destination-level settings.identify fires on the first push (once the
179
+ * state cache is empty). The destination calls posthog.identify() and
180
+ * tracks the resolved distinctId in runtime state; subsequent pushes
181
+ * with unchanged values do NOT re-fire identify().
182
+ *
183
+ * With NO $set/$set_once keys in the resolved object, posthog.identify
184
+ * is called with just the distinctId.
185
+ */
186
+ declare const destinationLevelIdentify: PostHogStepExample;
187
+ /**
188
+ * Per-event identify with the full PostHog identity vocabulary.
189
+ * This is the "user login" pattern: set a new distinctId and enrich
190
+ * person properties. `skip: true` suppresses the default posthog.capture()
191
+ * call because we're running identity side effects only.
192
+ *
193
+ * PostHog identify signature:
194
+ * posthog.identify(distinctId, $set, $set_once)
195
+ */
196
+ declare const userLoginIdentify: PostHogStepExample;
197
+ /**
198
+ * Person-properties-only update — when the resolved identify object has
199
+ * NO `distinctId` key, the destination calls setPersonProperties($set, $set_once)
200
+ * instead of identify(). This is the "profile update" pattern: enrich
201
+ * user properties without changing identity.
202
+ *
203
+ * `skip` defaults to false here — we intentionally ALSO capture a
204
+ * "profile update" event so it shows up in PostHog's event stream.
205
+ */
206
+ declare const profileUpdateSetPersonProperties: PostHogStepExample;
207
+ /**
208
+ * User logout — reset: true fires posthog.reset(), which clears the
209
+ * distinct ID and generates a new anonymous one. `skip: true` because
210
+ * we're only running the reset side effect, no default capture().
211
+ */
212
+ declare const userLogoutReset: PostHogStepExample;
213
+ /**
214
+ * Group assignment + group properties. PostHog's group analytics (paid)
215
+ * aggregates events by company / team / project. The destination resolves
216
+ * `settings.group` to { type, key, properties? } and calls
217
+ * posthog.group(type, key, properties). `skip: true` keeps this a
218
+ * pure side-effect rule — no "company update" capture().
219
+ */
220
+ declare const groupAssignmentWithProperties: PostHogStepExample;
221
+ /**
222
+ * Order complete — PostHog has no dedicated revenue API. Revenue tracking
223
+ * is just a capture() call with the revenue properties in data. This
224
+ * example pairs `include: ["data", "globals"]` with a destination-level
225
+ * capture. The order total, shipping, currency, etc. all become
226
+ * data_* properties on the PostHog event.
227
+ */
228
+ declare const orderCompleteWithInclude: PostHogStepExample;
229
+ /**
230
+ * Consent revoked → posthog.opt_out_capturing(). The destination checks
231
+ * the consent key declared in config.consent (here "analytics") and
232
+ * toggles accordingly. opt_out_capturing() stops capture, session
233
+ * replay, AND survey rendering.
234
+ *
235
+ * Uses the canonical StepExample.command='consent' pattern: the test
236
+ * runner dispatches via elb('walker consent', in) instead of pushing
237
+ * an event.
238
+ */
239
+ declare const consentRevokeOptOut: PostHogStepExample;
240
+ /**
241
+ * Consent granted → posthog.opt_in_capturing(). Called without arguments
242
+ * by default (the SDK fires its own $opt_in event).
243
+ */
244
+ declare const consentGrantOptIn: PostHogStepExample;
245
+
246
+ type step_PostHogStepExample = PostHogStepExample;
247
+ declare const step_consentGrantOptIn: typeof consentGrantOptIn;
248
+ declare const step_consentRevokeOptOut: typeof consentRevokeOptOut;
249
+ declare const step_defaultEventForwarding: typeof defaultEventForwarding;
250
+ declare const step_destinationLevelIdentify: typeof destinationLevelIdentify;
251
+ declare const step_destinationLevelInclude: typeof destinationLevelInclude;
252
+ declare const step_groupAssignmentWithProperties: typeof groupAssignmentWithProperties;
253
+ declare const step_orderCompleteWithInclude: typeof orderCompleteWithInclude;
254
+ declare const step_profileUpdateSetPersonProperties: typeof profileUpdateSetPersonProperties;
255
+ declare const step_ruleIncludeReplaces: typeof ruleIncludeReplaces;
256
+ declare const step_userLoginIdentify: typeof userLoginIdentify;
257
+ declare const step_userLogoutReset: typeof userLogoutReset;
258
+ declare const step_wildcardIgnored: typeof wildcardIgnored;
259
+ declare namespace step {
260
+ export { type step_PostHogStepExample as PostHogStepExample, step_consentGrantOptIn as consentGrantOptIn, step_consentRevokeOptOut as consentRevokeOptOut, step_defaultEventForwarding as defaultEventForwarding, step_destinationLevelIdentify as destinationLevelIdentify, step_destinationLevelInclude as destinationLevelInclude, step_groupAssignmentWithProperties as groupAssignmentWithProperties, step_orderCompleteWithInclude as orderCompleteWithInclude, step_profileUpdateSetPersonProperties as profileUpdateSetPersonProperties, step_ruleIncludeReplaces as ruleIncludeReplaces, step_userLoginIdentify as userLoginIdentify, step_userLogoutReset as userLogoutReset, step_wildcardIgnored as wildcardIgnored };
261
+ }
262
+
263
+ declare const index_env: typeof env;
264
+ declare const index_step: typeof step;
265
+ declare namespace index {
266
+ export { index_env as env, index_step as step };
267
+ }
268
+
269
+ export { index as examples, index$1 as schemas };