posthog-node 5.48.2 → 5.49.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/dist/ai-capture/batching.d.ts +11 -0
- package/dist/ai-capture/batching.d.ts.map +1 -0
- package/dist/ai-capture/batching.js +73 -0
- package/dist/ai-capture/batching.mjs +36 -0
- package/dist/ai-capture/routing.d.ts +5 -0
- package/dist/ai-capture/routing.d.ts.map +1 -0
- package/dist/ai-capture/routing.js +48 -0
- package/dist/ai-capture/routing.mjs +5 -0
- package/dist/client.d.ts +32 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +66 -6
- package/dist/client.mjs +67 -7
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +2 -2
- package/src/ai-capture/batching.ts +47 -0
- package/src/ai-capture/routing.ts +7 -0
- package/src/client.ts +123 -8
- package/src/types.ts +39 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PostHogEventProperties } from '@posthog/core';
|
|
2
|
+
export type AiBatchPartition = {
|
|
3
|
+
batches: PostHogEventProperties[][];
|
|
4
|
+
dropped: {
|
|
5
|
+
event: string;
|
|
6
|
+
bytes: number;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
export declare function eventByteSize(message: PostHogEventProperties): number;
|
|
10
|
+
export declare function partitionAiBatch(messages: (PostHogEventProperties | undefined)[], maxEventBytes?: number, targetBatchBytes?: number): AiBatchPartition;
|
|
11
|
+
//# sourceMappingURL=batching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batching.d.ts","sourceRoot":"","sources":["../../src/ai-capture/batching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAqB,MAAM,eAAe,CAAA;AAMzE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAA;IACnC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAC5C,CAAA;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAErE;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,CAAC,sBAAsB,GAAG,SAAS,CAAC,EAAE,EAChD,aAAa,GAAE,MAA2B,EAC1C,gBAAgB,GAAE,MAA8B,GAC/C,gBAAgB,CA2BlB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
eventByteSize: ()=>eventByteSize,
|
|
28
|
+
partitionAiBatch: ()=>partitionAiBatch
|
|
29
|
+
});
|
|
30
|
+
const core_namespaceObject = require("@posthog/core");
|
|
31
|
+
const external_routing_js_namespaceObject = require("./routing.js");
|
|
32
|
+
const encoder = new TextEncoder();
|
|
33
|
+
function eventByteSize(message) {
|
|
34
|
+
return encoder.encode((0, core_namespaceObject.safeJsonStringify)(message)).length;
|
|
35
|
+
}
|
|
36
|
+
function partitionAiBatch(messages, maxEventBytes = external_routing_js_namespaceObject.AI_MAX_EVENT_BYTES, targetBatchBytes = external_routing_js_namespaceObject.AI_BATCH_TARGET_BYTES) {
|
|
37
|
+
const batches = [];
|
|
38
|
+
const dropped = [];
|
|
39
|
+
let current = [];
|
|
40
|
+
let currentBytes = 0;
|
|
41
|
+
for (const message of messages){
|
|
42
|
+
if (void 0 === message) continue;
|
|
43
|
+
const bytes = eventByteSize(message);
|
|
44
|
+
if (bytes > maxEventBytes) {
|
|
45
|
+
dropped.push({
|
|
46
|
+
event: 'string' == typeof message.event ? message.event : 'unknown',
|
|
47
|
+
bytes
|
|
48
|
+
});
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (current.length > 0 && currentBytes + bytes > targetBatchBytes) {
|
|
52
|
+
batches.push(current);
|
|
53
|
+
current = [];
|
|
54
|
+
currentBytes = 0;
|
|
55
|
+
}
|
|
56
|
+
current.push(message);
|
|
57
|
+
currentBytes += bytes;
|
|
58
|
+
}
|
|
59
|
+
if (current.length > 0) batches.push(current);
|
|
60
|
+
return {
|
|
61
|
+
batches,
|
|
62
|
+
dropped
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exports.eventByteSize = __webpack_exports__.eventByteSize;
|
|
66
|
+
exports.partitionAiBatch = __webpack_exports__.partitionAiBatch;
|
|
67
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
68
|
+
"eventByteSize",
|
|
69
|
+
"partitionAiBatch"
|
|
70
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
71
|
+
Object.defineProperty(exports, '__esModule', {
|
|
72
|
+
value: true
|
|
73
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { safeJsonStringify } from "@posthog/core";
|
|
2
|
+
import { AI_BATCH_TARGET_BYTES, AI_MAX_EVENT_BYTES } from "./routing.mjs";
|
|
3
|
+
const encoder = new TextEncoder();
|
|
4
|
+
function eventByteSize(message) {
|
|
5
|
+
return encoder.encode(safeJsonStringify(message)).length;
|
|
6
|
+
}
|
|
7
|
+
function partitionAiBatch(messages, maxEventBytes = AI_MAX_EVENT_BYTES, targetBatchBytes = AI_BATCH_TARGET_BYTES) {
|
|
8
|
+
const batches = [];
|
|
9
|
+
const dropped = [];
|
|
10
|
+
let current = [];
|
|
11
|
+
let currentBytes = 0;
|
|
12
|
+
for (const message of messages){
|
|
13
|
+
if (void 0 === message) continue;
|
|
14
|
+
const bytes = eventByteSize(message);
|
|
15
|
+
if (bytes > maxEventBytes) {
|
|
16
|
+
dropped.push({
|
|
17
|
+
event: 'string' == typeof message.event ? message.event : 'unknown',
|
|
18
|
+
bytes
|
|
19
|
+
});
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (current.length > 0 && currentBytes + bytes > targetBatchBytes) {
|
|
23
|
+
batches.push(current);
|
|
24
|
+
current = [];
|
|
25
|
+
currentBytes = 0;
|
|
26
|
+
}
|
|
27
|
+
current.push(message);
|
|
28
|
+
currentBytes += bytes;
|
|
29
|
+
}
|
|
30
|
+
if (current.length > 0) batches.push(current);
|
|
31
|
+
return {
|
|
32
|
+
batches,
|
|
33
|
+
dropped
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export { eventByteSize, partitionAiBatch };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/ai-capture/routing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAE5C,eAAO,MAAM,wBAAwB,oBAAoB,CAAA;AAEzD,eAAO,MAAM,kBAAkB,QAAkB,CAAA;AAEjD,eAAO,MAAM,qBAAqB,QAAkB,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
AI_BATCH_TARGET_BYTES: ()=>AI_BATCH_TARGET_BYTES,
|
|
28
|
+
AI_CAPTURE_ENDPOINT_PATH: ()=>AI_CAPTURE_ENDPOINT_PATH,
|
|
29
|
+
AI_CAPTURE_ROUTE: ()=>AI_CAPTURE_ROUTE,
|
|
30
|
+
AI_MAX_EVENT_BYTES: ()=>AI_MAX_EVENT_BYTES
|
|
31
|
+
});
|
|
32
|
+
const AI_CAPTURE_ROUTE = 'ai-capture';
|
|
33
|
+
const AI_CAPTURE_ENDPOINT_PATH = '/i/v0/ai/batch/';
|
|
34
|
+
const AI_MAX_EVENT_BYTES = 8388608;
|
|
35
|
+
const AI_BATCH_TARGET_BYTES = 5242880;
|
|
36
|
+
exports.AI_BATCH_TARGET_BYTES = __webpack_exports__.AI_BATCH_TARGET_BYTES;
|
|
37
|
+
exports.AI_CAPTURE_ENDPOINT_PATH = __webpack_exports__.AI_CAPTURE_ENDPOINT_PATH;
|
|
38
|
+
exports.AI_CAPTURE_ROUTE = __webpack_exports__.AI_CAPTURE_ROUTE;
|
|
39
|
+
exports.AI_MAX_EVENT_BYTES = __webpack_exports__.AI_MAX_EVENT_BYTES;
|
|
40
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
41
|
+
"AI_BATCH_TARGET_BYTES",
|
|
42
|
+
"AI_CAPTURE_ENDPOINT_PATH",
|
|
43
|
+
"AI_CAPTURE_ROUTE",
|
|
44
|
+
"AI_MAX_EVENT_BYTES"
|
|
45
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
46
|
+
Object.defineProperty(exports, '__esModule', {
|
|
47
|
+
value: true
|
|
48
|
+
});
|
package/dist/client.d.ts
CHANGED
|
@@ -18,6 +18,9 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
18
18
|
private _metrics?;
|
|
19
19
|
private readonly captureMode;
|
|
20
20
|
private _v1Sender?;
|
|
21
|
+
/** Whether this client captures full AI content: see `enableFullAiCapture` in `PostHogOptions`. */
|
|
22
|
+
readonly enableFullAiCapture: boolean;
|
|
23
|
+
private _aiCaptureRouteActive;
|
|
21
24
|
private _flagOverrides?;
|
|
22
25
|
private _payloadOverrides?;
|
|
23
26
|
private _minimalFlagCalledEvents;
|
|
@@ -53,7 +56,7 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
53
56
|
* @param options - Configuration options for the client
|
|
54
57
|
*/
|
|
55
58
|
constructor(apiKey: string, options?: PostHogOptions);
|
|
56
|
-
protected enqueue(type: string, message: any, options?: PostHogCaptureOptions): void;
|
|
59
|
+
protected enqueue(type: string, message: any, options?: PostHogCaptureOptions, explicitRoute?: string): void;
|
|
57
60
|
flush(): Promise<void>;
|
|
58
61
|
private scheduleDebouncedFlush;
|
|
59
62
|
private _consumeWaitUntilCycle;
|
|
@@ -131,6 +134,7 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
131
134
|
protected getQueueRouteKey(message: PostHogEventProperties): string;
|
|
132
135
|
protected persistedQueueKeyForRoute(route: string): PostHogPersistedProperty;
|
|
133
136
|
protected getActiveQueueRoutes(): string[];
|
|
137
|
+
protected getBatchEndpointPath(route: string): string;
|
|
134
138
|
/**
|
|
135
139
|
* Capture submission seam shared by the batched (`_flush`) and immediate (`sendImmediate`)
|
|
136
140
|
* paths. Events are routed to homogeneous per-route queues at enqueue time, so a batch here is
|
|
@@ -140,6 +144,8 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
140
144
|
* failure can never re-send analytics events already accepted on the V1 leg.
|
|
141
145
|
*/
|
|
142
146
|
protected sendBatch(batchMessages: (PostHogEventProperties | undefined)[], retryOptions?: Partial<RetriableOptions>, route?: string): Promise<void>;
|
|
147
|
+
private sendAiCaptureBatch;
|
|
148
|
+
private sendAiSubBatch;
|
|
143
149
|
private getV1Sender;
|
|
144
150
|
/**
|
|
145
151
|
* Get the library version from package.json.
|
|
@@ -323,6 +329,31 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
323
329
|
* @returns Promise that resolves when the event is captured
|
|
324
330
|
*/
|
|
325
331
|
captureImmediate(props: EventMessage): Promise<void>;
|
|
332
|
+
/**
|
|
333
|
+
* Capture an AI event on the dedicated AI capture endpoint.
|
|
334
|
+
*
|
|
335
|
+
* Beta: the signature is stable; operational limits (per-event size cap,
|
|
336
|
+
* batching, endpoint) may change without notice. Delivery is async, and no
|
|
337
|
+
* redaction or truncation is applied to the payload.
|
|
338
|
+
*
|
|
339
|
+
* {@label Capture}
|
|
340
|
+
*
|
|
341
|
+
* @param props - The event properties
|
|
342
|
+
* @returns The event UUID, or `undefined` when the client is disabled
|
|
343
|
+
*/
|
|
344
|
+
captureAi(props: EventMessage): string | undefined;
|
|
345
|
+
/**
|
|
346
|
+
* Capture an AI event on the dedicated AI capture endpoint, resolving after
|
|
347
|
+
* the send completes. Use in short-lived processes (serverless) where the
|
|
348
|
+
* runtime may freeze before a background flush runs.
|
|
349
|
+
*
|
|
350
|
+
* {@label Capture}
|
|
351
|
+
*
|
|
352
|
+
* @param props - The event properties
|
|
353
|
+
* @returns The event UUID, or `undefined` when the client is disabled
|
|
354
|
+
*/
|
|
355
|
+
captureAiImmediate(props: EventMessage): Promise<string | undefined>;
|
|
356
|
+
private _sendPreparedAiEvent;
|
|
326
357
|
/**
|
|
327
358
|
* Identify a user and set their properties.
|
|
328
359
|
*
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAKhB,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAG/B,wBAAwB,EACxB,UAAU,EAEV,gBAAgB,EAIjB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EACL,eAAe,EACf,YAAY,EAIZ,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,2BAA2B,EAC3B,cAAc,EAEd,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,SAAS,CAAA;AAChB,OAAO,EAEL,sBAAsB,EAEtB,qBAAqB,EACtB,MAAM,4BAA4B,CAAA;AAOnC,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,KAAK,CAAC,EAAE,sBAAsB,GAC7B,IAAI;IAeP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,yBAAyB,CAC7B,KAAK,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACnD,KAAK,CAAC,EAAE,sBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAeH,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAC7D,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,EAAE,sBAAsB,CAAA;QAClC,OAAO,EAAE,qBAAqB,CAAA;KAC/B,CAAC;YAIY,oBAAoB;IAsJlC,OAAO,CAAC,cAAc;CAuBvB"}
|
package/dist/client.js
CHANGED
|
@@ -47,6 +47,8 @@ const external_storage_memory_js_namespaceObject = require("./storage-memory.js"
|
|
|
47
47
|
const config_js_namespaceObject = require("./capture-v1/config.js");
|
|
48
48
|
const routing_js_namespaceObject = require("./capture-v1/routing.js");
|
|
49
49
|
const sender_js_namespaceObject = require("./capture-v1/sender.js");
|
|
50
|
+
const batching_js_namespaceObject = require("./ai-capture/batching.js");
|
|
51
|
+
const external_ai_capture_routing_js_namespaceObject = require("./ai-capture/routing.js");
|
|
50
52
|
const MINIMUM_POLLING_INTERVAL = 100;
|
|
51
53
|
const THIRTY_SECONDS = 30000;
|
|
52
54
|
const MAX_CACHE_SIZE = 50000;
|
|
@@ -97,9 +99,10 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
97
99
|
host: normalizeHost(options.host),
|
|
98
100
|
personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
|
|
99
101
|
};
|
|
100
|
-
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new external_storage_memory_js_namespaceObject.PostHogMemoryStorage(), this._minimalFlagCalledEvents = false;
|
|
102
|
+
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new external_storage_memory_js_namespaceObject.PostHogMemoryStorage(), this._aiCaptureRouteActive = false, this._minimalFlagCalledEvents = false;
|
|
101
103
|
this.options = normalizedOptions;
|
|
102
104
|
this.captureMode = (0, config_js_namespaceObject.resolveCaptureMode)();
|
|
105
|
+
this.enableFullAiCapture = true === normalizedOptions.enableFullAiCapture;
|
|
103
106
|
this.context = this.initializeContext();
|
|
104
107
|
this.options.featureFlagsPollingInterval = 'number' == typeof normalizedOptions.featureFlagsPollingInterval ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
|
|
105
108
|
if ('number' == typeof normalizedOptions.waitUntilDebounceMs) this.options.waitUntilDebounceMs = Math.max(normalizedOptions.waitUntilDebounceMs, 0);
|
|
@@ -132,8 +135,8 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
132
135
|
this.distinctIdHasSentFlagCalls = {};
|
|
133
136
|
this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE;
|
|
134
137
|
}
|
|
135
|
-
enqueue(type, message, options) {
|
|
136
|
-
super.enqueue(type, message, options);
|
|
138
|
+
enqueue(type, message, options, explicitRoute) {
|
|
139
|
+
super.enqueue(type, message, options, explicitRoute);
|
|
137
140
|
this.scheduleDebouncedFlush();
|
|
138
141
|
}
|
|
139
142
|
async flush() {
|
|
@@ -203,21 +206,55 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
203
206
|
return 'v1' === this.captureMode && (0, routing_js_namespaceObject.isLegacyOnlyEvent)(message) ? routing_js_namespaceObject.AI_ROUTE : routing_js_namespaceObject.ANALYTICS_ROUTE;
|
|
204
207
|
}
|
|
205
208
|
persistedQueueKeyForRoute(route) {
|
|
209
|
+
if (route === external_ai_capture_routing_js_namespaceObject.AI_CAPTURE_ROUTE) return core_namespaceObject.PostHogPersistedProperty.AiCaptureQueue;
|
|
206
210
|
return route === routing_js_namespaceObject.AI_ROUTE ? core_namespaceObject.PostHogPersistedProperty.AiQueue : core_namespaceObject.PostHogPersistedProperty.Queue;
|
|
207
211
|
}
|
|
208
212
|
getActiveQueueRoutes() {
|
|
209
|
-
|
|
213
|
+
const routes = 'v1' === this.captureMode ? [
|
|
210
214
|
routing_js_namespaceObject.ANALYTICS_ROUTE,
|
|
211
215
|
routing_js_namespaceObject.AI_ROUTE
|
|
212
216
|
] : [
|
|
213
217
|
routing_js_namespaceObject.ANALYTICS_ROUTE
|
|
214
218
|
];
|
|
219
|
+
if (this._aiCaptureRouteActive) routes.push(external_ai_capture_routing_js_namespaceObject.AI_CAPTURE_ROUTE);
|
|
220
|
+
return routes;
|
|
221
|
+
}
|
|
222
|
+
getBatchEndpointPath(route) {
|
|
223
|
+
return route === external_ai_capture_routing_js_namespaceObject.AI_CAPTURE_ROUTE ? external_ai_capture_routing_js_namespaceObject.AI_CAPTURE_ENDPOINT_PATH : super.getBatchEndpointPath(route);
|
|
215
224
|
}
|
|
216
225
|
async sendBatch(batchMessages, retryOptions, route = routing_js_namespaceObject.ANALYTICS_ROUTE) {
|
|
226
|
+
if (route === external_ai_capture_routing_js_namespaceObject.AI_CAPTURE_ROUTE) return this.sendAiCaptureBatch(batchMessages, retryOptions);
|
|
217
227
|
if ('v1' !== this.captureMode || route === routing_js_namespaceObject.AI_ROUTE) return super.sendBatch(batchMessages, retryOptions, route);
|
|
218
228
|
const v1Events = batchMessages.filter((message)=>void 0 !== message);
|
|
219
229
|
await this.getV1Sender().sendV1Batch(v1Events);
|
|
220
230
|
}
|
|
231
|
+
async sendAiCaptureBatch(batchMessages, retryOptions) {
|
|
232
|
+
const { batches, dropped } = (0, batching_js_namespaceObject.partitionAiBatch)(batchMessages);
|
|
233
|
+
for (const { event, bytes } of dropped){
|
|
234
|
+
const message = `Event ${event} (${bytes} bytes) exceeds the ${external_ai_capture_routing_js_namespaceObject.AI_MAX_EVENT_BYTES / 1048576}MiB limit for ${external_ai_capture_routing_js_namespaceObject.AI_CAPTURE_ENDPOINT_PATH}, dropping.`;
|
|
235
|
+
this._logger.error(message);
|
|
236
|
+
this._events.emit('error', new Error(message));
|
|
237
|
+
}
|
|
238
|
+
for (const batch of batches)await this.sendAiSubBatch(batch, retryOptions);
|
|
239
|
+
}
|
|
240
|
+
async sendAiSubBatch(batch, retryOptions) {
|
|
241
|
+
try {
|
|
242
|
+
await super.sendBatch(batch, retryOptions, external_ai_capture_routing_js_namespaceObject.AI_CAPTURE_ROUTE);
|
|
243
|
+
} catch (err) {
|
|
244
|
+
if (!(0, core_namespaceObject.isPostHogFetchContentTooLargeError)(err)) throw err;
|
|
245
|
+
if (1 === batch.length) {
|
|
246
|
+
const [event] = batch;
|
|
247
|
+
const eventName = 'string' == typeof event.event ? event.event : 'unknown';
|
|
248
|
+
const message = `Event ${eventName} (${(0, batching_js_namespaceObject.eventByteSize)(event)} bytes) was rejected with 413 by ${external_ai_capture_routing_js_namespaceObject.AI_CAPTURE_ENDPOINT_PATH} on its own, dropping.`;
|
|
249
|
+
this._logger.error(message);
|
|
250
|
+
this._events.emit('error', new Error(message));
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const mid = Math.ceil(batch.length / 2);
|
|
254
|
+
await this.sendAiSubBatch(batch.slice(0, mid), retryOptions);
|
|
255
|
+
await this.sendAiSubBatch(batch.slice(mid), retryOptions);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
221
258
|
getV1Sender() {
|
|
222
259
|
if (!this._v1Sender) this._v1Sender = new sender_js_namespaceObject.V1CaptureSender({
|
|
223
260
|
host: this.host,
|
|
@@ -267,7 +304,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
267
304
|
if ('string' == typeof props) this._logger.warn(stringArgumentWarning);
|
|
268
305
|
if ('$exception' === props.event && !props._originatedFromCaptureException) this._logger.warn(exceptionCaptureWarning);
|
|
269
306
|
}
|
|
270
|
-
_sendPreparedEvent(type, props, immediate, prepareOptions) {
|
|
307
|
+
_sendPreparedEvent(type, props, immediate, prepareOptions, explicitRoute) {
|
|
271
308
|
return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options })=>{
|
|
272
309
|
const captureOptions = {
|
|
273
310
|
timestamp: options.timestamp,
|
|
@@ -282,7 +319,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
282
319
|
...this.getCommonEventProperties()
|
|
283
320
|
}
|
|
284
321
|
};
|
|
285
|
-
return immediate ? this.sendImmediate(type, message, captureOptions) : this.enqueue(type, message, captureOptions);
|
|
322
|
+
return immediate ? this.sendImmediate(type, message, captureOptions, explicitRoute) : this.enqueue(type, message, captureOptions, explicitRoute);
|
|
286
323
|
}).catch((err)=>{
|
|
287
324
|
if (err) console.error(err);
|
|
288
325
|
}));
|
|
@@ -298,6 +335,29 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
298
335
|
this._warnIfInvalidCapture(props, 'Called captureImmediate() with a string as the first argument when an object was expected.', "Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default.");
|
|
299
336
|
return this._capturePreparedEvent(props, true);
|
|
300
337
|
}
|
|
338
|
+
captureAi(props) {
|
|
339
|
+
if (this.disabled) return;
|
|
340
|
+
const uuid = (0, core_namespaceObject.getEventUuid)(props.uuid, core_namespaceObject.uuidv7);
|
|
341
|
+
this._sendPreparedAiEvent({
|
|
342
|
+
...props,
|
|
343
|
+
uuid
|
|
344
|
+
}, false);
|
|
345
|
+
return uuid;
|
|
346
|
+
}
|
|
347
|
+
async captureAiImmediate(props) {
|
|
348
|
+
if (this.disabled) return;
|
|
349
|
+
const uuid = (0, core_namespaceObject.getEventUuid)(props.uuid, core_namespaceObject.uuidv7);
|
|
350
|
+
await this._sendPreparedAiEvent({
|
|
351
|
+
...props,
|
|
352
|
+
uuid
|
|
353
|
+
}, true);
|
|
354
|
+
return uuid;
|
|
355
|
+
}
|
|
356
|
+
_sendPreparedAiEvent(props, immediate) {
|
|
357
|
+
if ('string' == typeof props?.event && !props.event.startsWith('$ai_')) this._logger.debug(`captureAi called with non-AI event ${props.event}; routing it to the AI endpoint anyway.`);
|
|
358
|
+
this._aiCaptureRouteActive = true;
|
|
359
|
+
return this._sendPreparedEvent('capture', props, immediate, void 0, external_ai_capture_routing_js_namespaceObject.AI_CAPTURE_ROUTE);
|
|
360
|
+
}
|
|
301
361
|
identify({ distinctId, properties = {}, disableGeoip }) {
|
|
302
362
|
const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
|
|
303
363
|
const setProps = $set || rest;
|
package/dist/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { version } from "./version.mjs";
|
|
2
|
-
import { PostHogCoreStateless, PostHogMetrics, PostHogPersistedProperty, isBlockedUA, isPlainObject, minimizeFlagCalledEventProperties, raceWithTimeout, resolveMetricsConfig, safeSetTimeout, uuidv7 } from "@posthog/core";
|
|
2
|
+
import { PostHogCoreStateless, PostHogMetrics, PostHogPersistedProperty, getEventUuid, isBlockedUA, isPlainObject, isPostHogFetchContentTooLargeError, minimizeFlagCalledEventProperties, raceWithTimeout, resolveMetricsConfig, safeSetTimeout, uuidv7 } from "@posthog/core";
|
|
3
3
|
import { FeatureFlagError } from "./types.mjs";
|
|
4
4
|
import { FeatureFlagEvaluations } from "./feature-flag-evaluations.mjs";
|
|
5
5
|
import { FeatureFlagsPoller, InconclusiveMatchError, RequiresServerEvaluation } from "./extensions/feature-flags/feature-flags.mjs";
|
|
@@ -8,6 +8,8 @@ import { PostHogMemoryStorage } from "./storage-memory.mjs";
|
|
|
8
8
|
import { resolveCaptureMode } from "./capture-v1/config.mjs";
|
|
9
9
|
import { AI_ROUTE, ANALYTICS_ROUTE, isLegacyOnlyEvent } from "./capture-v1/routing.mjs";
|
|
10
10
|
import { V1CaptureSender } from "./capture-v1/sender.mjs";
|
|
11
|
+
import { eventByteSize, partitionAiBatch } from "./ai-capture/batching.mjs";
|
|
12
|
+
import { AI_CAPTURE_ENDPOINT_PATH, AI_CAPTURE_ROUTE, AI_MAX_EVENT_BYTES } from "./ai-capture/routing.mjs";
|
|
11
13
|
const MINIMUM_POLLING_INTERVAL = 100;
|
|
12
14
|
const THIRTY_SECONDS = 30000;
|
|
13
15
|
const MAX_CACHE_SIZE = 50000;
|
|
@@ -58,9 +60,10 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
58
60
|
host: normalizeHost(options.host),
|
|
59
61
|
personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
|
|
60
62
|
};
|
|
61
|
-
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage(), this._minimalFlagCalledEvents = false;
|
|
63
|
+
super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage(), this._aiCaptureRouteActive = false, this._minimalFlagCalledEvents = false;
|
|
62
64
|
this.options = normalizedOptions;
|
|
63
65
|
this.captureMode = resolveCaptureMode();
|
|
66
|
+
this.enableFullAiCapture = true === normalizedOptions.enableFullAiCapture;
|
|
64
67
|
this.context = this.initializeContext();
|
|
65
68
|
this.options.featureFlagsPollingInterval = 'number' == typeof normalizedOptions.featureFlagsPollingInterval ? Math.max(normalizedOptions.featureFlagsPollingInterval, MINIMUM_POLLING_INTERVAL) : THIRTY_SECONDS;
|
|
66
69
|
if ('number' == typeof normalizedOptions.waitUntilDebounceMs) this.options.waitUntilDebounceMs = Math.max(normalizedOptions.waitUntilDebounceMs, 0);
|
|
@@ -93,8 +96,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
93
96
|
this.distinctIdHasSentFlagCalls = {};
|
|
94
97
|
this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE;
|
|
95
98
|
}
|
|
96
|
-
enqueue(type, message, options) {
|
|
97
|
-
super.enqueue(type, message, options);
|
|
99
|
+
enqueue(type, message, options, explicitRoute) {
|
|
100
|
+
super.enqueue(type, message, options, explicitRoute);
|
|
98
101
|
this.scheduleDebouncedFlush();
|
|
99
102
|
}
|
|
100
103
|
async flush() {
|
|
@@ -164,21 +167,55 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
164
167
|
return 'v1' === this.captureMode && isLegacyOnlyEvent(message) ? AI_ROUTE : ANALYTICS_ROUTE;
|
|
165
168
|
}
|
|
166
169
|
persistedQueueKeyForRoute(route) {
|
|
170
|
+
if (route === AI_CAPTURE_ROUTE) return PostHogPersistedProperty.AiCaptureQueue;
|
|
167
171
|
return route === AI_ROUTE ? PostHogPersistedProperty.AiQueue : PostHogPersistedProperty.Queue;
|
|
168
172
|
}
|
|
169
173
|
getActiveQueueRoutes() {
|
|
170
|
-
|
|
174
|
+
const routes = 'v1' === this.captureMode ? [
|
|
171
175
|
ANALYTICS_ROUTE,
|
|
172
176
|
AI_ROUTE
|
|
173
177
|
] : [
|
|
174
178
|
ANALYTICS_ROUTE
|
|
175
179
|
];
|
|
180
|
+
if (this._aiCaptureRouteActive) routes.push(AI_CAPTURE_ROUTE);
|
|
181
|
+
return routes;
|
|
182
|
+
}
|
|
183
|
+
getBatchEndpointPath(route) {
|
|
184
|
+
return route === AI_CAPTURE_ROUTE ? AI_CAPTURE_ENDPOINT_PATH : super.getBatchEndpointPath(route);
|
|
176
185
|
}
|
|
177
186
|
async sendBatch(batchMessages, retryOptions, route = ANALYTICS_ROUTE) {
|
|
187
|
+
if (route === AI_CAPTURE_ROUTE) return this.sendAiCaptureBatch(batchMessages, retryOptions);
|
|
178
188
|
if ('v1' !== this.captureMode || route === AI_ROUTE) return super.sendBatch(batchMessages, retryOptions, route);
|
|
179
189
|
const v1Events = batchMessages.filter((message)=>void 0 !== message);
|
|
180
190
|
await this.getV1Sender().sendV1Batch(v1Events);
|
|
181
191
|
}
|
|
192
|
+
async sendAiCaptureBatch(batchMessages, retryOptions) {
|
|
193
|
+
const { batches, dropped } = partitionAiBatch(batchMessages);
|
|
194
|
+
for (const { event, bytes } of dropped){
|
|
195
|
+
const message = `Event ${event} (${bytes} bytes) exceeds the ${AI_MAX_EVENT_BYTES / 1048576}MiB limit for ${AI_CAPTURE_ENDPOINT_PATH}, dropping.`;
|
|
196
|
+
this._logger.error(message);
|
|
197
|
+
this._events.emit('error', new Error(message));
|
|
198
|
+
}
|
|
199
|
+
for (const batch of batches)await this.sendAiSubBatch(batch, retryOptions);
|
|
200
|
+
}
|
|
201
|
+
async sendAiSubBatch(batch, retryOptions) {
|
|
202
|
+
try {
|
|
203
|
+
await super.sendBatch(batch, retryOptions, AI_CAPTURE_ROUTE);
|
|
204
|
+
} catch (err) {
|
|
205
|
+
if (!isPostHogFetchContentTooLargeError(err)) throw err;
|
|
206
|
+
if (1 === batch.length) {
|
|
207
|
+
const [event] = batch;
|
|
208
|
+
const eventName = 'string' == typeof event.event ? event.event : 'unknown';
|
|
209
|
+
const message = `Event ${eventName} (${eventByteSize(event)} bytes) was rejected with 413 by ${AI_CAPTURE_ENDPOINT_PATH} on its own, dropping.`;
|
|
210
|
+
this._logger.error(message);
|
|
211
|
+
this._events.emit('error', new Error(message));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const mid = Math.ceil(batch.length / 2);
|
|
215
|
+
await this.sendAiSubBatch(batch.slice(0, mid), retryOptions);
|
|
216
|
+
await this.sendAiSubBatch(batch.slice(mid), retryOptions);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
182
219
|
getV1Sender() {
|
|
183
220
|
if (!this._v1Sender) this._v1Sender = new V1CaptureSender({
|
|
184
221
|
host: this.host,
|
|
@@ -228,7 +265,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
228
265
|
if ('string' == typeof props) this._logger.warn(stringArgumentWarning);
|
|
229
266
|
if ('$exception' === props.event && !props._originatedFromCaptureException) this._logger.warn(exceptionCaptureWarning);
|
|
230
267
|
}
|
|
231
|
-
_sendPreparedEvent(type, props, immediate, prepareOptions) {
|
|
268
|
+
_sendPreparedEvent(type, props, immediate, prepareOptions, explicitRoute) {
|
|
232
269
|
return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options })=>{
|
|
233
270
|
const captureOptions = {
|
|
234
271
|
timestamp: options.timestamp,
|
|
@@ -243,7 +280,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
243
280
|
...this.getCommonEventProperties()
|
|
244
281
|
}
|
|
245
282
|
};
|
|
246
|
-
return immediate ? this.sendImmediate(type, message, captureOptions) : this.enqueue(type, message, captureOptions);
|
|
283
|
+
return immediate ? this.sendImmediate(type, message, captureOptions, explicitRoute) : this.enqueue(type, message, captureOptions, explicitRoute);
|
|
247
284
|
}).catch((err)=>{
|
|
248
285
|
if (err) console.error(err);
|
|
249
286
|
}));
|
|
@@ -259,6 +296,29 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
259
296
|
this._warnIfInvalidCapture(props, 'Called captureImmediate() with a string as the first argument when an object was expected.', "Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default.");
|
|
260
297
|
return this._capturePreparedEvent(props, true);
|
|
261
298
|
}
|
|
299
|
+
captureAi(props) {
|
|
300
|
+
if (this.disabled) return;
|
|
301
|
+
const uuid = getEventUuid(props.uuid, uuidv7);
|
|
302
|
+
this._sendPreparedAiEvent({
|
|
303
|
+
...props,
|
|
304
|
+
uuid
|
|
305
|
+
}, false);
|
|
306
|
+
return uuid;
|
|
307
|
+
}
|
|
308
|
+
async captureAiImmediate(props) {
|
|
309
|
+
if (this.disabled) return;
|
|
310
|
+
const uuid = getEventUuid(props.uuid, uuidv7);
|
|
311
|
+
await this._sendPreparedAiEvent({
|
|
312
|
+
...props,
|
|
313
|
+
uuid
|
|
314
|
+
}, true);
|
|
315
|
+
return uuid;
|
|
316
|
+
}
|
|
317
|
+
_sendPreparedAiEvent(props, immediate) {
|
|
318
|
+
if ('string' == typeof props?.event && !props.event.startsWith('$ai_')) this._logger.debug(`captureAi called with non-AI event ${props.event}; routing it to the AI endpoint anyway.`);
|
|
319
|
+
this._aiCaptureRouteActive = true;
|
|
320
|
+
return this._sendPreparedEvent('capture', props, immediate, void 0, AI_CAPTURE_ROUTE);
|
|
321
|
+
}
|
|
262
322
|
identify({ distinctId, properties = {}, disableGeoip }) {
|
|
263
323
|
const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
|
|
264
324
|
const setProps = $set || rest;
|
package/dist/types.d.ts
CHANGED
|
@@ -299,6 +299,13 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
|
|
|
299
299
|
* new PostHog('key', { isServer: false })
|
|
300
300
|
*/
|
|
301
301
|
isServer?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Capture full AI content: PostHog AI wrapper events route through the
|
|
304
|
+
* dedicated AI capture endpoint, skip string truncation, and pass media
|
|
305
|
+
* (base64 / data URIs) through unredacted. Privacy mode always wins.
|
|
306
|
+
* Defaults to false.
|
|
307
|
+
*/
|
|
308
|
+
enableFullAiCapture?: boolean;
|
|
302
309
|
} & ExceptionRateLimiterConfig;
|
|
303
310
|
export type PostHogFeatureFlag = {
|
|
304
311
|
id: number;
|
|
@@ -378,6 +385,29 @@ export interface IPostHog {
|
|
|
378
385
|
* @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values.
|
|
379
386
|
*/
|
|
380
387
|
captureImmediate({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): Promise<void>;
|
|
388
|
+
/**
|
|
389
|
+
* @description Capture an AI event on the dedicated AI capture endpoint.
|
|
390
|
+
* Beta: the signature is stable; operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async, and no redaction or truncation is applied to the payload.
|
|
391
|
+
* @param distinctId which uniquely identifies your user
|
|
392
|
+
* @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
|
|
393
|
+
* @param properties OPTIONAL | which can be a object with any information you'd like to add
|
|
394
|
+
* @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
|
|
395
|
+
* @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call.
|
|
396
|
+
* @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values.
|
|
397
|
+
* @returns The event UUID, or `undefined` when the client is disabled
|
|
398
|
+
*/
|
|
399
|
+
captureAi({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): string | undefined;
|
|
400
|
+
/**
|
|
401
|
+
* @description Capture an AI event on the dedicated AI capture endpoint, resolving after the send completes. Use in short-lived processes (serverless) where the runtime may freeze before a background flush runs.
|
|
402
|
+
* @param distinctId which uniquely identifies your user
|
|
403
|
+
* @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
|
|
404
|
+
* @param properties OPTIONAL | which can be a object with any information you'd like to add
|
|
405
|
+
* @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
|
|
406
|
+
* @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call.
|
|
407
|
+
* @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values.
|
|
408
|
+
* @returns The event UUID, or `undefined` when the client is disabled
|
|
409
|
+
*/
|
|
410
|
+
captureAiImmediate({ distinctId, event, properties, groups, flags, sendFeatureFlags, }: EventMessage): Promise<string | undefined>;
|
|
381
411
|
/**
|
|
382
412
|
* @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog,
|
|
383
413
|
* and even do things like segment users by these properties.
|
package/dist/types.d.ts.map
CHANGED
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;IAErC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnD;;;;OAIG;IACH,2BAA2B,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAEjE;;;OAGG;IACH,sBAAsB,IAAI,OAAO,CAAA;CAClC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.49.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
version: ()=>version
|
|
28
28
|
});
|
|
29
|
-
const version = '5.
|
|
29
|
+
const version = '5.49.0';
|
|
30
30
|
exports.version = __webpack_exports__.version;
|
|
31
31
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
32
32
|
"version"
|
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '5.
|
|
1
|
+
const version = '5.49.0';
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-node",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.49.0",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"module": "dist/entrypoints/index.node.mjs",
|
|
29
29
|
"types": "dist/entrypoints/index.node.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@posthog/core": "^1.
|
|
31
|
+
"@posthog/core": "^1.48.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@edge-runtime/jest-environment": "^4.0.0",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { PostHogEventProperties, safeJsonStringify } from '@posthog/core'
|
|
2
|
+
|
|
3
|
+
import { AI_BATCH_TARGET_BYTES, AI_MAX_EVENT_BYTES } from './routing'
|
|
4
|
+
|
|
5
|
+
const encoder = new TextEncoder()
|
|
6
|
+
|
|
7
|
+
export type AiBatchPartition = {
|
|
8
|
+
batches: PostHogEventProperties[][]
|
|
9
|
+
dropped: { event: string; bytes: number }[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function eventByteSize(message: PostHogEventProperties): number {
|
|
13
|
+
return encoder.encode(safeJsonStringify(message)).length
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function partitionAiBatch(
|
|
17
|
+
messages: (PostHogEventProperties | undefined)[],
|
|
18
|
+
maxEventBytes: number = AI_MAX_EVENT_BYTES,
|
|
19
|
+
targetBatchBytes: number = AI_BATCH_TARGET_BYTES
|
|
20
|
+
): AiBatchPartition {
|
|
21
|
+
const batches: PostHogEventProperties[][] = []
|
|
22
|
+
const dropped: { event: string; bytes: number }[] = []
|
|
23
|
+
let current: PostHogEventProperties[] = []
|
|
24
|
+
let currentBytes = 0
|
|
25
|
+
|
|
26
|
+
for (const message of messages) {
|
|
27
|
+
if (message === undefined) {
|
|
28
|
+
continue
|
|
29
|
+
}
|
|
30
|
+
const bytes = eventByteSize(message)
|
|
31
|
+
if (bytes > maxEventBytes) {
|
|
32
|
+
dropped.push({ event: typeof message.event === 'string' ? message.event : 'unknown', bytes })
|
|
33
|
+
continue
|
|
34
|
+
}
|
|
35
|
+
if (current.length > 0 && currentBytes + bytes > targetBatchBytes) {
|
|
36
|
+
batches.push(current)
|
|
37
|
+
current = []
|
|
38
|
+
currentBytes = 0
|
|
39
|
+
}
|
|
40
|
+
current.push(message)
|
|
41
|
+
currentBytes += bytes
|
|
42
|
+
}
|
|
43
|
+
if (current.length > 0) {
|
|
44
|
+
batches.push(current)
|
|
45
|
+
}
|
|
46
|
+
return { batches, dropped }
|
|
47
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { version } from './version'
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
FeatureFlagValue,
|
|
5
|
+
getEventUuid,
|
|
5
6
|
isBlockedUA,
|
|
6
7
|
isPlainObject,
|
|
8
|
+
isPostHogFetchContentTooLargeError,
|
|
7
9
|
JsonType,
|
|
8
10
|
minimizeFlagCalledEventProperties,
|
|
9
11
|
PostHogCaptureOptions,
|
|
@@ -58,6 +60,8 @@ import { ContextData, ContextOptions, IPostHogContext } from './extensions/conte
|
|
|
58
60
|
import { type CaptureMode, resolveCaptureMode } from './capture-v1/config'
|
|
59
61
|
import { AI_ROUTE, ANALYTICS_ROUTE, isLegacyOnlyEvent } from './capture-v1/routing'
|
|
60
62
|
import { V1CaptureSender } from './capture-v1/sender'
|
|
63
|
+
import { eventByteSize, partitionAiBatch } from './ai-capture/batching'
|
|
64
|
+
import { AI_CAPTURE_ENDPOINT_PATH, AI_CAPTURE_ROUTE, AI_MAX_EVENT_BYTES } from './ai-capture/routing'
|
|
61
65
|
|
|
62
66
|
// Standard local evaluation rate limit is 600 per minute (10 per second),
|
|
63
67
|
// so the fastest a poller should ever be set is 100ms.
|
|
@@ -143,6 +147,9 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
143
147
|
|
|
144
148
|
private readonly captureMode: CaptureMode
|
|
145
149
|
private _v1Sender?: V1CaptureSender
|
|
150
|
+
/** Whether this client captures full AI content: see `enableFullAiCapture` in `PostHogOptions`. */
|
|
151
|
+
public readonly enableFullAiCapture: boolean
|
|
152
|
+
private _aiCaptureRouteActive = false
|
|
146
153
|
|
|
147
154
|
// Feature flag overrides for local testing/development
|
|
148
155
|
private _flagOverrides?: Record<string, FeatureFlagValue>
|
|
@@ -209,6 +216,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
209
216
|
|
|
210
217
|
this.options = normalizedOptions
|
|
211
218
|
this.captureMode = resolveCaptureMode()
|
|
219
|
+
this.enableFullAiCapture = normalizedOptions.enableFullAiCapture === true
|
|
212
220
|
this.context = this.initializeContext()
|
|
213
221
|
|
|
214
222
|
this.options.featureFlagsPollingInterval =
|
|
@@ -262,8 +270,13 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
262
270
|
this.maxCacheSize = normalizedOptions.maxCacheSize || MAX_CACHE_SIZE
|
|
263
271
|
}
|
|
264
272
|
|
|
265
|
-
protected override enqueue(
|
|
266
|
-
|
|
273
|
+
protected override enqueue(
|
|
274
|
+
type: string,
|
|
275
|
+
message: any,
|
|
276
|
+
options?: PostHogCaptureOptions,
|
|
277
|
+
explicitRoute?: string
|
|
278
|
+
): void {
|
|
279
|
+
super.enqueue(type, message, options, explicitRoute)
|
|
267
280
|
this.scheduleDebouncedFlush()
|
|
268
281
|
}
|
|
269
282
|
|
|
@@ -433,13 +446,22 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
433
446
|
}
|
|
434
447
|
|
|
435
448
|
protected persistedQueueKeyForRoute(route: string): PostHogPersistedProperty {
|
|
449
|
+
if (route === AI_CAPTURE_ROUTE) {
|
|
450
|
+
return PostHogPersistedProperty.AiCaptureQueue
|
|
451
|
+
}
|
|
436
452
|
return route === AI_ROUTE ? PostHogPersistedProperty.AiQueue : PostHogPersistedProperty.Queue
|
|
437
453
|
}
|
|
438
454
|
|
|
439
455
|
protected getActiveQueueRoutes(): string[] {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
456
|
+
const routes = this.captureMode === 'v1' ? [ANALYTICS_ROUTE, AI_ROUTE] : [ANALYTICS_ROUTE]
|
|
457
|
+
if (this._aiCaptureRouteActive) {
|
|
458
|
+
routes.push(AI_CAPTURE_ROUTE)
|
|
459
|
+
}
|
|
460
|
+
return routes
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
protected getBatchEndpointPath(route: string): string {
|
|
464
|
+
return route === AI_CAPTURE_ROUTE ? AI_CAPTURE_ENDPOINT_PATH : super.getBatchEndpointPath(route)
|
|
443
465
|
}
|
|
444
466
|
|
|
445
467
|
/**
|
|
@@ -455,6 +477,10 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
455
477
|
retryOptions?: Partial<RetriableOptions>,
|
|
456
478
|
route: string = ANALYTICS_ROUTE
|
|
457
479
|
): Promise<void> {
|
|
480
|
+
if (route === AI_CAPTURE_ROUTE) {
|
|
481
|
+
return this.sendAiCaptureBatch(batchMessages, retryOptions)
|
|
482
|
+
}
|
|
483
|
+
|
|
458
484
|
if (this.captureMode !== 'v1' || route === AI_ROUTE) {
|
|
459
485
|
return super.sendBatch(batchMessages, retryOptions, route)
|
|
460
486
|
}
|
|
@@ -465,6 +491,46 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
465
491
|
await this.getV1Sender().sendV1Batch(v1Events)
|
|
466
492
|
}
|
|
467
493
|
|
|
494
|
+
private async sendAiCaptureBatch(
|
|
495
|
+
batchMessages: (PostHogEventProperties | undefined)[],
|
|
496
|
+
retryOptions?: Partial<RetriableOptions>
|
|
497
|
+
): Promise<void> {
|
|
498
|
+
const { batches, dropped } = partitionAiBatch(batchMessages)
|
|
499
|
+
for (const { event, bytes } of dropped) {
|
|
500
|
+
const message = `Event ${event} (${bytes} bytes) exceeds the ${AI_MAX_EVENT_BYTES / (1024 * 1024)}MiB limit for ${AI_CAPTURE_ENDPOINT_PATH}, dropping.`
|
|
501
|
+
this._logger.error(message)
|
|
502
|
+
this._events.emit('error', new Error(message))
|
|
503
|
+
}
|
|
504
|
+
for (const batch of batches) {
|
|
505
|
+
await this.sendAiSubBatch(batch, retryOptions)
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// A single-event 413 means the server's cap is below that event's size, so no split can save it.
|
|
510
|
+
private async sendAiSubBatch(
|
|
511
|
+
batch: PostHogEventProperties[],
|
|
512
|
+
retryOptions?: Partial<RetriableOptions>
|
|
513
|
+
): Promise<void> {
|
|
514
|
+
try {
|
|
515
|
+
await super.sendBatch(batch, retryOptions, AI_CAPTURE_ROUTE)
|
|
516
|
+
} catch (err) {
|
|
517
|
+
if (!isPostHogFetchContentTooLargeError(err)) {
|
|
518
|
+
throw err
|
|
519
|
+
}
|
|
520
|
+
if (batch.length === 1) {
|
|
521
|
+
const [event] = batch
|
|
522
|
+
const eventName = typeof event.event === 'string' ? event.event : 'unknown'
|
|
523
|
+
const message = `Event ${eventName} (${eventByteSize(event)} bytes) was rejected with 413 by ${AI_CAPTURE_ENDPOINT_PATH} on its own, dropping.`
|
|
524
|
+
this._logger.error(message)
|
|
525
|
+
this._events.emit('error', new Error(message))
|
|
526
|
+
return
|
|
527
|
+
}
|
|
528
|
+
const mid = Math.ceil(batch.length / 2)
|
|
529
|
+
await this.sendAiSubBatch(batch.slice(0, mid), retryOptions)
|
|
530
|
+
await this.sendAiSubBatch(batch.slice(mid), retryOptions)
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
468
534
|
private getV1Sender(): V1CaptureSender {
|
|
469
535
|
if (!this._v1Sender) {
|
|
470
536
|
this._v1Sender = new V1CaptureSender(
|
|
@@ -658,7 +724,8 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
658
724
|
type: string,
|
|
659
725
|
props: EventMessage,
|
|
660
726
|
immediate: boolean,
|
|
661
|
-
prepareOptions?: { includeContextProperties?: boolean }
|
|
727
|
+
prepareOptions?: { includeContextProperties?: boolean },
|
|
728
|
+
explicitRoute?: string
|
|
662
729
|
): Promise<void> {
|
|
663
730
|
return this.addPendingPromise(
|
|
664
731
|
this._prepareEventMessage(props, prepareOptions)
|
|
@@ -677,8 +744,8 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
677
744
|
},
|
|
678
745
|
}
|
|
679
746
|
return immediate
|
|
680
|
-
? this.sendImmediate(type, message, captureOptions)
|
|
681
|
-
: this.enqueue(type, message, captureOptions)
|
|
747
|
+
? this.sendImmediate(type, message, captureOptions, explicitRoute)
|
|
748
|
+
: this.enqueue(type, message, captureOptions, explicitRoute)
|
|
682
749
|
})
|
|
683
750
|
.catch((err) => {
|
|
684
751
|
if (err) {
|
|
@@ -771,6 +838,54 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
771
838
|
return this._capturePreparedEvent(props, true)
|
|
772
839
|
}
|
|
773
840
|
|
|
841
|
+
/**
|
|
842
|
+
* Capture an AI event on the dedicated AI capture endpoint.
|
|
843
|
+
*
|
|
844
|
+
* Beta: the signature is stable; operational limits (per-event size cap,
|
|
845
|
+
* batching, endpoint) may change without notice. Delivery is async, and no
|
|
846
|
+
* redaction or truncation is applied to the payload.
|
|
847
|
+
*
|
|
848
|
+
* {@label Capture}
|
|
849
|
+
*
|
|
850
|
+
* @param props - The event properties
|
|
851
|
+
* @returns The event UUID, or `undefined` when the client is disabled
|
|
852
|
+
*/
|
|
853
|
+
captureAi(props: EventMessage): string | undefined {
|
|
854
|
+
if (this.disabled) {
|
|
855
|
+
return undefined
|
|
856
|
+
}
|
|
857
|
+
const uuid = getEventUuid(props.uuid, uuidv7)
|
|
858
|
+
void this._sendPreparedAiEvent({ ...props, uuid }, false)
|
|
859
|
+
return uuid
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Capture an AI event on the dedicated AI capture endpoint, resolving after
|
|
864
|
+
* the send completes. Use in short-lived processes (serverless) where the
|
|
865
|
+
* runtime may freeze before a background flush runs.
|
|
866
|
+
*
|
|
867
|
+
* {@label Capture}
|
|
868
|
+
*
|
|
869
|
+
* @param props - The event properties
|
|
870
|
+
* @returns The event UUID, or `undefined` when the client is disabled
|
|
871
|
+
*/
|
|
872
|
+
async captureAiImmediate(props: EventMessage): Promise<string | undefined> {
|
|
873
|
+
if (this.disabled) {
|
|
874
|
+
return undefined
|
|
875
|
+
}
|
|
876
|
+
const uuid = getEventUuid(props.uuid, uuidv7)
|
|
877
|
+
await this._sendPreparedAiEvent({ ...props, uuid }, true)
|
|
878
|
+
return uuid
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
private _sendPreparedAiEvent(props: EventMessage, immediate: boolean): Promise<void> {
|
|
882
|
+
if (typeof props?.event === 'string' && !props.event.startsWith('$ai_')) {
|
|
883
|
+
this._logger.debug(`captureAi called with non-AI event ${props.event}; routing it to the AI endpoint anyway.`)
|
|
884
|
+
}
|
|
885
|
+
this._aiCaptureRouteActive = true
|
|
886
|
+
return this._sendPreparedEvent('capture', props, immediate, undefined, AI_CAPTURE_ROUTE)
|
|
887
|
+
}
|
|
888
|
+
|
|
774
889
|
/**
|
|
775
890
|
* Identify a user and set their properties.
|
|
776
891
|
*
|
package/src/types.ts
CHANGED
|
@@ -336,6 +336,13 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
|
|
|
336
336
|
* new PostHog('key', { isServer: false })
|
|
337
337
|
*/
|
|
338
338
|
isServer?: boolean
|
|
339
|
+
/**
|
|
340
|
+
* Capture full AI content: PostHog AI wrapper events route through the
|
|
341
|
+
* dedicated AI capture endpoint, skip string truncation, and pass media
|
|
342
|
+
* (base64 / data URIs) through unredacted. Privacy mode always wins.
|
|
343
|
+
* Defaults to false.
|
|
344
|
+
*/
|
|
345
|
+
enableFullAiCapture?: boolean
|
|
339
346
|
} & ExceptionRateLimiterConfig
|
|
340
347
|
|
|
341
348
|
export type PostHogFeatureFlag = {
|
|
@@ -425,6 +432,38 @@ export interface IPostHog {
|
|
|
425
432
|
*/
|
|
426
433
|
captureImmediate({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): Promise<void>
|
|
427
434
|
|
|
435
|
+
/**
|
|
436
|
+
* @description Capture an AI event on the dedicated AI capture endpoint.
|
|
437
|
+
* Beta: the signature is stable; operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async, and no redaction or truncation is applied to the payload.
|
|
438
|
+
* @param distinctId which uniquely identifies your user
|
|
439
|
+
* @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
|
|
440
|
+
* @param properties OPTIONAL | which can be a object with any information you'd like to add
|
|
441
|
+
* @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
|
|
442
|
+
* @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call.
|
|
443
|
+
* @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values.
|
|
444
|
+
* @returns The event UUID, or `undefined` when the client is disabled
|
|
445
|
+
*/
|
|
446
|
+
captureAi({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): string | undefined
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* @description Capture an AI event on the dedicated AI capture endpoint, resolving after the send completes. Use in short-lived processes (serverless) where the runtime may freeze before a background flush runs.
|
|
450
|
+
* @param distinctId which uniquely identifies your user
|
|
451
|
+
* @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
|
|
452
|
+
* @param properties OPTIONAL | which can be a object with any information you'd like to add
|
|
453
|
+
* @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
|
|
454
|
+
* @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call.
|
|
455
|
+
* @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values.
|
|
456
|
+
* @returns The event UUID, or `undefined` when the client is disabled
|
|
457
|
+
*/
|
|
458
|
+
captureAiImmediate({
|
|
459
|
+
distinctId,
|
|
460
|
+
event,
|
|
461
|
+
properties,
|
|
462
|
+
groups,
|
|
463
|
+
flags,
|
|
464
|
+
sendFeatureFlags,
|
|
465
|
+
}: EventMessage): Promise<string | undefined>
|
|
466
|
+
|
|
428
467
|
/**
|
|
429
468
|
* @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog,
|
|
430
469
|
* and even do things like segment users by these properties.
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.49.0'
|