@hogsend/core 0.21.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/providers/analytics.ts +32 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hogsend/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
33
|
"iana-db-timezones": "^0.3.0",
|
|
34
34
|
"zod": "^4.4.3",
|
|
35
|
-
"@hogsend/db": "^0.
|
|
35
|
+
"@hogsend/db": "^0.23.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "latest",
|
|
@@ -61,6 +61,12 @@ export interface AnalyticsCapabilities {
|
|
|
61
61
|
personWrites: boolean;
|
|
62
62
|
/** True when the provider supports the `hogsend connect` OAuth flow. */
|
|
63
63
|
oauth?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* True when the provider can durably fold two distinct ids into ONE person
|
|
66
|
+
* (PostHog `alias`, Segment/Rudderstack `alias`, Amplitude merge). When false
|
|
67
|
+
* or absent, the engine's identity helper no-ops — stitching is best-effort.
|
|
68
|
+
*/
|
|
69
|
+
identityMerge?: boolean;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
export interface AnalyticsProviderMeta {
|
|
@@ -85,6 +91,18 @@ export interface AnalyticsProvider extends IdentityProvider {
|
|
|
85
91
|
opts: { distinctId: string } & PersonPropertiesWrite,
|
|
86
92
|
): Promise<void>;
|
|
87
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Declare `alias` and `distinctId` are the SAME person, folding `alias`'s
|
|
96
|
+
* history into the canonical id. Direction is load-bearing: `distinctId` is
|
|
97
|
+
* the SURVIVING/canonical id, `alias` the absorbed (anonymous) one — mapping
|
|
98
|
+
* straight from the engine's SURVIVOR RULE. Best-effort, idempotent,
|
|
99
|
+
* fire-and-forget. MUST be called only at the moment two keys first become
|
|
100
|
+
* one (a merge event), never per-event: PostHog `alias` is one-directional
|
|
101
|
+
* and once-only per pair. A provider that cannot merge omits this (and sets
|
|
102
|
+
* `identityMerge=false`); the engine no-ops.
|
|
103
|
+
*/
|
|
104
|
+
mergeIdentities?(opts: IdentityMergeOptions): void;
|
|
105
|
+
|
|
88
106
|
/** Event capture under a distinct id. Fire-and-forget semantics. */
|
|
89
107
|
capture(opts: CaptureOptions): void;
|
|
90
108
|
|
|
@@ -128,3 +146,17 @@ export interface CaptureOptions {
|
|
|
128
146
|
event: string;
|
|
129
147
|
properties?: Record<string, unknown>;
|
|
130
148
|
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Options for {@link AnalyticsProvider.mergeIdentities}. Direction is
|
|
152
|
+
* load-bearing (MF-1): `distinctId` is the SURVIVING/canonical (identified) id
|
|
153
|
+
* and `alias` is the ABSORBED (anonymous) one, which MUST never have been an
|
|
154
|
+
* identify/alias `distinct_id`. Maps straight to PostHog `client.alias` per the
|
|
155
|
+
* PostHog DOCS — NOT the posthog-node `.d.ts` example, which is backwards.
|
|
156
|
+
*/
|
|
157
|
+
export interface IdentityMergeOptions {
|
|
158
|
+
/** The SURVIVING/canonical (identified) id — the only value that may survive. */
|
|
159
|
+
distinctId: string;
|
|
160
|
+
/** The ABSORBED (anonymous) id — must never have been identified. */
|
|
161
|
+
alias: string;
|
|
162
|
+
}
|