Sentry integration

It'd be nice to have third party integrations for error tracking (I know convex runs in a special env, so I don't know the feasability, but this would be nice)
6 Replies
ian
ian2y ago
Yeah that would be cool, it’s on our radar. I’m curious if you’re just tracking from the client side for now? And what is the biggest pain point of doing it from there for you?
Chad Maycumber
Chad MaycumberOP2y ago
I just launched convex in my stack, so I haven't had too long to really evaluate fully, it does look like I'm getting some client side errors that do show up in sentry just fine. My biggest concern would be background processes. I really like how you can basically build an event driven system on convex, and I'm leveraging that pretty heavily.
jamwt
jamwt2y ago
awesome! that's part of the design we have some vague plans to explore sentry and datadog integrations (or maybe opentelemetry generally), but those are a bit further down the road right now. is that similar to what you had in mind?
RJ
RJ2y ago
@Chad Maycumber I have a wrapper for my Convex actions that intercepts errors and reports them to Sentry via another action which looks like this:
export default internalAction(async (_, error: unknown): Promise<null> => {
if (process.env.NODE_ENV === "production") {
Sentry.init({
dsn: sentryConfig.dsn,
});

typeof error === "string"
? Sentry.captureMessage(error)
: Sentry.captureException(error);

await Sentry.flush(2000);

return null;
} else if (process.env.NODE_ENV === "development") {
return null;
} else {
throw `Unexpected NODE_ENV '${process.env.NODE_ENV}'`;
}
});
export default internalAction(async (_, error: unknown): Promise<null> => {
if (process.env.NODE_ENV === "production") {
Sentry.init({
dsn: sentryConfig.dsn,
});

typeof error === "string"
? Sentry.captureMessage(error)
: Sentry.captureException(error);

await Sentry.flush(2000);

return null;
} else if (process.env.NODE_ENV === "development") {
return null;
} else {
throw `Unexpected NODE_ENV '${process.env.NODE_ENV}'`;
}
});
You probably want to make sure that the error is still thrown in the originating action as well. That's worked well for me so far; might be a nearer-term solution worth considering.
Chad Maycumber
Chad MaycumberOP2y ago
That's great thanks for sharing! I'm going to use this for sure
RJ
RJ2y ago
Note also that NODE_ENV is not available by default, I added it to my Convex environment variables for each of dev and prod.

Did you find this page helpful?