Files
Cassandra 174c63d479 feat: structured logging (JSON) (#5179)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
2026-02-26 17:02:58 +00:00

45 lines
1.3 KiB
JavaScript

const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { getMonitorRelativeURL } = require("../../src/util");
const { Settings } = require("../settings");
class Stackfield extends NotificationProvider {
name = "stackfield";
/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
try {
// Stackfield message formatting: https://www.stackfield.com/help/formatting-messages-2001
let textMsg = "+Uptime Kuma Alert+";
if (monitorJSON && monitorJSON.name) {
textMsg += `\n*${monitorJSON.name}*`;
}
textMsg += `\n${msg}`;
const baseURL = await Settings.get("primaryBaseURL");
if (baseURL) {
textMsg += `\n${baseURL + getMonitorRelativeURL(monitorJSON.id)}`;
}
const data = {
Title: textMsg,
};
let config = this.getAxiosConfigWithProxy({});
await axios.post(notification.stackfieldwebhookURL, data, config);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = Stackfield;