UNPKG

1.18 kBJavaScriptView Raw
1Object.defineProperty(exports, '__esModule', { value: true });
2
3const utils = require('@sentry/utils');
4const hub = require('./hub.js');
5
6/** A class object that can instantiate Client objects. */
7
8/**
9 * Internal function to create a new SDK client instance. The client is
10 * installed and then bound to the current scope.
11 *
12 * @param clientClass The client class to instantiate.
13 * @param options Options to pass to the client.
14 */
15function initAndBind(
16 clientClass,
17 options,
18) {
19 if (options.debug === true) {
20 if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
21 utils.logger.enable();
22 } else {
23 // use `console.warn` rather than `logger.warn` since by non-debug bundles have all `logger.x` statements stripped
24 // eslint-disable-next-line no-console
25 console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');
26 }
27 }
28 const hub$1 = hub.getCurrentHub();
29 const scope = hub$1.getScope();
30 if (scope) {
31 scope.update(options.initialScope);
32 }
33
34 const client = new clientClass(options);
35 hub$1.bindClient(client);
36}
37
38exports.initAndBind = initAndBind;
39//# sourceMappingURL=sdk.js.map