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.
- checksums.yaml +4 -4
- data/README.md +243 -225
- data/generated/activitysmith_openapi/api/app_icon_badges_api.rb +4 -4
- data/generated/activitysmith_openapi/api/live_activities_api.rb +10 -10
- data/generated/activitysmith_openapi/api/push_notifications_api.rb +2 -2
- data/generated/activitysmith_openapi/configuration.rb +7 -0
- data/generated/activitysmith_openapi/models/app_icon_badge_count_update_error.rb +386 -0
- data/generated/activitysmith_openapi/models/app_icon_badge_count_update_request.rb +0 -1
- data/generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb +33 -11
- data/generated/activitysmith_openapi/models/live_activity_action.rb +1 -1
- data/generated/activitysmith_openapi/models/live_activity_end_request.rb +64 -2
- data/generated/activitysmith_openapi/models/live_activity_limit_error.rb +25 -5
- data/generated/activitysmith_openapi/models/live_activity_start_request.rb +48 -5
- data/generated/activitysmith_openapi/models/live_activity_start_response.rb +13 -1
- data/generated/activitysmith_openapi/models/live_activity_stream_delete_request.rb +45 -2
- data/generated/activitysmith_openapi/models/live_activity_stream_put_response.rb +13 -1
- data/generated/activitysmith_openapi/models/live_activity_stream_request.rb +48 -5
- data/generated/activitysmith_openapi/models/live_activity_update_request.rb +64 -2
- data/generated/activitysmith_openapi/models/metadata_value.rb +106 -0
- data/generated/activitysmith_openapi/models/push_notification_action.rb +1 -1
- data/generated/activitysmith_openapi/models/push_notification_request.rb +60 -8
- data/generated/activitysmith_openapi/models/push_notification_response.rb +13 -1
- data/generated/activitysmith_openapi/models/update_app_icon_badge_count422_response.rb +105 -0
- data/generated/activitysmith_openapi/version.rb +1 -1
- data/generated/activitysmith_openapi.rb +3 -0
- data/generated/openapi-source.json +6 -0
- data/lib/activitysmith/live_activities.rb +36 -14
- data/lib/activitysmith/notifications.rb +19 -4
- data/lib/activitysmith/version.rb +1 -1
- metadata +6 -2
data/README.md
CHANGED
|
@@ -1,50 +1,35 @@
|
|
|
1
1
|
# ActivitySmith Ruby 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/ruby)
|
|
26
4
|
|
|
27
5
|
## Installation
|
|
28
6
|
|
|
29
|
-
|
|
7
|
+
Install the ActivitySmith Ruby SDK with RubyGems:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
30
10
|
gem install activitysmith
|
|
31
11
|
```
|
|
32
12
|
|
|
33
|
-
##
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
1. [Create an API key](https://activitysmith.com/app/keys)
|
|
16
|
+
2. Set `ACTIVITYSMITH_API_KEY` or pass it directly to `ActivitySmith::Client`.
|
|
34
17
|
|
|
35
18
|
```ruby
|
|
36
19
|
require "activitysmith"
|
|
37
20
|
|
|
38
|
-
activitysmith = ActivitySmith::Client.new(
|
|
21
|
+
activitysmith = ActivitySmith::Client.new(
|
|
22
|
+
api_key: ENV["ACTIVITYSMITH_API_KEY"]
|
|
23
|
+
)
|
|
39
24
|
```
|
|
40
25
|
|
|
41
26
|
## Push Notifications
|
|
42
27
|
|
|
43
28
|
### Send a Push Notification
|
|
44
29
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
Send an immediate notification for a completed task or event.
|
|
31
|
+
|
|
32
|
+

|
|
48
33
|
|
|
49
34
|
```ruby
|
|
50
35
|
activitysmith.notifications.send(
|
|
@@ -57,26 +42,21 @@ activitysmith.notifications.send(
|
|
|
57
42
|
|
|
58
43
|
### Rich Push Notifications with Media
|
|
59
44
|
|
|
60
|
-
|
|
61
|
-
<img src="https://cdn.activitysmith.com/features/rich-push-notification-with-image.png" alt="Rich push notification with image" width="680" />
|
|
62
|
-
</p>
|
|
45
|
+

|
|
63
46
|
|
|
64
47
|
```ruby
|
|
65
48
|
activitysmith.notifications.send(
|
|
66
49
|
{
|
|
67
50
|
title: "Homepage ready",
|
|
68
51
|
message: "Your agent finished the redesign.",
|
|
69
|
-
media: "https://cdn.example.com/output/homepage-v2.png"
|
|
70
|
-
redirection: "https://github.com/acme/web/pull/482"
|
|
52
|
+
media: "https://cdn.example.com/output/homepage-v2.png"
|
|
71
53
|
}
|
|
72
54
|
)
|
|
73
55
|
```
|
|
74
56
|
|
|
75
|
-
|
|
57
|
+
Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media.
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
<img src="https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png" alt="Rich push notification with audio" width="680" />
|
|
79
|
-
</p>
|
|
59
|
+

|
|
80
60
|
|
|
81
61
|
What will work:
|
|
82
62
|
|
|
@@ -85,24 +65,54 @@ What will work:
|
|
|
85
65
|
- direct video file URL: `.mp4`, `.mov`, etc.
|
|
86
66
|
- URL that responds with a proper media `Content-Type`, even if the path has no extension
|
|
87
67
|
|
|
68
|
+
`media` cannot be combined with `actions`.
|
|
69
|
+
|
|
70
|
+
### Push Notifications with Redirection
|
|
71
|
+
|
|
72
|
+
Open a web page, run an iOS Shortcut, or open an app when someone taps the notification. `redirection` supports:
|
|
73
|
+
|
|
74
|
+
- **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
|
|
75
|
+
- **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
|
|
76
|
+
- **App deep links:** Installed apps or specific content within them
|
|
77
|
+
- **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6`
|
|
78
|
+
- **Termius:** `termius://` to open the app
|
|
79
|
+
- **Claude:** `claude://code` to open the Code tab
|
|
80
|
+
- **ChatGPT:** `chatgpt://` to open the app <!-- Verify ChatGPT URL scheme on iOS before publishing -->
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
activitysmith.notifications.send(
|
|
84
|
+
{
|
|
85
|
+
title: "Homepage ready",
|
|
86
|
+
message: "Your agent finished the redesign.",
|
|
87
|
+
redirection: "https://github.com/acme/web/pull/482"
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
88
92
|
### Actionable Push Notifications
|
|
89
93
|
|
|
90
|
-
|
|
91
|
-
<img src="https://cdn.activitysmith.com/features/actionable-push-notifications-2.png" alt="Actionable push notification example" width="680" />
|
|
92
|
-
</p>
|
|
94
|
+

|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
`open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links:
|
|
97
|
+
|
|
98
|
+
- **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
|
|
99
|
+
- **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
|
|
100
|
+
- **App deep links:** Installed apps or specific content within them
|
|
101
|
+
- **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6`
|
|
102
|
+
- **Termius:** `termius://` to open the app
|
|
103
|
+
- **Claude:** `claude://code` to open the Code tab
|
|
104
|
+
- **ChatGPT:** `chatgpt://` to open the app <!-- Verify ChatGPT URL scheme on iOS before publishing -->
|
|
105
|
+
|
|
106
|
+
Webhooks are executed by the ActivitySmith backend and must use HTTPS.
|
|
96
107
|
|
|
97
108
|
```ruby
|
|
98
109
|
activitysmith.notifications.send(
|
|
99
110
|
{
|
|
100
111
|
title: "New subscription 💸",
|
|
101
112
|
message: "Customer upgraded to Pro plan",
|
|
102
|
-
|
|
103
|
-
actions: [ # Optional (max 4)
|
|
113
|
+
actions: [
|
|
104
114
|
{
|
|
105
|
-
title: "Open CRM
|
|
115
|
+
title: "Open CRM",
|
|
106
116
|
type: "open_url",
|
|
107
117
|
url: "https://crm.example.com/customers/cus_9f3a1d"
|
|
108
118
|
},
|
|
@@ -128,14 +138,31 @@ activitysmith.notifications.send(
|
|
|
128
138
|
|
|
129
139
|
## Live Activities
|
|
130
140
|
|
|
131
|
-
|
|
141
|
+
Choose the Live Activity type that matches what you want to show:
|
|
142
|
+
|
|
143
|
+

|
|
144
|
+
|
|
145
|
+
**Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
|
|
146
|
+
|
|
147
|
+

|
|
148
|
+
|
|
149
|
+
**Metrics**: Track two related values with segmented bars, such as CPU and memory.
|
|
132
150
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
151
|
+

|
|
152
|
+
|
|
153
|
+
**Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
|
|
154
|
+
|
|
155
|
+

|
|
156
|
+
|
|
157
|
+
**Progress**: Show percentage progress for jobs that move continuously toward completion.
|
|
158
|
+
|
|
159
|
+

|
|
160
|
+
|
|
161
|
+
**Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.
|
|
162
|
+
|
|
163
|
+

|
|
164
|
+
|
|
165
|
+
**Timer**: Count down from a duration, or count up from 00:00 while a job runs.
|
|
139
166
|
|
|
140
167
|
### Start & Update Live Activity
|
|
141
168
|
|
|
@@ -143,13 +170,7 @@ Use a stable `stream_key` to identify the metric, job, deployment, or system you
|
|
|
143
170
|
|
|
144
171
|
#### Stats
|
|
145
172
|
|
|
146
|
-
|
|
147
|
-
<img
|
|
148
|
-
src="https://cdn.activitysmith.com/features/stats-live-activity.png"
|
|
149
|
-
alt="Stats Live Activity stream example"
|
|
150
|
-
width="680"
|
|
151
|
-
/>
|
|
152
|
-
</p>
|
|
173
|
+

|
|
153
174
|
|
|
154
175
|
```ruby
|
|
155
176
|
activitysmith.live_activities.stream(
|
|
@@ -174,13 +195,7 @@ activitysmith.live_activities.stream(
|
|
|
174
195
|
|
|
175
196
|
#### Metrics
|
|
176
197
|
|
|
177
|
-
|
|
178
|
-
<img
|
|
179
|
-
src="https://cdn.activitysmith.com/features/metrics-live-activity-start.png"
|
|
180
|
-
alt="Metrics Live Activity stream example"
|
|
181
|
-
width="680"
|
|
182
|
-
/>
|
|
183
|
-
</p>
|
|
198
|
+

|
|
184
199
|
|
|
185
200
|
```ruby
|
|
186
201
|
activitysmith.live_activities.stream(
|
|
@@ -201,13 +216,7 @@ activitysmith.live_activities.stream(
|
|
|
201
216
|
|
|
202
217
|
#### Segmented Progress
|
|
203
218
|
|
|
204
|
-
|
|
205
|
-
<img
|
|
206
|
-
src="https://cdn.activitysmith.com/features/update-live-activity.png"
|
|
207
|
-
alt="Segmented Progress Live Activity stream example"
|
|
208
|
-
width="680"
|
|
209
|
-
/>
|
|
210
|
-
</p>
|
|
219
|
+

|
|
211
220
|
|
|
212
221
|
```ruby
|
|
213
222
|
activitysmith.live_activities.stream(
|
|
@@ -226,13 +235,7 @@ activitysmith.live_activities.stream(
|
|
|
226
235
|
|
|
227
236
|
#### Progress
|
|
228
237
|
|
|
229
|
-
|
|
230
|
-
<img
|
|
231
|
-
src="https://cdn.activitysmith.com/features/progress-live-activity.png"
|
|
232
|
-
alt="Progress Live Activity stream example"
|
|
233
|
-
width="680"
|
|
234
|
-
/>
|
|
235
|
-
</p>
|
|
238
|
+

|
|
236
239
|
|
|
237
240
|
```ruby
|
|
238
241
|
activitysmith.live_activities.stream(
|
|
@@ -250,13 +253,7 @@ activitysmith.live_activities.stream(
|
|
|
250
253
|
|
|
251
254
|
#### Alert
|
|
252
255
|
|
|
253
|
-
|
|
254
|
-
<img
|
|
255
|
-
src="https://cdn.activitysmith.com/features/alert-live-activity.png"
|
|
256
|
-
alt="Alert Live Activity stream example"
|
|
257
|
-
width="680"
|
|
258
|
-
/>
|
|
259
|
-
</p>
|
|
256
|
+

|
|
260
257
|
|
|
261
258
|
```ruby
|
|
262
259
|
activitysmith.live_activities.stream(
|
|
@@ -275,13 +272,7 @@ activitysmith.live_activities.stream(
|
|
|
275
272
|
|
|
276
273
|
#### Timer
|
|
277
274
|
|
|
278
|
-
|
|
279
|
-
<img
|
|
280
|
-
src="https://cdn.activitysmith.com/features/timer-live-activity.png"
|
|
281
|
-
alt="Timer Live Activity showing a benchmark run countdown"
|
|
282
|
-
width="680"
|
|
283
|
-
/>
|
|
284
|
-
</p>
|
|
275
|
+

|
|
285
276
|
|
|
286
277
|
```ruby
|
|
287
278
|
activitysmith.live_activities.stream(
|
|
@@ -304,7 +295,7 @@ To start at 00:00 and count up, set `counts_down: false` and leave out `duration
|
|
|
304
295
|
|
|
305
296
|
### End Live Activity
|
|
306
297
|
|
|
307
|
-
Call `end_stream(...)` with the same `stream_key` to dismiss the Live Activity. You can include final values before it is removed.
|
|
298
|
+
Call `end_stream(...)` with the same `stream_key` 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.
|
|
308
299
|
|
|
309
300
|
```ruby
|
|
310
301
|
activitysmith.live_activities.end_stream(
|
|
@@ -318,30 +309,89 @@ activitysmith.live_activities.end_stream(
|
|
|
318
309
|
{ label: "CPU", value: 7, unit: "%" },
|
|
319
310
|
{ label: "MEM", value: 38, unit: "%" }
|
|
320
311
|
],
|
|
321
|
-
|
|
312
|
+
auto_dismiss_seconds: 30
|
|
322
313
|
}
|
|
323
314
|
}
|
|
324
315
|
)
|
|
325
316
|
```
|
|
326
317
|
|
|
318
|
+
### Icons and Badges
|
|
319
|
+
|
|
320
|
+
Add more context to Live Activities with icons and badges.
|
|
321
|
+
|
|
322
|
+
#### Icon
|
|
323
|
+
|
|
324
|
+
Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, `alert`, and `timer`.
|
|
325
|
+
|
|
326
|
+

|
|
327
|
+
|
|
328
|
+
```ruby
|
|
329
|
+
activitysmith.live_activities.stream(
|
|
330
|
+
"prod-web-1",
|
|
331
|
+
{
|
|
332
|
+
content_state: ActivitySmith::LiveActivities.content_state(
|
|
333
|
+
title: "Server Health",
|
|
334
|
+
subtitle: "prod-web-1",
|
|
335
|
+
type: "metrics",
|
|
336
|
+
icon: ActivitySmith::LiveActivities.alert_icon("server.rack", color: "blue"),
|
|
337
|
+
metrics: [
|
|
338
|
+
{ label: "CPU", value: 18, unit: "%" },
|
|
339
|
+
{ label: "MEM", value: 42, unit: "%" }
|
|
340
|
+
]
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
The `icon` symbol value is an Apple SF Symbol name. Browse the catalog with one of these tools:
|
|
347
|
+
|
|
348
|
+
- [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
|
|
349
|
+
- [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
|
|
350
|
+
- [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
|
|
351
|
+
|
|
352
|
+
#### Badge
|
|
353
|
+
|
|
354
|
+
Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities.
|
|
355
|
+
|
|
356
|
+

|
|
357
|
+
|
|
358
|
+
```ruby
|
|
359
|
+
activitysmith.live_activities.stream(
|
|
360
|
+
"nightly-database-backup",
|
|
361
|
+
{
|
|
362
|
+
content_state: ActivitySmith::LiveActivities.content_state(
|
|
363
|
+
title: "Nightly Database Backup",
|
|
364
|
+
subtitle: "verify restore",
|
|
365
|
+
type: "progress",
|
|
366
|
+
badge: ActivitySmith::LiveActivities.alert_badge("S3", color: "cyan"),
|
|
367
|
+
percentage: 62
|
|
368
|
+
)
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Live Activity Colors
|
|
374
|
+
|
|
375
|
+
Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
|
|
376
|
+
|
|
377
|
+
`lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
|
|
378
|
+
|
|
327
379
|
### Live Activity Action
|
|
328
380
|
|
|
329
|
-
Live
|
|
381
|
+

|
|
330
382
|
|
|
331
|
-
|
|
332
|
-
- `open_url` with a `shortcuts://` URL: run an Apple Shortcut, for example to open an app.
|
|
333
|
-
- `webhook`: trigger a backend GET/POST workflow.
|
|
383
|
+
Live Activities can include an action button.
|
|
334
384
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png"
|
|
338
|
-
alt="Live Activity with action button"
|
|
339
|
-
width="680"
|
|
340
|
-
/>
|
|
341
|
-
</p>
|
|
385
|
+
- `open_url`: Open a web page or run an iOS Shortcut
|
|
386
|
+
- `webhook`: Trigger a backend GET/POST workflow
|
|
342
387
|
|
|
343
388
|
#### Open URL action
|
|
344
389
|
|
|
390
|
+
Open a web page or run an iOS Shortcut when someone taps the button. Supported links:
|
|
391
|
+
|
|
392
|
+
- **HTTP/HTTPS:** Web pages, e.g. `https://example.com`
|
|
393
|
+
- **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` <!-- full-width -->
|
|
394
|
+
|
|
345
395
|
```ruby
|
|
346
396
|
activitysmith.live_activities.stream(
|
|
347
397
|
"prod-web-1",
|
|
@@ -358,7 +408,7 @@ activitysmith.live_activities.stream(
|
|
|
358
408
|
action: {
|
|
359
409
|
title: "Dashboard",
|
|
360
410
|
type: "open_url",
|
|
361
|
-
url: "https://
|
|
411
|
+
url: "https://status.example.com/servers/prod-web-1"
|
|
362
412
|
}
|
|
363
413
|
}
|
|
364
414
|
)
|
|
@@ -368,14 +418,16 @@ activitysmith.live_activities.stream(
|
|
|
368
418
|
|
|
369
419
|
```ruby
|
|
370
420
|
activitysmith.live_activities.stream(
|
|
371
|
-
"
|
|
421
|
+
"prod-web-1",
|
|
372
422
|
{
|
|
373
423
|
content_state: {
|
|
374
|
-
title: "
|
|
375
|
-
subtitle: "
|
|
376
|
-
type: "
|
|
377
|
-
|
|
378
|
-
|
|
424
|
+
title: "Server Health",
|
|
425
|
+
subtitle: "prod-web-1",
|
|
426
|
+
type: "metrics",
|
|
427
|
+
metrics: [
|
|
428
|
+
{ label: "CPU", value: 76, unit: "%" },
|
|
429
|
+
{ label: "MEM", value: 52, unit: "%" }
|
|
430
|
+
]
|
|
379
431
|
},
|
|
380
432
|
action: {
|
|
381
433
|
title: "Chat with Jarvis",
|
|
@@ -415,13 +467,7 @@ activitysmith.live_activities.stream(
|
|
|
415
467
|
|
|
416
468
|
#### Secondary action
|
|
417
469
|
|
|
418
|
-
|
|
419
|
-
<img
|
|
420
|
-
src="https://cdn.activitysmith.com/features/live-activity-secondary-action.png"
|
|
421
|
-
alt="Alert Live Activity with primary and secondary action buttons"
|
|
422
|
-
width="680"
|
|
423
|
-
/>
|
|
424
|
-
</p>
|
|
470
|
+

|
|
425
471
|
|
|
426
472
|
Use `secondary_action` when you want a second button beside the primary `action`.
|
|
427
473
|
|
|
@@ -463,126 +509,105 @@ activitysmith.live_activities.stream(
|
|
|
463
509
|
)
|
|
464
510
|
```
|
|
465
511
|
|
|
466
|
-
|
|
512
|
+
## Lock Screen Widgets
|
|
467
513
|
|
|
468
|
-
|
|
514
|
+

|
|
469
515
|
|
|
470
|
-
|
|
516
|
+
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.
|
|
471
517
|
|
|
472
|
-
|
|
518
|
+

|
|
473
519
|
|
|
474
|
-
|
|
475
|
-
<img
|
|
476
|
-
src="https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png"
|
|
477
|
-
alt="Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen"
|
|
478
|
-
width="680"
|
|
479
|
-
/>
|
|
480
|
-
</p>
|
|
520
|
+
Use the metric key to update its value.
|
|
481
521
|
|
|
482
522
|
```ruby
|
|
483
|
-
activitysmith.
|
|
484
|
-
"prod-web-1",
|
|
485
|
-
{
|
|
486
|
-
content_state: ActivitySmith::LiveActivities.content_state(
|
|
487
|
-
title: "Server Health",
|
|
488
|
-
subtitle: "prod-web-1",
|
|
489
|
-
type: "metrics",
|
|
490
|
-
icon: ActivitySmith::LiveActivities.alert_icon("server.rack", color: "blue"),
|
|
491
|
-
metrics: [
|
|
492
|
-
{ label: "CPU", value: 18, unit: "%" },
|
|
493
|
-
{ label: "MEM", value: 42, unit: "%" }
|
|
494
|
-
]
|
|
495
|
-
)
|
|
496
|
-
}
|
|
497
|
-
)
|
|
523
|
+
activitysmith.metrics.update("deploy.success_rate", 99.9)
|
|
498
524
|
```
|
|
499
525
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
- [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use
|
|
503
|
-
- [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app
|
|
504
|
-
- [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography
|
|
505
|
-
|
|
506
|
-
#### Badge
|
|
507
|
-
|
|
508
|
-
Badges are supported by `alert`, `progress`, and `segmented_progress` Live Activities.
|
|
509
|
-
|
|
510
|
-
<p align="center">
|
|
511
|
-
<img
|
|
512
|
-
src="https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png"
|
|
513
|
-
alt="Progress Live Activity with a badge on the iPhone Lock Screen"
|
|
514
|
-
width="680"
|
|
515
|
-
/>
|
|
516
|
-
</p>
|
|
526
|
+
String metric values work too.
|
|
517
527
|
|
|
518
528
|
```ruby
|
|
519
|
-
activitysmith.
|
|
520
|
-
"nightly-database-backup",
|
|
521
|
-
{
|
|
522
|
-
content_state: ActivitySmith::LiveActivities.content_state(
|
|
523
|
-
title: "Nightly Database Backup",
|
|
524
|
-
subtitle: "verify restore",
|
|
525
|
-
type: "progress",
|
|
526
|
-
badge: ActivitySmith::LiveActivities.alert_badge("S3", color: "cyan"),
|
|
527
|
-
percentage: 62
|
|
528
|
-
)
|
|
529
|
-
}
|
|
530
|
-
)
|
|
529
|
+
activitysmith.metrics.update("prod.status", "healthy")
|
|
531
530
|
```
|
|
532
531
|
|
|
533
|
-
|
|
532
|
+
## App Icon Badge Count
|
|
534
533
|
|
|
535
|
-
|
|
534
|
+

|
|
536
535
|
|
|
537
|
-
|
|
536
|
+
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.
|
|
538
537
|
|
|
539
|
-
|
|
538
|
+
### Set or update the badge value
|
|
540
539
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
540
|
+
```ruby
|
|
541
|
+
activitysmith.badge_count(8333)
|
|
542
|
+
```
|
|
544
543
|
|
|
545
|
-
|
|
544
|
+
### Clear the badge
|
|
546
545
|
|
|
547
|
-
|
|
548
|
-
<img src="https://cdn.activitysmith.com/features/create-widget-metric.png" alt="Create widget metric" width="680" />
|
|
549
|
-
</p>
|
|
546
|
+
Pass `0` to clear the badge.
|
|
550
547
|
|
|
551
548
|
```ruby
|
|
552
|
-
activitysmith.
|
|
549
|
+
activitysmith.badge_count(0)
|
|
553
550
|
```
|
|
554
551
|
|
|
555
|
-
|
|
552
|
+
## Metadata
|
|
553
|
+
|
|
554
|
+
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.
|
|
556
555
|
|
|
557
556
|
```ruby
|
|
558
|
-
activitysmith.
|
|
559
|
-
|
|
557
|
+
activitysmith.notifications.send(
|
|
558
|
+
title: "New subscription 💸",
|
|
559
|
+
message: "Customer upgraded to Pro plan",
|
|
560
|
+
metadata: {
|
|
561
|
+
customer_id: "382",
|
|
562
|
+
plan: "Pro",
|
|
563
|
+
amount: 29,
|
|
564
|
+
trial: false,
|
|
565
|
+
}
|
|
566
|
+
)
|
|
560
567
|
|
|
561
|
-
|
|
568
|
+
activitysmith.live_activities.stream(
|
|
569
|
+
"customer-import",
|
|
570
|
+
content_state: {
|
|
571
|
+
title: "Customer Import",
|
|
572
|
+
type: "progress",
|
|
573
|
+
percentage: 60,
|
|
574
|
+
},
|
|
575
|
+
metadata: {
|
|
576
|
+
job_id: "import-382",
|
|
577
|
+
records: 1200,
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
```
|
|
562
581
|
|
|
563
|
-
|
|
564
|
-
<img src="https://cdn.activitysmith.com/features/badge-count.png" alt="ActivitySmith app icon with an App Icon Badge Count" width="680" />
|
|
565
|
-
</p>
|
|
582
|
+
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.
|
|
566
583
|
|
|
567
|
-
|
|
584
|
+
## Tags
|
|
568
585
|
|
|
569
|
-
|
|
586
|
+
Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them.
|
|
570
587
|
|
|
571
588
|
```ruby
|
|
572
|
-
activitysmith.
|
|
589
|
+
activitysmith.notifications.send(
|
|
590
|
+
{
|
|
591
|
+
title: "New subscription 💸",
|
|
592
|
+
message: "Customer upgraded to Pro plan",
|
|
593
|
+
tags: ["user:382", "billing"]
|
|
594
|
+
}
|
|
595
|
+
)
|
|
573
596
|
```
|
|
574
597
|
|
|
575
|
-
|
|
598
|
+
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.
|
|
576
599
|
|
|
577
600
|
```ruby
|
|
578
|
-
activitysmith.
|
|
601
|
+
activitysmith.live_activities.update(
|
|
602
|
+
activity_id: "YOUR_ACTIVITY_ID",
|
|
603
|
+
content_state: { title: "Customer Import", percentage: 60 },
|
|
604
|
+
tags: []
|
|
605
|
+
)
|
|
579
606
|
```
|
|
580
607
|
|
|
581
608
|
## Channels
|
|
582
609
|
|
|
583
|
-
Use `channels` to target specific team members or devices
|
|
584
|
-
|
|
585
|
-
### Push Notifications
|
|
610
|
+
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.
|
|
586
611
|
|
|
587
612
|
```ruby
|
|
588
613
|
activitysmith.notifications.send(
|
|
@@ -592,46 +617,39 @@ activitysmith.notifications.send(
|
|
|
592
617
|
channels: ["sales", "customer-success"]
|
|
593
618
|
}
|
|
594
619
|
)
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
### Live Activities
|
|
598
620
|
|
|
599
|
-
|
|
600
|
-
|
|
621
|
+
activitysmith.live_activities.stream(
|
|
622
|
+
"nightly-backup",
|
|
601
623
|
{
|
|
624
|
+
channels: ["ios-builds"],
|
|
602
625
|
content_state: {
|
|
603
|
-
title: "Nightly
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
channels: ["sales", "customer-success"]
|
|
626
|
+
title: "Nightly database backup",
|
|
627
|
+
number_of_steps: 3,
|
|
628
|
+
current_step: 1,
|
|
629
|
+
type: "segmented_progress"
|
|
630
|
+
}
|
|
609
631
|
}
|
|
610
632
|
)
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
### App Icon Badge Count
|
|
614
633
|
|
|
615
|
-
```ruby
|
|
616
634
|
activitysmith.badge_count(3, channels: ["sales", "customer-success"])
|
|
617
635
|
```
|
|
618
636
|
|
|
619
637
|
## Error Handling
|
|
620
638
|
|
|
639
|
+
Handle API errors with `begin/rescue` around SDK calls:
|
|
640
|
+
|
|
621
641
|
```ruby
|
|
622
642
|
begin
|
|
623
643
|
activitysmith.notifications.send(
|
|
624
|
-
{ title: "
|
|
644
|
+
{ title: "Hello" }
|
|
625
645
|
)
|
|
626
646
|
rescue OpenapiClient::ApiError => err
|
|
627
647
|
puts "Request failed: #{err.code} #{err.message}"
|
|
628
648
|
end
|
|
629
649
|
```
|
|
630
650
|
|
|
631
|
-
##
|
|
632
|
-
|
|
633
|
-
- Ruby 3.0+
|
|
651
|
+
## Additional Resources
|
|
634
652
|
|
|
635
|
-
|
|
653
|
+
### [RubyGems Package](https://rubygems.org/gems/activitysmith)
|
|
636
654
|
|
|
637
|
-
|
|
655
|
+
Install the ActivitySmith Ruby SDK from RubyGems
|