diff --git a/governance/package.json b/governance/package.json index 538af8a6b71..37159ba6e0f 100644 --- a/governance/package.json +++ b/governance/package.json @@ -43,4 +43,4 @@ "lint:code": "eslint .", "lint": "yarn lint:code" } -} \ No newline at end of file +} diff --git a/graph-service/package.json b/graph-service/package.json index 1bebfb52b2c..2bd6db9a6c5 100644 --- a/graph-service/package.json +++ b/graph-service/package.json @@ -3,7 +3,6 @@ "dependencies": { "@cloudflare/workers-types": "4.20241127.0", "@sentry/node": "8.41.0", - "toucan-js": "4.0.0", "wrangler": "3.91.0" }, "devDependencies": { diff --git a/graph-service/src/index.ts b/graph-service/src/index.ts index 82cc3c7d179..a7c5c07fb3a 100644 --- a/graph-service/src/index.ts +++ b/graph-service/src/index.ts @@ -1,16 +1,9 @@ -import { Toucan } from 'toucan-js' import { getSubgraphUrl } from './networks' import { Env, GraphQLRequest } from './types' import networks from '@unlock-protocol/networks' export default { async fetch(request: Request, env: Env): Promise { - // Initialize Sentry for error tracking - const sentry = new Toucan({ - dsn: env.SENTRY_DSN, - request, - }) - // Define CORS headers to allow cross-origin requests const corsHeaders = { 'Access-Control-Allow-Origin': '*', @@ -65,49 +58,49 @@ export default { }) } - try { - // Parse the incoming JSON request body - const { query, variables }: GraphQLRequest = await request.json() + // Parse the incoming JSON request body + const { query, variables }: GraphQLRequest = await request.json() - // Validate that a query is provided - if (!query) { - return new Response('Bad Request: query is required', { - status: 400, - headers: corsHeaders, - }) - } - - // Forward the GraphQL request to the subgraph - const graphResponse = await fetch(subgraphUrl, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ query, variables }), + // Validate that a query is provided + if (!query) { + return new Response('Bad Request: query is required', { + status: 400, + headers: corsHeaders, }) + } - // Extract response data and headers - const responseData = await graphResponse.text() - const responseHeaders = new Headers(graphResponse.headers) + // Forward the GraphQL request to the subgraph + const graphResponse = await fetch(subgraphUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ query, variables }), + }) - // Append CORS headers to the response - Object.entries(corsHeaders).forEach(([key, value]) => { - responseHeaders.set(key, value) - }) + // Extract response data and headers + const responseData = await graphResponse.text() + const responseHeaders = new Headers(graphResponse.headers) + + // Append CORS headers to the response + Object.entries(corsHeaders).forEach(([key, value]) => { + responseHeaders.set(key, value) + }) - // Return the response from the subgraph - return new Response(responseData, { + if (graphResponse.status !== 200) { + console.log({ status: graphResponse.status, - headers: responseHeaders, - }) - } catch (error) { - // Capture and log any errors that occur during processing - sentry.captureException(error) - console.error('Error processing request:', error) - return new Response('Internal Server Error', { - status: 500, - headers: corsHeaders, + subgraphUrl, + query, + variables, + responseData, }) } + + // Return the response from the subgraph + return new Response(responseData, { + status: graphResponse.status, + headers: responseHeaders, + }) }, } diff --git a/graph-service/wrangler.toml b/graph-service/wrangler.toml index 52c84a7dc9b..cfbda12d4b2 100644 --- a/graph-service/wrangler.toml +++ b/graph-service/wrangler.toml @@ -4,4 +4,11 @@ compatibility_date = "2024-07-29" tail_consumers = [{service = "graph-service-tail"}] [vars] -SENTRY_DSN="https://5f60928f69cd6e060f6bed5bfd5b4a2c@o555569.ingest.us.sentry.io/4507855281979392" \ No newline at end of file +SENTRY_DSN="https://5f60928f69cd6e060f6bed5bfd5b4a2c@o555569.ingest.us.sentry.io/4507855281979392" + +[observability] +enabled = true +head_sampling_rate = 1 # optional. default = 1. + +[observability.logs] +enabled = true diff --git a/yarn.lock b/yarn.lock index 4ea7b056131..a59dddb6c53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13701,16 +13701,6 @@ __metadata: languageName: node linkType: hard -"@sentry/core@npm:8.9.2": - version: 8.9.2 - resolution: "@sentry/core@npm:8.9.2" - dependencies: - "@sentry/types": "npm:8.9.2" - "@sentry/utils": "npm:8.9.2" - checksum: 10/f11532b9f0cceceb40f1934a23360c98d3dd7ae8a05f14e2ed5f5a247932716f5f7367aa1f6cba7dc2736b063ceaefe27d4ebe55af6e6ca593a9b39d75d1ca4e - languageName: node - linkType: hard - "@sentry/hub@npm:5.30.0": version: 5.30.0 resolution: "@sentry/hub@npm:5.30.0" @@ -13972,13 +13962,6 @@ __metadata: languageName: node linkType: hard -"@sentry/types@npm:8.9.2": - version: 8.9.2 - resolution: "@sentry/types@npm:8.9.2" - checksum: 10/a38f4dd21330a3d4c848f94ba678ce24ce5489236286247bae351db1d97d49733cd4888b59e1b193077fe38a1bd8e04e72067e749897bfd15d657cc551333657 - languageName: node - linkType: hard - "@sentry/utils@npm:5.30.0": version: 5.30.0 resolution: "@sentry/utils@npm:5.30.0" @@ -14016,15 +13999,6 @@ __metadata: languageName: node linkType: hard -"@sentry/utils@npm:8.9.2": - version: 8.9.2 - resolution: "@sentry/utils@npm:8.9.2" - dependencies: - "@sentry/types": "npm:8.9.2" - checksum: 10/4933dbbb837ce61006ea867fea061d610c72330d04b33fd1871a9a327e8d11d8d150db34054d5fd7c316270167c17179f5bfe7eddded49cb5010b14cdffb5e75 - languageName: node - linkType: hard - "@sentry/vercel-edge@npm:7.119.2": version: 7.119.2 resolution: "@sentry/vercel-edge@npm:7.119.2" @@ -31114,7 +31088,6 @@ __metadata: dependencies: "@cloudflare/workers-types": "npm:4.20241127.0" "@sentry/node": "npm:8.41.0" - toucan-js: "npm:4.0.0" vitest: "npm:2.1.8" wrangler: "npm:3.91.0" languageName: unknown @@ -48972,17 +48945,6 @@ __metadata: languageName: node linkType: hard -"toucan-js@npm:4.0.0": - version: 4.0.0 - resolution: "toucan-js@npm:4.0.0" - dependencies: - "@sentry/core": "npm:8.9.2" - "@sentry/types": "npm:8.9.2" - "@sentry/utils": "npm:8.9.2" - checksum: 10/900b09b5da8e3a5f19ccffa20f10de1ea2f538a2a3f5847ecfb75683d4ff161ea7d10fcf610f585be8ec7271ec8b3e3a10f44598c70e1296229bae3b11b75da7 - languageName: node - linkType: hard - "tough-cookie@npm:^5.0.0": version: 5.0.0 resolution: "tough-cookie@npm:5.0.0"