activitysmith 1.9.0 → 1.11.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 +236 -204
- package/dist/generated/apis/AppIconBadgesApi.d.ts +4 -4
- package/dist/generated/apis/AppIconBadgesApi.js +4 -4
- package/dist/generated/apis/LiveActivitiesApi.d.ts +10 -10
- package/dist/generated/apis/LiveActivitiesApi.js +10 -10
- package/dist/generated/apis/PushNotificationsApi.d.ts +2 -2
- package/dist/generated/apis/PushNotificationsApi.js +2 -2
- package/dist/generated/models/index.d.ts +224 -14
- package/dist/generated/models/index.js +8 -1
- package/dist/src/ActivitySmith.d.ts +4 -0
- package/dist/src/ActivitySmith.js +18 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,49 +1,22 @@
|
|
|
1
|
-
# ActivitySmith Node SDK
|
|
1
|
+
# ActivitySmith Node.js SDK
|
|
2
2
|
|
|
3
|
-
|
|
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)
|
|
3
|
+
[Documentation](https://activitysmith.com/docs/sdks/node)
|
|
26
4
|
|
|
27
5
|
## Installation
|
|
28
6
|
|
|
29
|
-
|
|
7
|
+
Install the ActivitySmith Node.js SDK with npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
30
10
|
npm install activitysmith
|
|
31
11
|
```
|
|
32
12
|
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import ActivitySmith from "activitysmith";
|
|
37
|
-
|
|
38
|
-
const activitysmith = new ActivitySmith({
|
|
39
|
-
apiKey: process.env.ACTIVITYSMITH_API_KEY,
|
|
40
|
-
});
|
|
41
|
-
```
|
|
13
|
+
## Quickstart
|
|
42
14
|
|
|
43
|
-
|
|
15
|
+
1. [Create an API key](https://activitysmith.com/app/keys)
|
|
16
|
+
2. Set `ACTIVITYSMITH_API_KEY` or pass `apiKey` when creating the client.
|
|
44
17
|
|
|
45
18
|
```js
|
|
46
|
-
|
|
19
|
+
import ActivitySmith from "activitysmith";
|
|
47
20
|
|
|
48
21
|
const activitysmith = new ActivitySmith({
|
|
49
22
|
apiKey: process.env.ACTIVITYSMITH_API_KEY,
|
|
@@ -54,11 +27,11 @@ const activitysmith = new ActivitySmith({
|
|
|
54
27
|
|
|
55
28
|
### Send a Push Notification
|
|
56
29
|
|
|
57
|
-
|
|
58
|
-
<img src="https://cdn.activitysmith.com/features/new-subscription-push-notification.png" alt="Push notification example" width="680" />
|
|
59
|
-
</p>
|
|
30
|
+
Send an immediate notification for a completed task or event.
|
|
60
31
|
|
|
61
|
-
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
```js
|
|
62
35
|
await activitysmith.notifications.send({
|
|
63
36
|
title: "New subscription 💸",
|
|
64
37
|
message: "Customer upgraded to Pro plan",
|
|
@@ -67,24 +40,19 @@ await activitysmith.notifications.send({
|
|
|
67
40
|
|
|
68
41
|
### Rich Push Notifications with Media
|
|
69
42
|
|
|
70
|
-
|
|
71
|
-
<img src="https://cdn.activitysmith.com/features/rich-push-notification-with-image.png" alt="Rich push notification with image" width="680" />
|
|
72
|
-
</p>
|
|
43
|
+

|
|
73
44
|
|
|
74
|
-
```
|
|
45
|
+
```js
|
|
75
46
|
await activitysmith.notifications.send({
|
|
76
47
|
title: "Homepage ready",
|
|
77
48
|
message: "Your agent finished the redesign.",
|
|
78
49
|
media: "https://cdn.example.com/output/homepage-v2.png",
|
|
79
|
-
redirection: "https://github.com/acme/web/pull/482",
|
|
80
50
|
});
|
|
81
51
|
```
|
|
82
52
|
|
|
83
|
-
|
|
53
|
+
Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media.
|
|
84
54
|
|
|
85
|
-
|
|
86
|
-
<img src="https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png" alt="Rich push notification with audio" width="680" />
|
|
87
|
-
</p>
|
|
55
|
+

|
|
88
56
|
|
|
89
57
|
What will work:
|
|
90
58
|
|
|
@@ -93,23 +61,51 @@ What will work:
|
|
|
93
61
|
- direct video file URL: `.mp4`, `.mov`, etc.
|
|
94
62
|
- URL that responds with a proper media `Content-Type`, even if the path has no extension
|
|
95
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
|
+
|
|
96
86
|
### Actionable Push Notifications
|
|
97
87
|
|
|
98
|
-
|
|
99
|
-
<img src="https://cdn.activitysmith.com/features/actionable-push-notifications-2.png" alt="Actionable push notification example" width="680" />
|
|
100
|
-
</p>
|
|
88
|
+

|
|
101
89
|
|
|
102
|
-
|
|
103
|
-
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:
|
|
104
91
|
|
|
105
|
-
|
|
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
|
|
106
103
|
await activitysmith.notifications.send({
|
|
107
104
|
title: "New subscription 💸",
|
|
108
105
|
message: "Customer upgraded to Pro plan",
|
|
109
|
-
redirection: "https://crm.example.com/customers/cus_9f3a1d", // Optional
|
|
110
106
|
actions: [
|
|
111
107
|
{
|
|
112
|
-
title: "Open CRM
|
|
108
|
+
title: "Open CRM",
|
|
113
109
|
type: "open_url",
|
|
114
110
|
url: "https://crm.example.com/customers/cus_9f3a1d",
|
|
115
111
|
},
|
|
@@ -128,20 +124,37 @@ await activitysmith.notifications.send({
|
|
|
128
124
|
plan: "pro",
|
|
129
125
|
},
|
|
130
126
|
},
|
|
131
|
-
],
|
|
127
|
+
],
|
|
132
128
|
});
|
|
133
129
|
```
|
|
134
130
|
|
|
135
131
|
## Live Activities
|
|
136
132
|
|
|
137
|
-
|
|
133
|
+
Choose the Live Activity type that matches what you want to show:
|
|
134
|
+
|
|
135
|
+

|
|
136
|
+
|
|
137
|
+
**Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
|
|
138
|
+
|
|
139
|
+

|
|
140
|
+
|
|
141
|
+
**Metrics**: Track two related values with segmented bars, such as CPU and memory.
|
|
142
|
+
|
|
143
|
+

|
|
144
|
+
|
|
145
|
+
**Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
|
|
138
146
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+

|
|
148
|
+
|
|
149
|
+
**Progress**: Show percentage progress for jobs that move continuously toward completion.
|
|
150
|
+
|
|
151
|
+

|
|
152
|
+
|
|
153
|
+
**Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.
|
|
154
|
+
|
|
155
|
+

|
|
156
|
+
|
|
157
|
+
**Timer**: Count down from a duration, or count up from 00:00 while a job runs.
|
|
145
158
|
|
|
146
159
|
### Start & Update Live Activity
|
|
147
160
|
|
|
@@ -149,9 +162,7 @@ Use a stable `streamKey` to identify the metric, job, deployment, or system you
|
|
|
149
162
|
|
|
150
163
|
#### Stats
|
|
151
164
|
|
|
152
|
-
|
|
153
|
-
<img src="https://cdn.activitysmith.com/features/stats-live-activity.png" alt="Stats Live Activity stream example" width="680" />
|
|
154
|
-
</p>
|
|
165
|
+

|
|
155
166
|
|
|
156
167
|
```ts
|
|
157
168
|
await activitysmith.liveActivities.stream("sales-hourly", {
|
|
@@ -173,9 +184,7 @@ await activitysmith.liveActivities.stream("sales-hourly", {
|
|
|
173
184
|
|
|
174
185
|
#### Metrics
|
|
175
186
|
|
|
176
|
-
|
|
177
|
-
<img src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png" alt="Metrics Live Activity stream example" width="680" />
|
|
178
|
-
</p>
|
|
187
|
+

|
|
179
188
|
|
|
180
189
|
```ts
|
|
181
190
|
await activitysmith.liveActivities.stream("prod-web-1", {
|
|
@@ -193,9 +202,7 @@ await activitysmith.liveActivities.stream("prod-web-1", {
|
|
|
193
202
|
|
|
194
203
|
#### Segmented Progress
|
|
195
204
|
|
|
196
|
-
|
|
197
|
-
<img src="https://cdn.activitysmith.com/features/update-live-activity.png" alt="Segmented Progress Live Activity stream example" width="680" />
|
|
198
|
-
</p>
|
|
205
|
+

|
|
199
206
|
|
|
200
207
|
```ts
|
|
201
208
|
await activitysmith.liveActivities.stream("nightly-backup", {
|
|
@@ -211,9 +218,7 @@ await activitysmith.liveActivities.stream("nightly-backup", {
|
|
|
211
218
|
|
|
212
219
|
#### Progress
|
|
213
220
|
|
|
214
|
-
|
|
215
|
-
<img src="https://cdn.activitysmith.com/features/progress-live-activity.png" alt="Progress Live Activity stream example" width="680" />
|
|
216
|
-
</p>
|
|
221
|
+

|
|
217
222
|
|
|
218
223
|
```ts
|
|
219
224
|
await activitysmith.liveActivities.stream("search-reindex", {
|
|
@@ -228,9 +233,7 @@ await activitysmith.liveActivities.stream("search-reindex", {
|
|
|
228
233
|
|
|
229
234
|
#### Alert
|
|
230
235
|
|
|
231
|
-
|
|
232
|
-
<img src="https://cdn.activitysmith.com/features/alert-live-activity.png" alt="Alert Live Activity stream example" width="680" />
|
|
233
|
-
</p>
|
|
236
|
+

|
|
234
237
|
|
|
235
238
|
```ts
|
|
236
239
|
await activitysmith.liveActivities.stream("customer-ops", {
|
|
@@ -246,9 +249,7 @@ await activitysmith.liveActivities.stream("customer-ops", {
|
|
|
246
249
|
|
|
247
250
|
#### Timer
|
|
248
251
|
|
|
249
|
-
|
|
250
|
-
<img src="https://cdn.activitysmith.com/features/timer-live-activity.png" alt="Timer Live Activity showing a benchmark run countdown" width="680" />
|
|
251
|
-
</p>
|
|
252
|
+

|
|
252
253
|
|
|
253
254
|
```ts
|
|
254
255
|
await activitysmith.liveActivities.stream("benchmark-run", {
|
|
@@ -268,7 +269,7 @@ To start at 00:00 and count up, set `counts_down: false` and leave out `duration
|
|
|
268
269
|
|
|
269
270
|
### End Live Activity
|
|
270
271
|
|
|
271
|
-
Call `endStream(...)` with the same `streamKey` to dismiss the Live Activity. You can include final values before it is removed.
|
|
272
|
+
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.
|
|
272
273
|
|
|
273
274
|
```ts
|
|
274
275
|
await activitysmith.liveActivities.endStream("prod-web-1", {
|
|
@@ -280,25 +281,82 @@ await activitysmith.liveActivities.endStream("prod-web-1", {
|
|
|
280
281
|
{ label: "CPU", value: 7, unit: "%" },
|
|
281
282
|
{ label: "MEM", value: 38, unit: "%" },
|
|
282
283
|
],
|
|
283
|
-
|
|
284
|
+
auto_dismiss_seconds: 30,
|
|
284
285
|
},
|
|
285
286
|
});
|
|
286
287
|
```
|
|
287
288
|
|
|
289
|
+
### Icons and Badges
|
|
290
|
+
|
|
291
|
+
Add more context to Live Activities with icons and badges.
|
|
292
|
+
|
|
293
|
+
#### Icon
|
|
294
|
+
|
|
295
|
+
Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, `alert`, and `timer`.
|
|
296
|
+
|
|
297
|
+

|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
await activitysmith.liveActivities.stream("prod-web-1", {
|
|
301
|
+
content_state: ActivitySmith.contentState({
|
|
302
|
+
title: "Server Health",
|
|
303
|
+
subtitle: "prod-web-1",
|
|
304
|
+
type: "metrics",
|
|
305
|
+
icon: ActivitySmith.alertIcon("server.rack", { color: "blue" }),
|
|
306
|
+
metrics: [
|
|
307
|
+
{ label: "CPU", value: 18, unit: "%" },
|
|
308
|
+
{ label: "MEM", value: 42, unit: "%" },
|
|
309
|
+
],
|
|
310
|
+
}),
|
|
311
|
+
});
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools:
|
|
315
|
+
|
|
316
|
+
- [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
|
|
317
|
+
- [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
|
|
318
|
+
- [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
|
|
319
|
+
|
|
320
|
+
#### Badge
|
|
321
|
+
|
|
322
|
+
Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities.
|
|
323
|
+
|
|
324
|
+

|
|
325
|
+
|
|
326
|
+
```ts
|
|
327
|
+
await activitysmith.liveActivities.stream("nightly-database-backup", {
|
|
328
|
+
content_state: ActivitySmith.contentState({
|
|
329
|
+
title: "Nightly Database Backup",
|
|
330
|
+
subtitle: "verify restore",
|
|
331
|
+
type: "progress",
|
|
332
|
+
badge: ActivitySmith.alertBadge("S3", { color: "cyan" }),
|
|
333
|
+
percentage: 62,
|
|
334
|
+
}),
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Live Activity Colors
|
|
339
|
+
|
|
340
|
+
Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
|
|
341
|
+
|
|
342
|
+
`lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
|
|
343
|
+
|
|
288
344
|
### Live Activity Action
|
|
289
345
|
|
|
290
|
-
Live
|
|
346
|
+

|
|
291
347
|
|
|
292
|
-
|
|
293
|
-
- `open_url` with a `shortcuts://` URL: run an Apple Shortcut, for example to open an app.
|
|
294
|
-
- `webhook`: trigger a backend GET/POST workflow.
|
|
348
|
+
Live Activities can include an action button.
|
|
295
349
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
</p>
|
|
350
|
+
- `open_url`: Open a web page or run an iOS Shortcut
|
|
351
|
+
- `webhook`: Trigger a backend GET/POST workflow
|
|
299
352
|
|
|
300
353
|
#### Open URL action
|
|
301
354
|
|
|
355
|
+
Open a web page or run an iOS Shortcut when someone taps the button. Supported links:
|
|
356
|
+
|
|
357
|
+
- **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
|
|
358
|
+
- **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
|
|
359
|
+
|
|
302
360
|
```ts
|
|
303
361
|
await activitysmith.liveActivities.stream("prod-web-1", {
|
|
304
362
|
content_state: {
|
|
@@ -313,7 +371,7 @@ await activitysmith.liveActivities.stream("prod-web-1", {
|
|
|
313
371
|
action: {
|
|
314
372
|
title: "Dashboard",
|
|
315
373
|
type: "open_url",
|
|
316
|
-
url: "https://
|
|
374
|
+
url: "https://status.example.com/servers/prod-web-1",
|
|
317
375
|
},
|
|
318
376
|
});
|
|
319
377
|
```
|
|
@@ -321,13 +379,15 @@ await activitysmith.liveActivities.stream("prod-web-1", {
|
|
|
321
379
|
#### Apple Shortcut action
|
|
322
380
|
|
|
323
381
|
```ts
|
|
324
|
-
await activitysmith.liveActivities.stream("
|
|
382
|
+
await activitysmith.liveActivities.stream("prod-web-1", {
|
|
325
383
|
content_state: {
|
|
326
|
-
title: "
|
|
327
|
-
subtitle: "
|
|
328
|
-
type: "
|
|
329
|
-
|
|
330
|
-
|
|
384
|
+
title: "Server Health",
|
|
385
|
+
subtitle: "prod-web-1",
|
|
386
|
+
type: "metrics",
|
|
387
|
+
metrics: [
|
|
388
|
+
{ label: "CPU", value: 76, unit: "%" },
|
|
389
|
+
{ label: "MEM", value: 52, unit: "%" },
|
|
390
|
+
],
|
|
331
391
|
},
|
|
332
392
|
action: {
|
|
333
393
|
title: "Chat with Jarvis",
|
|
@@ -363,9 +423,7 @@ await activitysmith.liveActivities.stream("search-reindex", {
|
|
|
363
423
|
|
|
364
424
|
#### Secondary action
|
|
365
425
|
|
|
366
|
-
|
|
367
|
-
<img src="https://cdn.activitysmith.com/features/live-activity-secondary-action.png" alt="Alert Live Activity with primary and secondary action buttons" width="680" />
|
|
368
|
-
</p>
|
|
426
|
+

|
|
369
427
|
|
|
370
428
|
Use `secondary_action` when you want a second button beside the primary `action`.
|
|
371
429
|
|
|
@@ -410,140 +468,120 @@ await activitysmith.liveActivities.stream("agent-approval", {
|
|
|
410
468
|
});
|
|
411
469
|
```
|
|
412
470
|
|
|
413
|
-
|
|
471
|
+
## Lock Screen Widgets
|
|
414
472
|
|
|
415
|
-
|
|
473
|
+

|
|
416
474
|
|
|
417
|
-
|
|
475
|
+
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.
|
|
418
476
|
|
|
419
|
-
|
|
477
|
+

|
|
420
478
|
|
|
421
|
-
|
|
422
|
-
<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" />
|
|
423
|
-
</p>
|
|
479
|
+
Use the metric key to update its value.
|
|
424
480
|
|
|
425
481
|
```ts
|
|
426
|
-
await activitysmith.
|
|
427
|
-
content_state: ActivitySmith.contentState({
|
|
428
|
-
title: "Server Health",
|
|
429
|
-
subtitle: "prod-web-1",
|
|
430
|
-
type: "metrics",
|
|
431
|
-
icon: ActivitySmith.alertIcon("server.rack", { color: "blue" }),
|
|
432
|
-
metrics: [
|
|
433
|
-
{ label: "CPU", value: 18, unit: "%" },
|
|
434
|
-
{ label: "MEM", value: 42, unit: "%" },
|
|
435
|
-
],
|
|
436
|
-
}),
|
|
437
|
-
});
|
|
482
|
+
await activitysmith.metrics.update("deploy.success_rate", 99.9);
|
|
438
483
|
```
|
|
439
484
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
- [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
|
|
443
|
-
- [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
|
|
444
|
-
- [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
|
|
445
|
-
|
|
446
|
-
#### Badge
|
|
447
|
-
|
|
448
|
-
Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities.
|
|
449
|
-
|
|
450
|
-
<p align="center">
|
|
451
|
-
<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" />
|
|
452
|
-
</p>
|
|
485
|
+
String metric values work too.
|
|
453
486
|
|
|
454
487
|
```ts
|
|
455
|
-
await activitysmith.
|
|
456
|
-
content_state: ActivitySmith.contentState({
|
|
457
|
-
title: "Nightly Database Backup",
|
|
458
|
-
subtitle: "verify restore",
|
|
459
|
-
type: "progress",
|
|
460
|
-
badge: ActivitySmith.alertBadge("S3", { color: "cyan" }),
|
|
461
|
-
percentage: 62,
|
|
462
|
-
}),
|
|
463
|
-
});
|
|
488
|
+
await activitysmith.metrics.update("prod.status", "healthy");
|
|
464
489
|
```
|
|
465
490
|
|
|
466
|
-
|
|
491
|
+
## App Icon Badge Count
|
|
467
492
|
|
|
468
|
-
|
|
493
|
+

|
|
469
494
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
## Widgets
|
|
495
|
+
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.
|
|
473
496
|
|
|
474
|
-
|
|
475
|
-
<img src="https://cdn.activitysmith.com/features/lock-screen-widgets.png" alt="Lock screen widgets" width="680" />
|
|
476
|
-
</p>
|
|
497
|
+
### Set or update the badge value
|
|
477
498
|
|
|
478
|
-
|
|
499
|
+
```js
|
|
500
|
+
await activitysmith.badgeCount(8333);
|
|
501
|
+
```
|
|
479
502
|
|
|
480
|
-
|
|
481
|
-
<img src="https://cdn.activitysmith.com/features/create-widget-metric.png" alt="Create widget metric" width="680" />
|
|
482
|
-
</p>
|
|
503
|
+
### Clear the badge
|
|
483
504
|
|
|
484
|
-
|
|
505
|
+
Pass `0` to clear the badge.
|
|
485
506
|
|
|
486
|
-
```
|
|
487
|
-
await activitysmith.
|
|
507
|
+
```js
|
|
508
|
+
await activitysmith.badgeCount(0);
|
|
488
509
|
```
|
|
489
510
|
|
|
490
|
-
|
|
511
|
+
## Metadata
|
|
491
512
|
|
|
492
|
-
|
|
493
|
-
await activitysmith.metrics.update("prod.status", "healthy");
|
|
494
|
-
```
|
|
513
|
+
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.
|
|
495
514
|
|
|
496
|
-
|
|
515
|
+
```js
|
|
516
|
+
await activitysmith.notifications.send({
|
|
517
|
+
title: "New subscription 💸",
|
|
518
|
+
message: "Customer upgraded to Pro plan",
|
|
519
|
+
metadata: {
|
|
520
|
+
customer_id: "382",
|
|
521
|
+
plan: "Pro",
|
|
522
|
+
amount: 29,
|
|
523
|
+
trial: false,
|
|
524
|
+
},
|
|
525
|
+
});
|
|
497
526
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
527
|
+
await activitysmith.liveActivities.stream("customer-import", {
|
|
528
|
+
content_state: {
|
|
529
|
+
title: "Customer Import",
|
|
530
|
+
type: "progress",
|
|
531
|
+
percentage: 60,
|
|
532
|
+
},
|
|
533
|
+
metadata: {
|
|
534
|
+
job_id: "import-382",
|
|
535
|
+
records: 1200,
|
|
536
|
+
},
|
|
537
|
+
});
|
|
538
|
+
```
|
|
501
539
|
|
|
502
|
-
|
|
540
|
+
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.
|
|
503
541
|
|
|
504
|
-
|
|
542
|
+
## Tags
|
|
505
543
|
|
|
506
|
-
|
|
507
|
-
|
|
544
|
+
Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them.
|
|
545
|
+
|
|
546
|
+
```js
|
|
547
|
+
await activitysmith.notifications.send({
|
|
548
|
+
title: "New subscription 💸",
|
|
549
|
+
message: "Customer upgraded to Pro plan",
|
|
550
|
+
tags: ["user:382", "billing"],
|
|
551
|
+
});
|
|
508
552
|
```
|
|
509
553
|
|
|
510
|
-
|
|
554
|
+
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.
|
|
511
555
|
|
|
512
|
-
```
|
|
513
|
-
await activitysmith.
|
|
556
|
+
```js
|
|
557
|
+
await activitysmith.liveActivities.update({
|
|
558
|
+
activity_id: "YOUR_ACTIVITY_ID",
|
|
559
|
+
content_state: { title: "Customer Import", percentage: 60 },
|
|
560
|
+
tags: [],
|
|
561
|
+
});
|
|
514
562
|
```
|
|
515
563
|
|
|
516
564
|
## Channels
|
|
517
565
|
|
|
518
|
-
Use `channels` to target specific team members or devices
|
|
566
|
+
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.
|
|
519
567
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
```ts
|
|
568
|
+
```js
|
|
523
569
|
await activitysmith.notifications.send({
|
|
524
570
|
title: "New subscription 💸",
|
|
525
571
|
message: "Customer upgraded to Pro plan",
|
|
526
572
|
channels: ["sales", "customer-success"],
|
|
527
573
|
});
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
### Live Activities
|
|
531
574
|
|
|
532
|
-
|
|
533
|
-
await activitysmith.liveActivities.start({
|
|
575
|
+
await activitysmith.liveActivities.stream("nightly-backup", {
|
|
534
576
|
content_state: {
|
|
535
|
-
title: "Nightly
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
577
|
+
title: "Nightly database backup",
|
|
578
|
+
number_of_steps: 3,
|
|
579
|
+
current_step: 1,
|
|
580
|
+
type: "segmented_progress",
|
|
539
581
|
},
|
|
540
|
-
channels: ["
|
|
582
|
+
channels: ["ios-builds"],
|
|
541
583
|
});
|
|
542
|
-
```
|
|
543
|
-
|
|
544
|
-
### App Icon Badge Count
|
|
545
584
|
|
|
546
|
-
```ts
|
|
547
585
|
await activitysmith.badgeCount(3, {
|
|
548
586
|
channels: ["sales", "customer-success"],
|
|
549
587
|
});
|
|
@@ -551,24 +589,18 @@ await activitysmith.badgeCount(3, {
|
|
|
551
589
|
|
|
552
590
|
## Error Handling
|
|
553
591
|
|
|
554
|
-
|
|
592
|
+
SDK calls return promises, so you can wrap API calls with `try/catch`:
|
|
593
|
+
|
|
594
|
+
```js
|
|
555
595
|
try {
|
|
556
|
-
await activitysmith.notifications.send({
|
|
557
|
-
title: "New subscription 💸",
|
|
558
|
-
});
|
|
596
|
+
await activitysmith.notifications.send({ title: "Hello" });
|
|
559
597
|
} catch (error) {
|
|
560
598
|
console.error(error);
|
|
561
599
|
}
|
|
562
600
|
```
|
|
563
601
|
|
|
564
|
-
##
|
|
565
|
-
|
|
566
|
-
This package is written in TypeScript and ships with type definitions out of the box.
|
|
567
|
-
|
|
568
|
-
## Requirements
|
|
569
|
-
|
|
570
|
-
- Node.js 18 or newer
|
|
602
|
+
## Additional Resources
|
|
571
603
|
|
|
572
|
-
|
|
604
|
+
### [NPM Package](https://www.npmjs.com/package/activitysmith)
|
|
573
605
|
|
|
574
|
-
|
|
606
|
+
Install the ActivitySmith Node.js SDK from npm
|