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
83
83
}
84
84
}
85
85
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 {
88
91
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
+ } ) ;
90
100
}
91
-
92
- return { ...exports , OpenAI : WrappedOpenAI } ;
101
+ return exports ;
93
102
}
94
103
}
You can’t perform that action at this time.
0 commit comments