-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat: keephq notification provider #4722
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8cc5a54
feat: keephq notification provider
ezhil56x 8b643ce
feat: keephq notification provider
ezhil56x 4840b25
feat: keephq notification provider
ezhil56x 127b800
feat: keephq notification provider
ezhil56x ec61acd
feat: keephq notification provider
ezhil56x 9a21a38
feat: keephq notification provider
ezhil56x 8e3c5ab
feat: keephq notification provider
ezhil56x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,47 @@ | ||
const NotificationProvider = require("./notification-provider"); | ||
const axios = require("axios"); | ||
const FormData = require("form-data"); | ||
|
||
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, | ||
}, | ||
}; | ||
|
||
const formData = new FormData(); | ||
formData.append("data", JSON.stringify(data)); | ||
config.headers = formData.getHeaders(); | ||
data = formData; | ||
|
||
let url = notification.webhookURL; | ||
|
||
if (url.endsWith("/")) { | ||
url = url.slice(0, -1); | ||
} | ||
|
||
let webhookURL = url + "/alert/events/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,52 @@ | ||
<template> | ||
<div class="mb-3"> | ||
<label for="webhook-url" class="form-label">{{ $t("Host URL") }}</label> | ||
CommanderStorm marked this conversation as resolved.
Show resolved
Hide resolved
CommanderStorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<input | ||
id="webhook-url" | ||
v-model="$parent.notification.webhookURL" | ||
type="url" | ||
pattern="https?://.+" | ||
class="form-control" | ||
required | ||
/> | ||
</div> | ||
|
||
<div class="mb-3"> | ||
<label for="webhook-apikey" class="form-label">{{ $t("API Key") }}</label> | ||
<input | ||
CommanderStorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
id="webhook-apikey" | ||
v-model="$parent.notification.webhookAPIKey" | ||
type="text" | ||
class="form-control" | ||
required | ||
/> | ||
</div> | ||
CommanderStorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</template> | ||
|
||
<script> | ||
export default { | ||
computed: { | ||
headersPlaceholder() { | ||
return this.$t("Example:", [ | ||
`{ | ||
"Authorization": "Authorization Token" | ||
}`, | ||
]); | ||
}, | ||
customBodyPlaceholder() { | ||
return this.$t("Example:", [ | ||
`{ | ||
"Title": "Uptime Kuma Alert{% if monitorJSON %} - {{ monitorJSON['name'] }}{% endif %}", | ||
"Body": "{{ msg }}" | ||
}` | ||
]); | ||
} | ||
CommanderStorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
textarea { | ||
CommanderStorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
min-height: 200px; | ||
} | ||
</style> |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(in general, not only this PR)
I think we can remove this dependency in v2.0, as we have upgraded to the minimum supported node version to 18:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this as it is no longer required