Skip to content

Commit

Permalink
Merge branch 'master' into upgrade-snapshot.js-to-0.8.0-beta.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaituVR authored Oct 27, 2023
2 parents 58dad61 + 8c7127f commit 84368b0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@graphql-tools/schema": "^10.0.0",
"@snapshot-labs/keycard": "^0.4.0",
"@snapshot-labs/snapshot-metrics": "^1.3.1",
"@snapshot-labs/snapshot-sentry": "^1.5.1",
"@snapshot-labs/snapshot-sentry": "^1.5.2",
"@snapshot-labs/snapshot.js": "^0.8.0-beta.0",
"bluebird": "^3.7.2",
"connection-string": "^1.0.1",
Expand Down
12 changes: 9 additions & 3 deletions src/helpers/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import init, { client } from '@snapshot-labs/snapshot-metrics';
import { capture } from '@snapshot-labs/snapshot-sentry';
import { Express, type Request, type Response } from 'express';
import { parse } from 'graphql';
import { GraphQLError, parse } from 'graphql';
import { spacesMetadata } from './spaces';
import { strategies } from './strategies';
import db from './mysql';
Expand Down Expand Up @@ -58,9 +58,13 @@ export default function initMetrics(app: Express) {
if (query && operationName) {
const definition = parse(query).definitions.find(
// @ts-ignore
def => def.name.value === operationName
def => def.name?.value === operationName
);

if (!definition) {
return;
}

// @ts-ignore
const types = definition.selectionSet.selections.map(sel => sel.name.value);

Expand All @@ -71,7 +75,9 @@ export default function initMetrics(app: Express) {
}
}
} catch (e: any) {
capture(e);
if (!(e instanceof GraphQLError)) {
capture(e);
}
}
});
}
Expand Down
1 change: 1 addition & 0 deletions test/.env.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
HUB_DATABASE_URL=mysql://root:[email protected]:3306/hub_test
SEQ_DATABASE_URL=mysql://root:[email protected]:3306/hub_test
NODE_ENV=test
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1315,10 +1315,10 @@
node-fetch "^2.7.0"
prom-client "^14.2.0"

"@snapshot-labs/snapshot-sentry@^1.5.1":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot-sentry/-/snapshot-sentry-1.5.1.tgz#c4b5da87a97f760d9327743f7748783aaef14d9a"
integrity sha512-2xM72Xqypr73x6iWP5kr9fsNDeygmbiflTLhKeahT5yjjpFaSyS2razha+qxjo6w+0rIwNQXXYnlcrju24K2iA==
"@snapshot-labs/snapshot-sentry@^1.5.2":
version "1.5.2"
resolved "https://registry.yarnpkg.com/@snapshot-labs/snapshot-sentry/-/snapshot-sentry-1.5.2.tgz#a8c48e6602e0f236ba582a6728381e542501fe2a"
integrity sha512-xDZKiXigmfBWimDQGQwh/1WoqcD2n23nQczjWe+ukkLSvqk3AMwWz0F2tnd/MLiiklSyHezfcAzsSVMxlZPsPA==
dependencies:
"@sentry/node" "^7.60.1"

Expand Down

0 comments on commit 84368b0

Please sign in to comment.