-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysis.js
37 lines (29 loc) · 1.18 KB
/
analysis.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { Analysis, Services, Utils } = require("@tago-io/sdk");
/**
* The main function used by Tago to run the script.
* It sends a notification to the account and another one linked to a dashboard.
* Optional: You can set a dashboard_id using an environment variable
* this will show a button on the notification to send the user directly to the dashboard
*/
async function startAnalysis(context) {
// reads the values from the environment variables and saves it in the variable env_vars
const env_var = Utils.envToJson(context.environment);
const notification = new Services({ token: context.token }).Notification;
// In this variable, you type the title of the notification
const title = 'Your title';
// In this variable, you type the message that you will send on the notification
const message = 'Your message';
try {
const service_response = await notification.send({
message,
title,
ref_id: env_var.dashboard_id || undefined,
});
context.log(service_response);
} catch (error) {
context.log(error);
}
}
Analysis.use(startAnalysis);
// To run analysis on your machine (external)
// Analysis.use(myAnalysis, { token: "YOUR-TOKEN" });