UNPKG

@sentry/core

Version:
47 lines (40 loc) 1.6 kB
import { forEachEnvelopeItem } from '@sentry/utils'; import { defineIntegration } from '../integration.js'; import { stripMetadataFromStackFrames, addMetadataToStackFrames } from '../metadata.js'; const INTEGRATION_NAME = 'ModuleMetadata'; const _moduleMetadataIntegration = (() => { return { name: INTEGRATION_NAME, setup(client) { // We need to strip metadata from stack frames before sending them to Sentry since these are client side only. client.on('beforeEnvelope', envelope => { forEachEnvelopeItem(envelope, (item, type) => { if (type === 'event') { const event = Array.isArray(item) ? (item )[1] : undefined; if (event) { stripMetadataFromStackFrames(event); item[1] = event; } } }); }); }, processEvent(event, _hint, client) { const stackParser = client.getOptions().stackParser; addMetadataToStackFrames(stackParser, event); return event; }, }; }) ; /** * Adds module metadata to stack frames. * * Metadata can be injected by the Sentry bundler plugins using the `_experiments.moduleMetadata` config option. * * When this integration is added, the metadata passed to the bundler plugin is added to the stack frames of all events * under the `module_metadata` property. This can be used to help in tagging or routing of events from different teams * our sources */ const moduleMetadataIntegration = defineIntegration(_moduleMetadataIntegration); export { moduleMetadataIntegration }; //# sourceMappingURL=metadata.js.map