Skip to content

Commit

Permalink
feat(bun): Export bunServerIntegration() (#10439)
Browse files Browse the repository at this point in the history
And deprecate `new BunServer()`
  • Loading branch information
mydea committed Jan 31, 2024
1 parent 3e148e6 commit 793ad71
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ export {

import { Integrations as CoreIntegrations } from '@sentry/core';
import { Integrations as NodeIntegrations } from '@sentry/node';

import * as BunIntegrations from './integrations';
import { BunServer } from './integrations/bunserver';
export { bunServerIntegration } from './integrations/bunserver';

const INTEGRATIONS = {
// eslint-disable-next-line deprecation/deprecation
...CoreIntegrations,
// eslint-disable-next-line deprecation/deprecation
...NodeIntegrations,
...BunIntegrations,
BunServer,
};

export { INTEGRATIONS as Integrations };
7 changes: 6 additions & 1 deletion packages/bun/src/integrations/bunserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
captureException,
continueTrace,
convertIntegrationFnToClass,
defineIntegration,
getCurrentScope,
runWithAsyncContext,
setHttpStatus,
Expand All @@ -15,7 +16,7 @@ import { getSanitizedUrlString, parseUrl } from '@sentry/utils';

const INTEGRATION_NAME = 'BunServer';

const bunServerIntegration = (() => {
const _bunServerIntegration = (() => {
return {
name: INTEGRATION_NAME,
setupOnce() {
Expand All @@ -24,8 +25,12 @@ const bunServerIntegration = (() => {
};
}) satisfies IntegrationFn;

export const bunServerIntegration = defineIntegration(_bunServerIntegration);

/**
* Instruments `Bun.serve` to automatically create transactions and capture errors.
*
* @deprecated Use `bunServerIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const BunServer = convertIntegrationFnToClass(INTEGRATION_NAME, bunServerIntegration);
Expand Down
1 change: 0 additions & 1 deletion packages/bun/src/integrations/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/bun/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import type { Integration, Options } from '@sentry/types';

import { BunClient } from './client';
import { BunServer } from './integrations';
import { bunServerIntegration } from './integrations/bunserver';
import { makeFetchTransport } from './transports';
import type { BunOptions } from './types';

Expand All @@ -41,7 +41,7 @@ export const defaultIntegrations = [
nodeContextIntegration(),
modulesIntegration(),
// Bun Specific
new BunServer(),
bunServerIntegration(),
];

/** Get the default integrations for the Bun SDK. */
Expand Down

0 comments on commit 793ad71

Please sign in to comment.