@@ -5,13 +5,13 @@ import { Integrations, Transaction } from "@sentry/tracing";
55import { BaseRedisCache } from "apollo-server-cache-redis" ;
66import { InMemoryLRUCache } from "apollo-server-caching" ;
77import {
8- ApolloServerPluginCacheControl ,
9- ApolloServerPluginDrainHttpServer ,
10- ApolloServerPluginLandingPageDisabled ,
8+ ApolloServerPluginCacheControl ,
9+ ApolloServerPluginDrainHttpServer ,
10+ ApolloServerPluginLandingPageDisabled
1111} from "apollo-server-core" ;
1212import { ApolloServer } from "apollo-server-fastify" ;
1313import responseCachePlugin from "apollo-server-plugin-response-cache" ;
14- import fastify , { FastifyContext } from "fastify" ;
14+ import fastify , { FastifyContext , FastifyReply , FastifyRequest } from "fastify" ;
1515import Redis from "ioredis" ;
1616import { MongoClient } from "mongodb" ;
1717import pEvent from "p-event" ;
@@ -63,12 +63,17 @@ export interface Context {
6363async 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