UNPKG

1.06 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 console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');
23 }
24 }
25 var hub = getCurrentHub();
26 var scope = hub.getScope();
27 if (scope) {
28 scope.update(options.initialScope);
29 }
30
31 var client = new clientClass(options);
32 hub.bindClient(client);
33}
34
35export { initAndBind };
36//# sourceMappingURL=sdk.js.map