Last active
February 5, 2020 10:06
-
-
Save benoitguigal/137075b0d83d2d0d061d2f8c24be6c8c to your computer and use it in GitHub Desktop.
server.ts
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
const sentryMiddleware = () => | |
sentry<GraphQLContext>({ | |
config: { | |
dsn: SENTRY_DSN, | |
environment: NODE_ENV, | |
integrations: [new CaptureConsole({ levels: ["error"] })] | |
}, | |
forwardErrors: true, | |
withScope: (scope, error, context) => { | |
const reqUser = !!context.user ? context.user.email : "anonymous"; | |
scope.setUser({ | |
email: reqUser | |
}); | |
scope.setExtra("body", context.req.body); | |
scope.setExtra("origin", context.req.headers.origin); | |
scope.setExtra("user-agent", context.req.headers["user-agent"]); | |
scope.setExtra("ip", context.req.headers["x-real-ip"]); | |
scope.setTag("service", "api"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment