index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. Object.defineProperty(exports, '__esModule', { value: true });
  2. const debugBuild = require('../debug-build.js');
  3. const logger = require('../logger.js');
  4. const console = require('./console.js');
  5. const dom = require('./dom.js');
  6. const fetch = require('./fetch.js');
  7. const globalError = require('./globalError.js');
  8. const globalUnhandledRejection = require('./globalUnhandledRejection.js');
  9. const history = require('./history.js');
  10. const xhr = require('./xhr.js');
  11. // 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.
  12. /**
  13. * Add handler that will be called when given type of instrumentation triggers.
  14. * Use at your own risk, this might break without changelog notice, only used internally.
  15. * @hidden
  16. * @deprecated Use the proper function per instrumentation type instead!
  17. */
  18. function addInstrumentationHandler(type, callback) {
  19. switch (type) {
  20. case 'console':
  21. return console.addConsoleInstrumentationHandler(callback);
  22. case 'dom':
  23. return dom.addClickKeypressInstrumentationHandler(callback);
  24. case 'xhr':
  25. return xhr.addXhrInstrumentationHandler(callback);
  26. case 'fetch':
  27. return fetch.addFetchInstrumentationHandler(callback);
  28. case 'history':
  29. return history.addHistoryInstrumentationHandler(callback);
  30. case 'error':
  31. return globalError.addGlobalErrorInstrumentationHandler(callback);
  32. case 'unhandledrejection':
  33. return globalUnhandledRejection.addGlobalUnhandledRejectionInstrumentationHandler(callback);
  34. default:
  35. debugBuild.DEBUG_BUILD && logger.logger.warn('unknown instrumentation type:', type);
  36. }
  37. }
  38. exports.addConsoleInstrumentationHandler = console.addConsoleInstrumentationHandler;
  39. exports.addClickKeypressInstrumentationHandler = dom.addClickKeypressInstrumentationHandler;
  40. exports.addFetchInstrumentationHandler = fetch.addFetchInstrumentationHandler;
  41. exports.addGlobalErrorInstrumentationHandler = globalError.addGlobalErrorInstrumentationHandler;
  42. exports.addGlobalUnhandledRejectionInstrumentationHandler = globalUnhandledRejection.addGlobalUnhandledRejectionInstrumentationHandler;
  43. exports.addHistoryInstrumentationHandler = history.addHistoryInstrumentationHandler;
  44. exports.SENTRY_XHR_DATA_KEY = xhr.SENTRY_XHR_DATA_KEY;
  45. exports.addXhrInstrumentationHandler = xhr.addXhrInstrumentationHandler;
  46. exports.addInstrumentationHandler = addInstrumentationHandler;
  47. //# sourceMappingURL=index.js.map