activitysmith-cli 1.12.0 → 1.14.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 (3) hide show
  1. package/README.md +96 -11
  2. package/package.json +2 -2
  3. package/src/cli.js +45 -8
package/README.md CHANGED
@@ -57,6 +57,19 @@ activitysmith push \
57
57
  --subtitle "main"
58
58
  ```
59
59
 
60
+ ### Custom Push Notification Icons
61
+
62
+ ![Push Notifications with custom icons](https://cdn.activitysmith.com/features/push-notifications-with-custom-icons.png)
63
+
64
+ Set `--icon` to a publicly accessible HTTPS image URL to show a logo or avatar alongside a smaller ActivitySmith app icon. With a custom icon, iOS may omit the subtitle from the notification.
65
+
66
+ ```bash
67
+ activitysmith push \
68
+ --title 'MRR just crossed $10,000 🎉' \
69
+ --message "Up 18% this month from 31 new subscriptions." \
70
+ --icon "https://cdn.activitysmith.com/integrations/icons/stripe.png"
71
+ ```
72
+
60
73
  ### Rich Push Notifications with Media
61
74
 
62
75
  ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png)
@@ -154,28 +167,104 @@ activitysmith push \
154
167
  --actions-file "./actions.json"
155
168
  ```
156
169
 
170
+ ### Push Notification Interruption Levels
171
+
172
+ ![Time Sensitive Push Notification](https://cdn.activitysmith.com/features/time-sensitive-push-notifications.png)
173
+
174
+ Use `--interruption-level` to choose how urgently iOS presents a Push Notification. Omit it for normal delivery. Explicit `active` has the same behavior as the default.
175
+
176
+ | Value | Behavior |
177
+ | --- | --- |
178
+ | `passive` | Appears quietly in the notification list, without sound or waking the screen. |
179
+ | `active` | Normal delivery, subject to the device's notification settings and Focus. This is the default. |
180
+ | `time-sensitive` | Can bypass Scheduled Summary and Focus when the user allows Time Sensitive Notifications for ActivitySmith. |
181
+
182
+ See Apple's [interruption levels](https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel) for the system behavior.
183
+
184
+ #### Passive
185
+
186
+ ```bash
187
+ activitysmith push \
188
+ --title "Daily summary" \
189
+ --message "All scheduled jobs completed successfully." \
190
+ --interruption-level "passive"
191
+ ```
192
+
193
+ #### Active (default)
194
+
195
+ ```bash
196
+ activitysmith push \
197
+ --title "Deployment complete" \
198
+ --message "Your latest changes are live." \
199
+ --interruption-level "active"
200
+ ```
201
+
202
+ Removing the interruption level from this example produces the same delivery behavior.
203
+
204
+ #### Time Sensitive
205
+
206
+ ```bash
207
+ activitysmith push \
208
+ --title "🚨 checkout-api is down" \
209
+ --message "500 errors on 62% of requests. Customers can't complete payments." \
210
+ --interruption-level "time-sensitive"
211
+ ```
212
+
213
+ ### Replace a Push Notification
214
+
215
+ Every `push` prints a `Notification ID`. Pass it to `--replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original, so `--channels` and `--interruption-level` don't apply.
216
+
217
+ ```bash
218
+ activitysmith push \
219
+ --title "🚨 checkout-api is down" \
220
+ --message "500 errors on 62% of requests."
221
+ # Notification ID: Xk3pQ8mV2nR7tL9wB4yZ
222
+
223
+ activitysmith push \
224
+ --replace "Xk3pQ8mV2nR7tL9wB4yZ" \
225
+ --title "✅ checkout-api recovered" \
226
+ --message "Error rate is back to normal. Incident resolved."
227
+ ```
228
+
157
229
  ## Live Activities
158
230
 
159
231
  Choose the Live Activity type that matches what you want to show:
160
232
 
161
- - ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature.
233
+ ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png)
234
+
235
+ **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature.
236
+
237
+ ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png)
238
+
239
+ **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
240
+
241
+ ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png)
242
+
243
+ **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.
162
244
 
163
- - ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion.
245
+ ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png)
164
246
 
165
- - ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint.
247
+ **Metrics**: Track two related values with segmented bars, such as CPU and memory.
166
248
 
167
- - ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory.
249
+ ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png)
168
250
 
169
- - ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
251
+ **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify.
170
252
 
171
- - ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion.
253
+ ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png)
172
254
 
173
- - ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs.
255
+ **Progress**: Show percentage progress for jobs that move continuously toward completion.
256
+
257
+ ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png)
258
+
259
+ **Timer**: Count down from a duration, or count up from 00:00 while a job runs.
174
260
 
175
261
  ### Start & Update Live Activity
176
262
 
177
263
  Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `activity stream` command starts the Live Activity. Later commands with the same `stream_key` update it.
178
264
 
265
+ > [!WARNING]
266
+ > iOS limits how often a Live Activity can update. Short bursts that end, like deployment steps, are fine. If one Live Activity keeps updating more often than every couple of minutes, iOS throttles it until the budget refills, roughly an hour, even though the API still returns `200`. [Learn more](https://activitysmith.com/docs/live-activity-stream#update-frequency-and-ios-limits)
267
+
179
268
  #### Value
180
269
 
181
270
  ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png)
@@ -609,7 +698,3 @@ The CLI exits non-zero on non-2xx responses and prints the API error body. That
609
698
  ### [NPM Package](https://www.npmjs.com/package/activitysmith-cli)
610
699
 
611
700
  Install the ActivitySmith CLI from npm
612
-
613
- ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-cli)
614
-
615
- View the CLI source on GitHub
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "Command-line interface for ActivitySmith. Send Push Notifications, start, update, and end Live Activities, and set App Icon Badge Counts from your terminal.",
5
5
  "keywords": [
6
6
  "activitysmith",
@@ -42,7 +42,7 @@
42
42
  "test": "node --test"
43
43
  },
44
44
  "dependencies": {
45
- "activitysmith": "^1.12.0",
45
+ "activitysmith": "^1.14.0",
46
46
  "commander": "^12.1.0"
47
47
  }
48
48
  }
package/src/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { Command, InvalidArgumentError } from "commander";
3
+ import { Command, InvalidArgumentError, Option } from "commander";
4
4
  import { loadMetadata } from "./metadata.js";
5
5
  import ActivitySmith from "activitysmith";
6
6
  import { createRequire } from "module";
@@ -1257,14 +1257,26 @@ const outputResult = (payload, options, lines) => {
1257
1257
 
1258
1258
  program
1259
1259
  .command("push")
1260
- .description("Send a push notification")
1260
+ .description("Send a push notification, or replace one you already sent")
1261
1261
  .requiredOption("--title <title>", "Push title")
1262
+ .option(
1263
+ "--replace <notification-id>",
1264
+ "Silently replace a sent push notification, using the notification ID from its send output"
1265
+ )
1262
1266
  .option("--message <message>", "Push message")
1263
1267
  .option("--subtitle <subtitle>", "Push subtitle")
1264
1268
  .option(
1265
1269
  "--media <url>",
1266
1270
  "HTTPS URL for image, audio, or video shown when the notification is expanded"
1267
1271
  )
1272
+ .option("--icon <url>", "HTTPS image URL for the notification icon, such as a logo or avatar")
1273
+ .addOption(
1274
+ new Option("--interruption-level <level>", "Notification interruption level").choices([
1275
+ "passive",
1276
+ "active",
1277
+ "time-sensitive",
1278
+ ])
1279
+ )
1268
1280
  .option("--redirection <url>", "HTTPS or shortcuts:// URL opened when notification is tapped")
1269
1281
  .option("--actions <json>", "Actions JSON array (max 4)")
1270
1282
  .option("--actions-file <path>", "Path to actions JSON array file")
@@ -1291,6 +1303,16 @@ program
1291
1303
  media: options.media,
1292
1304
  actions,
1293
1305
  });
1306
+ if (options.replace !== undefined) {
1307
+ if (options.channels !== undefined || options.interruptionLevel !== undefined) {
1308
+ throw new Error(
1309
+ "--channels and --interruption-level cannot be combined with --replace. Replacements go to the original recipients and arrive silently."
1310
+ );
1311
+ }
1312
+ if (options.replace.trim() === "") {
1313
+ throw new Error("--replace requires the notification ID from the original push output.");
1314
+ }
1315
+ }
1294
1316
 
1295
1317
  const pushNotificationRequest = withTargetChannels(
1296
1318
  {
@@ -1301,6 +1323,11 @@ program
1301
1323
  options.media !== undefined
1302
1324
  ? normalizeHttpsUrl(options.media, "media")
1303
1325
  : undefined,
1326
+ icon:
1327
+ options.icon !== undefined
1328
+ ? normalizeHttpsUrl(options.icon, "icon")
1329
+ : undefined,
1330
+ interruption_level: options.interruptionLevel,
1304
1331
  redirection:
1305
1332
  options.redirection !== undefined
1306
1333
  ? normalizeOpenUrl(options.redirection, "redirection")
@@ -1312,18 +1339,24 @@ program
1312
1339
  options.channels
1313
1340
  );
1314
1341
 
1315
- const response = await client.notifications.sendPushNotification({
1316
- pushNotificationRequest,
1317
- });
1342
+ const isReplacement = options.replace !== undefined;
1343
+ const response = isReplacement
1344
+ ? await client.notifications.replace(options.replace.trim(), pushNotificationRequest)
1345
+ : await client.notifications.sendPushNotification({
1346
+ pushNotificationRequest,
1347
+ });
1348
+ const devicesNotified = response?.devices_notified ?? response?.devicesNotified;
1349
+ const notificationId = response?.notification_id ?? response?.notificationId;
1318
1350
 
1319
1351
  outputResult(response, globalOptions, [
1320
- "Push sent.",
1352
+ isReplacement ? "Push replaced." : "Push sent.",
1321
1353
  response?.success !== undefined
1322
1354
  ? `Success: ${response.success}`
1323
1355
  : null,
1324
- response?.devicesNotified !== undefined
1325
- ? `Devices notified: ${response.devicesNotified}`
1356
+ devicesNotified !== undefined
1357
+ ? `Devices notified: ${devicesNotified}`
1326
1358
  : null,
1359
+ notificationId ? `Notification ID: ${notificationId}` : null,
1327
1360
  ]);
1328
1361
  } catch (error) {
1329
1362
  await handleError(error, globalOptions);
@@ -1404,6 +1437,10 @@ addLiveActivityActionOptions(addContentStateOptions(
1404
1437
  activityCommand
1405
1438
  .command("stream")
1406
1439
  .description("Send a stateless Live Activity stream update")
1440
+ .addHelpText(
1441
+ "after",
1442
+ "\niOS limits how often a Live Activity can update. Short bursts are fine, but avoid updating the same Live Activity more often than every couple of minutes for long periods.\n"
1443
+ )
1407
1444
  .argument("<stream-key>", "Stable stream key")
1408
1445
  .option(
1409
1446
  "--channels <channels>",