index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { DEBUG_BUILD } from '../debug-build.js';
  2. import { logger } from '../logger.js';
  3. import { addConsoleInstrumentationHandler } from './console.js';
  4. export { addConsoleInstrumentationHandler } from './console.js';
  5. import { addClickKeypressInstrumentationHandler } from './dom.js';
  6. export { addClickKeypressInstrumentationHandler } from './dom.js';
  7. import { addFetchInstrumentationHandler } from './fetch.js';
  8. export { addFetchInstrumentationHandler } from './fetch.js';
  9. import { addGlobalErrorInstrumentationHandler } from './globalError.js';
  10. export { addGlobalErrorInstrumentationHandler } from './globalError.js';
  11. import { addGlobalUnhandledRejectionInstrumentationHandler } from './globalUnhandledRejection.js';
  12. export { addGlobalUnhandledRejectionInstrumentationHandler } from './globalUnhandledRejection.js';
  13. import { addHistoryInstrumentationHandler } from './history.js';
  14. export { addHistoryInstrumentationHandler } from './history.js';
  15. import { addXhrInstrumentationHandler } from './xhr.js';
  16. export { SENTRY_XHR_DATA_KEY, addXhrInstrumentationHandler } from './xhr.js';
  17. // TODO(v8): Consider moving this file (or at least parts of it) into the browser package. The registered handlers are mostly non-generic and we risk leaking runtime specific code into generic packages.
  18. /**
  19. * Add handler that will be called when given type of instrumentation triggers.
  20. * Use at your own risk, this might break without changelog notice, only used internally.
  21. * @hidden
  22. * @deprecated Use the proper function per instrumentation type instead!
  23. */
  24. function addInstrumentationHandler(type, callback) {
  25. switch (type) {
  26. case 'console':
  27. return addConsoleInstrumentationHandler(callback);
  28. case 'dom':
  29. return addClickKeypressInstrumentationHandler(callback);
  30. case 'xhr':
  31. return addXhrInstrumentationHandler(callback);
  32. case 'fetch':
  33. return addFetchInstrumentationHandler(callback);
  34. case 'history':
  35. return addHistoryInstrumentationHandler(callback);
  36. case 'error':
  37. return addGlobalErrorInstrumentationHandler(callback);
  38. case 'unhandledrejection':
  39. return addGlobalUnhandledRejectionInstrumentationHandler(callback);
  40. default:
  41. DEBUG_BUILD && logger.warn('unknown instrumentation type:', type);
  42. }
  43. }
  44. export { addInstrumentationHandler };
  45. //# sourceMappingURL=index.js.map