UNPKG

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