@walkeros/server-destination-posthog 4.9.0-next-1793116456867 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -3
- package/README.md +1 -1
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.js +12 -6
- package/dist/examples/index.mjs +12 -6
- package/dist/walkerOS.json +9 -9
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @walkeros/server-destination-posthog
|
|
2
2
|
|
|
3
|
-
## 4.9.0
|
|
3
|
+
## 4.9.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
`data.term` and `data.results`, and gross fields such as Matomo `grandTotal`
|
|
14
14
|
read `data.total` first, then `data.value`. The CLI ships default event
|
|
15
15
|
contracts for common site types in `examples/contracts/`.
|
|
16
|
+
- 1306d8a: Step examples carry event timestamps in milliseconds, as the walkerOS
|
|
17
|
+
event model defines them, instead of seconds that read as a date in
|
|
18
|
+
January 1970. Where an example's output repeats the timestamp, such as
|
|
19
|
+
`event_timestamp` in the gtag include example or the event a transformer
|
|
20
|
+
example returns, the output shows the same value.
|
|
16
21
|
- 5313635: The package publishes a minimal example: the project API key, read as
|
|
17
22
|
the `POSTHOG_API_KEY` secret. The docs page renders the install line, the
|
|
18
23
|
integrated code and the flow from it, and the package test runs the same
|
|
@@ -22,16 +27,22 @@
|
|
|
22
27
|
`featureFlagsPollingInterval` say that the destination evaluates no feature
|
|
23
28
|
flags, and `disableGeoip` states its default of `true`. Step examples that
|
|
24
29
|
depend on destination config name it, with timestamps in milliseconds.
|
|
30
|
+
- Updated dependencies [a67546d]
|
|
31
|
+
- Updated dependencies [1306d8a]
|
|
25
32
|
- Updated dependencies [34fd225]
|
|
26
33
|
- Updated dependencies [5313635]
|
|
34
|
+
- Updated dependencies [1306d8a]
|
|
35
|
+
- Updated dependencies [fa46337]
|
|
27
36
|
- Updated dependencies [5313635]
|
|
28
37
|
- Updated dependencies [5313635]
|
|
29
38
|
- Updated dependencies [5313635]
|
|
30
39
|
- Updated dependencies [5313635]
|
|
31
40
|
- Updated dependencies [34fd225]
|
|
41
|
+
- Updated dependencies [fa46337]
|
|
42
|
+
- Updated dependencies [1306d8a]
|
|
32
43
|
- Updated dependencies [5313635]
|
|
33
|
-
- @walkeros/core@4.9.0
|
|
34
|
-
- @walkeros/server-core@4.9.0
|
|
44
|
+
- @walkeros/core@4.9.0
|
|
45
|
+
- @walkeros/server-core@4.9.0
|
|
35
46
|
|
|
36
47
|
## 4.8.2
|
|
37
48
|
|
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ npm install @walkeros/server-destination-posthog
|
|
|
31
31
|
"destinations": {
|
|
32
32
|
"posthog": {
|
|
33
33
|
"package": "@walkeros/server-destination-posthog",
|
|
34
|
-
"config": { "settings": { "apiKey": "
|
|
34
|
+
"config": { "settings": { "apiKey": "$secret.POSTHOG_API_KEY" } }
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(e,i)=>{for(var a in i)t(e,a,{get:i[a],enumerable:!0})},o={};s(o,{examples:()=>m,schemas:()=>r}),module.exports=(e=o,((e,s,o,r)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let l of a(s))n.call(e,l)||l===o||t(e,l,{get:()=>s[l],enumerable:!(r=i(s,l))||r.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r={};s(r,{MappingSchema:()=>d,SettingsSchema:()=>c,mapping:()=>h,settings:()=>g});var l=require("@walkeros/core/dev"),p=require("@walkeros/core/dev"),c=p.z.object({apiKey:p.z.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:p.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:p.z.number().describe("Calls the SDK queues before it starts a send on its own. Each push and each config.batch batch flushes the SDK and waits for the answer either way. Default: 20.").optional(),flushInterval:p.z.number().describe("Milliseconds after which the SDK sends calls still queued on its own. Each push and each config.batch batch flushes the SDK either way. Default: 10000.").optional(),personalApiKey:p.z.string().describe("Personal API key (phx_...). With it the SDK polls feature flag definitions; this destination evaluates no flags and attaches none to its events.").optional(),featureFlagsPollingInterval:p.z.number().describe("Milliseconds between feature flag definition polls, with personalApiKey set. This destination evaluates no flags. Default: 30000.").optional(),disableGeoip:p.z.boolean().describe("Disable GeoIP lookups for every event. Default: true, the SDK default.").optional(),disableCompression:p.z.boolean().describe("Send requests uncompressed (no gzip). Default: false.").optional(),requestTimeout:p.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:p.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:p.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:p.z.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),disabled:p.z.boolean().describe("Disable the PostHog client: nothing is sent. Default: false.").optional(),identify:p.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:p.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,l.zodToSchema)(c),h=(0,l.zodToSchema)(d),m={};s(m,{env:()=>f,minimal:()=>S,step:()=>v});var f={};s(f,{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={};s(v,{captureWithGroupContext:()=>D,captureWithInclude:()=>_,consentGrant:()=>H,consentRevoke:()=>z,defaultCapture:()=>P,groupIdentifyWithProperties:()=>I,groupIdentifyWithoutData:()=>K,identifyWithSetAndSetOnce:()=>k,silentRule:()=>A});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:
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(e,i)=>{for(var a in i)t(e,a,{get:i[a],enumerable:!0})},o={};s(o,{examples:()=>m,schemas:()=>r}),module.exports=(e=o,((e,s,o,r)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let l of a(s))n.call(e,l)||l===o||t(e,l,{get:()=>s[l],enumerable:!(r=i(s,l))||r.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r={};s(r,{MappingSchema:()=>d,SettingsSchema:()=>c,mapping:()=>h,settings:()=>g});var l=require("@walkeros/core/dev"),p=require("@walkeros/core/dev"),c=p.z.object({apiKey:p.z.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:p.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:p.z.number().describe("Calls the SDK queues before it starts a send on its own. Each push and each config.batch batch flushes the SDK and waits for the answer either way. Default: 20.").optional(),flushInterval:p.z.number().describe("Milliseconds after which the SDK sends calls still queued on its own. Each push and each config.batch batch flushes the SDK either way. Default: 10000.").optional(),personalApiKey:p.z.string().describe("Personal API key (phx_...). With it the SDK polls feature flag definitions; this destination evaluates no flags and attaches none to its events.").optional(),featureFlagsPollingInterval:p.z.number().describe("Milliseconds between feature flag definition polls, with personalApiKey set. This destination evaluates no flags. Default: 30000.").optional(),disableGeoip:p.z.boolean().describe("Disable GeoIP lookups for every event. Default: true, the SDK default.").optional(),disableCompression:p.z.boolean().describe("Send requests uncompressed (no gzip). Default: false.").optional(),requestTimeout:p.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:p.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:p.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:p.z.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),disabled:p.z.boolean().describe("Disable the PostHog client: nothing is sent. Default: false.").optional(),identify:p.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:p.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,l.zodToSchema)(c),h=(0,l.zodToSchema)(d),m={};s(m,{env:()=>f,minimal:()=>S,step:()=>v});var f={};s(f,{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={};s(v,{captureWithGroupContext:()=>D,captureWithInclude:()=>_,consentGrant:()=>H,consentRevoke:()=>z,defaultCapture:()=>P,groupIdentifyWithProperties:()=>I,groupIdentifyWithoutData:()=>K,identifyWithSetAndSetOnce:()=>k,silentRule:()=>A});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:17000001e5}),out:[["client.capture",{uuid:"b8a7f21f-1a9f-8aa7-8480-8d16fb64c44c",distinctId:"us3r",event:"product view",properties:{}}]]},_={title:"Capture with include",description:"With include: ['data', 'globals'] in the destination config, the data and globals sections are flattened into prefixed PostHog event properties.",in:(0,w.getEvent)("order complete",{id:"ev1700000101",timestamp:1700000101e3}),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_value:462,data_tax:73.76,data_shipping:5.22,data_total:467.22,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:1700000102e3,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:1700000102e3}}}]]},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:1700000103e3,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"}}]]},D={title:"Capture with group",description:"With settings.group mapping type to 'company' and key to 'globals.company_id', every PostHog capture call carries the resolved group.",in:(0,w.getEvent)("page view",{id:"ev1700000104",timestamp:1700000104e3,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"}}]]},z={title:"Consent revoked",description:"With consent: { analytics: true } in the destination config, revoking analytics consent after a grant calls client.disable on the PostHog client.",command:"consent",before:{analytics:!0},in:{analytics:!1},settings:{},out:[["client.enable"],["client.disable"]]},H={title:"Consent granted",description:"With consent: { analytics: true } in the destination config, a walker consent command that grants analytics calls client.enable on the PostHog client.",command:"consent",in:{analytics:!0},settings:{},out:[["client.enable"]]},A={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:1700000105e3}),mapping:{silent:!0},out:[]},K={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:1700000106e3},mapping:I.mapping,out:[]},S={settings:{apiKey:"phc_test"},secrets:{apiKey:"POSTHOG_API_KEY"}};//# 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","../src/examples/minimal.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 'Calls the SDK queues before it starts a send on its own. Each push and each config.batch batch flushes the SDK and waits for the answer either way. Default: 20.',\n )\n .optional(),\n flushInterval: z\n .number()\n .describe(\n 'Milliseconds after which the SDK sends calls still queued on its own. Each push and each config.batch batch flushes the SDK either way. Default: 10000.',\n )\n .optional(),\n personalApiKey: z\n .string()\n .describe(\n 'Personal API key (phx_...). With it the SDK polls feature flag definitions; this destination evaluates no flags and attaches none to its events.',\n )\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls, with personalApiKey set. This destination evaluates no flags. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe(\n 'Disable GeoIP lookups for every event. Default: true, the SDK default.',\n )\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';\nexport { minimal } from './minimal';\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 \"With include: ['data', 'globals'] in the destination config, the data and globals sections are flattened 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_value: 462,\n data_tax: 73.76,\n data_shipping: 5.22,\n data_total: 467.22,\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: 1700000102000,\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: 1700000102000,\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 \"With settings.group mapping type to 'company' and key to 'globals.company_id', every PostHog capture call carries the resolved group.\",\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 'With consent: { analytics: true } in the destination config, revoking analytics consent after a grant 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 'With consent: { analytics: true } in the destination config, a walker consent command that grants analytics 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","import type { Flow } from '@walkeros/core';\n\n/**\n * The setting PostHog needs to deliver: the project API key, read from the\n * environment.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: { apiKey: 'phc_test' },\n secrets: { apiKey: 'POSTHOG_API_KEY' },\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,E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ACA;AAAA,QACE,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,OAAO;AAAA,QACP,YAAY,CAAC;AAAA,QACb,QAAQ,EAAE,SAAS,cAAc;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF;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,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;;;AC7QO,IAAM,UAA+B;AAAA,EAC1C,UAAU,EAAE,QAAQ,WAAW;AAAA,EAC/B,SAAS,EAAE,QAAQ,kBAAkB;AACvC;","names":["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","../src/examples/minimal.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 'Calls the SDK queues before it starts a send on its own. Each push and each config.batch batch flushes the SDK and waits for the answer either way. Default: 20.',\n )\n .optional(),\n flushInterval: z\n .number()\n .describe(\n 'Milliseconds after which the SDK sends calls still queued on its own. Each push and each config.batch batch flushes the SDK either way. Default: 10000.',\n )\n .optional(),\n personalApiKey: z\n .string()\n .describe(\n 'Personal API key (phx_...). With it the SDK polls feature flag definitions; this destination evaluates no flags and attaches none to its events.',\n )\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls, with personalApiKey set. This destination evaluates no flags. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe(\n 'Disable GeoIP lookups for every event. Default: true, the SDK default.',\n )\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';\nexport { minimal } from './minimal';\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', {\n id: 'ev1700000100',\n timestamp: 1700000100000,\n }),\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 \"With include: ['data', 'globals'] in the destination config, the data and globals sections are flattened into prefixed PostHog event properties.\",\n in: getEvent('order complete', {\n id: 'ev1700000101',\n timestamp: 1700000101000,\n }),\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_value: 462,\n data_tax: 73.76,\n data_shipping: 5.22,\n data_total: 467.22,\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: 1700000102000,\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: 1700000102000,\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: 1700000103000,\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 \"With settings.group mapping type to 'company' and key to 'globals.company_id', every PostHog capture call carries the resolved group.\",\n in: getEvent('page view', {\n id: 'ev1700000104',\n timestamp: 1700000104000,\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 'With consent: { analytics: true } in the destination config, revoking analytics consent after a grant 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 'With consent: { analytics: true } in the destination config, a walker consent command that grants analytics 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: 1700000105000 }),\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: 1700000106000,\n },\n mapping: groupIdentifyWithProperties.mapping,\n out: [],\n};\n","import type { Flow } from '@walkeros/core';\n\n/**\n * The setting PostHog needs to deliver: the project API key, read from the\n * environment.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: { apiKey: 'phc_test' },\n secrets: { apiKey: 'POSTHOG_API_KEY' },\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;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,6BAA6B,aAC1B,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,cAAc,aACX,QAAQ,EACR;AAAA,IACC;AAAA,EACF,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;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,QAAI,sBAAS,aAAa,EAAE,WAAW,aAAc,CAAC;AAAA,EACtD,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;;;ACnRO,IAAM,UAA+B;AAAA,EAC1C,UAAU,EAAE,QAAQ,WAAW;AAAA,EAC/B,SAAS,EAAE,QAAQ,kBAAkB;AACvC;","names":["import_dev","import_dev"]}
|
package/dist/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,i=(e,i)=>{for(var a in i)t(e,a,{get:i[a],enumerable:!0})},a={};i(a,{MappingSchema:()=>p,SettingsSchema:()=>o,mapping:()=>c,settings:()=>l});import{zodToSchema as s}from"@walkeros/core/dev";import{z as n}from"@walkeros/core/dev";var o=n.object({apiKey:n.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:n.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:n.number().describe("Calls the SDK queues before it starts a send on its own. Each push and each config.batch batch flushes the SDK and waits for the answer either way. Default: 20.").optional(),flushInterval:n.number().describe("Milliseconds after which the SDK sends calls still queued on its own. Each push and each config.batch batch flushes the SDK either way. Default: 10000.").optional(),personalApiKey:n.string().describe("Personal API key (phx_...). With it the SDK polls feature flag definitions; this destination evaluates no flags and attaches none to its events.").optional(),featureFlagsPollingInterval:n.number().describe("Milliseconds between feature flag definition polls, with personalApiKey set. This destination evaluates no flags. Default: 30000.").optional(),disableGeoip:n.boolean().describe("Disable GeoIP lookups for every event. Default: true, the SDK default.").optional(),disableCompression:n.boolean().describe("Send requests uncompressed (no gzip). Default: false.").optional(),requestTimeout:n.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:n.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:n.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:n.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),disabled:n.boolean().describe("Disable the PostHog client: nothing is sent. Default: false.").optional(),identify:n.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:n.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(o),c=s(p),d={};i(d,{env:()=>u,minimal:()=>A,step:()=>h});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"],h={};i(h,{captureWithGroupContext:()=>P,captureWithInclude:()=>v,consentGrant:()=>I,consentRevoke:()=>k,defaultCapture:()=>b,groupIdentifyWithProperties:()=>_,groupIdentifyWithoutData:()=>H,identifyWithSetAndSetOnce:()=>w,silentRule:()=>D});import{createEvent as f,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:
|
|
1
|
+
import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,i=(e,i)=>{for(var a in i)t(e,a,{get:i[a],enumerable:!0})},a={};i(a,{MappingSchema:()=>p,SettingsSchema:()=>o,mapping:()=>c,settings:()=>l});import{zodToSchema as s}from"@walkeros/core/dev";import{z as n}from"@walkeros/core/dev";var o=n.object({apiKey:n.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:n.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:n.number().describe("Calls the SDK queues before it starts a send on its own. Each push and each config.batch batch flushes the SDK and waits for the answer either way. Default: 20.").optional(),flushInterval:n.number().describe("Milliseconds after which the SDK sends calls still queued on its own. Each push and each config.batch batch flushes the SDK either way. Default: 10000.").optional(),personalApiKey:n.string().describe("Personal API key (phx_...). With it the SDK polls feature flag definitions; this destination evaluates no flags and attaches none to its events.").optional(),featureFlagsPollingInterval:n.number().describe("Milliseconds between feature flag definition polls, with personalApiKey set. This destination evaluates no flags. Default: 30000.").optional(),disableGeoip:n.boolean().describe("Disable GeoIP lookups for every event. Default: true, the SDK default.").optional(),disableCompression:n.boolean().describe("Send requests uncompressed (no gzip). Default: false.").optional(),requestTimeout:n.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:n.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:n.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:n.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),disabled:n.boolean().describe("Disable the PostHog client: nothing is sent. Default: false.").optional(),identify:n.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:n.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(o),c=s(p),d={};i(d,{env:()=>u,minimal:()=>A,step:()=>h});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"],h={};i(h,{captureWithGroupContext:()=>P,captureWithInclude:()=>v,consentGrant:()=>I,consentRevoke:()=>k,defaultCapture:()=>b,groupIdentifyWithProperties:()=>_,groupIdentifyWithoutData:()=>H,identifyWithSetAndSetOnce:()=>w,silentRule:()=>D});import{createEvent as f,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:17000001e5}),out:[["client.capture",{uuid:"b8a7f21f-1a9f-8aa7-8480-8d16fb64c44c",distinctId:"us3r",event:"product view",properties:{}}]]},v={title:"Capture with include",description:"With include: ['data', 'globals'] in the destination config, the data and globals sections are flattened into prefixed PostHog event properties.",in:y("order complete",{id:"ev1700000101",timestamp:1700000101e3}),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_value:462,data_tax:73.76,data_shipping:5.22,data_total:467.22,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:f({name:"user login",timestamp:1700000102e3,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:1700000102e3}}}]]},_={title:"Group identify",description:"A company update fires PostHog groupIdentify with group type, key, and associated group properties.",in:f({name:"company update",timestamp:1700000103e3,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"}}]]},P={title:"Capture with group",description:"With settings.group mapping type to 'company' and key to 'globals.company_id', every PostHog capture call carries the resolved group.",in:y("page view",{id:"ev1700000104",timestamp:1700000104e3,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:"With consent: { analytics: true } in the destination config, revoking analytics consent after a grant 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:"With consent: { analytics: true } in the destination config, a walker consent command that grants analytics 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:y("page view",{timestamp:1700000105e3}),mapping:{silent:!0},out:[]},H={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:1700000106e3},mapping:_.mapping,out:[]},A={settings:{apiKey:"phc_test"},secrets:{apiKey:"POSTHOG_API_KEY"}};export{d as examples,a 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","../src/examples/minimal.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 'Calls the SDK queues before it starts a send on its own. Each push and each config.batch batch flushes the SDK and waits for the answer either way. Default: 20.',\n )\n .optional(),\n flushInterval: z\n .number()\n .describe(\n 'Milliseconds after which the SDK sends calls still queued on its own. Each push and each config.batch batch flushes the SDK either way. Default: 10000.',\n )\n .optional(),\n personalApiKey: z\n .string()\n .describe(\n 'Personal API key (phx_...). With it the SDK polls feature flag definitions; this destination evaluates no flags and attaches none to its events.',\n )\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls, with personalApiKey set. This destination evaluates no flags. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe(\n 'Disable GeoIP lookups for every event. Default: true, the SDK default.',\n )\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';\nexport { minimal } from './minimal';\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 \"With include: ['data', 'globals'] in the destination config, the data and globals sections are flattened 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_value: 462,\n data_tax: 73.76,\n data_shipping: 5.22,\n data_total: 467.22,\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: 1700000102000,\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: 1700000102000,\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 \"With settings.group mapping type to 'company' and key to 'globals.company_id', every PostHog capture call carries the resolved group.\",\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 'With consent: { analytics: true } in the destination config, revoking analytics consent after a grant 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 'With consent: { analytics: true } in the destination config, a walker consent command that grants analytics 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","import type { Flow } from '@walkeros/core';\n\n/**\n * The setting PostHog needs to deliver: the project API key, read from the\n * environment.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: { apiKey: 'phc_test' },\n secrets: { apiKey: 'POSTHOG_API_KEY' },\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;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,6BAA6B,EAC1B,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,cAAc,EACX,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,oBAAoB,EACjB,QAAQ,EACR,SAAS,uDAAuD,EAChE,SAAS;AAAA,EACZ,gBAAgB,EACb,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,iBAAiB,EACd,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,iBAAiB,EACd,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,OAAO,EACJ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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;;;AC7QO,IAAM,UAA+B;AAAA,EAC1C,UAAU,EAAE,QAAQ,WAAW;AAAA,EAC/B,SAAS,EAAE,QAAQ,kBAAkB;AACvC;","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","../src/examples/minimal.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 'Calls the SDK queues before it starts a send on its own. Each push and each config.batch batch flushes the SDK and waits for the answer either way. Default: 20.',\n )\n .optional(),\n flushInterval: z\n .number()\n .describe(\n 'Milliseconds after which the SDK sends calls still queued on its own. Each push and each config.batch batch flushes the SDK either way. Default: 10000.',\n )\n .optional(),\n personalApiKey: z\n .string()\n .describe(\n 'Personal API key (phx_...). With it the SDK polls feature flag definitions; this destination evaluates no flags and attaches none to its events.',\n )\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls, with personalApiKey set. This destination evaluates no flags. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe(\n 'Disable GeoIP lookups for every event. Default: true, the SDK default.',\n )\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';\nexport { minimal } from './minimal';\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', {\n id: 'ev1700000100',\n timestamp: 1700000100000,\n }),\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 \"With include: ['data', 'globals'] in the destination config, the data and globals sections are flattened into prefixed PostHog event properties.\",\n in: getEvent('order complete', {\n id: 'ev1700000101',\n timestamp: 1700000101000,\n }),\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_value: 462,\n data_tax: 73.76,\n data_shipping: 5.22,\n data_total: 467.22,\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: 1700000102000,\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: 1700000102000,\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: 1700000103000,\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 \"With settings.group mapping type to 'company' and key to 'globals.company_id', every PostHog capture call carries the resolved group.\",\n in: getEvent('page view', {\n id: 'ev1700000104',\n timestamp: 1700000104000,\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 'With consent: { analytics: true } in the destination config, revoking analytics consent after a grant 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 'With consent: { analytics: true } in the destination config, a walker consent command that grants analytics 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: 1700000105000 }),\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: 1700000106000,\n },\n mapping: groupIdentifyWithProperties.mapping,\n out: [],\n};\n","import type { Flow } from '@walkeros/core';\n\n/**\n * The setting PostHog needs to deliver: the project API key, read from the\n * environment.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: { apiKey: 'phc_test' },\n secrets: { apiKey: 'POSTHOG_API_KEY' },\n};\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAA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AA,IACR,WAAW;AAAA,EACb;AAAA,EACA,SAAS,4BAA4B;AAAA,EACrC,KAAK,CAAC;AACR;;;ACnRO,IAAM,UAA+B;AAAA,EAC1C,UAAU,EAAE,QAAQ,WAAW;AAAA,EAC/B,SAAS,EAAE,QAAQ,kBAAkB;AACvC;","names":["z"]}
|
package/dist/examples/index.js
CHANGED
|
@@ -95,7 +95,10 @@ var import_core = require("@walkeros/core");
|
|
|
95
95
|
var defaultCapture = {
|
|
96
96
|
title: "Default capture",
|
|
97
97
|
description: "A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.",
|
|
98
|
-
in: (0, import_core.getEvent)("product view", {
|
|
98
|
+
in: (0, import_core.getEvent)("product view", {
|
|
99
|
+
id: "ev1700000100",
|
|
100
|
+
timestamp: 17000001e5
|
|
101
|
+
}),
|
|
99
102
|
out: [
|
|
100
103
|
[
|
|
101
104
|
"client.capture",
|
|
@@ -111,7 +114,10 @@ var defaultCapture = {
|
|
|
111
114
|
var captureWithInclude = {
|
|
112
115
|
title: "Capture with include",
|
|
113
116
|
description: "With include: ['data', 'globals'] in the destination config, the data and globals sections are flattened into prefixed PostHog event properties.",
|
|
114
|
-
in: (0, import_core.getEvent)("order complete", {
|
|
117
|
+
in: (0, import_core.getEvent)("order complete", {
|
|
118
|
+
id: "ev1700000101",
|
|
119
|
+
timestamp: 1700000101e3
|
|
120
|
+
}),
|
|
115
121
|
configInclude: ["data", "globals"],
|
|
116
122
|
out: [
|
|
117
123
|
[
|
|
@@ -189,7 +195,7 @@ var groupIdentifyWithProperties = {
|
|
|
189
195
|
description: "A company update fires PostHog groupIdentify with group type, key, and associated group properties.",
|
|
190
196
|
in: (0, import_core.createEvent)({
|
|
191
197
|
name: "company update",
|
|
192
|
-
timestamp:
|
|
198
|
+
timestamp: 1700000103e3,
|
|
193
199
|
data: {
|
|
194
200
|
company_id: "company_123",
|
|
195
201
|
company_name: "Acme",
|
|
@@ -232,7 +238,7 @@ var captureWithGroupContext = {
|
|
|
232
238
|
description: "With settings.group mapping type to 'company' and key to 'globals.company_id', every PostHog capture call carries the resolved group.",
|
|
233
239
|
in: (0, import_core.getEvent)("page view", {
|
|
234
240
|
id: "ev1700000104",
|
|
235
|
-
timestamp:
|
|
241
|
+
timestamp: 1700000104e3,
|
|
236
242
|
globals: { pagegroup: "docs", company_id: "company_123" }
|
|
237
243
|
}),
|
|
238
244
|
settings: {
|
|
@@ -278,7 +284,7 @@ var consentGrant = {
|
|
|
278
284
|
var silentRule = {
|
|
279
285
|
public: false,
|
|
280
286
|
description: "A rule with silent: true and no identify or group mapping sends nothing to PostHog.",
|
|
281
|
-
in: (0, import_core.getEvent)("page view", { timestamp:
|
|
287
|
+
in: (0, import_core.getEvent)("page view", { timestamp: 1700000105e3 }),
|
|
282
288
|
mapping: { silent: true },
|
|
283
289
|
out: []
|
|
284
290
|
};
|
|
@@ -289,7 +295,7 @@ var groupIdentifyWithoutData = {
|
|
|
289
295
|
name: "company update",
|
|
290
296
|
entity: "company",
|
|
291
297
|
action: "update",
|
|
292
|
-
timestamp:
|
|
298
|
+
timestamp: 1700000106e3
|
|
293
299
|
},
|
|
294
300
|
mapping: groupIdentifyWithProperties.mapping,
|
|
295
301
|
out: []
|
package/dist/examples/index.mjs
CHANGED
|
@@ -73,7 +73,10 @@ import { createEvent, getEvent } from "@walkeros/core";
|
|
|
73
73
|
var defaultCapture = {
|
|
74
74
|
title: "Default capture",
|
|
75
75
|
description: "A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.",
|
|
76
|
-
in: getEvent("product view", {
|
|
76
|
+
in: getEvent("product view", {
|
|
77
|
+
id: "ev1700000100",
|
|
78
|
+
timestamp: 17000001e5
|
|
79
|
+
}),
|
|
77
80
|
out: [
|
|
78
81
|
[
|
|
79
82
|
"client.capture",
|
|
@@ -89,7 +92,10 @@ var defaultCapture = {
|
|
|
89
92
|
var captureWithInclude = {
|
|
90
93
|
title: "Capture with include",
|
|
91
94
|
description: "With include: ['data', 'globals'] in the destination config, the data and globals sections are flattened into prefixed PostHog event properties.",
|
|
92
|
-
in: getEvent("order complete", {
|
|
95
|
+
in: getEvent("order complete", {
|
|
96
|
+
id: "ev1700000101",
|
|
97
|
+
timestamp: 1700000101e3
|
|
98
|
+
}),
|
|
93
99
|
configInclude: ["data", "globals"],
|
|
94
100
|
out: [
|
|
95
101
|
[
|
|
@@ -167,7 +173,7 @@ var groupIdentifyWithProperties = {
|
|
|
167
173
|
description: "A company update fires PostHog groupIdentify with group type, key, and associated group properties.",
|
|
168
174
|
in: createEvent({
|
|
169
175
|
name: "company update",
|
|
170
|
-
timestamp:
|
|
176
|
+
timestamp: 1700000103e3,
|
|
171
177
|
data: {
|
|
172
178
|
company_id: "company_123",
|
|
173
179
|
company_name: "Acme",
|
|
@@ -210,7 +216,7 @@ var captureWithGroupContext = {
|
|
|
210
216
|
description: "With settings.group mapping type to 'company' and key to 'globals.company_id', every PostHog capture call carries the resolved group.",
|
|
211
217
|
in: getEvent("page view", {
|
|
212
218
|
id: "ev1700000104",
|
|
213
|
-
timestamp:
|
|
219
|
+
timestamp: 1700000104e3,
|
|
214
220
|
globals: { pagegroup: "docs", company_id: "company_123" }
|
|
215
221
|
}),
|
|
216
222
|
settings: {
|
|
@@ -256,7 +262,7 @@ var consentGrant = {
|
|
|
256
262
|
var silentRule = {
|
|
257
263
|
public: false,
|
|
258
264
|
description: "A rule with silent: true and no identify or group mapping sends nothing to PostHog.",
|
|
259
|
-
in: getEvent("page view", { timestamp:
|
|
265
|
+
in: getEvent("page view", { timestamp: 1700000105e3 }),
|
|
260
266
|
mapping: { silent: true },
|
|
261
267
|
out: []
|
|
262
268
|
};
|
|
@@ -267,7 +273,7 @@ var groupIdentifyWithoutData = {
|
|
|
267
273
|
name: "company update",
|
|
268
274
|
entity: "company",
|
|
269
275
|
action: "update",
|
|
270
|
-
timestamp:
|
|
276
|
+
timestamp: 1700000106e3
|
|
271
277
|
},
|
|
272
278
|
mapping: groupIdentifyWithProperties.mapping,
|
|
273
279
|
out: []
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/server-destination-posthog",
|
|
4
|
-
"version": "4.9.0
|
|
4
|
+
"version": "4.9.0",
|
|
5
5
|
"type": "destination",
|
|
6
6
|
"platform": [
|
|
7
7
|
"server"
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
"trigger": "load",
|
|
164
164
|
"entity": "page",
|
|
165
165
|
"action": "view",
|
|
166
|
-
"timestamp":
|
|
166
|
+
"timestamp": 1700000104000,
|
|
167
167
|
"timing": 3.14,
|
|
168
168
|
"source": {
|
|
169
169
|
"count": 1,
|
|
@@ -282,7 +282,7 @@
|
|
|
282
282
|
"trigger": "load",
|
|
283
283
|
"entity": "order",
|
|
284
284
|
"action": "complete",
|
|
285
|
-
"timestamp":
|
|
285
|
+
"timestamp": 1700000101000,
|
|
286
286
|
"timing": 3.14,
|
|
287
287
|
"source": {
|
|
288
288
|
"count": 1,
|
|
@@ -387,7 +387,7 @@
|
|
|
387
387
|
"trigger": "load",
|
|
388
388
|
"entity": "product",
|
|
389
389
|
"action": "view",
|
|
390
|
-
"timestamp":
|
|
390
|
+
"timestamp": 1700000100000,
|
|
391
391
|
"timing": 3.14,
|
|
392
392
|
"source": {
|
|
393
393
|
"count": 1,
|
|
@@ -446,11 +446,11 @@
|
|
|
446
446
|
"consent": {
|
|
447
447
|
"functional": true
|
|
448
448
|
},
|
|
449
|
-
"id": "
|
|
449
|
+
"id": "4729b22af127fbe6",
|
|
450
450
|
"trigger": "test",
|
|
451
451
|
"entity": "company",
|
|
452
452
|
"action": "update",
|
|
453
|
-
"timestamp":
|
|
453
|
+
"timestamp": 1700000103000,
|
|
454
454
|
"timing": 3.14,
|
|
455
455
|
"source": {
|
|
456
456
|
"count": 1,
|
|
@@ -499,7 +499,7 @@
|
|
|
499
499
|
"name": "company update",
|
|
500
500
|
"entity": "company",
|
|
501
501
|
"action": "update",
|
|
502
|
-
"timestamp":
|
|
502
|
+
"timestamp": 1700000106000
|
|
503
503
|
},
|
|
504
504
|
"mapping": {
|
|
505
505
|
"silent": true,
|
|
@@ -560,7 +560,7 @@
|
|
|
560
560
|
"consent": {
|
|
561
561
|
"functional": true
|
|
562
562
|
},
|
|
563
|
-
"id": "
|
|
563
|
+
"id": "cb217f5789f0b507",
|
|
564
564
|
"trigger": "test",
|
|
565
565
|
"entity": "user",
|
|
566
566
|
"action": "login",
|
|
@@ -657,7 +657,7 @@
|
|
|
657
657
|
"trigger": "load",
|
|
658
658
|
"entity": "page",
|
|
659
659
|
"action": "view",
|
|
660
|
-
"timestamp":
|
|
660
|
+
"timestamp": 1700000105000,
|
|
661
661
|
"timing": 3.14,
|
|
662
662
|
"source": {
|
|
663
663
|
"count": 1,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/server-destination-posthog",
|
|
3
3
|
"description": "PostHog server destination for walkerOS",
|
|
4
|
-
"version": "4.9.0
|
|
4
|
+
"version": "4.9.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"update": "npx npm-check-updates -u && npm update"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@walkeros/core": "4.9.0
|
|
39
|
-
"@walkeros/server-core": "4.9.0
|
|
38
|
+
"@walkeros/core": "4.9.0",
|
|
39
|
+
"@walkeros/server-core": "4.9.0",
|
|
40
40
|
"posthog-node": "^5.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@walkeros/collector": "4.9.0
|
|
43
|
+
"@walkeros/collector": "4.9.0"
|
|
44
44
|
},
|
|
45
45
|
"repository": {
|
|
46
46
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|