UNPKG

2.62 kBJavaScriptView Raw
1import { __assign, __extends } from "tslib";
2import { BaseClient, SDK_VERSION } from '@sentry/core';
3import { getGlobalObject, logger } from '@sentry/utils';
4import { BrowserBackend } from './backend';
5import { injectReportDialog } from './helpers';
6import { Breadcrumbs } from './integrations';
7/**
8 * The Sentry Browser SDK Client.
9 *
10 * @see BrowserOptions for documentation on configuration options.
11 * @see SentryClient for usage documentation.
12 */
13var BrowserClient = /** @class */ (function (_super) {
14 __extends(BrowserClient, _super);
15 /**
16 * Creates a new Browser SDK instance.
17 *
18 * @param options Configuration options for this SDK.
19 */
20 function BrowserClient(options) {
21 if (options === void 0) { options = {}; }
22 var _this = this;
23 options._metadata = options._metadata || {};
24 options._metadata.sdk = options._metadata.sdk || {
25 name: 'sentry.javascript.browser',
26 packages: [
27 {
28 name: 'npm:@sentry/browser',
29 version: SDK_VERSION,
30 },
31 ],
32 version: SDK_VERSION,
33 };
34 _this = _super.call(this, BrowserBackend, options) || this;
35 return _this;
36 }
37 /**
38 * Show a report dialog to the user to send feedback to a specific event.
39 *
40 * @param options Set individual options for the dialog
41 */
42 BrowserClient.prototype.showReportDialog = function (options) {
43 if (options === void 0) { options = {}; }
44 // doesn't work without a document (React Native)
45 var document = getGlobalObject().document;
46 if (!document) {
47 return;
48 }
49 if (!this._isEnabled()) {
50 logger.error('Trying to call showReportDialog with Sentry Client disabled');
51 return;
52 }
53 injectReportDialog(__assign(__assign({}, options), { dsn: options.dsn || this.getDsn() }));
54 };
55 /**
56 * @inheritDoc
57 */
58 BrowserClient.prototype._prepareEvent = function (event, scope, hint) {
59 event.platform = event.platform || 'javascript';
60 return _super.prototype._prepareEvent.call(this, event, scope, hint);
61 };
62 /**
63 * @inheritDoc
64 */
65 BrowserClient.prototype._sendEvent = function (event) {
66 var integration = this.getIntegration(Breadcrumbs);
67 if (integration) {
68 integration.addSentryBreadcrumb(event);
69 }
70 _super.prototype._sendEvent.call(this, event);
71 };
72 return BrowserClient;
73}(BaseClient));
74export { BrowserClient };
75//# sourceMappingURL=client.js.map
\No newline at end of file