sendlit 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -60,11 +60,12 @@ new SendLit({
60
60
 
61
61
  | Resource | Methods |
62
62
  | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
63
- | `sendlit.contacts` | `create`, `list`, `listAll`, `get`, `update`, `remove`, `addTag`, `removeTag`, `deliveries` |
63
+ | `sendlit.contacts` | `create`, `list`, `listAll`, `get`, `update`, `remove`, `addTag`, `removeTag`, `deliveries`, `events` |
64
64
  | `sendlit.segments` | `create`, `list`, `get`, `update`, `remove` |
65
65
  | `sendlit.templates` | `list`, `listSystem`, `get`, `create`, `update`, `duplicate`, `remove` |
66
- | `sendlit.sequences` | Broadcasts and sequences: `create`, `list`, `listAll`, `get`, `update`, `remove`, `addEmail`, `updateEmail`, `removeEmail`, `start`, `pause`, `stats`, `subscribers` |
66
+ | `sendlit.sequences` | Broadcasts and sequences: `create`, `list`, `listAll`, `get`, `update`, `remove`, `addEmail`, `updateEmail`, `publishChanges`, `discardChanges`, `emailVersions`, `restoreEmailVersion`, `removeEmail`, `start`, `pause`, `stats`, `subscribers` |
67
67
  | `sendlit.emails` | Transactional email: `send`, `get`, `list`, `listAll` |
68
+ | `sendlit.events` | Custom events: `track`, and `definitions.list`, `definitions.get`, `definitions.create`, `definitions.update`, `definitions.delete` |
68
69
  | `sendlit.provisioning` | Organization key only: `provisionTeam`, `getTeam`, `updateTeam`, `createTeamKey`, `suspendTeam`, `resumeTeam`, `archiveTeam`, `getTeamUsage` |
69
70
  | `sendlit.suppressions` | `list`, `listAll`, `get`, `release` |
70
71
  | `sendlit.deliveryEvents` | `list`, `listAll`, `get` |
@@ -85,6 +86,31 @@ Request and response types are exported too, for example `Contact`,
85
86
  the onboarding trigger, or call `addTag` after creating the contact if you
86
87
  want a tag trigger.
87
88
 
89
+ ### Custom events
90
+
91
+ `events.track` records something a contact did in your product and starts
92
+ every active sequence triggered by that event. Nothing has to be set up in
93
+ SendLit first: the first event with a new name registers it.
94
+
95
+ ```ts
96
+ await sendlit.events.track({
97
+ email: user.email,
98
+ eventName: "course purchased",
99
+ properties: { courseName: course.title, price: order.total },
100
+ idempotencyKey: order.id,
101
+ });
102
+ ```
103
+
104
+ - An unknown email creates the contact (`createContact` defaults to `true`).
105
+ Pass `createContact: false` to get a 404 instead.
106
+ - The same `idempotencyKey` within 30 days stores one event; repeats return
107
+ the original with `duplicate: true`.
108
+ - `backfill: true` imports history without starting any sequence.
109
+
110
+ `events.definitions` manages the team's list of events, and
111
+ `contacts.events(contactId)` lists the events a contact sent. See
112
+ [Custom events](https://sendlit.app/developers/events).
113
+
88
114
  ### Pagination
89
115
 
90
116
  `list` returns one page as `{ items, total }`. `listAll` returns an async
@@ -133,7 +159,7 @@ jitter. It honors `Retry-After` when the response includes one.
133
159
  safe to repeat. That means `GET`, `PUT` and `DELETE` requests,
134
160
  `contacts.create` and `contacts.addTag` (both find-or-create),
135
161
  `provisioning.provisionTeam` (idempotent by `externalId`), and
136
- `emails.send` when you pass an `idempotencyKey`.
162
+ `emails.send` and `events.track` when you pass an `idempotencyKey`.
137
163
 
138
164
  ```ts
139
165
  await sendlit.emails.send({
@@ -203,6 +229,19 @@ Starting a broadcast or sequence requires a mailing address in the team's
203
229
  settings (set it with `mailingAddress` when provisioning) and a way to send
204
230
  email: either an organization delivery grant or the team's own ESP.
205
231
 
232
+ While a broadcast or sequence is active, `updateEmail` saves subject and
233
+ content changes as a draft; contacts keep getting the published version until
234
+ you publish:
235
+
236
+ ```ts
237
+ await sendlit.sequences.updateEmail(sequenceId, emailId, { subject: "Updated" });
238
+ await sendlit.sequences.publishChanges(sequenceId, {
239
+ emailIds: [emailId],
240
+ // Sequences: "in_flight" (default) or "new_entrants".
241
+ scope: "new_entrants",
242
+ });
243
+ ```
244
+
206
245
  ## License
207
246
 
208
247
  MIT