Skip to content

Commit 1512de8

Browse files
committed
fix: add ip
1 parent e1d861c commit 1512de8

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

worker/src/index.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { Integrations, Transaction } from "@sentry/tracing";
55
import { BaseRedisCache } from "apollo-server-cache-redis";
66
import { InMemoryLRUCache } from "apollo-server-caching";
77
import {
8-
ApolloServerPluginCacheControl,
9-
ApolloServerPluginDrainHttpServer,
10-
ApolloServerPluginLandingPageDisabled,
8+
ApolloServerPluginCacheControl,
9+
ApolloServerPluginDrainHttpServer,
10+
ApolloServerPluginLandingPageDisabled
1111
} from "apollo-server-core";
1212
import { ApolloServer } from "apollo-server-fastify";
1313
import responseCachePlugin from "apollo-server-plugin-response-cache";
14-
import fastify, { FastifyContext } from "fastify";
14+
import fastify, { FastifyContext, FastifyReply, FastifyRequest } from "fastify";
1515
import Redis from "ioredis";
1616
import { MongoClient } from "mongodb";
1717
import pEvent from "p-event";
@@ -63,12 +63,17 @@ export interface Context {
6363
async function run() {
6464
const apolloGenericSettings = {
6565
dataSources: () => dSources,
66-
context: () => ({
67-
transaction: Sentry.startTransaction({
68-
op: "gql",
69-
name: "GraphQLTransaction"
70-
})
71-
}),
66+
context: (req: FastifyRequest, res: FastifyReply) => {
67+
Sentry.setUser({
68+
ip_address: req.ip
69+
});
70+
return {
71+
transaction: Sentry.startTransaction({
72+
op: "gql",
73+
name: "GraphQLTransaction"
74+
})
75+
};
76+
},
7277
introspection: true,
7378
cache: baseRedisCache,
7479
plugins: [

0 commit comments

Comments
 (0)