posthog-node 6.2.3 → 6.3.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/MIGRATION.md CHANGED
@@ -266,7 +266,7 @@ Analytics events and `captureAi()` events use separate lanes. Each lane has its
266
266
 
267
267
  `captureAi()` and `captureAiImmediate()` send to `/i/v1/ai/events`. In 5.x.x they sent to the legacy AI endpoint.
268
268
 
269
- - **Large events.** The SDK drops an AI event whose `properties` are larger than 8 MiB before sending and reports it through `'error'`.
269
+ - **Large events.** The SDK sends an AI event whose `properties` are larger than 8 MiB without `$ai_input`, `$ai_output`, `$ai_output_choices`, `$ai_input_state`, `$ai_output_state` and `$ai_tools`, adds `$ai_content_removal_reason: 'event_too_large'` and `$ai_event_bytes_before_removal`, and logs one warning with the event name and sizes. If it's still over 8 MiB, or has none of those properties, the SDK drops it and reports it through `'error'`.
270
270
  - **Event names.** PostHog drops an event sent with `captureAi()` whose name doesn't start with `$ai_` (`misrouted_event`), and `'error'` reports it. Send other events with `capture()`.
271
271
  - **`@posthog/ai` on 6.x.x.** `@posthog/ai` sends every AI event with `captureAi()` when the client is posthog-node 6.x.x. `enableFullAiCapture` then controls only string truncation and media redaction.
272
272
  - **`@posthog/ai` on 5.x.x.** Nothing changes. AI events use `capture()` unless `enableFullAiCapture` is set.
@@ -0,0 +1,8 @@
1
+ import type { PostHogEventProperties } from '@posthog/core';
2
+ export declare const HEAVY_AI_PROPERTIES: readonly string[];
3
+ /**
4
+ * A copy of the message without its heavy AI properties and with the removal markers set, or
5
+ * undefined when it carries none of those properties, so there is nothing to remove.
6
+ */
7
+ export declare function removeAiContent(message: PostHogEventProperties, bytesBeforeRemoval: number): PostHogEventProperties | undefined;
8
+ //# sourceMappingURL=ai-content-removal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-content-removal.d.ts","sourceRoot":"","sources":["../../src/capture-lane/ai-content-removal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAE3D,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAOhD,CAAA;AAMD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,sBAAsB,EAC/B,kBAAkB,EAAE,MAAM,GACzB,sBAAsB,GAAG,SAAS,CAiBpC"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ const HEAVY_AI_PROPERTIES = [
31
+ '$ai_input',
32
+ '$ai_output',
33
+ '$ai_output_choices',
34
+ '$ai_input_state',
35
+ '$ai_output_state',
36
+ '$ai_tools'
37
+ ];
38
+ const CONTENT_REMOVAL_REASON_PROPERTY = '$ai_content_removal_reason';
39
+ const BYTES_BEFORE_REMOVAL_PROPERTY = '$ai_event_bytes_before_removal';
40
+ const EVENT_TOO_LARGE = 'event_too_large';
41
+ function removeAiContent(message, bytesBeforeRemoval) {
42
+ const properties = message.properties;
43
+ if ('object' != typeof properties || null === properties) return;
44
+ if (!HEAVY_AI_PROPERTIES.some((name)=>name in properties)) return;
45
+ const kept = Object.fromEntries(Object.entries(properties).filter(([name])=>!HEAVY_AI_PROPERTIES.includes(name)));
46
+ return {
47
+ ...message,
48
+ properties: {
49
+ ...kept,
50
+ [CONTENT_REMOVAL_REASON_PROPERTY]: EVENT_TOO_LARGE,
51
+ [BYTES_BEFORE_REMOVAL_PROPERTY]: bytesBeforeRemoval
52
+ }
53
+ };
54
+ }
55
+ __webpack_require__.d(__webpack_exports__, {
56
+ removeAiContent: ()=>removeAiContent
57
+ }, {
58
+ HEAVY_AI_PROPERTIES: HEAVY_AI_PROPERTIES
59
+ });
60
+ exports.HEAVY_AI_PROPERTIES = __webpack_exports__.HEAVY_AI_PROPERTIES;
61
+ exports.removeAiContent = __webpack_exports__.removeAiContent;
62
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
63
+ "HEAVY_AI_PROPERTIES",
64
+ "removeAiContent"
65
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
66
+ Object.defineProperty(exports, '__esModule', {
67
+ value: true
68
+ });
@@ -0,0 +1,26 @@
1
+ const HEAVY_AI_PROPERTIES = [
2
+ '$ai_input',
3
+ '$ai_output',
4
+ '$ai_output_choices',
5
+ '$ai_input_state',
6
+ '$ai_output_state',
7
+ '$ai_tools'
8
+ ];
9
+ const CONTENT_REMOVAL_REASON_PROPERTY = '$ai_content_removal_reason';
10
+ const BYTES_BEFORE_REMOVAL_PROPERTY = '$ai_event_bytes_before_removal';
11
+ const EVENT_TOO_LARGE = 'event_too_large';
12
+ function removeAiContent(message, bytesBeforeRemoval) {
13
+ const properties = message.properties;
14
+ if ('object' != typeof properties || null === properties) return;
15
+ if (!HEAVY_AI_PROPERTIES.some((name)=>name in properties)) return;
16
+ const kept = Object.fromEntries(Object.entries(properties).filter(([name])=>!HEAVY_AI_PROPERTIES.includes(name)));
17
+ return {
18
+ ...message,
19
+ properties: {
20
+ ...kept,
21
+ [CONTENT_REMOVAL_REASON_PROPERTY]: EVENT_TOO_LARGE,
22
+ [BYTES_BEFORE_REMOVAL_PROPERTY]: bytesBeforeRemoval
23
+ }
24
+ };
25
+ }
26
+ export { HEAVY_AI_PROPERTIES, removeAiContent };
@@ -22,6 +22,8 @@ export interface CaptureLaneConfig {
22
22
  maxEventBytes: number;
23
23
  /** Whether `maxEventBytes` applies to the whole serialized event or to its `properties` only. */
24
24
  maxEventBytesOf: 'event' | 'properties';
25
+ /** Whether an over-size event is retried without its heavy AI properties before it is dropped. */
26
+ removeAiContentWhenTooLarge: boolean;
25
27
  }
26
28
  export interface CaptureLaneHooks {
27
29
  sender: CaptureLaneSender;
@@ -34,6 +36,8 @@ export interface CaptureLaneHooks {
34
36
  onError: (error: unknown) => void;
35
37
  /** The messages one flush cycle sent. */
36
38
  onFlush: (messages: PostHogEventProperties[]) => void;
39
+ /** An over-size event the lane sends without its AI content. Not a loss, so it is not reported as a drop. */
40
+ onAiContentRemoved?: (event: string, bytesBeforeRemoval: number, bytesAfterRemoval: number, limit: number) => void;
37
41
  /** Each flush the lane starts on its own, from its timer or `flushAt`. */
38
42
  onBackgroundFlush?: (flush: Promise<void>) => void;
39
43
  logger: Logger;
@@ -78,6 +82,7 @@ export declare class CaptureLane {
78
82
  * message can carry event data.
79
83
  */
80
84
  private check;
85
+ private stripAiContent;
81
86
  /** Sends everything queued when the returned flush starts. Never rejects. */
82
87
  flush(): Promise<void>;
83
88
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"lane.d.ts","sourceRoot":"","sources":["../../src/capture-lane/lane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,sBAAsB,EAAkB,MAAM,eAAe,CAAA;AAExF,OAAO,EAAE,YAAY,EAAmE,MAAM,sBAAsB,CAAA;AACpH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,KAAK,iBAAiB,EAAiC,MAAM,yBAAyB,CAAA;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MA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;IACH,OAAO,CAAC,KAAK;IAgBb,OAAO,CAAC,cAAc;IA2BtB,6EAA6E;IAC7E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAarB;IAED;;;OAGG;IACG,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO7C;IAED;;;OAGG;IACH,cAAc,IAAI,IAAI,CAQrB;IAED,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,iBAAiB;YAQX,aAAa;IA+C3B,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,gBAAgB;IAMxB,oGAAoG;IACpG,OAAO,CAAC,WAAW;IA8CnB,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,OAAO;IAYf,OAAO,CAAC,MAAM;CAOf"}
@@ -33,6 +33,7 @@ __webpack_require__.d(__webpack_exports__, {
33
33
  const core_namespaceObject = require("@posthog/core");
34
34
  const errors_js_namespaceObject = require("../capture-v1/errors.js");
35
35
  const serialize_js_namespaceObject = require("../capture-v1/serialize.js");
36
+ const external_ai_content_removal_js_namespaceObject = require("./ai-content-removal.js");
36
37
  const MAX_REPORTED_LOCAL_DROPS = 100;
37
38
  const emptyTally = ()=>({
38
39
  queueFull: 0,
@@ -72,7 +73,7 @@ class CaptureLane {
72
73
  if (this.queue.length >= this.config.maxQueueSize) this.recordLocalDrop(this.queue.shift().uuid, 'queueFull');
73
74
  this.queue.push({
74
75
  ...checked.event,
75
- message
76
+ message: checked.message ?? message
76
77
  });
77
78
  if (this.queue.length >= this.config.flushAt) this.flushInBackground();
78
79
  else this.armFlushTimer();
@@ -115,13 +116,30 @@ class CaptureLane {
115
116
  drop: 'unserializable'
116
117
  };
117
118
  }
118
- return this.isTooLarge(event) ? {
119
+ if (!this.isTooLarge(event)) return {
120
+ event
121
+ };
122
+ return this.stripAiContent(message, event) ?? {
119
123
  uuid: event.uuid,
120
124
  drop: 'tooLarge'
121
- } : {
122
- event
123
125
  };
124
126
  }
127
+ stripAiContent(message, event) {
128
+ if (!this.config.removeAiContentWhenTooLarge) return;
129
+ try {
130
+ const stripped = (0, external_ai_content_removal_js_namespaceObject.removeAiContent)(message, event.propertiesBytes);
131
+ if (!stripped) return;
132
+ const strippedEvent = (0, serialize_js_namespaceObject.serializeV1Event)(stripped);
133
+ if (this.isTooLarge(strippedEvent)) return;
134
+ this.safely(()=>this.hooks.onAiContentRemoved?.(String(message.event), event.propertiesBytes, strippedEvent.propertiesBytes, this.config.maxEventBytes));
135
+ return {
136
+ event: strippedEvent,
137
+ message: stripped
138
+ };
139
+ } catch {
140
+ return;
141
+ }
142
+ }
125
143
  flush() {
126
144
  if (this.queuedFlush) return this.queuedFlush;
127
145
  if (!this.activeFlush) return this.startFlush();
@@ -1,6 +1,7 @@
1
1
  import { safeSetTimeout } from "@posthog/core";
2
2
  import { CaptureError, CaptureLossTally, describeCaptureLoss } from "../capture-v1/errors.mjs";
3
3
  import { serializeV1Event, wireProblem } from "../capture-v1/serialize.mjs";
4
+ import { removeAiContent } from "./ai-content-removal.mjs";
4
5
  const MAX_REPORTED_LOCAL_DROPS = 100;
5
6
  const emptyTally = ()=>({
6
7
  queueFull: 0,
@@ -40,7 +41,7 @@ class CaptureLane {
40
41
  if (this.queue.length >= this.config.maxQueueSize) this.recordLocalDrop(this.queue.shift().uuid, 'queueFull');
41
42
  this.queue.push({
42
43
  ...checked.event,
43
- message
44
+ message: checked.message ?? message
44
45
  });
45
46
  if (this.queue.length >= this.config.flushAt) this.flushInBackground();
46
47
  else this.armFlushTimer();
@@ -83,13 +84,30 @@ class CaptureLane {
83
84
  drop: 'unserializable'
84
85
  };
85
86
  }
86
- return this.isTooLarge(event) ? {
87
+ if (!this.isTooLarge(event)) return {
88
+ event
89
+ };
90
+ return this.stripAiContent(message, event) ?? {
87
91
  uuid: event.uuid,
88
92
  drop: 'tooLarge'
89
- } : {
90
- event
91
93
  };
92
94
  }
95
+ stripAiContent(message, event) {
96
+ if (!this.config.removeAiContentWhenTooLarge) return;
97
+ try {
98
+ const stripped = removeAiContent(message, event.propertiesBytes);
99
+ if (!stripped) return;
100
+ const strippedEvent = serializeV1Event(stripped);
101
+ if (this.isTooLarge(strippedEvent)) return;
102
+ this.safely(()=>this.hooks.onAiContentRemoved?.(String(message.event), event.propertiesBytes, strippedEvent.propertiesBytes, this.config.maxEventBytes));
103
+ return {
104
+ event: strippedEvent,
105
+ message: stripped
106
+ };
107
+ } catch {
108
+ return;
109
+ }
110
+ }
93
111
  flush() {
94
112
  if (this.queuedFlush) return this.queuedFlush;
95
113
  if (!this.activeFlush) return this.startFlush();
package/dist/client.d.ts CHANGED
@@ -289,7 +289,8 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
289
289
  */
290
290
  get logger(): CaptureLogger;
291
291
  /**
292
- * Send transactional email from PostHog templates or inline code, read send status, and update topic preferences.
292
+ * Send transactional email from PostHog templates, or transactional and marketing email from inline code, read send
293
+ * status, and update topic preferences.
293
294
  *
294
295
  * - **Credentials and scopes.** Needs `secretKey` (`phs_...`). `send` needs `transactional_email:write`, `get` needs `transactional_email:read` or `transactional_email:write`, `setPreferences` needs `messaging_preference:write`, and `hog_flow:write` keys cover all three. Set `enableLocalEvaluation: false` when the key is only for email.
295
296
  * - **Routing and retries.** Requests go to `appHost`, or the PostHog Cloud app host for `host`. Configure `emailRequestTimeoutMs` and `emailRequestMaxRetries` per client.
@@ -688,8 +689,9 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
688
689
  * Capture an AI event on the dedicated AI capture endpoint.
689
690
  *
690
691
  * Beta: the signature is stable; operational limits (per-event size cap,
691
- * batching, endpoint) may change without notice. Delivery is async, and no
692
- * redaction or truncation is applied to the payload.
692
+ * batching, endpoint) may change without notice. Delivery is async. The
693
+ * payload is sent as given, except that an event whose properties exceed the
694
+ * per-event size cap is sent without its content properties.
693
695
  *
694
696
  * {@label Capture}
695
697
  *
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,gBAAgB,EAGhB,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,+BAA+B,EAG/B,wBAAwB,EAGxB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAEtB,UAAU,EAOX,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EACV,OAAO,EACP,yBAAyB,EACzB,IAAI,EACJ,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,YAAY,EACZ,YAAY,EAGZ,4BAA4B,EAE5B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,2BAA2B,EAC3B,cAAc,EACd,oBAAoB,EAEpB,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,SAAS,CAAA;AAChB,OAAO,EAEL,sBAAsB,EAEtB,qBAAqB,EACtB,MAAM,4BAA4B,CAAA;AAsBnC,OAAO,aAAa,MAAM,6BAA6B,CAAA;AAGvD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAQzF,OAAO,EAAE,KAAK,iBAAiB,EAAsC,MAAM,0BAA0B,CAAA;AAiBrG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAyB5C;;GAEG;AACH,wBAAgB,iCAAiC,IAAI,IAAI,CAExD;AAiRD,8BAAsB,oBAAqB,SAAQ,oBAAqB,YAAW,QAAQ;IACzF,OAAO,CAAC,cAAc,CAA6B;IAEnD,OAAO,CAAC,kBAAkB,CAAC,CAAoB;IAC/C,SAAS,CAAC,aAAa,EAAE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;;;;;;;;;;;;;;;OAkBG;IACU,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAMnF;IAED;;;;;OAKG;YACW,oBAAoB;IA0IlC,OAAO,CAAC,cAAc;CAgCvB"}
package/dist/client.js CHANGED
@@ -461,6 +461,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
461
461
  onLocalDrops: (errors, summary)=>this._reportCaptureLoss(errors, summary),
462
462
  onError: (error)=>this._events.emit('error', error),
463
463
  onFlush: (messages)=>this._events.emit('flush', messages),
464
+ onAiContentRemoved: (event, bytesBeforeRemoval, bytesAfterRemoval, limit)=>console.warn(`[PostHog] Event ${event} has ${bytesBeforeRemoval} bytes of properties, over the ${limit} byte limit for AI events, so it is sent without its content (${bytesAfterRemoval} bytes)`),
464
465
  onBackgroundFlush: (flush)=>this._onLaneBackgroundFlush(flush),
465
466
  logger: this._logger
466
467
  });
@@ -479,7 +480,8 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
479
480
  maxQueueSize: isAi ? this._captureSettings.ai.maxQueueSize : Math.max(this.flushAt, this.options.maxQueueSize ?? 10000),
480
481
  targetBatchBytes: limits_js_namespaceObject.CAPTURE_BATCH_TARGET_BYTES,
481
482
  maxEventBytes: isAi ? limits_js_namespaceObject.AI_MAX_PROPERTIES_BYTES : limits_js_namespaceObject.ANALYTICS_MAX_EVENT_BYTES,
482
- maxEventBytesOf: isAi ? 'properties' : 'event'
483
+ maxEventBytesOf: isAi ? 'properties' : 'event',
484
+ removeAiContentWhenTooLarge: isAi
483
485
  };
484
486
  }
485
487
  _reportCaptureLoss(errors, summary) {
package/dist/client.mjs CHANGED
@@ -418,6 +418,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
418
418
  onLocalDrops: (errors, summary)=>this._reportCaptureLoss(errors, summary),
419
419
  onError: (error)=>this._events.emit('error', error),
420
420
  onFlush: (messages)=>this._events.emit('flush', messages),
421
+ onAiContentRemoved: (event, bytesBeforeRemoval, bytesAfterRemoval, limit)=>console.warn(`[PostHog] Event ${event} has ${bytesBeforeRemoval} bytes of properties, over the ${limit} byte limit for AI events, so it is sent without its content (${bytesAfterRemoval} bytes)`),
421
422
  onBackgroundFlush: (flush)=>this._onLaneBackgroundFlush(flush),
422
423
  logger: this._logger
423
424
  });
@@ -436,7 +437,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
436
437
  maxQueueSize: isAi ? this._captureSettings.ai.maxQueueSize : Math.max(this.flushAt, this.options.maxQueueSize ?? 10000),
437
438
  targetBatchBytes: CAPTURE_BATCH_TARGET_BYTES,
438
439
  maxEventBytes: isAi ? AI_MAX_PROPERTIES_BYTES : ANALYTICS_MAX_EVENT_BYTES,
439
- maxEventBytesOf: isAi ? 'properties' : 'event'
440
+ maxEventBytesOf: isAi ? 'properties' : 'event',
441
+ removeAiContentWhenTooLarge: isAi
440
442
  };
441
443
  }
442
444
  _reportCaptureLoss(errors, summary) {
@@ -23,9 +23,9 @@ export interface EmailSenderHooks {
23
23
  userAgent?: string;
24
24
  }
25
25
  /**
26
- * Sends one transactional email per call to the messaging send API on the app host, reads the
27
- * status of a sent email, and sets a recipient's topic preferences. Owns the attempt loop, so every
28
- * attempt of a send carries the same idempotency key.
26
+ * Sends one transactional or marketing email per call to the messaging send API on the app host,
27
+ * reads the status of a sent email, and sets a recipient's topic preferences. Owns the attempt
28
+ * loop, so every attempt of a send carries the same idempotency key.
29
29
  */
30
30
  export declare class EmailSender implements Emails {
31
31
  private readonly config;
@@ -1 +1 @@
1
- {"version":3,"file":"emails.d.ts","sourceRoot":"","sources":["../../src/emails/emails.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAI1B,MAAM,eAAe,CAAA;AAYtB,OAAO,KAAK,EAIV,kBAAkB,EAGlB,MAAM,EACN,gBAAgB,EAEhB,gBAAgB,EAChB,iBAAiB,EAGjB,0BAA0B,E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AA;IACzB,QAAQ,EAAE,MAAM,OAAO,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAuBD;;;;GAIG;AACH,qBAAa,WAAY,YAAW,MAAM;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IAEvD,YAAY,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,gBAAgB,EAG7D;IAED,IAAI,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAEpF;IAED,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEzC;IAED,cAAc,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAExF;IAED,OAAO,CAAC,KAAK;IAMb;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;YAEa,aAAa;YAiCb,YAAY;YAoBZ,iBAAiB;YAsCjB,UAAU;YA0CV,uBAAuB;IAiBrC,OAAO,CAAC,OAAO;IA6Bf,OAAO,CAAC,OAAO;YAeD,WAAW;YAwBX,OAAO;CA6DtB"}
@@ -76,12 +76,13 @@ const CODE_FIELDS = {
76
76
  tracking: true,
77
77
  html: true,
78
78
  text: true,
79
- react: true
79
+ react: true,
80
+ category: true
80
81
  };
81
82
  const TEMPLATE_FORM = {
82
83
  name: 'templateId',
83
84
  fields: fieldSet(SHARED_FIELDS, TEMPLATE_FIELDS),
84
- why: "A template made in PostHog sets its own sender, subject and content, and follows the project's engagement setting.",
85
+ why: "A template made in PostHog sets its own sender, subject, content and category, and follows the project's engagement setting.",
85
86
  howToSend: 'send a template made in PostHog with templateId'
86
87
  };
87
88
  const CODE_FORM = {
@@ -457,7 +458,8 @@ function codeContent(send, distinctId) {
457
458
  };
458
459
  }
459
460
  function codeFormFields(send) {
460
- const { from, replyTo, cc, bcc, captureEngagement, sensitive, tracking } = send;
461
+ const { from, replyTo, cc, bcc, captureEngagement, sensitive, tracking, category } = send;
462
+ if (void 0 !== category && 'string' != typeof category) throw invalid('invalid_form', 'category must be the key of a message category, as a string.', 'category');
461
463
  return {
462
464
  ...void 0 !== from && {
463
465
  from
@@ -473,6 +475,9 @@ function codeFormFields(send) {
473
475
  },
474
476
  ...void 0 !== tracking && {
475
477
  tracking
478
+ },
479
+ ...void 0 !== category && {
480
+ category
476
481
  }
477
482
  };
478
483
  }
@@ -42,12 +42,13 @@ const CODE_FIELDS = {
42
42
  tracking: true,
43
43
  html: true,
44
44
  text: true,
45
- react: true
45
+ react: true,
46
+ category: true
46
47
  };
47
48
  const TEMPLATE_FORM = {
48
49
  name: 'templateId',
49
50
  fields: fieldSet(SHARED_FIELDS, TEMPLATE_FIELDS),
50
- why: "A template made in PostHog sets its own sender, subject and content, and follows the project's engagement setting.",
51
+ why: "A template made in PostHog sets its own sender, subject, content and category, and follows the project's engagement setting.",
51
52
  howToSend: 'send a template made in PostHog with templateId'
52
53
  };
53
54
  const CODE_FORM = {
@@ -423,7 +424,8 @@ function codeContent(send, distinctId) {
423
424
  };
424
425
  }
425
426
  function codeFormFields(send) {
426
- const { from, replyTo, cc, bcc, captureEngagement, sensitive, tracking } = send;
427
+ const { from, replyTo, cc, bcc, captureEngagement, sensitive, tracking, category } = send;
428
+ if (void 0 !== category && 'string' != typeof category) throw invalid('invalid_form', 'category must be the key of a message category, as a string.', 'category');
427
429
  return {
428
430
  ...void 0 !== from && {
429
431
  from
@@ -439,6 +441,9 @@ function codeFormFields(send) {
439
441
  },
440
442
  ...void 0 !== tracking && {
441
443
  tracking
444
+ },
445
+ ...void 0 !== category && {
446
+ category
442
447
  }
443
448
  };
444
449
  }
@@ -86,6 +86,19 @@ interface CodeEmailFields {
86
86
  * click tracking. Needs posthog-node 5.71.0 or later.
87
87
  */
88
88
  tracking?: boolean | EmailTracking;
89
+ /**
90
+ * The key of one of the project's message categories, such as `'newsletter'`, for the email
91
+ * your code rendered. A marketing category skips recipients who opted out of it or of all
92
+ * marketing email, fills `{{ unsubscribe_url }}` with the recipient's preferences link, and
93
+ * adds List-Unsubscribe headers. A marketing email can't have `cc` or `bcc`.
94
+ *
95
+ * PostHog refuses the send with `category_not_found` when the project has no category with this
96
+ * key, `marketing_copies_unsupported` when a marketing email has `cc` or `bcc`, and
97
+ * `sandbox_fields_unsupported` when a marketing email would go out from PostHog's test sender
98
+ * because the project has no verified sending domain. A marketing email with `attachments` is
99
+ * refused with `workflow_can_wait` (verified sender) or `sandbox_fields_unsupported` (test sender).
100
+ */
101
+ category?: string;
89
102
  }
90
103
  /** Which kinds of tracking a send with `templateKey` turns on. */
91
104
  export interface EmailTracking {
@@ -280,13 +293,14 @@ export type SetEmailPreferencesResponse = {
280
293
  error: EmailError;
281
294
  };
282
295
  /**
283
- * The `posthog.emails` API: sends transactional email from PostHog email templates or from
284
- * content your code rendered, reads the status of each email it sent, and sets a recipient's
285
- * topic preferences.
296
+ * The `posthog.emails` API: sends transactional email from PostHog email templates, or
297
+ * transactional and marketing email from content your code rendered, reads the status of each
298
+ * email it sent, and sets a recipient's topic preferences.
286
299
  */
287
300
  export interface Emails {
288
301
  /**
289
- * Queue one email, from a transactional email template or from content your code rendered.
302
+ * Queue one email: a transactional email from a PostHog email template, or a transactional or
303
+ * marketing email from content your code rendered.
290
304
  *
291
305
  * Resolves to `{ data, error }` and does not reject. `data` means PostHog queued the email,
292
306
  * not that it was delivered. `error` is an `EmailError`: branch on its `code`.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/emails/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,mC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M,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAA;AAErG;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,mHAAmH;IACnH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACjC;AAED,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,2HAA2H;IAC3H,YAAY,EAAE,OAAO,GAAG,IAAI,CAAA;IAC5B,kGAAkG;IAClG,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC;AAED;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAA;AAErH;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;;;;;;;;OAkBG;IACH,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAE3D;;;;;;;;;;OAUG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAE1C;;;;;;;;;OASG;IACH,cAAc,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;CAC1F"}
package/dist/types.d.ts CHANGED
@@ -807,7 +807,7 @@ export interface IPostHog {
807
807
  /**
808
808
  * Capture an AI event on the dedicated AI capture endpoint (`/i/v1/ai/events`).
809
809
  *
810
- * Beta: the signature is stable, while operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async with no redaction or truncation.
810
+ * Beta: the signature is stable, while operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async. The payload is sent as given, except that an event whose properties exceed the per-event size cap is sent without its content properties.
811
811
  *
812
812
  * @param props - AI event payload including `event`, optional `distinctId`, `properties`, `groups`, `flags`, and `options`
813
813
  * @returns The event UUID, or `undefined` when the client is disabled
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "6.2.3";
1
+ export declare const version = "6.3.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -27,7 +27,7 @@ var __webpack_require__ = {};
27
27
  })();
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
- const version = "6.2.3";
30
+ const version = "6.3.0";
31
31
  __webpack_require__.d(__webpack_exports__, {}, {
32
32
  version: version
33
33
  });
package/dist/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- const version = "6.2.3";
1
+ const version = "6.3.0";
2
2
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-node",
3
- "version": "6.2.3",
3
+ "version": "6.3.0",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -30,7 +30,7 @@
30
30
  "module": "dist/entrypoints/index.node.mjs",
31
31
  "types": "dist/entrypoints/index.node.d.ts",
32
32
  "dependencies": {
33
- "@posthog/core": "^1.69.8"
33
+ "@posthog/core": "^1.69.9"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@edge-runtime/vm": "^5.0.0",
@@ -51,8 +51,8 @@
51
51
  "rxjs": "^7.8.0",
52
52
  "typescript": "7.0.2",
53
53
  "vitest": "^1.6.1",
54
- "@posthog/types": "^1.428.0",
55
- "@posthog-tooling/tsconfig-base": "1.1.1"
54
+ "@posthog-tooling/tsconfig-base": "1.1.1",
55
+ "@posthog/types": "^1.428.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@opentelemetry/api": "^1.2.0",
@@ -0,0 +1,40 @@
1
+ import type { PostHogEventProperties } from '@posthog/core'
2
+
3
+ export const HEAVY_AI_PROPERTIES: readonly string[] = [
4
+ '$ai_input',
5
+ '$ai_output',
6
+ '$ai_output_choices',
7
+ '$ai_input_state',
8
+ '$ai_output_state',
9
+ '$ai_tools',
10
+ ]
11
+
12
+ const CONTENT_REMOVAL_REASON_PROPERTY = '$ai_content_removal_reason'
13
+ const BYTES_BEFORE_REMOVAL_PROPERTY = '$ai_event_bytes_before_removal'
14
+ const EVENT_TOO_LARGE = 'event_too_large'
15
+
16
+ /**
17
+ * A copy of the message without its heavy AI properties and with the removal markers set, or
18
+ * undefined when it carries none of those properties, so there is nothing to remove.
19
+ */
20
+ export function removeAiContent(
21
+ message: PostHogEventProperties,
22
+ bytesBeforeRemoval: number
23
+ ): PostHogEventProperties | undefined {
24
+ const properties = message.properties
25
+ if (typeof properties !== 'object' || properties === null) {
26
+ return undefined
27
+ }
28
+ if (!HEAVY_AI_PROPERTIES.some((name) => name in properties)) {
29
+ return undefined
30
+ }
31
+ const kept = Object.fromEntries(Object.entries(properties).filter(([name]) => !HEAVY_AI_PROPERTIES.includes(name)))
32
+ return {
33
+ ...message,
34
+ properties: {
35
+ ...kept,
36
+ [CONTENT_REMOVAL_REASON_PROPERTY]: EVENT_TOO_LARGE,
37
+ [BYTES_BEFORE_REMOVAL_PROPERTY]: bytesBeforeRemoval,
38
+ },
39
+ }
40
+ }
@@ -4,6 +4,7 @@ import { CaptureError, CaptureLossTally, type CaptureDroppedEvent, describeCaptu
4
4
  import type { V1SendOptions } from '../capture-v1/sender'
5
5
  import { type SerializedV1Event, serializeV1Event, wireProblem } from '../capture-v1/serialize'
6
6
  import type { CaptureEndpoint } from '../capture-v1/types'
7
+ import { removeAiContent } from './ai-content-removal'
7
8
 
8
9
  /** Upper bound on the uuids one local-drop report lists; the message still carries the full count. */
9
10
  const MAX_REPORTED_LOCAL_DROPS = 100
@@ -28,6 +29,8 @@ export interface CaptureLaneConfig {
28
29
  maxEventBytes: number
29
30
  /** Whether `maxEventBytes` applies to the whole serialized event or to its `properties` only. */
30
31
  maxEventBytesOf: 'event' | 'properties'
32
+ /** Whether an over-size event is retried without its heavy AI properties before it is dropped. */
33
+ removeAiContentWhenTooLarge: boolean
31
34
  }
32
35
 
33
36
  export interface CaptureLaneHooks {
@@ -41,6 +44,8 @@ export interface CaptureLaneHooks {
41
44
  onError: (error: unknown) => void
42
45
  /** The messages one flush cycle sent. */
43
46
  onFlush: (messages: PostHogEventProperties[]) => void
47
+ /** An over-size event the lane sends without its AI content. Not a loss, so it is not reported as a drop. */
48
+ onAiContentRemoved?: (event: string, bytesBeforeRemoval: number, bytesAfterRemoval: number, limit: number) => void
44
49
  /** Each flush the lane starts on its own, from its timer or `flushAt`. */
45
50
  onBackgroundFlush?: (flush: Promise<void>) => void
46
51
  logger: Logger
@@ -71,7 +76,9 @@ const LOCAL_DROP_DETAILS: Record<LocalDropReason, string> = {
71
76
  }
72
77
 
73
78
  /** An event ready to send, or the uuid and reason of one dropped before sending. */
74
- type CheckedEvent = { event: SerializedV1Event } | { uuid: string; drop: LocalDropReason }
79
+ type CheckedEvent =
80
+ | { event: SerializedV1Event; message?: PostHogEventProperties }
81
+ | { uuid: string; drop: LocalDropReason }
75
82
 
76
83
  /**
77
84
  * One capture endpoint's in-memory queue, flush timer, `flushAt` trigger, batching and
@@ -119,7 +126,7 @@ export class CaptureLane {
119
126
  if (this.queue.length >= this.config.maxQueueSize) {
120
127
  this.recordLocalDrop(this.queue.shift()!.uuid, 'queueFull')
121
128
  }
122
- this.queue.push({ ...checked.event, message })
129
+ this.queue.push({ ...checked.event, message: checked.message ?? message })
123
130
 
124
131
  if (this.queue.length >= this.config.flushAt) {
125
132
  this.flushInBackground()
@@ -172,7 +179,37 @@ export class CaptureLane {
172
179
  } catch {
173
180
  return { uuid: String(message.uuid), drop: 'unserializable' }
174
181
  }
175
- return this.isTooLarge(event) ? { uuid: event.uuid, drop: 'tooLarge' } : { event }
182
+ if (!this.isTooLarge(event)) {
183
+ return { event }
184
+ }
185
+ return this.stripAiContent(message, event) ?? { uuid: event.uuid, drop: 'tooLarge' }
186
+ }
187
+
188
+ private stripAiContent(message: PostHogEventProperties, event: SerializedV1Event): CheckedEvent | undefined {
189
+ if (!this.config.removeAiContentWhenTooLarge) {
190
+ return undefined
191
+ }
192
+ try {
193
+ const stripped = removeAiContent(message, event.propertiesBytes)
194
+ if (!stripped) {
195
+ return undefined
196
+ }
197
+ const strippedEvent = serializeV1Event(stripped)
198
+ if (this.isTooLarge(strippedEvent)) {
199
+ return undefined
200
+ }
201
+ this.safely(() =>
202
+ this.hooks.onAiContentRemoved?.(
203
+ String(message.event),
204
+ event.propertiesBytes,
205
+ strippedEvent.propertiesBytes,
206
+ this.config.maxEventBytes
207
+ )
208
+ )
209
+ return { event: strippedEvent, message: stripped }
210
+ } catch {
211
+ return undefined
212
+ }
176
213
  }
177
214
 
178
215
  /** Sends everything queued when the returned flush starts. Never rejects. */
package/src/client.ts CHANGED
@@ -964,6 +964,11 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
964
964
  onLocalDrops: (errors, summary) => this._reportCaptureLoss(errors, summary),
965
965
  onError: (error) => this._events.emit('error', error),
966
966
  onFlush: (messages) => this._events.emit('flush', messages),
967
+ onAiContentRemoved: (event, bytesBeforeRemoval, bytesAfterRemoval, limit) =>
968
+ // console.warn, not this._logger: the logger only prints in debug mode. Names and sizes only, never content.
969
+ console.warn(
970
+ `[PostHog] Event ${event} has ${bytesBeforeRemoval} bytes of properties, over the ${limit} byte limit for AI events, so it is sent without its content (${bytesAfterRemoval} bytes)`
971
+ ),
967
972
  onBackgroundFlush: (flush) => this._onLaneBackgroundFlush(flush),
968
973
  logger: this._logger,
969
974
  })
@@ -988,6 +993,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
988
993
  targetBatchBytes: CAPTURE_BATCH_TARGET_BYTES,
989
994
  maxEventBytes: isAi ? AI_MAX_PROPERTIES_BYTES : ANALYTICS_MAX_EVENT_BYTES,
990
995
  maxEventBytesOf: isAi ? 'properties' : 'event',
996
+ removeAiContentWhenTooLarge: isAi,
991
997
  }
992
998
  }
993
999
 
@@ -1175,7 +1181,8 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
1175
1181
  }
1176
1182
 
1177
1183
  /**
1178
- * Send transactional email from PostHog templates or inline code, read send status, and update topic preferences.
1184
+ * Send transactional email from PostHog templates, or transactional and marketing email from inline code, read send
1185
+ * status, and update topic preferences.
1179
1186
  *
1180
1187
  * - **Credentials and scopes.** Needs `secretKey` (`phs_...`). `send` needs `transactional_email:write`, `get` needs `transactional_email:read` or `transactional_email:write`, `setPreferences` needs `messaging_preference:write`, and `hog_flow:write` keys cover all three. Set `enableLocalEvaluation: false` when the key is only for email.
1181
1188
  * - **Routing and retries.** Requests go to `appHost`, or the PostHog Cloud app host for `host`. Configure `emailRequestTimeoutMs` and `emailRequestMaxRetries` per client.
@@ -1886,8 +1893,9 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
1886
1893
  * Capture an AI event on the dedicated AI capture endpoint.
1887
1894
  *
1888
1895
  * Beta: the signature is stable; operational limits (per-event size cap,
1889
- * batching, endpoint) may change without notice. Delivery is async, and no
1890
- * redaction or truncation is applied to the payload.
1896
+ * batching, endpoint) may change without notice. Delivery is async. The
1897
+ * payload is sent as given, except that an event whose properties exceed the
1898
+ * per-event size cap is sent without its content properties.
1891
1899
  *
1892
1900
  * {@label Capture}
1893
1901
  *
@@ -85,11 +85,12 @@ const CODE_FIELDS: EveryField<CodeEmailForm> = {
85
85
  html: true,
86
86
  text: true,
87
87
  react: true,
88
+ category: true,
88
89
  }
89
90
  const TEMPLATE_FORM: SendForm = {
90
91
  name: 'templateId',
91
92
  fields: fieldSet(SHARED_FIELDS, TEMPLATE_FIELDS),
92
- why: "A template made in PostHog sets its own sender, subject and content, and follows the project's engagement setting.",
93
+ why: "A template made in PostHog sets its own sender, subject, content and category, and follows the project's engagement setting.",
93
94
  howToSend: 'send a template made in PostHog with templateId',
94
95
  }
95
96
  const CODE_FORM: SendForm = {
@@ -147,9 +148,9 @@ interface Reply {
147
148
  }
148
149
 
149
150
  /**
150
- * Sends one transactional email per call to the messaging send API on the app host, reads the
151
- * status of a sent email, and sets a recipient's topic preferences. Owns the attempt loop, so every
152
- * attempt of a send carries the same idempotency key.
151
+ * Sends one transactional or marketing email per call to the messaging send API on the app host,
152
+ * reads the status of a sent email, and sets a recipient's topic preferences. Owns the attempt
153
+ * loop, so every attempt of a send carries the same idempotency key.
153
154
  */
154
155
  export class EmailSender implements Emails {
155
156
  private readonly config: EmailSenderConfig
@@ -624,7 +625,10 @@ function codeContent(send: UncheckedSend, distinctId: string | undefined): SendC
624
625
  }
625
626
 
626
627
  function codeFormFields(send: UncheckedSend): Record<string, unknown> {
627
- const { from, replyTo, cc, bcc, captureEngagement, sensitive, tracking } = send
628
+ const { from, replyTo, cc, bcc, captureEngagement, sensitive, tracking, category } = send
629
+ if (category !== undefined && typeof category !== 'string') {
630
+ throw invalid('invalid_form', 'category must be the key of a message category, as a string.', 'category')
631
+ }
628
632
  return {
629
633
  ...(from !== undefined && { from }),
630
634
  ...(replyTo !== undefined && unlessEmpty('reply_to', addressList(replyTo))),
@@ -633,6 +637,7 @@ function codeFormFields(send: UncheckedSend): Record<string, unknown> {
633
637
  ...(captureEngagement !== undefined && { capture_engagement: captureEngagement }),
634
638
  ...(sensitive !== undefined && { sensitive }),
635
639
  ...(tracking !== undefined && { tracking }),
640
+ ...(category !== undefined && { category }),
636
641
  }
637
642
  }
638
643
 
@@ -89,6 +89,19 @@ interface CodeEmailFields {
89
89
  * click tracking. Needs posthog-node 5.71.0 or later.
90
90
  */
91
91
  tracking?: boolean | EmailTracking
92
+ /**
93
+ * The key of one of the project's message categories, such as `'newsletter'`, for the email
94
+ * your code rendered. A marketing category skips recipients who opted out of it or of all
95
+ * marketing email, fills `{{ unsubscribe_url }}` with the recipient's preferences link, and
96
+ * adds List-Unsubscribe headers. A marketing email can't have `cc` or `bcc`.
97
+ *
98
+ * PostHog refuses the send with `category_not_found` when the project has no category with this
99
+ * key, `marketing_copies_unsupported` when a marketing email has `cc` or `bcc`, and
100
+ * `sandbox_fields_unsupported` when a marketing email would go out from PostHog's test sender
101
+ * because the project has no verified sending domain. A marketing email with `attachments` is
102
+ * refused with `workflow_can_wait` (verified sender) or `sandbox_fields_unsupported` (test sender).
103
+ */
104
+ category?: string
92
105
  }
93
106
 
94
107
  /** Which kinds of tracking a send with `templateKey` turns on. */
@@ -277,13 +290,14 @@ export interface EmailPreferences {
277
290
  export type SetEmailPreferencesResponse = { data: EmailPreferences; error: null } | { data: null; error: EmailError }
278
291
 
279
292
  /**
280
- * The `posthog.emails` API: sends transactional email from PostHog email templates or from
281
- * content your code rendered, reads the status of each email it sent, and sets a recipient's
282
- * topic preferences.
293
+ * The `posthog.emails` API: sends transactional email from PostHog email templates, or
294
+ * transactional and marketing email from content your code rendered, reads the status of each
295
+ * email it sent, and sets a recipient's topic preferences.
283
296
  */
284
297
  export interface Emails {
285
298
  /**
286
- * Queue one email, from a transactional email template or from content your code rendered.
299
+ * Queue one email: a transactional email from a PostHog email template, or a transactional or
300
+ * marketing email from content your code rendered.
287
301
  *
288
302
  * Resolves to `{ data, error }` and does not reject. `data` means PostHog queued the email,
289
303
  * not that it was delivered. `error` is an `EmailError`: branch on its `code`.
package/src/types.ts CHANGED
@@ -877,7 +877,7 @@ export interface IPostHog {
877
877
  /**
878
878
  * Capture an AI event on the dedicated AI capture endpoint (`/i/v1/ai/events`).
879
879
  *
880
- * Beta: the signature is stable, while operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async with no redaction or truncation.
880
+ * Beta: the signature is stable, while operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async. The payload is sent as given, except that an event whose properties exceed the per-event size cap is sent without its content properties.
881
881
  *
882
882
  * @param props - AI event payload including `event`, optional `distinctId`, `properties`, `groups`, `flags`, and `options`
883
883
  * @returns The event UUID, or `undefined` when the client is disabled
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "6.2.3"
1
+ export const version = "6.3.0"