UNPKG

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