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