File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
packages/node/src/integrations/tracing/openai Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -83,12 +83,21 @@ export class SentryOpenAiInstrumentation extends InstrumentationBase<Instrumenta
8383 }
8484 }
8585
86- const isESM = Object . prototype . toString . call ( exports ) === '[object Module]' ;
87- if ( isESM ) {
86+ // Constructor replacement - handle read-only properties
87+ // The OpenAI property might have only a getter, so use defineProperty
88+ // Constructor replacement works the same for both ESM and CJS modules
89+ // We can directly assign to exports.OpenAI in both module systems
90+ try {
8891 exports . OpenAI = WrappedOpenAI ;
89- return exports ;
92+ } catch ( error ) {
93+ // If direct assignment fails, override the property descriptor
94+ Object . defineProperty ( exports , 'OpenAI' , {
95+ value : WrappedOpenAI ,
96+ writable : true ,
97+ configurable : true ,
98+ enumerable : true ,
99+ } ) ;
90100 }
91-
92- return { ...exports , OpenAI : WrappedOpenAI } ;
101+ return exports ;
93102 }
94103}
You can’t perform that action at this time.
0 commit comments