feat: add LocationResult type and locationResults to Check model#3311
Closed
gorkem-bwl wants to merge 11 commits intodevelopfrom
Closed
feat: add LocationResult type and locationResults to Check model#3311gorkem-bwl wants to merge 11 commits intodevelopfrom
gorkem-bwl wants to merge 11 commits intodevelopfrom
Conversation
## Changes ### Server - Add `locations` field to Monitor model and types (up to 5 locations per monitor) - Add `location` field to Check metadata for per-location tracking - Add `globalpingApiKey` to AppSettings for API key management - Create GlobalpingService that wraps the Globalping SDK to run distributed HTTP/ping checks from multiple global locations (NA, EU, AS, SA, OC, AF) - Extend SuperSimpleQueueHelper with fire-and-forget Globalping checks that run alongside the existing local check without affecting the main pipeline - Add location-aware check queries with aggregation pipeline grouping by location in MongoChecksRepository - Filter location checks from main uptime aggregation to preserve local check as source of truth for status/incidents - Extend monitor details endpoint to return per-location check data - Add GET /globalping/locations endpoint for available location options - Add globalpingKeySet to settings response - Add Joi validation for locations and globalpingApiKey fields ### Client - Add locations multi-select (Autocomplete with chips) to monitor creation form, shown only for HTTP and ping monitor types - Add SettingsGlobalping component for API key management (matching existing PageSpeed pattern with set/reset flow) - Add per-location breakdown section to uptime details page with tabs, avg response time, uptime percentage, and response time charts - Add globe icon with tooltip to monitor table for monitors with locations - Add Zod validation for locations field in HTTP and ping schemas - Add all translation keys for globalping settings, locations form, and location details sections ## Benefits - Users gain visibility into geographic availability and latency data - Local check remains the source of truth, Globalping runs alongside - Supports up to 5 locations per monitor with 6 continent-level options - Graceful degradation when API key is not configured or rate limited
The MongoSettingsRepository.toEntity method was missing the globalpingApiKey field, causing GlobalpingService to always report the API key as not configured.
## Changes ### Server - Expand LOCATION_MAP to support city/country-level locations for the 15-location tier (US East/West, Toronto, London, Frankfurt, Amsterdam, Warsaw, Tokyo, Singapore, Mumbai, Sydney, Brazil, Santiago, Johannesburg, Dubai) - Add globalpingLocationsTier field to Settings type, Mongoose model, repository mapper, and Joi validation (valid: 3, 6, 15, default: 6) - Update getGlobalpingLocations endpoint to return locations based on the configured tier from settings - Pass settingsService to MonitorController for tier lookup ### Client - Add tier selector (radio buttons) to SettingsGlobalping component with descriptions for each option: - 3 locations: North America, Europe, Asia - 6 locations: all continents - 15 locations: city-level global coverage - Add rate limits info box explaining credit usage per tier: - Without token: 250 tests/hour - With free token: 500 tests/hour - GitHub sponsors: higher limits - Add all translation keys for tier labels, descriptions, and rate info ## Benefits - Admins can choose the right balance of coverage vs API usage - Rate limit info helps users decide whether they need authentication
- Add top margin to radio buttons so they align with the first line of the multi-line labels - Remove custom background color from rate limits box that was unreadable in dark mode - Use default text color for bullet points instead of text.secondary - Keep only the example note in text.secondary with italic style
…t size - Remove default Radio padding and use explicit margin-right for consistent alignment with the first line of label text - Use RadioGroup gap for consistent spacing between options - Switch rate limits text from body2 to default (body1) to match other settings section descriptions
## Changes - Remove per-monitor location selection — locations are now determined globally by the tier setting in admin settings (3, 6, or 15 locations) - GlobalpingService reads tier from settings on each check run, so changing the tier in settings immediately affects all HTTP/ping monitors - Add resolveLocationId() to map Globalping probe results back to configured location IDs for proper grouping - Export LOCATION_LABELS for human-readable location names on the client - Remove unused locations field from Zod schemas and form defaults - Remove per-monitor location ConfigBox from CreateMonitor page - Fix settingsController.updateAppSettings missing try/catch - Fix MongoSettingsRepository duplicate findOneAndUpdate call - Use typed LocationCheckData instead of Record<string, any> - Remove unused REVERSE_LOCATION_MAP from globalpingService ## Benefits - Changing the location tier in settings takes effect immediately for all monitors without needing to edit each one individually - Cleaner separation of concerns — location configuration lives in settings, not scattered across monitors - Human-readable location labels shown in uptime details tabs
When saving settings, empty sensitive fields (pagespeedApiKey, globalpingApiKey, systemEmailPassword) were sent as "" to the server, which treated them as $unset operations — deleting the stored keys. Now the form omits these fields from the payload when they're already set and haven't been explicitly reset by the user.
Add a globalpingEnabled boolean to the Monitor model so users can opt-in to global location checks per monitor during creation/edit. ## Changes - Add globalpingEnabled field to server types, Mongoose model, Joi validation, and repository mappers - Add globalpingEnabled to client Monitor type, Zod schemas for HTTP and ping monitors, and form defaults - Add "Global monitoring" ConfigBox with Switch toggle to the monitor creation/edit form, visible for HTTP and ping types - Queue helper and monitorService now check globalpingEnabled before running Globalping checks or fetching location data - Add translation keys for the new form section ## Benefits - Users can selectively enable Globalping on monitors that need it rather than running location checks on every HTTP/ping monitor - Reduces unnecessary API usage and keeps the UI clean for monitors that only need local checks
…array The globe icon in the monitor list was checking row.locations.length, but locations are no longer stored per-monitor. Updated to check row.globalpingEnabled and show a "Global monitoring enabled" tooltip.
## Changes ### Critical fixes - Fix Switch `isChecked` → `checked` prop in CreateMonitor Globalping toggle - Merge double `getDBSettings()` calls in globalpingService into single `getClientAndLocations()` method to eliminate redundant DB reads per check cycle - Add in-flight lock (Set) to prevent overlapping Globalping checks for the same monitor - Add hostname validation before calling Globalping API to prevent invalid targets ### Dead code removal - Remove unused `locations` field from server Monitor type, Mongoose model, Joi validation, and repository mappers - Remove unused `locations` field from client Monitor type - Remove dead `getLimits()` method from globalpingService - Remove dead `locations` translation keys from en.json - Remove dead `monitorType`, `groupedUpChecks`, `groupedDownChecks` fields from findLocationChecksByMonitorId return value ### Medium/low fixes - Make globalping/locations API fetch conditional on `monitor.globalpingEnabled` in Details page to avoid unnecessary requests - Add useEffect to reset selectedLocationTab when location keys change to prevent out-of-bounds tab index - Add `globalpingEnabled: false` to default case in useMonitorForm - Replace console.log with comment in CreateMonitor onError handler - Add aria-label to Globe icon for accessibility - Add warning log when Globalping buildCheck returns undefined - Fix step numbering in SuperSimpleQueueHelper (was duplicated Step 4) ## Benefits - Eliminates one DB round-trip per monitor check cycle - Prevents race conditions with overlapping Globalping checks - Validates hostnames before external API calls - Removes ~30 lines of dead code across server and client - Improves accessibility with proper aria labels
467e0f0 to
ebfcb95
Compare
## Changes - Add LocationResult interface to server check types - Add locationResults optional field to Check interface - Add GlobalpingCheckResult interface to network types - Add locationResultSchema subdocument and locationResults field to Mongoose Check schema - Fix formatting in pre-existing files (SettingsGlobalping, Settings index, UptimeMonitorsTable, monitorService) ## Benefits Non-destructive addition of the data model needed to store per-location Globalping results inside a single Check document. No existing behaviour is changed.
ebfcb95 to
d25ce9e
Compare
962be80 to
d25ce9e
Compare
Member
|
@gorkem-bwl can you please clear the conflicts here? |
Contributor
Author
|
@Br0wnHammer Alex is now taking care of this, picking up the parts of the issue and come up with a PR himself |
Member
|
@gorkem-bwl should we close this out then? |
Contributor
Author
Yes please, Alex has the latest code (this and other 3) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
LocationResultinterface andlocationResultssubdocument array to the Check type and Mongoose schemaGlobalpingCheckResulttype to network typesTest plan
npm run buildin/serverpasses with zero errorslocationResultsfield