mirror of
				https://github.com/tormachris/cf-workers-status-page.git
				synced 2025-11-04 12:56:24 +01:00 
			
		
		
		
	chore: readme collectResponseTimes example
This commit is contained in:
		@@ -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 (
 | 
			
		||||
                    <>
 | 
			
		||||
 
 | 
			
		||||
@@ -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))
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
@@ -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)}*`,
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user