Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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.9.2",
"dotenv": "^16.4.5"
}
}
36 changes: 12 additions & 24 deletions apps/hapi/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
const Sentry = require('@sentry/node');
import './instrument';
import * as Sentry from '@sentry/node';
import Hapi from '@hapi/hapi';
import dotenv from 'dotenv';

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

const server = Hapi.server({
port: 3030,
host: 'localhost',
});

declare global {
namespace globalThis {
var transactionIds: string[];
}
}

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 () => {
const server = Hapi.server({
port: 3030,
host: 'localhost',
});

server.route({
method: 'GET',
path: '/test-success',
handler: function (request, h) {
console.log('test console');
return { version: 'v1' };
},
});
Expand Down Expand Up @@ -136,10 +123,11 @@ const init = async () => {
return { exceptionId };
},
});
};

(async () => {
init();
// @ts-ignore
await Sentry.setupHapiErrorHandler(server);
await server.start();
console.log('Server running on %s', server.info.uri);
})();
};

init();
12 changes: 12 additions & 0 deletions apps/hapi/src/instrument.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
});
Loading