Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Heii On-Call Notification Provider #4485

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions server/notification-providers/heii-oncall.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,38 @@ const { setting } = require("../util-server");

const NotificationProvider = require("./notification-provider");
const axios = require("axios");

const heiiOnCallBaseUrl = "https://heiioncall.com";

class HeiiOnCall extends NotificationProvider {
name = "HeiiOnCall";

/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
// Payload to Heii On-Call is the entire heartbat JSON
const payload = heartbeatJSON ? heartbeatJSON : {};
const payload = heartbeatJSON || {};

// If we can, add url back to monitor to payload
const baseURL = await setting("primaryBaseURL");
if (baseURL && monitorJSON) {
payload["url"] = baseURL + getMonitorRelativeURL(monitorJSON.id);
}

if (!heartbeatJSON) {
// No heartbeatJSON. Could be test button, but not necessarily. Just pull msg into payload.
payload["msg"] = msg;
return this.postNotification(notification, "alert", payload);
}
try {
if (!heartbeatJSON) {
// Testing or general notification like certificate expiry
payload["msg"] = msg;
return this.postNotification(notification, "alert", payload);
}

if (heartbeatJSON.status === DOWN) {
// Monitor is DOWN, alert on Heii On-Call
return this.postNotification(notification, "alert", payload);
}
if (heartbeatJSON.status === DOWN) {
return this.postNotification(notification, "alert", payload);
}

if (heartbeatJSON.status === UP) {
// Monitor is UP, resolve on Heii On-Call
return this.postNotification(notification, "resolve", payload);
if (heartbeatJSON.status === UP) {
return this.postNotification(notification, "resolve", payload);
}
} catch (error) {
this.throwGeneralAxiosError(error);
}

}

/**
Expand All @@ -56,17 +54,13 @@ class HeiiOnCall extends NotificationProvider {
};

// Post to Heii On-Call Trigger https://heiioncall.com/docs#manual-triggers
try {
await axios.post(
`${heiiOnCallBaseUrl}/triggers/${notification.heiiOnCallTriggerId}/${action}`,
payload,
config
);
} catch (error) {
this.throwGeneralAxiosError(error);
}
await axios.post(
`https://heiioncall.com/triggers/${notification.heiiOnCallTriggerId}/${action}`,
payload,
config
);

return "Heii On-Call post sent successfully.";
return "Sent Successfully";
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/components/notifications/HeiiOnCall.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@
></HiddenInput>
</div>
<div class="mb-3">
<label for="heiioncall-trigger-id" class="form-label">{{ $t("Trigger ID") }}<span
<label for="heiioncall-trigger-id" class="form-label">Trigger ID<span
style="color: red;"
><sup>*</sup></span></label>
<HiddenInput
id="heiioncall-trigger-id" v-model="$parent.notification.heiiOnCallTriggerId" required="true"
autocomplete="false"
></HiddenInput>
</div>
<div class="form-text">
<i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" style="margin-top: 8px;">
<a href="https://heiioncall.com/docs" target="_blank">Heii On-Call Documentation</a>
</i18n-t>
</div>
<i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" class="form-text mt-3">
<a href="https://heiioncall.com/docs" target="_blank">{{ $t("documentationOf", ["Heii On-Call"]) }}</a>
hevans66 marked this conversation as resolved.
Show resolved Hide resolved
</i18n-t>
</template>

<script>
Expand Down
4 changes: 2 additions & 2 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,6 @@
"GrafanaOncallUrl": "Grafana Oncall URL",
"Browser Screenshot": "Browser Screenshot",
"What is a Remote Browser?": "What is a Remote Browser?",
"Trigger ID": "Trigger ID",
"wayToGetHeiiOnCallDetails": "To get a Heii On-Call Tigger ID and Api Token visit: {0}"
"wayToGetHeiiOnCallDetails": "How to get the Tigger ID and API Keys is explained in the {0}",
hevans66 marked this conversation as resolved.
Show resolved Hide resolved
"documentationOf": "{0} Documentation"
}
Loading