Skip to content

feat: Update hapi to v8.0.0-rc.1 #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/hapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@hapi/hapi": "21.3.9",
"@sentry/node": "7.113.0",
"@sentry/node": "8.0.0-beta.6",
"dotenv": "^16.4.5"
}
}
27 changes: 14 additions & 13 deletions apps/hapi/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
const Sentry = require('@sentry/node');
import Hapi from '@hapi/hapi';
import * as Sentry from '@sentry/node';
import dotenv from 'dotenv';

dotenv.config({ path: './../../.env' });

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
debug: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
});

import Hapi from '@hapi/hapi';

dotenv.config({ path: './../../.env' });

const server = Hapi.server({
port: 3030,
host: 'localhost',
Expand All @@ -15,22 +27,11 @@ declare global {
}
}

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.SENTRY_DSN,
includeLocalVariables: true,
integrations: [Sentry.hapiIntegration({ server })],
debug: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
});

const init = async () => {
server.route({
method: 'GET',
path: '/test-success',
handler: function (request, h) {
console.log('test console');
return { version: 'v1' };
},
});
Expand Down
97 changes: 61 additions & 36 deletions payload-files/hapi/_test-error--event.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"event_id": "[[ID1]]",
"sdk": {
"name": "sentry.javascript.node",
"version": "7.113.0"
"version": "8.0.0-beta.6"
},
"sent_at": "[[ISODateString]]",
"trace": {
Expand All @@ -13,7 +13,7 @@
"sample_rate": "1",
"sampled": "true",
"trace_id": "[[ID2]]",
"transaction": "/test-error"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v7 does not include the http method

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is def. better in v8! 🚀

"transaction": "GET /test-error"
}
},
{
Expand All @@ -26,18 +26,6 @@
"level": "log",
"message": "Server running on http://localhost:3030",
"timestamp": "[[timestamp]]"
},
{
"category": "console",
"level": "log",
"message": "test console",
"timestamp": "[[timestamp]]"
},
{
"category": "console",
"level": "log",
"message": "test console",
"timestamp": "[[timestamp]]"
}
],
"contexts": {
Expand Down Expand Up @@ -70,13 +58,6 @@
"version": "v20.12.1"
},
"trace": {
"data": {
"sentry.op": "hapi.request",
"sentry.origin": "manual",
"sentry.sample_rate": 1
},
"op": "hapi.request",
"origin": "manual",
"span_id": "[[ID3]]",
"trace_id": "[[ID2]]"
}
Expand Down Expand Up @@ -179,7 +160,7 @@
"filename": "[[FILENAME3]]",
"function": "handler",
"in_app": true,
"lineno": 71,
"lineno": 72,
"module": "app",
"post_context": [
" var exceptionId;",
Expand Down Expand Up @@ -233,7 +214,7 @@
"colno": 71,
"context_line": " step((generator = generator.apply(thisArg, _arguments || [])).next());",
"filename": "[[FILENAME3]]",
"function": "<anonymous>",
"function": "?",
"in_app": true,
"lineno": 8,
"module": "app",
Expand Down Expand Up @@ -314,9 +295,9 @@
"colno": 71,
"context_line": " exceptionId = Sentry.captureException(new Error('This is an error'));",
"filename": "[[FILENAME3]]",
"function": "<anonymous>",
"function": "?",
"in_app": true,
"lineno": 76,
"lineno": 77,
"module": "app",
"post_context": [
" return [4 /*yield*/, Sentry.flush(2000)];",
Expand Down Expand Up @@ -345,10 +326,44 @@
]
},
"modules": {
"localforage": "1.10.0",
"mime-db": "1.52.0"
"debug": "4.3.4",
"dotenv": "16.4.5",
"function-bind": "1.1.2",
"hasown": "2.0.2",
"import-in-the-middle": "1.7.1",
"is-core-module": "2.13.1",
"mime-db": "1.52.0",
"module-details-from-path": "1.0.3",
"opentelemetry-instrumentation-fetch-node": "1.2.0",
"require-in-the-middle": "7.3.0",
"resolve": "1.22.8",
"semver": "7.6.0",
"shimmer": "1.2.1",
"supports-color": "5.5.0",
"yallist": "4.0.0"
},
"platform": "node",
"request": {
"cookies": {},
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-US,en;q=0.5",
"cache-control": "no-cache",
"connection": "keep-alive",
"dnt": "1",
"host": "localhost:3030",
"pragma": "no-cache",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"user-agent": "[[user-agent]]"
},
"method": "GET",
"url": "http://localhost:3030/test-error"
Comment on lines +350 to +351
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing in all v7 files.

},
"sdk": {
"integrations": [
"InboundFilters",
Expand All @@ -357,28 +372,38 @@
"RequestData",
"Console",
"Http",
"Undici",
"NodeFetch",
"OnUncaughtException",
"OnUnhandledRejection",
"ContextLines",
"LocalVariables",
"LocalVariablesAsync",
"Context",
"Modules",
"Hapi"
"Express",
"Fastify",
"Graphql",
"Mongo",
"Mongoose",
"Mysql",
"Mysql2",
"Redis",
"Postgres",
"Nest",
"Hapi",
"Koa",
"Connect"
],
"name": "sentry.javascript.node",
"packages": [
{
"name": "npm:@sentry/node",
"version": "7.113.0"
"version": "8.0.0-beta.6"
}
],
"version": "7.113.0"
"version": "8.0.0-beta.6"
},
"server_name": "D9M3PY4LQ7.local",
"tags": {
"transaction": "/test-error"
},
"timestamp": "[[timestamp]]"
"timestamp": "[[timestamp]]",
"transaction": "GET /test-error"
}
]
Loading