@walkeros/server-destination-posthog 4.8.1-next-1792019907609 → 4.8.2

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/CHANGELOG.md CHANGED
@@ -1,12 +1,43 @@
1
1
  # @walkeros/server-destination-posthog
2
2
 
3
- ## 4.8.1-next-1792019907609
3
+ ## 4.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 2374f54: `settings.include` is removed; it had no effect, use
8
+ `config.include`. Events batch by default (`config.batch` 20 events or 10
9
+ seconds) through `pushBatch`; a failed send fails its events and lands them in
10
+ the dead-letter queue instead of counting as delivered.
11
+ - acf757d: A silent rule whose identify, group or similar mapping resolves to
12
+ nothing sends nothing, counts as delivered and writes one DEBUG line naming
13
+ the call and mapping key, never the value. HubSpot's warning and Mixpanel's
14
+ error for this case are now DEBUG, because nothing was lost.
15
+ - 7e5fc27: Retries stay inside the destination's `config.timeout`: a quarter of
16
+ it per attempt, at most two retries, and a value set in the settings wins.
17
+ RudderStack gains a `timeout` setting. Events carry `event.id` as the vendor's
18
+ dedup id (PostHog on `capture` only), so at-least-once delivery drops
19
+ duplicates.
20
+ - Updated dependencies [2374f54]
21
+ - Updated dependencies [7e5fc27]
22
+ - Updated dependencies [2374f54]
23
+ - Updated dependencies [964590a]
24
+ - Updated dependencies [4100ede]
25
+ - Updated dependencies [2374f54]
26
+ - Updated dependencies [2374f54]
27
+ - Updated dependencies [15eb7b2]
28
+ - Updated dependencies [33a2779]
29
+ - Updated dependencies [33a2779]
30
+ - Updated dependencies [2374f54]
31
+ - @walkeros/core@4.8.2
32
+ - @walkeros/server-core@4.8.2
33
+
34
+ ## 4.8.1
4
35
 
5
36
  ### Patch Changes
6
37
 
7
38
  - Updated dependencies [1062e99]
8
- - @walkeros/core@4.8.1-next-1792019907609
9
- - @walkeros/server-core@4.8.1-next-1792019907609
39
+ - @walkeros/core@4.8.1
40
+ - @walkeros/server-core@4.8.1
10
41
 
11
42
  ## 4.8.0
12
43
 
package/README.md CHANGED
@@ -32,7 +32,7 @@ npm install @walkeros/server-destination-posthog
32
32
  "destinations": {
33
33
  "posthog": {
34
34
  "package": "@walkeros/server-destination-posthog",
35
- "config": {}
35
+ "config": { "settings": { "apiKey": "YOUR_API_KEY" } }
36
36
  }
37
37
  }
38
38
  }
package/dist/dev.d.mts CHANGED
@@ -12,11 +12,15 @@ declare const SettingsSchema: z.ZodObject<{
12
12
  personalApiKey: z.ZodOptional<z.ZodString>;
13
13
  featureFlagsPollingInterval: z.ZodOptional<z.ZodNumber>;
14
14
  disableGeoip: z.ZodOptional<z.ZodBoolean>;
15
+ disableCompression: z.ZodOptional<z.ZodBoolean>;
16
+ requestTimeout: z.ZodOptional<z.ZodNumber>;
17
+ fetchRetryCount: z.ZodOptional<z.ZodNumber>;
18
+ fetchRetryDelay: z.ZodOptional<z.ZodNumber>;
15
19
  debug: z.ZodOptional<z.ZodBoolean>;
20
+ disabled: z.ZodOptional<z.ZodBoolean>;
16
21
  identify: z.ZodOptional<z.ZodUnknown>;
17
22
  group: z.ZodOptional<z.ZodUnknown>;
18
- include: z.ZodOptional<z.ZodArray<z.ZodString>>;
19
- }, z.core.$strip>;
23
+ }, z.core.$strict>;
20
24
  type Settings$1 = z.infer<typeof SettingsSchema>;
21
25
 
22
26
  declare const MappingSchema: z.ZodObject<{
@@ -46,8 +50,6 @@ interface Settings {
46
50
  identify?: Mapping$1.Value;
47
51
  /** Destination-level group mapping */
48
52
  group?: Mapping$1.Value;
49
- /** Event sections to flatten into capture properties */
50
- include?: string[];
51
53
  host?: string;
52
54
  flushAt?: number;
53
55
  flushInterval?: number;
@@ -60,6 +62,8 @@ interface Settings {
60
62
  fetchRetryDelay?: number;
61
63
  debug?: boolean;
62
64
  disabled?: boolean;
65
+ /** The running send; the next one waits for it. Runtime only. */
66
+ _sending?: Promise<void>;
63
67
  }
64
68
  /**
65
69
  * The part of a PostHog client this destination calls. `PostHog` from
@@ -70,6 +74,10 @@ interface PostHogClient {
70
74
  capture(props: Parameters<PostHog['capture']>[0]): void;
71
75
  identify(props: Parameters<PostHog['identify']>[0]): void;
72
76
  groupIdentify(props: Parameters<PostHog['groupIdentify']>[0]): void;
77
+ /** Sends the queued calls; rejects when the request failed. */
78
+ flush(): Promise<void>;
79
+ /** The SDK reports a failed send as an `error` event; returns its remover. */
80
+ on?(event: 'error', listener: (error: unknown) => void): () => void;
73
81
  shutdown(): Promise<void> | void;
74
82
  enable(): Promise<void> | void;
75
83
  disable(): Promise<void> | void;
@@ -144,6 +152,14 @@ declare const consentRevoke: PostHogStepExample;
144
152
  * Consent granted - client.enable() is called.
145
153
  */
146
154
  declare const consentGrant: PostHogStepExample;
155
+ /** A silent rule without identify or group mappings calls nothing. */
156
+ declare const silentRule: PostHogStepExample;
157
+ /**
158
+ * The silent group identify rule of groupIdentifyWithProperties on an event
159
+ * without data: no group key resolves and the rule suppresses the capture,
160
+ * so nothing is sent.
161
+ */
162
+ declare const groupIdentifyWithoutData: PostHogStepExample;
147
163
 
148
164
  type step_PostHogStepExample = PostHogStepExample;
149
165
  declare const step_captureWithGroupContext: typeof captureWithGroupContext;
@@ -152,9 +168,11 @@ declare const step_consentGrant: typeof consentGrant;
152
168
  declare const step_consentRevoke: typeof consentRevoke;
153
169
  declare const step_defaultCapture: typeof defaultCapture;
154
170
  declare const step_groupIdentifyWithProperties: typeof groupIdentifyWithProperties;
171
+ declare const step_groupIdentifyWithoutData: typeof groupIdentifyWithoutData;
155
172
  declare const step_identifyWithSetAndSetOnce: typeof identifyWithSetAndSetOnce;
173
+ declare const step_silentRule: typeof silentRule;
156
174
  declare namespace step {
157
- export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce };
175
+ export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_groupIdentifyWithoutData as groupIdentifyWithoutData, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce, step_silentRule as silentRule };
158
176
  }
159
177
 
160
178
  declare const index_env: typeof env;
package/dist/dev.d.ts CHANGED
@@ -12,11 +12,15 @@ declare const SettingsSchema: z.ZodObject<{
12
12
  personalApiKey: z.ZodOptional<z.ZodString>;
13
13
  featureFlagsPollingInterval: z.ZodOptional<z.ZodNumber>;
14
14
  disableGeoip: z.ZodOptional<z.ZodBoolean>;
15
+ disableCompression: z.ZodOptional<z.ZodBoolean>;
16
+ requestTimeout: z.ZodOptional<z.ZodNumber>;
17
+ fetchRetryCount: z.ZodOptional<z.ZodNumber>;
18
+ fetchRetryDelay: z.ZodOptional<z.ZodNumber>;
15
19
  debug: z.ZodOptional<z.ZodBoolean>;
20
+ disabled: z.ZodOptional<z.ZodBoolean>;
16
21
  identify: z.ZodOptional<z.ZodUnknown>;
17
22
  group: z.ZodOptional<z.ZodUnknown>;
18
- include: z.ZodOptional<z.ZodArray<z.ZodString>>;
19
- }, z.core.$strip>;
23
+ }, z.core.$strict>;
20
24
  type Settings$1 = z.infer<typeof SettingsSchema>;
21
25
 
22
26
  declare const MappingSchema: z.ZodObject<{
@@ -46,8 +50,6 @@ interface Settings {
46
50
  identify?: Mapping$1.Value;
47
51
  /** Destination-level group mapping */
48
52
  group?: Mapping$1.Value;
49
- /** Event sections to flatten into capture properties */
50
- include?: string[];
51
53
  host?: string;
52
54
  flushAt?: number;
53
55
  flushInterval?: number;
@@ -60,6 +62,8 @@ interface Settings {
60
62
  fetchRetryDelay?: number;
61
63
  debug?: boolean;
62
64
  disabled?: boolean;
65
+ /** The running send; the next one waits for it. Runtime only. */
66
+ _sending?: Promise<void>;
63
67
  }
64
68
  /**
65
69
  * The part of a PostHog client this destination calls. `PostHog` from
@@ -70,6 +74,10 @@ interface PostHogClient {
70
74
  capture(props: Parameters<PostHog['capture']>[0]): void;
71
75
  identify(props: Parameters<PostHog['identify']>[0]): void;
72
76
  groupIdentify(props: Parameters<PostHog['groupIdentify']>[0]): void;
77
+ /** Sends the queued calls; rejects when the request failed. */
78
+ flush(): Promise<void>;
79
+ /** The SDK reports a failed send as an `error` event; returns its remover. */
80
+ on?(event: 'error', listener: (error: unknown) => void): () => void;
73
81
  shutdown(): Promise<void> | void;
74
82
  enable(): Promise<void> | void;
75
83
  disable(): Promise<void> | void;
@@ -144,6 +152,14 @@ declare const consentRevoke: PostHogStepExample;
144
152
  * Consent granted - client.enable() is called.
145
153
  */
146
154
  declare const consentGrant: PostHogStepExample;
155
+ /** A silent rule without identify or group mappings calls nothing. */
156
+ declare const silentRule: PostHogStepExample;
157
+ /**
158
+ * The silent group identify rule of groupIdentifyWithProperties on an event
159
+ * without data: no group key resolves and the rule suppresses the capture,
160
+ * so nothing is sent.
161
+ */
162
+ declare const groupIdentifyWithoutData: PostHogStepExample;
147
163
 
148
164
  type step_PostHogStepExample = PostHogStepExample;
149
165
  declare const step_captureWithGroupContext: typeof captureWithGroupContext;
@@ -152,9 +168,11 @@ declare const step_consentGrant: typeof consentGrant;
152
168
  declare const step_consentRevoke: typeof consentRevoke;
153
169
  declare const step_defaultCapture: typeof defaultCapture;
154
170
  declare const step_groupIdentifyWithProperties: typeof groupIdentifyWithProperties;
171
+ declare const step_groupIdentifyWithoutData: typeof groupIdentifyWithoutData;
155
172
  declare const step_identifyWithSetAndSetOnce: typeof identifyWithSetAndSetOnce;
173
+ declare const step_silentRule: typeof silentRule;
156
174
  declare namespace step {
157
- export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce };
175
+ export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_groupIdentifyWithoutData as groupIdentifyWithoutData, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce, step_silentRule as silentRule };
158
176
  }
159
177
 
160
178
  declare const index_env: typeof env;
package/dist/dev.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,n=(e,o)=>{for(var i in o)t(e,i,{get:o[i],enumerable:!0})},a={};n(a,{examples:()=>y,schemas:()=>r}),module.exports=(e=a,((e,n,a,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let p of i(n))s.call(e,p)||p===a||t(e,p,{get:()=>n[p],enumerable:!(r=o(n,p))||r.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r={};n(r,{MappingSchema:()=>u,SettingsSchema:()=>c,mapping:()=>m,settings:()=>g});var p=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),c=l.z.object({apiKey:l.z.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:l.z.string().describe("PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.").optional(),flushAt:l.z.number().describe("Number of events queued before auto-flush. Default: 20.").optional(),flushInterval:l.z.number().describe("Milliseconds between periodic flushes. Default: 10000.").optional(),personalApiKey:l.z.string().describe("Personal API key (phx_...) for local feature flag evaluation.").optional(),featureFlagsPollingInterval:l.z.number().describe("Milliseconds between feature flag definition polls. Default: 30000.").optional(),disableGeoip:l.z.boolean().describe("Disable GeoIP lookups globally. Useful for GDPR compliance.").optional(),debug:l.z.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),identify:l.z.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:l.z.unknown().describe("walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.").optional(),include:l.z.array(l.z.string()).describe('Event sections to flatten into capture() properties (e.g. ["data", "globals"]).').optional()}),d=require("@walkeros/core/dev"),u=d.z.object({identify:d.z.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:d.z.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),g=(0,p.zodToSchema)(c),m=(0,p.zodToSchema)(u),y={};n(y,{env:()=>h,step:()=>v});var h={};n(h,{push:()=>f,simulation:()=>b});var f={get PostHog(){return class{apiKey;options;calls;constructor(e,t){this.apiKey=e,this.options=t||{},this.calls=[]}capture(e){this.calls.push({method:"capture",args:[e]})}identify(e){this.calls.push({method:"identify",args:[e]})}groupIdentify(e){this.calls.push({method:"groupIdentify",args:[e]})}flush(){return this.calls.push({method:"flush",args:[]}),Promise.resolve()}async shutdown(){this.calls.push({method:"shutdown",args:[]})}enable(){this.calls.push({method:"enable",args:[]})}disable(){this.calls.push({method:"disable",args:[]})}}}},b=["call:PostHog.capture","call:PostHog.identify","call:PostHog.groupIdentify","call:PostHog.shutdown"],v={};n(v,{captureWithGroupContext:()=>z,captureWithInclude:()=>_,consentGrant:()=>A,consentRevoke:()=>H,defaultCapture:()=>P,groupIdentifyWithProperties:()=>I,identifyWithSetAndSetOnce:()=>k});var w=require("@walkeros/core"),P={title:"Default capture",description:"A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.",in:(0,w.getEvent)("product view",{timestamp:1700000100}),out:[["client.capture",{distinctId:"us3r",event:"product view",properties:{}}]]},_={title:"Capture with include",description:"Destination-level include flattens data and globals sections into prefixed PostHog event properties.",in:(0,w.getEvent)("order complete",{timestamp:1700000101}),configInclude:["data","globals"],out:[["client.capture",{distinctId:"us3r",event:"order complete",properties:{data_id:"0rd3r1d",data_currency:"EUR",data_shipping:5.22,data_taxes:73.76,data_total:555,globals_pagegroup:"shop"}}]]},k={title:"Identify with $set",description:"A user login fires PostHog identify with $set and $set_once person properties and skips the capture.",in:(0,w.getEvent)("user login",{timestamp:1700000102,data:{user_id:"new-user-123",email:"user@acme.com",plan:"premium"}}),mapping:{silent:!0,settings:{identify:{map:{distinctId:"data.user_id",$set:{map:{email:"data.email",plan:"data.plan"}},$set_once:{map:{first_login:"timestamp"}}}}}},out:[["client.identify",{distinctId:"new-user-123",properties:{$set:{email:"user@acme.com",plan:"premium"},$set_once:{first_login:1700000102}}}]]},I={title:"Group identify",description:"A company update fires PostHog groupIdentify with group type, key, and associated group properties.",in:(0,w.getEvent)("company update",{timestamp:1700000103,data:{company_id:"company_123",company_name:"Acme",plan:"enterprise"}}),mapping:{silent:!0,settings:{group:{map:{type:{value:"company"},key:"data.company_id",properties:{map:{name:"data.company_name",plan:"data.plan"}}}}}},out:[["client.groupIdentify",{groupType:"company",groupKey:"company_123",properties:{name:"Acme",plan:"enterprise"}}]]},z={title:"Capture with group",description:"A destination-level group mapping attaches the resolved group context to every PostHog capture call.",in:(0,w.getEvent)("page view",{timestamp:1700000104,globals:{pagegroup:"docs",company_id:"company_123"}}),settings:{group:{map:{type:{value:"company"},key:"globals.company_id"}}},out:[["client.capture",{distinctId:"us3r",event:"page view",properties:{},groups:{company:"company_123"}}]]},H={title:"Consent revoked",description:"A walker consent command with analytics denied calls client.disable on the PostHog client.",command:"consent",before:{analytics:!0},in:{analytics:!1},settings:{},out:[["client.enable"],["client.disable"]]},A={title:"Consent granted",description:"A walker consent command with analytics granted calls client.enable on the PostHog client.",command:"consent",in:{analytics:!0},settings:{},out:[["client.enable"]]};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,a=(e,i)=>{for(var o in i)t(e,o,{get:i[o],enumerable:!0})},s={};a(s,{examples:()=>f,schemas:()=>r}),module.exports=(e=s,((e,a,s,r)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let p of o(a))n.call(e,p)||p===s||t(e,p,{get:()=>a[p],enumerable:!(r=i(a,p))||r.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r={};a(r,{MappingSchema:()=>d,SettingsSchema:()=>c,mapping:()=>m,settings:()=>g});var p=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),c=l.z.object({apiKey:l.z.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:l.z.string().describe("PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.").optional(),flushAt:l.z.number().describe("Number of queued group identifies before auto-flush. Captures and identifies are sent at once, each push awaiting its own call. Default: 20.").optional(),flushInterval:l.z.number().describe("Milliseconds between periodic flushes of queued group identifies. Default: 10000.").optional(),personalApiKey:l.z.string().describe("Personal API key (phx_...) for local feature flag evaluation.").optional(),featureFlagsPollingInterval:l.z.number().describe("Milliseconds between feature flag definition polls. Default: 30000.").optional(),disableGeoip:l.z.boolean().describe("Disable GeoIP lookups globally. Useful for GDPR compliance.").optional(),disableCompression:l.z.boolean().describe("Send requests uncompressed (no gzip). Default: false.").optional(),requestTimeout:l.z.number().describe("Milliseconds before a request to PostHog times out. Default: a quarter of config.timeout (2500 at the 10 s default). A value set here wins.").optional(),fetchRetryCount:l.z.number().describe("Retries of a failed request to PostHog. Default: 2, which with the default timeout and delay ends within config.timeout. A value set here wins.").optional(),fetchRetryDelay:l.z.number().describe("Milliseconds between retries of a failed request. Default: a tenth of config.timeout (1000 at the 10 s default). A value set here wins.").optional(),debug:l.z.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),disabled:l.z.boolean().describe("Disable the PostHog client: nothing is sent. Default: false.").optional(),identify:l.z.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:l.z.unknown().describe("walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.").optional()}).strict(),u=require("@walkeros/core/dev"),d=u.z.object({identify:u.z.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:u.z.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),g=(0,p.zodToSchema)(c),m=(0,p.zodToSchema)(d),f={};a(f,{env:()=>h,step:()=>v});var h={};a(h,{push:()=>y,simulation:()=>b});var y={get PostHog(){return class{apiKey;options;calls;constructor(e,t){this.apiKey=e,this.options=t||{},this.calls=[]}capture(e){this.calls.push({method:"capture",args:[e]})}identify(e){this.calls.push({method:"identify",args:[e]})}groupIdentify(e){this.calls.push({method:"groupIdentify",args:[e]})}flush(){return this.calls.push({method:"flush",args:[]}),Promise.resolve()}async shutdown(){this.calls.push({method:"shutdown",args:[]})}enable(){this.calls.push({method:"enable",args:[]})}disable(){this.calls.push({method:"disable",args:[]})}}}},b=["call:PostHog.capture","call:PostHog.identify","call:PostHog.groupIdentify","call:PostHog.shutdown"],v={};a(v,{captureWithGroupContext:()=>z,captureWithInclude:()=>_,consentGrant:()=>A,consentRevoke:()=>H,defaultCapture:()=>P,groupIdentifyWithProperties:()=>I,groupIdentifyWithoutData:()=>$,identifyWithSetAndSetOnce:()=>k,silentRule:()=>D});var w=require("@walkeros/core"),P={title:"Default capture",description:"A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.",in:(0,w.getEvent)("product view",{id:"ev1700000100",timestamp:1700000100}),out:[["client.capture",{uuid:"b8a7f21f-1a9f-8aa7-8480-8d16fb64c44c",distinctId:"us3r",event:"product view",properties:{}}]]},_={title:"Capture with include",description:"Destination-level include flattens data and globals sections into prefixed PostHog event properties.",in:(0,w.getEvent)("order complete",{id:"ev1700000101",timestamp:1700000101}),configInclude:["data","globals"],out:[["client.capture",{uuid:"a5a5ede9-4f3b-85f4-b30f-3da8773fabfa",distinctId:"us3r",event:"order complete",properties:{data_id:"0rd3r1d",data_currency:"EUR",data_shipping:5.22,data_taxes:73.76,data_value:555,globals_pagegroup:"shop"}}]]},k={title:"Identify with $set",description:"A user login fires PostHog identify with $set and $set_once person properties and skips the capture.",in:(0,w.createEvent)({name:"user login",timestamp:1700000102,data:{user_id:"new-user-123",email:"user@acme.com",plan:"premium"}}),mapping:{silent:!0,settings:{identify:{map:{distinctId:"data.user_id",$set:{map:{email:"data.email",plan:"data.plan"}},$set_once:{map:{first_login:"timestamp"}}}}}},out:[["client.identify",{distinctId:"new-user-123",properties:{$set:{email:"user@acme.com",plan:"premium"},$set_once:{first_login:1700000102}}}]]},I={title:"Group identify",description:"A company update fires PostHog groupIdentify with group type, key, and associated group properties.",in:(0,w.createEvent)({name:"company update",timestamp:1700000103,data:{company_id:"company_123",company_name:"Acme",plan:"enterprise"}}),mapping:{silent:!0,settings:{group:{map:{type:{value:"company"},key:"data.company_id",properties:{map:{name:"data.company_name",plan:"data.plan"}}}}}},out:[["client.groupIdentify",{groupType:"company",groupKey:"company_123",properties:{name:"Acme",plan:"enterprise"}}]]},z={title:"Capture with group",description:"A destination-level group mapping attaches the resolved group context to every PostHog capture call.",in:(0,w.getEvent)("page view",{id:"ev1700000104",timestamp:1700000104,globals:{pagegroup:"docs",company_id:"company_123"}}),settings:{group:{map:{type:{value:"company"},key:"globals.company_id"}}},out:[["client.capture",{uuid:"c6a47305-44fc-8835-b15f-3f494c1f9e20",distinctId:"us3r",event:"page view",properties:{},groups:{company:"company_123"}}]]},H={title:"Consent revoked",description:"A walker consent command with analytics denied calls client.disable on the PostHog client.",command:"consent",before:{analytics:!0},in:{analytics:!1},settings:{},out:[["client.enable"],["client.disable"]]},A={title:"Consent granted",description:"A walker consent command with analytics granted calls client.enable on the PostHog client.",command:"consent",in:{analytics:!0},settings:{},out:[["client.enable"]]},D={public:!1,description:"A rule with silent: true and no identify or group mapping sends nothing to PostHog.",in:(0,w.getEvent)("page view",{timestamp:1700000105}),mapping:{silent:!0},out:[]},$={public:!1,description:"A silent group rule whose key finds no data sends nothing: an unmet mapping, not a failure, so the push returns normally.",in:{name:"company update",entity:"company",action:"update",timestamp:1700000106},mapping:I.mapping,out:[]};//# sourceMappingURL=dev.js.map
package/dist/dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'PostHog project API key (starts with \"phc_\"). Find it in PostHog project settings.',\n ),\n host: z\n .string()\n .describe(\n 'PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.',\n )\n .optional(),\n flushAt: z\n .number()\n .describe('Number of events queued before auto-flush. Default: 20.')\n .optional(),\n flushInterval: z\n .number()\n .describe('Milliseconds between periodic flushes. Default: 10000.')\n .optional(),\n personalApiKey: z\n .string()\n .describe('Personal API key (phx_...) for local feature flag evaluation.')\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe('Disable GeoIP lookups globally. Useful for GDPR compliance.')\n .optional(),\n debug: z\n .boolean()\n .describe('Enable PostHog SDK debug logging. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n 'Event sections to flatten into capture() properties (e.g. [\"data\", \"globals\"]).',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Mock PostHog class that records method calls for testing.\n * Follows the BigQuery env.BigQuery constructor injection pattern.\n */\nfunction createMockPostHog() {\n return class MockPostHog {\n apiKey: string;\n options: Record<string, unknown>;\n calls: Array<{ method: string; args: unknown[] }>;\n\n constructor(apiKey: string, options?: Record<string, unknown>) {\n this.apiKey = apiKey;\n this.options = options || {};\n this.calls = [];\n }\n\n capture(params: Record<string, unknown>) {\n this.calls.push({ method: 'capture', args: [params] });\n }\n\n identify(params: Record<string, unknown>) {\n this.calls.push({ method: 'identify', args: [params] });\n }\n\n groupIdentify(params: Record<string, unknown>) {\n this.calls.push({ method: 'groupIdentify', args: [params] });\n }\n\n flush() {\n this.calls.push({ method: 'flush', args: [] });\n return Promise.resolve();\n }\n\n async shutdown() {\n this.calls.push({ method: 'shutdown', args: [] });\n }\n\n enable() {\n this.calls.push({ method: 'enable', args: [] });\n }\n\n disable() {\n this.calls.push({ method: 'disable', args: [] });\n }\n };\n}\n\n/**\n * Standard mock environment for push operations.\n * Injects a mock PostHog class constructor via env.PostHog.\n */\nexport const push: Env = {\n get PostHog() {\n return createMockPostHog();\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:PostHog.capture',\n 'call:PostHog.identify',\n 'call:PostHog.groupIdentify',\n 'call:PostHog.shutdown',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * PostHog server step examples carry destination-level settings and\n * optional configInclude for the test runner to wire up.\n *\n * At push time the destination invokes methods on a `client` constructed\n * via `env.PostHog`. Each `out` tuple is `['client.<method>', ...args]`\n * matching the underlying SDK signature. Multiple calls (identify +\n * capture, groupIdentify + capture) are expressed as a tuple list.\n */\nexport type PostHogStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n /** Consent granted before `in` so a gated destination is loaded first. */\n before?: WalkerOS.Consent;\n};\n\n/**\n * Default event forwarding - every walkerOS event becomes\n * client.capture({ distinctId, event, properties }). With no mapping\n * and no include, properties is {}. distinctId falls back to event.user.id.\n */\nexport const defaultCapture: PostHogStepExample = {\n title: 'Default capture',\n description:\n 'A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.',\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\n },\n ],\n ],\n};\n\n/**\n * Capture with include - destination-level include flattens data and\n * globals sections into prefixed properties.\n */\nexport const captureWithInclude: PostHogStepExample = {\n title: 'Capture with include',\n description:\n 'Destination-level include flattens data and globals sections into prefixed PostHog event properties.',\n in: getEvent('order complete', { timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'order complete',\n properties: {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_total: 555,\n globals_pagegroup: 'shop',\n },\n },\n ],\n ],\n};\n\n/**\n * Identify with $set and $set_once - per-event mapping fires\n * client.identify() with person properties. silent: true suppresses capture.\n */\nexport const identifyWithSetAndSetOnce: PostHogStepExample = {\n title: 'Identify with $set',\n description:\n 'A user login fires PostHog identify with $set and $set_once person properties and skips the capture.',\n in: getEvent('user login', {\n timestamp: 1700000102,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n plan: 'premium',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n $set: {\n map: {\n email: 'data.email',\n plan: 'data.plan',\n },\n },\n $set_once: {\n map: {\n first_login: 'timestamp',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.identify',\n {\n distinctId: 'new-user-123',\n properties: {\n $set: {\n email: 'user@acme.com',\n plan: 'premium',\n },\n $set_once: {\n first_login: 1700000102,\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Group identify with properties - per-event mapping fires\n * client.groupIdentify() with group properties. silent: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\n title: 'Group identify',\n description:\n 'A company update fires PostHog groupIdentify with group type, key, and associated group properties.',\n in: getEvent('company update', {\n timestamp: 1700000103,\n data: {\n company_id: 'company_123',\n company_name: 'Acme',\n plan: 'enterprise',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'data.company_id',\n properties: {\n map: {\n name: 'data.company_name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.groupIdentify',\n {\n groupType: 'company',\n groupKey: 'company_123',\n properties: {\n name: 'Acme',\n plan: 'enterprise',\n },\n },\n ],\n ],\n};\n\n/**\n * Capture with group context - destination-level settings.group resolves\n * type + key (no properties). The capture call includes groups.\n */\nexport const captureWithGroupContext: PostHogStepExample = {\n title: 'Capture with group',\n description:\n 'A destination-level group mapping attaches the resolved group context to every PostHog capture call.',\n in: getEvent('page view', {\n timestamp: 1700000104,\n globals: { pagegroup: 'docs', company_id: 'company_123' },\n }),\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'globals.company_id',\n },\n },\n },\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n ],\n};\n\n/**\n * Consent revoked - after analytics consent is granted (PostHog loads and is\n * enabled), revoking it calls client.disable() via the on('consent') handler.\n * The destination is never loaded under denied consent, so the disable is a\n * real revocation of an already-granted destination.\n */\nexport const consentRevoke: PostHogStepExample = {\n title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied calls client.disable on the PostHog client.',\n command: 'consent',\n before: { analytics: true },\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.enable'], ['client.disable']],\n};\n\n/**\n * Consent granted - client.enable() is called.\n */\nexport const consentGrant: PostHogStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted calls client.enable on the PostHog client.',\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.enable']],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,QAAQ,aACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,MAAM,aACH,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,aACN,OAAO,EACP,SAAS,yDAAyD,EAClE,SAAS;AAAA,EACZ,eAAe,aACZ,OAAO,EACP,SAAS,wDAAwD,EACjE,SAAS;AAAA,EACZ,gBAAgB,aACb,OAAO,EACP,SAAS,+DAA+D,EACxE,SAAS;AAAA,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":["import_dev","import_dev"]}
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z\n .object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'PostHog project API key (starts with \"phc_\"). Find it in PostHog project settings.',\n ),\n host: z\n .string()\n .describe(\n 'PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.',\n )\n .optional(),\n flushAt: z\n .number()\n .describe(\n 'Number of queued group identifies before auto-flush. Captures and identifies are sent at once, each push awaiting its own call. Default: 20.',\n )\n .optional(),\n flushInterval: z\n .number()\n .describe(\n 'Milliseconds between periodic flushes of queued group identifies. Default: 10000.',\n )\n .optional(),\n personalApiKey: z\n .string()\n .describe('Personal API key (phx_...) for local feature flag evaluation.')\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe('Disable GeoIP lookups globally. Useful for GDPR compliance.')\n .optional(),\n disableCompression: z\n .boolean()\n .describe('Send requests uncompressed (no gzip). Default: false.')\n .optional(),\n requestTimeout: z\n .number()\n .describe(\n 'Milliseconds before a request to PostHog times out. Default: a quarter of config.timeout (2500 at the 10 s default). A value set here wins.',\n )\n .optional(),\n fetchRetryCount: z\n .number()\n .describe(\n 'Retries of a failed request to PostHog. Default: 2, which with the default timeout and delay ends within config.timeout. A value set here wins.',\n )\n .optional(),\n fetchRetryDelay: z\n .number()\n .describe(\n 'Milliseconds between retries of a failed request. Default: a tenth of config.timeout (1000 at the 10 s default). A value set here wins.',\n )\n .optional(),\n debug: z\n .boolean()\n .describe('Enable PostHog SDK debug logging. Default: false.')\n .optional(),\n disabled: z\n .boolean()\n .describe('Disable the PostHog client: nothing is sent. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.',\n )\n .optional(),\n })\n .strict();\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Mock PostHog class that records method calls for testing.\n * Follows the BigQuery env.BigQuery constructor injection pattern.\n */\nfunction createMockPostHog() {\n return class MockPostHog {\n apiKey: string;\n options: Record<string, unknown>;\n calls: Array<{ method: string; args: unknown[] }>;\n\n constructor(apiKey: string, options?: Record<string, unknown>) {\n this.apiKey = apiKey;\n this.options = options || {};\n this.calls = [];\n }\n\n capture(params: Record<string, unknown>) {\n this.calls.push({ method: 'capture', args: [params] });\n }\n\n identify(params: Record<string, unknown>) {\n this.calls.push({ method: 'identify', args: [params] });\n }\n\n groupIdentify(params: Record<string, unknown>) {\n this.calls.push({ method: 'groupIdentify', args: [params] });\n }\n\n flush() {\n this.calls.push({ method: 'flush', args: [] });\n return Promise.resolve();\n }\n\n async shutdown() {\n this.calls.push({ method: 'shutdown', args: [] });\n }\n\n enable() {\n this.calls.push({ method: 'enable', args: [] });\n }\n\n disable() {\n this.calls.push({ method: 'disable', args: [] });\n }\n };\n}\n\n/**\n * Standard mock environment for push operations.\n * Injects a mock PostHog class constructor via env.PostHog.\n */\nexport const push: Env = {\n get PostHog() {\n return createMockPostHog();\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:PostHog.capture',\n 'call:PostHog.identify',\n 'call:PostHog.groupIdentify',\n 'call:PostHog.shutdown',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { createEvent, getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * PostHog server step examples carry destination-level settings and\n * optional configInclude for the test runner to wire up.\n *\n * At push time the destination invokes methods on a `client` constructed\n * via `env.PostHog`. Each `out` tuple is `['client.<method>', ...args]`\n * matching the underlying SDK signature. Multiple calls (identify +\n * capture, groupIdentify + capture) are expressed as a tuple list.\n */\nexport type PostHogStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n /** Consent granted before `in` so a gated destination is loaded first. */\n before?: WalkerOS.Consent;\n};\n\n/**\n * Default event forwarding - every walkerOS event becomes\n * client.capture({ distinctId, event, properties }). With no mapping\n * and no include, properties is {}. distinctId falls back to event.user.id.\n */\nexport const defaultCapture: PostHogStepExample = {\n title: 'Default capture',\n description:\n 'A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.',\n in: getEvent('product view', { id: 'ev1700000100', timestamp: 1700000100 }),\n out: [\n [\n 'client.capture',\n {\n uuid: 'b8a7f21f-1a9f-8aa7-8480-8d16fb64c44c',\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\n },\n ],\n ],\n};\n\n/**\n * Capture with include - destination-level include flattens data and\n * globals sections into prefixed properties.\n */\nexport const captureWithInclude: PostHogStepExample = {\n title: 'Capture with include',\n description:\n 'Destination-level include flattens data and globals sections into prefixed PostHog event properties.',\n in: getEvent('order complete', { id: 'ev1700000101', timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\n [\n 'client.capture',\n {\n uuid: 'a5a5ede9-4f3b-85f4-b30f-3da8773fabfa',\n distinctId: 'us3r',\n event: 'order complete',\n properties: {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_value: 555,\n globals_pagegroup: 'shop',\n },\n },\n ],\n ],\n};\n\n/**\n * Identify with $set and $set_once - per-event mapping fires\n * client.identify() with person properties. silent: true suppresses capture.\n */\nexport const identifyWithSetAndSetOnce: PostHogStepExample = {\n title: 'Identify with $set',\n description:\n 'A user login fires PostHog identify with $set and $set_once person properties and skips the capture.',\n in: createEvent({\n name: 'user login',\n timestamp: 1700000102,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n plan: 'premium',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n $set: {\n map: {\n email: 'data.email',\n plan: 'data.plan',\n },\n },\n $set_once: {\n map: {\n first_login: 'timestamp',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.identify',\n {\n distinctId: 'new-user-123',\n properties: {\n $set: {\n email: 'user@acme.com',\n plan: 'premium',\n },\n $set_once: {\n first_login: 1700000102,\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Group identify with properties - per-event mapping fires\n * client.groupIdentify() with group properties. silent: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\n title: 'Group identify',\n description:\n 'A company update fires PostHog groupIdentify with group type, key, and associated group properties.',\n in: createEvent({\n name: 'company update',\n timestamp: 1700000103,\n data: {\n company_id: 'company_123',\n company_name: 'Acme',\n plan: 'enterprise',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'data.company_id',\n properties: {\n map: {\n name: 'data.company_name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.groupIdentify',\n {\n groupType: 'company',\n groupKey: 'company_123',\n properties: {\n name: 'Acme',\n plan: 'enterprise',\n },\n },\n ],\n ],\n};\n\n/**\n * Capture with group context - destination-level settings.group resolves\n * type + key (no properties). The capture call includes groups.\n */\nexport const captureWithGroupContext: PostHogStepExample = {\n title: 'Capture with group',\n description:\n 'A destination-level group mapping attaches the resolved group context to every PostHog capture call.',\n in: getEvent('page view', {\n id: 'ev1700000104',\n timestamp: 1700000104,\n globals: { pagegroup: 'docs', company_id: 'company_123' },\n }),\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'globals.company_id',\n },\n },\n },\n out: [\n [\n 'client.capture',\n {\n uuid: 'c6a47305-44fc-8835-b15f-3f494c1f9e20',\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n ],\n};\n\nconst analyticsDenied: WalkerOS.Consent = { analytics: false };\nconst analyticsGranted: WalkerOS.Consent = { analytics: true };\n\n/**\n * Consent revoked - after analytics consent is granted (PostHog loads and is\n * enabled), revoking it calls client.disable() via the on('consent') handler.\n * The destination is never loaded under denied consent, so the disable is a\n * real revocation of an already-granted destination.\n */\nexport const consentRevoke: PostHogStepExample = {\n title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied calls client.disable on the PostHog client.',\n command: 'consent',\n before: { analytics: true },\n in: analyticsDenied,\n settings: {},\n out: [['client.enable'], ['client.disable']],\n};\n\n/**\n * Consent granted - client.enable() is called.\n */\nexport const consentGrant: PostHogStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted calls client.enable on the PostHog client.',\n command: 'consent',\n in: analyticsGranted,\n settings: {},\n out: [['client.enable']],\n};\n\n/** A silent rule without identify or group mappings calls nothing. */\nexport const silentRule: PostHogStepExample = {\n public: false,\n description:\n 'A rule with silent: true and no identify or group mapping sends nothing to PostHog.',\n in: getEvent('page view', { timestamp: 1700000105 }),\n mapping: { silent: true },\n out: [],\n};\n\n/**\n * The silent group identify rule of groupIdentifyWithProperties on an event\n * without data: no group key resolves and the rule suppresses the capture,\n * so nothing is sent.\n */\nexport const groupIdentifyWithoutData: PostHogStepExample = {\n public: false,\n description:\n 'A silent group rule whose key finds no data sends nothing: an unmet mapping, not a failure, so the push returns normally.',\n in: {\n name: 'company update',\n entity: 'company',\n action: 'update',\n timestamp: 1700000106,\n },\n mapping: groupIdentifyWithProperties.mapping,\n out: [],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAC3B,OAAO;AAAA,EACN,QAAQ,aACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,MAAM,aACH,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,aACN,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,eAAe,aACZ,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,gBAAgB,aACb,OAAO,EACP,SAAS,+DAA+D,EACxE,SAAS;AAAA,EACZ,6BAA6B,aAC1B,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,cAAc,aACX,QAAQ,EACR,SAAS,6DAA6D,EACtE,SAAS;AAAA,EACZ,oBAAoB,aACjB,QAAQ,EACR,SAAS,uDAAuD,EAChE,SAAS;AAAA,EACZ,gBAAgB,aACb,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,iBAAiB,aACd,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,iBAAiB,aACd,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,OAAO,aACJ,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ACzB;AAGO,IAAM,aAAiC;AAAA,EAC5C,QAAQ;AAAA,EACR,aACE;AAAA,EACF,QAAI,sBAAS,aAAa,EAAE,WAAW,WAAW,CAAC;AAAA,EACnD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;AAOO,IAAM,2BAA+C;AAAA,EAC1D,QAAQ;AAAA,EACR,aACE;AAAA,EACF,IAAI;AAAA,IACF,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAAA,EACA,SAAS,4BAA4B;AAAA,EACrC,KAAK,CAAC;AACR;","names":["import_dev","import_dev"]}
package/dist/dev.mjs CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,o)=>{for(var i in o)e(t,i,{get:o[i],enumerable:!0})},o={};t(o,{MappingSchema:()=>r,SettingsSchema:()=>a,mapping:()=>l,settings:()=>p});import{zodToSchema as i}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var a=s.object({apiKey:s.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:s.string().describe("PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.").optional(),flushAt:s.number().describe("Number of events queued before auto-flush. Default: 20.").optional(),flushInterval:s.number().describe("Milliseconds between periodic flushes. Default: 10000.").optional(),personalApiKey:s.string().describe("Personal API key (phx_...) for local feature flag evaluation.").optional(),featureFlagsPollingInterval:s.number().describe("Milliseconds between feature flag definition polls. Default: 30000.").optional(),disableGeoip:s.boolean().describe("Disable GeoIP lookups globally. Useful for GDPR compliance.").optional(),debug:s.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),identify:s.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:s.unknown().describe("walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.").optional(),include:s.array(s.string()).describe('Event sections to flatten into capture() properties (e.g. ["data", "globals"]).').optional()});import{z as n}from"@walkeros/core/dev";var r=n.object({identify:n.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:n.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),p=i(a),l=i(r),c={};t(c,{env:()=>d,step:()=>m});var d={};t(d,{push:()=>u,simulation:()=>g});var u={get PostHog(){return class{apiKey;options;calls;constructor(e,t){this.apiKey=e,this.options=t||{},this.calls=[]}capture(e){this.calls.push({method:"capture",args:[e]})}identify(e){this.calls.push({method:"identify",args:[e]})}groupIdentify(e){this.calls.push({method:"groupIdentify",args:[e]})}flush(){return this.calls.push({method:"flush",args:[]}),Promise.resolve()}async shutdown(){this.calls.push({method:"shutdown",args:[]})}enable(){this.calls.push({method:"enable",args:[]})}disable(){this.calls.push({method:"disable",args:[]})}}}},g=["call:PostHog.capture","call:PostHog.identify","call:PostHog.groupIdentify","call:PostHog.shutdown"],m={};t(m,{captureWithGroupContext:()=>w,captureWithInclude:()=>f,consentGrant:()=>P,consentRevoke:()=>_,defaultCapture:()=>y,groupIdentifyWithProperties:()=>v,identifyWithSetAndSetOnce:()=>b});import{getEvent as h}from"@walkeros/core";var y={title:"Default capture",description:"A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.",in:h("product view",{timestamp:1700000100}),out:[["client.capture",{distinctId:"us3r",event:"product view",properties:{}}]]},f={title:"Capture with include",description:"Destination-level include flattens data and globals sections into prefixed PostHog event properties.",in:h("order complete",{timestamp:1700000101}),configInclude:["data","globals"],out:[["client.capture",{distinctId:"us3r",event:"order complete",properties:{data_id:"0rd3r1d",data_currency:"EUR",data_shipping:5.22,data_taxes:73.76,data_total:555,globals_pagegroup:"shop"}}]]},b={title:"Identify with $set",description:"A user login fires PostHog identify with $set and $set_once person properties and skips the capture.",in:h("user login",{timestamp:1700000102,data:{user_id:"new-user-123",email:"user@acme.com",plan:"premium"}}),mapping:{silent:!0,settings:{identify:{map:{distinctId:"data.user_id",$set:{map:{email:"data.email",plan:"data.plan"}},$set_once:{map:{first_login:"timestamp"}}}}}},out:[["client.identify",{distinctId:"new-user-123",properties:{$set:{email:"user@acme.com",plan:"premium"},$set_once:{first_login:1700000102}}}]]},v={title:"Group identify",description:"A company update fires PostHog groupIdentify with group type, key, and associated group properties.",in:h("company update",{timestamp:1700000103,data:{company_id:"company_123",company_name:"Acme",plan:"enterprise"}}),mapping:{silent:!0,settings:{group:{map:{type:{value:"company"},key:"data.company_id",properties:{map:{name:"data.company_name",plan:"data.plan"}}}}}},out:[["client.groupIdentify",{groupType:"company",groupKey:"company_123",properties:{name:"Acme",plan:"enterprise"}}]]},w={title:"Capture with group",description:"A destination-level group mapping attaches the resolved group context to every PostHog capture call.",in:h("page view",{timestamp:1700000104,globals:{pagegroup:"docs",company_id:"company_123"}}),settings:{group:{map:{type:{value:"company"},key:"globals.company_id"}}},out:[["client.capture",{distinctId:"us3r",event:"page view",properties:{},groups:{company:"company_123"}}]]},_={title:"Consent revoked",description:"A walker consent command with analytics denied calls client.disable on the PostHog client.",command:"consent",before:{analytics:!0},in:{analytics:!1},settings:{},out:[["client.enable"],["client.disable"]]},P={title:"Consent granted",description:"A walker consent command with analytics granted calls client.enable on the PostHog client.",command:"consent",in:{analytics:!0},settings:{},out:[["client.enable"]]};export{c as examples,o as schemas};//# sourceMappingURL=dev.mjs.map
1
+ import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,i=(e,i)=>{for(var o in i)t(e,o,{get:i[o],enumerable:!0})},o={};i(o,{MappingSchema:()=>p,SettingsSchema:()=>n,mapping:()=>c,settings:()=>l});import{zodToSchema as s}from"@walkeros/core/dev";import{z as a}from"@walkeros/core/dev";var n=a.object({apiKey:a.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:a.string().describe("PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.").optional(),flushAt:a.number().describe("Number of queued group identifies before auto-flush. Captures and identifies are sent at once, each push awaiting its own call. Default: 20.").optional(),flushInterval:a.number().describe("Milliseconds between periodic flushes of queued group identifies. Default: 10000.").optional(),personalApiKey:a.string().describe("Personal API key (phx_...) for local feature flag evaluation.").optional(),featureFlagsPollingInterval:a.number().describe("Milliseconds between feature flag definition polls. Default: 30000.").optional(),disableGeoip:a.boolean().describe("Disable GeoIP lookups globally. Useful for GDPR compliance.").optional(),disableCompression:a.boolean().describe("Send requests uncompressed (no gzip). Default: false.").optional(),requestTimeout:a.number().describe("Milliseconds before a request to PostHog times out. Default: a quarter of config.timeout (2500 at the 10 s default). A value set here wins.").optional(),fetchRetryCount:a.number().describe("Retries of a failed request to PostHog. Default: 2, which with the default timeout and delay ends within config.timeout. A value set here wins.").optional(),fetchRetryDelay:a.number().describe("Milliseconds between retries of a failed request. Default: a tenth of config.timeout (1000 at the 10 s default). A value set here wins.").optional(),debug:a.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),disabled:a.boolean().describe("Disable the PostHog client: nothing is sent. Default: false.").optional(),identify:a.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:a.unknown().describe("walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.").optional()}).strict();import{z as r}from"@walkeros/core/dev";var p=r.object({identify:r.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:r.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),l=s(n),c=s(p),d={};i(d,{env:()=>u,step:()=>f});var u={};i(u,{push:()=>m,simulation:()=>g});var m={get PostHog(){return class{apiKey;options;calls;constructor(e,t){this.apiKey=e,this.options=t||{},this.calls=[]}capture(e){this.calls.push({method:"capture",args:[e]})}identify(e){this.calls.push({method:"identify",args:[e]})}groupIdentify(e){this.calls.push({method:"groupIdentify",args:[e]})}flush(){return this.calls.push({method:"flush",args:[]}),Promise.resolve()}async shutdown(){this.calls.push({method:"shutdown",args:[]})}enable(){this.calls.push({method:"enable",args:[]})}disable(){this.calls.push({method:"disable",args:[]})}}}},g=["call:PostHog.capture","call:PostHog.identify","call:PostHog.groupIdentify","call:PostHog.shutdown"],f={};i(f,{captureWithGroupContext:()=>_,captureWithInclude:()=>v,consentGrant:()=>I,consentRevoke:()=>k,defaultCapture:()=>b,groupIdentifyWithProperties:()=>P,groupIdentifyWithoutData:()=>A,identifyWithSetAndSetOnce:()=>w,silentRule:()=>H});import{createEvent as h,getEvent as y}from"@walkeros/core";var b={title:"Default capture",description:"A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.",in:y("product view",{id:"ev1700000100",timestamp:1700000100}),out:[["client.capture",{uuid:"b8a7f21f-1a9f-8aa7-8480-8d16fb64c44c",distinctId:"us3r",event:"product view",properties:{}}]]},v={title:"Capture with include",description:"Destination-level include flattens data and globals sections into prefixed PostHog event properties.",in:y("order complete",{id:"ev1700000101",timestamp:1700000101}),configInclude:["data","globals"],out:[["client.capture",{uuid:"a5a5ede9-4f3b-85f4-b30f-3da8773fabfa",distinctId:"us3r",event:"order complete",properties:{data_id:"0rd3r1d",data_currency:"EUR",data_shipping:5.22,data_taxes:73.76,data_value:555,globals_pagegroup:"shop"}}]]},w={title:"Identify with $set",description:"A user login fires PostHog identify with $set and $set_once person properties and skips the capture.",in:h({name:"user login",timestamp:1700000102,data:{user_id:"new-user-123",email:"user@acme.com",plan:"premium"}}),mapping:{silent:!0,settings:{identify:{map:{distinctId:"data.user_id",$set:{map:{email:"data.email",plan:"data.plan"}},$set_once:{map:{first_login:"timestamp"}}}}}},out:[["client.identify",{distinctId:"new-user-123",properties:{$set:{email:"user@acme.com",plan:"premium"},$set_once:{first_login:1700000102}}}]]},P={title:"Group identify",description:"A company update fires PostHog groupIdentify with group type, key, and associated group properties.",in:h({name:"company update",timestamp:1700000103,data:{company_id:"company_123",company_name:"Acme",plan:"enterprise"}}),mapping:{silent:!0,settings:{group:{map:{type:{value:"company"},key:"data.company_id",properties:{map:{name:"data.company_name",plan:"data.plan"}}}}}},out:[["client.groupIdentify",{groupType:"company",groupKey:"company_123",properties:{name:"Acme",plan:"enterprise"}}]]},_={title:"Capture with group",description:"A destination-level group mapping attaches the resolved group context to every PostHog capture call.",in:y("page view",{id:"ev1700000104",timestamp:1700000104,globals:{pagegroup:"docs",company_id:"company_123"}}),settings:{group:{map:{type:{value:"company"},key:"globals.company_id"}}},out:[["client.capture",{uuid:"c6a47305-44fc-8835-b15f-3f494c1f9e20",distinctId:"us3r",event:"page view",properties:{},groups:{company:"company_123"}}]]},k={title:"Consent revoked",description:"A walker consent command with analytics denied calls client.disable on the PostHog client.",command:"consent",before:{analytics:!0},in:{analytics:!1},settings:{},out:[["client.enable"],["client.disable"]]},I={title:"Consent granted",description:"A walker consent command with analytics granted calls client.enable on the PostHog client.",command:"consent",in:{analytics:!0},settings:{},out:[["client.enable"]]},H={public:!1,description:"A rule with silent: true and no identify or group mapping sends nothing to PostHog.",in:y("page view",{timestamp:1700000105}),mapping:{silent:!0},out:[]},A={public:!1,description:"A silent group rule whose key finds no data sends nothing: an unmet mapping, not a failure, so the push returns normally.",in:{name:"company update",entity:"company",action:"update",timestamp:1700000106},mapping:P.mapping,out:[]};export{d as examples,o as schemas};//# sourceMappingURL=dev.mjs.map
package/dist/dev.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'PostHog project API key (starts with \"phc_\"). Find it in PostHog project settings.',\n ),\n host: z\n .string()\n .describe(\n 'PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.',\n )\n .optional(),\n flushAt: z\n .number()\n .describe('Number of events queued before auto-flush. Default: 20.')\n .optional(),\n flushInterval: z\n .number()\n .describe('Milliseconds between periodic flushes. Default: 10000.')\n .optional(),\n personalApiKey: z\n .string()\n .describe('Personal API key (phx_...) for local feature flag evaluation.')\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe('Disable GeoIP lookups globally. Useful for GDPR compliance.')\n .optional(),\n debug: z\n .boolean()\n .describe('Enable PostHog SDK debug logging. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n 'Event sections to flatten into capture() properties (e.g. [\"data\", \"globals\"]).',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Mock PostHog class that records method calls for testing.\n * Follows the BigQuery env.BigQuery constructor injection pattern.\n */\nfunction createMockPostHog() {\n return class MockPostHog {\n apiKey: string;\n options: Record<string, unknown>;\n calls: Array<{ method: string; args: unknown[] }>;\n\n constructor(apiKey: string, options?: Record<string, unknown>) {\n this.apiKey = apiKey;\n this.options = options || {};\n this.calls = [];\n }\n\n capture(params: Record<string, unknown>) {\n this.calls.push({ method: 'capture', args: [params] });\n }\n\n identify(params: Record<string, unknown>) {\n this.calls.push({ method: 'identify', args: [params] });\n }\n\n groupIdentify(params: Record<string, unknown>) {\n this.calls.push({ method: 'groupIdentify', args: [params] });\n }\n\n flush() {\n this.calls.push({ method: 'flush', args: [] });\n return Promise.resolve();\n }\n\n async shutdown() {\n this.calls.push({ method: 'shutdown', args: [] });\n }\n\n enable() {\n this.calls.push({ method: 'enable', args: [] });\n }\n\n disable() {\n this.calls.push({ method: 'disable', args: [] });\n }\n };\n}\n\n/**\n * Standard mock environment for push operations.\n * Injects a mock PostHog class constructor via env.PostHog.\n */\nexport const push: Env = {\n get PostHog() {\n return createMockPostHog();\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:PostHog.capture',\n 'call:PostHog.identify',\n 'call:PostHog.groupIdentify',\n 'call:PostHog.shutdown',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * PostHog server step examples carry destination-level settings and\n * optional configInclude for the test runner to wire up.\n *\n * At push time the destination invokes methods on a `client` constructed\n * via `env.PostHog`. Each `out` tuple is `['client.<method>', ...args]`\n * matching the underlying SDK signature. Multiple calls (identify +\n * capture, groupIdentify + capture) are expressed as a tuple list.\n */\nexport type PostHogStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n /** Consent granted before `in` so a gated destination is loaded first. */\n before?: WalkerOS.Consent;\n};\n\n/**\n * Default event forwarding - every walkerOS event becomes\n * client.capture({ distinctId, event, properties }). With no mapping\n * and no include, properties is {}. distinctId falls back to event.user.id.\n */\nexport const defaultCapture: PostHogStepExample = {\n title: 'Default capture',\n description:\n 'A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.',\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\n },\n ],\n ],\n};\n\n/**\n * Capture with include - destination-level include flattens data and\n * globals sections into prefixed properties.\n */\nexport const captureWithInclude: PostHogStepExample = {\n title: 'Capture with include',\n description:\n 'Destination-level include flattens data and globals sections into prefixed PostHog event properties.',\n in: getEvent('order complete', { timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'order complete',\n properties: {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_total: 555,\n globals_pagegroup: 'shop',\n },\n },\n ],\n ],\n};\n\n/**\n * Identify with $set and $set_once - per-event mapping fires\n * client.identify() with person properties. silent: true suppresses capture.\n */\nexport const identifyWithSetAndSetOnce: PostHogStepExample = {\n title: 'Identify with $set',\n description:\n 'A user login fires PostHog identify with $set and $set_once person properties and skips the capture.',\n in: getEvent('user login', {\n timestamp: 1700000102,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n plan: 'premium',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n $set: {\n map: {\n email: 'data.email',\n plan: 'data.plan',\n },\n },\n $set_once: {\n map: {\n first_login: 'timestamp',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.identify',\n {\n distinctId: 'new-user-123',\n properties: {\n $set: {\n email: 'user@acme.com',\n plan: 'premium',\n },\n $set_once: {\n first_login: 1700000102,\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Group identify with properties - per-event mapping fires\n * client.groupIdentify() with group properties. silent: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\n title: 'Group identify',\n description:\n 'A company update fires PostHog groupIdentify with group type, key, and associated group properties.',\n in: getEvent('company update', {\n timestamp: 1700000103,\n data: {\n company_id: 'company_123',\n company_name: 'Acme',\n plan: 'enterprise',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'data.company_id',\n properties: {\n map: {\n name: 'data.company_name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.groupIdentify',\n {\n groupType: 'company',\n groupKey: 'company_123',\n properties: {\n name: 'Acme',\n plan: 'enterprise',\n },\n },\n ],\n ],\n};\n\n/**\n * Capture with group context - destination-level settings.group resolves\n * type + key (no properties). The capture call includes groups.\n */\nexport const captureWithGroupContext: PostHogStepExample = {\n title: 'Capture with group',\n description:\n 'A destination-level group mapping attaches the resolved group context to every PostHog capture call.',\n in: getEvent('page view', {\n timestamp: 1700000104,\n globals: { pagegroup: 'docs', company_id: 'company_123' },\n }),\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'globals.company_id',\n },\n },\n },\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n ],\n};\n\n/**\n * Consent revoked - after analytics consent is granted (PostHog loads and is\n * enabled), revoking it calls client.disable() via the on('consent') handler.\n * The destination is never loaded under denied consent, so the disable is a\n * real revocation of an already-granted destination.\n */\nexport const consentRevoke: PostHogStepExample = {\n title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied calls client.disable on the PostHog client.',\n command: 'consent',\n before: { analytics: true },\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.enable'], ['client.disable']],\n};\n\n/**\n * Consent granted - client.enable() is called.\n */\nexport const consentGrant: PostHogStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted calls client.enable on the PostHog client.',\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.enable']],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,QAAQ,EACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,MAAM,EACH,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,EACN,OAAO,EACP,SAAS,yDAAyD,EAClE,SAAS;AAAA,EACZ,eAAe,EACZ,OAAO,EACP,SAAS,wDAAwD,EACjE,SAAS;AAAA,EACZ,gBAAgB,EACb,OAAO,EACP,SAAS,+DAA+D,EACxE,SAAS;AAAA,EACZ,6BAA6B,EAC1B,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,cAAc,EACX,QAAQ,EACR,SAAS,6DAA6D,EACtE,SAAS;AAAA,EACZ,OAAO,EACJ,QAAQ,EACR,SAAS,mDAAmD,EAC5D,SAAS;AAAA,EACZ,UAAU,EACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,OAAO,EACJ,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,EACN,MAAM,EAAE,OAAO,CAAC,EAChB;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC;;;AC3DD,SAAS,KAAAA,UAAS;AAEX,IAAM,gBAAgBA,GAAE,OAAO;AAAA,EACpC,UAAUA,GACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,OAAOA,GACJ,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC;;;AFPM,IAAM,WAAW,YAAY,cAAc;AAC3C,IAAM,UAAU,YAAY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AA,QACE,YAAY;AAAA,QACZ,OAAO;AAAA,QACP,YAAY,CAAC;AAAA,QACb,QAAQ,EAAE,SAAS,cAAc;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF;AAQO,IAAM,gBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,QAAQ,EAAE,WAAW,KAAK;AAAA,EAC1B,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,eAAe,GAAG,CAAC,gBAAgB,CAAC;AAC7C;AAKO,IAAM,eAAmC;AAAA,EAC9C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,eAAe,CAAC;AACzB;","names":["z"]}
1
+ {"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z\n .object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'PostHog project API key (starts with \"phc_\"). Find it in PostHog project settings.',\n ),\n host: z\n .string()\n .describe(\n 'PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.',\n )\n .optional(),\n flushAt: z\n .number()\n .describe(\n 'Number of queued group identifies before auto-flush. Captures and identifies are sent at once, each push awaiting its own call. Default: 20.',\n )\n .optional(),\n flushInterval: z\n .number()\n .describe(\n 'Milliseconds between periodic flushes of queued group identifies. Default: 10000.',\n )\n .optional(),\n personalApiKey: z\n .string()\n .describe('Personal API key (phx_...) for local feature flag evaluation.')\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe('Disable GeoIP lookups globally. Useful for GDPR compliance.')\n .optional(),\n disableCompression: z\n .boolean()\n .describe('Send requests uncompressed (no gzip). Default: false.')\n .optional(),\n requestTimeout: z\n .number()\n .describe(\n 'Milliseconds before a request to PostHog times out. Default: a quarter of config.timeout (2500 at the 10 s default). A value set here wins.',\n )\n .optional(),\n fetchRetryCount: z\n .number()\n .describe(\n 'Retries of a failed request to PostHog. Default: 2, which with the default timeout and delay ends within config.timeout. A value set here wins.',\n )\n .optional(),\n fetchRetryDelay: z\n .number()\n .describe(\n 'Milliseconds between retries of a failed request. Default: a tenth of config.timeout (1000 at the 10 s default). A value set here wins.',\n )\n .optional(),\n debug: z\n .boolean()\n .describe('Enable PostHog SDK debug logging. Default: false.')\n .optional(),\n disabled: z\n .boolean()\n .describe('Disable the PostHog client: nothing is sent. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.',\n )\n .optional(),\n })\n .strict();\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Mock PostHog class that records method calls for testing.\n * Follows the BigQuery env.BigQuery constructor injection pattern.\n */\nfunction createMockPostHog() {\n return class MockPostHog {\n apiKey: string;\n options: Record<string, unknown>;\n calls: Array<{ method: string; args: unknown[] }>;\n\n constructor(apiKey: string, options?: Record<string, unknown>) {\n this.apiKey = apiKey;\n this.options = options || {};\n this.calls = [];\n }\n\n capture(params: Record<string, unknown>) {\n this.calls.push({ method: 'capture', args: [params] });\n }\n\n identify(params: Record<string, unknown>) {\n this.calls.push({ method: 'identify', args: [params] });\n }\n\n groupIdentify(params: Record<string, unknown>) {\n this.calls.push({ method: 'groupIdentify', args: [params] });\n }\n\n flush() {\n this.calls.push({ method: 'flush', args: [] });\n return Promise.resolve();\n }\n\n async shutdown() {\n this.calls.push({ method: 'shutdown', args: [] });\n }\n\n enable() {\n this.calls.push({ method: 'enable', args: [] });\n }\n\n disable() {\n this.calls.push({ method: 'disable', args: [] });\n }\n };\n}\n\n/**\n * Standard mock environment for push operations.\n * Injects a mock PostHog class constructor via env.PostHog.\n */\nexport const push: Env = {\n get PostHog() {\n return createMockPostHog();\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:PostHog.capture',\n 'call:PostHog.identify',\n 'call:PostHog.groupIdentify',\n 'call:PostHog.shutdown',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { createEvent, getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * PostHog server step examples carry destination-level settings and\n * optional configInclude for the test runner to wire up.\n *\n * At push time the destination invokes methods on a `client` constructed\n * via `env.PostHog`. Each `out` tuple is `['client.<method>', ...args]`\n * matching the underlying SDK signature. Multiple calls (identify +\n * capture, groupIdentify + capture) are expressed as a tuple list.\n */\nexport type PostHogStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n /** Consent granted before `in` so a gated destination is loaded first. */\n before?: WalkerOS.Consent;\n};\n\n/**\n * Default event forwarding - every walkerOS event becomes\n * client.capture({ distinctId, event, properties }). With no mapping\n * and no include, properties is {}. distinctId falls back to event.user.id.\n */\nexport const defaultCapture: PostHogStepExample = {\n title: 'Default capture',\n description:\n 'A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.',\n in: getEvent('product view', { id: 'ev1700000100', timestamp: 1700000100 }),\n out: [\n [\n 'client.capture',\n {\n uuid: 'b8a7f21f-1a9f-8aa7-8480-8d16fb64c44c',\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\n },\n ],\n ],\n};\n\n/**\n * Capture with include - destination-level include flattens data and\n * globals sections into prefixed properties.\n */\nexport const captureWithInclude: PostHogStepExample = {\n title: 'Capture with include',\n description:\n 'Destination-level include flattens data and globals sections into prefixed PostHog event properties.',\n in: getEvent('order complete', { id: 'ev1700000101', timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\n [\n 'client.capture',\n {\n uuid: 'a5a5ede9-4f3b-85f4-b30f-3da8773fabfa',\n distinctId: 'us3r',\n event: 'order complete',\n properties: {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_value: 555,\n globals_pagegroup: 'shop',\n },\n },\n ],\n ],\n};\n\n/**\n * Identify with $set and $set_once - per-event mapping fires\n * client.identify() with person properties. silent: true suppresses capture.\n */\nexport const identifyWithSetAndSetOnce: PostHogStepExample = {\n title: 'Identify with $set',\n description:\n 'A user login fires PostHog identify with $set and $set_once person properties and skips the capture.',\n in: createEvent({\n name: 'user login',\n timestamp: 1700000102,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n plan: 'premium',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n $set: {\n map: {\n email: 'data.email',\n plan: 'data.plan',\n },\n },\n $set_once: {\n map: {\n first_login: 'timestamp',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.identify',\n {\n distinctId: 'new-user-123',\n properties: {\n $set: {\n email: 'user@acme.com',\n plan: 'premium',\n },\n $set_once: {\n first_login: 1700000102,\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Group identify with properties - per-event mapping fires\n * client.groupIdentify() with group properties. silent: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\n title: 'Group identify',\n description:\n 'A company update fires PostHog groupIdentify with group type, key, and associated group properties.',\n in: createEvent({\n name: 'company update',\n timestamp: 1700000103,\n data: {\n company_id: 'company_123',\n company_name: 'Acme',\n plan: 'enterprise',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'data.company_id',\n properties: {\n map: {\n name: 'data.company_name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.groupIdentify',\n {\n groupType: 'company',\n groupKey: 'company_123',\n properties: {\n name: 'Acme',\n plan: 'enterprise',\n },\n },\n ],\n ],\n};\n\n/**\n * Capture with group context - destination-level settings.group resolves\n * type + key (no properties). The capture call includes groups.\n */\nexport const captureWithGroupContext: PostHogStepExample = {\n title: 'Capture with group',\n description:\n 'A destination-level group mapping attaches the resolved group context to every PostHog capture call.',\n in: getEvent('page view', {\n id: 'ev1700000104',\n timestamp: 1700000104,\n globals: { pagegroup: 'docs', company_id: 'company_123' },\n }),\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'globals.company_id',\n },\n },\n },\n out: [\n [\n 'client.capture',\n {\n uuid: 'c6a47305-44fc-8835-b15f-3f494c1f9e20',\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n ],\n};\n\nconst analyticsDenied: WalkerOS.Consent = { analytics: false };\nconst analyticsGranted: WalkerOS.Consent = { analytics: true };\n\n/**\n * Consent revoked - after analytics consent is granted (PostHog loads and is\n * enabled), revoking it calls client.disable() via the on('consent') handler.\n * The destination is never loaded under denied consent, so the disable is a\n * real revocation of an already-granted destination.\n */\nexport const consentRevoke: PostHogStepExample = {\n title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied calls client.disable on the PostHog client.',\n command: 'consent',\n before: { analytics: true },\n in: analyticsDenied,\n settings: {},\n out: [['client.enable'], ['client.disable']],\n};\n\n/**\n * Consent granted - client.enable() is called.\n */\nexport const consentGrant: PostHogStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted calls client.enable on the PostHog client.',\n command: 'consent',\n in: analyticsGranted,\n settings: {},\n out: [['client.enable']],\n};\n\n/** A silent rule without identify or group mappings calls nothing. */\nexport const silentRule: PostHogStepExample = {\n public: false,\n description:\n 'A rule with silent: true and no identify or group mapping sends nothing to PostHog.',\n in: getEvent('page view', { timestamp: 1700000105 }),\n mapping: { silent: true },\n out: [],\n};\n\n/**\n * The silent group identify rule of groupIdentifyWithProperties on an event\n * without data: no group key resolves and the rule suppresses the capture,\n * so nothing is sent.\n */\nexport const groupIdentifyWithoutData: PostHogStepExample = {\n public: false,\n description:\n 'A silent group rule whose key finds no data sends nothing: an unmet mapping, not a failure, so the push returns normally.',\n in: {\n name: 'company update',\n entity: 'company',\n action: 'update',\n timestamp: 1700000106,\n },\n mapping: groupIdentifyWithProperties.mapping,\n out: [],\n};\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAC3B,OAAO;AAAA,EACN,QAAQ,EACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,MAAM,EACH,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,EACN,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,eAAe,EACZ,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,gBAAgB,EACb,OAAO,EACP,SAAS,+DA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F;AAEA,IAAM,kBAAoC,EAAE,WAAW,MAAM;AAC7D,IAAM,mBAAqC,EAAE,WAAW,KAAK;AAQtD,IAAM,gBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,QAAQ,EAAE,WAAW,KAAK;AAAA,EAC1B,IAAI;AAAA,EACJ,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,eAAe,GAAG,CAAC,gBAAgB,CAAC;AAC7C;AAKO,IAAM,eAAmC;AAAA,EAC9C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,eAAe,CAAC;AACzB;AAGO,IAAM,aAAiC;AAAA,EAC5C,QAAQ;AAAA,EACR,aACE;AAAA,EACF,IAAI,SAAS,aAAa,EAAE,WAAW,WAAW,CAAC;AAAA,EACnD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;AAOO,IAAM,2BAA+C;AAAA,EAC1D,QAAQ;AAAA,EACR,aACE;AAAA,EACF,IAAI;AAAA,IACF,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAAA,EACA,SAAS,4BAA4B;AAAA,EACrC,KAAK,CAAC;AACR;","names":["z"]}
@@ -11,8 +11,6 @@ interface Settings {
11
11
  identify?: Mapping.Value;
12
12
  /** Destination-level group mapping */
13
13
  group?: Mapping.Value;
14
- /** Event sections to flatten into capture properties */
15
- include?: string[];
16
14
  host?: string;
17
15
  flushAt?: number;
18
16
  flushInterval?: number;
@@ -25,6 +23,8 @@ interface Settings {
25
23
  fetchRetryDelay?: number;
26
24
  debug?: boolean;
27
25
  disabled?: boolean;
26
+ /** The running send; the next one waits for it. Runtime only. */
27
+ _sending?: Promise<void>;
28
28
  }
29
29
  /**
30
30
  * The part of a PostHog client this destination calls. `PostHog` from
@@ -35,6 +35,10 @@ interface PostHogClient {
35
35
  capture(props: Parameters<PostHog['capture']>[0]): void;
36
36
  identify(props: Parameters<PostHog['identify']>[0]): void;
37
37
  groupIdentify(props: Parameters<PostHog['groupIdentify']>[0]): void;
38
+ /** Sends the queued calls; rejects when the request failed. */
39
+ flush(): Promise<void>;
40
+ /** The SDK reports a failed send as an `error` event; returns its remover. */
41
+ on?(event: 'error', listener: (error: unknown) => void): () => void;
38
42
  shutdown(): Promise<void> | void;
39
43
  enable(): Promise<void> | void;
40
44
  disable(): Promise<void> | void;
@@ -109,6 +113,14 @@ declare const consentRevoke: PostHogStepExample;
109
113
  * Consent granted - client.enable() is called.
110
114
  */
111
115
  declare const consentGrant: PostHogStepExample;
116
+ /** A silent rule without identify or group mappings calls nothing. */
117
+ declare const silentRule: PostHogStepExample;
118
+ /**
119
+ * The silent group identify rule of groupIdentifyWithProperties on an event
120
+ * without data: no group key resolves and the rule suppresses the capture,
121
+ * so nothing is sent.
122
+ */
123
+ declare const groupIdentifyWithoutData: PostHogStepExample;
112
124
 
113
125
  type step_PostHogStepExample = PostHogStepExample;
114
126
  declare const step_captureWithGroupContext: typeof captureWithGroupContext;
@@ -117,9 +129,11 @@ declare const step_consentGrant: typeof consentGrant;
117
129
  declare const step_consentRevoke: typeof consentRevoke;
118
130
  declare const step_defaultCapture: typeof defaultCapture;
119
131
  declare const step_groupIdentifyWithProperties: typeof groupIdentifyWithProperties;
132
+ declare const step_groupIdentifyWithoutData: typeof groupIdentifyWithoutData;
120
133
  declare const step_identifyWithSetAndSetOnce: typeof identifyWithSetAndSetOnce;
134
+ declare const step_silentRule: typeof silentRule;
121
135
  declare namespace step {
122
- export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce };
136
+ export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_groupIdentifyWithoutData as groupIdentifyWithoutData, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce, step_silentRule as silentRule };
123
137
  }
124
138
 
125
139
  export { env, step };
@@ -11,8 +11,6 @@ interface Settings {
11
11
  identify?: Mapping.Value;
12
12
  /** Destination-level group mapping */
13
13
  group?: Mapping.Value;
14
- /** Event sections to flatten into capture properties */
15
- include?: string[];
16
14
  host?: string;
17
15
  flushAt?: number;
18
16
  flushInterval?: number;
@@ -25,6 +23,8 @@ interface Settings {
25
23
  fetchRetryDelay?: number;
26
24
  debug?: boolean;
27
25
  disabled?: boolean;
26
+ /** The running send; the next one waits for it. Runtime only. */
27
+ _sending?: Promise<void>;
28
28
  }
29
29
  /**
30
30
  * The part of a PostHog client this destination calls. `PostHog` from
@@ -35,6 +35,10 @@ interface PostHogClient {
35
35
  capture(props: Parameters<PostHog['capture']>[0]): void;
36
36
  identify(props: Parameters<PostHog['identify']>[0]): void;
37
37
  groupIdentify(props: Parameters<PostHog['groupIdentify']>[0]): void;
38
+ /** Sends the queued calls; rejects when the request failed. */
39
+ flush(): Promise<void>;
40
+ /** The SDK reports a failed send as an `error` event; returns its remover. */
41
+ on?(event: 'error', listener: (error: unknown) => void): () => void;
38
42
  shutdown(): Promise<void> | void;
39
43
  enable(): Promise<void> | void;
40
44
  disable(): Promise<void> | void;
@@ -109,6 +113,14 @@ declare const consentRevoke: PostHogStepExample;
109
113
  * Consent granted - client.enable() is called.
110
114
  */
111
115
  declare const consentGrant: PostHogStepExample;
116
+ /** A silent rule without identify or group mappings calls nothing. */
117
+ declare const silentRule: PostHogStepExample;
118
+ /**
119
+ * The silent group identify rule of groupIdentifyWithProperties on an event
120
+ * without data: no group key resolves and the rule suppresses the capture,
121
+ * so nothing is sent.
122
+ */
123
+ declare const groupIdentifyWithoutData: PostHogStepExample;
112
124
 
113
125
  type step_PostHogStepExample = PostHogStepExample;
114
126
  declare const step_captureWithGroupContext: typeof captureWithGroupContext;
@@ -117,9 +129,11 @@ declare const step_consentGrant: typeof consentGrant;
117
129
  declare const step_consentRevoke: typeof consentRevoke;
118
130
  declare const step_defaultCapture: typeof defaultCapture;
119
131
  declare const step_groupIdentifyWithProperties: typeof groupIdentifyWithProperties;
132
+ declare const step_groupIdentifyWithoutData: typeof groupIdentifyWithoutData;
120
133
  declare const step_identifyWithSetAndSetOnce: typeof identifyWithSetAndSetOnce;
134
+ declare const step_silentRule: typeof silentRule;
121
135
  declare namespace step {
122
- export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce };
136
+ export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_groupIdentifyWithoutData as groupIdentifyWithoutData, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce, step_silentRule as silentRule };
123
137
  }
124
138
 
125
139
  export { env, step };