activitysmith 1.1.0 → 1.2.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 +59 -24
- package/dist/generated/apis/LiveActivitiesApi.d.ts +6 -6
- package/dist/generated/apis/LiveActivitiesApi.js +6 -6
- package/dist/generated/apis/MetricsApi.d.ts +32 -0
- package/dist/generated/apis/MetricsApi.js +61 -0
- package/dist/generated/apis/index.d.ts +1 -0
- package/dist/generated/apis/index.js +1 -0
- package/dist/generated/models/index.d.ts +168 -18
- package/dist/generated/models/index.js +24 -17
- package/dist/src/ActivitySmith.d.ts +15 -1
- package/dist/src/ActivitySmith.js +41 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,24 @@ The ActivitySmith Node SDK provides convenient access to the ActivitySmith API f
|
|
|
6
6
|
|
|
7
7
|
See [API reference](https://activitysmith.com/docs/api-reference/introduction)
|
|
8
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
|
+
- [Simple: Let ActivitySmith manage the Live Activity for you](#simple-let-activitysmith-manage-the-live-activity-for-you)
|
|
19
|
+
- [Advanced: Full lifecycle control](#advanced-full-lifecycle-control)
|
|
20
|
+
- [Metrics Type](#metrics-type)
|
|
21
|
+
- [Segmented Progress Type](#segmented-progress-type)
|
|
22
|
+
- [Progress Type](#progress-type)
|
|
23
|
+
- [Live Activity Action](#live-activity-action)
|
|
24
|
+
- [Channels](#channels)
|
|
25
|
+
- [Widgets](#widgets)
|
|
26
|
+
|
|
9
27
|
## Installation
|
|
10
28
|
|
|
11
29
|
```sh
|
|
@@ -112,32 +130,27 @@ await activitysmith.notifications.send({
|
|
|
112
130
|
## Live Activities
|
|
113
131
|
|
|
114
132
|
<p align="center">
|
|
115
|
-
<img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Live
|
|
133
|
+
<img src="https://cdn.activitysmith.com/features/metrics-live-activity-action.png" alt="Metrics Live Activity screenshot" width="680" />
|
|
116
134
|
</p>
|
|
117
135
|
|
|
118
|
-
|
|
136
|
+
There are three types of Live Activities:
|
|
119
137
|
|
|
120
|
-
-
|
|
121
|
-
-
|
|
138
|
+
- `metrics`: best for live operational stats like server CPU and memory, queue depth, or replica lag
|
|
139
|
+
- `segmented_progress`: best for step-based workflows like deployments, backups, and ETL pipelines
|
|
140
|
+
- `progress`: best for continuous jobs like uploads, reindexes, and long-running migrations tracked as a percentage
|
|
122
141
|
|
|
123
|
-
|
|
124
|
-
store `activity_id` or manage lifecycle state yourself. Send the latest state
|
|
125
|
-
for a stable `streamKey` and ActivitySmith will start or update the Live
|
|
126
|
-
Activity for you. When the tracked process is over, call `endStream(...)`.
|
|
142
|
+
When working with Live Activities via our API, you have two approaches tailored to different needs. First, the stateless mode is the simplest path - one API call can initiate or update an activity, and another ends it - no state tracking on your side.
|
|
127
143
|
|
|
128
|
-
|
|
129
|
-
Live Activity instance.
|
|
144
|
+
This is ideal if you want minimal complexity, perfect for automated workflows like cron jobs.
|
|
130
145
|
|
|
131
|
-
|
|
146
|
+
In contrast, if you need precise lifecycle control, the classic approach offers distinct calls for start, updates, and end, giving you full control over the activity's state.
|
|
132
147
|
|
|
133
|
-
|
|
134
|
-
- `segmented_progress`: best for step-based workflows like deployments, backups, and ETL pipelines
|
|
135
|
-
- `progress`: best for continuous jobs like uploads, reindexes, and long-running migrations tracked as a percentage
|
|
148
|
+
In the following sections, we'll break down how to implement each method so you can choose what fits your use case best.
|
|
136
149
|
|
|
137
|
-
###
|
|
150
|
+
### Simple: Let ActivitySmith manage the Live Activity for you
|
|
138
151
|
|
|
139
152
|
Use a stable `streamKey` to identify the system or workflow you are tracking,
|
|
140
|
-
such as a server, deployment, build pipeline
|
|
153
|
+
such as a server, deployment, or build pipeline.
|
|
141
154
|
This is especially useful for cron jobs and other scheduled tasks where you do
|
|
142
155
|
not want to store `activity_id` between runs.
|
|
143
156
|
|
|
@@ -230,11 +243,9 @@ Stream responses include an `operation` field:
|
|
|
230
243
|
- `paused`: the stream is paused, so no Live Activity was started or updated
|
|
231
244
|
- `ended`: returned by `endStream(...)` after the stream is ended
|
|
232
245
|
|
|
233
|
-
### Advanced:
|
|
234
|
-
|
|
235
|
-
Use these methods when you want to manage the Live Activity lifecycle yourself.
|
|
246
|
+
### Advanced: Full lifecycle control
|
|
236
247
|
|
|
237
|
-
|
|
248
|
+
Use these methods when you want to manage the Live Activity lifecycle yourself:
|
|
238
249
|
|
|
239
250
|
1. Call `activitysmith.liveActivities.start(...)`.
|
|
240
251
|
2. Save the returned `activity_id`.
|
|
@@ -313,10 +324,10 @@ await activitysmith.liveActivities.end({
|
|
|
313
324
|
|
|
314
325
|
### Segmented Progress Type
|
|
315
326
|
|
|
316
|
-
Use `segmented_progress`
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
327
|
+
Use `segmented_progress` for jobs and workflows that move through clear steps or
|
|
328
|
+
phases. It fits jobs like backups, deployments, ETL pipelines, and checklists.
|
|
329
|
+
`number_of_steps` is dynamic, so you can increase or decrease it later if the
|
|
330
|
+
workflow changes.
|
|
320
331
|
|
|
321
332
|
#### Start
|
|
322
333
|
|
|
@@ -508,6 +519,30 @@ await activitysmith.notifications.send({
|
|
|
508
519
|
});
|
|
509
520
|
```
|
|
510
521
|
|
|
522
|
+
## Widgets
|
|
523
|
+
|
|
524
|
+
<p align="center">
|
|
525
|
+
<img src="https://cdn.activitysmith.com/features/lock-screen-widgets.png" alt="Lock screen widgets" width="680" />
|
|
526
|
+
</p>
|
|
527
|
+
|
|
528
|
+
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, then update the metric value using our API, add a widget to your lock screen and it will fetch the latest update automatically.
|
|
529
|
+
|
|
530
|
+
<p align="center">
|
|
531
|
+
<img src="https://cdn.activitysmith.com/features/create-widget-metric.png" alt="Create widget metric" width="680" />
|
|
532
|
+
</p>
|
|
533
|
+
|
|
534
|
+
Use the metric key to update its value.
|
|
535
|
+
|
|
536
|
+
```ts
|
|
537
|
+
await activitysmith.metrics.update("deploy.success_rate", 99.9);
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
String metric values work too.
|
|
541
|
+
|
|
542
|
+
```ts
|
|
543
|
+
await activitysmith.metrics.update("prod.status", "healthy");
|
|
544
|
+
```
|
|
545
|
+
|
|
511
546
|
## Error Handling
|
|
512
547
|
|
|
513
548
|
```ts
|
|
@@ -33,12 +33,12 @@ export interface UpdateLiveActivityRequest {
|
|
|
33
33
|
*/
|
|
34
34
|
export declare class LiveActivitiesApi extends runtime.BaseAPI {
|
|
35
35
|
/**
|
|
36
|
-
* Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress,
|
|
36
|
+
* Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
|
|
37
37
|
* End a Live Activity
|
|
38
38
|
*/
|
|
39
39
|
endLiveActivityRaw(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityEndResponse>>;
|
|
40
40
|
/**
|
|
41
|
-
* Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress,
|
|
41
|
+
* Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
|
|
42
42
|
* End a Live Activity
|
|
43
43
|
*/
|
|
44
44
|
endLiveActivity(requestParameters: EndLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityEndResponse>;
|
|
@@ -63,22 +63,22 @@ export declare class LiveActivitiesApi extends runtime.BaseAPI {
|
|
|
63
63
|
*/
|
|
64
64
|
reconcileLiveActivityStream(requestParameters: ReconcileLiveActivityStreamRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityStreamPutResponse>;
|
|
65
65
|
/**
|
|
66
|
-
* Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress,
|
|
66
|
+
* Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
|
|
67
67
|
* Start a Live Activity
|
|
68
68
|
*/
|
|
69
69
|
startLiveActivityRaw(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityStartResponse>>;
|
|
70
70
|
/**
|
|
71
|
-
* Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress,
|
|
71
|
+
* Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
|
|
72
72
|
* Start a Live Activity
|
|
73
73
|
*/
|
|
74
74
|
startLiveActivity(requestParameters: StartLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityStartResponse>;
|
|
75
75
|
/**
|
|
76
|
-
* Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress,
|
|
76
|
+
* Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
|
|
77
77
|
* Update a Live Activity
|
|
78
78
|
*/
|
|
79
79
|
updateLiveActivityRaw(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LiveActivityUpdateResponse>>;
|
|
80
80
|
/**
|
|
81
|
-
* Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress,
|
|
81
|
+
* Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
|
|
82
82
|
* Update a Live Activity
|
|
83
83
|
*/
|
|
84
84
|
updateLiveActivity(requestParameters: UpdateLiveActivityRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LiveActivityUpdateResponse>;
|
|
@@ -20,7 +20,7 @@ const runtime = require("../runtime");
|
|
|
20
20
|
*/
|
|
21
21
|
class LiveActivitiesApi extends runtime.BaseAPI {
|
|
22
22
|
/**
|
|
23
|
-
* Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress,
|
|
23
|
+
* Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
|
|
24
24
|
* End a Live Activity
|
|
25
25
|
*/
|
|
26
26
|
async endLiveActivityRaw(requestParameters, initOverrides) {
|
|
@@ -47,7 +47,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
|
|
|
47
47
|
return new runtime.JSONApiResponse(response);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress,
|
|
50
|
+
* Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start.
|
|
51
51
|
* End a Live Activity
|
|
52
52
|
*/
|
|
53
53
|
async endLiveActivity(requestParameters, initOverrides) {
|
|
@@ -128,7 +128,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
|
|
|
128
128
|
return await response.value();
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
|
-
* Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress,
|
|
131
|
+
* Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
|
|
132
132
|
* Start a Live Activity
|
|
133
133
|
*/
|
|
134
134
|
async startLiveActivityRaw(requestParameters, initOverrides) {
|
|
@@ -155,7 +155,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
|
|
|
155
155
|
return new runtime.JSONApiResponse(response);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
|
-
* Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress,
|
|
158
|
+
* Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes.
|
|
159
159
|
* Start a Live Activity
|
|
160
160
|
*/
|
|
161
161
|
async startLiveActivity(requestParameters, initOverrides) {
|
|
@@ -163,7 +163,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
|
|
|
163
163
|
return await response.value();
|
|
164
164
|
}
|
|
165
165
|
/**
|
|
166
|
-
* Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress,
|
|
166
|
+
* Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
|
|
167
167
|
* Update a Live Activity
|
|
168
168
|
*/
|
|
169
169
|
async updateLiveActivityRaw(requestParameters, initOverrides) {
|
|
@@ -190,7 +190,7 @@ class LiveActivitiesApi extends runtime.BaseAPI {
|
|
|
190
190
|
return new runtime.JSONApiResponse(response);
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
|
-
* Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress,
|
|
193
|
+
* Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes.
|
|
194
194
|
* Update a Live Activity
|
|
195
195
|
*/
|
|
196
196
|
async updateLiveActivity(requestParameters, initOverrides) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActivitySmith API
|
|
3
|
+
* Send push notifications and Live Activities to your own devices via a single API key.
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import * as runtime from '../runtime';
|
|
13
|
+
import type { MetricValueUpdateRequest, MetricValueUpdateResponse } from '../models/index';
|
|
14
|
+
export interface UpdateMetricValueRequest {
|
|
15
|
+
key: string;
|
|
16
|
+
metricValueUpdateRequest: MetricValueUpdateRequest;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export declare class MetricsApi extends runtime.BaseAPI {
|
|
22
|
+
/**
|
|
23
|
+
* Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters.
|
|
24
|
+
* Update a widget metric value
|
|
25
|
+
*/
|
|
26
|
+
updateMetricValueRaw(requestParameters: UpdateMetricValueRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MetricValueUpdateResponse>>;
|
|
27
|
+
/**
|
|
28
|
+
* Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters.
|
|
29
|
+
* Update a widget metric value
|
|
30
|
+
*/
|
|
31
|
+
updateMetricValue(requestParameters: UpdateMetricValueRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MetricValueUpdateResponse>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* ActivitySmith API
|
|
6
|
+
* Send push notifications and Live Activities to your own devices via a single API key.
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.MetricsApi = void 0;
|
|
17
|
+
const runtime = require("../runtime");
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
class MetricsApi extends runtime.BaseAPI {
|
|
22
|
+
/**
|
|
23
|
+
* Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters.
|
|
24
|
+
* Update a widget metric value
|
|
25
|
+
*/
|
|
26
|
+
async updateMetricValueRaw(requestParameters, initOverrides) {
|
|
27
|
+
if (requestParameters['key'] == null) {
|
|
28
|
+
throw new runtime.RequiredError('key', 'Required parameter "key" was null or undefined when calling updateMetricValue().');
|
|
29
|
+
}
|
|
30
|
+
if (requestParameters['metricValueUpdateRequest'] == null) {
|
|
31
|
+
throw new runtime.RequiredError('metricValueUpdateRequest', 'Required parameter "metricValueUpdateRequest" was null or undefined when calling updateMetricValue().');
|
|
32
|
+
}
|
|
33
|
+
const queryParameters = {};
|
|
34
|
+
const headerParameters = {};
|
|
35
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
36
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
37
|
+
const token = this.configuration.accessToken;
|
|
38
|
+
const tokenString = await token("apiKeyAuth", []);
|
|
39
|
+
if (tokenString) {
|
|
40
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const response = await this.request({
|
|
44
|
+
path: `/metrics/{key}/value`.replace(`{${"key"}}`, encodeURIComponent(String(requestParameters['key']))),
|
|
45
|
+
method: 'POST',
|
|
46
|
+
headers: headerParameters,
|
|
47
|
+
query: queryParameters,
|
|
48
|
+
body: requestParameters['metricValueUpdateRequest'],
|
|
49
|
+
}, initOverrides);
|
|
50
|
+
return new runtime.JSONApiResponse(response);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters.
|
|
54
|
+
* Update a widget metric value
|
|
55
|
+
*/
|
|
56
|
+
async updateMetricValue(requestParameters, initOverrides) {
|
|
57
|
+
const response = await this.updateMetricValueRaw(requestParameters, initOverrides);
|
|
58
|
+
return await response.value();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.MetricsApi = MetricsApi;
|
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
/* tslint:disable */
|
|
18
18
|
/* eslint-disable */
|
|
19
19
|
__exportStar(require("./LiveActivitiesApi"), exports);
|
|
20
|
+
__exportStar(require("./MetricsApi"), exports);
|
|
20
21
|
__exportStar(require("./PushNotificationsApi"), exports);
|
|
@@ -79,7 +79,7 @@ export interface ChannelTarget {
|
|
|
79
79
|
channels: Array<string>;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array.
|
|
82
|
+
* End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start.
|
|
83
83
|
* @export
|
|
84
84
|
* @interface ContentStateEnd
|
|
85
85
|
*/
|
|
@@ -171,9 +171,6 @@ export declare const ContentStateEndTypeEnum: {
|
|
|
171
171
|
readonly SegmentedProgress: "segmented_progress";
|
|
172
172
|
readonly Progress: "progress";
|
|
173
173
|
readonly Metrics: "metrics";
|
|
174
|
-
readonly Counter: "counter";
|
|
175
|
-
readonly Timer: "timer";
|
|
176
|
-
readonly Countdown: "countdown";
|
|
177
174
|
};
|
|
178
175
|
export type ContentStateEndTypeEnum = typeof ContentStateEndTypeEnum[keyof typeof ContentStateEndTypeEnum];
|
|
179
176
|
/**
|
|
@@ -222,7 +219,7 @@ export declare const ContentStateEndStepColorsEnum: {
|
|
|
222
219
|
};
|
|
223
220
|
export type ContentStateEndStepColorsEnum = typeof ContentStateEndStepColorsEnum[keyof typeof ContentStateEndStepColorsEnum];
|
|
224
221
|
/**
|
|
225
|
-
* Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array.
|
|
222
|
+
* Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls.
|
|
226
223
|
* @export
|
|
227
224
|
* @interface ContentStateStart
|
|
228
225
|
*/
|
|
@@ -308,9 +305,6 @@ export declare const ContentStateStartTypeEnum: {
|
|
|
308
305
|
readonly SegmentedProgress: "segmented_progress";
|
|
309
306
|
readonly Progress: "progress";
|
|
310
307
|
readonly Metrics: "metrics";
|
|
311
|
-
readonly Counter: "counter";
|
|
312
|
-
readonly Timer: "timer";
|
|
313
|
-
readonly Countdown: "countdown";
|
|
314
308
|
};
|
|
315
309
|
export type ContentStateStartTypeEnum = typeof ContentStateStartTypeEnum[keyof typeof ContentStateStartTypeEnum];
|
|
316
310
|
/**
|
|
@@ -359,7 +353,7 @@ export declare const ContentStateStartStepColorsEnum: {
|
|
|
359
353
|
};
|
|
360
354
|
export type ContentStateStartStepColorsEnum = typeof ContentStateStartStepColorsEnum[keyof typeof ContentStateStartStepColorsEnum];
|
|
361
355
|
/**
|
|
362
|
-
* Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array.
|
|
356
|
+
* Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates.
|
|
363
357
|
* @export
|
|
364
358
|
* @interface ContentStateUpdate
|
|
365
359
|
*/
|
|
@@ -445,9 +439,6 @@ export declare const ContentStateUpdateTypeEnum: {
|
|
|
445
439
|
readonly SegmentedProgress: "segmented_progress";
|
|
446
440
|
readonly Progress: "progress";
|
|
447
441
|
readonly Metrics: "metrics";
|
|
448
|
-
readonly Counter: "counter";
|
|
449
|
-
readonly Timer: "timer";
|
|
450
|
-
readonly Countdown: "countdown";
|
|
451
442
|
};
|
|
452
443
|
export type ContentStateUpdateTypeEnum = typeof ContentStateUpdateTypeEnum[keyof typeof ContentStateUpdateTypeEnum];
|
|
453
444
|
/**
|
|
@@ -1009,6 +1000,87 @@ export declare const LiveActivityWebhookMethod: {
|
|
|
1009
1000
|
readonly Post: "POST";
|
|
1010
1001
|
};
|
|
1011
1002
|
export type LiveActivityWebhookMethod = typeof LiveActivityWebhookMethod[keyof typeof LiveActivityWebhookMethod];
|
|
1003
|
+
/**
|
|
1004
|
+
*
|
|
1005
|
+
* @export
|
|
1006
|
+
* @interface MetricError
|
|
1007
|
+
*/
|
|
1008
|
+
export interface MetricError {
|
|
1009
|
+
[key: string]: any | any;
|
|
1010
|
+
/**
|
|
1011
|
+
*
|
|
1012
|
+
* @type {string}
|
|
1013
|
+
* @memberof MetricError
|
|
1014
|
+
*/
|
|
1015
|
+
error: string;
|
|
1016
|
+
/**
|
|
1017
|
+
*
|
|
1018
|
+
* @type {string}
|
|
1019
|
+
* @memberof MetricError
|
|
1020
|
+
*/
|
|
1021
|
+
message?: string;
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
*
|
|
1025
|
+
* @export
|
|
1026
|
+
*/
|
|
1027
|
+
export declare const MetricFormat: {
|
|
1028
|
+
readonly Number: "number";
|
|
1029
|
+
readonly Currency: "currency";
|
|
1030
|
+
readonly Percent: "percent";
|
|
1031
|
+
readonly Unit: "unit";
|
|
1032
|
+
readonly String: "string";
|
|
1033
|
+
};
|
|
1034
|
+
export type MetricFormat = typeof MetricFormat[keyof typeof MetricFormat];
|
|
1035
|
+
/**
|
|
1036
|
+
*
|
|
1037
|
+
* @export
|
|
1038
|
+
*/
|
|
1039
|
+
export declare const MetricUnitSpacing: {
|
|
1040
|
+
readonly None: "none";
|
|
1041
|
+
readonly Space: "space";
|
|
1042
|
+
};
|
|
1043
|
+
export type MetricUnitSpacing = typeof MetricUnitSpacing[keyof typeof MetricUnitSpacing];
|
|
1044
|
+
/**
|
|
1045
|
+
* Latest metric value to display in widgets.
|
|
1046
|
+
* @export
|
|
1047
|
+
* @interface MetricValueUpdateRequest
|
|
1048
|
+
*/
|
|
1049
|
+
export interface MetricValueUpdateRequest {
|
|
1050
|
+
[key: string]: any | any;
|
|
1051
|
+
/**
|
|
1052
|
+
*
|
|
1053
|
+
* @type {MetricValueUpdateRequestValue}
|
|
1054
|
+
* @memberof MetricValueUpdateRequest
|
|
1055
|
+
*/
|
|
1056
|
+
value: MetricValueUpdateRequestValue;
|
|
1057
|
+
/**
|
|
1058
|
+
* Optional ISO timestamp for when the metric value was measured. Defaults to the server receive time.
|
|
1059
|
+
* @type {string}
|
|
1060
|
+
* @memberof MetricValueUpdateRequest
|
|
1061
|
+
*/
|
|
1062
|
+
timestamp?: string;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* @type MetricValueUpdateRequestValue
|
|
1066
|
+
*
|
|
1067
|
+
* @export
|
|
1068
|
+
*/
|
|
1069
|
+
export type MetricValueUpdateRequestValue = number | string;
|
|
1070
|
+
/**
|
|
1071
|
+
*
|
|
1072
|
+
* @export
|
|
1073
|
+
* @interface MetricValueUpdateResponse
|
|
1074
|
+
*/
|
|
1075
|
+
export interface MetricValueUpdateResponse {
|
|
1076
|
+
[key: string]: any | any;
|
|
1077
|
+
/**
|
|
1078
|
+
*
|
|
1079
|
+
* @type {WidgetMetric}
|
|
1080
|
+
* @memberof MetricValueUpdateResponse
|
|
1081
|
+
*/
|
|
1082
|
+
metric: WidgetMetric;
|
|
1083
|
+
}
|
|
1012
1084
|
/**
|
|
1013
1085
|
*
|
|
1014
1086
|
* @export
|
|
@@ -1248,7 +1320,7 @@ export interface RateLimitError {
|
|
|
1248
1320
|
*/
|
|
1249
1321
|
export type SendPushNotification429Response = LiveActivityLimitError | RateLimitError;
|
|
1250
1322
|
/**
|
|
1251
|
-
* Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress,
|
|
1323
|
+
* Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, and metrics types.
|
|
1252
1324
|
* @export
|
|
1253
1325
|
* @interface StreamContentState
|
|
1254
1326
|
*/
|
|
@@ -1267,13 +1339,13 @@ export interface StreamContentState {
|
|
|
1267
1339
|
*/
|
|
1268
1340
|
subtitle?: string;
|
|
1269
1341
|
/**
|
|
1270
|
-
* Use for segmented_progress
|
|
1342
|
+
* Use for segmented_progress.
|
|
1271
1343
|
* @type {number}
|
|
1272
1344
|
* @memberof StreamContentState
|
|
1273
1345
|
*/
|
|
1274
1346
|
number_of_steps?: number;
|
|
1275
1347
|
/**
|
|
1276
|
-
* Use for segmented_progress
|
|
1348
|
+
* Use for segmented_progress.
|
|
1277
1349
|
* @type {number}
|
|
1278
1350
|
* @memberof StreamContentState
|
|
1279
1351
|
*/
|
|
@@ -1346,9 +1418,6 @@ export declare const StreamContentStateTypeEnum: {
|
|
|
1346
1418
|
readonly SegmentedProgress: "segmented_progress";
|
|
1347
1419
|
readonly Progress: "progress";
|
|
1348
1420
|
readonly Metrics: "metrics";
|
|
1349
|
-
readonly Counter: "counter";
|
|
1350
|
-
readonly Timer: "timer";
|
|
1351
|
-
readonly Countdown: "countdown";
|
|
1352
1421
|
};
|
|
1353
1422
|
export type StreamContentStateTypeEnum = typeof StreamContentStateTypeEnum[keyof typeof StreamContentStateTypeEnum];
|
|
1354
1423
|
/**
|
|
@@ -1396,3 +1465,84 @@ export declare const StreamContentStateStepColorsEnum: {
|
|
|
1396
1465
|
readonly Yellow: "yellow";
|
|
1397
1466
|
};
|
|
1398
1467
|
export type StreamContentStateStepColorsEnum = typeof StreamContentStateStepColorsEnum[keyof typeof StreamContentStateStepColorsEnum];
|
|
1468
|
+
/**
|
|
1469
|
+
* A metric configured for ActivitySmith widgets.
|
|
1470
|
+
* @export
|
|
1471
|
+
* @interface WidgetMetric
|
|
1472
|
+
*/
|
|
1473
|
+
export interface WidgetMetric {
|
|
1474
|
+
[key: string]: any | any;
|
|
1475
|
+
/**
|
|
1476
|
+
*
|
|
1477
|
+
* @type {string}
|
|
1478
|
+
* @memberof WidgetMetric
|
|
1479
|
+
*/
|
|
1480
|
+
public_id: string;
|
|
1481
|
+
/**
|
|
1482
|
+
*
|
|
1483
|
+
* @type {string}
|
|
1484
|
+
* @memberof WidgetMetric
|
|
1485
|
+
*/
|
|
1486
|
+
key: string;
|
|
1487
|
+
/**
|
|
1488
|
+
*
|
|
1489
|
+
* @type {string}
|
|
1490
|
+
* @memberof WidgetMetric
|
|
1491
|
+
*/
|
|
1492
|
+
label: string;
|
|
1493
|
+
/**
|
|
1494
|
+
* Present when format is currency.
|
|
1495
|
+
* @type {string}
|
|
1496
|
+
* @memberof WidgetMetric
|
|
1497
|
+
*/
|
|
1498
|
+
currency_code: string | null;
|
|
1499
|
+
/**
|
|
1500
|
+
* Present when format is unit.
|
|
1501
|
+
* @type {string}
|
|
1502
|
+
* @memberof WidgetMetric
|
|
1503
|
+
*/
|
|
1504
|
+
unit: string | null;
|
|
1505
|
+
/**
|
|
1506
|
+
*
|
|
1507
|
+
* @type {MetricUnitSpacing}
|
|
1508
|
+
* @memberof WidgetMetric
|
|
1509
|
+
*/
|
|
1510
|
+
unit_spacing: MetricUnitSpacing;
|
|
1511
|
+
/**
|
|
1512
|
+
*
|
|
1513
|
+
* @type {MetricFormat}
|
|
1514
|
+
* @memberof WidgetMetric
|
|
1515
|
+
*/
|
|
1516
|
+
format: MetricFormat;
|
|
1517
|
+
/**
|
|
1518
|
+
*
|
|
1519
|
+
* @type {WidgetMetricLatestValue}
|
|
1520
|
+
* @memberof WidgetMetric
|
|
1521
|
+
*/
|
|
1522
|
+
latest_value: WidgetMetricLatestValue | null;
|
|
1523
|
+
/**
|
|
1524
|
+
*
|
|
1525
|
+
* @type {string}
|
|
1526
|
+
* @memberof WidgetMetric
|
|
1527
|
+
*/
|
|
1528
|
+
latest_value_at: string | null;
|
|
1529
|
+
/**
|
|
1530
|
+
*
|
|
1531
|
+
* @type {string}
|
|
1532
|
+
* @memberof WidgetMetric
|
|
1533
|
+
*/
|
|
1534
|
+
created_at: string;
|
|
1535
|
+
/**
|
|
1536
|
+
*
|
|
1537
|
+
* @type {string}
|
|
1538
|
+
* @memberof WidgetMetric
|
|
1539
|
+
*/
|
|
1540
|
+
updated_at: string;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Latest metric value. Numeric formats return a number. String metrics return text.
|
|
1544
|
+
* @export
|
|
1545
|
+
* @interface WidgetMetricLatestValue
|
|
1546
|
+
*/
|
|
1547
|
+
export interface WidgetMetricLatestValue {
|
|
1548
|
+
}
|
|
@@ -1,16 +1,13 @@
|
|
|
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.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 = void 0;
|
|
3
|
+
exports.StreamContentStateStepColorsEnum = exports.StreamContentStateStepColorEnum = exports.StreamContentStateColorEnum = exports.StreamContentStateTypeEnum = exports.PushNotificationWebhookMethod = exports.PushNotificationActionType = exports.MetricUnitSpacing = exports.MetricFormat = exports.LiveActivityWebhookMethod = exports.LiveActivityStreamPutResponseOperationEnum = exports.LiveActivityStreamDeleteResponseOperationEnum = 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 = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @export
|
|
6
6
|
*/
|
|
7
7
|
exports.ContentStateEndTypeEnum = {
|
|
8
8
|
SegmentedProgress: 'segmented_progress',
|
|
9
9
|
Progress: 'progress',
|
|
10
|
-
Metrics: 'metrics'
|
|
11
|
-
Counter: 'counter',
|
|
12
|
-
Timer: 'timer',
|
|
13
|
-
Countdown: 'countdown'
|
|
10
|
+
Metrics: 'metrics'
|
|
14
11
|
};
|
|
15
12
|
/**
|
|
16
13
|
* @export
|
|
@@ -60,10 +57,7 @@ exports.ContentStateEndStepColorsEnum = {
|
|
|
60
57
|
exports.ContentStateStartTypeEnum = {
|
|
61
58
|
SegmentedProgress: 'segmented_progress',
|
|
62
59
|
Progress: 'progress',
|
|
63
|
-
Metrics: 'metrics'
|
|
64
|
-
Counter: 'counter',
|
|
65
|
-
Timer: 'timer',
|
|
66
|
-
Countdown: 'countdown'
|
|
60
|
+
Metrics: 'metrics'
|
|
67
61
|
};
|
|
68
62
|
/**
|
|
69
63
|
* @export
|
|
@@ -113,10 +107,7 @@ exports.ContentStateStartStepColorsEnum = {
|
|
|
113
107
|
exports.ContentStateUpdateTypeEnum = {
|
|
114
108
|
SegmentedProgress: 'segmented_progress',
|
|
115
109
|
Progress: 'progress',
|
|
116
|
-
Metrics: 'metrics'
|
|
117
|
-
Counter: 'counter',
|
|
118
|
-
Timer: 'timer',
|
|
119
|
-
Countdown: 'countdown'
|
|
110
|
+
Metrics: 'metrics'
|
|
120
111
|
};
|
|
121
112
|
/**
|
|
122
113
|
* @export
|
|
@@ -192,6 +183,25 @@ exports.LiveActivityWebhookMethod = {
|
|
|
192
183
|
Get: 'GET',
|
|
193
184
|
Post: 'POST'
|
|
194
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
*
|
|
188
|
+
* @export
|
|
189
|
+
*/
|
|
190
|
+
exports.MetricFormat = {
|
|
191
|
+
Number: 'number',
|
|
192
|
+
Currency: 'currency',
|
|
193
|
+
Percent: 'percent',
|
|
194
|
+
Unit: 'unit',
|
|
195
|
+
String: 'string'
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
*
|
|
199
|
+
* @export
|
|
200
|
+
*/
|
|
201
|
+
exports.MetricUnitSpacing = {
|
|
202
|
+
None: 'none',
|
|
203
|
+
Space: 'space'
|
|
204
|
+
};
|
|
195
205
|
/**
|
|
196
206
|
*
|
|
197
207
|
* @export
|
|
@@ -214,10 +224,7 @@ exports.PushNotificationWebhookMethod = {
|
|
|
214
224
|
exports.StreamContentStateTypeEnum = {
|
|
215
225
|
SegmentedProgress: 'segmented_progress',
|
|
216
226
|
Progress: 'progress',
|
|
217
|
-
Metrics: 'metrics'
|
|
218
|
-
Counter: 'counter',
|
|
219
|
-
Timer: 'timer',
|
|
220
|
-
Countdown: 'countdown'
|
|
227
|
+
Metrics: 'metrics'
|
|
221
228
|
};
|
|
222
229
|
/**
|
|
223
230
|
* @export
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PushNotificationsApi, LiveActivitiesApi } from "../generated/index";
|
|
1
|
+
import { PushNotificationsApi, LiveActivitiesApi, MetricsApi } from "../generated/index";
|
|
2
2
|
export interface ActivitySmithOptions {
|
|
3
3
|
apiKey: string;
|
|
4
4
|
}
|
|
@@ -12,6 +12,12 @@ type EndRequestBody = Parameters<LiveActivitiesApi["endLiveActivity"]>[0]["liveA
|
|
|
12
12
|
type StreamRequestBody = Parameters<LiveActivitiesApi["reconcileLiveActivityStream"]>[0]["liveActivityStreamRequest"];
|
|
13
13
|
type StreamDeleteRequestBody = Parameters<LiveActivitiesApi["endLiveActivityStream"]>[0]["liveActivityStreamDeleteRequest"];
|
|
14
14
|
type LiveInitOverrides = Parameters<LiveActivitiesApi["startLiveActivity"]>[1];
|
|
15
|
+
type MetricUpdateParameters = Parameters<MetricsApi["updateMetricValue"]>[0];
|
|
16
|
+
type MetricRawParameters = Parameters<MetricsApi["updateMetricValueRaw"]>[0];
|
|
17
|
+
type MetricUpdateRequestBody = MetricUpdateParameters["metricValueUpdateRequest"];
|
|
18
|
+
type MetricValue = MetricUpdateRequestBody["value"];
|
|
19
|
+
type MetricUpdateOptions = Omit<MetricUpdateRequestBody, "value">;
|
|
20
|
+
type MetricInitOverrides = Parameters<MetricsApi["updateMetricValue"]>[1];
|
|
15
21
|
type PushSendRequest = PushRequestBody & {
|
|
16
22
|
channels?: string[];
|
|
17
23
|
};
|
|
@@ -47,9 +53,17 @@ export declare class LiveActivitiesResource {
|
|
|
47
53
|
reconcileLiveActivityStreamRaw(...args: Parameters<LiveActivitiesApi["reconcileLiveActivityStreamRaw"]>): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").LiveActivityStreamPutResponse>>;
|
|
48
54
|
endLiveActivityStreamRaw(...args: Parameters<LiveActivitiesApi["endLiveActivityStreamRaw"]>): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").LiveActivityStreamDeleteResponse>>;
|
|
49
55
|
}
|
|
56
|
+
export declare class MetricsResource {
|
|
57
|
+
private readonly api;
|
|
58
|
+
constructor(api: MetricsApi);
|
|
59
|
+
update(key: string, valueOrRequest: MetricValue | MetricUpdateRequestBody, options?: MetricUpdateOptions, initOverrides?: MetricInitOverrides): Promise<import("../generated/models").MetricValueUpdateResponse>;
|
|
60
|
+
updateMetricValue(requestParameters: MetricUpdateParameters, initOverrides?: MetricInitOverrides): Promise<import("../generated/models").MetricValueUpdateResponse>;
|
|
61
|
+
updateMetricValueRaw(requestParameters: MetricRawParameters, initOverrides?: MetricInitOverrides): Promise<import("../generated/runtime").ApiResponse<import("../generated/models").MetricValueUpdateResponse>>;
|
|
62
|
+
}
|
|
50
63
|
export declare class ActivitySmith {
|
|
51
64
|
readonly notifications: NotificationsResource;
|
|
52
65
|
readonly liveActivities: LiveActivitiesResource;
|
|
66
|
+
readonly metrics: MetricsResource;
|
|
53
67
|
constructor(opts: ActivitySmithOptions);
|
|
54
68
|
}
|
|
55
69
|
export {};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActivitySmith = exports.LiveActivitiesResource = exports.NotificationsResource = void 0;
|
|
3
|
+
exports.ActivitySmith = exports.MetricsResource = exports.LiveActivitiesResource = exports.NotificationsResource = void 0;
|
|
4
4
|
const index_1 = require("../generated/index");
|
|
5
|
+
const SDK_VERSION = "1.1.0";
|
|
6
|
+
const SDK_HEADER_NAME = "X-ActivitySmith-SDK";
|
|
7
|
+
const SDK_HEADER_VALUE = `node-v${SDK_VERSION}`;
|
|
5
8
|
function withTargetChannels(request) {
|
|
6
9
|
const channels = request.channels;
|
|
7
10
|
if (!channels || channels.length === 0 || request.target) {
|
|
@@ -31,6 +34,20 @@ function assertValidPushRequest(request) {
|
|
|
31
34
|
throw new Error("ActivitySmith: media cannot be combined with actions");
|
|
32
35
|
}
|
|
33
36
|
}
|
|
37
|
+
function toMetricUpdateRequest(valueOrRequest, options) {
|
|
38
|
+
if (typeof valueOrRequest === "object" &&
|
|
39
|
+
valueOrRequest !== null &&
|
|
40
|
+
"value" in valueOrRequest) {
|
|
41
|
+
return {
|
|
42
|
+
...valueOrRequest,
|
|
43
|
+
...options,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
value: valueOrRequest,
|
|
48
|
+
...options,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
34
51
|
class NotificationsResource {
|
|
35
52
|
constructor(api) {
|
|
36
53
|
this.api = api;
|
|
@@ -109,6 +126,25 @@ class LiveActivitiesResource {
|
|
|
109
126
|
}
|
|
110
127
|
}
|
|
111
128
|
exports.LiveActivitiesResource = LiveActivitiesResource;
|
|
129
|
+
class MetricsResource {
|
|
130
|
+
constructor(api) {
|
|
131
|
+
this.api = api;
|
|
132
|
+
}
|
|
133
|
+
update(key, valueOrRequest, options, initOverrides) {
|
|
134
|
+
return this.api.updateMetricValue({
|
|
135
|
+
key,
|
|
136
|
+
metricValueUpdateRequest: toMetricUpdateRequest(valueOrRequest, options),
|
|
137
|
+
}, initOverrides);
|
|
138
|
+
}
|
|
139
|
+
// Backward-compatible generated-style aliases.
|
|
140
|
+
updateMetricValue(requestParameters, initOverrides) {
|
|
141
|
+
return this.api.updateMetricValue(requestParameters, initOverrides);
|
|
142
|
+
}
|
|
143
|
+
updateMetricValueRaw(requestParameters, initOverrides) {
|
|
144
|
+
return this.api.updateMetricValueRaw(requestParameters, initOverrides);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.MetricsResource = MetricsResource;
|
|
112
148
|
class ActivitySmith {
|
|
113
149
|
constructor(opts) {
|
|
114
150
|
if (!opts?.apiKey) {
|
|
@@ -117,9 +153,13 @@ class ActivitySmith {
|
|
|
117
153
|
// basePath omitted on purpose — it will use the default from the generated runtime
|
|
118
154
|
const config = new index_1.Configuration({
|
|
119
155
|
accessToken: opts.apiKey,
|
|
156
|
+
headers: {
|
|
157
|
+
[SDK_HEADER_NAME]: SDK_HEADER_VALUE,
|
|
158
|
+
},
|
|
120
159
|
});
|
|
121
160
|
this.notifications = new NotificationsResource(new index_1.PushNotificationsApi(config));
|
|
122
161
|
this.liveActivities = new LiveActivitiesResource(new index_1.LiveActivitiesApi(config));
|
|
162
|
+
this.metrics = new MetricsResource(new index_1.MetricsApi(config));
|
|
123
163
|
}
|
|
124
164
|
}
|
|
125
165
|
exports.ActivitySmith = ActivitySmith;
|