-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsdk.ts
More file actions
24 lines (21 loc) · 1021 Bytes
/
sdk.ts
File metadata and controls
24 lines (21 loc) · 1021 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
import type { Client } from '@sentry/core';
import { applySdkMetadata } 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.
*
* In general, it is recommended to initialize Sentry via the `sentry()` middleware, as it sets up everything by default and calls `init` internally.
*
* When manually calling `init`, add the `honoIntegration` to the `integrations` array to set up the Hono integration.
*/
export function init(options: HonoNodeOptions): Client | undefined {
applySdkMetadata(options, 'hono', ['hono', 'node']);
// Remove Hono from the SDK defaults to prevent double instrumentation: @sentry/node
const filteredOptions: HonoNodeOptions = {
...options,
integrations: buildFilteredIntegrations(options.integrations, false),
};
return initNode(filteredOptions);
}