Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fill(xhr, 'onreadystatechange', function(original: WrappedFunction): Function {
const wrapOptions = {
mechanism: {
data: {
function: 'onreadystatechange',
handler: getFunctionName(original),
},
handled: true,
type: 'instrument',
},
};
// If Instrument integration has been called before TryCatch, get the name of original function
if (original.__sentry_original__) {
wrapOptions.mechanism.data.handler = getFunctionName(original.__sentry_original__);
}
// Otherwise wrap directly
return wrap(original, wrapOptions);
});
}
fill(xhr, 'onreadystatechange', function(original: WrappedFunction): Function {
const wrapOptions = {
mechanism: {
data: {
function: 'onreadystatechange',
handler: getFunctionName(original),
},
handled: true,
type: 'instrument',
},
};
// If Instrument integration has been called before TryCatch, get the name of original function
if (original.__sentry_original__) {
wrapOptions.mechanism.data.handler = getFunctionName(original.__sentry_original__);
}
// Otherwise wrap directly
return wrap(original, wrapOptions);
});
}
type: 'instrument',
},
});
}
} catch (err) {
// can sometimes get 'Permission denied to access property "handle Event'
}
return original.call(
this,
eventName,
wrap((fn as any) as WrappedFunction, {
mechanism: {
data: {
function: 'addEventListener',
handler: getFunctionName(fn),
target,
},
handled: true,
type: 'instrument',
},
}),
options,
);
};
});
fill(this, prop, original =>
wrap(original, {
mechanism: {
data: {
function: prop,
handler: getFunctionName(original),
},
handled: true,
type: 'instrument',
},
}),
);
return function(this: any, callback: () => void): () => void {
return original(
wrap(callback, {
mechanism: {
data: {
function: 'requestAnimationFrame',
handler: getFunctionName(original),
},
handled: true,
type: 'instrument',
},
}),
);
};
}
return function(this: any, ...args: any[]): number {
const originalCallback = args[0];
args[0] = wrap(originalCallback, {
mechanism: {
data: { function: getFunctionName(original) },
handled: true,
type: 'instrument',
},
});
return original.apply(this, args);
};
}