-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hook up sentry reporting for local deployments (#31478)
While we're rolling out dev with local deployments and trying to identify bugs, it'll be helpful to be able to see any errors that the local backend hits (similar to being able to see errors hit by `npx convex dev` and similar from cloud deployments). This change makes it so that `npx convex dev --local` reports errors from the local backend to one of our Sentry projects -- alpha testing instructions will be updated to make this clear. We'll make this reporting opt in or at least configurable before releasing more broadly. This makes it so that local backend can generally be configured to report errors (I think we weren't calling `sentry::init` anywhere before), but only if there's a `SENTRY_DSN` env var provided. GitOrigin-RevId: f08666117de00545e3ef755fb682fdf15964f065
- Loading branch information
Showing
3 changed files
with
42 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,15 +14,13 @@ import { login } from "./login.js"; | |
import { logout } from "./logout.js"; | ||
import chalk from "chalk"; | ||
import * as Sentry from "@sentry/node"; | ||
import "@sentry/tracing"; | ||
import stripAnsi from "strip-ansi"; | ||
import { productionProvisionHost, provisionHost } from "./lib/config.js"; | ||
import { convexImport } from "./convexImport.js"; | ||
import { initSentry } from "./lib/utils/sentry.js"; | ||
import { dev } from "./dev.js"; | ||
import { deploy } from "./deploy.js"; | ||
import { logs } from "./logs.js"; | ||
import { networkTest } from "./network_test.js"; | ||
import { convexExport } from "./convexExport.js"; | ||
import { convexImport } from "./convexImport.js"; | ||
import { env } from "./env.js"; | ||
import { data } from "./data.js"; | ||
import inquirer from "inquirer"; | ||
|
@@ -40,28 +38,10 @@ function logToStderr(...args: unknown[]) { | |
} | ||
|
||
async function main() { | ||
// If you want to use `@sentry/tracing` in your project directly, use a named import instead: | ||
// import * as SentryTracing from "@sentry/tracing" | ||
// Unused named imports are not guaranteed to patch the global hub. | ||
|
||
// Use ipv4 first for 127.0.0.1 in tests | ||
dns.setDefaultResultOrder("ipv4first"); | ||
|
||
if (!process.env.CI && provisionHost === productionProvisionHost) { | ||
Sentry.init({ | ||
dsn: "https://[email protected]/6390839", | ||
release: "cli@" + version, | ||
tracesSampleRate: 0.2, | ||
beforeBreadcrumb: (breadcrumb) => { | ||
// Strip ANSI color codes from log lines that are sent as breadcrumbs. | ||
if (breadcrumb.message) { | ||
breadcrumb.message = stripAnsi(breadcrumb.message); | ||
} | ||
return breadcrumb; | ||
}, | ||
}); | ||
} | ||
|
||
initSentry(); | ||
inquirer.registerPrompt("search-list", inquirerSearchList); | ||
|
||
const nodeVersion = process.versions.node; | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import "@sentry/tracing"; | ||
import { productionProvisionHost, provisionHost } from "../config.js"; | ||
import stripAnsi from "strip-ansi"; | ||
import * as Sentry from "@sentry/node"; | ||
import { version } from "../../../index.js"; | ||
|
||
export const SENTRY_DSN = | ||
"https://[email protected]/6390839"; | ||
|
||
export function initSentry() { | ||
if (!process.env.CI && provisionHost === productionProvisionHost) { | ||
Sentry.init({ | ||
dsn: SENTRY_DSN, | ||
release: "cli@" + version, | ||
tracesSampleRate: 0.2, | ||
beforeBreadcrumb: (breadcrumb) => { | ||
// Strip ANSI color codes from log lines that are sent as breadcrumbs. | ||
if (breadcrumb.message) { | ||
breadcrumb.message = stripAnsi(breadcrumb.message); | ||
} | ||
return breadcrumb; | ||
}, | ||
}); | ||
} | ||
} |