1- import type {
2- ClientOptions ,
3- CustomSamplingContext ,
4- Integration ,
5- IntegrationClass ,
6- Options ,
7- SamplingContext ,
8- TransactionContext ,
9- } from '@sentry/types' ;
10- import { dynamicRequire , isNaN , isNodeEnv , loadModule , logger } from '@sentry/utils' ;
1+ import type { ClientOptions , CustomSamplingContext , Options , SamplingContext , TransactionContext } from '@sentry/types' ;
2+ import { isNaN , logger } from '@sentry/utils' ;
113
12- import type { Hub } from '..' ;
13- import { getMainCarrier } from '..' ;
14- import { registerErrorInstrumentation } from './errors' ;
4+ import type { Hub } from '../' ;
5+ import { getMainCarrier } from '../' ;
156import { IdleTransaction } from './idletransaction' ;
167import { Transaction } from './transaction' ;
178import { hasTracingEnabled } from './utils' ;
@@ -220,9 +211,9 @@ export function startIdleTransaction(
220211}
221212
222213/**
223- * @private
214+ * Adds tracing extensions to the global hub.
224215 */
225- export function _addTracingExtensions ( ) : void {
216+ export function addTracingExtensions ( ) : void {
226217 const carrier = getMainCarrier ( ) ;
227218 if ( ! carrier . __SENTRY__ ) {
228219 return ;
@@ -235,70 +226,3 @@ export function _addTracingExtensions(): void {
235226 carrier . __SENTRY__ . extensions . traceHeaders = traceHeaders ;
236227 }
237228}
238-
239- /**
240- * @private
241- */
242- function _autoloadDatabaseIntegrations ( ) : void {
243- const carrier = getMainCarrier ( ) ;
244- if ( ! carrier . __SENTRY__ ) {
245- return ;
246- }
247-
248- const packageToIntegrationMapping : Record < string , ( ) => Integration > = {
249- mongodb ( ) {
250- const integration = dynamicRequire ( module , './integrations/node/mongo' ) as {
251- Mongo : IntegrationClass < Integration > ;
252- } ;
253- return new integration . Mongo ( ) ;
254- } ,
255- mongoose ( ) {
256- const integration = dynamicRequire ( module , './integrations/node/mongo' ) as {
257- Mongo : IntegrationClass < Integration > ;
258- } ;
259- return new integration . Mongo ( { mongoose : true } ) ;
260- } ,
261- mysql ( ) {
262- const integration = dynamicRequire ( module , './integrations/node/mysql' ) as {
263- Mysql : IntegrationClass < Integration > ;
264- } ;
265- return new integration . Mysql ( ) ;
266- } ,
267- pg ( ) {
268- const integration = dynamicRequire ( module , './integrations/node/postgres' ) as {
269- Postgres : IntegrationClass < Integration > ;
270- } ;
271- return new integration . Postgres ( ) ;
272- } ,
273- } ;
274-
275- const mappedPackages = Object . keys ( packageToIntegrationMapping )
276- . filter ( moduleName => ! ! loadModule ( moduleName ) )
277- . map ( pkg => {
278- try {
279- return packageToIntegrationMapping [ pkg ] ( ) ;
280- } catch ( e ) {
281- return undefined ;
282- }
283- } )
284- . filter ( p => p ) as Integration [ ] ;
285-
286- if ( mappedPackages . length > 0 ) {
287- carrier . __SENTRY__ . integrations = [ ...( carrier . __SENTRY__ . integrations || [ ] ) , ...mappedPackages ] ;
288- }
289- }
290-
291- /**
292- * This patches the global object and injects the Tracing extensions methods
293- */
294- export function addExtensionMethods ( ) : void {
295- _addTracingExtensions ( ) ;
296-
297- // Detect and automatically load specified integrations.
298- if ( isNodeEnv ( ) ) {
299- _autoloadDatabaseIntegrations ( ) ;
300- }
301-
302- // If an error happens globally, we should make sure transaction status is set to error.
303- registerErrorInstrumentation ( ) ;
304- }
0 commit comments