metadata.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Object.defineProperty(exports, '__esModule', { value: true });
  2. const utils = require('@sentry/utils');
  3. const integration = require('../integration.js');
  4. const metadata = require('../metadata.js');
  5. const INTEGRATION_NAME = 'ModuleMetadata';
  6. const _moduleMetadataIntegration = (() => {
  7. return {
  8. name: INTEGRATION_NAME,
  9. // TODO v8: Remove this
  10. setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
  11. setup(client) {
  12. if (typeof client.on !== 'function') {
  13. return;
  14. }
  15. // We need to strip metadata from stack frames before sending them to Sentry since these are client side only.
  16. client.on('beforeEnvelope', envelope => {
  17. utils.forEachEnvelopeItem(envelope, (item, type) => {
  18. if (type === 'event') {
  19. const event = Array.isArray(item) ? (item )[1] : undefined;
  20. if (event) {
  21. metadata.stripMetadataFromStackFrames(event);
  22. item[1] = event;
  23. }
  24. }
  25. });
  26. });
  27. },
  28. processEvent(event, _hint, client) {
  29. const stackParser = client.getOptions().stackParser;
  30. metadata.addMetadataToStackFrames(stackParser, event);
  31. return event;
  32. },
  33. };
  34. }) ;
  35. const moduleMetadataIntegration = integration.defineIntegration(_moduleMetadataIntegration);
  36. /**
  37. * Adds module metadata to stack frames.
  38. *
  39. * Metadata can be injected by the Sentry bundler plugins using the `_experiments.moduleMetadata` config option.
  40. *
  41. * When this integration is added, the metadata passed to the bundler plugin is added to the stack frames of all events
  42. * under the `module_metadata` property. This can be used to help in tagging or routing of events from different teams
  43. * our sources
  44. *
  45. * @deprecated Use `moduleMetadataIntegration()` instead.
  46. */
  47. // eslint-disable-next-line deprecation/deprecation
  48. const ModuleMetadata = integration.convertIntegrationFnToClass(
  49. INTEGRATION_NAME,
  50. moduleMetadataIntegration,
  51. )
  52. ;
  53. exports.ModuleMetadata = ModuleMetadata;
  54. exports.moduleMetadataIntegration = moduleMetadataIntegration;
  55. //# sourceMappingURL=metadata.js.map