Skip to content

Catch analytics tracking error during maintenance mode

When developing locally in maintenance mode, users would be [presented with a javascript error](Relates to #499327 (closed)) which seems to have been caused by a POST request for usage tracking data. The request failed due to the url not being in the allowlist of requests during maintenance mode.

This MR catches/silences the JS error to avoid displaying the webpack error page.

A decision on allowing the POST request through in maintenance mode is still being discussed here.

Changelog: fixed

Screenshots

Before After
Screenshot_2024-10-22_at_16.02.38 Screenshot_2024-10-22_at_16.02.18

How to set up and validate locally

  1. Remove/comment the added code from this MR - .catch(() => {}); in app/assets/javascripts/api.js
  2. Turn on maintenance mode via the Maintenance Mode section on the Admin > Settings > General settings page at /admin/application_settings/general
  3. Refresh the Admin page and click anywhere to trigger a tracking event - you should observe a webpack error on the page, and in the browser console
  4. Uncomment the code mentioned in step 1
  5. Refresh the Admin page again and try to click anywhere, the error should no longer be present, but will still be logged in the browser developer console

Related to #499327 (closed)

Edited by Scott Murray

Merge request reports

Loading