@walkeros/server-destination-posthog 3.4.1 → 4.0.0-next-1777463920154
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.d.mts +9 -9
- package/dist/dev.d.ts +9 -9
- 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.d.mts +9 -9
- package/dist/examples/index.d.ts +9 -9
- package/dist/examples/index.js +5 -2
- package/dist/examples/index.mjs +5 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +19 -75
- package/package.json +4 -4
package/dist/dev.d.mts
CHANGED
|
@@ -93,37 +93,37 @@ type PostHogStepExample = Flow.StepExample & {
|
|
|
93
93
|
configInclude?: string[];
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
|
-
* Default event forwarding
|
|
96
|
+
* Default event forwarding - every walkerOS event becomes
|
|
97
97
|
* client.capture({ distinctId, event, properties }). With no mapping
|
|
98
98
|
* and no include, properties is {}. distinctId falls back to event.user.id.
|
|
99
99
|
*/
|
|
100
100
|
declare const defaultCapture: PostHogStepExample;
|
|
101
101
|
/**
|
|
102
|
-
* Capture with include
|
|
102
|
+
* Capture with include - destination-level include flattens data and
|
|
103
103
|
* globals sections into prefixed properties.
|
|
104
104
|
*/
|
|
105
105
|
declare const captureWithInclude: PostHogStepExample;
|
|
106
106
|
/**
|
|
107
|
-
* Identify with $set and $set_once
|
|
108
|
-
* client.identify() with person properties.
|
|
107
|
+
* Identify with $set and $set_once - per-event mapping fires
|
|
108
|
+
* client.identify() with person properties. silent: true suppresses capture.
|
|
109
109
|
*/
|
|
110
110
|
declare const identifyWithSetAndSetOnce: PostHogStepExample;
|
|
111
111
|
/**
|
|
112
|
-
* Group identify with properties
|
|
113
|
-
* client.groupIdentify() with group properties.
|
|
112
|
+
* Group identify with properties - per-event mapping fires
|
|
113
|
+
* client.groupIdentify() with group properties. silent: true suppresses capture.
|
|
114
114
|
*/
|
|
115
115
|
declare const groupIdentifyWithProperties: PostHogStepExample;
|
|
116
116
|
/**
|
|
117
|
-
* Capture with group context
|
|
117
|
+
* Capture with group context - destination-level settings.group resolves
|
|
118
118
|
* type + key (no properties). The capture call includes groups.
|
|
119
119
|
*/
|
|
120
120
|
declare const captureWithGroupContext: PostHogStepExample;
|
|
121
121
|
/**
|
|
122
|
-
* Consent revoked
|
|
122
|
+
* Consent revoked - client.disable() is called.
|
|
123
123
|
*/
|
|
124
124
|
declare const consentRevoke: PostHogStepExample;
|
|
125
125
|
/**
|
|
126
|
-
* Consent granted
|
|
126
|
+
* Consent granted - client.enable() is called.
|
|
127
127
|
*/
|
|
128
128
|
declare const consentGrant: PostHogStepExample;
|
|
129
129
|
|
package/dist/dev.d.ts
CHANGED
|
@@ -93,37 +93,37 @@ type PostHogStepExample = Flow.StepExample & {
|
|
|
93
93
|
configInclude?: string[];
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
|
-
* Default event forwarding
|
|
96
|
+
* Default event forwarding - every walkerOS event becomes
|
|
97
97
|
* client.capture({ distinctId, event, properties }). With no mapping
|
|
98
98
|
* and no include, properties is {}. distinctId falls back to event.user.id.
|
|
99
99
|
*/
|
|
100
100
|
declare const defaultCapture: PostHogStepExample;
|
|
101
101
|
/**
|
|
102
|
-
* Capture with include
|
|
102
|
+
* Capture with include - destination-level include flattens data and
|
|
103
103
|
* globals sections into prefixed properties.
|
|
104
104
|
*/
|
|
105
105
|
declare const captureWithInclude: PostHogStepExample;
|
|
106
106
|
/**
|
|
107
|
-
* Identify with $set and $set_once
|
|
108
|
-
* client.identify() with person properties.
|
|
107
|
+
* Identify with $set and $set_once - per-event mapping fires
|
|
108
|
+
* client.identify() with person properties. silent: true suppresses capture.
|
|
109
109
|
*/
|
|
110
110
|
declare const identifyWithSetAndSetOnce: PostHogStepExample;
|
|
111
111
|
/**
|
|
112
|
-
* Group identify with properties
|
|
113
|
-
* client.groupIdentify() with group properties.
|
|
112
|
+
* Group identify with properties - per-event mapping fires
|
|
113
|
+
* client.groupIdentify() with group properties. silent: true suppresses capture.
|
|
114
114
|
*/
|
|
115
115
|
declare const groupIdentifyWithProperties: PostHogStepExample;
|
|
116
116
|
/**
|
|
117
|
-
* Capture with group context
|
|
117
|
+
* Capture with group context - destination-level settings.group resolves
|
|
118
118
|
* type + key (no properties). The capture call includes groups.
|
|
119
119
|
*/
|
|
120
120
|
declare const captureWithGroupContext: PostHogStepExample;
|
|
121
121
|
/**
|
|
122
|
-
* Consent revoked
|
|
122
|
+
* Consent revoked - client.disable() is called.
|
|
123
123
|
*/
|
|
124
124
|
declare const consentRevoke: PostHogStepExample;
|
|
125
125
|
/**
|
|
126
|
-
* Consent granted
|
|
126
|
+
* Consent granted - client.enable() is called.
|
|
127
127
|
*/
|
|
128
128
|
declare const consentGrant: PostHogStepExample;
|
|
129
129
|
|
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(e,o)=>{for(var i in o)t(e,i,{get:o[i],enumerable:!0})},a={};s(a,{examples:()=>y,schemas:()=>r}),module.exports=(e=a,((e,s,a,r)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let p of i(s))n.call(e,p)||p===a||t(e,p,{get:()=>s[p],enumerable:!(r=o(s,p))||r.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r={};s(r,{MappingSchema:()=>u,SettingsSchema:()=>c,mapping:()=>m,settings:()=>g});var p=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),c=l.z.object({apiKey:l.z.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:l.z.string().describe("PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.").optional(),flushAt:l.z.number().describe("Number of events queued before auto-flush. Default: 20.").optional(),flushInterval:l.z.number().describe("Milliseconds between periodic flushes. Default: 10000.").optional(),personalApiKey:l.z.string().describe("Personal API key (phx_...) for local feature flag evaluation.").optional(),featureFlagsPollingInterval:l.z.number().describe("Milliseconds between feature flag definition polls. Default: 30000.").optional(),disableGeoip:l.z.boolean().describe("Disable GeoIP lookups globally. Useful for GDPR compliance.").optional(),debug:l.z.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),identify:l.z.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:l.z.unknown().describe("walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.").optional(),include:l.z.array(l.z.string()).describe('Event sections to flatten into capture() properties (e.g. ["data", "globals"]).').optional()}),d=require("@walkeros/core/dev"),u=d.z.object({identify:d.z.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:d.z.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),g=(0,p.zodToSchema)(c),m=(0,p.zodToSchema)(u),y={};s(y,{env:()=>h,step:()=>v});var h={};s(h,{push:()=>f,simulation:()=>b});var f={get PostHog(){return class{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:client.capture","call:client.identify","call:client.groupIdentify","call:client.shutdown"],v={};s(v,{captureWithGroupContext:()=>z,captureWithInclude:()=>
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(e,o)=>{for(var i in o)t(e,i,{get:o[i],enumerable:!0})},a={};s(a,{examples:()=>y,schemas:()=>r}),module.exports=(e=a,((e,s,a,r)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let p of i(s))n.call(e,p)||p===a||t(e,p,{get:()=>s[p],enumerable:!(r=o(s,p))||r.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r={};s(r,{MappingSchema:()=>u,SettingsSchema:()=>c,mapping:()=>m,settings:()=>g});var p=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),c=l.z.object({apiKey:l.z.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:l.z.string().describe("PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.").optional(),flushAt:l.z.number().describe("Number of events queued before auto-flush. Default: 20.").optional(),flushInterval:l.z.number().describe("Milliseconds between periodic flushes. Default: 10000.").optional(),personalApiKey:l.z.string().describe("Personal API key (phx_...) for local feature flag evaluation.").optional(),featureFlagsPollingInterval:l.z.number().describe("Milliseconds between feature flag definition polls. Default: 30000.").optional(),disableGeoip:l.z.boolean().describe("Disable GeoIP lookups globally. Useful for GDPR compliance.").optional(),debug:l.z.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),identify:l.z.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:l.z.unknown().describe("walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.").optional(),include:l.z.array(l.z.string()).describe('Event sections to flatten into capture() properties (e.g. ["data", "globals"]).').optional()}),d=require("@walkeros/core/dev"),u=d.z.object({identify:d.z.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:d.z.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),g=(0,p.zodToSchema)(c),m=(0,p.zodToSchema)(u),y={};s(y,{env:()=>h,step:()=>v});var h={};s(h,{push:()=>f,simulation:()=>b});var f={get PostHog(){return class{apiKey;options;calls;constructor(e,t){this.apiKey=e,this.options=t||{},this.calls=[]}capture(e){this.calls.push({method:"capture",args:[e]})}identify(e){this.calls.push({method:"identify",args:[e]})}groupIdentify(e){this.calls.push({method:"groupIdentify",args:[e]})}flush(){return this.calls.push({method:"flush",args:[]}),Promise.resolve()}async shutdown(){this.calls.push({method:"shutdown",args:[]})}enable(){this.calls.push({method:"enable",args:[]})}disable(){this.calls.push({method:"disable",args:[]})}}}},b=["call:client.capture","call:client.identify","call:client.groupIdentify","call:client.shutdown"],v={};s(v,{captureWithGroupContext:()=>z,captureWithInclude:()=>P,consentGrant:()=>$,consentRevoke:()=>A,defaultCapture:()=>_,groupIdentifyWithProperties:()=>I,identifyWithSetAndSetOnce:()=>k});var w=require("@walkeros/core"),_={title:"Default capture",description:"A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.",in:(0,w.getEvent)("product view",{timestamp:1700000100}),out:[["client.capture",{distinctId:"us3r",event:"product view",properties:{}}]]},P={title:"Capture with include",description:"Destination-level include flattens data and globals sections into prefixed PostHog event properties.",in:(0,w.getEvent)("order complete",{timestamp:1700000101}),configInclude:["data","globals"],out:[["client.capture",{distinctId:"us3r",event:"order complete",properties:{data_id:"0rd3r1d",data_currency:"EUR",data_shipping:5.22,data_taxes:73.76,data_total:555,globals_pagegroup:"shop"}}]]},k={title:"Identify with $set",description:"A user login fires PostHog identify with $set and $set_once person properties and skips the capture.",in:(0,w.getEvent)("user login",{timestamp:1700000102,data:{user_id:"new-user-123",email:"user@acme.com",plan:"premium"}}),mapping:{silent:!0,settings:{identify:{map:{distinctId:"data.user_id",$set:{map:{email:"data.email",plan:"data.plan"}},$set_once:{map:{first_login:"timestamp"}}}}}},out:[["client.identify",{distinctId:"new-user-123",properties:{$set:{email:"user@acme.com",plan:"premium"},$set_once:{first_login:1700000102}}}]]},I={title:"Group identify",description:"A company update fires PostHog groupIdentify with group type, key, and associated group properties.",in:(0,w.getEvent)("company update",{timestamp:1700000103,data:{company_id:"company_123",company_name:"Acme",plan:"enterprise"}}),mapping:{silent:!0,settings:{group:{map:{type:{value:"company"},key:"data.company_id",properties:{map:{name:"data.company_name",plan:"data.plan"}}}}}},out:[["client.groupIdentify",{groupType:"company",groupKey:"company_123",properties:{name:"Acme",plan:"enterprise"}}]]},z={title:"Capture with group",description:"A destination-level group mapping attaches the resolved group context to every PostHog capture call.",in:(0,w.getEvent)("page view",{timestamp:1700000104,globals:{pagegroup:"docs",company_id:"company_123"}}),settings:{group:{map:{type:{value:"company"},key:"globals.company_id"}}},out:[["client.capture",{distinctId:"us3r",event:"page view",properties:{},groups:{company:"company_123"}}]]},A={title:"Consent revoked",description:"A walker consent command with analytics denied calls client.disable on the PostHog client.",command:"consent",in:{analytics:!1},settings:{},out:[["client.disable"]]},$={title:"Consent granted",description:"A walker consent command with analytics granted calls client.enable on the PostHog client.",command:"consent",in:{analytics:!0},settings:{},out:[["client.enable"]]};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'PostHog project API key (starts with \"phc_\"). Find it in PostHog project settings.',\n ),\n host: z\n .string()\n .describe(\n 'PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.',\n )\n .optional(),\n flushAt: z\n .number()\n .describe('Number of events queued before auto-flush. Default: 20.')\n .optional(),\n flushInterval: z\n .number()\n .describe('Milliseconds between periodic flushes. Default: 10000.')\n .optional(),\n personalApiKey: z\n .string()\n .describe('Personal API key (phx_...) for local feature flag evaluation.')\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe('Disable GeoIP lookups globally. Useful for GDPR compliance.')\n .optional(),\n debug: z\n .boolean()\n .describe('Enable PostHog SDK debug logging. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n 'Event sections to flatten into capture() properties (e.g. [\"data\", \"globals\"]).',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Mock PostHog class that records method calls for testing.\n * Follows the BigQuery env.BigQuery constructor injection pattern.\n */\nfunction createMockPostHog() {\n return class MockPostHog {\n apiKey: string;\n options: Record<string, unknown>;\n calls: Array<{ method: string; args: unknown[] }>;\n\n constructor(apiKey: string, options?: Record<string, unknown>) {\n this.apiKey = apiKey;\n this.options = options || {};\n this.calls = [];\n }\n\n capture(params: Record<string, unknown>) {\n this.calls.push({ method: 'capture', args: [params] });\n }\n\n identify(params: Record<string, unknown>) {\n this.calls.push({ method: 'identify', args: [params] });\n }\n\n groupIdentify(params: Record<string, unknown>) {\n this.calls.push({ method: 'groupIdentify', args: [params] });\n }\n\n flush() {\n this.calls.push({ method: 'flush', args: [] });\n return Promise.resolve();\n }\n\n async shutdown() {\n this.calls.push({ method: 'shutdown', args: [] });\n }\n\n enable() {\n this.calls.push({ method: 'enable', args: [] });\n }\n\n disable() {\n this.calls.push({ method: 'disable', args: [] });\n }\n };\n}\n\n/**\n * Standard mock environment for push operations.\n * Injects a mock PostHog class constructor via env.PostHog.\n */\nexport const push: Env = {\n get PostHog() {\n return createMockPostHog() as unknown as Env['PostHog'];\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:client.capture',\n 'call:client.identify',\n 'call:client.groupIdentify',\n 'call:client.shutdown',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * PostHog server step examples carry destination-level settings and\n * optional configInclude for the test runner to wire up.\n *\n * At push time the destination invokes methods on a `client` constructed\n * via `env.PostHog`. Each `out` tuple is `['client.<method>', ...args]`\n * matching the underlying SDK signature. Multiple calls (identify +\n * capture, groupIdentify + capture) are expressed as a tuple list.\n */\nexport type PostHogStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n};\n\n/**\n * Default event forwarding — every walkerOS event becomes\n * client.capture({ distinctId, event, properties }). With no mapping\n * and no include, properties is {}. distinctId falls back to event.user.id.\n */\nexport const defaultCapture: PostHogStepExample = {\n title: 'Default capture',\n description:\n 'A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.',\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\n },\n ],\n ],\n};\n\n/**\n * Capture with include — destination-level include flattens data and\n * globals sections into prefixed properties.\n */\nexport const captureWithInclude: PostHogStepExample = {\n title: 'Capture with include',\n description:\n 'Destination-level include flattens data and globals sections into prefixed PostHog event properties.',\n in: getEvent('order complete', { timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'order complete',\n properties: {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_total: 555,\n globals_pagegroup: 'shop',\n },\n },\n ],\n ],\n};\n\n/**\n * Identify with $set and $set_once — per-event mapping fires\n * client.identify() with person properties. skip: true suppresses capture.\n */\nexport const identifyWithSetAndSetOnce: PostHogStepExample = {\n title: 'Identify with $set',\n description:\n 'A user login fires PostHog identify with $set and $set_once person properties and skips the capture.',\n in: getEvent('user login', {\n timestamp: 1700000102,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n plan: 'premium',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n $set: {\n map: {\n email: 'data.email',\n plan: 'data.plan',\n },\n },\n $set_once: {\n map: {\n first_login: 'timestamp',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.identify',\n {\n distinctId: 'new-user-123',\n properties: {\n $set: {\n email: 'user@acme.com',\n plan: 'premium',\n },\n $set_once: {\n first_login: 1700000102,\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Group identify with properties — per-event mapping fires\n * client.groupIdentify() with group properties. skip: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\n title: 'Group identify',\n description:\n 'A company update fires PostHog groupIdentify with group type, key, and associated group properties.',\n in: getEvent('company update', {\n timestamp: 1700000103,\n data: {\n company_id: 'company_123',\n company_name: 'Acme',\n plan: 'enterprise',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'data.company_id',\n properties: {\n map: {\n name: 'data.company_name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.groupIdentify',\n {\n groupType: 'company',\n groupKey: 'company_123',\n properties: {\n name: 'Acme',\n plan: 'enterprise',\n },\n },\n ],\n ],\n};\n\n/**\n * Capture with group context — destination-level settings.group resolves\n * type + key (no properties). The capture call includes groups.\n */\nexport const captureWithGroupContext: PostHogStepExample = {\n title: 'Capture with group',\n description:\n 'A destination-level group mapping attaches the resolved group context to every PostHog capture call.',\n in: getEvent('page view', {\n timestamp: 1700000104,\n globals: { pagegroup: 'docs', company_id: 'company_123' },\n }),\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'globals.company_id',\n },\n },\n },\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n ],\n};\n\n/**\n * Consent revoked — client.disable() is called.\n */\nexport const consentRevoke: PostHogStepExample = {\n title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied calls client.disable on the PostHog client.',\n command: 'consent',\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.disable']],\n};\n\n/**\n * Consent granted — client.enable() is called.\n */\nexport const consentGrant: PostHogStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted calls client.enable on the PostHog client.',\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.enable']],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AA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AAC;AAAA,EACX,KAAK,CAAC,CAAC,gBAAgB,CAAC;AAC1B;AAKO,IAAM,eAAmC;AAAA,EAC9C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,eAAe,CAAC;AACzB;","names":["import_dev","import_dev"]}
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'PostHog project API key (starts with \"phc_\"). Find it in PostHog project settings.',\n ),\n host: z\n .string()\n .describe(\n 'PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.',\n )\n .optional(),\n flushAt: z\n .number()\n .describe('Number of events queued before auto-flush. Default: 20.')\n .optional(),\n flushInterval: z\n .number()\n .describe('Milliseconds between periodic flushes. Default: 10000.')\n .optional(),\n personalApiKey: z\n .string()\n .describe('Personal API key (phx_...) for local feature flag evaluation.')\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe('Disable GeoIP lookups globally. Useful for GDPR compliance.')\n .optional(),\n debug: z\n .boolean()\n .describe('Enable PostHog SDK debug logging. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n 'Event sections to flatten into capture() properties (e.g. [\"data\", \"globals\"]).',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Mock PostHog class that records method calls for testing.\n * Follows the BigQuery env.BigQuery constructor injection pattern.\n */\nfunction createMockPostHog() {\n return class MockPostHog {\n apiKey: string;\n options: Record<string, unknown>;\n calls: Array<{ method: string; args: unknown[] }>;\n\n constructor(apiKey: string, options?: Record<string, unknown>) {\n this.apiKey = apiKey;\n this.options = options || {};\n this.calls = [];\n }\n\n capture(params: Record<string, unknown>) {\n this.calls.push({ method: 'capture', args: [params] });\n }\n\n identify(params: Record<string, unknown>) {\n this.calls.push({ method: 'identify', args: [params] });\n }\n\n groupIdentify(params: Record<string, unknown>) {\n this.calls.push({ method: 'groupIdentify', args: [params] });\n }\n\n flush() {\n this.calls.push({ method: 'flush', args: [] });\n return Promise.resolve();\n }\n\n async shutdown() {\n this.calls.push({ method: 'shutdown', args: [] });\n }\n\n enable() {\n this.calls.push({ method: 'enable', args: [] });\n }\n\n disable() {\n this.calls.push({ method: 'disable', args: [] });\n }\n };\n}\n\n/**\n * Standard mock environment for push operations.\n * Injects a mock PostHog class constructor via env.PostHog.\n */\nexport const push: Env = {\n get PostHog() {\n return createMockPostHog() as unknown as Env['PostHog'];\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:client.capture',\n 'call:client.identify',\n 'call:client.groupIdentify',\n 'call:client.shutdown',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * PostHog server step examples carry destination-level settings and\n * optional configInclude for the test runner to wire up.\n *\n * At push time the destination invokes methods on a `client` constructed\n * via `env.PostHog`. Each `out` tuple is `['client.<method>', ...args]`\n * matching the underlying SDK signature. Multiple calls (identify +\n * capture, groupIdentify + capture) are expressed as a tuple list.\n */\nexport type PostHogStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n};\n\n/**\n * Default event forwarding - every walkerOS event becomes\n * client.capture({ distinctId, event, properties }). With no mapping\n * and no include, properties is {}. distinctId falls back to event.user.id.\n */\nexport const defaultCapture: PostHogStepExample = {\n title: 'Default capture',\n description:\n 'A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.',\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\n },\n ],\n ],\n};\n\n/**\n * Capture with include - destination-level include flattens data and\n * globals sections into prefixed properties.\n */\nexport const captureWithInclude: PostHogStepExample = {\n title: 'Capture with include',\n description:\n 'Destination-level include flattens data and globals sections into prefixed PostHog event properties.',\n in: getEvent('order complete', { timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'order complete',\n properties: {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_total: 555,\n globals_pagegroup: 'shop',\n },\n },\n ],\n ],\n};\n\n/**\n * Identify with $set and $set_once - per-event mapping fires\n * client.identify() with person properties. silent: true suppresses capture.\n */\nexport const identifyWithSetAndSetOnce: PostHogStepExample = {\n title: 'Identify with $set',\n description:\n 'A user login fires PostHog identify with $set and $set_once person properties and skips the capture.',\n in: getEvent('user login', {\n timestamp: 1700000102,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n plan: 'premium',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n $set: {\n map: {\n email: 'data.email',\n plan: 'data.plan',\n },\n },\n $set_once: {\n map: {\n first_login: 'timestamp',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.identify',\n {\n distinctId: 'new-user-123',\n properties: {\n $set: {\n email: 'user@acme.com',\n plan: 'premium',\n },\n $set_once: {\n first_login: 1700000102,\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Group identify with properties - per-event mapping fires\n * client.groupIdentify() with group properties. silent: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\n title: 'Group identify',\n description:\n 'A company update fires PostHog groupIdentify with group type, key, and associated group properties.',\n in: getEvent('company update', {\n timestamp: 1700000103,\n data: {\n company_id: 'company_123',\n company_name: 'Acme',\n plan: 'enterprise',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'data.company_id',\n properties: {\n map: {\n name: 'data.company_name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.groupIdentify',\n {\n groupType: 'company',\n groupKey: 'company_123',\n properties: {\n name: 'Acme',\n plan: 'enterprise',\n },\n },\n ],\n ],\n};\n\n/**\n * Capture with group context - destination-level settings.group resolves\n * type + key (no properties). The capture call includes groups.\n */\nexport const captureWithGroupContext: PostHogStepExample = {\n title: 'Capture with group',\n description:\n 'A destination-level group mapping attaches the resolved group context to every PostHog capture call.',\n in: getEvent('page view', {\n timestamp: 1700000104,\n globals: { pagegroup: 'docs', company_id: 'company_123' },\n }),\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'globals.company_id',\n },\n },\n },\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n ],\n};\n\n/**\n * Consent revoked - client.disable() is called.\n */\nexport const consentRevoke: PostHogStepExample = {\n title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied calls client.disable on the PostHog client.',\n command: 'consent',\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.disable']],\n};\n\n/**\n * Consent granted - client.enable() is called.\n */\nexport const consentGrant: PostHogStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted calls client.enable on the PostHog client.',\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.enable']],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,QAAQ,aACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,MAAM,aACH,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,aACN,OAAO,EACP,SAAS,yDAAyD,EAClE,SAAS;AAAA,EACZ,eAAe,aACZ,OAAO,EACP,SAAS,wDAAwD,EACjE,SAAS;AAAA,EACZ,gBAAgB,aACb,OAAO,EACP,SAAS,+DAA+D,EACxE,SAAS;AAAA,EACZ,6BAA6B,aAC1B,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,cAAc,aACX,QAAQ,EACR,SAAS,6DAA6D,EACtE,SAAS;AAAA,EACZ,OAAO,aACJ,QAAQ,EACR,SAAS,mDAAmD,EAC5D,SAAS;AAAA,E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AA,QACE,WAAW;AAAA,QACX,UAAU;AAAA,QACV,YAAY;AAAA,UACV,MAAM;AAAA,UACN,MAAM;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,0BAA8C;AAAA,EACzD,OAAO;AAAA,EACP,aACE;AAAA,EACF,QAAI,sBAAS,aAAa;AAAA,IACxB,WAAW;AAAA,IACX,SAAS,EAAE,WAAW,QAAQ,YAAY,cAAc;AAAA,EAC1D,CAAC;AAAA,EACD,UAAU;AAAA,IACR,OAAO;AAAA,MACL,KAAK;AAAA,QACH,MAAM,EAAE,OAAO,UAAU;AAAA,QACzB,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,QACE,YAAY;AAAA,QACZ,OAAO;AAAA,QACP,YAAY,CAAC;AAAA,QACb,QAAQ,EAAE,SAAS,cAAc;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,gBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,gBAAgB,CAAC;AAC1B;AAKO,IAAM,eAAmC;AAAA,EAC9C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,eAAe,CAAC;AACzB;","names":["import_dev","import_dev"]}
|
package/dist/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,i)=>{for(var o in i)e(t,o,{get:i[o],enumerable:!0})},i={};t(i,{MappingSchema:()=>r,SettingsSchema:()=>n,mapping:()=>l,settings:()=>p});import{zodToSchema as o}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var n=s.object({apiKey:s.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:s.string().describe("PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.").optional(),flushAt:s.number().describe("Number of events queued before auto-flush. Default: 20.").optional(),flushInterval:s.number().describe("Milliseconds between periodic flushes. Default: 10000.").optional(),personalApiKey:s.string().describe("Personal API key (phx_...) for local feature flag evaluation.").optional(),featureFlagsPollingInterval:s.number().describe("Milliseconds between feature flag definition polls. Default: 30000.").optional(),disableGeoip:s.boolean().describe("Disable GeoIP lookups globally. Useful for GDPR compliance.").optional(),debug:s.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),identify:s.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:s.unknown().describe("walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.").optional(),include:s.array(s.string()).describe('Event sections to flatten into capture() properties (e.g. ["data", "globals"]).').optional()});import{z as a}from"@walkeros/core/dev";var r=a.object({identify:a.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:a.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),p=o(n),l=o(r),c={};t(c,{env:()=>d,step:()=>g});var d={};t(d,{push:()=>u,simulation:()=>m});var u={get PostHog(){return class{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:[]})}}}},m=["call:client.capture","call:client.identify","call:client.groupIdentify","call:client.shutdown"],g={};t(g,{captureWithGroupContext:()=>w,captureWithInclude:()=>f,consentGrant:()=>k,consentRevoke:()=>_,defaultCapture:()=>y,groupIdentifyWithProperties:()=>v,identifyWithSetAndSetOnce:()=>b});import{getEvent as h}from"@walkeros/core";var y={title:"Default capture",description:"A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.",in:h("product view",{timestamp:1700000100}),out:[["client.capture",{distinctId:"us3r",event:"product view",properties:{}}]]},f={title:"Capture with include",description:"Destination-level include flattens data and globals sections into prefixed PostHog event properties.",in:h("order complete",{timestamp:1700000101}),configInclude:["data","globals"],out:[["client.capture",{distinctId:"us3r",event:"order complete",properties:{data_id:"0rd3r1d",data_currency:"EUR",data_shipping:5.22,data_taxes:73.76,data_total:555,globals_pagegroup:"shop"}}]]},b={title:"Identify with $set",description:"A user login fires PostHog identify with $set and $set_once person properties and skips the capture.",in:h("user login",{timestamp:1700000102,data:{user_id:"new-user-123",email:"user@acme.com",plan:"premium"}}),mapping:{
|
|
1
|
+
var e=Object.defineProperty,t=(t,i)=>{for(var o in i)e(t,o,{get:i[o],enumerable:!0})},i={};t(i,{MappingSchema:()=>r,SettingsSchema:()=>n,mapping:()=>l,settings:()=>p});import{zodToSchema as o}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var n=s.object({apiKey:s.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:s.string().describe("PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.").optional(),flushAt:s.number().describe("Number of events queued before auto-flush. Default: 20.").optional(),flushInterval:s.number().describe("Milliseconds between periodic flushes. Default: 10000.").optional(),personalApiKey:s.string().describe("Personal API key (phx_...) for local feature flag evaluation.").optional(),featureFlagsPollingInterval:s.number().describe("Milliseconds between feature flag definition polls. Default: 30000.").optional(),disableGeoip:s.boolean().describe("Disable GeoIP lookups globally. Useful for GDPR compliance.").optional(),debug:s.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),identify:s.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:s.unknown().describe("walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.").optional(),include:s.array(s.string()).describe('Event sections to flatten into capture() properties (e.g. ["data", "globals"]).').optional()});import{z as a}from"@walkeros/core/dev";var r=a.object({identify:a.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:a.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),p=o(n),l=o(r),c={};t(c,{env:()=>d,step:()=>g});var d={};t(d,{push:()=>u,simulation:()=>m});var u={get PostHog(){return class{apiKey;options;calls;constructor(e,t){this.apiKey=e,this.options=t||{},this.calls=[]}capture(e){this.calls.push({method:"capture",args:[e]})}identify(e){this.calls.push({method:"identify",args:[e]})}groupIdentify(e){this.calls.push({method:"groupIdentify",args:[e]})}flush(){return this.calls.push({method:"flush",args:[]}),Promise.resolve()}async shutdown(){this.calls.push({method:"shutdown",args:[]})}enable(){this.calls.push({method:"enable",args:[]})}disable(){this.calls.push({method:"disable",args:[]})}}}},m=["call:client.capture","call:client.identify","call:client.groupIdentify","call:client.shutdown"],g={};t(g,{captureWithGroupContext:()=>w,captureWithInclude:()=>f,consentGrant:()=>k,consentRevoke:()=>_,defaultCapture:()=>y,groupIdentifyWithProperties:()=>v,identifyWithSetAndSetOnce:()=>b});import{getEvent as h}from"@walkeros/core";var y={title:"Default capture",description:"A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.",in:h("product view",{timestamp:1700000100}),out:[["client.capture",{distinctId:"us3r",event:"product view",properties:{}}]]},f={title:"Capture with include",description:"Destination-level include flattens data and globals sections into prefixed PostHog event properties.",in:h("order complete",{timestamp:1700000101}),configInclude:["data","globals"],out:[["client.capture",{distinctId:"us3r",event:"order complete",properties:{data_id:"0rd3r1d",data_currency:"EUR",data_shipping:5.22,data_taxes:73.76,data_total:555,globals_pagegroup:"shop"}}]]},b={title:"Identify with $set",description:"A user login fires PostHog identify with $set and $set_once person properties and skips the capture.",in:h("user login",{timestamp:1700000102,data:{user_id:"new-user-123",email:"user@acme.com",plan:"premium"}}),mapping:{silent:!0,settings:{identify:{map:{distinctId:"data.user_id",$set:{map:{email:"data.email",plan:"data.plan"}},$set_once:{map:{first_login:"timestamp"}}}}}},out:[["client.identify",{distinctId:"new-user-123",properties:{$set:{email:"user@acme.com",plan:"premium"},$set_once:{first_login:1700000102}}}]]},v={title:"Group identify",description:"A company update fires PostHog groupIdentify with group type, key, and associated group properties.",in:h("company update",{timestamp:1700000103,data:{company_id:"company_123",company_name:"Acme",plan:"enterprise"}}),mapping:{silent:!0,settings:{group:{map:{type:{value:"company"},key:"data.company_id",properties:{map:{name:"data.company_name",plan:"data.plan"}}}}}},out:[["client.groupIdentify",{groupType:"company",groupKey:"company_123",properties:{name:"Acme",plan:"enterprise"}}]]},w={title:"Capture with group",description:"A destination-level group mapping attaches the resolved group context to every PostHog capture call.",in:h("page view",{timestamp:1700000104,globals:{pagegroup:"docs",company_id:"company_123"}}),settings:{group:{map:{type:{value:"company"},key:"globals.company_id"}}},out:[["client.capture",{distinctId:"us3r",event:"page view",properties:{},groups:{company:"company_123"}}]]},_={title:"Consent revoked",description:"A walker consent command with analytics denied calls client.disable on the PostHog client.",command:"consent",in:{analytics:!1},settings:{},out:[["client.disable"]]},k={title:"Consent granted",description:"A walker consent command with analytics granted calls client.enable on the PostHog client.",command:"consent",in:{analytics:!0},settings:{},out:[["client.enable"]]};export{c as examples,i as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'PostHog project API key (starts with \"phc_\"). Find it in PostHog project settings.',\n ),\n host: z\n .string()\n .describe(\n 'PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.',\n )\n .optional(),\n flushAt: z\n .number()\n .describe('Number of events queued before auto-flush. Default: 20.')\n .optional(),\n flushInterval: z\n .number()\n .describe('Milliseconds between periodic flushes. Default: 10000.')\n .optional(),\n personalApiKey: z\n .string()\n .describe('Personal API key (phx_...) for local feature flag evaluation.')\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe('Disable GeoIP lookups globally. Useful for GDPR compliance.')\n .optional(),\n debug: z\n .boolean()\n .describe('Enable PostHog SDK debug logging. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n 'Event sections to flatten into capture() properties (e.g. [\"data\", \"globals\"]).',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Mock PostHog class that records method calls for testing.\n * Follows the BigQuery env.BigQuery constructor injection pattern.\n */\nfunction createMockPostHog() {\n return class MockPostHog {\n apiKey: string;\n options: Record<string, unknown>;\n calls: Array<{ method: string; args: unknown[] }>;\n\n constructor(apiKey: string, options?: Record<string, unknown>) {\n this.apiKey = apiKey;\n this.options = options || {};\n this.calls = [];\n }\n\n capture(params: Record<string, unknown>) {\n this.calls.push({ method: 'capture', args: [params] });\n }\n\n identify(params: Record<string, unknown>) {\n this.calls.push({ method: 'identify', args: [params] });\n }\n\n groupIdentify(params: Record<string, unknown>) {\n this.calls.push({ method: 'groupIdentify', args: [params] });\n }\n\n flush() {\n this.calls.push({ method: 'flush', args: [] });\n return Promise.resolve();\n }\n\n async shutdown() {\n this.calls.push({ method: 'shutdown', args: [] });\n }\n\n enable() {\n this.calls.push({ method: 'enable', args: [] });\n }\n\n disable() {\n this.calls.push({ method: 'disable', args: [] });\n }\n };\n}\n\n/**\n * Standard mock environment for push operations.\n * Injects a mock PostHog class constructor via env.PostHog.\n */\nexport const push: Env = {\n get PostHog() {\n return createMockPostHog() as unknown as Env['PostHog'];\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:client.capture',\n 'call:client.identify',\n 'call:client.groupIdentify',\n 'call:client.shutdown',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * PostHog server step examples carry destination-level settings and\n * optional configInclude for the test runner to wire up.\n *\n * At push time the destination invokes methods on a `client` constructed\n * via `env.PostHog`. Each `out` tuple is `['client.<method>', ...args]`\n * matching the underlying SDK signature. Multiple calls (identify +\n * capture, groupIdentify + capture) are expressed as a tuple list.\n */\nexport type PostHogStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n};\n\n/**\n * Default event forwarding — every walkerOS event becomes\n * client.capture({ distinctId, event, properties }). With no mapping\n * and no include, properties is {}. distinctId falls back to event.user.id.\n */\nexport const defaultCapture: PostHogStepExample = {\n title: 'Default capture',\n description:\n 'A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.',\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\n },\n ],\n ],\n};\n\n/**\n * Capture with include — destination-level include flattens data and\n * globals sections into prefixed properties.\n */\nexport const captureWithInclude: PostHogStepExample = {\n title: 'Capture with include',\n description:\n 'Destination-level include flattens data and globals sections into prefixed PostHog event properties.',\n in: getEvent('order complete', { timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'order complete',\n properties: {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_total: 555,\n globals_pagegroup: 'shop',\n },\n },\n ],\n ],\n};\n\n/**\n * Identify with $set and $set_once — per-event mapping fires\n * client.identify() with person properties. skip: true suppresses capture.\n */\nexport const identifyWithSetAndSetOnce: PostHogStepExample = {\n title: 'Identify with $set',\n description:\n 'A user login fires PostHog identify with $set and $set_once person properties and skips the capture.',\n in: getEvent('user login', {\n timestamp: 1700000102,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n plan: 'premium',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n $set: {\n map: {\n email: 'data.email',\n plan: 'data.plan',\n },\n },\n $set_once: {\n map: {\n first_login: 'timestamp',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.identify',\n {\n distinctId: 'new-user-123',\n properties: {\n $set: {\n email: 'user@acme.com',\n plan: 'premium',\n },\n $set_once: {\n first_login: 1700000102,\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Group identify with properties — per-event mapping fires\n * client.groupIdentify() with group properties. skip: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\n title: 'Group identify',\n description:\n 'A company update fires PostHog groupIdentify with group type, key, and associated group properties.',\n in: getEvent('company update', {\n timestamp: 1700000103,\n data: {\n company_id: 'company_123',\n company_name: 'Acme',\n plan: 'enterprise',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'data.company_id',\n properties: {\n map: {\n name: 'data.company_name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.groupIdentify',\n {\n groupType: 'company',\n groupKey: 'company_123',\n properties: {\n name: 'Acme',\n plan: 'enterprise',\n },\n },\n ],\n ],\n};\n\n/**\n * Capture with group context — destination-level settings.group resolves\n * type + key (no properties). The capture call includes groups.\n */\nexport const captureWithGroupContext: PostHogStepExample = {\n title: 'Capture with group',\n description:\n 'A destination-level group mapping attaches the resolved group context to every PostHog capture call.',\n in: getEvent('page view', {\n timestamp: 1700000104,\n globals: { pagegroup: 'docs', company_id: 'company_123' },\n }),\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'globals.company_id',\n },\n },\n },\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n ],\n};\n\n/**\n * Consent revoked — client.disable() is called.\n */\nexport const consentRevoke: PostHogStepExample = {\n title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied calls client.disable on the PostHog client.',\n command: 'consent',\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.disable']],\n};\n\n/**\n * Consent granted — client.enable() is called.\n */\nexport const consentGrant: PostHogStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted calls client.enable on the PostHog client.',\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.enable']],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,QAAQ,EACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,MAAM,EACH,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,EACN,OAAO,EACP,SAAS,yDAAyD,EAClE,SAAS;AAAA,EACZ,eAAe,EACZ,OAAO,EACP,SAAS,wDAAwD,EACjE,SAAS;AAAA,EACZ,gBAAgB,EACb,OAAO,EACP,SAAS,+DAA+D,EACxE,SAAS;AAAA,EACZ,6BAA6B,EAC1B,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,cAAc,EACX,QAAQ,EACR,SAAS,6DAA6D,EACtE,SAAS;AAAA,EACZ,OAAO,EACJ,QAAQ,EACR,SAAS,mDAAmD,EAC5D,SAAS;AAAA,EACZ,UAAU,EACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,OAAO,EACJ,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,EACN,MAAM,EAAE,OAAO,CAAC,EAChB;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC;;;AC3DD,SAAS,KAAAA,UAAS;AAEX,IAAM,gBAAgBA,GAAE,OAAO;AAAA,EACpC,UAAUA,GACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,OAAOA,GACJ,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC;;;AFPM,IAAM,WAAW,YAAY,cAAc;AAC3C,IAAM,UAAU,YAAY,aAAa;;;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AAY,CAAC;AAAA,QACb,QAAQ,EAAE,SAAS,cAAc;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,gBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,gBAAgB,CAAC;AAC1B;AAKO,IAAM,eAAmC;AAAA,EAC9C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,eAAe,CAAC;AACzB;","names":["z"]}
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'PostHog project API key (starts with \"phc_\"). Find it in PostHog project settings.',\n ),\n host: z\n .string()\n .describe(\n 'PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.',\n )\n .optional(),\n flushAt: z\n .number()\n .describe('Number of events queued before auto-flush. Default: 20.')\n .optional(),\n flushInterval: z\n .number()\n .describe('Milliseconds between periodic flushes. Default: 10000.')\n .optional(),\n personalApiKey: z\n .string()\n .describe('Personal API key (phx_...) for local feature flag evaluation.')\n .optional(),\n featureFlagsPollingInterval: z\n .number()\n .describe(\n 'Milliseconds between feature flag definition polls. Default: 30000.',\n )\n .optional(),\n disableGeoip: z\n .boolean()\n .describe('Disable GeoIP lookups globally. Useful for GDPR compliance.')\n .optional(),\n debug: z\n .boolean()\n .describe('Enable PostHog SDK debug logging. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n 'Event sections to flatten into capture() properties (e.g. [\"data\", \"globals\"]).',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Mock PostHog class that records method calls for testing.\n * Follows the BigQuery env.BigQuery constructor injection pattern.\n */\nfunction createMockPostHog() {\n return class MockPostHog {\n apiKey: string;\n options: Record<string, unknown>;\n calls: Array<{ method: string; args: unknown[] }>;\n\n constructor(apiKey: string, options?: Record<string, unknown>) {\n this.apiKey = apiKey;\n this.options = options || {};\n this.calls = [];\n }\n\n capture(params: Record<string, unknown>) {\n this.calls.push({ method: 'capture', args: [params] });\n }\n\n identify(params: Record<string, unknown>) {\n this.calls.push({ method: 'identify', args: [params] });\n }\n\n groupIdentify(params: Record<string, unknown>) {\n this.calls.push({ method: 'groupIdentify', args: [params] });\n }\n\n flush() {\n this.calls.push({ method: 'flush', args: [] });\n return Promise.resolve();\n }\n\n async shutdown() {\n this.calls.push({ method: 'shutdown', args: [] });\n }\n\n enable() {\n this.calls.push({ method: 'enable', args: [] });\n }\n\n disable() {\n this.calls.push({ method: 'disable', args: [] });\n }\n };\n}\n\n/**\n * Standard mock environment for push operations.\n * Injects a mock PostHog class constructor via env.PostHog.\n */\nexport const push: Env = {\n get PostHog() {\n return createMockPostHog() as unknown as Env['PostHog'];\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:client.capture',\n 'call:client.identify',\n 'call:client.groupIdentify',\n 'call:client.shutdown',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * PostHog server step examples carry destination-level settings and\n * optional configInclude for the test runner to wire up.\n *\n * At push time the destination invokes methods on a `client` constructed\n * via `env.PostHog`. Each `out` tuple is `['client.<method>', ...args]`\n * matching the underlying SDK signature. Multiple calls (identify +\n * capture, groupIdentify + capture) are expressed as a tuple list.\n */\nexport type PostHogStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n};\n\n/**\n * Default event forwarding - every walkerOS event becomes\n * client.capture({ distinctId, event, properties }). With no mapping\n * and no include, properties is {}. distinctId falls back to event.user.id.\n */\nexport const defaultCapture: PostHogStepExample = {\n title: 'Default capture',\n description:\n 'A walker event becomes a PostHog capture call with the user id as distinctId and no extra properties.',\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\n },\n ],\n ],\n};\n\n/**\n * Capture with include - destination-level include flattens data and\n * globals sections into prefixed properties.\n */\nexport const captureWithInclude: PostHogStepExample = {\n title: 'Capture with include',\n description:\n 'Destination-level include flattens data and globals sections into prefixed PostHog event properties.',\n in: getEvent('order complete', { timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'order complete',\n properties: {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_total: 555,\n globals_pagegroup: 'shop',\n },\n },\n ],\n ],\n};\n\n/**\n * Identify with $set and $set_once - per-event mapping fires\n * client.identify() with person properties. silent: true suppresses capture.\n */\nexport const identifyWithSetAndSetOnce: PostHogStepExample = {\n title: 'Identify with $set',\n description:\n 'A user login fires PostHog identify with $set and $set_once person properties and skips the capture.',\n in: getEvent('user login', {\n timestamp: 1700000102,\n data: {\n user_id: 'new-user-123',\n email: 'user@acme.com',\n plan: 'premium',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n $set: {\n map: {\n email: 'data.email',\n plan: 'data.plan',\n },\n },\n $set_once: {\n map: {\n first_login: 'timestamp',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.identify',\n {\n distinctId: 'new-user-123',\n properties: {\n $set: {\n email: 'user@acme.com',\n plan: 'premium',\n },\n $set_once: {\n first_login: 1700000102,\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Group identify with properties - per-event mapping fires\n * client.groupIdentify() with group properties. silent: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\n title: 'Group identify',\n description:\n 'A company update fires PostHog groupIdentify with group type, key, and associated group properties.',\n in: getEvent('company update', {\n timestamp: 1700000103,\n data: {\n company_id: 'company_123',\n company_name: 'Acme',\n plan: 'enterprise',\n },\n }),\n mapping: {\n silent: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'data.company_id',\n properties: {\n map: {\n name: 'data.company_name',\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'client.groupIdentify',\n {\n groupType: 'company',\n groupKey: 'company_123',\n properties: {\n name: 'Acme',\n plan: 'enterprise',\n },\n },\n ],\n ],\n};\n\n/**\n * Capture with group context - destination-level settings.group resolves\n * type + key (no properties). The capture call includes groups.\n */\nexport const captureWithGroupContext: PostHogStepExample = {\n title: 'Capture with group',\n description:\n 'A destination-level group mapping attaches the resolved group context to every PostHog capture call.',\n in: getEvent('page view', {\n timestamp: 1700000104,\n globals: { pagegroup: 'docs', company_id: 'company_123' },\n }),\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n key: 'globals.company_id',\n },\n },\n },\n out: [\n [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n ],\n};\n\n/**\n * Consent revoked - client.disable() is called.\n */\nexport const consentRevoke: PostHogStepExample = {\n title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied calls client.disable on the PostHog client.',\n command: 'consent',\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.disable']],\n};\n\n/**\n * Consent granted - client.enable() is called.\n */\nexport const consentGrant: PostHogStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted calls client.enable on the PostHog client.',\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [['client.enable']],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,QAAQ,EACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,MAAM,EACH,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,EACN,OAAO,EACP,SAAS,yDAAyD,EAClE,SAAS;AAAA,EACZ,eAAe,EACZ,OAAO,EACP,SAAS,wDAAwD,EACjE,SAAS;AAAA,EACZ,gBAAgB,EACb,OAAO,EACP,SAAS,+DAA+D,EACxE,SAAS;AAAA,EACZ,6BAA6B,EAC1B,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,cAAc,EACX,QA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AA,YACR;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,QACE,WAAW;AAAA,QACX,UAAU;AAAA,QACV,YAAY;AAAA,UACV,MAAM;AAAA,UACN,MAAM;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,0BAA8C;AAAA,EACzD,OAAO;AAAA,EACP,aACE;AAAA,EACF,IAAI,SAAS,aAAa;AAAA,IACxB,WAAW;AAAA,IACX,SAAS,EAAE,WAAW,QAAQ,YAAY,cAAc;AAAA,EAC1D,CAAC;AAAA,EACD,UAAU;AAAA,IACR,OAAO;AAAA,MACL,KAAK;AAAA,QACH,MAAM,EAAE,OAAO,UAAU;AAAA,QACzB,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,QACE,YAAY;AAAA,QACZ,OAAO;AAAA,QACP,YAAY,CAAC;AAAA,QACb,QAAQ,EAAE,SAAS,cAAc;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,gBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,gBAAgB,CAAC;AAC1B;AAKO,IAAM,eAAmC;AAAA,EAC9C,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,eAAe,CAAC;AACzB;","names":["z"]}
|
|
@@ -58,37 +58,37 @@ type PostHogStepExample = Flow.StepExample & {
|
|
|
58
58
|
configInclude?: string[];
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
|
-
* Default event forwarding
|
|
61
|
+
* Default event forwarding - every walkerOS event becomes
|
|
62
62
|
* client.capture({ distinctId, event, properties }). With no mapping
|
|
63
63
|
* and no include, properties is {}. distinctId falls back to event.user.id.
|
|
64
64
|
*/
|
|
65
65
|
declare const defaultCapture: PostHogStepExample;
|
|
66
66
|
/**
|
|
67
|
-
* Capture with include
|
|
67
|
+
* Capture with include - destination-level include flattens data and
|
|
68
68
|
* globals sections into prefixed properties.
|
|
69
69
|
*/
|
|
70
70
|
declare const captureWithInclude: PostHogStepExample;
|
|
71
71
|
/**
|
|
72
|
-
* Identify with $set and $set_once
|
|
73
|
-
* client.identify() with person properties.
|
|
72
|
+
* Identify with $set and $set_once - per-event mapping fires
|
|
73
|
+
* client.identify() with person properties. silent: true suppresses capture.
|
|
74
74
|
*/
|
|
75
75
|
declare const identifyWithSetAndSetOnce: PostHogStepExample;
|
|
76
76
|
/**
|
|
77
|
-
* Group identify with properties
|
|
78
|
-
* client.groupIdentify() with group properties.
|
|
77
|
+
* Group identify with properties - per-event mapping fires
|
|
78
|
+
* client.groupIdentify() with group properties. silent: true suppresses capture.
|
|
79
79
|
*/
|
|
80
80
|
declare const groupIdentifyWithProperties: PostHogStepExample;
|
|
81
81
|
/**
|
|
82
|
-
* Capture with group context
|
|
82
|
+
* Capture with group context - destination-level settings.group resolves
|
|
83
83
|
* type + key (no properties). The capture call includes groups.
|
|
84
84
|
*/
|
|
85
85
|
declare const captureWithGroupContext: PostHogStepExample;
|
|
86
86
|
/**
|
|
87
|
-
* Consent revoked
|
|
87
|
+
* Consent revoked - client.disable() is called.
|
|
88
88
|
*/
|
|
89
89
|
declare const consentRevoke: PostHogStepExample;
|
|
90
90
|
/**
|
|
91
|
-
* Consent granted
|
|
91
|
+
* Consent granted - client.enable() is called.
|
|
92
92
|
*/
|
|
93
93
|
declare const consentGrant: PostHogStepExample;
|
|
94
94
|
|
package/dist/examples/index.d.ts
CHANGED
|
@@ -58,37 +58,37 @@ type PostHogStepExample = Flow.StepExample & {
|
|
|
58
58
|
configInclude?: string[];
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
|
-
* Default event forwarding
|
|
61
|
+
* Default event forwarding - every walkerOS event becomes
|
|
62
62
|
* client.capture({ distinctId, event, properties }). With no mapping
|
|
63
63
|
* and no include, properties is {}. distinctId falls back to event.user.id.
|
|
64
64
|
*/
|
|
65
65
|
declare const defaultCapture: PostHogStepExample;
|
|
66
66
|
/**
|
|
67
|
-
* Capture with include
|
|
67
|
+
* Capture with include - destination-level include flattens data and
|
|
68
68
|
* globals sections into prefixed properties.
|
|
69
69
|
*/
|
|
70
70
|
declare const captureWithInclude: PostHogStepExample;
|
|
71
71
|
/**
|
|
72
|
-
* Identify with $set and $set_once
|
|
73
|
-
* client.identify() with person properties.
|
|
72
|
+
* Identify with $set and $set_once - per-event mapping fires
|
|
73
|
+
* client.identify() with person properties. silent: true suppresses capture.
|
|
74
74
|
*/
|
|
75
75
|
declare const identifyWithSetAndSetOnce: PostHogStepExample;
|
|
76
76
|
/**
|
|
77
|
-
* Group identify with properties
|
|
78
|
-
* client.groupIdentify() with group properties.
|
|
77
|
+
* Group identify with properties - per-event mapping fires
|
|
78
|
+
* client.groupIdentify() with group properties. silent: true suppresses capture.
|
|
79
79
|
*/
|
|
80
80
|
declare const groupIdentifyWithProperties: PostHogStepExample;
|
|
81
81
|
/**
|
|
82
|
-
* Capture with group context
|
|
82
|
+
* Capture with group context - destination-level settings.group resolves
|
|
83
83
|
* type + key (no properties). The capture call includes groups.
|
|
84
84
|
*/
|
|
85
85
|
declare const captureWithGroupContext: PostHogStepExample;
|
|
86
86
|
/**
|
|
87
|
-
* Consent revoked
|
|
87
|
+
* Consent revoked - client.disable() is called.
|
|
88
88
|
*/
|
|
89
89
|
declare const consentRevoke: PostHogStepExample;
|
|
90
90
|
/**
|
|
91
|
-
* Consent granted
|
|
91
|
+
* Consent granted - client.enable() is called.
|
|
92
92
|
*/
|
|
93
93
|
declare const consentGrant: PostHogStepExample;
|
|
94
94
|
|
package/dist/examples/index.js
CHANGED
|
@@ -33,6 +33,9 @@ __export(env_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
function createMockPostHog() {
|
|
35
35
|
return class MockPostHog {
|
|
36
|
+
apiKey;
|
|
37
|
+
options;
|
|
38
|
+
calls;
|
|
36
39
|
constructor(apiKey, options) {
|
|
37
40
|
this.apiKey = apiKey;
|
|
38
41
|
this.options = options || {};
|
|
@@ -136,7 +139,7 @@ var identifyWithSetAndSetOnce = {
|
|
|
136
139
|
}
|
|
137
140
|
}),
|
|
138
141
|
mapping: {
|
|
139
|
-
|
|
142
|
+
silent: true,
|
|
140
143
|
settings: {
|
|
141
144
|
identify: {
|
|
142
145
|
map: {
|
|
@@ -186,7 +189,7 @@ var groupIdentifyWithProperties = {
|
|
|
186
189
|
}
|
|
187
190
|
}),
|
|
188
191
|
mapping: {
|
|
189
|
-
|
|
192
|
+
silent: true,
|
|
190
193
|
settings: {
|
|
191
194
|
group: {
|
|
192
195
|
map: {
|
package/dist/examples/index.mjs
CHANGED
|
@@ -12,6 +12,9 @@ __export(env_exports, {
|
|
|
12
12
|
});
|
|
13
13
|
function createMockPostHog() {
|
|
14
14
|
return class MockPostHog {
|
|
15
|
+
apiKey;
|
|
16
|
+
options;
|
|
17
|
+
calls;
|
|
15
18
|
constructor(apiKey, options) {
|
|
16
19
|
this.apiKey = apiKey;
|
|
17
20
|
this.options = options || {};
|
|
@@ -115,7 +118,7 @@ var identifyWithSetAndSetOnce = {
|
|
|
115
118
|
}
|
|
116
119
|
}),
|
|
117
120
|
mapping: {
|
|
118
|
-
|
|
121
|
+
silent: true,
|
|
119
122
|
settings: {
|
|
120
123
|
identify: {
|
|
121
124
|
map: {
|
|
@@ -165,7 +168,7 @@ var groupIdentifyWithProperties = {
|
|
|
165
168
|
}
|
|
166
169
|
}),
|
|
167
170
|
mapping: {
|
|
168
|
-
|
|
171
|
+
silent: true,
|
|
169
172
|
settings: {
|
|
170
173
|
group: {
|
|
171
174
|
map: {
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationPostHog:()=>types_exports,default:()=>index_default,destinationPostHog:()=>destinationPostHog}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_posthog_node=require("posthog-node");var import_core=require("@walkeros/core"),types_exports={},destinationPostHog={type:"posthog",config:{},async init({config:partialConfig,env:env,logger:logger}){const config=function(partialConfig={},env,logger){const settings=partialConfig.settings||{},{apiKey:apiKey}=settings;apiKey||logger.throw("Config settings apiKey missing");const options={};settings.host&&(options.host=settings.host),void 0!==settings.flushAt&&(options.flushAt=settings.flushAt),void 0!==settings.flushInterval&&(options.flushInterval=settings.flushInterval),settings.personalApiKey&&(options.personalApiKey=settings.personalApiKey),void 0!==settings.featureFlagsPollingInterval&&(options.featureFlagsPollingInterval=settings.featureFlagsPollingInterval),void 0!==settings.disableGeoip&&(options.disableGeoip=settings.disableGeoip),void 0!==settings.disableCompression&&(options.disableCompression=settings.disableCompression),void 0!==settings.requestTimeout&&(options.requestTimeout=settings.requestTimeout),void 0!==settings.fetchRetryCount&&(options.fetchRetryCount=settings.fetchRetryCount),void 0!==settings.fetchRetryDelay&&(options.fetchRetryDelay=settings.fetchRetryDelay),void 0!==settings.debug&&(options.debug=settings.debug),void 0!==settings.disabled&&(options.disabled=settings.disabled);const client=new(
|
|
1
|
+
"use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationPostHog:()=>types_exports,default:()=>index_default,destinationPostHog:()=>destinationPostHog}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_posthog_node=require("posthog-node");var import_core=require("@walkeros/core"),types_exports={},destinationPostHog={type:"posthog",config:{},async init({config:partialConfig,env:env,logger:logger}){const config=function(partialConfig={},env,logger){const settings=partialConfig.settings||{},{apiKey:apiKey}=settings;apiKey||logger.throw("Config settings apiKey missing");const options={};settings.host&&(options.host=settings.host),void 0!==settings.flushAt&&(options.flushAt=settings.flushAt),void 0!==settings.flushInterval&&(options.flushInterval=settings.flushInterval),settings.personalApiKey&&(options.personalApiKey=settings.personalApiKey),void 0!==settings.featureFlagsPollingInterval&&(options.featureFlagsPollingInterval=settings.featureFlagsPollingInterval),void 0!==settings.disableGeoip&&(options.disableGeoip=settings.disableGeoip),void 0!==settings.disableCompression&&(options.disableCompression=settings.disableCompression),void 0!==settings.requestTimeout&&(options.requestTimeout=settings.requestTimeout),void 0!==settings.fetchRetryCount&&(options.fetchRetryCount=settings.fetchRetryCount),void 0!==settings.fetchRetryDelay&&(options.fetchRetryDelay=settings.fetchRetryDelay),void 0!==settings.debug&&(options.debug=settings.debug),void 0!==settings.disabled&&(options.disabled=settings.disabled);const client=new(env?.PostHog||import_posthog_node.PostHog)(apiKey,options),settingsConfig={...settings,apiKey:apiKey,client:client};return{...partialConfig,settings:settingsConfig}}(partialConfig,env,logger);return config},push:async(event,context)=>await async function(event,{config:config,rule:rule,data:data,collector:collector}){const settings=config.settings,client=settings.client;if(!client)return;const mappingSettings=rule?.settings||{},identifyMapping=mappingSettings.identify??settings.identify;let distinctId,identifyResolved;if(void 0!==identifyMapping){const resolved=await(0,import_core.getMappingValue)(event,identifyMapping,{collector:collector});(0,import_core.isObject)(resolved)&&(identifyResolved=resolved,(0,import_core.isString)(identifyResolved.distinctId)&&(distinctId=identifyResolved.distinctId))}if(distinctId||(distinctId=((0,import_core.isString)(event.user?.id)?event.user.id:void 0)||((0,import_core.isString)(event.user?.hash)?event.user.hash:void 0)||((0,import_core.isString)(event.user?.session)?event.user.session:void 0)||"anonymous"),identifyResolved){const $set=(0,import_core.isObject)(identifyResolved.$set)?identifyResolved.$set:void 0,$setOnce=(0,import_core.isObject)(identifyResolved.$set_once)?identifyResolved.$set_once:void 0;if($set||$setOnce){const properties={};$set&&(properties.$set=$set),$setOnce&&(properties.$set_once=$setOnce),client.identify({distinctId:distinctId,properties:properties})}}const groupMapping=mappingSettings.group??settings.group;let groups;if(void 0!==groupMapping){const resolved=await(0,import_core.getMappingValue)(event,groupMapping,{collector:collector});if((0,import_core.isObject)(resolved)){const groupResolved=resolved,type=groupResolved.type,key=groupResolved.key,properties=(0,import_core.isObject)(groupResolved.properties)?groupResolved.properties:void 0;(0,import_core.isString)(type)&&((0,import_core.isString)(key)||"number"==typeof key)&&(properties&&client.groupIdentify({groupType:type,groupKey:String(key),properties:properties}),groups={[type]:key})}}if(!0!==rule?.silent){const captureArgs={distinctId:distinctId,event:(0,import_core.isString)(rule?.name)?rule.name:event.name,properties:(0,import_core.isObject)(data)?data:{}};groups&&(captureArgs.groups=groups),client.capture(captureArgs)}}(event,context),async destroy({config:config}){const client=config?.settings?.client;client&&await client.shutdown()},on(type,context){if("consent"!==type||!context?.data)return;const client=(context.config?.settings||{}).client;if(!client)return;const consent=context.data,required=context.config?.consent;if(!required||0===Object.keys(required).length)return;Object.keys(required).every(key=>!0===consent[key])?client.enable():client.disable()}},index_default=destinationPostHog;//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/push.ts","../src/types/index.ts"],"sourcesContent":["import type { WalkerOS } from '@walkeros/core';\nimport type { Destination, Env, Settings } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationPostHog from './types';\n\nexport const destinationPostHog: Destination = {\n type: 'posthog',\n\n config: {},\n\n async init({ config: partialConfig, env, logger }) {\n const config = getConfig(partialConfig, env as Env | undefined, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n\n async destroy({ config }) {\n const client = (config?.settings as Settings | undefined)?.client;\n if (client) {\n await client.shutdown();\n }\n },\n\n on(type, context) {\n if (type !== 'consent' || !context?.data) return;\n\n const settings = (context.config?.settings || {}) as Settings;\n const client = settings.client;\n if (!client) return;\n\n const consent = context.data as WalkerOS.Consent;\n const required = (context.config as { consent?: WalkerOS.Consent })\n ?.consent;\n if (!required || Object.keys(required).length === 0) return;\n\n const allGranted = Object.keys(required).every(\n (key) => consent[key] === true,\n );\n if (allGranted) {\n client.enable();\n } else {\n client.disable();\n }\n },\n};\n\nexport default destinationPostHog;\n","import type { Config, Env, PartialConfig, Settings } from './types';\nimport type { Logger } from '@walkeros/core';\nimport { PostHog } from 'posthog-node';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n env: Env | undefined,\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { apiKey } = settings;\n\n if (!apiKey) logger.throw('Config settings apiKey missing');\n\n // Extract PostHog SDK options from settings\n const options: Record<string, unknown> = {};\n if (settings.host) options.host = settings.host;\n if (settings.flushAt !== undefined) options.flushAt = settings.flushAt;\n if (settings.flushInterval !== undefined)\n options.flushInterval = settings.flushInterval;\n if (settings.personalApiKey) options.personalApiKey = settings.personalApiKey;\n if (settings.featureFlagsPollingInterval !== undefined)\n options.featureFlagsPollingInterval = settings.featureFlagsPollingInterval;\n if (settings.disableGeoip !== undefined)\n options.disableGeoip = settings.disableGeoip;\n if (settings.disableCompression !== undefined)\n options.disableCompression = settings.disableCompression;\n if (settings.requestTimeout !== undefined)\n options.requestTimeout = settings.requestTimeout;\n if (settings.fetchRetryCount !== undefined)\n options.fetchRetryCount = settings.fetchRetryCount;\n if (settings.fetchRetryDelay !== undefined)\n options.fetchRetryDelay = settings.fetchRetryDelay;\n if (settings.debug !== undefined) options.debug = settings.debug;\n if (settings.disabled !== undefined) options.disabled = settings.disabled;\n\n // Use PostHog from env if available, otherwise use real PostHog\n const PostHogClass = env?.PostHog || PostHog;\n const client = new PostHogClass(apiKey, options);\n\n const settingsConfig: Settings = {\n ...settings,\n apiKey,\n client,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { PushFn } from './types';\nimport { getMappingValue, isObject, isString } from '@walkeros/core';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector },\n) {\n const settings = config.settings!;\n const client = settings.client;\n if (!client) return;\n\n const mappingSettings = (rule?.settings || {}) as Record<string, unknown>;\n\n // Resolve distinctId: rule-level identify wins over destination-level\n const identifyMapping = mappingSettings.identify ?? settings.identify;\n let distinctId: string | undefined;\n let identifyResolved: Record<string, unknown> | undefined;\n\n if (identifyMapping !== undefined) {\n const resolved = await getMappingValue(event, identifyMapping, {\n collector,\n });\n if (isObject(resolved)) {\n identifyResolved = resolved as Record<string, unknown>;\n if (isString(identifyResolved.distinctId)) {\n distinctId = identifyResolved.distinctId as string;\n }\n }\n }\n\n // Fallback distinctId from event.user\n if (!distinctId) {\n distinctId =\n (isString(event.user?.id) ? event.user.id : undefined) ||\n (isString(event.user?.hash) ? event.user.hash : undefined) ||\n (isString(event.user?.session) ? event.user.session : undefined) ||\n 'anonymous';\n }\n\n // 1. Identity — if $set or $set_once present, call client.identify()\n if (identifyResolved) {\n const $set = isObject(identifyResolved.$set)\n ? (identifyResolved.$set as Record<string, unknown>)\n : undefined;\n const $setOnce = isObject(identifyResolved.$set_once)\n ? (identifyResolved.$set_once as Record<string, unknown>)\n : undefined;\n\n if ($set || $setOnce) {\n const properties: Record<string, unknown> = {};\n if ($set) properties.$set = $set;\n if ($setOnce) properties.$set_once = $setOnce;\n client.identify({ distinctId, properties });\n }\n }\n\n // 2. Group — resolve group mapping (rule-level wins)\n const groupMapping = mappingSettings.group ?? settings.group;\n let groups: Record<string, string | number> | undefined;\n\n if (groupMapping !== undefined) {\n const resolved = await getMappingValue(event, groupMapping, {\n collector,\n });\n if (isObject(resolved)) {\n const groupResolved = resolved as Record<string, unknown>;\n const type = groupResolved.type;\n const key = groupResolved.key;\n const properties = isObject(groupResolved.properties)\n ? (groupResolved.properties as Record<string, unknown>)\n : undefined;\n\n if (isString(type) && (isString(key) || typeof key === 'number')) {\n // If properties present, call groupIdentify\n if (properties) {\n client.groupIdentify({\n groupType: type,\n groupKey: String(key),\n properties,\n });\n }\n // Build groups object for capture\n groups = { [type]: key as string | number };\n }\n }\n }\n\n // 3. Capture — unless rule opts out via skip\n if (rule?.skip !== true) {\n const eventName = isString(rule?.name) ? rule.name : event.name;\n const properties = isObject(data) ? (data as Record<string, unknown>) : {};\n\n const captureArgs: Record<string, unknown> = {\n distinctId,\n event: eventName,\n properties,\n };\n if (groups) captureArgs.groups = groups;\n\n client.capture(captureArgs as Parameters<typeof client.capture>[0]);\n }\n};\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer } from '@walkeros/server-core';\nimport type { PostHog } from 'posthog-node';\n\nexport interface Settings {\n /** PostHog project API key (phc_...) */\n apiKey: string;\n /** PostHog client instance, populated by init */\n client?: PostHog;\n /** Destination-level identity mapping */\n identify?: WalkerOSMapping.Value;\n /** Destination-level group mapping */\n group?: WalkerOSMapping.Value;\n /** Event sections to flatten into capture properties */\n include?: string[];\n // PostHog SDK passthrough options\n host?: string;\n flushAt?: number;\n flushInterval?: number;\n personalApiKey?: string;\n featureFlagsPollingInterval?: number;\n disableGeoip?: boolean;\n disableCompression?: boolean;\n requestTimeout?: number;\n fetchRetryCount?: number;\n fetchRetryDelay?: number;\n debug?: boolean;\n disabled?: boolean;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n identify?: WalkerOSMapping.Value;\n group?: WalkerOSMapping.Value;\n}\n\nexport interface Env extends DestinationServer.Env {\n PostHog?: typeof PostHog;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,0BAAwB;AAEjB,SAAS,UACd,gBAA+B,CAAC,GAChC,KACA,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,OAAO,IAAI;AAEnB,MAAI,CAAC,OAAQ,QAAO,MAAM,gCAAgC;AAG1D,QAAM,UAAmC,CAAC;AAC1C,MAAI,SAAS,KAAM,SAAQ,OAAO,SAAS;AAC3C,MAAI,SAAS,YAAY,OAAW,SAAQ,UAAU,SAAS;AAC/D,MAAI,SAAS,kBAAkB;AAC7B,YAAQ,gBAAgB,SAAS;AACnC,MAAI,SAAS,eAAgB,SAAQ,iBAAiB,SAAS;AAC/D,MAAI,SAAS,gCAAgC;AAC3C,YAAQ,8BAA8B,SAAS;AACjD,MAAI,SAAS,iBAAiB;AAC5B,YAAQ,eAAe,SAAS;AAClC,MAAI,SAAS,uBAAuB;AAClC,Y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;;;ACrGA;;;AHQO,IAAM,qBAAkC;AAAA,EAC7C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,eAAe,KAAK,OAAO,GAAG;AACjD,UAAM,SAAS,UAAU,eAAe,KAAwB,MAAM;AACtE,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,SAAS;AACzB,WAAO,MAAM,KAAK,OAAO,OAAO;AAAA,EAClC;AAAA,EAEA,MAAM,QAAQ,EAAE,OAAO,GAAG;AAtB5B;AAuBI,UAAM,UAAU,sCAAQ,aAAR,mBAA2C;AAC3D,QAAI,QAAQ;AACV,YAAM,OAAO,SAAS;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,GAAG,MAAM,SAAS;AA7BpB;AA8BI,QAAI,SAAS,aAAa,EAAC,mCAAS,MAAM;AAE1C,UAAM,aAAY,aAAQ,WAAR,mBAAgB,aAAY,CAAC;AAC/C,UAAM,SAAS,SAAS;AACxB,QAAI,CAAC,OAAQ;AAEb,UAAM,UAAU,QAAQ;AACxB,UAAM,YAAY,aAAQ,WAAR,mBACd;AACJ,QAAI,CAAC,YAAY,OAAO,KAAK,QAAQ,EAAE,WAAW,EAAG;AAErD,UAAM,aAAa,OAAO,KAAK,QAAQ,EAAE;AAAA,MACvC,CAAC,QAAQ,QAAQ,GAAG,MAAM;AAAA,IAC5B;AACA,QAAI,YAAY;AACd,aAAO,OAAO;AAAA,IAChB,OAAO;AACL,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/push.ts","../src/types/index.ts"],"sourcesContent":["import type { WalkerOS } from '@walkeros/core';\nimport type { Destination, Env, Settings } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationPostHog from './types';\n\nexport const destinationPostHog: Destination = {\n type: 'posthog',\n\n config: {},\n\n async init({ config: partialConfig, env, logger }) {\n const config = getConfig(partialConfig, env as Env | undefined, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n\n async destroy({ config }) {\n const client = (config?.settings as Settings | undefined)?.client;\n if (client) {\n await client.shutdown();\n }\n },\n\n on(type, context) {\n if (type !== 'consent' || !context?.data) return;\n\n const settings = (context.config?.settings || {}) as Settings;\n const client = settings.client;\n if (!client) return;\n\n const consent = context.data as WalkerOS.Consent;\n const required = (context.config as { consent?: WalkerOS.Consent })\n ?.consent;\n if (!required || Object.keys(required).length === 0) return;\n\n const allGranted = Object.keys(required).every(\n (key) => consent[key] === true,\n );\n if (allGranted) {\n client.enable();\n } else {\n client.disable();\n }\n },\n};\n\nexport default destinationPostHog;\n","import type { Config, Env, PartialConfig, Settings } from './types';\nimport type { Logger } from '@walkeros/core';\nimport { PostHog } from 'posthog-node';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n env: Env | undefined,\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { apiKey } = settings;\n\n if (!apiKey) logger.throw('Config settings apiKey missing');\n\n // Extract PostHog SDK options from settings\n const options: Record<string, unknown> = {};\n if (settings.host) options.host = settings.host;\n if (settings.flushAt !== undefined) options.flushAt = settings.flushAt;\n if (settings.flushInterval !== undefined)\n options.flushInterval = settings.flushInterval;\n if (settings.personalApiKey) options.personalApiKey = settings.personalApiKey;\n if (settings.featureFlagsPollingInterval !== undefined)\n options.featureFlagsPollingInterval = settings.featureFlagsPollingInterval;\n if (settings.disableGeoip !== undefined)\n options.disableGeoip = settings.disableGeoip;\n if (settings.disableCompression !== undefined)\n options.disableCompression = settings.disableCompression;\n if (settings.requestTimeout !== undefined)\n options.requestTimeout = settings.requestTimeout;\n if (settings.fetchRetryCount !== undefined)\n options.fetchRetryCount = settings.fetchRetryCount;\n if (settings.fetchRetryDelay !== undefined)\n options.fetchRetryDelay = settings.fetchRetryDelay;\n if (settings.debug !== undefined) options.debug = settings.debug;\n if (settings.disabled !== undefined) options.disabled = settings.disabled;\n\n // Use PostHog from env if available, otherwise use real PostHog\n const PostHogClass = env?.PostHog || PostHog;\n const client = new PostHogClass(apiKey, options);\n\n const settingsConfig: Settings = {\n ...settings,\n apiKey,\n client,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { PushFn } from './types';\nimport { getMappingValue, isObject, isString } from '@walkeros/core';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector },\n) {\n const settings = config.settings!;\n const client = settings.client;\n if (!client) return;\n\n const mappingSettings = (rule?.settings || {}) as Record<string, unknown>;\n\n // Resolve distinctId: rule-level identify wins over destination-level\n const identifyMapping = mappingSettings.identify ?? settings.identify;\n let distinctId: string | undefined;\n let identifyResolved: Record<string, unknown> | undefined;\n\n if (identifyMapping !== undefined) {\n const resolved = await getMappingValue(event, identifyMapping, {\n collector,\n });\n if (isObject(resolved)) {\n identifyResolved = resolved as Record<string, unknown>;\n if (isString(identifyResolved.distinctId)) {\n distinctId = identifyResolved.distinctId as string;\n }\n }\n }\n\n // Fallback distinctId from event.user\n if (!distinctId) {\n distinctId =\n (isString(event.user?.id) ? event.user.id : undefined) ||\n (isString(event.user?.hash) ? event.user.hash : undefined) ||\n (isString(event.user?.session) ? event.user.session : undefined) ||\n 'anonymous';\n }\n\n // 1. Identity - if $set or $set_once present, call client.identify()\n if (identifyResolved) {\n const $set = isObject(identifyResolved.$set)\n ? (identifyResolved.$set as Record<string, unknown>)\n : undefined;\n const $setOnce = isObject(identifyResolved.$set_once)\n ? (identifyResolved.$set_once as Record<string, unknown>)\n : undefined;\n\n if ($set || $setOnce) {\n const properties: Record<string, unknown> = {};\n if ($set) properties.$set = $set;\n if ($setOnce) properties.$set_once = $setOnce;\n client.identify({ distinctId, properties });\n }\n }\n\n // 2. Group - resolve group mapping (rule-level wins)\n const groupMapping = mappingSettings.group ?? settings.group;\n let groups: Record<string, string | number> | undefined;\n\n if (groupMapping !== undefined) {\n const resolved = await getMappingValue(event, groupMapping, {\n collector,\n });\n if (isObject(resolved)) {\n const groupResolved = resolved as Record<string, unknown>;\n const type = groupResolved.type;\n const key = groupResolved.key;\n const properties = isObject(groupResolved.properties)\n ? (groupResolved.properties as Record<string, unknown>)\n : undefined;\n\n if (isString(type) && (isString(key) || typeof key === 'number')) {\n // If properties present, call groupIdentify\n if (properties) {\n client.groupIdentify({\n groupType: type,\n groupKey: String(key),\n properties,\n });\n }\n // Build groups object for capture\n groups = { [type]: key as string | number };\n }\n }\n }\n\n // 3. Capture - unless rule opts out via silent\n if (rule?.silent !== true) {\n const eventName = isString(rule?.name) ? rule.name : event.name;\n const properties = isObject(data) ? (data as Record<string, unknown>) : {};\n\n const captureArgs: Record<string, unknown> = {\n distinctId,\n event: eventName,\n properties,\n };\n if (groups) captureArgs.groups = groups;\n\n client.capture(captureArgs as Parameters<typeof client.capture>[0]);\n }\n};\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer } from '@walkeros/server-core';\nimport type { PostHog } from 'posthog-node';\n\nexport interface Settings {\n /** PostHog project API key (phc_...) */\n apiKey: string;\n /** PostHog client instance, populated by init */\n client?: PostHog;\n /** Destination-level identity mapping */\n identify?: WalkerOSMapping.Value;\n /** Destination-level group mapping */\n group?: WalkerOSMapping.Value;\n /** Event sections to flatten into capture properties */\n include?: string[];\n // PostHog SDK passthrough options\n host?: string;\n flushAt?: number;\n flushInterval?: number;\n personalApiKey?: string;\n featureFlagsPollingInterval?: number;\n disableGeoip?: boolean;\n disableCompression?: boolean;\n requestTimeout?: number;\n fetchRetryCount?: number;\n fetchRetryDelay?: number;\n debug?: boolean;\n disabled?: boolean;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n identify?: WalkerOSMapping.Value;\n group?: WalkerOSMapping.Value;\n}\n\nexport interface Env extends DestinationServer.Env {\n PostHog?: typeof PostHog;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,0BAAwB;AAEjB,SAAS,UACd,gBAA+B,CAAC,GAChC,KACA,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,OAAO,IAAI;AAEnB,MAAI,CAAC,OAAQ,QAAO,MAAM,gCAAgC;AAG1D,QAAM,UAAmC,CAAC;AAC1C,MAAI,SAAS,KAAM,SAAQ,OAAO,SAAS;AAC3C,MAAI,SAAS,YAAY,OAAW,SAAQ,UAAU,SAAS;AAC/D,MAAI,SAAS,kBAAkB;AAC7B,YAAQ,gBAAgB,SAAS;AACnC,MAAI,SAAS,eAAgB,SAAQ,iBAAiB,SAAS;AAC/D,MAAI,SAAS,gCAAgC;AAC3C,YAAQ,8BAA8B,SAAS;AACjD,MAAI,SAAS,iBAAiB;AAC5B,YAAQ,eAAe,SAAS;AAClC,MAAI,SAAS,uBAAuB;AAClC,YAAQ,qBAAqB,SAAS;AACxC,MAAI,SAAS,mBAAmB;AAC9B,YAAQ,iBAAiB,SAAS;AACpC,MAAI,SAAS,oBAAoB;AAC/B,YAAQ,kBAAkB,SAAS;AACrC,MAAI,SAAS,oBAAoB;AAC/B,YAAQ,kBAAkB,SAAS;AACrC,MAAI,SAAS,UAAU,OAAW,SAAQ,QAAQ,SAAS;AAC3D,MAAI,SAAS,aAAa,OAAW,SAAQ,WA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G;AACxB,UAAM,SAAU,QAAQ,UAAmC;AAC3D,QAAI,QAAQ;AACV,YAAM,OAAO,SAAS;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,GAAG,MAAM,SAAS;AAChB,QAAI,SAAS,aAAa,CAAC,SAAS,KAAM;AAE1C,UAAM,WAAY,QAAQ,QAAQ,YAAY,CAAC;AAC/C,UAAM,SAAS,SAAS;AACxB,QAAI,CAAC,OAAQ;AAEb,UAAM,UAAU,QAAQ;AACxB,UAAM,WAAY,QAAQ,QACtB;AACJ,QAAI,CAAC,YAAY,OAAO,KAAK,QAAQ,EAAE,WAAW,EAAG;AAErD,UAAM,aAAa,OAAO,KAAK,QAAQ,EAAE;AAAA,MACvC,CAAC,QAAQ,QAAQ,GAAG,MAAM;AAAA,IAC5B;AACA,QAAI,YAAY;AACd,aAAO,OAAO;AAAA,IAChB,OAAO;AACL,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PostHog}from"posthog-node";import{getMappingValue,isObject,isString}from"@walkeros/core";var types_exports={},destinationPostHog={type:"posthog",config:{},async init({config:partialConfig,env:env,logger:logger}){const config=function(partialConfig={},env,logger){const settings=partialConfig.settings||{},{apiKey:apiKey}=settings;apiKey||logger.throw("Config settings apiKey missing");const options={};settings.host&&(options.host=settings.host),void 0!==settings.flushAt&&(options.flushAt=settings.flushAt),void 0!==settings.flushInterval&&(options.flushInterval=settings.flushInterval),settings.personalApiKey&&(options.personalApiKey=settings.personalApiKey),void 0!==settings.featureFlagsPollingInterval&&(options.featureFlagsPollingInterval=settings.featureFlagsPollingInterval),void 0!==settings.disableGeoip&&(options.disableGeoip=settings.disableGeoip),void 0!==settings.disableCompression&&(options.disableCompression=settings.disableCompression),void 0!==settings.requestTimeout&&(options.requestTimeout=settings.requestTimeout),void 0!==settings.fetchRetryCount&&(options.fetchRetryCount=settings.fetchRetryCount),void 0!==settings.fetchRetryDelay&&(options.fetchRetryDelay=settings.fetchRetryDelay),void 0!==settings.debug&&(options.debug=settings.debug),void 0!==settings.disabled&&(options.disabled=settings.disabled);const client=new(
|
|
1
|
+
import{PostHog}from"posthog-node";import{getMappingValue,isObject,isString}from"@walkeros/core";var types_exports={},destinationPostHog={type:"posthog",config:{},async init({config:partialConfig,env:env,logger:logger}){const config=function(partialConfig={},env,logger){const settings=partialConfig.settings||{},{apiKey:apiKey}=settings;apiKey||logger.throw("Config settings apiKey missing");const options={};settings.host&&(options.host=settings.host),void 0!==settings.flushAt&&(options.flushAt=settings.flushAt),void 0!==settings.flushInterval&&(options.flushInterval=settings.flushInterval),settings.personalApiKey&&(options.personalApiKey=settings.personalApiKey),void 0!==settings.featureFlagsPollingInterval&&(options.featureFlagsPollingInterval=settings.featureFlagsPollingInterval),void 0!==settings.disableGeoip&&(options.disableGeoip=settings.disableGeoip),void 0!==settings.disableCompression&&(options.disableCompression=settings.disableCompression),void 0!==settings.requestTimeout&&(options.requestTimeout=settings.requestTimeout),void 0!==settings.fetchRetryCount&&(options.fetchRetryCount=settings.fetchRetryCount),void 0!==settings.fetchRetryDelay&&(options.fetchRetryDelay=settings.fetchRetryDelay),void 0!==settings.debug&&(options.debug=settings.debug),void 0!==settings.disabled&&(options.disabled=settings.disabled);const client=new(env?.PostHog||PostHog)(apiKey,options),settingsConfig={...settings,apiKey:apiKey,client:client};return{...partialConfig,settings:settingsConfig}}(partialConfig,env,logger);return config},push:async(event,context)=>await async function(event,{config:config,rule:rule,data:data,collector:collector}){const settings=config.settings,client=settings.client;if(!client)return;const mappingSettings=rule?.settings||{},identifyMapping=mappingSettings.identify??settings.identify;let distinctId,identifyResolved;if(void 0!==identifyMapping){const resolved=await getMappingValue(event,identifyMapping,{collector:collector});isObject(resolved)&&(identifyResolved=resolved,isString(identifyResolved.distinctId)&&(distinctId=identifyResolved.distinctId))}if(distinctId||(distinctId=(isString(event.user?.id)?event.user.id:void 0)||(isString(event.user?.hash)?event.user.hash:void 0)||(isString(event.user?.session)?event.user.session:void 0)||"anonymous"),identifyResolved){const $set=isObject(identifyResolved.$set)?identifyResolved.$set:void 0,$setOnce=isObject(identifyResolved.$set_once)?identifyResolved.$set_once:void 0;if($set||$setOnce){const properties={};$set&&(properties.$set=$set),$setOnce&&(properties.$set_once=$setOnce),client.identify({distinctId:distinctId,properties:properties})}}const groupMapping=mappingSettings.group??settings.group;let groups;if(void 0!==groupMapping){const resolved=await getMappingValue(event,groupMapping,{collector:collector});if(isObject(resolved)){const groupResolved=resolved,type=groupResolved.type,key=groupResolved.key,properties=isObject(groupResolved.properties)?groupResolved.properties:void 0;isString(type)&&(isString(key)||"number"==typeof key)&&(properties&&client.groupIdentify({groupType:type,groupKey:String(key),properties:properties}),groups={[type]:key})}}if(!0!==rule?.silent){const captureArgs={distinctId:distinctId,event:isString(rule?.name)?rule.name:event.name,properties:isObject(data)?data:{}};groups&&(captureArgs.groups=groups),client.capture(captureArgs)}}(event,context),async destroy({config:config}){const client=config?.settings?.client;client&&await client.shutdown()},on(type,context){if("consent"!==type||!context?.data)return;const client=(context.config?.settings||{}).client;if(!client)return;const consent=context.data,required=context.config?.consent;if(!required||0===Object.keys(required).length)return;Object.keys(required).every(key=>!0===consent[key])?client.enable():client.disable()}},index_default=destinationPostHog;export{types_exports as DestinationPostHog,index_default as default,destinationPostHog};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config.ts","../src/push.ts","../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type { Config, Env, PartialConfig, Settings } from './types';\nimport type { Logger } from '@walkeros/core';\nimport { PostHog } from 'posthog-node';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n env: Env | undefined,\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { apiKey } = settings;\n\n if (!apiKey) logger.throw('Config settings apiKey missing');\n\n // Extract PostHog SDK options from settings\n const options: Record<string, unknown> = {};\n if (settings.host) options.host = settings.host;\n if (settings.flushAt !== undefined) options.flushAt = settings.flushAt;\n if (settings.flushInterval !== undefined)\n options.flushInterval = settings.flushInterval;\n if (settings.personalApiKey) options.personalApiKey = settings.personalApiKey;\n if (settings.featureFlagsPollingInterval !== undefined)\n options.featureFlagsPollingInterval = settings.featureFlagsPollingInterval;\n if (settings.disableGeoip !== undefined)\n options.disableGeoip = settings.disableGeoip;\n if (settings.disableCompression !== undefined)\n options.disableCompression = settings.disableCompression;\n if (settings.requestTimeout !== undefined)\n options.requestTimeout = settings.requestTimeout;\n if (settings.fetchRetryCount !== undefined)\n options.fetchRetryCount = settings.fetchRetryCount;\n if (settings.fetchRetryDelay !== undefined)\n options.fetchRetryDelay = settings.fetchRetryDelay;\n if (settings.debug !== undefined) options.debug = settings.debug;\n if (settings.disabled !== undefined) options.disabled = settings.disabled;\n\n // Use PostHog from env if available, otherwise use real PostHog\n const PostHogClass = env?.PostHog || PostHog;\n const client = new PostHogClass(apiKey, options);\n\n const settingsConfig: Settings = {\n ...settings,\n apiKey,\n client,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { PushFn } from './types';\nimport { getMappingValue, isObject, isString } from '@walkeros/core';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector },\n) {\n const settings = config.settings!;\n const client = settings.client;\n if (!client) return;\n\n const mappingSettings = (rule?.settings || {}) as Record<string, unknown>;\n\n // Resolve distinctId: rule-level identify wins over destination-level\n const identifyMapping = mappingSettings.identify ?? settings.identify;\n let distinctId: string | undefined;\n let identifyResolved: Record<string, unknown> | undefined;\n\n if (identifyMapping !== undefined) {\n const resolved = await getMappingValue(event, identifyMapping, {\n collector,\n });\n if (isObject(resolved)) {\n identifyResolved = resolved as Record<string, unknown>;\n if (isString(identifyResolved.distinctId)) {\n distinctId = identifyResolved.distinctId as string;\n }\n }\n }\n\n // Fallback distinctId from event.user\n if (!distinctId) {\n distinctId =\n (isString(event.user?.id) ? event.user.id : undefined) ||\n (isString(event.user?.hash) ? event.user.hash : undefined) ||\n (isString(event.user?.session) ? event.user.session : undefined) ||\n 'anonymous';\n }\n\n // 1. Identity — if $set or $set_once present, call client.identify()\n if (identifyResolved) {\n const $set = isObject(identifyResolved.$set)\n ? (identifyResolved.$set as Record<string, unknown>)\n : undefined;\n const $setOnce = isObject(identifyResolved.$set_once)\n ? (identifyResolved.$set_once as Record<string, unknown>)\n : undefined;\n\n if ($set || $setOnce) {\n const properties: Record<string, unknown> = {};\n if ($set) properties.$set = $set;\n if ($setOnce) properties.$set_once = $setOnce;\n client.identify({ distinctId, properties });\n }\n }\n\n // 2. Group — resolve group mapping (rule-level wins)\n const groupMapping = mappingSettings.group ?? settings.group;\n let groups: Record<string, string | number> | undefined;\n\n if (groupMapping !== undefined) {\n const resolved = await getMappingValue(event, groupMapping, {\n collector,\n });\n if (isObject(resolved)) {\n const groupResolved = resolved as Record<string, unknown>;\n const type = groupResolved.type;\n const key = groupResolved.key;\n const properties = isObject(groupResolved.properties)\n ? (groupResolved.properties as Record<string, unknown>)\n : undefined;\n\n if (isString(type) && (isString(key) || typeof key === 'number')) {\n // If properties present, call groupIdentify\n if (properties) {\n client.groupIdentify({\n groupType: type,\n groupKey: String(key),\n properties,\n });\n }\n // Build groups object for capture\n groups = { [type]: key as string | number };\n }\n }\n }\n\n // 3. Capture — unless rule opts out via skip\n if (rule?.skip !== true) {\n const eventName = isString(rule?.name) ? rule.name : event.name;\n const properties = isObject(data) ? (data as Record<string, unknown>) : {};\n\n const captureArgs: Record<string, unknown> = {\n distinctId,\n event: eventName,\n properties,\n };\n if (groups) captureArgs.groups = groups;\n\n client.capture(captureArgs as Parameters<typeof client.capture>[0]);\n }\n};\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer } from '@walkeros/server-core';\nimport type { PostHog } from 'posthog-node';\n\nexport interface Settings {\n /** PostHog project API key (phc_...) */\n apiKey: string;\n /** PostHog client instance, populated by init */\n client?: PostHog;\n /** Destination-level identity mapping */\n identify?: WalkerOSMapping.Value;\n /** Destination-level group mapping */\n group?: WalkerOSMapping.Value;\n /** Event sections to flatten into capture properties */\n include?: string[];\n // PostHog SDK passthrough options\n host?: string;\n flushAt?: number;\n flushInterval?: number;\n personalApiKey?: string;\n featureFlagsPollingInterval?: number;\n disableGeoip?: boolean;\n disableCompression?: boolean;\n requestTimeout?: number;\n fetchRetryCount?: number;\n fetchRetryDelay?: number;\n debug?: boolean;\n disabled?: boolean;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n identify?: WalkerOSMapping.Value;\n group?: WalkerOSMapping.Value;\n}\n\nexport interface Env extends DestinationServer.Env {\n PostHog?: typeof PostHog;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n","import type { WalkerOS } from '@walkeros/core';\nimport type { Destination, Env, Settings } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationPostHog from './types';\n\nexport const destinationPostHog: Destination = {\n type: 'posthog',\n\n config: {},\n\n async init({ config: partialConfig, env, logger }) {\n const config = getConfig(partialConfig, env as Env | undefined, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n\n async destroy({ config }) {\n const client = (config?.settings as Settings | undefined)?.client;\n if (client) {\n await client.shutdown();\n }\n },\n\n on(type, context) {\n if (type !== 'consent' || !context?.data) return;\n\n const settings = (context.config?.settings || {}) as Settings;\n const client = settings.client;\n if (!client) return;\n\n const consent = context.data as WalkerOS.Consent;\n const required = (context.config as { consent?: WalkerOS.Consent })\n ?.consent;\n if (!required || Object.keys(required).length === 0) return;\n\n const allGranted = Object.keys(required).every(\n (key) => consent[key] === true,\n );\n if (allGranted) {\n client.enable();\n } else {\n client.disable();\n }\n },\n};\n\nexport default destinationPostHog;\n"],"mappings":";AAEA,SAAS,eAAe;AAEjB,SAAS,UACd,gBAA+B,CAAC,GAChC,KACA,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,OAAO,IAAI;AAEnB,MAAI,CAAC,OAAQ,QAAO,MAAM,gCAAgC;AAG1D,QAAM,UAAmC,CAAC;AAC1C,MAAI,SAAS,KAAM,SAAQ,OAAO,SAAS;AAC3C,MAAI,SAAS,YAAY,OAAW,SAAQ,UAAU,SAAS;AAC/D,MAAI,SAAS,kBAAkB;AAC7B,YAAQ,gBAAgB,SAAS;AACnC,MAAI,SAAS,eAAgB,SAAQ,iBAAiB,SAAS;AAC/D,MAAI,SAAS,gCAAgC;AAC3C,YAAQ,8BAA8B,SAAS;AACjD,MAAI,SAAS,iBAAiB;AAC5B,YAAQ,eAAe,SAAS;AAClC,MAAI,SAAS,uBAAuB;AAClC,YAAQ,qBAAqB,SAAS;AACxC,MAAI,SAAS,mBAAmB;AAC9B,YAAQ,iBAAiB,SAAS;AACpC,MAAI,SAAS,oBAAoB;AAC/B,YAAQ,kBAAkB,SAAS;AACrC,MAAI,SAAS,oBAAoB;AAC/B,YAAQ,kBAAkB,SAAS;AACrC,MAAI,SAAS,UAAU,OAAW,SAAQ,QAAQ,SAAS;AAC3D,MAAI,SAAS,aAAa,OAAW,SAAQ,WAAW,SAAS;AAGjE,QAAM,gBAAe,2BAAK,YAAW;AACrC,QAAM,SAAS,IAAI,aAAa,QAAQ,OAAO;AAE/C,QAAM,iBAA2B;AAAA,IAC/B,GAAG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V,YAAM,OAAO,SAAS;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,GAAG,MAAM,SAAS;AA7BpB;AA8BI,QAAI,SAAS,aAAa,EAAC,mCAAS,MAAM;AAE1C,UAAM,aAAY,aAAQ,WAAR,mBAAgB,aAAY,CAAC;AAC/C,UAAM,SAAS,SAAS;AACxB,QAAI,CAAC,OAAQ;AAEb,UAAM,UAAU,QAAQ;AACxB,UAAM,YAAY,aAAQ,WAAR,mBACd;AACJ,QAAI,CAAC,YAAY,OAAO,KAAK,QAAQ,EAAE,WAAW,EAAG;AAErD,UAAM,aAAa,OAAO,KAAK,QAAQ,EAAE;AAAA,MACvC,CAAC,QAAQ,QAAQ,GAAG,MAAM;AAAA,IAC5B;AACA,QAAI,YAAY;AACd,aAAO,OAAO;AAAA,IAChB,OAAO;AACL,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/config.ts","../src/push.ts","../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type { Config, Env, PartialConfig, Settings } from './types';\nimport type { Logger } from '@walkeros/core';\nimport { PostHog } from 'posthog-node';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n env: Env | undefined,\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { apiKey } = settings;\n\n if (!apiKey) logger.throw('Config settings apiKey missing');\n\n // Extract PostHog SDK options from settings\n const options: Record<string, unknown> = {};\n if (settings.host) options.host = settings.host;\n if (settings.flushAt !== undefined) options.flushAt = settings.flushAt;\n if (settings.flushInterval !== undefined)\n options.flushInterval = settings.flushInterval;\n if (settings.personalApiKey) options.personalApiKey = settings.personalApiKey;\n if (settings.featureFlagsPollingInterval !== undefined)\n options.featureFlagsPollingInterval = settings.featureFlagsPollingInterval;\n if (settings.disableGeoip !== undefined)\n options.disableGeoip = settings.disableGeoip;\n if (settings.disableCompression !== undefined)\n options.disableCompression = settings.disableCompression;\n if (settings.requestTimeout !== undefined)\n options.requestTimeout = settings.requestTimeout;\n if (settings.fetchRetryCount !== undefined)\n options.fetchRetryCount = settings.fetchRetryCount;\n if (settings.fetchRetryDelay !== undefined)\n options.fetchRetryDelay = settings.fetchRetryDelay;\n if (settings.debug !== undefined) options.debug = settings.debug;\n if (settings.disabled !== undefined) options.disabled = settings.disabled;\n\n // Use PostHog from env if available, otherwise use real PostHog\n const PostHogClass = env?.PostHog || PostHog;\n const client = new PostHogClass(apiKey, options);\n\n const settingsConfig: Settings = {\n ...settings,\n apiKey,\n client,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { PushFn } from './types';\nimport { getMappingValue, isObject, isString } from '@walkeros/core';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector },\n) {\n const settings = config.settings!;\n const client = settings.client;\n if (!client) return;\n\n const mappingSettings = (rule?.settings || {}) as Record<string, unknown>;\n\n // Resolve distinctId: rule-level identify wins over destination-level\n const identifyMapping = mappingSettings.identify ?? settings.identify;\n let distinctId: string | undefined;\n let identifyResolved: Record<string, unknown> | undefined;\n\n if (identifyMapping !== undefined) {\n const resolved = await getMappingValue(event, identifyMapping, {\n collector,\n });\n if (isObject(resolved)) {\n identifyResolved = resolved as Record<string, unknown>;\n if (isString(identifyResolved.distinctId)) {\n distinctId = identifyResolved.distinctId as string;\n }\n }\n }\n\n // Fallback distinctId from event.user\n if (!distinctId) {\n distinctId =\n (isString(event.user?.id) ? event.user.id : undefined) ||\n (isString(event.user?.hash) ? event.user.hash : undefined) ||\n (isString(event.user?.session) ? event.user.session : undefined) ||\n 'anonymous';\n }\n\n // 1. Identity - if $set or $set_once present, call client.identify()\n if (identifyResolved) {\n const $set = isObject(identifyResolved.$set)\n ? (identifyResolved.$set as Record<string, unknown>)\n : undefined;\n const $setOnce = isObject(identifyResolved.$set_once)\n ? (identifyResolved.$set_once as Record<string, unknown>)\n : undefined;\n\n if ($set || $setOnce) {\n const properties: Record<string, unknown> = {};\n if ($set) properties.$set = $set;\n if ($setOnce) properties.$set_once = $setOnce;\n client.identify({ distinctId, properties });\n }\n }\n\n // 2. Group - resolve group mapping (rule-level wins)\n const groupMapping = mappingSettings.group ?? settings.group;\n let groups: Record<string, string | number> | undefined;\n\n if (groupMapping !== undefined) {\n const resolved = await getMappingValue(event, groupMapping, {\n collector,\n });\n if (isObject(resolved)) {\n const groupResolved = resolved as Record<string, unknown>;\n const type = groupResolved.type;\n const key = groupResolved.key;\n const properties = isObject(groupResolved.properties)\n ? (groupResolved.properties as Record<string, unknown>)\n : undefined;\n\n if (isString(type) && (isString(key) || typeof key === 'number')) {\n // If properties present, call groupIdentify\n if (properties) {\n client.groupIdentify({\n groupType: type,\n groupKey: String(key),\n properties,\n });\n }\n // Build groups object for capture\n groups = { [type]: key as string | number };\n }\n }\n }\n\n // 3. Capture - unless rule opts out via silent\n if (rule?.silent !== true) {\n const eventName = isString(rule?.name) ? rule.name : event.name;\n const properties = isObject(data) ? (data as Record<string, unknown>) : {};\n\n const captureArgs: Record<string, unknown> = {\n distinctId,\n event: eventName,\n properties,\n };\n if (groups) captureArgs.groups = groups;\n\n client.capture(captureArgs as Parameters<typeof client.capture>[0]);\n }\n};\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer } from '@walkeros/server-core';\nimport type { PostHog } from 'posthog-node';\n\nexport interface Settings {\n /** PostHog project API key (phc_...) */\n apiKey: string;\n /** PostHog client instance, populated by init */\n client?: PostHog;\n /** Destination-level identity mapping */\n identify?: WalkerOSMapping.Value;\n /** Destination-level group mapping */\n group?: WalkerOSMapping.Value;\n /** Event sections to flatten into capture properties */\n include?: string[];\n // PostHog SDK passthrough options\n host?: string;\n flushAt?: number;\n flushInterval?: number;\n personalApiKey?: string;\n featureFlagsPollingInterval?: number;\n disableGeoip?: boolean;\n disableCompression?: boolean;\n requestTimeout?: number;\n fetchRetryCount?: number;\n fetchRetryDelay?: number;\n debug?: boolean;\n disabled?: boolean;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n identify?: WalkerOSMapping.Value;\n group?: WalkerOSMapping.Value;\n}\n\nexport interface Env extends DestinationServer.Env {\n PostHog?: typeof PostHog;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n","import type { WalkerOS } from '@walkeros/core';\nimport type { Destination, Env, Settings } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationPostHog from './types';\n\nexport const destinationPostHog: Destination = {\n type: 'posthog',\n\n config: {},\n\n async init({ config: partialConfig, env, logger }) {\n const config = getConfig(partialConfig, env as Env | undefined, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n\n async destroy({ config }) {\n const client = (config?.settings as Settings | undefined)?.client;\n if (client) {\n await client.shutdown();\n }\n },\n\n on(type, context) {\n if (type !== 'consent' || !context?.data) return;\n\n const settings = (context.config?.settings || {}) as Settings;\n const client = settings.client;\n if (!client) return;\n\n const consent = context.data as WalkerOS.Consent;\n const required = (context.config as { consent?: WalkerOS.Consent })\n ?.consent;\n if (!required || Object.keys(required).length === 0) return;\n\n const allGranted = Object.keys(required).every(\n (key) => consent[key] === true,\n );\n if (allGranted) {\n client.enable();\n } else {\n client.disable();\n }\n },\n};\n\nexport default destinationPostHog;\n"],"mappings":";AAEA,SAAS,eAAe;AAEjB,SAAS,UACd,gBAA+B,CAAC,GAChC,KACA,QAC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AAM;AAAA,IAC5B;AACA,QAAI,YAAY;AACd,aAAO,OAAO;AAAA,IAChB,OAAO;AACL,aAAO,QAAQ;AAAA,IACjB;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":[]}
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/server-destination-posthog",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-next-1777463920154",
|
|
5
5
|
"type": "destination",
|
|
6
6
|
"platform": [
|
|
7
7
|
"server"
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"env": {
|
|
85
85
|
"push": {
|
|
86
86
|
"PostHog": {
|
|
87
|
-
"$code": "class{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:[]})}}"
|
|
87
|
+
"$code": "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:[]})}}"
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
"simulation": [
|
|
@@ -131,35 +131,21 @@
|
|
|
131
131
|
"entity": "child",
|
|
132
132
|
"data": {
|
|
133
133
|
"is": "subordinated"
|
|
134
|
-
},
|
|
135
|
-
"nested": [],
|
|
136
|
-
"context": {
|
|
137
|
-
"element": [
|
|
138
|
-
"child",
|
|
139
|
-
0
|
|
140
|
-
]
|
|
141
134
|
}
|
|
142
135
|
}
|
|
143
136
|
],
|
|
144
137
|
"consent": {
|
|
145
138
|
"functional": true
|
|
146
139
|
},
|
|
147
|
-
"id": "
|
|
140
|
+
"id": "ed9bf0968db6f6ef",
|
|
148
141
|
"trigger": "load",
|
|
149
142
|
"entity": "page",
|
|
150
143
|
"action": "view",
|
|
151
144
|
"timestamp": 1700000104,
|
|
152
145
|
"timing": 3.14,
|
|
153
|
-
"group": "gr0up",
|
|
154
|
-
"count": 1,
|
|
155
|
-
"version": {
|
|
156
|
-
"source": "3.4.1",
|
|
157
|
-
"tagging": 1
|
|
158
|
-
},
|
|
159
146
|
"source": {
|
|
160
|
-
"type": "
|
|
161
|
-
"
|
|
162
|
-
"previous_id": "http://remotehost:9001"
|
|
147
|
+
"type": "collector",
|
|
148
|
+
"schema": "4"
|
|
163
149
|
}
|
|
164
150
|
},
|
|
165
151
|
"settings": {
|
|
@@ -266,22 +252,15 @@
|
|
|
266
252
|
"consent": {
|
|
267
253
|
"functional": true
|
|
268
254
|
},
|
|
269
|
-
"id": "
|
|
255
|
+
"id": "3b388ebb5ae4a15a",
|
|
270
256
|
"trigger": "load",
|
|
271
257
|
"entity": "order",
|
|
272
258
|
"action": "complete",
|
|
273
259
|
"timestamp": 1700000101,
|
|
274
260
|
"timing": 3.14,
|
|
275
|
-
"group": "gr0up",
|
|
276
|
-
"count": 1,
|
|
277
|
-
"version": {
|
|
278
|
-
"source": "3.4.1",
|
|
279
|
-
"tagging": 1
|
|
280
|
-
},
|
|
281
261
|
"source": {
|
|
282
|
-
"type": "
|
|
283
|
-
"
|
|
284
|
-
"previous_id": "http://remotehost:9001"
|
|
262
|
+
"type": "collector",
|
|
263
|
+
"schema": "4"
|
|
285
264
|
}
|
|
286
265
|
},
|
|
287
266
|
"configInclude": [
|
|
@@ -367,22 +346,15 @@
|
|
|
367
346
|
"consent": {
|
|
368
347
|
"functional": true
|
|
369
348
|
},
|
|
370
|
-
"id": "
|
|
349
|
+
"id": "7d9584cd98614209",
|
|
371
350
|
"trigger": "load",
|
|
372
351
|
"entity": "product",
|
|
373
352
|
"action": "view",
|
|
374
353
|
"timestamp": 1700000100,
|
|
375
354
|
"timing": 3.14,
|
|
376
|
-
"group": "gr0up",
|
|
377
|
-
"count": 1,
|
|
378
|
-
"version": {
|
|
379
|
-
"source": "3.4.1",
|
|
380
|
-
"tagging": 1
|
|
381
|
-
},
|
|
382
355
|
"source": {
|
|
383
|
-
"type": "
|
|
384
|
-
"
|
|
385
|
-
"previous_id": "http://remotehost:9001"
|
|
356
|
+
"type": "collector",
|
|
357
|
+
"schema": "4"
|
|
386
358
|
}
|
|
387
359
|
},
|
|
388
360
|
"out": [
|
|
@@ -428,39 +400,25 @@
|
|
|
428
400
|
"entity": "child",
|
|
429
401
|
"data": {
|
|
430
402
|
"is": "subordinated"
|
|
431
|
-
},
|
|
432
|
-
"nested": [],
|
|
433
|
-
"context": {
|
|
434
|
-
"element": [
|
|
435
|
-
"child",
|
|
436
|
-
0
|
|
437
|
-
]
|
|
438
403
|
}
|
|
439
404
|
}
|
|
440
405
|
],
|
|
441
406
|
"consent": {
|
|
442
407
|
"functional": true
|
|
443
408
|
},
|
|
444
|
-
"id": "
|
|
409
|
+
"id": "72fe570d23fbecf5",
|
|
445
410
|
"trigger": "test",
|
|
446
411
|
"entity": "company",
|
|
447
412
|
"action": "update",
|
|
448
413
|
"timestamp": 1700000103,
|
|
449
414
|
"timing": 3.14,
|
|
450
|
-
"group": "gr0up",
|
|
451
|
-
"count": 1,
|
|
452
|
-
"version": {
|
|
453
|
-
"source": "3.4.1",
|
|
454
|
-
"tagging": 1
|
|
455
|
-
},
|
|
456
415
|
"source": {
|
|
457
|
-
"type": "
|
|
458
|
-
"
|
|
459
|
-
"previous_id": "http://remotehost:9001"
|
|
416
|
+
"type": "collector",
|
|
417
|
+
"schema": "4"
|
|
460
418
|
}
|
|
461
419
|
},
|
|
462
420
|
"mapping": {
|
|
463
|
-
"
|
|
421
|
+
"silent": true,
|
|
464
422
|
"settings": {
|
|
465
423
|
"group": {
|
|
466
424
|
"map": {
|
|
@@ -524,39 +482,25 @@
|
|
|
524
482
|
"entity": "child",
|
|
525
483
|
"data": {
|
|
526
484
|
"is": "subordinated"
|
|
527
|
-
},
|
|
528
|
-
"nested": [],
|
|
529
|
-
"context": {
|
|
530
|
-
"element": [
|
|
531
|
-
"child",
|
|
532
|
-
0
|
|
533
|
-
]
|
|
534
485
|
}
|
|
535
486
|
}
|
|
536
487
|
],
|
|
537
488
|
"consent": {
|
|
538
489
|
"functional": true
|
|
539
490
|
},
|
|
540
|
-
"id": "
|
|
491
|
+
"id": "5aea355077374596",
|
|
541
492
|
"trigger": "test",
|
|
542
493
|
"entity": "user",
|
|
543
494
|
"action": "login",
|
|
544
495
|
"timestamp": 1700000102,
|
|
545
496
|
"timing": 3.14,
|
|
546
|
-
"group": "gr0up",
|
|
547
|
-
"count": 1,
|
|
548
|
-
"version": {
|
|
549
|
-
"source": "3.4.1",
|
|
550
|
-
"tagging": 1
|
|
551
|
-
},
|
|
552
497
|
"source": {
|
|
553
|
-
"type": "
|
|
554
|
-
"
|
|
555
|
-
"previous_id": "http://remotehost:9001"
|
|
498
|
+
"type": "collector",
|
|
499
|
+
"schema": "4"
|
|
556
500
|
}
|
|
557
501
|
},
|
|
558
502
|
"mapping": {
|
|
559
|
-
"
|
|
503
|
+
"silent": true,
|
|
560
504
|
"settings": {
|
|
561
505
|
"identify": {
|
|
562
506
|
"map": {
|
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
|
+
"version": "4.0.0-next-1777463920154",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"update": "npx npm-check-updates -u && npm update"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@walkeros/core": "
|
|
38
|
-
"@walkeros/server-core": "
|
|
37
|
+
"@walkeros/core": "4.0.0-next-1777463920154",
|
|
38
|
+
"@walkeros/server-core": "4.0.0-next-1777463920154",
|
|
39
39
|
"posthog-node": "^5.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@walkeros/collector": "
|
|
42
|
+
"@walkeros/collector": "4.0.0-next-1777463920154"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|