-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsdk.ts
More file actions
27 lines (23 loc) · 1018 Bytes
/
sdk.ts
File metadata and controls
27 lines (23 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import type { Client } from '@sentry/core';
import { applySdkMetadata, debug, getClient } from '@sentry/core';
import { init as initNode } from '@sentry/node';
import type { HonoNodeOptions } from './middleware';
import { buildFilteredIntegrations } from '../shared/buildFilteredIntegrations';
/**
* Initializes Sentry for Hono running in a Node runtime environment.
*
* This function should be called in an `instrument.ts` file loaded via `--import` to set up Sentry globally for the application.
*/
export function init(options: HonoNodeOptions): Client | undefined {
const existingClient = getClient();
if (existingClient) {
existingClient.getOptions().debug && debug.log('Sentry is already initialized, skipping re-initialization.');
return existingClient;
}
applySdkMetadata(options, 'hono', ['hono', 'node']);
const filteredOptions: HonoNodeOptions = {
...options,
integrations: buildFilteredIntegrations(options.integrations, false),
};
return initNode(filteredOptions);
}