activitysmith 1.10.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 +232 -213
- package/dist/generated/models/index.d.ts +181 -7
- 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,50 +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)
|
|
26
|
-
- [Tags](#tags)
|
|
3
|
+
[Documentation](https://activitysmith.com/docs/sdks/node)
|
|
27
4
|
|
|
28
5
|
## Installation
|
|
29
6
|
|
|
30
|
-
|
|
7
|
+
Install the ActivitySmith Node.js SDK with npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
31
10
|
npm install activitysmith
|
|
32
11
|
```
|
|
33
12
|
|
|
34
|
-
##
|
|
13
|
+
## Quickstart
|
|
35
14
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const activitysmith = new ActivitySmith({
|
|
40
|
-
apiKey: process.env.ACTIVITYSMITH_API_KEY,
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
+

|
|
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
|
-
|
|
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
|
+

|
|
74
44
|
|
|
75
|
-
```
|
|
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
|
-
|
|
53
|
+
Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media.
|
|
85
54
|
|
|
86
|
-
|
|
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
|
+

|
|
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
|
-
|
|
100
|
-
<img src="https://cdn.activitysmith.com/features/actionable-push-notifications-2.png" alt="Actionable push notification example" width="680" />
|
|
101
|
-
</p>
|
|
88
|
+

|
|
102
89
|
|
|
103
|
-
|
|
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
|
-
|
|
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
|
|
108
|
+
title: "Open CRM",
|
|
114
109
|
type: "open_url",
|
|
115
110
|
url: "https://crm.example.com/customers/cus_9f3a1d",
|
|
116
111
|
},
|
|
@@ -129,20 +124,37 @@ await activitysmith.notifications.send({
|
|
|
129
124
|
plan: "pro",
|
|
130
125
|
},
|
|
131
126
|
},
|
|
132
|
-
],
|
|
127
|
+
],
|
|
133
128
|
});
|
|
134
129
|
```
|
|
135
130
|
|
|
136
131
|
## Live Activities
|
|
137
132
|
|
|
138
|
-
|
|
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.
|
|
146
|
+
|
|
147
|
+

|
|
139
148
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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.
|
|
146
158
|
|
|
147
159
|
### Start & Update Live Activity
|
|
148
160
|
|
|
@@ -150,9 +162,7 @@ Use a stable `streamKey` to identify the metric, job, deployment, or system you
|
|
|
150
162
|
|
|
151
163
|
#### Stats
|
|
152
164
|
|
|
153
|
-
|
|
154
|
-
<img src="https://cdn.activitysmith.com/features/stats-live-activity.png" alt="Stats Live Activity stream example" width="680" />
|
|
155
|
-
</p>
|
|
165
|
+

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

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

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

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

|
|
235
237
|
|
|
236
238
|
```ts
|
|
237
239
|
await activitysmith.liveActivities.stream("customer-ops", {
|
|
@@ -247,9 +249,7 @@ await activitysmith.liveActivities.stream("customer-ops", {
|
|
|
247
249
|
|
|
248
250
|
#### Timer
|
|
249
251
|
|
|
250
|
-
|
|
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>
|
|
252
|
+

|
|
253
253
|
|
|
254
254
|
```ts
|
|
255
255
|
await activitysmith.liveActivities.stream("benchmark-run", {
|
|
@@ -269,7 +269,7 @@ To start at 00:00 and count up, set `counts_down: false` and leave out `duration
|
|
|
269
269
|
|
|
270
270
|
### End Live Activity
|
|
271
271
|
|
|
272
|
-
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.
|
|
273
273
|
|
|
274
274
|
```ts
|
|
275
275
|
await activitysmith.liveActivities.endStream("prod-web-1", {
|
|
@@ -281,25 +281,82 @@ await activitysmith.liveActivities.endStream("prod-web-1", {
|
|
|
281
281
|
{ label: "CPU", value: 7, unit: "%" },
|
|
282
282
|
{ label: "MEM", value: 38, unit: "%" },
|
|
283
283
|
],
|
|
284
|
-
|
|
284
|
+
auto_dismiss_seconds: 30,
|
|
285
285
|
},
|
|
286
286
|
});
|
|
287
287
|
```
|
|
288
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
|
+
|
|
289
344
|
### Live Activity Action
|
|
290
345
|
|
|
291
|
-
Live
|
|
346
|
+

|
|
292
347
|
|
|
293
|
-
|
|
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.
|
|
348
|
+
Live Activities can include an action button.
|
|
296
349
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
</p>
|
|
350
|
+
- `open_url`: Open a web page or run an iOS Shortcut
|
|
351
|
+
- `webhook`: Trigger a backend GET/POST workflow
|
|
300
352
|
|
|
301
353
|
#### Open URL action
|
|
302
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
|
+
|
|
303
360
|
```ts
|
|
304
361
|
await activitysmith.liveActivities.stream("prod-web-1", {
|
|
305
362
|
content_state: {
|
|
@@ -314,7 +371,7 @@ await activitysmith.liveActivities.stream("prod-web-1", {
|
|
|
314
371
|
action: {
|
|
315
372
|
title: "Dashboard",
|
|
316
373
|
type: "open_url",
|
|
317
|
-
url: "https://
|
|
374
|
+
url: "https://status.example.com/servers/prod-web-1",
|
|
318
375
|
},
|
|
319
376
|
});
|
|
320
377
|
```
|
|
@@ -322,13 +379,15 @@ await activitysmith.liveActivities.stream("prod-web-1", {
|
|
|
322
379
|
#### Apple Shortcut action
|
|
323
380
|
|
|
324
381
|
```ts
|
|
325
|
-
await activitysmith.liveActivities.stream("
|
|
382
|
+
await activitysmith.liveActivities.stream("prod-web-1", {
|
|
326
383
|
content_state: {
|
|
327
|
-
title: "
|
|
328
|
-
subtitle: "
|
|
329
|
-
type: "
|
|
330
|
-
|
|
331
|
-
|
|
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
|
+
],
|
|
332
391
|
},
|
|
333
392
|
action: {
|
|
334
393
|
title: "Chat with Jarvis",
|
|
@@ -364,9 +423,7 @@ await activitysmith.liveActivities.stream("search-reindex", {
|
|
|
364
423
|
|
|
365
424
|
#### Secondary action
|
|
366
425
|
|
|
367
|
-
|
|
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>
|
|
426
|
+

|
|
370
427
|
|
|
371
428
|
Use `secondary_action` when you want a second button beside the primary `action`.
|
|
372
429
|
|
|
@@ -411,76 +468,13 @@ await activitysmith.liveActivities.stream("agent-approval", {
|
|
|
411
468
|
});
|
|
412
469
|
```
|
|
413
470
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
Add more context to Live Activities with icons and badges.
|
|
471
|
+
## Lock Screen Widgets
|
|
417
472
|
|
|
418
|
-
|
|
473
|
+

|
|
419
474
|
|
|
420
|
-
|
|
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.
|
|
421
476
|
|
|
422
|
-
|
|
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>
|
|
454
|
-
|
|
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
|
-
```
|
|
466
|
-
|
|
467
|
-
### Live Activity Colors
|
|
468
|
-
|
|
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>
|
|
477
|
+

|
|
484
478
|
|
|
485
479
|
Use the metric key to update its value.
|
|
486
480
|
|
|
@@ -496,65 +490,60 @@ await activitysmith.metrics.update("prod.status", "healthy");
|
|
|
496
490
|
|
|
497
491
|
## App Icon Badge Count
|
|
498
492
|
|
|
499
|
-
|
|
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>
|
|
493
|
+

|
|
502
494
|
|
|
503
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.
|
|
504
496
|
|
|
505
|
-
Set or update the badge value
|
|
497
|
+
### Set or update the badge value
|
|
506
498
|
|
|
507
|
-
```
|
|
499
|
+
```js
|
|
508
500
|
await activitysmith.badgeCount(8333);
|
|
509
501
|
```
|
|
510
502
|
|
|
511
|
-
|
|
503
|
+
### Clear the badge
|
|
512
504
|
|
|
513
|
-
|
|
505
|
+
Pass `0` to clear the badge.
|
|
506
|
+
|
|
507
|
+
```js
|
|
514
508
|
await activitysmith.badgeCount(0);
|
|
515
509
|
```
|
|
516
510
|
|
|
517
|
-
##
|
|
518
|
-
|
|
519
|
-
Use `channels` to target specific team members or devices
|
|
511
|
+
## Metadata
|
|
520
512
|
|
|
521
|
-
|
|
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.
|
|
522
514
|
|
|
523
|
-
```
|
|
515
|
+
```js
|
|
524
516
|
await activitysmith.notifications.send({
|
|
525
517
|
title: "New subscription 💸",
|
|
526
518
|
message: "Customer upgraded to Pro plan",
|
|
527
|
-
|
|
519
|
+
metadata: {
|
|
520
|
+
customer_id: "382",
|
|
521
|
+
plan: "Pro",
|
|
522
|
+
amount: 29,
|
|
523
|
+
trial: false,
|
|
524
|
+
},
|
|
528
525
|
});
|
|
529
|
-
```
|
|
530
|
-
|
|
531
|
-
### Live Activities
|
|
532
526
|
|
|
533
|
-
|
|
534
|
-
await activitysmith.liveActivities.start({
|
|
527
|
+
await activitysmith.liveActivities.stream("customer-import", {
|
|
535
528
|
content_state: {
|
|
536
|
-
title: "
|
|
537
|
-
subtitle: "verify restore",
|
|
529
|
+
title: "Customer Import",
|
|
538
530
|
type: "progress",
|
|
539
|
-
percentage:
|
|
531
|
+
percentage: 60,
|
|
532
|
+
},
|
|
533
|
+
metadata: {
|
|
534
|
+
job_id: "import-382",
|
|
535
|
+
records: 1200,
|
|
540
536
|
},
|
|
541
|
-
channels: ["sales", "customer-success"],
|
|
542
537
|
});
|
|
543
538
|
```
|
|
544
539
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
```ts
|
|
548
|
-
await activitysmith.badgeCount(3, {
|
|
549
|
-
channels: ["sales", "customer-success"],
|
|
550
|
-
});
|
|
551
|
-
```
|
|
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.
|
|
552
541
|
|
|
553
542
|
## Tags
|
|
554
543
|
|
|
555
544
|
Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them.
|
|
556
545
|
|
|
557
|
-
```
|
|
546
|
+
```js
|
|
558
547
|
await activitysmith.notifications.send({
|
|
559
548
|
title: "New subscription 💸",
|
|
560
549
|
message: "Customer upgraded to Pro plan",
|
|
@@ -562,26 +551,56 @@ await activitysmith.notifications.send({
|
|
|
562
551
|
});
|
|
563
552
|
```
|
|
564
553
|
|
|
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.
|
|
555
|
+
|
|
556
|
+
```js
|
|
557
|
+
await activitysmith.liveActivities.update({
|
|
558
|
+
activity_id: "YOUR_ACTIVITY_ID",
|
|
559
|
+
content_state: { title: "Customer Import", percentage: 60 },
|
|
560
|
+
tags: [],
|
|
561
|
+
});
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
## Channels
|
|
565
|
+
|
|
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.
|
|
567
|
+
|
|
568
|
+
```js
|
|
569
|
+
await activitysmith.notifications.send({
|
|
570
|
+
title: "New subscription 💸",
|
|
571
|
+
message: "Customer upgraded to Pro plan",
|
|
572
|
+
channels: ["sales", "customer-success"],
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
await activitysmith.liveActivities.stream("nightly-backup", {
|
|
576
|
+
content_state: {
|
|
577
|
+
title: "Nightly database backup",
|
|
578
|
+
number_of_steps: 3,
|
|
579
|
+
current_step: 1,
|
|
580
|
+
type: "segmented_progress",
|
|
581
|
+
},
|
|
582
|
+
channels: ["ios-builds"],
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
await activitysmith.badgeCount(3, {
|
|
586
|
+
channels: ["sales", "customer-success"],
|
|
587
|
+
});
|
|
588
|
+
```
|
|
589
|
+
|
|
565
590
|
## Error Handling
|
|
566
591
|
|
|
567
|
-
|
|
592
|
+
SDK calls return promises, so you can wrap API calls with `try/catch`:
|
|
593
|
+
|
|
594
|
+
```js
|
|
568
595
|
try {
|
|
569
|
-
await activitysmith.notifications.send({
|
|
570
|
-
title: "New subscription 💸",
|
|
571
|
-
});
|
|
596
|
+
await activitysmith.notifications.send({ title: "Hello" });
|
|
572
597
|
} catch (error) {
|
|
573
598
|
console.error(error);
|
|
574
599
|
}
|
|
575
600
|
```
|
|
576
601
|
|
|
577
|
-
##
|
|
578
|
-
|
|
579
|
-
This package is written in TypeScript and ships with type definitions out of the box.
|
|
580
|
-
|
|
581
|
-
## Requirements
|
|
582
|
-
|
|
583
|
-
- Node.js 18 or newer
|
|
602
|
+
## Additional Resources
|
|
584
603
|
|
|
585
|
-
|
|
604
|
+
### [NPM Package](https://www.npmjs.com/package/activitysmith)
|
|
586
605
|
|
|
587
|
-
|
|
606
|
+
Install the ActivitySmith Node.js SDK from npm
|
|
@@ -70,6 +70,76 @@ export interface AlertPayload {
|
|
|
70
70
|
*/
|
|
71
71
|
body?: string;
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @export
|
|
76
|
+
* @interface AppIconBadgeCountUpdateError
|
|
77
|
+
*/
|
|
78
|
+
export interface AppIconBadgeCountUpdateError {
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @type {string}
|
|
82
|
+
* @memberof AppIconBadgeCountUpdateError
|
|
83
|
+
*/
|
|
84
|
+
error: string;
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @type {string}
|
|
88
|
+
* @memberof AppIconBadgeCountUpdateError
|
|
89
|
+
*/
|
|
90
|
+
code: AppIconBadgeCountUpdateErrorCodeEnum;
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @type {string}
|
|
94
|
+
* @memberof AppIconBadgeCountUpdateError
|
|
95
|
+
*/
|
|
96
|
+
message: string;
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @type {number}
|
|
100
|
+
* @memberof AppIconBadgeCountUpdateError
|
|
101
|
+
*/
|
|
102
|
+
badge: number;
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
* @type {number}
|
|
106
|
+
* @memberof AppIconBadgeCountUpdateError
|
|
107
|
+
*/
|
|
108
|
+
devices_targeted?: number;
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* @type {number}
|
|
112
|
+
* @memberof AppIconBadgeCountUpdateError
|
|
113
|
+
*/
|
|
114
|
+
devices_updated: number;
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @type {number}
|
|
118
|
+
* @memberof AppIconBadgeCountUpdateError
|
|
119
|
+
*/
|
|
120
|
+
users_updated?: number;
|
|
121
|
+
/**
|
|
122
|
+
* Deprecated compatibility alias for devices_updated.
|
|
123
|
+
* @type {number}
|
|
124
|
+
* @memberof AppIconBadgeCountUpdateError
|
|
125
|
+
* @deprecated
|
|
126
|
+
*/
|
|
127
|
+
devices_notified?: number;
|
|
128
|
+
/**
|
|
129
|
+
*
|
|
130
|
+
* @type {Array<string>}
|
|
131
|
+
* @memberof AppIconBadgeCountUpdateError
|
|
132
|
+
*/
|
|
133
|
+
effective_channel_slugs?: Array<string>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @export
|
|
137
|
+
*/
|
|
138
|
+
export declare const AppIconBadgeCountUpdateErrorCodeEnum: {
|
|
139
|
+
readonly DeviceDisconnected: "badge_device_disconnected";
|
|
140
|
+
readonly UpdateFailed: "badge_update_failed";
|
|
141
|
+
};
|
|
142
|
+
export type AppIconBadgeCountUpdateErrorCodeEnum = typeof AppIconBadgeCountUpdateErrorCodeEnum[keyof typeof AppIconBadgeCountUpdateErrorCodeEnum];
|
|
73
143
|
/**
|
|
74
144
|
*
|
|
75
145
|
* @export
|
|
@@ -108,17 +178,31 @@ export interface AppIconBadgeCountUpdateResponse {
|
|
|
108
178
|
*/
|
|
109
179
|
badge: number;
|
|
110
180
|
/**
|
|
111
|
-
*
|
|
181
|
+
* Number of devices whose App Icon Badge Count was updated.
|
|
112
182
|
* @type {number}
|
|
113
183
|
* @memberof AppIconBadgeCountUpdateResponse
|
|
114
184
|
*/
|
|
115
|
-
|
|
185
|
+
devices_updated: number;
|
|
116
186
|
/**
|
|
117
|
-
*
|
|
187
|
+
* Number of account users with at least one updated device.
|
|
188
|
+
* @type {number}
|
|
189
|
+
* @memberof AppIconBadgeCountUpdateResponse
|
|
190
|
+
*/
|
|
191
|
+
users_updated: number;
|
|
192
|
+
/**
|
|
193
|
+
* Deprecated compatibility alias for devices_updated.
|
|
194
|
+
* @type {number}
|
|
195
|
+
* @memberof AppIconBadgeCountUpdateResponse
|
|
196
|
+
* @deprecated
|
|
197
|
+
*/
|
|
198
|
+
devices_notified?: number;
|
|
199
|
+
/**
|
|
200
|
+
* Deprecated compatibility alias for users_updated.
|
|
118
201
|
* @type {number}
|
|
119
202
|
* @memberof AppIconBadgeCountUpdateResponse
|
|
203
|
+
* @deprecated
|
|
120
204
|
*/
|
|
121
|
-
users_notified
|
|
205
|
+
users_notified?: number;
|
|
122
206
|
/**
|
|
123
207
|
*
|
|
124
208
|
* @type {Array<string>}
|
|
@@ -822,12 +906,26 @@ export type LiveActivityColor = typeof LiveActivityColor[keyof typeof LiveActivi
|
|
|
822
906
|
* @interface LiveActivityEndRequest
|
|
823
907
|
*/
|
|
824
908
|
export interface LiveActivityEndRequest {
|
|
909
|
+
/**
|
|
910
|
+
* Additional information shown in notification and Live Activity details in ActivitySmith. Not displayed in the Push Notification or Live Activity on the device. Values must be strings, finite numbers, or booleans. At most 50 entries and 16 KB of serialized UTF-8 JSON. Omit on updates to preserve existing Metadata; send {} to clear it.
|
|
911
|
+
* @type {{ [key: string]: MetadataValue; }}
|
|
912
|
+
* @memberof LiveActivityEndRequest
|
|
913
|
+
*/
|
|
914
|
+
metadata?: {
|
|
915
|
+
[key: string]: MetadataValue;
|
|
916
|
+
};
|
|
825
917
|
/**
|
|
826
918
|
*
|
|
827
919
|
* @type {string}
|
|
828
920
|
* @memberof LiveActivityEndRequest
|
|
829
921
|
*/
|
|
830
922
|
activity_id: string;
|
|
923
|
+
/**
|
|
924
|
+
* Tags for notification history. Omit to keep existing Tags, supply an array to replace them, or send an empty array to clear them.
|
|
925
|
+
* @type {Array<string>}
|
|
926
|
+
* @memberof LiveActivityEndRequest
|
|
927
|
+
*/
|
|
928
|
+
tags?: Array<string>;
|
|
831
929
|
/**
|
|
832
930
|
*
|
|
833
931
|
* @type {ContentStateEnd}
|
|
@@ -909,11 +1007,23 @@ export interface LiveActivityLimitError {
|
|
|
909
1007
|
*/
|
|
910
1008
|
limit: number;
|
|
911
1009
|
/**
|
|
912
|
-
*
|
|
1010
|
+
* Highest number of active Live Activities among the targeted devices.
|
|
913
1011
|
* @type {number}
|
|
914
1012
|
* @memberof LiveActivityLimitError
|
|
915
1013
|
*/
|
|
916
1014
|
active: number;
|
|
1015
|
+
/**
|
|
1016
|
+
* Number of targeted devices that have reached the enforced iOS Live Activity concurrency threshold. Included only when targeted devices have mixed capacity.
|
|
1017
|
+
* @type {number}
|
|
1018
|
+
* @memberof LiveActivityLimitError
|
|
1019
|
+
*/
|
|
1020
|
+
blocked_devices?: number;
|
|
1021
|
+
/**
|
|
1022
|
+
* Total number of targeted devices. Included only when targeted devices have mixed capacity.
|
|
1023
|
+
* @type {number}
|
|
1024
|
+
* @memberof LiveActivityLimitError
|
|
1025
|
+
*/
|
|
1026
|
+
targeted_devices?: number;
|
|
917
1027
|
}
|
|
918
1028
|
/**
|
|
919
1029
|
* Start a new Live Activity. The response includes activity_id for later update and end calls.
|
|
@@ -921,6 +1031,14 @@ export interface LiveActivityLimitError {
|
|
|
921
1031
|
* @interface LiveActivityStartRequest
|
|
922
1032
|
*/
|
|
923
1033
|
export interface LiveActivityStartRequest {
|
|
1034
|
+
/**
|
|
1035
|
+
* Additional information shown in notification and Live Activity details in ActivitySmith. Not displayed in the Push Notification or Live Activity on the device. Values must be strings, finite numbers, or booleans. At most 50 entries and 16 KB of serialized UTF-8 JSON. Omit on updates to preserve existing Metadata; send {} to clear it.
|
|
1036
|
+
* @type {{ [key: string]: MetadataValue; }}
|
|
1037
|
+
* @memberof LiveActivityStartRequest
|
|
1038
|
+
*/
|
|
1039
|
+
metadata?: {
|
|
1040
|
+
[key: string]: MetadataValue;
|
|
1041
|
+
};
|
|
924
1042
|
/**
|
|
925
1043
|
*
|
|
926
1044
|
* @type {ContentStateStart}
|
|
@@ -1013,6 +1131,20 @@ export interface LiveActivityStartResponse {
|
|
|
1013
1131
|
* @interface LiveActivityStreamDeleteRequest
|
|
1014
1132
|
*/
|
|
1015
1133
|
export interface LiveActivityStreamDeleteRequest {
|
|
1134
|
+
/**
|
|
1135
|
+
* Additional information shown in notification and Live Activity details in ActivitySmith. Not displayed in the Push Notification or Live Activity on the device. Values must be strings, finite numbers, or booleans. At most 50 entries and 16 KB of serialized UTF-8 JSON. Omit on updates to preserve existing Metadata; send {} to clear it.
|
|
1136
|
+
* @type {{ [key: string]: MetadataValue; }}
|
|
1137
|
+
* @memberof LiveActivityStreamDeleteRequest
|
|
1138
|
+
*/
|
|
1139
|
+
metadata?: {
|
|
1140
|
+
[key: string]: MetadataValue;
|
|
1141
|
+
};
|
|
1142
|
+
/**
|
|
1143
|
+
* Optional tags to organize and filter notification history.
|
|
1144
|
+
* @type {Array<string>}
|
|
1145
|
+
* @memberof LiveActivityStreamDeleteRequest
|
|
1146
|
+
*/
|
|
1147
|
+
tags?: Array<string>;
|
|
1016
1148
|
/**
|
|
1017
1149
|
*
|
|
1018
1150
|
* @type {StreamContentState}
|
|
@@ -1184,6 +1316,14 @@ export type LiveActivityStreamPutResponseOperationEnum = typeof LiveActivityStre
|
|
|
1184
1316
|
* @interface LiveActivityStreamRequest
|
|
1185
1317
|
*/
|
|
1186
1318
|
export interface LiveActivityStreamRequest {
|
|
1319
|
+
/**
|
|
1320
|
+
* Additional information shown in notification and Live Activity details in ActivitySmith. Not displayed in the Push Notification or Live Activity on the device. Values must be strings, finite numbers, or booleans. At most 50 entries and 16 KB of serialized UTF-8 JSON. Omit on updates to preserve existing Metadata; send {} to clear it.
|
|
1321
|
+
* @type {{ [key: string]: MetadataValue; }}
|
|
1322
|
+
* @memberof LiveActivityStreamRequest
|
|
1323
|
+
*/
|
|
1324
|
+
metadata?: {
|
|
1325
|
+
[key: string]: MetadataValue;
|
|
1326
|
+
};
|
|
1187
1327
|
/**
|
|
1188
1328
|
*
|
|
1189
1329
|
* @type {StreamContentState}
|
|
@@ -1233,12 +1373,26 @@ export interface LiveActivityStreamRequest {
|
|
|
1233
1373
|
* @interface LiveActivityUpdateRequest
|
|
1234
1374
|
*/
|
|
1235
1375
|
export interface LiveActivityUpdateRequest {
|
|
1376
|
+
/**
|
|
1377
|
+
* Additional information shown in notification and Live Activity details in ActivitySmith. Not displayed in the Push Notification or Live Activity on the device. Values must be strings, finite numbers, or booleans. At most 50 entries and 16 KB of serialized UTF-8 JSON. Omit on updates to preserve existing Metadata; send {} to clear it.
|
|
1378
|
+
* @type {{ [key: string]: MetadataValue; }}
|
|
1379
|
+
* @memberof LiveActivityUpdateRequest
|
|
1380
|
+
*/
|
|
1381
|
+
metadata?: {
|
|
1382
|
+
[key: string]: MetadataValue;
|
|
1383
|
+
};
|
|
1236
1384
|
/**
|
|
1237
1385
|
*
|
|
1238
1386
|
* @type {string}
|
|
1239
1387
|
* @memberof LiveActivityUpdateRequest
|
|
1240
1388
|
*/
|
|
1241
1389
|
activity_id: string;
|
|
1390
|
+
/**
|
|
1391
|
+
* Tags for notification history. Omit to keep existing Tags, supply an array to replace them, or send an empty array to clear them.
|
|
1392
|
+
* @type {Array<string>}
|
|
1393
|
+
* @memberof LiveActivityUpdateRequest
|
|
1394
|
+
*/
|
|
1395
|
+
tags?: Array<string>;
|
|
1242
1396
|
/**
|
|
1243
1397
|
*
|
|
1244
1398
|
* @type {ContentStateUpdate}
|
|
@@ -1304,6 +1458,12 @@ export declare const LiveActivityWebhookMethod: {
|
|
|
1304
1458
|
readonly Post: "POST";
|
|
1305
1459
|
};
|
|
1306
1460
|
export type LiveActivityWebhookMethod = typeof LiveActivityWebhookMethod[keyof typeof LiveActivityWebhookMethod];
|
|
1461
|
+
/**
|
|
1462
|
+
* @type MetadataValue
|
|
1463
|
+
*
|
|
1464
|
+
* @export
|
|
1465
|
+
*/
|
|
1466
|
+
export type MetadataValue = boolean | number | string;
|
|
1307
1467
|
/**
|
|
1308
1468
|
*
|
|
1309
1469
|
* @export
|
|
@@ -1425,7 +1585,7 @@ export interface PushNotificationAction {
|
|
|
1425
1585
|
*/
|
|
1426
1586
|
type: PushNotificationActionType;
|
|
1427
1587
|
/**
|
|
1428
|
-
* Action URL. For open_url, use
|
|
1588
|
+
* Action URL. For open_url, use HTTP, HTTPS, Shortcuts, or an installed app’s custom URL scheme, such as spotify:// or spotify:track:123. Custom app schemes require iOS 1.13.4 build 2 or later; no web fallback is provided. Internal and executable schemes are blocked. For webhook, use an HTTPS URL called by the ActivitySmith backend.
|
|
1429
1589
|
* @type {string}
|
|
1430
1590
|
* @memberof PushNotificationAction
|
|
1431
1591
|
*/
|
|
@@ -1459,6 +1619,14 @@ export type PushNotificationActionType = typeof PushNotificationActionType[keyof
|
|
|
1459
1619
|
*/
|
|
1460
1620
|
export interface PushNotificationRequest {
|
|
1461
1621
|
[key: string]: any | any;
|
|
1622
|
+
/**
|
|
1623
|
+
* Additional information shown in notification and Live Activity details in ActivitySmith. Not displayed in the Push Notification or Live Activity on the device. Values must be strings, finite numbers, or booleans. At most 50 entries and 16 KB of serialized UTF-8 JSON. Omit on updates to preserve existing Metadata; send {} to clear it.
|
|
1624
|
+
* @type {{ [key: string]: MetadataValue; }}
|
|
1625
|
+
* @memberof PushNotificationRequest
|
|
1626
|
+
*/
|
|
1627
|
+
metadata?: {
|
|
1628
|
+
[key: string]: MetadataValue;
|
|
1629
|
+
};
|
|
1462
1630
|
/**
|
|
1463
1631
|
*
|
|
1464
1632
|
* @type {string}
|
|
@@ -1484,7 +1652,7 @@ export interface PushNotificationRequest {
|
|
|
1484
1652
|
*/
|
|
1485
1653
|
media?: string;
|
|
1486
1654
|
/**
|
|
1487
|
-
* Optional HTTP
|
|
1655
|
+
* Optional HTTP, HTTPS, Shortcuts, or installed app URL opened when the user taps the notification body. Custom schemes such as spotify:// and spotify:track:123 require iOS 1.13.4 build 2 or later and an installed handler; no web fallback is provided. Internal and executable schemes are blocked. Overrides the default tap target from media.
|
|
1488
1656
|
* @type {string}
|
|
1489
1657
|
* @memberof PushNotificationRequest
|
|
1490
1658
|
*/
|
|
@@ -1790,3 +1958,9 @@ export declare const StreamContentStateStepColorsEnum: {
|
|
|
1790
1958
|
readonly Gray: "gray";
|
|
1791
1959
|
};
|
|
1792
1960
|
export type StreamContentStateStepColorsEnum = typeof StreamContentStateStepColorsEnum[keyof typeof StreamContentStateStepColorsEnum];
|
|
1961
|
+
/**
|
|
1962
|
+
* @type UpdateAppIconBadgeCount422Response
|
|
1963
|
+
*
|
|
1964
|
+
* @export
|
|
1965
|
+
*/
|
|
1966
|
+
export type UpdateAppIconBadgeCount422Response = AppIconBadgeCountUpdateError | NoRecipientsError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StreamContentStateStepColorsEnum = exports.StreamContentStateStepColorEnum = exports.StreamContentStateColorEnum = exports.StreamContentStateTypeEnum = exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.LiveActivityWebhookMethod = exports.LiveActivityStreamPutResponseOperationEnum = exports.LiveActivityStreamDeleteResponseOperationEnum = exports.LiveActivityColor = exports.LiveActivityActionType = exports.ContentStateUpdateStepColorsEnum = exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateUpdateTypeEnum = exports.ContentStateStartStepColorsEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorsEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = exports.ContentStateEndTypeEnum = exports.ActivityMetricColorEnum = void 0;
|
|
3
|
+
exports.StreamContentStateStepColorsEnum = exports.StreamContentStateStepColorEnum = exports.StreamContentStateColorEnum = exports.StreamContentStateTypeEnum = exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.LiveActivityWebhookMethod = exports.LiveActivityStreamPutResponseOperationEnum = exports.LiveActivityStreamDeleteResponseOperationEnum = exports.LiveActivityColor = exports.LiveActivityActionType = exports.ContentStateUpdateStepColorsEnum = exports.ContentStateUpdateStepColorEnum = exports.ContentStateUpdateColorEnum = exports.ContentStateUpdateTypeEnum = exports.ContentStateStartStepColorsEnum = exports.ContentStateStartStepColorEnum = exports.ContentStateStartColorEnum = exports.ContentStateStartTypeEnum = exports.ContentStateEndStepColorsEnum = exports.ContentStateEndStepColorEnum = exports.ContentStateEndColorEnum = exports.ContentStateEndTypeEnum = exports.AppIconBadgeCountUpdateErrorCodeEnum = exports.ActivityMetricColorEnum = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @export
|
|
6
6
|
*/
|
|
@@ -16,6 +16,13 @@ exports.ActivityMetricColorEnum = {
|
|
|
16
16
|
Yellow: 'yellow',
|
|
17
17
|
Gray: 'gray'
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* @export
|
|
21
|
+
*/
|
|
22
|
+
exports.AppIconBadgeCountUpdateErrorCodeEnum = {
|
|
23
|
+
DeviceDisconnected: 'badge_device_disconnected',
|
|
24
|
+
UpdateFailed: 'badge_update_failed'
|
|
25
|
+
};
|
|
19
26
|
/**
|
|
20
27
|
* @export
|
|
21
28
|
*/
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { AppIconBadgesApi, LiveActivitiesApi, MetricsApi, PushNotificationsApi } from "../generated/index";
|
|
2
2
|
export interface ActivitySmithOptions {
|
|
3
3
|
apiKey: string;
|
|
4
|
+
sdk?: {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
};
|
|
4
8
|
}
|
|
5
9
|
type PushRequestBody = Parameters<PushNotificationsApi["sendPushNotification"]>[0]["pushNotificationRequest"];
|
|
6
10
|
type PushSendParameters = Parameters<PushNotificationsApi["sendPushNotification"]>[0];
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActivitySmith = exports.MetricsResource = exports.LiveActivitiesResource = exports.NotificationsResource = void 0;
|
|
4
4
|
const index_1 = require("../generated/index");
|
|
5
|
-
const SDK_VERSION = "1.
|
|
5
|
+
const SDK_VERSION = "1.11.0";
|
|
6
6
|
const SDK_HEADER_NAME = "X-ActivitySmith-SDK";
|
|
7
|
-
const
|
|
7
|
+
const DEFAULT_SDK_NAME = "node";
|
|
8
|
+
const SDK_HEADER_VALUE = `${DEFAULT_SDK_NAME}-v${SDK_VERSION}`;
|
|
8
9
|
const LiveActivityTypes = {
|
|
9
10
|
segmentedProgress: "segmented_progress",
|
|
10
11
|
progress: "progress",
|
|
@@ -28,6 +29,20 @@ function withTargetChannels(request) {
|
|
|
28
29
|
function compactObject(value) {
|
|
29
30
|
return Object.fromEntries(Object.entries(value).filter(([, entryValue]) => entryValue !== undefined));
|
|
30
31
|
}
|
|
32
|
+
function sdkHeaderValue(sdk) {
|
|
33
|
+
if (!sdk) {
|
|
34
|
+
return SDK_HEADER_VALUE;
|
|
35
|
+
}
|
|
36
|
+
const name = sdk.name.trim().toLowerCase();
|
|
37
|
+
const version = sdk.version.trim();
|
|
38
|
+
if (!/^[a-z][a-z0-9]*$/.test(name)) {
|
|
39
|
+
throw new Error("ActivitySmith: sdk.name must start with a letter and contain only letters and numbers");
|
|
40
|
+
}
|
|
41
|
+
if (!version) {
|
|
42
|
+
throw new Error("ActivitySmith: sdk.version is required");
|
|
43
|
+
}
|
|
44
|
+
return `${name}-v${version}`;
|
|
45
|
+
}
|
|
31
46
|
function contentState(value) {
|
|
32
47
|
return compactObject(value);
|
|
33
48
|
}
|
|
@@ -180,7 +195,7 @@ class ActivitySmith {
|
|
|
180
195
|
const config = new index_1.Configuration({
|
|
181
196
|
accessToken: opts.apiKey,
|
|
182
197
|
headers: {
|
|
183
|
-
[SDK_HEADER_NAME]:
|
|
198
|
+
[SDK_HEADER_NAME]: sdkHeaderValue(opts.sdk),
|
|
184
199
|
},
|
|
185
200
|
});
|
|
186
201
|
this.notifications = new NotificationsResource(new index_1.PushNotificationsApi(config));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activitysmith",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Official ActivitySmith Node.js SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"activitysmith",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"node": ">=18"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"clean": "tsc -b --clean",
|
|
47
|
+
"clean": "tsc -b --clean && node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
48
48
|
"build": "npm run clean && tsc -b",
|
|
49
49
|
"prepublishOnly": "npm run build",
|
|
50
50
|
"test": "npm run build && vitest run"
|