@sentry/core
Version:
Base implementation for all Sentry JavaScript SDKs
48 lines (44 loc) • 1.67 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const client = require('./client.js');
const currentScopes = require('./currentScopes.js');
const debugBuild = require('./debug-build.js');
const debugLogger = require('./utils/debug-logger.js');
function initAndBind(clientClass, options) {
if (options.debug === true) {
if (debugBuild.DEBUG_BUILD) {
debugLogger.debug.enable();
} else {
debugLogger.consoleSandbox(() => {
console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.");
});
}
}
warnIfClientIsActive();
const scope = currentScopes.getCurrentScope();
scope.update(options.initialScope);
const client = new clientClass(options);
setCurrentClient(client);
client.init();
return client;
}
function getActiveClient() {
const client$1 = currentScopes.getClient();
return client$1 && !client.isClientClosed(client$1) ? client$1 : void 0;
}
function warnIfClientIsActive() {
if (getActiveClient()) {
debugLogger.consoleSandbox(() => {
console.warn(
"[Sentry] `Sentry.init()` was called more than once. The new client replaces the active client, but the active client is not closed, so state from both can mix. Call `Sentry.init()` only once, or call `await Sentry.close()` before you call it again."
);
});
}
}
function setCurrentClient(client) {
currentScopes.getCurrentScope().setClient(client);
}
exports.getActiveClient = getActiveClient;
exports.initAndBind = initAndBind;
exports.setCurrentClient = setCurrentClient;
exports.warnIfClientIsActive = warnIfClientIsActive;
//# sourceMappingURL=sdk.js.map