| 15 | * @param options Options to pass to the client. |
| 16 | */ |
| 17 | export function initAndBind<F extends Client, O extends ClientOptions>( |
| 18 | clientClass: ClientClass<F, O>, |
| 19 | options: O, |
| 20 | ): Client { |
| 21 | if (options.debug === true) { |
| 22 | if (DEBUG_BUILD) { |
| 23 | debug.enable(); |
| 24 | } else { |
| 25 | // use `console.warn` rather than `debug.warn` since by non-debug bundles have all `debug.x` statements stripped |
| 26 | consoleSandbox(() => { |
| 27 | // eslint-disable-next-line no-console |
| 28 | console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.'); |
| 29 | }); |
| 30 | } |
| 31 | } |
| 32 | const scope = getCurrentScope(); |
| 33 | scope.update(options.initialScope); |
| 34 | |
| 35 | const client = new clientClass(options); |
| 36 | setCurrentClient(client); |
| 37 | client.init(); |
| 38 | return client; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Make the given client the current client. |