This file contains hidden or 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 books string = ` | |
| [ | |
| { "id": 1, "title": "Pedro Páramo", author: "Juan Rulfo" }, | |
| { "id": 2, "title": "Meditations", author: "Marcus Aurelius" }, | |
| { "id": 3, "title": "Walden", author: "Henry David Thoreau" } | |
| ] | |
| ` | |
| const book1 string = ` | |
| { "id": 1, "title": "Pedro Páramo", author: "Juan Rulfo" } | |
| ` |
This file contains hidden or 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
| import { Transaction } from "@sentry/types" | |
| export interface Context { | |
| // ... other context fields for your context | |
| transaction: Transaction | |
| } | |
| export async function createContext(): Promise<Context> { { | |
| // ... create other context fields | |
| const transaction = Sentry.startTransaction({ |
This file contains hidden or 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
| import { ApolloServerPlugin } from "apollo-server-plugin-base" | |
| import { Context } from "./context" | |
| const plugin: ApolloServerPlugin<Context> = { | |
| requestDidStart({ request, context }) { | |
| if (!!request.operationName) { // set the transaction Name if we have named queries | |
| context.transaction.setName(request.operationName!) | |
| } | |
| return { | |
| willSendResponse({ context }) { // hook for transaction finished |
This file contains hidden or 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
| import { ApolloServer } from "apollo-server-micro" | |
| import { createContext } from "./context" | |
| import SentryPlugin from "./sentry-plugin" | |
| const apolloServer = new ApolloServer({ | |
| // ... your ApolloServer options | |
| // Create context function | |
| context: ({ req, connection }) => createContext({ req, connection }), | |
| // Add our sentry plugin |
OlderNewer