UNPKG

@sentry/browser

Version:
84 lines (72 loc) 2.16 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const core = require('@sentry/core'); const eventbuilder = require('./eventbuilder.js'); const helpers = require('./helpers.js'); /** * Configuration options for the Sentry Browser SDK. * @see @sentry/core Options for more information. */ /** * The Sentry Browser SDK Client. * * @see BrowserOptions for documentation on configuration options. * @see SentryClient for usage documentation. */ class BrowserClient extends core.Client { /** * Creates a new Browser SDK instance. * * @param options Configuration options for this SDK. */ constructor(options) { const opts = { // We default this to true, as it is the safer scenario parentSpanIsAlwaysRootSpan: true, ...options, }; const sdkSource = helpers.WINDOW.SENTRY_SDK_SOURCE || core.getSDKSource(); core.applySdkMetadata(opts, 'browser', ['browser'], sdkSource); super(opts); if (opts.sendClientReports && helpers.WINDOW.document) { helpers.WINDOW.document.addEventListener('visibilitychange', () => { if (helpers.WINDOW.document.visibilityState === 'hidden') { this._flushOutcomes(); } }); } if (this._options.sendDefaultPii) { this.on('postprocessEvent', core.addAutoIpAddressToUser); this.on('beforeSendSession', core.addAutoIpAddressToSession); } } /** * @inheritDoc */ eventFromException(exception, hint) { return eventbuilder.eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace); } /** * @inheritDoc */ eventFromMessage( message, level = 'info', hint, ) { return eventbuilder.eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace); } /** * @inheritDoc */ _prepareEvent( event, hint, currentScope, isolationScope, ) { event.platform = event.platform || 'javascript'; return super._prepareEvent(event, hint, currentScope, isolationScope); } } exports.BrowserClient = BrowserClient; //# sourceMappingURL=client.js.map