MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / get

Function get

packages/core/src/tracing/openai/index.ts:242–268  ·  view source on GitHub ↗
(obj: object, prop: string)

Source from the content-addressed store, hash-verified

240function createDeepProxy<T extends object>(target: T, currentPath = '', options: OpenAiOptions): T {
241 return new Proxy(target, {
242 get(obj: object, prop: string): unknown {
243 const value = (obj as Record<string, unknown>)[prop];
244 const methodPath = buildMethodPath(currentPath, String(prop));
245
246 const instrumentedMethod = OPENAI_METHOD_REGISTRY[methodPath as keyof typeof OPENAI_METHOD_REGISTRY];
247 if (typeof value === 'function' && instrumentedMethod) {
248 return instrumentMethod(
249 value as (...args: unknown[]) => Promise<unknown>,
250 methodPath,
251 instrumentedMethod,
252 obj,
253 options,
254 );
255 }
256
257 if (typeof value === 'function') {
258 // Bind non-instrumented functions to preserve the original `this` context,
259 // which is required for accessing private class fields (e.g. #baseURL) in OpenAI SDK v5.
260 return value.bind(obj);
261 }
262
263 if (value && typeof value === 'object') {
264 return createDeepProxy(value, methodPath, options);
265 }
266
267 return value;
268 },
269 }) as T;
270}
271

Callers

nothing calls this directly

Calls 4

buildMethodPathFunction · 0.90
bindMethod · 0.80
instrumentMethodFunction · 0.70
createDeepProxyFunction · 0.70

Tested by

no test coverage detected