activitysmith-cli 1.17.0 → 1.18.1
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 +55 -23
- package/package.json +2 -2
- package/src/cli.js +74 -5
package/README.md
CHANGED
|
@@ -111,22 +111,6 @@ activitysmith keys create --name "Ops alerts" --channels ops,alerts
|
|
|
111
111
|
|
|
112
112
|
An API key cannot create another key. This command always uses the browser sign-in, even when `ACTIVITYSMITH_API_KEY` is set.
|
|
113
113
|
|
|
114
|
-
## Paired Devices
|
|
115
|
-
|
|
116
|
-
List the iPhones and iPads paired to your account. Active devices come first:
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
activitysmith devices list
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
If no device is paired, the command prints the App Store link. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications.
|
|
123
|
-
|
|
124
|
-
Add `--include-inactive` to also list devices that can no longer receive deliveries:
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
activitysmith devices list --include-inactive
|
|
128
|
-
```
|
|
129
|
-
|
|
130
114
|
## Push Notifications
|
|
131
115
|
|
|
132
116
|
### Send a Push Notification
|
|
@@ -252,7 +236,7 @@ activitysmith push \
|
|
|
252
236
|
--actions-file "./actions.json"
|
|
253
237
|
```
|
|
254
238
|
|
|
255
|
-
###
|
|
239
|
+
### Interruption Levels
|
|
256
240
|
|
|
257
241
|

|
|
258
242
|
|
|
@@ -311,6 +295,23 @@ activitysmith push \
|
|
|
311
295
|
--message "Error rate is back to normal. Incident resolved."
|
|
312
296
|
```
|
|
313
297
|
|
|
298
|
+
### Dismiss a Push Notification
|
|
299
|
+
|
|
300
|
+
Pass the `Notification ID` to `push dismiss` when a Push Notification no longer needs attention, for example after you answered an agent's question somewhere else.
|
|
301
|
+
|
|
302
|
+
Dismissing clears it from the Lock Screen and Notification Center on every device it was sent to. History keeps it.
|
|
303
|
+
|
|
304
|
+
Devices clear the notification in the background, so it can take a moment.
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
activitysmith push \
|
|
308
|
+
--title "🙋 Agent needs your input" \
|
|
309
|
+
--message "Approve the database migration?"
|
|
310
|
+
# Notification ID: Xk3pQ8mV2nR7tL9wB4yZ
|
|
311
|
+
|
|
312
|
+
activitysmith push dismiss "Xk3pQ8mV2nR7tL9wB4yZ"
|
|
313
|
+
```
|
|
314
|
+
|
|
314
315
|
## Live Activities
|
|
315
316
|
|
|
316
317
|
Choose the Live Activity type that matches what you want to show:
|
|
@@ -527,13 +528,13 @@ activitysmith activity stream nightly-backup \
|
|
|
527
528
|
}'
|
|
528
529
|
```
|
|
529
530
|
|
|
530
|
-
###
|
|
531
|
+
### Colors
|
|
531
532
|
|
|
532
533
|
Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge:
|
|
533
534
|
|
|
534
535
|
`lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
|
|
535
536
|
|
|
536
|
-
###
|
|
537
|
+
### Actions
|
|
537
538
|
|
|
538
539
|

|
|
539
540
|
|
|
@@ -654,11 +655,9 @@ activitysmith activity stream agent-approval \
|
|
|
654
655
|
|
|
655
656
|

|
|
656
657
|
|
|
657
|
-
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.
|
|
658
|
+
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. Send a value to a metric key, add a widget to your Lock Screen, and it fetches the latest value automatically.
|
|
658
659
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
Use the metric key to update its value.
|
|
660
|
+
Use the metric key to update its value. The first value creates the metric.
|
|
662
661
|
|
|
663
662
|
```bash
|
|
664
663
|
activitysmith metrics update deploy.success_rate 99.9
|
|
@@ -670,6 +669,23 @@ String metric values work too.
|
|
|
670
669
|
activitysmith metrics update prod.status healthy
|
|
671
670
|
```
|
|
672
671
|
|
|
672
|
+
### Create a metric
|
|
673
|
+
|
|
674
|
+
Use `create` to set the label and how widgets show the value, such as currency, percent, or a unit. Omitted fields keep their current values, so you can call it every time your app starts.
|
|
675
|
+
|
|
676
|
+
```bash
|
|
677
|
+
activitysmith metrics create mrr \
|
|
678
|
+
--label MRR \
|
|
679
|
+
--format currency \
|
|
680
|
+
--currency-code USD
|
|
681
|
+
|
|
682
|
+
activitysmith metrics update mrr 12450
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
You can also create and edit metrics in the [web app](https://activitysmith.com/app/widgets).
|
|
686
|
+
|
|
687
|
+

|
|
688
|
+
|
|
673
689
|
## App Icon Badge
|
|
674
690
|
|
|
675
691
|

|
|
@@ -835,6 +851,22 @@ activitysmith activity stream nightly-backup \
|
|
|
835
851
|
activitysmith badge 3 --channels "sales,customer-success"
|
|
836
852
|
```
|
|
837
853
|
|
|
854
|
+
## Paired Devices
|
|
855
|
+
|
|
856
|
+
List the iPhones and iPads paired to your account. Active devices come first:
|
|
857
|
+
|
|
858
|
+
```bash
|
|
859
|
+
activitysmith devices list
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
If no device is paired, the command prints the App Store link. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications.
|
|
863
|
+
|
|
864
|
+
Add `--include-inactive` to also list devices that can no longer receive deliveries:
|
|
865
|
+
|
|
866
|
+
```bash
|
|
867
|
+
activitysmith devices list --include-inactive
|
|
868
|
+
```
|
|
869
|
+
|
|
838
870
|
## Output
|
|
839
871
|
|
|
840
872
|
Use `--json` for machine-readable output:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "activitysmith-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.1",
|
|
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.
|
|
45
|
+
"activitysmith": "^1.15.0",
|
|
46
46
|
"commander": "^12.1.0"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/cli.js
CHANGED
|
@@ -391,7 +391,7 @@ const validateContentState = (contentState, mode) => {
|
|
|
391
391
|
const normalizedType =
|
|
392
392
|
typeof contentState.type === "string" ? contentState.type.trim() : undefined;
|
|
393
393
|
|
|
394
|
-
if (
|
|
394
|
+
if (typeof contentState.title !== "string") {
|
|
395
395
|
throw new Error("contentState.title is required");
|
|
396
396
|
}
|
|
397
397
|
|
|
@@ -1282,10 +1282,11 @@ const outputResult = (payload, options, lines) => {
|
|
|
1282
1282
|
lines.filter(Boolean).forEach((line) => console.log(line));
|
|
1283
1283
|
};
|
|
1284
1284
|
|
|
1285
|
-
program
|
|
1285
|
+
const pushCommand = program
|
|
1286
1286
|
.command("push")
|
|
1287
|
-
.description("Send a push notification, or replace one you already sent")
|
|
1288
|
-
|
|
1287
|
+
.description("Send a push notification, or replace or dismiss one you already sent")
|
|
1288
|
+
// Not requiredOption: commander would then demand --title for the dismiss subcommand too.
|
|
1289
|
+
.option("--title <title>", "Push title (required to send or replace)")
|
|
1289
1290
|
.option(
|
|
1290
1291
|
"--replace <notification-id>",
|
|
1291
1292
|
"Silently replace a sent push notification, using the notification ID from its send output"
|
|
@@ -1322,6 +1323,10 @@ program
|
|
|
1322
1323
|
.action(async (options) => {
|
|
1323
1324
|
const globalOptions = program.opts();
|
|
1324
1325
|
|
|
1326
|
+
if (options.title === undefined) {
|
|
1327
|
+
pushCommand.error("error: required option '--title <title>' not specified");
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1325
1330
|
try {
|
|
1326
1331
|
const apiKey = await requireApiKey(globalOptions);
|
|
1327
1332
|
const client = createClient(apiKey);
|
|
@@ -1390,6 +1395,35 @@ program
|
|
|
1390
1395
|
}
|
|
1391
1396
|
});
|
|
1392
1397
|
|
|
1398
|
+
pushCommand
|
|
1399
|
+
.command("dismiss")
|
|
1400
|
+
.description(
|
|
1401
|
+
"Clear a sent push notification from the Lock Screen and Notification Center. History keeps it."
|
|
1402
|
+
)
|
|
1403
|
+
.argument("<notification-id>", "Notification ID from the push send output")
|
|
1404
|
+
.action(async (notificationId) => {
|
|
1405
|
+
const globalOptions = program.opts();
|
|
1406
|
+
|
|
1407
|
+
try {
|
|
1408
|
+
const id = String(notificationId).trim();
|
|
1409
|
+
if (!id) {
|
|
1410
|
+
throw new Error("Notification ID is required.");
|
|
1411
|
+
}
|
|
1412
|
+
const apiKey = await requireApiKey(globalOptions);
|
|
1413
|
+
const client = createClient(apiKey);
|
|
1414
|
+
const response = await client.notifications.dismiss(id);
|
|
1415
|
+
const dismissedAt = response?.dismissed_at ?? response?.dismissedAt;
|
|
1416
|
+
|
|
1417
|
+
outputResult(response, globalOptions, [
|
|
1418
|
+
"Push dismissed.",
|
|
1419
|
+
`Notification ID: ${response?.notification_id ?? response?.notificationId ?? id}`,
|
|
1420
|
+
dismissedAt ? `Dismissed at: ${dismissedAt}` : null,
|
|
1421
|
+
]);
|
|
1422
|
+
} catch (error) {
|
|
1423
|
+
await handleError(error, globalOptions);
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1426
|
+
|
|
1393
1427
|
program
|
|
1394
1428
|
.command("badge")
|
|
1395
1429
|
.alias("badge-count")
|
|
@@ -1432,7 +1466,42 @@ program
|
|
|
1432
1466
|
const metricsCommand = program
|
|
1433
1467
|
.command("metrics")
|
|
1434
1468
|
.alias("metric")
|
|
1435
|
-
.description("
|
|
1469
|
+
.description("Create widget metrics and update their values");
|
|
1470
|
+
|
|
1471
|
+
metricsCommand
|
|
1472
|
+
.command("create")
|
|
1473
|
+
.description("Create a widget metric, or update the fields you pass for an existing one")
|
|
1474
|
+
.argument("<metric-key>", "Metric key")
|
|
1475
|
+
.option("--label <label>", "Name shown on the widget (defaults to a label made from the key)")
|
|
1476
|
+
.option("--format <format>", "number, currency, percent, unit, or string (defaults to number)")
|
|
1477
|
+
.option("--currency-code <code>", "3-letter ISO currency code, required for the currency format")
|
|
1478
|
+
.option("--unit <unit>", "Unit suffix for the unit format, such as ms or GB")
|
|
1479
|
+
.option("--unit-spacing <spacing>", "For the unit format: none (120ms) or space (120 ms)")
|
|
1480
|
+
.action(async (metricKey, options) => {
|
|
1481
|
+
const globalOptions = program.opts();
|
|
1482
|
+
|
|
1483
|
+
try {
|
|
1484
|
+
const apiKey = await requireApiKey(globalOptions);
|
|
1485
|
+
const client = createClient(apiKey);
|
|
1486
|
+
const definition = Object.fromEntries(
|
|
1487
|
+
Object.entries({
|
|
1488
|
+
label: options.label,
|
|
1489
|
+
format: options.format,
|
|
1490
|
+
currency_code: options.currencyCode,
|
|
1491
|
+
unit: options.unit,
|
|
1492
|
+
unit_spacing: options.unitSpacing,
|
|
1493
|
+
}).filter(([, value]) => value !== undefined)
|
|
1494
|
+
);
|
|
1495
|
+
const response = await client.metrics.create(
|
|
1496
|
+
metricKey,
|
|
1497
|
+
Object.keys(definition).length > 0 ? definition : undefined
|
|
1498
|
+
);
|
|
1499
|
+
|
|
1500
|
+
outputResult(response, globalOptions, ["Metric saved."]);
|
|
1501
|
+
} catch (error) {
|
|
1502
|
+
await handleError(error, globalOptions);
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1436
1505
|
|
|
1437
1506
|
metricsCommand
|
|
1438
1507
|
.command("update")
|