activitysmith 1.10.0 → 1.12.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
@@ -1,50 +1,22 @@
1
- # ActivitySmith Node SDK
1
+ # ActivitySmith Node.js SDK
2
2
 
3
- The ActivitySmith Node SDK provides convenient access to the ActivitySmith API from server-side JavaScript and TypeScript applications.
4
-
5
- ## Documentation
6
-
7
- See [API reference](https://activitysmith.com/docs/api-reference/introduction)
8
-
9
- ## Table of Contents
10
-
11
- - [Installation](#installation)
12
- - [Setup](#setup)
13
- - [Push Notifications](#push-notifications)
14
- - [Send a Push Notification](#send-a-push-notification)
15
- - [Rich Push Notifications with Media](#rich-push-notifications-with-media)
16
- - [Actionable Push Notifications](#actionable-push-notifications)
17
- - [Live Activities](#live-activities)
18
- - [Start & Update Live Activity](#start--update-live-activity)
19
- - [End Live Activity](#end-live-activity)
20
- - [Live Activity Action](#live-activity-action)
21
- - [Icons and Badges](#icons-and-badges)
22
- - [Live Activity Colors](#live-activity-colors)
23
- - [Widgets](#widgets)
24
- - [App Icon Badge Count](#app-icon-badge-count)
25
- - [Channels](#channels)
26
- - [Tags](#tags)
3
+ [Documentation](https://activitysmith.com/docs/sdks/node)
27
4
 
28
5
  ## Installation
29
6
 
30
- ```sh
7
+ Install the ActivitySmith Node.js SDK with npm:
8
+
9
+ ```bash
31
10
  npm install activitysmith
32
11
  ```
33
12
 
34
- ## Setup
35
-
36
- ```ts
37
- import ActivitySmith from "activitysmith";
38
-
39
- const activitysmith = new ActivitySmith({
40
- apiKey: process.env.ACTIVITYSMITH_API_KEY,
41
- });
42
- ```
13
+ ## Quickstart
43
14
 
44
- CommonJS:
15
+ 1. [Create an API key](https://activitysmith.com/app/keys)
16
+ 2. Set `ACTIVITYSMITH_API_KEY` or pass `apiKey` when creating the client.
45
17
 
46
18
  ```js
47
- const ActivitySmith = require("activitysmith");
19
+ import ActivitySmith from "activitysmith";
48
20
 
49
21
  const activitysmith = new ActivitySmith({
50
22
  apiKey: process.env.ACTIVITYSMITH_API_KEY,
@@ -55,11 +27,11 @@ const activitysmith = new ActivitySmith({
55
27
 
56
28
  ### Send a Push Notification
57
29
 
58
- <p align="center">
59
- <img src="https://cdn.activitysmith.com/features/new-subscription-push-notification.png" alt="Push notification example" width="680" />
60
- </p>
30
+ Send an immediate notification for a completed task or event.
61
31
 
62
- ```ts
32
+ ![Push Notification example for a new subscription event](https://cdn.activitysmith.com/features/new-subscription-push-notification.png)
33
+
34
+ ```js
63
35
  await activitysmith.notifications.send({
64
36
  title: "New subscription 💸",
65
37
  message: "Customer upgraded to Pro plan",
@@ -68,24 +40,19 @@ await activitysmith.notifications.send({
68
40
 
69
41
  ### Rich Push Notifications with Media
70
42
 
71
- <p align="center">
72
- <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-image.png" alt="Rich push notification with image" width="680" />
73
- </p>
43
+ ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png)
74
44
 
75
- ```ts
45
+ ```js
76
46
  await activitysmith.notifications.send({
77
47
  title: "Homepage ready",
78
48
  message: "Your agent finished the redesign.",
79
49
  media: "https://cdn.example.com/output/homepage-v2.png",
80
- redirection: "https://github.com/acme/web/pull/482",
81
50
  });
82
51
  ```
83
52
 
84
- Send images, videos, or audio with your push notifications, press and hold to preview media directly from the notification, then tap through to open the linked content.
53
+ Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media.
85
54
 
86
- <p align="center">
87
- <img src="https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png" alt="Rich push notification with audio" width="680" />
88
- </p>
55
+ ![Rich Push Notification with audio](https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png)
89
56
 
90
57
  What will work:
91
58
 
@@ -94,23 +61,51 @@ What will work:
94
61
  - direct video file URL: `.mp4`, `.mov`, etc.
95
62
  - URL that responds with a proper media `Content-Type`, even if the path has no extension
96
63
 
64
+ `media` cannot be combined with `actions`.
65
+
66
+ ### Push Notifications with Redirection
67
+
68
+ Open a web page, run an iOS Shortcut, or open an app when someone taps the notification. `redirection` supports:
69
+
70
+ - **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
71
+ - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
72
+ - **App deep links:** Installed apps or specific content within them
73
+ - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6`
74
+ - **Termius:** `termius://` to open the app
75
+ - **Claude:** `claude://code` to open the Code tab
76
+ - **ChatGPT:** `chatgpt://` to open the app <!-- Verify ChatGPT URL scheme on iOS before publishing -->
77
+
78
+ ```js
79
+ await activitysmith.notifications.send({
80
+ title: "Homepage ready",
81
+ message: "Your agent finished the redesign.",
82
+ redirection: "https://github.com/acme/web/pull/482",
83
+ });
84
+ ```
85
+
97
86
  ### Actionable Push Notifications
98
87
 
99
- <p align="center">
100
- <img src="https://cdn.activitysmith.com/features/actionable-push-notifications-2.png" alt="Actionable push notification example" width="680" />
101
- </p>
88
+ ![Actionable Push Notification with redirection and actions](https://cdn.activitysmith.com/features/actionable-push-notifications-2.png)
102
89
 
103
- Push notification `redirection` and `actions` are optional. Use them to open HTTPS URLs, run a specific iPhone Shortcut with `shortcuts://run-shortcut?name=...`, or trigger backend webhook workflows.
104
- Webhooks are executed by the ActivitySmith backend.
90
+ `open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links:
105
91
 
106
- ```ts
92
+ - **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
93
+ - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
94
+ - **App deep links:** Installed apps or specific content within them
95
+ - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6`
96
+ - **Termius:** `termius://` to open the app
97
+ - **Claude:** `claude://code` to open the Code tab
98
+ - **ChatGPT:** `chatgpt://` to open the app <!-- Verify ChatGPT URL scheme on iOS before publishing -->
99
+
100
+ Webhooks are executed by the ActivitySmith backend and must use HTTPS.
101
+
102
+ ```js
107
103
  await activitysmith.notifications.send({
108
104
  title: "New subscription 💸",
109
105
  message: "Customer upgraded to Pro plan",
110
- redirection: "https://crm.example.com/customers/cus_9f3a1d", // Optional
111
106
  actions: [
112
107
  {
113
- title: "Open CRM Profile",
108
+ title: "Open CRM",
114
109
  type: "open_url",
115
110
  url: "https://crm.example.com/customers/cus_9f3a1d",
116
111
  },
@@ -129,30 +124,54 @@ await activitysmith.notifications.send({
129
124
  plan: "pro",
130
125
  },
131
126
  },
132
- ], // Optional (max 4)
127
+ ],
133
128
  });
134
129
  ```
135
130
 
136
131
  ## Live Activities
137
132
 
138
- There are six types of Live Activities:
133
+ Choose the Live Activity type that matches what you want to show:
134
+
135
+ - ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature.
136
+
137
+ - ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
138
+
139
+ - ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.
140
+
141
+ - ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory.
139
142
 
140
- - `stats`: best for showing business numbers side by side, such as revenue, sales, new users, conversion, refunds, or any other value you want visible at a glance
141
- - `metrics`: best for live percentage values that change often, like server CPU, memory usage, disk usage, or error rate
142
- - `segmented_progress`: best for anything that moves through clear stages, like deployments, onboarding flows, backups, ETL pipelines, migrations, and AI agent runs
143
- - `progress`: best for tracking real-time progress with percentage, like tasks, backups, migrations, syncs, or uploads
144
- - `alert`: best for status updates, such as feature adoption, reactivation, onboarding blockers, incidents, escalations, and other operational states
145
- - `timer`: best for countdowns and elapsed runtime, like benchmark runs, uploads, backups, transcodes, and long-running jobs
143
+ - ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
144
+
145
+ - ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion.
146
+
147
+ - ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs.
146
148
 
147
149
  ### Start & Update Live Activity
148
150
 
149
151
  Use a stable `streamKey` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `streamKey` update it.
150
152
 
153
+ #### Value
154
+
155
+ ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png)
156
+
157
+ ```ts
158
+ await activitysmith.liveActivities.stream("revenue-today", {
159
+ content_state: ActivitySmith.contentState({
160
+ title: "Revenue",
161
+ type: "value",
162
+ value: "$1,240",
163
+ color: "green",
164
+ icon: ActivitySmith.alertIcon("dollarsign.circle", { color: "green" }),
165
+ badge: ActivitySmith.alertBadge("↑ 18%", { color: "purple" }),
166
+ }),
167
+ });
168
+ ```
169
+
170
+ Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places.
171
+
151
172
  #### Stats
152
173
 
153
- <p align="center">
154
- <img src="https://cdn.activitysmith.com/features/stats-live-activity.png" alt="Stats Live Activity stream example" width="680" />
155
- </p>
174
+ ![Stats Live Activity stream example](https://cdn.activitysmith.com/features/stats-live-activity.png)
156
175
 
157
176
  ```ts
158
177
  await activitysmith.liveActivities.stream("sales-hourly", {
@@ -172,11 +191,25 @@ await activitysmith.liveActivities.stream("sales-hourly", {
172
191
  });
173
192
  ```
174
193
 
194
+ #### Alert
195
+
196
+ ![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png)
197
+
198
+ ```ts
199
+ await activitysmith.liveActivities.stream("customer-ops", {
200
+ content_state: ActivitySmith.contentState({
201
+ title: "Reactivation",
202
+ message: "Lumen came back after 2 weeks",
203
+ type: "alert",
204
+ icon: ActivitySmith.alertIcon("cloud.sun", { color: "yellow" }),
205
+ badge: ActivitySmith.alertBadge("Customer", { color: "magenta" }),
206
+ }),
207
+ });
208
+ ```
209
+
175
210
  #### Metrics
176
211
 
177
- <p align="center">
178
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png" alt="Metrics Live Activity stream example" width="680" />
179
- </p>
212
+ ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png)
180
213
 
181
214
  ```ts
182
215
  await activitysmith.liveActivities.stream("prod-web-1", {
@@ -194,9 +227,7 @@ await activitysmith.liveActivities.stream("prod-web-1", {
194
227
 
195
228
  #### Segmented Progress
196
229
 
197
- <p align="center">
198
- <img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented Progress Live Activity stream example" width="680" />
199
- </p>
230
+ ![Segmented Progress Live Activity stream example](https://cdn.activitysmith.com/features/update-live-activity.png)
200
231
 
201
232
  ```ts
202
233
  await activitysmith.liveActivities.stream("nightly-backup", {
@@ -212,9 +243,7 @@ await activitysmith.liveActivities.stream("nightly-backup", {
212
243
 
213
244
  #### Progress
214
245
 
215
- <p align="center">
216
- <img src="https://cdn.activitysmith.com/features/progress-live-activity.png" alt="Progress Live Activity stream example" width="680" />
217
- </p>
246
+ ![Progress Live Activity stream example](https://cdn.activitysmith.com/features/progress-live-activity.png)
218
247
 
219
248
  ```ts
220
249
  await activitysmith.liveActivities.stream("search-reindex", {
@@ -227,29 +256,9 @@ await activitysmith.liveActivities.stream("search-reindex", {
227
256
  });
228
257
  ```
229
258
 
230
- #### Alert
231
-
232
- <p align="center">
233
- <img src="https://cdn.activitysmith.com/features/alert-live-activity.png" alt="Alert Live Activity stream example" width="680" />
234
- </p>
235
-
236
- ```ts
237
- await activitysmith.liveActivities.stream("customer-ops", {
238
- content_state: ActivitySmith.contentState({
239
- title: "Reactivation",
240
- message: "Lumen came back after 2 weeks",
241
- type: "alert",
242
- icon: ActivitySmith.alertIcon("cloud.sun", { color: "yellow" }),
243
- badge: ActivitySmith.alertBadge("Customer", { color: "magenta" }),
244
- }),
245
- });
246
- ```
247
-
248
259
  #### Timer
249
260
 
250
- <p align="center">
251
- <img src="https://cdn.activitysmith.com/features/timer-live-activity.png" alt="Timer Live Activity showing a benchmark run countdown" width="680" />
252
- </p>
261
+ ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png)
253
262
 
254
263
  ```ts
255
264
  await activitysmith.liveActivities.stream("benchmark-run", {
@@ -269,7 +278,7 @@ To start at 00:00 and count up, set `counts_down: false` and leave out `duration
269
278
 
270
279
  ### End Live Activity
271
280
 
272
- Call `endStream(...)` with the same `streamKey` to dismiss the Live Activity. You can include final values before it is removed. By default, iOS removes the Live Activity after two minutes. Set `auto_dismiss_minutes` to choose a different dismissal time, including `0` for immediate dismissal.
281
+ Call `endStream(...)` with the same `streamKey` to dismiss the Live Activity. You can include final values before it is removed. Set `auto_dismiss_seconds` to dismiss it after a delay in seconds, or `auto_dismiss_minutes` for minutes. Use `0` for immediate dismissal. Seconds take precedence if both are set.
273
282
 
274
283
  ```ts
275
284
  await activitysmith.liveActivities.endStream("prod-web-1", {
@@ -281,25 +290,82 @@ await activitysmith.liveActivities.endStream("prod-web-1", {
281
290
  { label: "CPU", value: 7, unit: "%" },
282
291
  { label: "MEM", value: 38, unit: "%" },
283
292
  ],
284
- auto_dismiss_minutes: 2,
293
+ auto_dismiss_seconds: 30,
285
294
  },
286
295
  });
287
296
  ```
288
297
 
298
+ ### Icons and Badges
299
+
300
+ Add more context to Live Activities with icons and badges.
301
+
302
+ #### Icon
303
+
304
+ Supported Live Activity types: `value`, `stats`, `alert`, `metrics`, `segmented_progress`, `progress`, and `timer`.
305
+
306
+ ![Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen](https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png)
307
+
308
+ ```ts
309
+ await activitysmith.liveActivities.stream("prod-web-1", {
310
+ content_state: ActivitySmith.contentState({
311
+ title: "Server Health",
312
+ subtitle: "prod-web-1",
313
+ type: "metrics",
314
+ icon: ActivitySmith.alertIcon("server.rack", { color: "blue" }),
315
+ metrics: [
316
+ { label: "CPU", value: 18, unit: "%" },
317
+ { label: "MEM", value: 42, unit: "%" },
318
+ ],
319
+ }),
320
+ });
321
+ ```
322
+
323
+ The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools:
324
+
325
+ - [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
326
+ - [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
327
+ - [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
328
+
329
+ #### Badge
330
+
331
+ Badges are supported by `value`, `alert`, `segmented_progress`, and `progress` Live Activities.
332
+
333
+ ![Progress Live Activity with a badge on the iPhone Lock Screen](https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png)
334
+
335
+ ```ts
336
+ await activitysmith.liveActivities.stream("nightly-database-backup", {
337
+ content_state: ActivitySmith.contentState({
338
+ title: "Nightly Database Backup",
339
+ subtitle: "verify restore",
340
+ type: "progress",
341
+ badge: ActivitySmith.alertBadge("S3", { color: "cyan" }),
342
+ percentage: 62,
343
+ }),
344
+ });
345
+ ```
346
+
347
+ ### Live Activity Colors
348
+
349
+ Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
350
+
351
+ `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
352
+
289
353
  ### Live Activity Action
290
354
 
291
- Live Activities can include an action button.
355
+ ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png)
292
356
 
293
- - `open_url`: open an HTTPS URL.
294
- - `open_url` with a `shortcuts://` URL: run an Apple Shortcut, for example to open an app.
295
- - `webhook`: trigger a backend GET/POST workflow.
357
+ Live Activities can include an action button.
296
358
 
297
- <p align="center">
298
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Live Activity with action button" width="680" />
299
- </p>
359
+ - `open_url`: Open a web page or run an iOS Shortcut
360
+ - `webhook`: Trigger a backend GET/POST workflow
300
361
 
301
362
  #### Open URL action
302
363
 
364
+ Open a web page or run an iOS Shortcut when someone taps the button. Supported links:
365
+
366
+ - **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
367
+ - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
368
+
303
369
  ```ts
304
370
  await activitysmith.liveActivities.stream("prod-web-1", {
305
371
  content_state: {
@@ -314,7 +380,7 @@ await activitysmith.liveActivities.stream("prod-web-1", {
314
380
  action: {
315
381
  title: "Dashboard",
316
382
  type: "open_url",
317
- url: "https://ops.example.com/servers/prod-web-1",
383
+ url: "https://status.example.com/servers/prod-web-1",
318
384
  },
319
385
  });
320
386
  ```
@@ -322,13 +388,15 @@ await activitysmith.liveActivities.stream("prod-web-1", {
322
388
  #### Apple Shortcut action
323
389
 
324
390
  ```ts
325
- await activitysmith.liveActivities.stream("deploy-payments-api", {
391
+ await activitysmith.liveActivities.stream("prod-web-1", {
326
392
  content_state: {
327
- title: "Deploying payments-api",
328
- subtitle: "Running database migrations",
329
- type: "segmented_progress",
330
- number_of_steps: 5,
331
- current_step: 3,
393
+ title: "Server Health",
394
+ subtitle: "prod-web-1",
395
+ type: "metrics",
396
+ metrics: [
397
+ { label: "CPU", value: 76, unit: "%" },
398
+ { label: "MEM", value: 52, unit: "%" },
399
+ ],
332
400
  },
333
401
  action: {
334
402
  title: "Chat with Jarvis",
@@ -364,13 +432,11 @@ await activitysmith.liveActivities.stream("search-reindex", {
364
432
 
365
433
  #### Secondary action
366
434
 
367
- <p align="center">
368
- <img src="https://cdn.activitysmith.com/features/live-activity-secondary-action.png" alt="Alert Live Activity with primary and secondary action buttons" width="680" />
369
- </p>
435
+ ![Alert Live Activity with primary and secondary action buttons](https://cdn.activitysmith.com/features/live-activity-secondary-action.png)
370
436
 
371
437
  Use `secondary_action` when you want a second button beside the primary `action`.
372
438
 
373
- The secondary action button is supported for `alert`, `progress`, and `segmented_progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes.
439
+ The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes.
374
440
 
375
441
  ```ts
376
442
  await activitysmith.liveActivities.stream("agent-approval", {
@@ -411,76 +477,13 @@ await activitysmith.liveActivities.stream("agent-approval", {
411
477
  });
412
478
  ```
413
479
 
414
- ### Icons and Badges
415
-
416
- Add more context to Live Activities with icons and badges.
417
-
418
- #### Icon
419
-
420
- Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, `alert`, and `timer`.
421
-
422
- <p align="center">
423
- <img src="https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png" alt="Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen" width="680" />
424
- </p>
425
-
426
- ```ts
427
- await activitysmith.liveActivities.stream("prod-web-1", {
428
- content_state: ActivitySmith.contentState({
429
- title: "Server Health",
430
- subtitle: "prod-web-1",
431
- type: "metrics",
432
- icon: ActivitySmith.alertIcon("server.rack", { color: "blue" }),
433
- metrics: [
434
- { label: "CPU", value: 18, unit: "%" },
435
- { label: "MEM", value: 42, unit: "%" },
436
- ],
437
- }),
438
- });
439
- ```
440
-
441
- The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools:
442
-
443
- - [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
444
- - [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
445
- - [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
446
-
447
- #### Badge
448
-
449
- Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities.
450
-
451
- <p align="center">
452
- <img src="https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png" alt="Progress Live Activity with a badge on the iPhone Lock Screen" width="680" />
453
- </p>
480
+ ## Lock Screen Widgets
454
481
 
455
- ```ts
456
- await activitysmith.liveActivities.stream("nightly-database-backup", {
457
- content_state: ActivitySmith.contentState({
458
- title: "Nightly Database Backup",
459
- subtitle: "verify restore",
460
- type: "progress",
461
- badge: ActivitySmith.alertBadge("S3", { color: "cyan" }),
462
- percentage: 62,
463
- }),
464
- });
465
- ```
482
+ ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png)
466
483
 
467
- ### Live Activity Colors
484
+ ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Create a metric in the [web app](https://activitysmith.com/app/widgets), then update the metric value using our API, add a widget to your lock screen and it will fetch the latest update automatically.
468
485
 
469
- Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
470
-
471
- `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
472
-
473
- ## Widgets
474
-
475
- <p align="center">
476
- <img src="https://cdn.activitysmith.com/features/lock-screen-widgets.png" alt="Lock screen widgets" width="680" />
477
- </p>
478
-
479
- ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Create a metric in the <a href="https://activitysmith.com/app/widgets" target="_blank" rel="noopener noreferrer">web app</a>, then update the metric value using our API, add a widget to your lock screen and it will fetch the latest update automatically.
480
-
481
- <p align="center">
482
- <img src="https://cdn.activitysmith.com/features/create-widget-metric.png" alt="Create widget metric" width="680" />
483
- </p>
486
+ ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png)
484
487
 
485
488
  Use the metric key to update its value.
486
489
 
@@ -496,65 +499,60 @@ await activitysmith.metrics.update("prod.status", "healthy");
496
499
 
497
500
  ## App Icon Badge Count
498
501
 
499
- <p align="center">
500
- <img src="https://cdn.activitysmith.com/features/badge-count.png" alt="ActivitySmith app icon with an App Icon Badge Count" width="680" />
501
- </p>
502
+ ![ActivitySmith app icon with an App Icon Badge Count](https://cdn.activitysmith.com/features/badge-count.png)
502
503
 
503
504
  Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view.
504
505
 
505
- Set or update the badge value.
506
+ ### Set or update the badge value
506
507
 
507
- ```ts
508
+ ```js
508
509
  await activitysmith.badgeCount(8333);
509
510
  ```
510
511
 
511
- To clear the badge, set its value to 0.
512
+ ### Clear the badge
512
513
 
513
- ```ts
514
+ Pass `0` to clear the badge.
515
+
516
+ ```js
514
517
  await activitysmith.badgeCount(0);
515
518
  ```
516
519
 
517
- ## Channels
518
-
519
- Use `channels` to target specific team members or devices
520
+ ## Metadata
520
521
 
521
- ### Push Notifications
522
+ Metadata adds extra information to Push Notification and Live Activity details in ActivitySmith. It does not appear in the notification or Live Activity on your device.
522
523
 
523
- ```ts
524
+ ```js
524
525
  await activitysmith.notifications.send({
525
526
  title: "New subscription 💸",
526
527
  message: "Customer upgraded to Pro plan",
527
- channels: ["sales", "customer-success"],
528
+ metadata: {
529
+ customer_id: "382",
530
+ plan: "Pro",
531
+ amount: 29,
532
+ trial: false,
533
+ },
528
534
  });
529
- ```
530
-
531
- ### Live Activities
532
535
 
533
- ```ts
534
- await activitysmith.liveActivities.start({
536
+ await activitysmith.liveActivities.stream("customer-import", {
535
537
  content_state: {
536
- title: "Nightly Database Backup",
537
- subtitle: "verify restore",
538
+ title: "Customer Import",
538
539
  type: "progress",
539
- percentage: 62,
540
+ percentage: 60,
541
+ },
542
+ metadata: {
543
+ job_id: "import-382",
544
+ records: 1200,
540
545
  },
541
- channels: ["sales", "customer-success"],
542
546
  });
543
547
  ```
544
548
 
545
- ### App Icon Badge Count
546
-
547
- ```ts
548
- await activitysmith.badgeCount(3, {
549
- channels: ["sales", "customer-success"],
550
- });
551
- ```
549
+ Values can be strings, numbers, or booleans. Metadata supports up to 50 entries and 16 KB of JSON, with keys up to 100 characters and strings up to 4,000 characters. Nested objects, arrays, and null values are not supported.
552
550
 
553
551
  ## Tags
554
552
 
555
553
  Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them.
556
554
 
557
- ```ts
555
+ ```js
558
556
  await activitysmith.notifications.send({
559
557
  title: "New subscription 💸",
560
558
  message: "Customer upgraded to Pro plan",
@@ -562,26 +560,60 @@ await activitysmith.notifications.send({
562
560
  });
563
561
  ```
564
562
 
563
+ On Live Activity stream updates and legacy `update` or `end` calls, omit `tags` to keep existing Tags, supply a list to replace them, or pass `tags: []` to clear them.
564
+
565
+ ```js
566
+ await activitysmith.liveActivities.update({
567
+ activity_id: "YOUR_ACTIVITY_ID",
568
+ content_state: { title: "Customer Import", percentage: 60 },
569
+ tags: [],
570
+ });
571
+ ```
572
+
573
+ ## Channels
574
+
575
+ Use `channels` to target specific team members or devices when sending Push Notifications, Live Activities, or App Icon Badge Count updates. Omit it for account-wide delivery.
576
+
577
+ ```js
578
+ await activitysmith.notifications.send({
579
+ title: "New subscription 💸",
580
+ message: "Customer upgraded to Pro plan",
581
+ channels: ["sales", "customer-success"],
582
+ });
583
+
584
+ await activitysmith.liveActivities.stream("nightly-backup", {
585
+ content_state: {
586
+ title: "Nightly database backup",
587
+ number_of_steps: 3,
588
+ current_step: 1,
589
+ type: "segmented_progress",
590
+ },
591
+ channels: ["ios-builds"],
592
+ });
593
+
594
+ await activitysmith.badgeCount(3, {
595
+ channels: ["sales", "customer-success"],
596
+ });
597
+ ```
598
+
565
599
  ## Error Handling
566
600
 
567
- ```ts
601
+ SDK calls return promises, so you can wrap API calls with `try/catch`:
602
+
603
+ ```js
568
604
  try {
569
- await activitysmith.notifications.send({
570
- title: "New subscription 💸",
571
- });
605
+ await activitysmith.notifications.send({ title: "Hello" });
572
606
  } catch (error) {
573
607
  console.error(error);
574
608
  }
575
609
  ```
576
610
 
577
- ## TypeScript Support
578
-
579
- This package is written in TypeScript and ships with type definitions out of the box.
611
+ ## Additional Resources
580
612
 
581
- ## Requirements
613
+ ### [NPM Package](https://www.npmjs.com/package/activitysmith)
582
614
 
583
- - Node.js 18 or newer
615
+ Install the ActivitySmith Node.js SDK from npm
584
616
 
585
- ## License
617
+ ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-node)
586
618
 
587
- MIT
619
+ View the Node.js SDK source on GitHub