mirror of
				https://github.com/tormachris/cf-workers-status-page.git
				synced 2025-11-04 04:46:24 +01:00 
			
		
		
		
	chore: readme collectResponseTimes example
This commit is contained in:
		
							
								
								
									
										1
									
								
								.github/workflows/deploy.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/deploy.yml
									
									
									
									
										vendored
									
									
								
							@@ -38,6 +38,7 @@ jobs:
 | 
				
			|||||||
          SECRET_TELEGRAM_CHAT_ID
 | 
					          SECRET_TELEGRAM_CHAT_ID
 | 
				
			||||||
        environment: production
 | 
					        environment: production
 | 
				
			||||||
      env:
 | 
					      env:
 | 
				
			||||||
 | 
					        NODE_ENV: production
 | 
				
			||||||
        CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
 | 
					        CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
 | 
				
			||||||
        SECRET_SLACK_WEBHOOK_URL: ${{secrets.SECRET_SLACK_WEBHOOK_URL}}
 | 
					        SECRET_SLACK_WEBHOOK_URL: ${{secrets.SECRET_SLACK_WEBHOOK_URL}}
 | 
				
			||||||
        SECRET_TELEGRAM_API_TOKEN: ${{secrets.SECRET_TELEGRAM_API_TOKEN}}
 | 
					        SECRET_TELEGRAM_API_TOKEN: ${{secrets.SECRET_TELEGRAM_API_TOKEN}}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
					     url: 'https://status-page.eidam.dev' # used for Slack messages
 | 
				
			||||||
     logo: logo-192x192.png # image in ./public/ folder
 | 
					     logo: logo-192x192.png # image in ./public/ folder
 | 
				
			||||||
     daysInHistogram: 90 # number of days you want to display in histogram
 | 
					     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
 | 
					     # configurable texts across the status page
 | 
				
			||||||
     allmonitorsOperational: 'All Systems Operational'
 | 
					     allmonitorsOperational: 'All Systems Operational'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,7 +39,8 @@ export default function MonitorHistogram({ monitorId, kvMonitor }) {
 | 
				
			|||||||
              <span className="font-semibold text-sm">
 | 
					              <span className="font-semibold text-sm">
 | 
				
			||||||
                {dayInHistogramLabel}
 | 
					                {dayInHistogramLabel}
 | 
				
			||||||
              </span>
 | 
					              </span>
 | 
				
			||||||
              {kvMonitor && kvMonitor.checks.hasOwnProperty(dayInHistogram) &&
 | 
					              {kvMonitor &&
 | 
				
			||||||
 | 
					                kvMonitor.checks.hasOwnProperty(dayInHistogram) &&
 | 
				
			||||||
                Object.keys(kvMonitor.checks[dayInHistogram].res).map((key) => {
 | 
					                Object.keys(kvMonitor.checks[dayInHistogram].res).map((key) => {
 | 
				
			||||||
                  return (
 | 
					                  return (
 | 
				
			||||||
                    <>
 | 
					                    <>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,9 +79,11 @@ export async function processCronTrigger(event) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Send Telegram message on monitor change
 | 
					    // Send Telegram message on monitor change
 | 
				
			||||||
    if (
 | 
					    if (
 | 
				
			||||||
      monitorStatusChanged
 | 
					      monitorStatusChanged &&
 | 
				
			||||||
      && typeof SECRET_TELEGRAM_API_TOKEN !== 'undefined' && SECRET_TELEGRAM_API_TOKEN !== 'default-gh-action-secret'
 | 
					      typeof SECRET_TELEGRAM_API_TOKEN !== 'undefined' &&
 | 
				
			||||||
      && typeof SECRET_TELEGRAM_CHAT_ID !== 'undefined' && SECRET_TELEGRAM_CHAT_ID !== 'default-gh-action-secret'
 | 
					      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))
 | 
					      event.waitUntil(notifyTelegram(monitor, monitorOperational))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ export async function setKVMonitors(data) {
 | 
				
			|||||||
  return setKV(kvDataKey, JSON.stringify(data))
 | 
					  return setKV(kvDataKey, JSON.stringify(data))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const getOperationalLabel = operational => {
 | 
					const getOperationalLabel = (operational) => {
 | 
				
			||||||
  return operational
 | 
					  return operational
 | 
				
			||||||
    ? config.settings.monitorLabelOperational
 | 
					    ? config.settings.monitorLabelOperational
 | 
				
			||||||
    : config.settings.monitorLabelNotOperational
 | 
					    : config.settings.monitorLabelNotOperational
 | 
				
			||||||
@@ -33,7 +33,9 @@ export async function notifySlack(monitor, operational) {
 | 
				
			|||||||
            type: 'section',
 | 
					            type: 'section',
 | 
				
			||||||
            text: {
 | 
					            text: {
 | 
				
			||||||
              type: 'mrkdwn',
 | 
					              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) {
 | 
					export async function notifyTelegram(monitor, operational) {
 | 
				
			||||||
  const text = `Monitor *${monitor.name.replace('-', '\\-')}* changed status to *${getOperationalLabel(operational)}*
 | 
					  const text = `Monitor *${monitor.name.replace(
 | 
				
			||||||
  ${operational ? '✅' : '❌'} \`${monitor.method ? monitor.method : "GET"} ${monitor.url}\` \\- 👀 [Status Page](${config.settings.url})`
 | 
					    '-',
 | 
				
			||||||
 | 
					    '\\-',
 | 
				
			||||||
 | 
					  )}* changed status to *${getOperationalLabel(operational)}*
 | 
				
			||||||
 | 
					  ${operational ? '✅' : '❌'} \`${monitor.method ? monitor.method : 'GET'} ${
 | 
				
			||||||
 | 
					    monitor.url
 | 
				
			||||||
 | 
					  }\` \\- 👀 [Status Page](${config.settings.url})`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const payload = new FormData()
 | 
					  const payload = new FormData()
 | 
				
			||||||
  payload.append('chat_id', SECRET_TELEGRAM_CHAT_ID)
 | 
					  payload.append('chat_id', SECRET_TELEGRAM_CHAT_ID)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user