@apex-inc/sdk 0.1.1 → 0.6.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/README.md +70 -2
- package/dist/esm/index.js +175 -7
- package/dist/esm/management.js +395 -3
- package/dist/esm/plg-events.js +45 -0
- package/dist/index.d.ts +254 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +182 -8
- package/dist/index.js.map +1 -1
- package/dist/management.d.ts +285 -2
- package/dist/management.d.ts.map +1 -1
- package/dist/management.js +395 -3
- package/dist/management.js.map +1 -1
- package/dist/plg-events.d.ts +131 -0
- package/dist/plg-events.d.ts.map +1 -0
- package/dist/plg-events.js +50 -0
- package/dist/plg-events.js.map +1 -0
- package/package.json +6 -1
- package/skills/apex-communications/SKILL.md +217 -1
- package/skills/apex-experimentation/SKILL.md +2 -2
- package/skills/apex-growth-tracking/SKILL.md +93 -2
- package/skills/apex-integration-cookbook/SKILL.md +141 -26
- package/skills/apex-partner-network/SKILL.md +191 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export interface ApexConfig {
|
|
2
|
-
|
|
2
|
+
workspaceKey: string;
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use `workspaceKey`. Permanent back-compat alias from
|
|
5
|
+
* the project→workspace rename (2026-06); existing installs passing
|
|
6
|
+
* `projectKey` keep working forever.
|
|
7
|
+
*/
|
|
8
|
+
projectKey?: string;
|
|
3
9
|
apiUrl?: string;
|
|
4
10
|
/** Flush interval in ms (default: 5000) */
|
|
5
11
|
flushInterval?: number;
|
|
@@ -7,6 +13,25 @@ export interface ApexConfig {
|
|
|
7
13
|
flushAt?: number;
|
|
8
14
|
/** Enable debug logging (default: false) */
|
|
9
15
|
debug?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* MMP-070 — Web environment override.
|
|
18
|
+
*
|
|
19
|
+
* Apex auto-detects production / preview / localhost from the
|
|
20
|
+
* request hostname at ingest, which works correctly out of the box
|
|
21
|
+
* for ~95% of merchants. Set this when:
|
|
22
|
+
*
|
|
23
|
+
* - Your staging deploy lives on a custom domain that looks like
|
|
24
|
+
* production (e.g. `app-staging.acme.com` resolves to
|
|
25
|
+
* production but you want it billed as preview).
|
|
26
|
+
* - You want to force `localhost` in a hosted test harness.
|
|
27
|
+
* - You're running CI smoke tests that should never bill.
|
|
28
|
+
*
|
|
29
|
+
* Accepted values: `"production"`, `"preview"`, `"localhost"`.
|
|
30
|
+
* Server-side, `preview` and `localhost` are FREE — they don't
|
|
31
|
+
* count toward billing or fire outbound webhooks unless the
|
|
32
|
+
* webhook explicitly opts into those audiences.
|
|
33
|
+
*/
|
|
34
|
+
environment?: "production" | "preview" | "localhost";
|
|
10
35
|
}
|
|
11
36
|
export interface TrackEvent {
|
|
12
37
|
event: string;
|
|
@@ -17,18 +42,85 @@ export interface IdentifyPayload {
|
|
|
17
42
|
userId: string;
|
|
18
43
|
traits?: Record<string, unknown>;
|
|
19
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* MWO-009 — Group payload. Used for B2B account-level grouping so
|
|
47
|
+
* Apex can compute Product-Qualified Account (PQA) rollups from
|
|
48
|
+
* individual user events.
|
|
49
|
+
*/
|
|
50
|
+
export interface GroupPayload {
|
|
51
|
+
groupId: string;
|
|
52
|
+
traits?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* MWO-009 — Feature usage payload. Fire from your app when a feature
|
|
56
|
+
* is used so adoption rates and aha-moment funnels can be derived
|
|
57
|
+
* without bespoke queries.
|
|
58
|
+
*/
|
|
59
|
+
export interface FeaturePayload {
|
|
60
|
+
featureKey: string;
|
|
61
|
+
enabled?: boolean;
|
|
62
|
+
variant?: string;
|
|
63
|
+
properties?: Record<string, unknown>;
|
|
64
|
+
}
|
|
20
65
|
/**
|
|
21
66
|
* Initialize the Apex SDK. Must be called before track() or identify().
|
|
67
|
+
* Accepts `workspaceKey` (canonical) or the deprecated `projectKey`.
|
|
22
68
|
*/
|
|
23
|
-
export declare function init(options: ApexConfig
|
|
69
|
+
export declare function init(options: ApexConfig | (Omit<ApexConfig, "workspaceKey"> & {
|
|
70
|
+
workspaceKey?: string;
|
|
71
|
+
projectKey: string;
|
|
72
|
+
})): void;
|
|
24
73
|
/**
|
|
25
74
|
* Track a custom event.
|
|
26
75
|
*/
|
|
27
76
|
export declare function track(event: string, properties?: Record<string, unknown>): void;
|
|
77
|
+
/**
|
|
78
|
+
* Canonical Apex Spec user attribute names (snake_case). Emitting these
|
|
79
|
+
* keeps templates clean — `{{first_name}}` resolves directly. Aliases like
|
|
80
|
+
* `firstName` / `zip` still work (Apex maps them), but canonical names skip
|
|
81
|
+
* the mapping step. Arbitrary custom traits are allowed alongside these.
|
|
82
|
+
*/
|
|
83
|
+
export interface CanonicalUserTraits {
|
|
84
|
+
email?: string;
|
|
85
|
+
email_verified?: boolean;
|
|
86
|
+
first_name?: string;
|
|
87
|
+
last_name?: string;
|
|
88
|
+
full_name?: string;
|
|
89
|
+
username?: string;
|
|
90
|
+
phone?: string;
|
|
91
|
+
avatar_url?: string;
|
|
92
|
+
title?: string;
|
|
93
|
+
company?: string;
|
|
94
|
+
gender?: string;
|
|
95
|
+
birthday?: string;
|
|
96
|
+
address_line1?: string;
|
|
97
|
+
address_line2?: string;
|
|
98
|
+
city?: string;
|
|
99
|
+
region?: string;
|
|
100
|
+
postal_code?: string;
|
|
101
|
+
country?: string;
|
|
102
|
+
country_code?: string;
|
|
103
|
+
timezone?: string;
|
|
104
|
+
locale?: string;
|
|
105
|
+
created_at?: string;
|
|
106
|
+
last_seen_at?: string;
|
|
107
|
+
plan?: string;
|
|
108
|
+
subscription_status?: string;
|
|
109
|
+
trial_ends_at?: string;
|
|
110
|
+
lifetime_value?: number;
|
|
111
|
+
marketing_opt_in?: boolean;
|
|
112
|
+
/** Stitch server-side identify to the browser session (apex_vid cookie). */
|
|
113
|
+
visitorId?: string;
|
|
114
|
+
}
|
|
115
|
+
/** Traits accepted by `identify()` — canonical attributes plus any custom keys. */
|
|
116
|
+
export type IdentifyTraits = CanonicalUserTraits & Record<string, unknown>;
|
|
28
117
|
/**
|
|
29
118
|
* Identify a user with traits (email, name, plan, etc.).
|
|
30
119
|
* Also performs identity stitching if the userId looks like an email.
|
|
31
120
|
*
|
|
121
|
+
* Prefer canonical snake_case trait names (see `CanonicalUserTraits`) so
|
|
122
|
+
* templates resolve them cleanly.
|
|
123
|
+
*
|
|
32
124
|
* Pass `traits.visitorId` (the browser's `apex_vid` cookie value) to stitch
|
|
33
125
|
* server-side identify calls to the real browser session. Without it, the SDK
|
|
34
126
|
* creates a synthetic visitor ID that is disconnected from marketing touchpoints.
|
|
@@ -36,7 +128,25 @@ export declare function track(event: string, properties?: Record<string, unknown
|
|
|
36
128
|
* PLG integration pattern:
|
|
37
129
|
* apex.identify('user@example.com', { visitorId: req.cookies.apex_vid })
|
|
38
130
|
*/
|
|
39
|
-
export declare function identify(userId_: string, traits?:
|
|
131
|
+
export declare function identify(userId_: string, traits?: IdentifyTraits): void;
|
|
132
|
+
export declare function group(groupId_: string, traits?: Record<string, unknown>): void;
|
|
133
|
+
/**
|
|
134
|
+
* MWO-009 — Feature usage. Fire from your app whenever a user
|
|
135
|
+
* touches a named feature. Variant + enabled support wiring to
|
|
136
|
+
* Apex experiment payloads — if Phase 8's experiment engine served
|
|
137
|
+
* a variant, pass it through here to close the loop between
|
|
138
|
+
* assignment and adoption.
|
|
139
|
+
*/
|
|
140
|
+
export declare function feature(featureKey: string, opts?: {
|
|
141
|
+
enabled?: boolean;
|
|
142
|
+
variant?: string;
|
|
143
|
+
properties?: Record<string, unknown>;
|
|
144
|
+
}): void;
|
|
145
|
+
/**
|
|
146
|
+
* Returns the most recently set groupId (if any). Callers can use
|
|
147
|
+
* this to decorate their own payloads or assert in tests.
|
|
148
|
+
*/
|
|
149
|
+
export declare function currentGroupId(): string | null;
|
|
40
150
|
/**
|
|
41
151
|
* Track a form submission event with the email for identity stitching.
|
|
42
152
|
*/
|
|
@@ -50,9 +160,149 @@ export declare function trackForm(formData: {
|
|
|
50
160
|
* Immediately flush all queued events to the server.
|
|
51
161
|
*/
|
|
52
162
|
export declare function flush(): void;
|
|
163
|
+
/** Canonical line shape consumed by the server-side cart rollup. */
|
|
164
|
+
export interface CartLine {
|
|
165
|
+
/** Merchant SKU (required for stable line identity). */
|
|
166
|
+
sku: string;
|
|
167
|
+
/** Items in the line. Negative values are clamped to 0 server-side. */
|
|
168
|
+
qty: number;
|
|
169
|
+
priceCents?: number;
|
|
170
|
+
currency?: string;
|
|
171
|
+
/** Display name for the Contact-drawer rendering. */
|
|
172
|
+
name?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Stable per-merchant line id. Defaults to `sku` server-side, but
|
|
175
|
+
* pass an explicit value (e.g. `cart_line_<id>`) when a single SKU
|
|
176
|
+
* can have multiple cart lines (e.g. configurable products).
|
|
177
|
+
*/
|
|
178
|
+
stableLineId?: string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Helpers grouped under `trackCart.*` so call sites read naturally
|
|
182
|
+
* (`apex.trackCart.add({...})`). The implementation just delegates to
|
|
183
|
+
* `track()` with the canonical event names.
|
|
184
|
+
*/
|
|
185
|
+
export declare const trackCart: {
|
|
186
|
+
/** Fired when a user adds an item to their cart. */
|
|
187
|
+
readonly add: (line: CartLine) => void;
|
|
188
|
+
/** Fired when a user removes an item from their cart. */
|
|
189
|
+
readonly remove: (opts: {
|
|
190
|
+
sku: string;
|
|
191
|
+
qty: number;
|
|
192
|
+
stableLineId?: string;
|
|
193
|
+
/** Optional total cart value post-remove for snapshot reconciliation. */
|
|
194
|
+
cartValueCents?: number;
|
|
195
|
+
currency?: string;
|
|
196
|
+
}) => void;
|
|
197
|
+
/**
|
|
198
|
+
* Full-cart reconciliation snapshot. Use whenever the canonical
|
|
199
|
+
* cart state is loaded (login restore, app foreground, cart screen
|
|
200
|
+
* mount). The server-side rollup replaces all stored lines wholesale
|
|
201
|
+
* — this is the "source of truth" event when deltas drift.
|
|
202
|
+
*/
|
|
203
|
+
readonly snapshot: (opts: {
|
|
204
|
+
lines: CartLine[];
|
|
205
|
+
currency?: string;
|
|
206
|
+
}) => void;
|
|
207
|
+
/** Fired on checkout success; clears the rolled-up cart. */
|
|
208
|
+
readonly checkout: (opts: {
|
|
209
|
+
orderId: string;
|
|
210
|
+
totalCents: number;
|
|
211
|
+
currency?: string;
|
|
212
|
+
}) => void;
|
|
213
|
+
};
|
|
53
214
|
/**
|
|
54
215
|
* Shut down the SDK — flush remaining events and stop the timer.
|
|
55
216
|
*/
|
|
56
217
|
export declare function shutdown(): void;
|
|
57
|
-
export { createManagementClient, type ManagementConfig, type AssignVariantResult, } from "./management";
|
|
218
|
+
export { createManagementClient, type ManagementConfig, type AssignVariantResult, type CommChannel, type EndUserCommPreferences, type InboxNotification, type ApexDataSourceKind, type ApexDataSourceStatus, type ApexDataSource, type ApexDataSourceHealth, type ApexHostSeen, type ApexAnalyticsSources, } from "./management";
|
|
219
|
+
/**
|
|
220
|
+
* Configuration for server-side event delivery.
|
|
221
|
+
*/
|
|
222
|
+
export interface ServerEventsConfig {
|
|
223
|
+
/** Server API key (`apex_sk_…`). Required. */
|
|
224
|
+
apiKey: string;
|
|
225
|
+
/**
|
|
226
|
+
* Apex API base URL (defaults to `https://app.apex.inc`). Override
|
|
227
|
+
* for self-hosted instances or local dev.
|
|
228
|
+
*/
|
|
229
|
+
apiUrl?: string;
|
|
230
|
+
/**
|
|
231
|
+
* When your org has multiple workspaces, set this to disambiguate.
|
|
232
|
+
* Optional — Apex auto-picks if the org has exactly one workspace.
|
|
233
|
+
*/
|
|
234
|
+
workspaceKey?: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* A single server-side event in the Apex Spec shape.
|
|
238
|
+
*/
|
|
239
|
+
export interface ServerEvent {
|
|
240
|
+
/** Event name. Use Apex Spec verbs ("purchase_completed",
|
|
241
|
+
* "signup_completed") for free dashboard wiring; arbitrary strings
|
|
242
|
+
* are accepted. */
|
|
243
|
+
type: string;
|
|
244
|
+
/** Visitor ID that ties this event back to the original web /
|
|
245
|
+
* mobile session. Optional when you only have an email. */
|
|
246
|
+
visitorId?: string;
|
|
247
|
+
/** Email address. Server-side stitches by email when visitorId is
|
|
248
|
+
* not available. */
|
|
249
|
+
email?: string;
|
|
250
|
+
/** Free-form event payload (value, currency, order_id, …). */
|
|
251
|
+
data?: Record<string, unknown>;
|
|
252
|
+
/** ISO 8601 timestamp. Defaults to receipt time on the server. */
|
|
253
|
+
timestamp?: string;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Response from a successful (or deduplicated) batch.
|
|
257
|
+
*/
|
|
258
|
+
export interface ServerEventsResponse {
|
|
259
|
+
data: {
|
|
260
|
+
received: number;
|
|
261
|
+
duplicates: number;
|
|
262
|
+
errors: Array<{
|
|
263
|
+
index: number;
|
|
264
|
+
reason: string;
|
|
265
|
+
}>;
|
|
266
|
+
deduped?: boolean;
|
|
267
|
+
};
|
|
268
|
+
metadata?: {
|
|
269
|
+
workspaceKey?: string;
|
|
270
|
+
idempotencyKey?: string;
|
|
271
|
+
batchSize?: number;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Generate a stable idempotency key. Prefers `crypto.randomUUID()`
|
|
276
|
+
* when available (Node 19+, modern browsers). Falls back to a
|
|
277
|
+
* timestamp + random suffix that's good enough to avoid collisions
|
|
278
|
+
* within a single process.
|
|
279
|
+
*/
|
|
280
|
+
export declare function newIdempotencyKey(): string;
|
|
281
|
+
/**
|
|
282
|
+
* Send a single event server-to-server. Useful for Stripe webhooks,
|
|
283
|
+
* CRM-driven conversions, and any backend signal that should land in
|
|
284
|
+
* Apex without going through the browser snippet.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* await sendServerEvent(
|
|
288
|
+
* { apiKey: process.env.APEX_API_KEY! },
|
|
289
|
+
* {
|
|
290
|
+
* type: "purchase_completed",
|
|
291
|
+
* email: "user@example.com",
|
|
292
|
+
* data: { value: 99, currency: "USD", order_id: "order_42" },
|
|
293
|
+
* },
|
|
294
|
+
* { idempotencyKey: stripeEvent.id }
|
|
295
|
+
* );
|
|
296
|
+
*/
|
|
297
|
+
export declare function sendServerEvent(config: ServerEventsConfig, event: ServerEvent, options?: {
|
|
298
|
+
idempotencyKey?: string;
|
|
299
|
+
}): Promise<ServerEventsResponse>;
|
|
300
|
+
/**
|
|
301
|
+
* Send up to 100 events server-to-server in one request. Larger
|
|
302
|
+
* batches must be sharded by the caller (the API returns 400
|
|
303
|
+
* `batch_too_large` otherwise).
|
|
304
|
+
*/
|
|
305
|
+
export declare function sendServerEvents(config: ServerEventsConfig, events: ServerEvent[], options?: {
|
|
306
|
+
idempotencyKey?: string;
|
|
307
|
+
}): Promise<ServerEventsResponse>;
|
|
58
308
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC;CACtD;AAED,MAAM,WAAW,UAA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AAM,CAAA;SAAE,CAAC,CAAC;QACjD,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAI1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAO,GACxC,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,WAAW,EAAE,EACrB,OAAO,GAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAO,GACxC,OAAO,CAAC,oBAAoB,CAAC,CA0C/B"}
|
package/dist/index.js
CHANGED
|
@@ -33,13 +33,19 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createManagementClient = void 0;
|
|
36
|
+
exports.createManagementClient = exports.trackCart = void 0;
|
|
37
37
|
exports.init = init;
|
|
38
38
|
exports.track = track;
|
|
39
39
|
exports.identify = identify;
|
|
40
|
+
exports.group = group;
|
|
41
|
+
exports.feature = feature;
|
|
42
|
+
exports.currentGroupId = currentGroupId;
|
|
40
43
|
exports.trackForm = trackForm;
|
|
41
44
|
exports.flush = flush;
|
|
42
45
|
exports.shutdown = shutdown;
|
|
46
|
+
exports.newIdempotencyKey = newIdempotencyKey;
|
|
47
|
+
exports.sendServerEvent = sendServerEvent;
|
|
48
|
+
exports.sendServerEvents = sendServerEvents;
|
|
43
49
|
const isBrowser = typeof window !== "undefined";
|
|
44
50
|
const DEFAULT_API_URL = isBrowser ? window.location.origin : "http://localhost:3000";
|
|
45
51
|
let config = null;
|
|
@@ -56,9 +62,14 @@ async function sendBatch(events) {
|
|
|
56
62
|
const apiUrl = config.apiUrl ?? DEFAULT_API_URL;
|
|
57
63
|
const url = `${apiUrl.replace(/\/$/, "")}/api/events`;
|
|
58
64
|
const body = JSON.stringify({
|
|
59
|
-
|
|
65
|
+
workspaceKey: config.workspaceKey,
|
|
60
66
|
userId,
|
|
61
67
|
events,
|
|
68
|
+
// MMP-070 — propagate the SDK-level environment override (when
|
|
69
|
+
// set by `apex.init({ environment })`). The server prefers this
|
|
70
|
+
// over auto-detection from the Referer/Origin host. Mobile SDKs
|
|
71
|
+
// don't send this field; they set `mobile.releaseChannel` instead.
|
|
72
|
+
...(config.environment ? { webEnvironment: config.environment } : {}),
|
|
62
73
|
});
|
|
63
74
|
try {
|
|
64
75
|
const fetchFn = typeof fetch !== "undefined" ? fetch : await loadNodeFetch();
|
|
@@ -105,11 +116,16 @@ function enqueue(event) {
|
|
|
105
116
|
// ─── Public API ──────────────────────────────────────────────────────────────
|
|
106
117
|
/**
|
|
107
118
|
* Initialize the Apex SDK. Must be called before track() or identify().
|
|
119
|
+
* Accepts `workspaceKey` (canonical) or the deprecated `projectKey`.
|
|
108
120
|
*/
|
|
109
121
|
function init(options) {
|
|
110
|
-
|
|
122
|
+
const workspaceKey = options.workspaceKey ?? options.projectKey;
|
|
123
|
+
if (!workspaceKey) {
|
|
124
|
+
throw new Error("apex.init: `workspaceKey` is required");
|
|
125
|
+
}
|
|
126
|
+
config = { ...options, workspaceKey };
|
|
111
127
|
queue = [];
|
|
112
|
-
log("Initialized with
|
|
128
|
+
log("Initialized with workspace:", workspaceKey);
|
|
113
129
|
startFlushTimer();
|
|
114
130
|
}
|
|
115
131
|
/**
|
|
@@ -131,6 +147,9 @@ function track(event, properties) {
|
|
|
131
147
|
* Identify a user with traits (email, name, plan, etc.).
|
|
132
148
|
* Also performs identity stitching if the userId looks like an email.
|
|
133
149
|
*
|
|
150
|
+
* Prefer canonical snake_case trait names (see `CanonicalUserTraits`) so
|
|
151
|
+
* templates resolve them cleanly.
|
|
152
|
+
*
|
|
134
153
|
* Pass `traits.visitorId` (the browser's `apex_vid` cookie value) to stitch
|
|
135
154
|
* server-side identify calls to the real browser session. Without it, the SDK
|
|
136
155
|
* creates a synthetic visitor ID that is disconnected from marketing touchpoints.
|
|
@@ -153,15 +172,21 @@ function identify(userId_, traits) {
|
|
|
153
172
|
const email = userId_.includes("@") ? userId_ : traits?.email;
|
|
154
173
|
if (email) {
|
|
155
174
|
const browserVisitorId = traits?.visitorId;
|
|
156
|
-
|
|
175
|
+
// Forward the caller's stable user id as `userId` whenever it is NOT
|
|
176
|
+
// itself an email — this becomes the highest-precedence
|
|
177
|
+
// `internal_user_id` identifier server-side, which is what makes
|
|
178
|
+
// anonymous→known reconciliation deterministic. Always identify with
|
|
179
|
+
// your own user id (e.g. Cognito sub / DB id), not just an email.
|
|
180
|
+
const stableUserId = userId_.includes("@") ? undefined : userId_;
|
|
181
|
+
stitchIdentity(email, browserVisitorId, traits, stableUserId);
|
|
157
182
|
}
|
|
158
183
|
}
|
|
159
|
-
async function stitchIdentity(email, browserVisitorId, metadata) {
|
|
184
|
+
async function stitchIdentity(email, browserVisitorId, metadata, stableUserId) {
|
|
160
185
|
if (!config)
|
|
161
186
|
return;
|
|
162
187
|
const apiUrl = config.apiUrl ?? DEFAULT_API_URL;
|
|
163
188
|
const url = `${apiUrl.replace(/\/$/, "")}/api/identity/stitch`;
|
|
164
|
-
const effectiveVisitorId = browserVisitorId || `sdk-${config.
|
|
189
|
+
const effectiveVisitorId = browserVisitorId || `sdk-${config.workspaceKey}-${email}`;
|
|
165
190
|
try {
|
|
166
191
|
const fetchFn = typeof fetch !== "undefined" ? fetch : await loadNodeFetch();
|
|
167
192
|
await fetchFn(url, {
|
|
@@ -170,7 +195,8 @@ async function stitchIdentity(email, browserVisitorId, metadata) {
|
|
|
170
195
|
body: JSON.stringify({
|
|
171
196
|
visitorId: effectiveVisitorId,
|
|
172
197
|
email,
|
|
173
|
-
|
|
198
|
+
workspaceKey: config.workspaceKey,
|
|
199
|
+
...(stableUserId ? { userId: stableUserId } : {}),
|
|
174
200
|
metadata: metadata ?? {},
|
|
175
201
|
}),
|
|
176
202
|
});
|
|
@@ -180,6 +206,56 @@ async function stitchIdentity(email, browserVisitorId, metadata) {
|
|
|
180
206
|
log("Identity stitch failed:", err);
|
|
181
207
|
}
|
|
182
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* MWO-009 — Group a user into an account / company / team so B2B
|
|
211
|
+
* PQA rollups can be derived. Calling `group("acme-inc")` stamps
|
|
212
|
+
* every subsequent `track`/`feature` event with `groupId`.
|
|
213
|
+
*/
|
|
214
|
+
let groupId = null;
|
|
215
|
+
function group(groupId_, traits) {
|
|
216
|
+
if (!config) {
|
|
217
|
+
console.warn("[apex-sdk] Call init() before group()");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
groupId = groupId_;
|
|
221
|
+
log("Group:", groupId_, traits);
|
|
222
|
+
enqueue({
|
|
223
|
+
type: "group",
|
|
224
|
+
payload: { groupId: groupId_, traits },
|
|
225
|
+
timestamp: new Date().toISOString(),
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* MWO-009 — Feature usage. Fire from your app whenever a user
|
|
230
|
+
* touches a named feature. Variant + enabled support wiring to
|
|
231
|
+
* Apex experiment payloads — if Phase 8's experiment engine served
|
|
232
|
+
* a variant, pass it through here to close the loop between
|
|
233
|
+
* assignment and adoption.
|
|
234
|
+
*/
|
|
235
|
+
function feature(featureKey, opts = {}) {
|
|
236
|
+
if (!config) {
|
|
237
|
+
console.warn("[apex-sdk] Call init() before feature()");
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
log("Feature:", featureKey, opts);
|
|
241
|
+
enqueue({
|
|
242
|
+
type: "feature",
|
|
243
|
+
payload: {
|
|
244
|
+
featureKey,
|
|
245
|
+
enabled: opts.enabled,
|
|
246
|
+
variant: opts.variant,
|
|
247
|
+
properties: opts.properties,
|
|
248
|
+
},
|
|
249
|
+
timestamp: new Date().toISOString(),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Returns the most recently set groupId (if any). Callers can use
|
|
254
|
+
* this to decorate their own payloads or assert in tests.
|
|
255
|
+
*/
|
|
256
|
+
function currentGroupId() {
|
|
257
|
+
return groupId;
|
|
258
|
+
}
|
|
183
259
|
/**
|
|
184
260
|
* Track a form submission event with the email for identity stitching.
|
|
185
261
|
*/
|
|
@@ -207,6 +283,34 @@ function flush() {
|
|
|
207
283
|
const batch = queue.splice(0, queue.length);
|
|
208
284
|
sendBatch(batch);
|
|
209
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Helpers grouped under `trackCart.*` so call sites read naturally
|
|
288
|
+
* (`apex.trackCart.add({...})`). The implementation just delegates to
|
|
289
|
+
* `track()` with the canonical event names.
|
|
290
|
+
*/
|
|
291
|
+
exports.trackCart = {
|
|
292
|
+
/** Fired when a user adds an item to their cart. */
|
|
293
|
+
add(line) {
|
|
294
|
+
track("add_to_cart", { ...line });
|
|
295
|
+
},
|
|
296
|
+
/** Fired when a user removes an item from their cart. */
|
|
297
|
+
remove(opts) {
|
|
298
|
+
track("remove_from_cart", { ...opts });
|
|
299
|
+
},
|
|
300
|
+
/**
|
|
301
|
+
* Full-cart reconciliation snapshot. Use whenever the canonical
|
|
302
|
+
* cart state is loaded (login restore, app foreground, cart screen
|
|
303
|
+
* mount). The server-side rollup replaces all stored lines wholesale
|
|
304
|
+
* — this is the "source of truth" event when deltas drift.
|
|
305
|
+
*/
|
|
306
|
+
snapshot(opts) {
|
|
307
|
+
track("cart_snapshot", { ...opts });
|
|
308
|
+
},
|
|
309
|
+
/** Fired on checkout success; clears the rolled-up cart. */
|
|
310
|
+
checkout(opts) {
|
|
311
|
+
track("checkout_completed", { ...opts });
|
|
312
|
+
},
|
|
313
|
+
};
|
|
210
314
|
/**
|
|
211
315
|
* Shut down the SDK — flush remaining events and stop the timer.
|
|
212
316
|
*/
|
|
@@ -221,4 +325,74 @@ function shutdown() {
|
|
|
221
325
|
}
|
|
222
326
|
var management_1 = require("./management");
|
|
223
327
|
Object.defineProperty(exports, "createManagementClient", { enumerable: true, get: function () { return management_1.createManagementClient; } });
|
|
328
|
+
/**
|
|
329
|
+
* Generate a stable idempotency key. Prefers `crypto.randomUUID()`
|
|
330
|
+
* when available (Node 19+, modern browsers). Falls back to a
|
|
331
|
+
* timestamp + random suffix that's good enough to avoid collisions
|
|
332
|
+
* within a single process.
|
|
333
|
+
*/
|
|
334
|
+
function newIdempotencyKey() {
|
|
335
|
+
const c = globalThis.crypto;
|
|
336
|
+
if (c?.randomUUID)
|
|
337
|
+
return c.randomUUID();
|
|
338
|
+
return `idk_${Date.now()}_${Math.random().toString(36).slice(2, 12)}`;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Send a single event server-to-server. Useful for Stripe webhooks,
|
|
342
|
+
* CRM-driven conversions, and any backend signal that should land in
|
|
343
|
+
* Apex without going through the browser snippet.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* await sendServerEvent(
|
|
347
|
+
* { apiKey: process.env.APEX_API_KEY! },
|
|
348
|
+
* {
|
|
349
|
+
* type: "purchase_completed",
|
|
350
|
+
* email: "user@example.com",
|
|
351
|
+
* data: { value: 99, currency: "USD", order_id: "order_42" },
|
|
352
|
+
* },
|
|
353
|
+
* { idempotencyKey: stripeEvent.id }
|
|
354
|
+
* );
|
|
355
|
+
*/
|
|
356
|
+
async function sendServerEvent(config, event, options = {}) {
|
|
357
|
+
return sendServerEvents(config, [event], options);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Send up to 100 events server-to-server in one request. Larger
|
|
361
|
+
* batches must be sharded by the caller (the API returns 400
|
|
362
|
+
* `batch_too_large` otherwise).
|
|
363
|
+
*/
|
|
364
|
+
async function sendServerEvents(config, events, options = {}) {
|
|
365
|
+
if (!config.apiKey) {
|
|
366
|
+
throw new Error("apex-sdk: sendServerEvent requires apiKey");
|
|
367
|
+
}
|
|
368
|
+
if (events.length === 0) {
|
|
369
|
+
throw new Error("apex-sdk: sendServerEvent requires at least one event");
|
|
370
|
+
}
|
|
371
|
+
if (events.length > 100) {
|
|
372
|
+
throw new Error("apex-sdk: sendServerEvents batch_too_large — max 100 events; shard yourself");
|
|
373
|
+
}
|
|
374
|
+
const apiUrl = (config.apiUrl ?? "https://app.apex.inc").replace(/\/$/, "");
|
|
375
|
+
const url = `${apiUrl}/api/v1/events`;
|
|
376
|
+
const idempotencyKey = options.idempotencyKey ?? newIdempotencyKey();
|
|
377
|
+
const headers = {
|
|
378
|
+
"content-type": "application/json",
|
|
379
|
+
"x-api-key": config.apiKey,
|
|
380
|
+
"idempotency-key": idempotencyKey,
|
|
381
|
+
};
|
|
382
|
+
if (config.workspaceKey)
|
|
383
|
+
headers["x-apex-workspace"] = config.workspaceKey;
|
|
384
|
+
const fetchFn = typeof fetch !== "undefined" ? fetch : await loadNodeFetch();
|
|
385
|
+
const res = await fetchFn(url, {
|
|
386
|
+
method: "POST",
|
|
387
|
+
headers,
|
|
388
|
+
body: JSON.stringify({ events }),
|
|
389
|
+
});
|
|
390
|
+
const json = (await res.json().catch(() => ({})));
|
|
391
|
+
if (!res.ok) {
|
|
392
|
+
const code = json.error?.code ?? `http_${res.status}`;
|
|
393
|
+
const message = json.error?.message ?? `HTTP ${res.status}`;
|
|
394
|
+
throw new Error(`apex-sdk: sendServerEvent failed (${code}): ${message}`);
|
|
395
|
+
}
|
|
396
|
+
return json;
|
|
397
|
+
}
|
|
224
398
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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