@@ -32,6 +32,14 @@ const BUNDLE_PATHS: Record<string, Record<string, string>> = {
32
32
bundle_es6 : 'build/bundles/bundle.tracing.js' ,
33
33
bundle_es6_min : 'build/bundles/bundle.tracing.min.js' ,
34
34
} ,
35
+ integrations : {
36
+ cjs : 'build/npm/cjs/index.js' ,
37
+ esm : 'build/npm/esm/index.js' ,
38
+ bundle_es5 : 'build/bundles/[INTEGRATION_NAME].es5.js' ,
39
+ bundle_es5_min : 'build/bundles/[INTEGRATION_NAME].es5.min.js' ,
40
+ bundle_es6 : 'build/bundles/[INTEGRATION_NAME].js' ,
41
+ bundle_es6_min : 'build/bundles/[INTEGRATION_NAME].min.js' ,
42
+ } ,
35
43
} ;
36
44
37
45
/*
@@ -78,6 +86,7 @@ function generateSentryAlias(): Record<string, string> {
78
86
79
87
class SentryScenarioGenerationPlugin {
80
88
public requiresTracing : boolean = false ;
89
+ public requiredIntegrations : string [ ] = [ ] ;
81
90
82
91
private _name : string = 'SentryScenarioGenerationPlugin' ;
83
92
@@ -89,18 +98,24 @@ class SentryScenarioGenerationPlugin {
89
98
// To help Webpack resolve Sentry modules in `import` statements in cases where they're provided in bundles rather than in `node_modules`
90
99
'@sentry/browser' : 'Sentry' ,
91
100
'@sentry/tracing' : 'Sentry' ,
101
+ '@sentry/integrations' : 'Sentry.Integrations' ,
92
102
}
93
103
: { } ;
94
104
95
- // Checking if the current scenario has imported `@sentry/tracing`.
105
+ // Checking if the current scenario has imported `@sentry/tracing` or `@sentry/integrations` .
96
106
compiler . hooks . normalModuleFactory . tap ( this . _name , factory => {
97
107
factory . hooks . parser . for ( 'javascript/auto' ) . tap ( this . _name , parser => {
98
108
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
99
- parser . hooks . import . tap ( this . _name , ( _statement : unknown , source : string ) => {
100
- if ( source === '@sentry/tracing' ) {
101
- this . requiresTracing = true ;
102
- }
103
- } ) ;
109
+ parser . hooks . import . tap (
110
+ this . _name ,
111
+ ( statement : { specifiers : [ { imported : { name : string } } ] } , source : string ) => {
112
+ if ( source === '@sentry/tracing' ) {
113
+ this . requiresTracing = true ;
114
+ } else if ( source === '@sentry/integrations' ) {
115
+ this . requiredIntegrations . push ( statement . specifiers [ 0 ] . imported . name . toLowerCase ( ) ) ;
116
+ }
117
+ } ,
118
+ ) ;
104
119
} ) ;
105
120
} ) ;
106
121
@@ -113,6 +128,18 @@ class SentryScenarioGenerationPlugin {
113
128
src : path . resolve ( PACKAGES_DIR , bundleName , BUNDLE_PATHS [ bundleName ] [ bundleKey ] ) ,
114
129
} ) ;
115
130
131
+ this . requiredIntegrations . forEach ( integration => {
132
+ const integrationObject = createHtmlTagObject ( 'script' , {
133
+ src : path . resolve (
134
+ PACKAGES_DIR ,
135
+ 'integrations' ,
136
+ BUNDLE_PATHS [ 'integrations' ] [ bundleKey ] . replace ( '[INTEGRATION_NAME]' , integration ) ,
137
+ ) ,
138
+ } ) ;
139
+
140
+ data . assetTags . scripts . unshift ( integrationObject ) ;
141
+ } ) ;
142
+
116
143
data . assetTags . scripts . unshift ( bundleObject ) ;
117
144
}
118
145
0 commit comments