UNPKG

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