GlitchTip is behind Cloudflare, which answers the browser's cross-site ingest POSTs with 503 (no CORS headers -> 'Failed to fetch'); server-side requests pass. The browser SDK now posts envelopes same-origin to /sentry-tunnel, and the server forwards them to GlitchTip: - imports/startup/server/sentryTunnel.js: WebApp handler that relays the raw envelope to <dsn>/api/<project>/envelope/?sentry_key=<key> over IPv4 (family:4 avoids Happy-Eyeballs picking Cloudflare's unroutable IPv6 on IPv4-only hosts). GlitchTip authenticates by the sentry_key query, so the key is derived from the DSN and passed explicitly. - client ravenLogger: tunnel: '/sentry-tunnel'. Verified: POST /sentry-tunnel -> 200 (envelope reaches GlitchTip).
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
// Error reporter (client). Was flowkey:raven; replaced by @sentry/browser
|
|
// behind the same `.log()` facade (see the server counterpart). Enabled only
|
|
// when Meteor.settings.public.sentryPublicDSN is set; otherwise a plain console
|
|
// logger. ErrorBoundary calls `.log(error, info)` where info is React's
|
|
// { componentStack } — passed to Sentry as extra context.
|
|
import * as Sentry from '@sentry/browser';
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
const dsn = Meteor.settings.public.sentryPublicDSN;
|
|
const enabled = !!dsn;
|
|
|
|
if (enabled) {
|
|
Sentry.init({
|
|
dsn,
|
|
environment: Meteor.isDevelopment ? 'development' : 'production',
|
|
tracesSampleRate: 0,
|
|
// Send events same-origin to our own server, which forwards them to
|
|
// GlitchTip. GlitchTip is fronted by Cloudflare, whose bot protection
|
|
// returns 503 to the browser's cross-site ingest beacons (server-side
|
|
// requests pass fine). The tunnel sidesteps that entirely (and ad-blockers).
|
|
// See imports/startup/server/sentryTunnel.js.
|
|
tunnel: '/sentry-tunnel'
|
|
});
|
|
}
|
|
|
|
const ravenLogger = {
|
|
log(error, info) {
|
|
console.log(error);
|
|
if (enabled) {
|
|
Sentry.captureException(error, info ? { extra: { info } } : undefined);
|
|
}
|
|
}
|
|
};
|
|
|
|
console.log(`sentryLogger (client) ${enabled ? 'enabled' : 'disabled'}`);
|
|
|
|
export default ravenLogger;
|