Skip to content

Commit 3a3e6f5

Browse files
authored
Merge pull request #28 from getsentry/sig/hapi-v8
feat: Update hapi to v8.0.0-rc.1
2 parents 6dbfb04 + 20bd14b commit 3a3e6f5

17 files changed

+2798
-1884
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.9.2",
2020
"dotenv": "^16.4.5"
2121
}
2222
}

apps/hapi/src/app.ts

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
1-
const Sentry = require('@sentry/node');
1+
import './instrument';
2+
import * as Sentry from '@sentry/node';
23
import Hapi from '@hapi/hapi';
3-
import dotenv from 'dotenv';
4-
5-
dotenv.config({ path: './../../.env' });
6-
7-
const server = Hapi.server({
8-
port: 3030,
9-
host: 'localhost',
10-
});
114

125
declare global {
136
namespace globalThis {
147
var transactionIds: string[];
158
}
169
}
1710

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-
2811
const init = async () => {
12+
const server = Hapi.server({
13+
port: 3030,
14+
host: 'localhost',
15+
});
16+
2917
server.route({
3018
method: 'GET',
3119
path: '/test-success',
3220
handler: function (request, h) {
33-
console.log('test console');
3421
return { version: 'v1' };
3522
},
3623
});
@@ -136,10 +123,11 @@ const init = async () => {
136123
return { exceptionId };
137124
},
138125
});
139-
};
140126

141-
(async () => {
142-
init();
127+
// @ts-ignore
128+
await Sentry.setupHapiErrorHandler(server);
143129
await server.start();
144130
console.log('Server running on %s', server.info.uri);
145-
})();
131+
};
132+
133+
init();

apps/hapi/src/instrument.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as Sentry from '@sentry/node';
2+
import dotenv from 'dotenv';
3+
4+
dotenv.config({ path: './../../.env' });
5+
6+
Sentry.init({
7+
environment: 'qa', // dynamic sampling bias to keep transactions
8+
dsn: process.env.SENTRY_DSN,
9+
includeLocalVariables: true,
10+
tunnel: `http://localhost:3031/`, // proxy server
11+
tracesSampleRate: 1,
12+
});

0 commit comments

Comments
 (0)