Skip to content

Commit

Permalink
chore: readme collectResponseTimes example
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Janis committed Nov 22, 2020
1 parent c5eb49c commit 3ed1540
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
SECRET_TELEGRAM_CHAT_ID
environment: production
env:
NODE_ENV: production
CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
SECRET_SLACK_WEBHOOK_URL: ${{secrets.SECRET_SLACK_WEBHOOK_URL}}
SECRET_TELEGRAM_API_TOKEN: ${{secrets.SECRET_TELEGRAM_API_TOKEN}}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ You can either deploy with **Cloudflare Deploy Button** using GitHub Actions or
url: 'https://status-page.eidam.dev' # used for Slack messages
logo: logo-192x192.png # image in ./public/ folder
daysInHistogram: 90 # number of days you want to display in histogram
collectResponseTimes: false # experimental feature, enable only for <5 monitors or on paid plans

# configurable texts across the status page
allmonitorsOperational: 'All Systems Operational'
Expand Down
3 changes: 2 additions & 1 deletion src/components/monitorHistogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export default function MonitorHistogram({ monitorId, kvMonitor }) {
<span className="font-semibold text-sm">
{dayInHistogramLabel}
</span>
{kvMonitor && kvMonitor.checks.hasOwnProperty(dayInHistogram) &&
{kvMonitor &&
kvMonitor.checks.hasOwnProperty(dayInHistogram) &&
Object.keys(kvMonitor.checks[dayInHistogram].res).map((key) => {
return (
<>
Expand Down
8 changes: 5 additions & 3 deletions src/functions/cronTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ export async function processCronTrigger(event) {

// Send Telegram message on monitor change
if (
monitorStatusChanged
&& typeof SECRET_TELEGRAM_API_TOKEN !== 'undefined' && SECRET_TELEGRAM_API_TOKEN !== 'default-gh-action-secret'
&& typeof SECRET_TELEGRAM_CHAT_ID !== 'undefined' && SECRET_TELEGRAM_CHAT_ID !== 'default-gh-action-secret'
monitorStatusChanged &&
typeof SECRET_TELEGRAM_API_TOKEN !== 'undefined' &&
SECRET_TELEGRAM_API_TOKEN !== 'default-gh-action-secret' &&
typeof SECRET_TELEGRAM_CHAT_ID !== 'undefined' &&
SECRET_TELEGRAM_CHAT_ID !== 'default-gh-action-secret'
) {
event.waitUntil(notifyTelegram(monitor, monitorOperational))
}
Expand Down
15 changes: 11 additions & 4 deletions src/functions/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function setKVMonitors(data) {
return setKV(kvDataKey, JSON.stringify(data))
}

const getOperationalLabel = operational => {
const getOperationalLabel = (operational) => {
return operational
? config.settings.monitorLabelOperational
: config.settings.monitorLabelNotOperational
Expand All @@ -33,7 +33,9 @@ export async function notifySlack(monitor, operational) {
type: 'section',
text: {
type: 'mrkdwn',
text: `Monitor *${monitor.name}* changed status to *${getOperationalLabel(operational)}*`,
text: `Monitor *${
monitor.name
}* changed status to *${getOperationalLabel(operational)}*`,
},
},
{
Expand Down Expand Up @@ -61,8 +63,13 @@ export async function notifySlack(monitor, operational) {
}

export async function notifyTelegram(monitor, operational) {
const text = `Monitor *${monitor.name.replace('-', '\\-')}* changed status to *${getOperationalLabel(operational)}*
${operational ? '✅' : '❌'} \`${monitor.method ? monitor.method : "GET"} ${monitor.url}\` \\- 👀 [Status Page](${config.settings.url})`
const text = `Monitor *${monitor.name.replace(
'-',
'\\-',
)}* changed status to *${getOperationalLabel(operational)}*
${operational ? '✅' : '❌'} \`${monitor.method ? monitor.method : 'GET'} ${
monitor.url
}\` \\- 👀 [Status Page](${config.settings.url})`

const payload = new FormData()
payload.append('chat_id', SECRET_TELEGRAM_CHAT_ID)
Expand Down

0 comments on commit 3ed1540

Please sign in to comment.