Skip to content

Commit e1d6b87

Browse files
committed
hapi v8
1 parent d9b30b8 commit e1d6b87

15 files changed

+1491
-618
lines changed

apps/hapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"dependencies": {
1818
"@hapi/hapi": "21.3.9",
19-
"@sentry/node": "7.113.0",
19+
"@sentry/node": "8.0.0-beta.6",
2020
"dotenv": "^16.4.5"
2121
}
2222
}

apps/hapi/src/app.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
const Sentry = require('@sentry/node');
2-
import Hapi from '@hapi/hapi';
1+
import * as Sentry from '@sentry/node';
32
import dotenv from 'dotenv';
43

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

6+
Sentry.init({
7+
environment: 'qa', // dynamic sampling bias to keep transactions
8+
dsn: process.env.SENTRY_DSN,
9+
includeLocalVariables: true,
10+
debug: true,
11+
tunnel: `http://localhost:3031/`, // proxy server
12+
tracesSampleRate: 1,
13+
});
14+
15+
import Hapi from '@hapi/hapi';
16+
17+
dotenv.config({ path: './../../.env' });
18+
719
const server = Hapi.server({
820
port: 3030,
921
host: 'localhost',
@@ -15,22 +27,11 @@ declare global {
1527
}
1628
}
1729

18-
Sentry.init({
19-
environment: 'qa', // dynamic sampling bias to keep transactions
20-
dsn: process.env.SENTRY_DSN,
21-
includeLocalVariables: true,
22-
integrations: [Sentry.hapiIntegration({ server })],
23-
debug: true,
24-
tunnel: `http://localhost:3031/`, // proxy server
25-
tracesSampleRate: 1,
26-
});
27-
2830
const init = async () => {
2931
server.route({
3032
method: 'GET',
3133
path: '/test-success',
3234
handler: function (request, h) {
33-
console.log('test console');
3435
return { version: 'v1' };
3536
},
3637
});

payload-files/hapi/_test-error--event.json

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"event_id": "[[ID1]]",
55
"sdk": {
66
"name": "sentry.javascript.node",
7-
"version": "7.113.0"
7+
"version": "8.0.0-beta.6"
88
},
99
"sent_at": "[[ISODateString]]",
1010
"trace": {
@@ -13,7 +13,7 @@
1313
"sample_rate": "1",
1414
"sampled": "true",
1515
"trace_id": "[[ID2]]",
16-
"transaction": "/test-error"
16+
"transaction": "GET /test-error"
1717
}
1818
},
1919
{
@@ -26,18 +26,6 @@
2626
"level": "log",
2727
"message": "Server running on http://localhost:3030",
2828
"timestamp": "[[timestamp]]"
29-
},
30-
{
31-
"category": "console",
32-
"level": "log",
33-
"message": "test console",
34-
"timestamp": "[[timestamp]]"
35-
},
36-
{
37-
"category": "console",
38-
"level": "log",
39-
"message": "test console",
40-
"timestamp": "[[timestamp]]"
4129
}
4230
],
4331
"contexts": {
@@ -70,13 +58,6 @@
7058
"version": "v20.12.1"
7159
},
7260
"trace": {
73-
"data": {
74-
"sentry.op": "hapi.request",
75-
"sentry.origin": "manual",
76-
"sentry.sample_rate": 1
77-
},
78-
"op": "hapi.request",
79-
"origin": "manual",
8061
"span_id": "[[ID3]]",
8162
"trace_id": "[[ID2]]"
8263
}
@@ -179,7 +160,7 @@
179160
"filename": "[[FILENAME3]]",
180161
"function": "handler",
181162
"in_app": true,
182-
"lineno": 71,
163+
"lineno": 72,
183164
"module": "app",
184165
"post_context": [
185166
" var exceptionId;",
@@ -233,7 +214,7 @@
233214
"colno": 71,
234215
"context_line": " step((generator = generator.apply(thisArg, _arguments || [])).next());",
235216
"filename": "[[FILENAME3]]",
236-
"function": "<anonymous>",
217+
"function": "?",
237218
"in_app": true,
238219
"lineno": 8,
239220
"module": "app",
@@ -314,9 +295,9 @@
314295
"colno": 71,
315296
"context_line": " exceptionId = Sentry.captureException(new Error('This is an error'));",
316297
"filename": "[[FILENAME3]]",
317-
"function": "<anonymous>",
298+
"function": "?",
318299
"in_app": true,
319-
"lineno": 76,
300+
"lineno": 77,
320301
"module": "app",
321302
"post_context": [
322303
" return [4 /*yield*/, Sentry.flush(2000)];",
@@ -345,10 +326,44 @@
345326
]
346327
},
347328
"modules": {
348-
"localforage": "1.10.0",
349-
"mime-db": "1.52.0"
329+
"debug": "4.3.4",
330+
"dotenv": "16.4.5",
331+
"function-bind": "1.1.2",
332+
"hasown": "2.0.2",
333+
"import-in-the-middle": "1.7.1",
334+
"is-core-module": "2.13.1",
335+
"mime-db": "1.52.0",
336+
"module-details-from-path": "1.0.3",
337+
"opentelemetry-instrumentation-fetch-node": "1.2.0",
338+
"require-in-the-middle": "7.3.0",
339+
"resolve": "1.22.8",
340+
"semver": "7.6.0",
341+
"shimmer": "1.2.1",
342+
"supports-color": "5.5.0",
343+
"yallist": "4.0.0"
350344
},
351345
"platform": "node",
346+
"request": {
347+
"cookies": {},
348+
"headers": {
349+
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
350+
"accept-encoding": "gzip, deflate, br",
351+
"accept-language": "en-US,en;q=0.5",
352+
"cache-control": "no-cache",
353+
"connection": "keep-alive",
354+
"dnt": "1",
355+
"host": "localhost:3030",
356+
"pragma": "no-cache",
357+
"sec-fetch-dest": "document",
358+
"sec-fetch-mode": "navigate",
359+
"sec-fetch-site": "none",
360+
"sec-fetch-user": "?1",
361+
"upgrade-insecure-requests": "1",
362+
"user-agent": "[[user-agent]]"
363+
},
364+
"method": "GET",
365+
"url": "http://localhost:3030/test-error"
366+
},
352367
"sdk": {
353368
"integrations": [
354369
"InboundFilters",
@@ -357,28 +372,38 @@
357372
"RequestData",
358373
"Console",
359374
"Http",
360-
"Undici",
375+
"NodeFetch",
361376
"OnUncaughtException",
362377
"OnUnhandledRejection",
363378
"ContextLines",
364-
"LocalVariables",
379+
"LocalVariablesAsync",
365380
"Context",
366381
"Modules",
367-
"Hapi"
382+
"Express",
383+
"Fastify",
384+
"Graphql",
385+
"Mongo",
386+
"Mongoose",
387+
"Mysql",
388+
"Mysql2",
389+
"Redis",
390+
"Postgres",
391+
"Nest",
392+
"Hapi",
393+
"Koa",
394+
"Connect"
368395
],
369396
"name": "sentry.javascript.node",
370397
"packages": [
371398
{
372399
"name": "npm:@sentry/node",
373-
"version": "7.113.0"
400+
"version": "8.0.0-beta.6"
374401
}
375402
],
376-
"version": "7.113.0"
403+
"version": "8.0.0-beta.6"
377404
},
378405
"server_name": "D9M3PY4LQ7.local",
379-
"tags": {
380-
"transaction": "/test-error"
381-
},
382-
"timestamp": "[[timestamp]]"
406+
"timestamp": "[[timestamp]]",
407+
"transaction": "GET /test-error"
383408
}
384409
]

0 commit comments

Comments
 (0)