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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +243 -225
  3. data/generated/activitysmith_openapi/api/app_icon_badges_api.rb +4 -4
  4. data/generated/activitysmith_openapi/api/live_activities_api.rb +10 -10
  5. data/generated/activitysmith_openapi/api/push_notifications_api.rb +2 -2
  6. data/generated/activitysmith_openapi/configuration.rb +7 -0
  7. data/generated/activitysmith_openapi/models/app_icon_badge_count_update_error.rb +386 -0
  8. data/generated/activitysmith_openapi/models/app_icon_badge_count_update_request.rb +0 -1
  9. data/generated/activitysmith_openapi/models/app_icon_badge_count_update_response.rb +33 -11
  10. data/generated/activitysmith_openapi/models/live_activity_action.rb +1 -1
  11. data/generated/activitysmith_openapi/models/live_activity_end_request.rb +64 -2
  12. data/generated/activitysmith_openapi/models/live_activity_limit_error.rb +25 -5
  13. data/generated/activitysmith_openapi/models/live_activity_start_request.rb +48 -5
  14. data/generated/activitysmith_openapi/models/live_activity_start_response.rb +13 -1
  15. data/generated/activitysmith_openapi/models/live_activity_stream_delete_request.rb +45 -2
  16. data/generated/activitysmith_openapi/models/live_activity_stream_put_response.rb +13 -1
  17. data/generated/activitysmith_openapi/models/live_activity_stream_request.rb +48 -5
  18. data/generated/activitysmith_openapi/models/live_activity_update_request.rb +64 -2
  19. data/generated/activitysmith_openapi/models/metadata_value.rb +106 -0
  20. data/generated/activitysmith_openapi/models/push_notification_action.rb +1 -1
  21. data/generated/activitysmith_openapi/models/push_notification_request.rb +60 -8
  22. data/generated/activitysmith_openapi/models/push_notification_response.rb +13 -1
  23. data/generated/activitysmith_openapi/models/update_app_icon_badge_count422_response.rb +105 -0
  24. data/generated/activitysmith_openapi/version.rb +1 -1
  25. data/generated/activitysmith_openapi.rb +3 -0
  26. data/generated/openapi-source.json +6 -0
  27. data/lib/activitysmith/live_activities.rb +36 -14
  28. data/lib/activitysmith/notifications.rb +19 -4
  29. data/lib/activitysmith/version.rb +1 -1
  30. metadata +6 -2
data/README.md CHANGED
@@ -1,50 +1,35 @@
1
1
  # ActivitySmith Ruby SDK
2
2
 
3
- The ActivitySmith Ruby SDK provides convenient access to the ActivitySmith API from Ruby applications.
4
-
5
- ## Documentation
6
-
7
- See [API reference](https://activitysmith.com/docs/api-reference/introduction).
8
-
9
- ## Table of Contents
10
-
11
- - [Installation](#installation)
12
- - [Setup](#setup)
13
- - [Push Notifications](#push-notifications)
14
- - [Send a Push Notification](#send-a-push-notification)
15
- - [Rich Push Notifications with Media](#rich-push-notifications-with-media)
16
- - [Actionable Push Notifications](#actionable-push-notifications)
17
- - [Live Activities](#live-activities)
18
- - [Start & Update Live Activity](#start--update-live-activity)
19
- - [End Live Activity](#end-live-activity)
20
- - [Live Activity Action](#live-activity-action)
21
- - [Icons and Badges](#icons-and-badges)
22
- - [Live Activity Colors](#live-activity-colors)
23
- - [Widgets](#widgets)
24
- - [App Icon Badge Count](#app-icon-badge-count)
25
- - [Channels](#channels)
3
+ [Documentation](https://activitysmith.com/docs/sdks/ruby)
26
4
 
27
5
  ## Installation
28
6
 
29
- ```sh
7
+ Install the ActivitySmith Ruby SDK with RubyGems:
8
+
9
+ ```bash
30
10
  gem install activitysmith
31
11
  ```
32
12
 
33
- ## Setup
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(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY"))
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
- <p align="center">
46
- <img src="https://cdn.activitysmith.com/features/new-subscription-push-notification.png" alt="Push notification example" width="680" />
47
- </p>
30
+ Send an immediate notification for a completed task or event.
31
+
32
+ ![Push Notification example for a new subscription event](https://cdn.activitysmith.com/features/new-subscription-push-notification.png)
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
- <p align="center">
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
+ ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png)
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
- Send images, videos, or audio with your push notifications, press and hold to preview media directly from the notification, then tap through to open the linked content.
57
+ Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media.
76
58
 
77
- <p align="center">
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
+ ![Rich Push Notification with audio](https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png)
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
- <p align="center">
91
- <img src="https://cdn.activitysmith.com/features/actionable-push-notifications-2.png" alt="Actionable push notification example" width="680" />
92
- </p>
94
+ ![Actionable Push Notification with redirection and actions](https://cdn.activitysmith.com/features/actionable-push-notifications-2.png)
93
95
 
94
- Push notification `redirection` and `actions` are optional. Use them to open HTTPS URLs, run a specific iPhone Shortcut with `shortcuts://run-shortcut?name=...`, or trigger backend webhook workflows.
95
- Webhooks are executed by the ActivitySmith backend.
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
- redirection: "https://crm.example.com/customers/cus_9f3a1d", # Optional
103
- actions: [ # Optional (max 4)
113
+ actions: [
104
114
  {
105
- title: "Open CRM Profile",
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
- There are six types of Live Activities:
141
+ Choose the Live Activity type that matches what you want to show:
142
+
143
+ ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png)
144
+
145
+ **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
146
+
147
+ ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png)
148
+
149
+ **Metrics**: Track two related values with segmented bars, such as CPU and memory.
132
150
 
133
- - `stats`: best for showing business numbers side by side, such as revenue, sales, new users, conversion, refunds, or any other value you want visible at a glance
134
- - `metrics`: best for live percentage values that change often, like server CPU, memory usage, disk usage, or error rate
135
- - `segmented_progress`: best for anything that moves through clear stages, like deployments, onboarding flows, backups, ETL pipelines, migrations, and AI agent runs
136
- - `progress`: best for tracking real-time progress with percentage, like tasks, backups, migrations, syncs, or uploads
137
- - `alert`: best for status updates, such as feature adoption, reactivation, onboarding blockers, incidents, escalations, and other operational states
138
- - `timer`: best for countdowns and elapsed runtime, like benchmark runs, uploads, backups, transcodes, and long-running jobs
151
+ ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png)
152
+
153
+ **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
154
+
155
+ ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png)
156
+
157
+ **Progress**: Show percentage progress for jobs that move continuously toward completion.
158
+
159
+ ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png)
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
+ ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png)
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
- <p align="center">
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
+ ![Stats Live Activity stream example](https://cdn.activitysmith.com/features/stats-live-activity.png)
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
- <p align="center">
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
+ ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png)
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
- <p align="center">
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
+ ![Segmented Progress Live Activity stream example](https://cdn.activitysmith.com/features/update-live-activity.png)
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
- <p align="center">
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
+ ![Progress Live Activity stream example](https://cdn.activitysmith.com/features/progress-live-activity.png)
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
- <p align="center">
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
+ ![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png)
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
- <p align="center">
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
+ ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png)
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. By default, iOS removes the Live Activity after two minutes. Set `auto_dismiss_minutes` to choose a different dismissal time, including `0` for immediate dismissal.
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
- auto_dismiss_minutes: 2
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
+ ![Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen](https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png)
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
+ ![Progress Live Activity with a badge on the iPhone Lock Screen](https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png)
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 Activities can include an action button.
381
+ ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png)
330
382
 
331
- - `open_url`: open an HTTPS URL.
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
- <p align="center">
336
- <img
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://ops.example.com/servers/prod-web-1"
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
- "deploy-payments-api",
421
+ "prod-web-1",
372
422
  {
373
423
  content_state: {
374
- title: "Deploying payments-api",
375
- subtitle: "Running database migrations",
376
- type: "segmented_progress",
377
- number_of_steps: 5,
378
- current_step: 3
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
- <p align="center">
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
+ ![Alert Live Activity with primary and secondary action buttons](https://cdn.activitysmith.com/features/live-activity-secondary-action.png)
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
- ### Icons and Badges
512
+ ## Lock Screen Widgets
467
513
 
468
- Add more context to Live Activities with icons and badges.
514
+ ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png)
469
515
 
470
- #### Icon
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
- Supported Live Activity types: `stats`, `metrics`, `progress`, `segmented_progress`, `alert`, and `timer`.
518
+ ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png)
473
519
 
474
- <p align="center">
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.live_activities.stream(
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
- The `icon` symbol value is an Apple SF Symbol name. Browse the catalog with one of these tools:
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.live_activities.stream(
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
- ### Live Activity Colors
532
+ ## App Icon Badge Count
534
533
 
535
- Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
534
+ ![ActivitySmith app icon with an App Icon Badge Count](https://cdn.activitysmith.com/features/badge-count.png)
536
535
 
537
- `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
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
- ## Widgets
538
+ ### Set or update the badge value
540
539
 
541
- <p align="center">
542
- <img src="https://cdn.activitysmith.com/features/lock-screen-widgets.png" alt="Lock screen widgets" width="680" />
543
- </p>
540
+ ```ruby
541
+ activitysmith.badge_count(8333)
542
+ ```
544
543
 
545
- 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.
544
+ ### Clear the badge
546
545
 
547
- <p align="center">
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.metrics.update("deploy.success_rate", 99.9)
549
+ activitysmith.badge_count(0)
553
550
  ```
554
551
 
555
- String metric values work too.
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.metrics.update("prod.status", "healthy")
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
- ## App Icon Badge Count
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
- <p align="center">
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
- 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.
584
+ ## Tags
568
585
 
569
- Set or update the badge value.
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.badge_count(8333)
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
- To clear the badge, set its value to 0.
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.badge_count(0)
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
- ```ruby
600
- activitysmith.live_activities.start(
621
+ activitysmith.live_activities.stream(
622
+ "nightly-backup",
601
623
  {
624
+ channels: ["ios-builds"],
602
625
  content_state: {
603
- title: "Nightly Database Backup",
604
- subtitle: "verify restore",
605
- type: "progress",
606
- percentage: 62
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: "New subscription 💸" }
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
- ## Requirements
632
-
633
- - Ruby 3.0+
651
+ ## Additional Resources
634
652
 
635
- ## License
653
+ ### [RubyGems Package](https://rubygems.org/gems/activitysmith)
636
654
 
637
- MIT
655
+ Install the ActivitySmith Ruby SDK from RubyGems