-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: keephq notification provider (#4722)
- Loading branch information
Showing
6 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const NotificationProvider = require("./notification-provider"); | ||
const axios = require("axios"); | ||
|
||
class Keep extends NotificationProvider { | ||
name = "Keep"; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { | ||
const okMsg = "Sent Successfully."; | ||
|
||
try { | ||
let data = { | ||
heartbeat: heartbeatJSON, | ||
monitor: monitorJSON, | ||
msg, | ||
}; | ||
let config = { | ||
headers: { | ||
"x-api-key": notification.webhookAPIKey, | ||
"content-type": "application/json", | ||
}, | ||
}; | ||
|
||
let url = notification.webhookURL; | ||
|
||
if (url.endsWith("/")) { | ||
url = url.slice(0, -1); | ||
} | ||
|
||
let webhookURL = url + "/alerts/event/uptimekuma"; | ||
|
||
await axios.post(webhookURL, data, config); | ||
return okMsg; | ||
} catch (error) { | ||
this.throwGeneralAxiosError(error); | ||
} | ||
} | ||
} | ||
|
||
module.exports = Keep; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<template> | ||
<div class="mb-3"> | ||
<label for="webhook-url" class="form-label">{{ $t("Host URL") }}</label> | ||
<input | ||
id="webhook-url" | ||
v-model="$parent.notification.webhookURL" | ||
type="url" | ||
pattern="https?://.+" | ||
class="form-control" | ||
required | ||
/> | ||
<div class="form-text"> | ||
<i18n-t tag="p" keypath="Read more:"> | ||
<a href="https://docs.keephq.dev/providers/documentation/uptimekuma-provider" target="_blank">https://docs.keephq.dev/providers/documentation/uptimekuma-provider</a> | ||
</i18n-t> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<label for="webhook-apikey" class="form-label">{{ | ||
$t("API Key") | ||
}}</label> | ||
<HiddenInput | ||
id="webhook-apikey" | ||
v-model="$parent.notification.webhookAPIKey" | ||
:required="true" | ||
></HiddenInput> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import HiddenInput from "../HiddenInput.vue"; | ||
export default { | ||
components: { | ||
HiddenInput, | ||
}, | ||
mounted() { | ||
this.$parent.notification.webhookURL ||= ""; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters