posthog-node 5.61.2 → 5.62.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/client.d.ts CHANGED
@@ -206,9 +206,11 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
206
206
  * The `posthog.emails` API: sends transactional email from PostHog email templates, and reads
207
207
  * the status of each email it sent.
208
208
  *
209
- * Needs `secretKey`, a project secret API key with the `hog_flow:write` scope. A key with only
210
- * `hog_flow:read` can read statuses but not send. Requests go to `appHost`, or to the PostHog
211
- * Cloud app host of `host`. `send` and `get` resolve to `{ data, error }` and do not reject.
209
+ * Needs `secretKey`, a project secret API key with the `transactional_email:write` scope (the
210
+ * "Send transactional email" preset). A key with only `transactional_email:read` can read
211
+ * statuses but not send. Keys made with `hog_flow:write` still work. Requests go to `appHost`,
212
+ * or to the PostHog Cloud app host of `host`. `send` and `get` resolve to `{ data, error }` and
213
+ * do not reject.
212
214
  * `data.id` is the queued email's message ID, which `get` takes. A disabled client sends nothing
213
215
  * and returns the error `client_disabled`. After `shutdown()`, the client sends nothing and
214
216
  * returns the error `client_closed`.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,gBAAgB,EAKhB,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAG/B,wBAAwB,EAGxB,UAAU,EAIV,gBAAgB,EAKjB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EACJ,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,eAAe,EACf,YAAY,EAGZ,4BAA4B,EAE5B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,2BAA2B,EAC3B,cAAc,EAEd,0BAA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C,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+CzD;YAEa,2BAA2B;IAqCzC,OAAO,CAAC,0BAA0B;YA+BpB,uBAAuB;IAuErC,OAAO,CAAC,gCAAgC;IAqBxC,OAAO,CAAC,kCAAkC;IAI1C,OAAO,CAAC,kCAAkC;IAe1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,gBAAgB,CACd,KAAK,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACnD,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,EAC3B,KAAK,CAAC,EAAE,sBAAsB,GAC7B,IAAI,CAcN;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAcf;IAEY,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,CAED;YAEa,oBAAoB;IA0JlC,OAAO,CAAC,cAAc;CA4BvB"}
package/dist/client.js CHANGED
@@ -327,7 +327,8 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
327
327
  host: this.host,
328
328
  appHost: this.options.appHost,
329
329
  requestTimeoutMs: positiveNumberOr(this.options.emailRequestTimeoutMs, emails_js_namespaceObject.DEFAULT_EMAIL_REQUEST_TIMEOUT_MS),
330
- maxRetries: nonNegativeIntegerOr(this.options.emailRequestMaxRetries, emails_js_namespaceObject.DEFAULT_EMAIL_REQUEST_MAX_RETRIES)
330
+ maxRetries: nonNegativeIntegerOr(this.options.emailRequestMaxRetries, emails_js_namespaceObject.DEFAULT_EMAIL_REQUEST_MAX_RETRIES),
331
+ migratedFrom: this.options.migratedFrom
331
332
  }, {
332
333
  fetch: (url, fetchOptions)=>this.fetch(url, fetchOptions),
333
334
  isDisabled: ()=>this.disabled,
package/dist/client.mjs CHANGED
@@ -284,7 +284,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
284
284
  host: this.host,
285
285
  appHost: this.options.appHost,
286
286
  requestTimeoutMs: positiveNumberOr(this.options.emailRequestTimeoutMs, DEFAULT_EMAIL_REQUEST_TIMEOUT_MS),
287
- maxRetries: nonNegativeIntegerOr(this.options.emailRequestMaxRetries, DEFAULT_EMAIL_REQUEST_MAX_RETRIES)
287
+ maxRetries: nonNegativeIntegerOr(this.options.emailRequestMaxRetries, DEFAULT_EMAIL_REQUEST_MAX_RETRIES),
288
+ migratedFrom: this.options.migratedFrom
288
289
  }, {
289
290
  fetch: (url, fetchOptions)=>this.fetch(url, fetchOptions),
290
291
  isDisabled: ()=>this.disabled,
@@ -9,6 +9,7 @@ export interface EmailSenderConfig {
9
9
  appHost?: string;
10
10
  requestTimeoutMs: number;
11
11
  maxRetries: number;
12
+ migratedFrom?: string;
12
13
  }
13
14
  export interface EmailSenderHooks {
14
15
  fetch: FetchLike;
@@ -27,7 +28,7 @@ export declare class EmailSender implements Emails {
27
28
  private readonly hooks;
28
29
  private readonly inFlight;
29
30
  constructor(config: EmailSenderConfig, hooks: EmailSenderHooks);
30
- send(options: SendEmailOptions): Promise<SendEmailResponse>;
31
+ send(options: SendEmailOptions, ...unexpected: unknown[]): Promise<SendEmailResponse>;
31
32
  get(id: string): Promise<GetEmailResponse>;
32
33
  private track;
33
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"emails.d.ts","sourceRoot":"","sources":["../../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,OAAO,CAAC,gBAAgB,CAAC,CAEzC;IAED,OAAO,CAAC,KAAK;IAMb;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;YAEa,aAAa;YAwBb,YAAY;IAoB1B,OAAO,CAAC,OAAO;IA6Bf,OAAO,CAAC,OAAO;YAeD,WAAW;YAwBX,OAAO;CA2DtB"}
@@ -48,6 +48,38 @@ const CLOUD_APP_HOSTS = {
48
48
  const MAX_RETRY_DELAY_MS = 30000;
49
49
  const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
50
50
  const IDEMPOTENCY_KEY_PATTERN = /^[\x21-\x7e]{1,255}$/;
51
+ const TEMPLATE_KEY_PATTERN = /^[a-zA-Z0-9_-]{1,400}$/;
52
+ const SHARED_FIELDS = {
53
+ to: true,
54
+ distinctId: true,
55
+ idempotencyKey: true,
56
+ maxRetries: true
57
+ };
58
+ const TEMPLATE_FIELDS = {
59
+ templateId: true,
60
+ templateData: true
61
+ };
62
+ const CODE_FIELDS = {
63
+ templateKey: true,
64
+ subject: true,
65
+ from: true,
66
+ replyTo: true,
67
+ captureEngagement: true,
68
+ html: true,
69
+ text: true
70
+ };
71
+ const TEMPLATE_FORM = {
72
+ name: 'templateId',
73
+ fields: fieldSet(SHARED_FIELDS, TEMPLATE_FIELDS),
74
+ why: "A template made in PostHog sets its own sender, subject and content, and follows the project's engagement setting.",
75
+ howToSend: 'send a template made in PostHog with templateId'
76
+ };
77
+ const CODE_FORM = {
78
+ name: 'templateKey',
79
+ fields: fieldSet(SHARED_FIELDS, CODE_FIELDS),
80
+ why: 'A send with templateKey takes its content from your code.',
81
+ howToSend: 'send content from your code with templateKey'
82
+ };
51
83
  const DEFAULT_EMAIL_REQUEST_TIMEOUT_MS = 15000;
52
84
  const DEFAULT_EMAIL_REQUEST_MAX_RETRIES = 2;
53
85
  class EmailSender {
@@ -56,8 +88,8 @@ class EmailSender {
56
88
  this.config = config;
57
89
  this.hooks = hooks;
58
90
  }
59
- send(options) {
60
- return this.track(this.sendUntracked(options));
91
+ send(options, ...unexpected) {
92
+ return this.track(this.sendUntracked(options, unexpected));
61
93
  }
62
94
  get(id) {
63
95
  return this.track(this.getUntracked(id));
@@ -70,10 +102,11 @@ class EmailSender {
70
102
  async drain() {
71
103
  while(this.inFlight.size > 0)await Promise.all(this.inFlight);
72
104
  }
73
- async sendUntracked(options) {
105
+ async sendUntracked(options, unexpected) {
74
106
  try {
107
+ refuseSecondArgument(unexpected);
75
108
  const prepared = prepareSend(options, this.config.maxRetries);
76
- const { appHost, secretKey } = this.connect('no email was sent', 'Sending email needs secretKey, a project secret API key with the hog_flow:write scope.');
109
+ const { appHost, secretKey } = this.connect('no email was sent', 'Sending email needs secretKey, a project secret API key with the transactional_email:write scope.');
77
110
  const headers = this.headers(secretKey, {
78
111
  'Content-Type': 'application/json',
79
112
  'Idempotency-Key': prepared.idempotencyKey
@@ -94,7 +127,7 @@ class EmailSender {
94
127
  async getUntracked(id) {
95
128
  try {
96
129
  if ('string' != typeof id || !UUID_PATTERN.test(id)) throw invalid('invalid_message_id', 'id must be the message ID that send() returned.', 'id');
97
- const { appHost, secretKey } = this.connect('no email status was read', 'Reading an email status needs secretKey, a project secret API key with the hog_flow:read or hog_flow:write scope.');
130
+ const { appHost, secretKey } = this.connect('no email status was read', 'Reading an email status needs secretKey, a project secret API key with the transactional_email:read or transactional_email:write scope.');
98
131
  const url = appHost + STATUS_PATH.replace('{messageId}', id.toLowerCase());
99
132
  const headers = this.headers(secretKey, {});
100
133
  const status = await this.withRetries(this.config.maxRetries, async ()=>parseStatusReply(await this.request(url, 'GET', headers)));
@@ -140,6 +173,7 @@ class EmailSender {
140
173
  ...extra
141
174
  };
142
175
  if (this.hooks.userAgent) headers['User-Agent'] = this.hooks.userAgent;
176
+ if (this.config.migratedFrom) headers['X-PostHog-Migrated-From'] = this.config.migratedFrom;
143
177
  return headers;
144
178
  }
145
179
  async withRetries(maxRetries, attemptOnce) {
@@ -213,28 +247,106 @@ class EmailSender {
213
247
  }
214
248
  }
215
249
  }
250
+ function refuseSecondArgument(unexpected) {
251
+ if (unexpected.some((argument)=>void 0 !== argument)) throw new external_errors_js_namespaceObject.EmailError({
252
+ code: 'invalid_form',
253
+ message: 'send takes one options object, so no email was sent. Put idempotencyKey and every other option in it.'
254
+ });
255
+ }
216
256
  function prepareSend(options, defaultMaxRetries) {
217
- const fallback = {};
218
- const { to, templateId, templateData, distinctId, idempotencyKey, maxRetries } = options ?? fallback;
257
+ const send = options ?? {};
258
+ const { to, distinctId, idempotencyKey, maxRetries } = send;
219
259
  if ('string' != typeof to || !to.trim()) throw invalid('invalid_recipient', 'to must be one email address as a nonempty string.', 'to');
220
- if ('string' != typeof templateId || !UUID_PATTERN.test(templateId)) throw invalid('invalid_template_id', "templateId must be the template's UUID.", 'templateId');
221
- if (void 0 !== templateData && ('object' != typeof templateData || null === templateData || Array.isArray(templateData))) throw invalid('invalid_template_data', 'templateData must be an object.', 'templateData');
222
260
  if (void 0 !== distinctId && ('string' != typeof distinctId || !distinctId)) throw invalid('invalid_distinct_id', 'distinctId must be a nonempty string.', 'distinctId');
261
+ const content = contentOf(send, distinctId);
223
262
  if (void 0 !== idempotencyKey && ('string' != typeof idempotencyKey || !IDEMPOTENCY_KEY_PATTERN.test(idempotencyKey))) throw invalid('invalid_idempotency_key', 'idempotencyKey must be 1 to 255 visible ASCII characters without spaces.', 'idempotencyKey');
224
- if (void 0 !== maxRetries && !(Number.isInteger(maxRetries) && maxRetries >= 0)) throw invalid('invalid_max_retries', 'maxRetries must be a nonnegative integer.', 'maxRetries');
225
- const payload = {
226
- template_id: templateId.toLowerCase(),
227
- to,
228
- message_data: templateData ?? {}
229
- };
230
- if (void 0 !== distinctId) payload.distinct_id = distinctId;
263
+ if (void 0 !== maxRetries && !isRetryCount(maxRetries)) throw invalid('invalid_max_retries', 'maxRetries must be a nonnegative integer.', 'maxRetries');
231
264
  return {
232
265
  path: SEND_PATH,
233
- body: (0, core_namespaceObject.safeJsonStringify)(payload),
266
+ body: (0, core_namespaceObject.safeJsonStringify)({
267
+ ...content,
268
+ to
269
+ }),
234
270
  idempotencyKey: idempotencyKey ?? globalThis.crypto.randomUUID(),
235
- maxRetries: maxRetries ?? defaultMaxRetries
271
+ maxRetries: isRetryCount(maxRetries) ? maxRetries : defaultMaxRetries
236
272
  };
237
273
  }
274
+ function isRetryCount(value) {
275
+ return 'number' == typeof value && Number.isInteger(value) && value >= 0;
276
+ }
277
+ function contentOf(send, distinctId) {
278
+ if (void 0 === send.templateId === (void 0 === send.templateKey)) throw new external_errors_js_namespaceObject.EmailError({
279
+ code: 'invalid_form',
280
+ message: 'Send either templateId, or templateKey with subject and html or text.'
281
+ });
282
+ return void 0 === send.templateKey ? templateContent(send, distinctId) : codeContent(send, distinctId);
283
+ }
284
+ function templateContent(send, distinctId) {
285
+ const { templateId, templateData } = send;
286
+ if ('string' != typeof templateId || !UUID_PATTERN.test(templateId)) throw invalid('invalid_template_id', "templateId must be the template's UUID.", 'templateId');
287
+ if (void 0 !== templateData && ('object' != typeof templateData || null === templateData || Array.isArray(templateData))) throw invalid('invalid_template_data', 'templateData must be an object.', 'templateData');
288
+ refuseFieldsOutside(send, TEMPLATE_FORM, CODE_FORM);
289
+ return {
290
+ template_id: templateId.toLowerCase(),
291
+ message_data: templateData ?? {},
292
+ ...void 0 !== distinctId && {
293
+ distinct_id: distinctId
294
+ }
295
+ };
296
+ }
297
+ function codeContent(send, distinctId) {
298
+ const { templateKey, subject, html, text, from, replyTo, captureEngagement } = send;
299
+ if ('string' != typeof templateKey || !TEMPLATE_KEY_PATTERN.test(templateKey)) throw invalid('invalid_template_key', 'templateKey can only have letters, digits, hyphens (-) and underscores (_), at most 400.', 'templateKey');
300
+ refuseFieldsOutside(send, CODE_FORM, TEMPLATE_FORM);
301
+ if ('string' != typeof subject) throw invalid('invalid_form', 'A send with templateKey needs a subject.', 'subject');
302
+ if (void 0 !== html && 'string' != typeof html) throw invalid('invalid_form', 'html must be a string.', 'html');
303
+ if (void 0 !== text && 'string' != typeof text) throw invalid('invalid_form', 'text must be a string.', 'text');
304
+ if (void 0 === html && void 0 === text) throw invalid('invalid_form', 'A send with templateKey needs html, text or both.', 'html');
305
+ const sendsReplyTo = void 0 !== replyTo && !(Array.isArray(replyTo) && 0 === replyTo.length);
306
+ return {
307
+ template_key: templateKey,
308
+ subject,
309
+ ...void 0 !== html && {
310
+ html
311
+ },
312
+ ...void 0 !== text && {
313
+ text
314
+ },
315
+ ...void 0 !== from && {
316
+ from
317
+ },
318
+ ...sendsReplyTo && {
319
+ reply_to: 'string' == typeof replyTo ? [
320
+ replyTo
321
+ ] : replyTo
322
+ },
323
+ capture_engagement: captureEngagement ?? true,
324
+ ...void 0 !== distinctId && {
325
+ distinct_id: distinctId
326
+ }
327
+ };
328
+ }
329
+ function refuseFieldsOutside(send, form, otherForm) {
330
+ const field = Object.entries(send).find(([name, value])=>void 0 !== value && !form.fields.has(name))?.[0];
331
+ if (void 0 === field) return;
332
+ const message = `A send with ${form.name} doesn't take ${field}, so no email was sent.`;
333
+ if (!otherForm.fields.has(field)) throw new external_errors_js_namespaceObject.EmailError({
334
+ code: 'invalid_form',
335
+ message,
336
+ field,
337
+ fix: `Remove ${field} and send again.`
338
+ });
339
+ throw new external_errors_js_namespaceObject.EmailError({
340
+ code: 'invalid_form',
341
+ message,
342
+ field,
343
+ why: form.why,
344
+ fix: `Remove ${field}, or ${otherForm.howToSend}.`
345
+ });
346
+ }
347
+ function fieldSet(...groups) {
348
+ return new Set(groups.flatMap((group)=>Object.keys(group)));
349
+ }
238
350
  function invalid(code, message, field) {
239
351
  return new external_errors_js_namespaceObject.EmailError({
240
352
  code,
@@ -14,6 +14,38 @@ const CLOUD_APP_HOSTS = {
14
14
  const MAX_RETRY_DELAY_MS = 30000;
15
15
  const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16
16
  const IDEMPOTENCY_KEY_PATTERN = /^[\x21-\x7e]{1,255}$/;
17
+ const TEMPLATE_KEY_PATTERN = /^[a-zA-Z0-9_-]{1,400}$/;
18
+ const SHARED_FIELDS = {
19
+ to: true,
20
+ distinctId: true,
21
+ idempotencyKey: true,
22
+ maxRetries: true
23
+ };
24
+ const TEMPLATE_FIELDS = {
25
+ templateId: true,
26
+ templateData: true
27
+ };
28
+ const CODE_FIELDS = {
29
+ templateKey: true,
30
+ subject: true,
31
+ from: true,
32
+ replyTo: true,
33
+ captureEngagement: true,
34
+ html: true,
35
+ text: true
36
+ };
37
+ const TEMPLATE_FORM = {
38
+ name: 'templateId',
39
+ fields: fieldSet(SHARED_FIELDS, TEMPLATE_FIELDS),
40
+ why: "A template made in PostHog sets its own sender, subject and content, and follows the project's engagement setting.",
41
+ howToSend: 'send a template made in PostHog with templateId'
42
+ };
43
+ const CODE_FORM = {
44
+ name: 'templateKey',
45
+ fields: fieldSet(SHARED_FIELDS, CODE_FIELDS),
46
+ why: 'A send with templateKey takes its content from your code.',
47
+ howToSend: 'send content from your code with templateKey'
48
+ };
17
49
  const DEFAULT_EMAIL_REQUEST_TIMEOUT_MS = 15000;
18
50
  const DEFAULT_EMAIL_REQUEST_MAX_RETRIES = 2;
19
51
  class EmailSender {
@@ -22,8 +54,8 @@ class EmailSender {
22
54
  this.config = config;
23
55
  this.hooks = hooks;
24
56
  }
25
- send(options) {
26
- return this.track(this.sendUntracked(options));
57
+ send(options, ...unexpected) {
58
+ return this.track(this.sendUntracked(options, unexpected));
27
59
  }
28
60
  get(id) {
29
61
  return this.track(this.getUntracked(id));
@@ -36,10 +68,11 @@ class EmailSender {
36
68
  async drain() {
37
69
  while(this.inFlight.size > 0)await Promise.all(this.inFlight);
38
70
  }
39
- async sendUntracked(options) {
71
+ async sendUntracked(options, unexpected) {
40
72
  try {
73
+ refuseSecondArgument(unexpected);
41
74
  const prepared = prepareSend(options, this.config.maxRetries);
42
- const { appHost, secretKey } = this.connect('no email was sent', 'Sending email needs secretKey, a project secret API key with the hog_flow:write scope.');
75
+ const { appHost, secretKey } = this.connect('no email was sent', 'Sending email needs secretKey, a project secret API key with the transactional_email:write scope.');
43
76
  const headers = this.headers(secretKey, {
44
77
  'Content-Type': 'application/json',
45
78
  'Idempotency-Key': prepared.idempotencyKey
@@ -60,7 +93,7 @@ class EmailSender {
60
93
  async getUntracked(id) {
61
94
  try {
62
95
  if ('string' != typeof id || !UUID_PATTERN.test(id)) throw invalid('invalid_message_id', 'id must be the message ID that send() returned.', 'id');
63
- const { appHost, secretKey } = this.connect('no email status was read', 'Reading an email status needs secretKey, a project secret API key with the hog_flow:read or hog_flow:write scope.');
96
+ const { appHost, secretKey } = this.connect('no email status was read', 'Reading an email status needs secretKey, a project secret API key with the transactional_email:read or transactional_email:write scope.');
64
97
  const url = appHost + STATUS_PATH.replace('{messageId}', id.toLowerCase());
65
98
  const headers = this.headers(secretKey, {});
66
99
  const status = await this.withRetries(this.config.maxRetries, async ()=>parseStatusReply(await this.request(url, 'GET', headers)));
@@ -106,6 +139,7 @@ class EmailSender {
106
139
  ...extra
107
140
  };
108
141
  if (this.hooks.userAgent) headers['User-Agent'] = this.hooks.userAgent;
142
+ if (this.config.migratedFrom) headers['X-PostHog-Migrated-From'] = this.config.migratedFrom;
109
143
  return headers;
110
144
  }
111
145
  async withRetries(maxRetries, attemptOnce) {
@@ -179,28 +213,106 @@ class EmailSender {
179
213
  }
180
214
  }
181
215
  }
216
+ function refuseSecondArgument(unexpected) {
217
+ if (unexpected.some((argument)=>void 0 !== argument)) throw new EmailError({
218
+ code: 'invalid_form',
219
+ message: 'send takes one options object, so no email was sent. Put idempotencyKey and every other option in it.'
220
+ });
221
+ }
182
222
  function prepareSend(options, defaultMaxRetries) {
183
- const fallback = {};
184
- const { to, templateId, templateData, distinctId, idempotencyKey, maxRetries } = options ?? fallback;
223
+ const send = options ?? {};
224
+ const { to, distinctId, idempotencyKey, maxRetries } = send;
185
225
  if ('string' != typeof to || !to.trim()) throw invalid('invalid_recipient', 'to must be one email address as a nonempty string.', 'to');
186
- if ('string' != typeof templateId || !UUID_PATTERN.test(templateId)) throw invalid('invalid_template_id', "templateId must be the template's UUID.", 'templateId');
187
- if (void 0 !== templateData && ('object' != typeof templateData || null === templateData || Array.isArray(templateData))) throw invalid('invalid_template_data', 'templateData must be an object.', 'templateData');
188
226
  if (void 0 !== distinctId && ('string' != typeof distinctId || !distinctId)) throw invalid('invalid_distinct_id', 'distinctId must be a nonempty string.', 'distinctId');
227
+ const content = contentOf(send, distinctId);
189
228
  if (void 0 !== idempotencyKey && ('string' != typeof idempotencyKey || !IDEMPOTENCY_KEY_PATTERN.test(idempotencyKey))) throw invalid('invalid_idempotency_key', 'idempotencyKey must be 1 to 255 visible ASCII characters without spaces.', 'idempotencyKey');
190
- if (void 0 !== maxRetries && !(Number.isInteger(maxRetries) && maxRetries >= 0)) throw invalid('invalid_max_retries', 'maxRetries must be a nonnegative integer.', 'maxRetries');
191
- const payload = {
192
- template_id: templateId.toLowerCase(),
193
- to,
194
- message_data: templateData ?? {}
195
- };
196
- if (void 0 !== distinctId) payload.distinct_id = distinctId;
229
+ if (void 0 !== maxRetries && !isRetryCount(maxRetries)) throw invalid('invalid_max_retries', 'maxRetries must be a nonnegative integer.', 'maxRetries');
197
230
  return {
198
231
  path: SEND_PATH,
199
- body: safeJsonStringify(payload),
232
+ body: safeJsonStringify({
233
+ ...content,
234
+ to
235
+ }),
200
236
  idempotencyKey: idempotencyKey ?? globalThis.crypto.randomUUID(),
201
- maxRetries: maxRetries ?? defaultMaxRetries
237
+ maxRetries: isRetryCount(maxRetries) ? maxRetries : defaultMaxRetries
202
238
  };
203
239
  }
240
+ function isRetryCount(value) {
241
+ return 'number' == typeof value && Number.isInteger(value) && value >= 0;
242
+ }
243
+ function contentOf(send, distinctId) {
244
+ if (void 0 === send.templateId === (void 0 === send.templateKey)) throw new EmailError({
245
+ code: 'invalid_form',
246
+ message: 'Send either templateId, or templateKey with subject and html or text.'
247
+ });
248
+ return void 0 === send.templateKey ? templateContent(send, distinctId) : codeContent(send, distinctId);
249
+ }
250
+ function templateContent(send, distinctId) {
251
+ const { templateId, templateData } = send;
252
+ if ('string' != typeof templateId || !UUID_PATTERN.test(templateId)) throw invalid('invalid_template_id', "templateId must be the template's UUID.", 'templateId');
253
+ if (void 0 !== templateData && ('object' != typeof templateData || null === templateData || Array.isArray(templateData))) throw invalid('invalid_template_data', 'templateData must be an object.', 'templateData');
254
+ refuseFieldsOutside(send, TEMPLATE_FORM, CODE_FORM);
255
+ return {
256
+ template_id: templateId.toLowerCase(),
257
+ message_data: templateData ?? {},
258
+ ...void 0 !== distinctId && {
259
+ distinct_id: distinctId
260
+ }
261
+ };
262
+ }
263
+ function codeContent(send, distinctId) {
264
+ const { templateKey, subject, html, text, from, replyTo, captureEngagement } = send;
265
+ if ('string' != typeof templateKey || !TEMPLATE_KEY_PATTERN.test(templateKey)) throw invalid('invalid_template_key', 'templateKey can only have letters, digits, hyphens (-) and underscores (_), at most 400.', 'templateKey');
266
+ refuseFieldsOutside(send, CODE_FORM, TEMPLATE_FORM);
267
+ if ('string' != typeof subject) throw invalid('invalid_form', 'A send with templateKey needs a subject.', 'subject');
268
+ if (void 0 !== html && 'string' != typeof html) throw invalid('invalid_form', 'html must be a string.', 'html');
269
+ if (void 0 !== text && 'string' != typeof text) throw invalid('invalid_form', 'text must be a string.', 'text');
270
+ if (void 0 === html && void 0 === text) throw invalid('invalid_form', 'A send with templateKey needs html, text or both.', 'html');
271
+ const sendsReplyTo = void 0 !== replyTo && !(Array.isArray(replyTo) && 0 === replyTo.length);
272
+ return {
273
+ template_key: templateKey,
274
+ subject,
275
+ ...void 0 !== html && {
276
+ html
277
+ },
278
+ ...void 0 !== text && {
279
+ text
280
+ },
281
+ ...void 0 !== from && {
282
+ from
283
+ },
284
+ ...sendsReplyTo && {
285
+ reply_to: 'string' == typeof replyTo ? [
286
+ replyTo
287
+ ] : replyTo
288
+ },
289
+ capture_engagement: captureEngagement ?? true,
290
+ ...void 0 !== distinctId && {
291
+ distinct_id: distinctId
292
+ }
293
+ };
294
+ }
295
+ function refuseFieldsOutside(send, form, otherForm) {
296
+ const field = Object.entries(send).find(([name, value])=>void 0 !== value && !form.fields.has(name))?.[0];
297
+ if (void 0 === field) return;
298
+ const message = `A send with ${form.name} doesn't take ${field}, so no email was sent.`;
299
+ if (!otherForm.fields.has(field)) throw new EmailError({
300
+ code: 'invalid_form',
301
+ message,
302
+ field,
303
+ fix: `Remove ${field} and send again.`
304
+ });
305
+ throw new EmailError({
306
+ code: 'invalid_form',
307
+ message,
308
+ field,
309
+ why: form.why,
310
+ fix: `Remove ${field}, or ${otherForm.howToSend}.`
311
+ });
312
+ }
313
+ function fieldSet(...groups) {
314
+ return new Set(groups.flatMap((group)=>Object.keys(group)));
315
+ }
204
316
  function invalid(code, message, field) {
205
317
  return new EmailError({
206
318
  code,
@@ -1,14 +1,8 @@
1
1
  import type { EmailError } from './errors';
2
- /**
3
- * Options for `posthog.emails.send()`.
4
- */
5
- export interface SendEmailOptions {
2
+ /** What every send takes, whatever its form. */
3
+ export interface SendEmailBase {
6
4
  /** One recipient email address. */
7
5
  to: string;
8
- /** The UUID of an email template made transactional in PostHog. */
9
- templateId: string;
10
- /** Values for the template's `{{ variables.* }}` placeholders. Sent as `message_data`. */
11
- templateData?: Record<string, unknown>;
12
6
  /**
13
7
  * The recipient's distinct ID in your product. The email's events go to this person.
14
8
  * Without it, they go to a person whose distinct ID is the email address.
@@ -16,14 +10,62 @@ export interface SendEmailOptions {
16
10
  distinctId?: string;
17
11
  /**
18
12
  * 1 to 255 visible ASCII characters. A send with a key that PostHog has already accepted
19
- * queues nothing and returns the first send's result. Without it, the client makes a
20
- * UUID that covers its own retries. Pass a key derived from what the email is for, such
21
- * as `welcome:user_123`, to cover retries outside this call too.
13
+ * queues nothing and returns the first send's result. The same key with other options sends
14
+ * nothing and returns an error with code `idempotency_key_reused`. Without it, the client makes a UUID that
15
+ * covers its own retries. Pass a key derived from what the email is for, such as
16
+ * `welcome:user_123`, to cover retries outside this call too.
22
17
  */
23
18
  idempotencyKey?: string;
24
19
  /** Overrides the client's `emailRequestMaxRetries` for this send. `0` turns retries off. */
25
20
  maxRetries?: number;
26
21
  }
22
+ /** A template made transactional in PostHog, sent by its ID. */
23
+ export interface TemplateEmailForm {
24
+ /** The UUID of an email template made transactional in PostHog. */
25
+ templateId: string;
26
+ /** Values for the template's `{{ variables.* }}` placeholders. Sent as `message_data`. */
27
+ templateData?: Record<string, unknown>;
28
+ }
29
+ interface CodeEmailFields {
30
+ /**
31
+ * Names the email, such as `'password-reset'`, so its metrics, logs and status group under it
32
+ * in PostHog. Letters, digits, hyphens and underscores, at most 400.
33
+ */
34
+ templateKey: string;
35
+ subject: string;
36
+ /** A verified sender, such as `'Acme <security@example.com>'`. Without it, the project's default sender. */
37
+ from?: string;
38
+ replyTo?: string | string[];
39
+ /**
40
+ * Whether PostHog captures the email's engagement events (sent, delivered, opened, clicked,
41
+ * bounced) as events of the recipient. Defaults to `true`. A project whose admin turned
42
+ * engagement capture off captures nothing, whatever the send asks. A template made in PostHog
43
+ * follows the project's setting.
44
+ */
45
+ captureEngagement?: boolean;
46
+ }
47
+ /**
48
+ * Email content your code rendered, such as React Email output, named by a key. PostHog sends it
49
+ * as is and never stores it. Needs `html`, `text` or both. PostHog derives a missing `text` from
50
+ * the `html`.
51
+ */
52
+ export type CodeEmailForm = CodeEmailFields & ({
53
+ html: string;
54
+ text?: string;
55
+ } | {
56
+ html?: string;
57
+ text: string;
58
+ });
59
+ type Without<T> = {
60
+ [K in keyof T]?: never;
61
+ };
62
+ export type SendTemplateEmailOptions = SendEmailBase & TemplateEmailForm & Without<CodeEmailFields & {
63
+ html: string;
64
+ text: string;
65
+ }>;
66
+ export type SendCodeEmailOptions = SendEmailBase & CodeEmailForm & Without<TemplateEmailForm>;
67
+ /** Options for `posthog.emails.send()`: a template made in PostHog, or content from your code. */
68
+ export type SendEmailOptions = SendTemplateEmailOptions | SendCodeEmailOptions;
27
69
  /** A warning PostHog returned with a queued email. */
28
70
  export interface EmailWarning {
29
71
  code: string;
@@ -88,12 +130,12 @@ export type GetEmailResponse = {
88
130
  error: EmailError;
89
131
  };
90
132
  /**
91
- * The `posthog.emails` API: sends transactional email from PostHog email templates, and reads
92
- * the status of each email it sent.
133
+ * The `posthog.emails` API: sends transactional email from PostHog email templates or from
134
+ * content your code rendered, and reads the status of each email it sent.
93
135
  */
94
136
  export interface Emails {
95
137
  /**
96
- * Queue one email from a transactional email template.
138
+ * Queue one email, from a transactional email template or from content your code rendered.
97
139
  *
98
140
  * Resolves to `{ data, error }` and does not reject. `data` means PostHog queued the email,
99
141
  * not that it was delivered. Network errors, rate limits, an in-flight idempotency key and
@@ -109,4 +151,5 @@ export interface Emails {
109
151
  */
110
152
  get(id: string): Promise<GetEmailResponse>;
111
153
  }
154
+ export {};
112
155
  //# sourceMappingURL=types.d.ts.map
@@ -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;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAA;IAClB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf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,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAA;AAErG;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;OAMG;IACH,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAE3D;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAC3C"}
package/dist/exports.d.ts CHANGED
@@ -5,7 +5,7 @@ export { enrichCurrentSpan } from './extensions/context/listeners';
5
5
  export { FeatureFlagEvaluations } from './feature-flag-evaluations';
6
6
  export { EmailError } from './emails/errors';
7
7
  export type { EmailErrorName } from './emails/errors';
8
- export type { EmailDeliveryStatus, Emails, EmailStatus, EmailWarning, GetEmailResponse, SendEmailOptions, SendEmailResponse, SendEmailResult, } from './emails/types';
8
+ export type { CodeEmailForm, EmailDeliveryStatus, Emails, EmailStatus, EmailWarning, GetEmailResponse, SendCodeEmailOptions, SendEmailBase, SendEmailOptions, SendEmailResponse, SendEmailResult, SendTemplateEmailOptions, TemplateEmailForm, } from './emails/types';
9
9
  export type { FlagDefinitionCacheData, FlagDefinitionCacheInput, FlagDefinitionCacheProvider, } from './extensions/feature-flags/cache';
10
10
  export { FeatureFlagError } from '@posthog/core';
11
11
  export type { FeatureFlagErrorType, UnresolvedFlagReason } from '@posthog/core';