Correct way to setUser using @sentry/nextjs and Auth0? #6676
Answered
by
lforst
watadarkstar
asked this question in
Q&A
-
|
Where is the correct place to set the Sentry user context on the server side in a Next.js app using Auth0? I tried doing it in the import * as Sentry from "@sentry/nextjs";
const afterCallback = async (_req: any, _res: any, session: Session) => {
Sentry.setUser({
id: session?.user?.sub,
email: session?.user?.email,
username: session?.user?.nickname,
name: session?.user?.name,
avatar: session?.user?.picture,
});
return session;
};My test page in Next.js const Test1 = () => <h1>SSR Test 1</h1>;
export function getServerSideProps() {
throw new Error("SSR Test 1");
}
export default Test1; |
Beta Was this translation helpful? Give feedback.
Answered by
lforst
Jan 9, 2023
Replies: 1 comment 5 replies
-
|
I guess this would work the same way as with any other HTTP framework. For each incoming request, or rather in each route, you should do |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
smeubank
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess this would work the same way as with any other HTTP framework. For each incoming request, or rather in each route, you should do
Sentry.setUser(). Subsequent errors in the routes should then have the user set.