@walkeros/server-destination-posthog 3.3.0-next-1776098542393
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +147 -0
- package/dist/dev.d.mts +143 -0
- package/dist/dev.d.ts +143 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/examples/index.d.mts +102 -0
- package/dist/examples/index.d.ts +102 -0
- package/dist/examples/index.js +242 -0
- package/dist/examples/index.mjs +220 -0
- package/dist/index.d.mts +70 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/dist/walkerOS.json +571 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 elbWalker GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<p align="left">
|
|
2
|
+
<a href="https://www.walkeros.io">
|
|
3
|
+
<img alt="walkerOS" title="walkerOS" src="https://www.walkeros.io/img/walkerOS_logo.svg" width="256px"/>
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# PostHog Server Destination for walkerOS
|
|
8
|
+
|
|
9
|
+
[Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/server/destinations/posthog)
|
|
10
|
+
•
|
|
11
|
+
[NPM Package](https://www.npmjs.com/package/@walkeros/server-destination-posthog)
|
|
12
|
+
|
|
13
|
+
walkerOS follows a **source -> collector -> destination** architecture. This
|
|
14
|
+
PostHog destination receives processed events from the walkerOS collector and
|
|
15
|
+
sends them server-to-server to PostHog using the `posthog-node` SDK, supporting
|
|
16
|
+
capture, identify, groupIdentify, groups on capture, consent, and graceful
|
|
17
|
+
shutdown.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install @walkeros/server-destination-posthog
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Minimal flow.json
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"destinations": {
|
|
32
|
+
"posthog": {
|
|
33
|
+
"package": "@walkeros/server-destination-posthog",
|
|
34
|
+
"config": {
|
|
35
|
+
"settings": {
|
|
36
|
+
"apiKey": "phc_..."
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Programmatic
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { startFlow } from '@walkeros/collector';
|
|
48
|
+
import { destinationPostHog } from '@walkeros/server-destination-posthog';
|
|
49
|
+
|
|
50
|
+
await startFlow({
|
|
51
|
+
destinations: {
|
|
52
|
+
posthog: {
|
|
53
|
+
code: destinationPostHog,
|
|
54
|
+
config: {
|
|
55
|
+
settings: {
|
|
56
|
+
apiKey: 'phc_...',
|
|
57
|
+
host: 'https://eu.i.posthog.com',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Settings
|
|
66
|
+
|
|
67
|
+
| Name | Type | Description | Required |
|
|
68
|
+
| ----------------------------- | ---------- | -------------------------------------------------- | -------- |
|
|
69
|
+
| `apiKey` | `string` | PostHog project API key (`phc_...`) | Yes |
|
|
70
|
+
| `host` | `string` | API endpoint (default: `https://us.i.posthog.com`) | No |
|
|
71
|
+
| `flushAt` | `number` | Events queued before auto-flush (default: 20) | No |
|
|
72
|
+
| `flushInterval` | `number` | ms between periodic flushes (default: 10000) | No |
|
|
73
|
+
| `personalApiKey` | `string` | Personal API key for local flag evaluation | No |
|
|
74
|
+
| `featureFlagsPollingInterval` | `number` | ms between flag definition polls (default: 30000) | No |
|
|
75
|
+
| `disableGeoip` | `boolean` | Disable GeoIP lookups (GDPR) | No |
|
|
76
|
+
| `debug` | `boolean` | Enable SDK debug logging | No |
|
|
77
|
+
| `identify` | `Mapping` | Destination-level identity mapping | No |
|
|
78
|
+
| `group` | `Mapping` | Destination-level group mapping | No |
|
|
79
|
+
| `include` | `string[]` | Event sections flattened into properties | No |
|
|
80
|
+
|
|
81
|
+
## Mapping Settings
|
|
82
|
+
|
|
83
|
+
Per-event mapping settings override destination-level settings.
|
|
84
|
+
|
|
85
|
+
| Name | Type | Description |
|
|
86
|
+
| ---------- | --------- | ---------------------------------------------------------------- |
|
|
87
|
+
| `identify` | `Mapping` | Resolves to `{ distinctId, $set?, $set_once? }` for `identify()` |
|
|
88
|
+
| `group` | `Mapping` | Resolves to `{ type, key, properties? }` for `groupIdentify()` |
|
|
89
|
+
|
|
90
|
+
## Identity
|
|
91
|
+
|
|
92
|
+
Every PostHog server call requires a `distinctId`. Resolution order:
|
|
93
|
+
|
|
94
|
+
1. Mapping-level `settings.identify.map.distinctId`
|
|
95
|
+
2. Destination-level `settings.identify.map.distinctId`
|
|
96
|
+
3. Fallback: `event.user.id`, `event.user.hash`, `event.user.session`, or
|
|
97
|
+
`'anonymous'`
|
|
98
|
+
|
|
99
|
+
When `$set` or `$set_once` are present in the resolved identify object,
|
|
100
|
+
`client.identify()` is called with the person properties nested under
|
|
101
|
+
`properties: { $set, $set_once }`.
|
|
102
|
+
|
|
103
|
+
## Groups
|
|
104
|
+
|
|
105
|
+
Group analytics associates events with companies, teams, or projects.
|
|
106
|
+
|
|
107
|
+
- **With properties**:
|
|
108
|
+
`client.groupIdentify({ groupType, groupKey, properties })`
|
|
109
|
+
- **Without properties**: adds `groups: { [type]: key }` to `capture()` calls
|
|
110
|
+
|
|
111
|
+
## Destroy / Shutdown
|
|
112
|
+
|
|
113
|
+
The destination implements `destroy()` calling `client.shutdown()` to flush all
|
|
114
|
+
queued events before the server flow exits. This is critical for ensuring no
|
|
115
|
+
events are lost on process shutdown.
|
|
116
|
+
|
|
117
|
+
## Self-Hosted PostHog
|
|
118
|
+
|
|
119
|
+
Set `host` to your self-hosted PostHog instance URL:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
"settings": {
|
|
123
|
+
"apiKey": "phc_...",
|
|
124
|
+
"host": "https://posthog.your-domain.com"
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Feature Flags
|
|
129
|
+
|
|
130
|
+
Pass `personalApiKey` for local feature flag evaluation. Flag evaluation is not
|
|
131
|
+
a destination concern; it is exposed via the SDK client instance.
|
|
132
|
+
|
|
133
|
+
## Web Destination
|
|
134
|
+
|
|
135
|
+
For browser-side PostHog integration, see
|
|
136
|
+
[@walkeros/web-destination-posthog](https://www.npmjs.com/package/@walkeros/web-destination-posthog).
|
|
137
|
+
|
|
138
|
+
## Contribute
|
|
139
|
+
|
|
140
|
+
Feel free to contribute by submitting an
|
|
141
|
+
[issue](https://github.com/elbwalker/walkerOS/issues), starting a
|
|
142
|
+
[discussion](https://github.com/elbwalker/walkerOS/discussions), or getting in
|
|
143
|
+
[contact](https://calendly.com/elb-alexander/30min).
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
This project is licensed under the MIT License.
|
package/dist/dev.d.mts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
|
+
import { z } from '@walkeros/core/dev';
|
|
3
|
+
import { Mapping as Mapping$1, Flow } from '@walkeros/core';
|
|
4
|
+
import { DestinationServer } from '@walkeros/server-core';
|
|
5
|
+
import { PostHog } from 'posthog-node';
|
|
6
|
+
|
|
7
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
8
|
+
apiKey: z.ZodString;
|
|
9
|
+
host: z.ZodOptional<z.ZodString>;
|
|
10
|
+
flushAt: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
flushInterval: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
personalApiKey: z.ZodOptional<z.ZodString>;
|
|
13
|
+
featureFlagsPollingInterval: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
disableGeoip: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
debug: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
17
|
+
group: z.ZodOptional<z.ZodUnknown>;
|
|
18
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
type Settings$1 = z.infer<typeof SettingsSchema>;
|
|
21
|
+
|
|
22
|
+
declare const MappingSchema: z.ZodObject<{
|
|
23
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
24
|
+
group: z.ZodOptional<z.ZodUnknown>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
type Mapping = z.infer<typeof MappingSchema>;
|
|
27
|
+
|
|
28
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
29
|
+
declare const mapping: _walkeros_core_dev.JSONSchema;
|
|
30
|
+
|
|
31
|
+
type index$1_Mapping = Mapping;
|
|
32
|
+
declare const index$1_MappingSchema: typeof MappingSchema;
|
|
33
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
34
|
+
declare const index$1_mapping: typeof mapping;
|
|
35
|
+
declare const index$1_settings: typeof settings;
|
|
36
|
+
declare namespace index$1 {
|
|
37
|
+
export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface Settings {
|
|
41
|
+
/** PostHog project API key (phc_...) */
|
|
42
|
+
apiKey: string;
|
|
43
|
+
/** PostHog client instance, populated by init */
|
|
44
|
+
client?: PostHog;
|
|
45
|
+
/** Destination-level identity mapping */
|
|
46
|
+
identify?: Mapping$1.Value;
|
|
47
|
+
/** Destination-level group mapping */
|
|
48
|
+
group?: Mapping$1.Value;
|
|
49
|
+
/** Event sections to flatten into capture properties */
|
|
50
|
+
include?: string[];
|
|
51
|
+
host?: string;
|
|
52
|
+
flushAt?: number;
|
|
53
|
+
flushInterval?: number;
|
|
54
|
+
personalApiKey?: string;
|
|
55
|
+
featureFlagsPollingInterval?: number;
|
|
56
|
+
disableGeoip?: boolean;
|
|
57
|
+
disableCompression?: boolean;
|
|
58
|
+
requestTimeout?: number;
|
|
59
|
+
fetchRetryCount?: number;
|
|
60
|
+
fetchRetryDelay?: number;
|
|
61
|
+
debug?: boolean;
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface Env extends DestinationServer.Env {
|
|
65
|
+
PostHog?: typeof PostHog;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Standard mock environment for push operations.
|
|
70
|
+
* Injects a mock PostHog class constructor via env.PostHog.
|
|
71
|
+
*/
|
|
72
|
+
declare const push: Env;
|
|
73
|
+
/** Simulation tracking paths for CLI --simulate. */
|
|
74
|
+
declare const simulation: string[];
|
|
75
|
+
|
|
76
|
+
declare const env_push: typeof push;
|
|
77
|
+
declare const env_simulation: typeof simulation;
|
|
78
|
+
declare namespace env {
|
|
79
|
+
export { env_push as push, env_simulation as simulation };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* PostHog server step examples carry destination-level settings and
|
|
84
|
+
* optional configInclude for the test runner to wire up.
|
|
85
|
+
*/
|
|
86
|
+
type PostHogStepExample = Flow.StepExample & {
|
|
87
|
+
settings?: Partial<Settings>;
|
|
88
|
+
configInclude?: string[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Default event forwarding — every walkerOS event becomes
|
|
92
|
+
* client.capture({ distinctId, event, properties }). With no mapping
|
|
93
|
+
* and no include, properties is {}. distinctId falls back to event.user.id.
|
|
94
|
+
*/
|
|
95
|
+
declare const defaultCapture: PostHogStepExample;
|
|
96
|
+
/**
|
|
97
|
+
* Capture with include — destination-level include flattens data and
|
|
98
|
+
* globals sections into prefixed properties.
|
|
99
|
+
*/
|
|
100
|
+
declare const captureWithInclude: PostHogStepExample;
|
|
101
|
+
/**
|
|
102
|
+
* Identify with $set and $set_once — per-event mapping fires
|
|
103
|
+
* client.identify() with person properties. skip: true suppresses capture.
|
|
104
|
+
*/
|
|
105
|
+
declare const identifyWithSetAndSetOnce: PostHogStepExample;
|
|
106
|
+
/**
|
|
107
|
+
* Group identify with properties — per-event mapping fires
|
|
108
|
+
* client.groupIdentify() with group properties. skip: true suppresses capture.
|
|
109
|
+
*/
|
|
110
|
+
declare const groupIdentifyWithProperties: PostHogStepExample;
|
|
111
|
+
/**
|
|
112
|
+
* Capture with group context — destination-level settings.group resolves
|
|
113
|
+
* type + key (no properties). The capture call includes groups.
|
|
114
|
+
*/
|
|
115
|
+
declare const captureWithGroupContext: PostHogStepExample;
|
|
116
|
+
/**
|
|
117
|
+
* Consent revoked — client.disable() is called.
|
|
118
|
+
*/
|
|
119
|
+
declare const consentRevoke: PostHogStepExample;
|
|
120
|
+
/**
|
|
121
|
+
* Consent granted — client.enable() is called.
|
|
122
|
+
*/
|
|
123
|
+
declare const consentGrant: PostHogStepExample;
|
|
124
|
+
|
|
125
|
+
type step_PostHogStepExample = PostHogStepExample;
|
|
126
|
+
declare const step_captureWithGroupContext: typeof captureWithGroupContext;
|
|
127
|
+
declare const step_captureWithInclude: typeof captureWithInclude;
|
|
128
|
+
declare const step_consentGrant: typeof consentGrant;
|
|
129
|
+
declare const step_consentRevoke: typeof consentRevoke;
|
|
130
|
+
declare const step_defaultCapture: typeof defaultCapture;
|
|
131
|
+
declare const step_groupIdentifyWithProperties: typeof groupIdentifyWithProperties;
|
|
132
|
+
declare const step_identifyWithSetAndSetOnce: typeof identifyWithSetAndSetOnce;
|
|
133
|
+
declare namespace step {
|
|
134
|
+
export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
declare const index_env: typeof env;
|
|
138
|
+
declare const index_step: typeof step;
|
|
139
|
+
declare namespace index {
|
|
140
|
+
export { index_env as env, index_step as step };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { index as examples, index$1 as schemas };
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
|
+
import { z } from '@walkeros/core/dev';
|
|
3
|
+
import { Mapping as Mapping$1, Flow } from '@walkeros/core';
|
|
4
|
+
import { DestinationServer } from '@walkeros/server-core';
|
|
5
|
+
import { PostHog } from 'posthog-node';
|
|
6
|
+
|
|
7
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
8
|
+
apiKey: z.ZodString;
|
|
9
|
+
host: z.ZodOptional<z.ZodString>;
|
|
10
|
+
flushAt: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
flushInterval: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
personalApiKey: z.ZodOptional<z.ZodString>;
|
|
13
|
+
featureFlagsPollingInterval: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
disableGeoip: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
debug: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
17
|
+
group: z.ZodOptional<z.ZodUnknown>;
|
|
18
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
type Settings$1 = z.infer<typeof SettingsSchema>;
|
|
21
|
+
|
|
22
|
+
declare const MappingSchema: z.ZodObject<{
|
|
23
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
24
|
+
group: z.ZodOptional<z.ZodUnknown>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
type Mapping = z.infer<typeof MappingSchema>;
|
|
27
|
+
|
|
28
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
29
|
+
declare const mapping: _walkeros_core_dev.JSONSchema;
|
|
30
|
+
|
|
31
|
+
type index$1_Mapping = Mapping;
|
|
32
|
+
declare const index$1_MappingSchema: typeof MappingSchema;
|
|
33
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
34
|
+
declare const index$1_mapping: typeof mapping;
|
|
35
|
+
declare const index$1_settings: typeof settings;
|
|
36
|
+
declare namespace index$1 {
|
|
37
|
+
export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface Settings {
|
|
41
|
+
/** PostHog project API key (phc_...) */
|
|
42
|
+
apiKey: string;
|
|
43
|
+
/** PostHog client instance, populated by init */
|
|
44
|
+
client?: PostHog;
|
|
45
|
+
/** Destination-level identity mapping */
|
|
46
|
+
identify?: Mapping$1.Value;
|
|
47
|
+
/** Destination-level group mapping */
|
|
48
|
+
group?: Mapping$1.Value;
|
|
49
|
+
/** Event sections to flatten into capture properties */
|
|
50
|
+
include?: string[];
|
|
51
|
+
host?: string;
|
|
52
|
+
flushAt?: number;
|
|
53
|
+
flushInterval?: number;
|
|
54
|
+
personalApiKey?: string;
|
|
55
|
+
featureFlagsPollingInterval?: number;
|
|
56
|
+
disableGeoip?: boolean;
|
|
57
|
+
disableCompression?: boolean;
|
|
58
|
+
requestTimeout?: number;
|
|
59
|
+
fetchRetryCount?: number;
|
|
60
|
+
fetchRetryDelay?: number;
|
|
61
|
+
debug?: boolean;
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface Env extends DestinationServer.Env {
|
|
65
|
+
PostHog?: typeof PostHog;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Standard mock environment for push operations.
|
|
70
|
+
* Injects a mock PostHog class constructor via env.PostHog.
|
|
71
|
+
*/
|
|
72
|
+
declare const push: Env;
|
|
73
|
+
/** Simulation tracking paths for CLI --simulate. */
|
|
74
|
+
declare const simulation: string[];
|
|
75
|
+
|
|
76
|
+
declare const env_push: typeof push;
|
|
77
|
+
declare const env_simulation: typeof simulation;
|
|
78
|
+
declare namespace env {
|
|
79
|
+
export { env_push as push, env_simulation as simulation };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* PostHog server step examples carry destination-level settings and
|
|
84
|
+
* optional configInclude for the test runner to wire up.
|
|
85
|
+
*/
|
|
86
|
+
type PostHogStepExample = Flow.StepExample & {
|
|
87
|
+
settings?: Partial<Settings>;
|
|
88
|
+
configInclude?: string[];
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Default event forwarding — every walkerOS event becomes
|
|
92
|
+
* client.capture({ distinctId, event, properties }). With no mapping
|
|
93
|
+
* and no include, properties is {}. distinctId falls back to event.user.id.
|
|
94
|
+
*/
|
|
95
|
+
declare const defaultCapture: PostHogStepExample;
|
|
96
|
+
/**
|
|
97
|
+
* Capture with include — destination-level include flattens data and
|
|
98
|
+
* globals sections into prefixed properties.
|
|
99
|
+
*/
|
|
100
|
+
declare const captureWithInclude: PostHogStepExample;
|
|
101
|
+
/**
|
|
102
|
+
* Identify with $set and $set_once — per-event mapping fires
|
|
103
|
+
* client.identify() with person properties. skip: true suppresses capture.
|
|
104
|
+
*/
|
|
105
|
+
declare const identifyWithSetAndSetOnce: PostHogStepExample;
|
|
106
|
+
/**
|
|
107
|
+
* Group identify with properties — per-event mapping fires
|
|
108
|
+
* client.groupIdentify() with group properties. skip: true suppresses capture.
|
|
109
|
+
*/
|
|
110
|
+
declare const groupIdentifyWithProperties: PostHogStepExample;
|
|
111
|
+
/**
|
|
112
|
+
* Capture with group context — destination-level settings.group resolves
|
|
113
|
+
* type + key (no properties). The capture call includes groups.
|
|
114
|
+
*/
|
|
115
|
+
declare const captureWithGroupContext: PostHogStepExample;
|
|
116
|
+
/**
|
|
117
|
+
* Consent revoked — client.disable() is called.
|
|
118
|
+
*/
|
|
119
|
+
declare const consentRevoke: PostHogStepExample;
|
|
120
|
+
/**
|
|
121
|
+
* Consent granted — client.enable() is called.
|
|
122
|
+
*/
|
|
123
|
+
declare const consentGrant: PostHogStepExample;
|
|
124
|
+
|
|
125
|
+
type step_PostHogStepExample = PostHogStepExample;
|
|
126
|
+
declare const step_captureWithGroupContext: typeof captureWithGroupContext;
|
|
127
|
+
declare const step_captureWithInclude: typeof captureWithInclude;
|
|
128
|
+
declare const step_consentGrant: typeof consentGrant;
|
|
129
|
+
declare const step_consentRevoke: typeof consentRevoke;
|
|
130
|
+
declare const step_defaultCapture: typeof defaultCapture;
|
|
131
|
+
declare const step_groupIdentifyWithProperties: typeof groupIdentifyWithProperties;
|
|
132
|
+
declare const step_identifyWithSetAndSetOnce: typeof identifyWithSetAndSetOnce;
|
|
133
|
+
declare namespace step {
|
|
134
|
+
export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
declare const index_env: typeof env;
|
|
138
|
+
declare const index_step: typeof step;
|
|
139
|
+
declare namespace index {
|
|
140
|
+
export { index_env as env, index_step as step };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { index as examples, index$1 as schemas };
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,i=(e,o)=>{for(var s in o)t(e,s,{get:o[s],enumerable:!0})},n={};i(n,{examples:()=>y,schemas:()=>r}),module.exports=(e=n,((e,i,n,r)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let p of s(i))a.call(e,p)||p===n||t(e,p,{get:()=>i[p],enumerable:!(r=o(i,p))||r.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r={};i(r,{MappingSchema:()=>d,SettingsSchema:()=>c,mapping:()=>g,settings:()=>m});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()}),u=require("@walkeros/core/dev"),d=u.z.object({identify:u.z.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:u.z.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),m=(0,p.zodToSchema)(c),g=(0,p.zodToSchema)(d),y={};i(y,{env:()=>h,step:()=>v});var h={};i(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={};i(v,{captureWithGroupContext:()=>z,captureWithInclude:()=>I,consentGrant:()=>O,consentRevoke:()=>j,defaultCapture:()=>w,groupIdentifyWithProperties:()=>P,identifyWithSetAndSetOnce:()=>k});var _=require("@walkeros/core"),w={in:(0,_.getEvent)("product view",{timestamp:1700000100}),out:["client.capture",{distinctId:"us3r",event:"product view",properties:{}}]},I={in:(0,_.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={in:(0,_.getEvent)("user login",{timestamp:1700000102,data:{user_id:"new-user-123",email:"user@acme.com",plan:"premium"}}),mapping:{skip:!0,settings:{identify:{map:{distinctId:"data.user_id",$set:{map:{email:"data.email",plan:"data.plan"}},$set_once:{map:{first_login:"timestamp"}}}}}},out:["client.identify",{distinctId:"new-user-123",properties:{$set:{email:"user@acme.com",plan:"premium"},$set_once:{first_login:1700000102}}}]},P={in:(0,_.getEvent)("company update",{timestamp:1700000103,data:{company_id:"company_123",company_name:"Acme",plan:"enterprise"}}),mapping:{skip:!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={in:(0,_.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"}}]},j={command:"consent",in:{analytics:!1},settings:{},out:["client.disable"]},O={command:"consent",in:{analytics:!0},settings:{},out:["client.enable"]};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +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 */\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 in: getEvent('product view', { timestamp: 1700000100 }),\n out: [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\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 in: getEvent('order complete', { timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\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 * 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 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 '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 * Group identify with properties — per-event mapping fires\n * client.groupIdentify() with group properties. skip: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\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 '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 * 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 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 'client.capture',\n {\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n};\n\n/**\n * Consent revoked — client.disable() is called.\n */\nexport const consentRevoke: PostHogStepExample = {\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 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;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A,UACH,MAAM,EAAE,OAAO,UAAU;AAAA,UACzB,KAAK;AAAA,UACL,YAAY;AAAA,YACV,KAAK;AAAA,cACH,MAAM;AAAA,cACN,MAAM;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,IACA;AAAA,MACE,WAAW;AAAA,MACX,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,0BAA8C;AAAA,EACzD,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,IACA;AAAA,MACE,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,YAAY,CAAC;AAAA,MACb,QAAQ,EAAE,SAAS,cAAc;AAAA,IACnC;AAAA,EACF;AACF;AAKO,IAAM,gBAAoC;AAAA,EAC/C,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,gBAAgB;AACxB;AAKO,IAAM,eAAmC;AAAA,EAC9C,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,eAAe;AACvB;","names":["import_dev","import_dev"]}
|
package/dist/dev.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,s)=>{for(var o in s)e(t,o,{get:s[o],enumerable:!0})},s={};t(s,{MappingSchema:()=>r,SettingsSchema:()=>i,mapping:()=>l,settings:()=>p});import{zodToSchema as o}from"@walkeros/core/dev";import{z as a}from"@walkeros/core/dev";var i=a.object({apiKey:a.string().min(1).describe('PostHog project API key (starts with "phc_"). Find it in PostHog project settings.'),host:a.string().describe("PostHog API host. Defaults to https://us.i.posthog.com. Use https://eu.i.posthog.com for EU or your self-hosted URL.").optional(),flushAt:a.number().describe("Number of events queued before auto-flush. Default: 20.").optional(),flushInterval:a.number().describe("Milliseconds between periodic flushes. Default: 10000.").optional(),personalApiKey:a.string().describe("Personal API key (phx_...) for local feature flag evaluation.").optional(),featureFlagsPollingInterval:a.number().describe("Milliseconds between feature flag definition polls. Default: 30000.").optional(),disableGeoip:a.boolean().describe("Disable GeoIP lookups globally. Useful for GDPR compliance.").optional(),debug:a.boolean().describe("Enable PostHog SDK debug logging. Default: false.").optional(),identify:a.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: distinctId, $set, $set_once. Resolved on every push (server is stateless).").optional(),group:a.unknown().describe("walkerOS mapping value resolving to a group object. Keys: type, key, properties. Resolved on every push.").optional(),include:a.array(a.string()).describe('Event sections to flatten into capture() properties (e.g. ["data", "globals"]).').optional()});import{z as n}from"@walkeros/core/dev";var r=n.object({identify:n.unknown().describe("Per-event identity mapping. Resolves to { distinctId, $set?, $set_once? }. Fires client.identify() when $set/$set_once present.").optional(),group:n.unknown().describe("Group assignment. Resolves to { type, key, properties? }. Fires client.groupIdentify() when properties present, adds groups to capture().").optional()}),p=o(i),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:()=>_,captureWithInclude:()=>f,consentGrant:()=>I,consentRevoke:()=>w,defaultCapture:()=>h,groupIdentifyWithProperties:()=>v,identifyWithSetAndSetOnce:()=>b});import{getEvent as y}from"@walkeros/core";var h={in:y("product view",{timestamp:1700000100}),out:["client.capture",{distinctId:"us3r",event:"product view",properties:{}}]},f={in:y("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={in:y("user login",{timestamp:1700000102,data:{user_id:"new-user-123",email:"user@acme.com",plan:"premium"}}),mapping:{skip:!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={in:y("company update",{timestamp:1700000103,data:{company_id:"company_123",company_name:"Acme",plan:"enterprise"}}),mapping:{skip:!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"}}]},_={in:y("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"}}]},w={command:"consent",in:{analytics:!1},settings:{},out:["client.disable"]},I={command:"consent",in:{analytics:!0},settings:{},out:["client.enable"]};export{c as examples,s as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
ADDED
|
@@ -0,0 +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 */\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 in: getEvent('product view', { timestamp: 1700000100 }),\n out: [\n 'client.capture',\n {\n distinctId: 'us3r',\n event: 'product view',\n properties: {},\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 in: getEvent('order complete', { timestamp: 1700000101 }),\n configInclude: ['data', 'globals'],\n out: [\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 * 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 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 '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 * Group identify with properties — per-event mapping fires\n * client.groupIdentify() with group properties. skip: true suppresses capture.\n */\nexport const groupIdentifyWithProperties: PostHogStepExample = {\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 '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 * 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 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 'client.capture',\n {\n distinctId: 'us3r',\n event: 'page view',\n properties: {},\n groups: { company: 'company_123' },\n },\n ],\n};\n\n/**\n * Consent revoked — client.disable() is called.\n */\nexport const consentRevoke: PostHogStepExample = {\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 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,EACj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AAAA,EACA,KAAK;AAAA,IACH;AAAA,IACA;AAAA,MACE,WAAW;AAAA,MACX,UAAU;AAAA,MACV,YAAY;AAAA,QACV,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,0BAA8C;AAAA,EACzD,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,IACA;AAAA,MACE,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,YAAY,CAAC;AAAA,MACb,QAAQ,EAAE,SAAS,cAAc;AAAA,IACnC;AAAA,EACF;AACF;AAKO,IAAM,gBAAoC;AAAA,EAC/C,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,gBAAgB;AACxB;AAKO,IAAM,eAAmC;AAAA,EAC9C,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,eAAe;AACvB;","names":["z"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Mapping, Flow } from '@walkeros/core';
|
|
2
|
+
import { DestinationServer } from '@walkeros/server-core';
|
|
3
|
+
import { PostHog } from 'posthog-node';
|
|
4
|
+
|
|
5
|
+
interface Settings {
|
|
6
|
+
/** PostHog project API key (phc_...) */
|
|
7
|
+
apiKey: string;
|
|
8
|
+
/** PostHog client instance, populated by init */
|
|
9
|
+
client?: PostHog;
|
|
10
|
+
/** Destination-level identity mapping */
|
|
11
|
+
identify?: Mapping.Value;
|
|
12
|
+
/** Destination-level group mapping */
|
|
13
|
+
group?: Mapping.Value;
|
|
14
|
+
/** Event sections to flatten into capture properties */
|
|
15
|
+
include?: string[];
|
|
16
|
+
host?: string;
|
|
17
|
+
flushAt?: number;
|
|
18
|
+
flushInterval?: number;
|
|
19
|
+
personalApiKey?: string;
|
|
20
|
+
featureFlagsPollingInterval?: number;
|
|
21
|
+
disableGeoip?: boolean;
|
|
22
|
+
disableCompression?: boolean;
|
|
23
|
+
requestTimeout?: number;
|
|
24
|
+
fetchRetryCount?: number;
|
|
25
|
+
fetchRetryDelay?: number;
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface Env extends DestinationServer.Env {
|
|
30
|
+
PostHog?: typeof PostHog;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Standard mock environment for push operations.
|
|
35
|
+
* Injects a mock PostHog class constructor via env.PostHog.
|
|
36
|
+
*/
|
|
37
|
+
declare const push: Env;
|
|
38
|
+
/** Simulation tracking paths for CLI --simulate. */
|
|
39
|
+
declare const simulation: string[];
|
|
40
|
+
|
|
41
|
+
declare const env_push: typeof push;
|
|
42
|
+
declare const env_simulation: typeof simulation;
|
|
43
|
+
declare namespace env {
|
|
44
|
+
export { env_push as push, env_simulation as simulation };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* PostHog server step examples carry destination-level settings and
|
|
49
|
+
* optional configInclude for the test runner to wire up.
|
|
50
|
+
*/
|
|
51
|
+
type PostHogStepExample = Flow.StepExample & {
|
|
52
|
+
settings?: Partial<Settings>;
|
|
53
|
+
configInclude?: string[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Default event forwarding — every walkerOS event becomes
|
|
57
|
+
* client.capture({ distinctId, event, properties }). With no mapping
|
|
58
|
+
* and no include, properties is {}. distinctId falls back to event.user.id.
|
|
59
|
+
*/
|
|
60
|
+
declare const defaultCapture: PostHogStepExample;
|
|
61
|
+
/**
|
|
62
|
+
* Capture with include — destination-level include flattens data and
|
|
63
|
+
* globals sections into prefixed properties.
|
|
64
|
+
*/
|
|
65
|
+
declare const captureWithInclude: PostHogStepExample;
|
|
66
|
+
/**
|
|
67
|
+
* Identify with $set and $set_once — per-event mapping fires
|
|
68
|
+
* client.identify() with person properties. skip: true suppresses capture.
|
|
69
|
+
*/
|
|
70
|
+
declare const identifyWithSetAndSetOnce: PostHogStepExample;
|
|
71
|
+
/**
|
|
72
|
+
* Group identify with properties — per-event mapping fires
|
|
73
|
+
* client.groupIdentify() with group properties. skip: true suppresses capture.
|
|
74
|
+
*/
|
|
75
|
+
declare const groupIdentifyWithProperties: PostHogStepExample;
|
|
76
|
+
/**
|
|
77
|
+
* Capture with group context — destination-level settings.group resolves
|
|
78
|
+
* type + key (no properties). The capture call includes groups.
|
|
79
|
+
*/
|
|
80
|
+
declare const captureWithGroupContext: PostHogStepExample;
|
|
81
|
+
/**
|
|
82
|
+
* Consent revoked — client.disable() is called.
|
|
83
|
+
*/
|
|
84
|
+
declare const consentRevoke: PostHogStepExample;
|
|
85
|
+
/**
|
|
86
|
+
* Consent granted — client.enable() is called.
|
|
87
|
+
*/
|
|
88
|
+
declare const consentGrant: PostHogStepExample;
|
|
89
|
+
|
|
90
|
+
type step_PostHogStepExample = PostHogStepExample;
|
|
91
|
+
declare const step_captureWithGroupContext: typeof captureWithGroupContext;
|
|
92
|
+
declare const step_captureWithInclude: typeof captureWithInclude;
|
|
93
|
+
declare const step_consentGrant: typeof consentGrant;
|
|
94
|
+
declare const step_consentRevoke: typeof consentRevoke;
|
|
95
|
+
declare const step_defaultCapture: typeof defaultCapture;
|
|
96
|
+
declare const step_groupIdentifyWithProperties: typeof groupIdentifyWithProperties;
|
|
97
|
+
declare const step_identifyWithSetAndSetOnce: typeof identifyWithSetAndSetOnce;
|
|
98
|
+
declare namespace step {
|
|
99
|
+
export { type step_PostHogStepExample as PostHogStepExample, step_captureWithGroupContext as captureWithGroupContext, step_captureWithInclude as captureWithInclude, step_consentGrant as consentGrant, step_consentRevoke as consentRevoke, step_defaultCapture as defaultCapture, step_groupIdentifyWithProperties as groupIdentifyWithProperties, step_identifyWithSetAndSetOnce as identifyWithSetAndSetOnce };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { env, step };
|