posthog-node 6.2.2 → 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 +1 -1
- package/dist/capture-lane/ai-content-removal.d.ts +8 -0
- package/dist/capture-lane/ai-content-removal.d.ts.map +1 -0
- package/dist/capture-lane/ai-content-removal.js +68 -0
- package/dist/capture-lane/ai-content-removal.mjs +26 -0
- package/dist/capture-lane/lane.d.ts +5 -0
- package/dist/capture-lane/lane.d.ts.map +1 -1
- package/dist/capture-lane/lane.js +22 -4
- package/dist/capture-lane/lane.mjs +22 -4
- package/dist/client.d.ts +5 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -1
- package/dist/client.mjs +3 -1
- package/dist/emails/emails.d.ts +3 -3
- package/dist/emails/emails.d.ts.map +1 -1
- package/dist/emails/emails.js +8 -3
- package/dist/emails/emails.mjs +8 -3
- package/dist/emails/errors.d.ts +8 -1
- package/dist/emails/errors.d.ts.map +1 -1
- package/dist/emails/types.d.ts +59 -19
- package/dist/emails/types.d.ts.map +1 -1
- package/dist/types.d.ts +16 -8
- 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 +4 -4
- package/src/capture-lane/ai-content-removal.ts +40 -0
- package/src/capture-lane/lane.ts +40 -3
- package/src/client.ts +11 -3
- package/src/emails/emails.ts +10 -5
- package/src/emails/errors.ts +8 -1
- package/src/emails/types.ts +59 -19
- package/src/types.ts +16 -8
- package/src/version.ts +1 -1
package/src/emails/types.ts
CHANGED
|
@@ -14,14 +14,18 @@ export interface SendEmailBase {
|
|
|
14
14
|
* queues nothing and returns the first send's result. The same key with other options sends
|
|
15
15
|
* nothing and returns an error with code `idempotency_key_reused`. Without it, the client makes a UUID that
|
|
16
16
|
* covers its own retries. Pass a key derived from what the email is for, such as
|
|
17
|
-
* `welcome:user_123`, to cover retries outside this call too.
|
|
17
|
+
* `welcome:user_123`, to cover retries outside this call too. PostHog keeps a key for 7 days
|
|
18
|
+
* after it queues the email, so finish every retry within 7 days.
|
|
18
19
|
*/
|
|
19
20
|
idempotencyKey?: string
|
|
20
21
|
/** Overrides the client's `emailRequestMaxRetries` for this send. `0` turns retries off. */
|
|
21
22
|
maxRetries?: number
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* A template made transactional in PostHog, sent by its ID. Needs posthog-node 5.61.0 or later.
|
|
27
|
+
* A template send takes no subject, body, sender, copies, or attachments: the template sets them.
|
|
28
|
+
*/
|
|
25
29
|
export interface TemplateEmailForm {
|
|
26
30
|
/** The UUID of an email template made transactional in PostHog. */
|
|
27
31
|
templateId: string
|
|
@@ -35,18 +39,21 @@ interface CodeEmailFields {
|
|
|
35
39
|
* in PostHog. Letters, digits, hyphens and underscores, at most 400.
|
|
36
40
|
*/
|
|
37
41
|
templateKey: string
|
|
42
|
+
/** The subject line. */
|
|
38
43
|
subject: string
|
|
39
44
|
/** A verified sender, such as `'Acme <security@example.com>'`. Without it, the project's default sender. */
|
|
40
45
|
from?: string
|
|
46
|
+
/** One address or a list of addresses that replies go to. */
|
|
41
47
|
replyTo?: string | string[]
|
|
42
|
-
/** Bare addresses, such as `'finance@example.com'`, that get a copy. */
|
|
48
|
+
/** Bare addresses, such as `'finance@example.com'`, that get a copy. Needs posthog-node 5.72.0 or later. */
|
|
43
49
|
cc?: string | string[]
|
|
44
|
-
/** Bare addresses that get a copy the other recipients never see. */
|
|
50
|
+
/** Bare addresses that get a copy the other recipients never see. Needs posthog-node 5.72.0 or later. */
|
|
45
51
|
bcc?: string | string[]
|
|
46
52
|
/**
|
|
47
53
|
* Files sent with the email: at most 10, and at most 40 MB for the whole email after Base64
|
|
48
54
|
* encoding, about 29 MB of files. The SDK checks both before any request. It uploads each file
|
|
49
55
|
* PostHog doesn't have yet, then sends the email. When an upload fails, it sends nothing.
|
|
56
|
+
* Needs posthog-node 5.72.0 or later.
|
|
50
57
|
*/
|
|
51
58
|
attachments?: EmailAttachment[]
|
|
52
59
|
/**
|
|
@@ -66,7 +73,7 @@ interface CodeEmailFields {
|
|
|
66
73
|
*
|
|
67
74
|
* Without it, a send whose `templateKey` matches a template saved in PostHog follows that
|
|
68
75
|
* template's setting, and any other send is sensitive. PostHog refuses `sensitive: false` when
|
|
69
|
-
* the matching template is sensitive.
|
|
76
|
+
* the matching template is sensitive. Needs posthog-node 5.71.0 or later.
|
|
70
77
|
*/
|
|
71
78
|
sensitive?: boolean
|
|
72
79
|
/**
|
|
@@ -79,9 +86,22 @@ interface CodeEmailFields {
|
|
|
79
86
|
* - An object turns each kind on or off. A key you leave out keeps its default.
|
|
80
87
|
*
|
|
81
88
|
* Turn clicks on for a sensitive email only when its links are safe to send through PostHog's
|
|
82
|
-
* click tracking.
|
|
89
|
+
* click tracking. Needs posthog-node 5.71.0 or later.
|
|
83
90
|
*/
|
|
84
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
|
|
85
105
|
}
|
|
86
106
|
|
|
87
107
|
/** Which kinds of tracking a send with `templateKey` turns on. */
|
|
@@ -141,7 +161,7 @@ export interface EmailReactRenderer {
|
|
|
141
161
|
/**
|
|
142
162
|
* Email content from your code, named by a key: `html`, `text` or both, or a `react` element
|
|
143
163
|
* the client renders. PostHog sends it as is and never stores it. PostHog derives a missing
|
|
144
|
-
* `text` from the `html`.
|
|
164
|
+
* `text` from the `html`. Needs posthog-node 5.62.0 or later, and `react` needs 5.69.0 or later.
|
|
145
165
|
*/
|
|
146
166
|
export type CodeEmailForm = CodeEmailFields &
|
|
147
167
|
(
|
|
@@ -170,7 +190,10 @@ export type SendTemplateEmailOptions = SendEmailBase &
|
|
|
170
190
|
|
|
171
191
|
export type SendCodeEmailOptions = SendEmailBase & CodeEmailForm & Without<TemplateEmailForm>
|
|
172
192
|
|
|
173
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* Options for `posthog.emails.send()`: a template made in PostHog (`templateId`), or content from
|
|
195
|
+
* your code (`templateKey`, `subject`, and `html`, `text`, or `react`). `to` is required for both.
|
|
196
|
+
*/
|
|
174
197
|
export type SendEmailOptions = SendTemplateEmailOptions | SendCodeEmailOptions
|
|
175
198
|
|
|
176
199
|
/** A warning PostHog returned with a queued email. */
|
|
@@ -212,6 +235,7 @@ export type EmailDeliveryStatus = 'queued' | 'sent' | 'failed' | 'delivered' | '
|
|
|
212
235
|
export interface EmailStatus {
|
|
213
236
|
/** The message ID that `send()` returned. */
|
|
214
237
|
id: string
|
|
238
|
+
/** Where the email is now, such as `delivered`. See `EmailDeliveryStatus`. */
|
|
215
239
|
status: EmailDeliveryStatus | (string & {})
|
|
216
240
|
/** When PostHog queued the email, as an ISO 8601 timestamp. */
|
|
217
241
|
createdAt: string
|
|
@@ -266,26 +290,42 @@ export interface EmailPreferences {
|
|
|
266
290
|
export type SetEmailPreferencesResponse = { data: EmailPreferences; error: null } | { data: null; error: EmailError }
|
|
267
291
|
|
|
268
292
|
/**
|
|
269
|
-
* The `posthog.emails` API: sends transactional email from PostHog email templates or
|
|
270
|
-
* content your code rendered, reads the status of each
|
|
271
|
-
* 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.
|
|
272
296
|
*/
|
|
273
297
|
export interface Emails {
|
|
274
298
|
/**
|
|
275
|
-
* Queue one email
|
|
299
|
+
* Queue one email: a transactional email from a PostHog email template, or a transactional or
|
|
300
|
+
* marketing email from content your code rendered.
|
|
276
301
|
*
|
|
277
302
|
* Resolves to `{ data, error }` and does not reject. `data` means PostHog queued the email,
|
|
278
|
-
* not that it was delivered.
|
|
279
|
-
*
|
|
303
|
+
* not that it was delivered. `error` is an `EmailError`: branch on its `code`.
|
|
304
|
+
*
|
|
305
|
+
* The client retries a network error, a 429 rate limit (not `quota_limited` or `upload_quota_exceeded`),
|
|
306
|
+
* a 409 `idempotency_key_in_flight`, a 503, and a failed attachment upload with a 429 or 5xx. It
|
|
307
|
+
* retries each request up to the send's `maxRetries` or the client's `emailRequestMaxRetries` times
|
|
308
|
+
* (default 2), so a send with attachments can retry more times overall. Every retry of the send
|
|
309
|
+
* carries the same idempotency key. It waits about 1 second, then 2, doubling up to 30 seconds, or
|
|
310
|
+
* longer when the `Retry-After` header asks. When `Retry-After` asks for more than 30 seconds, it
|
|
311
|
+
* returns the error at once. Each request times out after `emailRequestTimeoutMs` (default 15000).
|
|
312
|
+
*
|
|
313
|
+
* A `network_error` or a 503 doesn't mean the email failed: PostHog may have queued it. Retry with
|
|
314
|
+
* the same `idempotencyKey` (pass your own, such as `welcome:user_123`, so a retry outside this
|
|
315
|
+
* call can reuse it), and don't resend it through another email provider.
|
|
280
316
|
*/
|
|
281
317
|
send(options: SendEmailOptions): Promise<SendEmailResponse>
|
|
282
318
|
|
|
283
319
|
/**
|
|
284
|
-
* Read the status of an email that `send()` queued, for 30 days after the send.
|
|
320
|
+
* Read the status of an email that `send()` queued, for 30 days after the send. Needs
|
|
321
|
+
* posthog-node 5.61.0 or later.
|
|
285
322
|
*
|
|
286
|
-
* Resolves to `{ data, error }` and does not reject.
|
|
287
|
-
*
|
|
288
|
-
*
|
|
323
|
+
* Resolves to `{ data, error }` and does not reject. `data` is an `EmailStatus`: `id`, `status`,
|
|
324
|
+
* `createdAt`, `statusAt` and `reason`. The error code is `not_found` when no email of this
|
|
325
|
+
* project has the ID, when the email is older than 30 days, or for a few seconds after the send.
|
|
326
|
+
* The client doesn't retry `not_found`, so right after a send, wait a few seconds and call again
|
|
327
|
+
* before you treat the email as missing. Network errors, rate limits and an unavailable service
|
|
328
|
+
* are retried.
|
|
289
329
|
*/
|
|
290
330
|
get(id: string): Promise<GetEmailResponse>
|
|
291
331
|
|
|
@@ -293,7 +333,7 @@ export interface Emails {
|
|
|
293
333
|
* Opt one recipient out of topics, or back in, in one request. PostHog saves the whole change at once. The same
|
|
294
334
|
* change twice ends the same, but a retry that lands after a newer change for the same recipient undoes that
|
|
295
335
|
* change. A failed call may still have saved the change. Workflows sends skip a marketing topic the recipient
|
|
296
|
-
* opted out of.
|
|
336
|
+
* opted out of. Needs posthog-node 5.70.0 or later.
|
|
297
337
|
*
|
|
298
338
|
* Resolves to `{ data, error }` and does not reject. The error code is `unknown_topic` when a topic key names no
|
|
299
339
|
* topic of the project, and nothing is saved. A plain `not_found` means the PostHog instance has no preferences
|
package/src/types.ts
CHANGED
|
@@ -497,20 +497,28 @@ export type PostHogOptions = Omit<
|
|
|
497
497
|
*
|
|
498
498
|
* Needed only when `host` is not PostHog Cloud, for example a reverse proxy, which must not
|
|
499
499
|
* receive the secret key. On PostHog Cloud, the client derives `https://us.posthog.com` or
|
|
500
|
-
* `https://eu.posthog.com` from `host`.
|
|
500
|
+
* `https://eu.posthog.com` from `host`. When `host` is not PostHog Cloud and `appHost` is not set,
|
|
501
|
+
* every `posthog.emails` call fails with `missing_app_host` and sends nothing. A self-hosted PostHog
|
|
502
|
+
* needs a version from 2026-11-18 or later, and an older one answers email calls with a 404.
|
|
503
|
+
*
|
|
504
|
+
* With `enableLocalEvaluation` on, the client polls flag definitions from `host` with `secretKey`,
|
|
505
|
+
* and `getRemoteConfigPayload()` always sends `secretKey` to `host`. When `host` is a proxy that
|
|
506
|
+
* must not see the key, set `enableLocalEvaluation: false` and don't call `getRemoteConfigPayload()`
|
|
507
|
+
* on this client.
|
|
501
508
|
*/
|
|
502
509
|
appHost?: string
|
|
503
510
|
/**
|
|
504
|
-
* Timeout in milliseconds for each `emails
|
|
505
|
-
*
|
|
511
|
+
* Timeout in milliseconds for each `posthog.emails` request: a send, a status read, a preferences
|
|
512
|
+
* change, or one attachment upload. Raise it when large files upload slowly. Rendering a `react`
|
|
513
|
+
* element has the same limit.
|
|
506
514
|
*
|
|
507
515
|
* @default 15000
|
|
508
516
|
*/
|
|
509
517
|
emailRequestTimeoutMs?: number
|
|
510
518
|
/**
|
|
511
|
-
* Number of retries for
|
|
512
|
-
* unavailable service. Every retry
|
|
513
|
-
* runner already retries the send.
|
|
519
|
+
* Number of retries for a `posthog.emails` call after a network error, a rate limit, or an
|
|
520
|
+
* unavailable service. Every retry of a send carries the same idempotency key. Set to 0 when a
|
|
521
|
+
* job runner already retries the send. A send's own `maxRetries` overrides it.
|
|
514
522
|
*
|
|
515
523
|
* @default 2
|
|
516
524
|
*/
|
|
@@ -521,7 +529,7 @@ export type PostHogOptions = Omit<
|
|
|
521
529
|
* Renders the `react` element of an `emails.send`. Set it when you bundle your app, such as
|
|
522
530
|
* for Cloudflare Workers, Convex, or Vercel Edge: posthog-node doesn't bundle `@react-email/render`,
|
|
523
531
|
* so apps that never send `react` don't carry it. Without it, posthog-node loads
|
|
524
|
-
* `@react-email/render` from `node_modules` when a send has `react`.
|
|
532
|
+
* `@react-email/render` from `node_modules` when a send has `react`. Needs posthog-node 6.2.0 or later.
|
|
525
533
|
*
|
|
526
534
|
* @example
|
|
527
535
|
* ```ts
|
|
@@ -869,7 +877,7 @@ export interface IPostHog {
|
|
|
869
877
|
/**
|
|
870
878
|
* Capture an AI event on the dedicated AI capture endpoint (`/i/v1/ai/events`).
|
|
871
879
|
*
|
|
872
|
-
* Beta: the signature is stable, while operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async
|
|
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.
|
|
873
881
|
*
|
|
874
882
|
* @param props - AI event payload including `event`, optional `distinctId`, `properties`, `groups`, `flags`, and `options`
|
|
875
883
|
* @returns The event UUID, or `undefined` when the client is disabled
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "6.
|
|
1
|
+
export const version = "6.3.0"
|