UNPKG

@datadog/browser-logs

Version:
32 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.startRuntimeErrorCollection = startRuntimeErrorCollection; const browser_core_1 = require("@datadog/browser-core"); const isAuthorized_1 = require("../logger/isAuthorized"); const createErrorFieldFromRawError_1 = require("../createErrorFieldFromRawError"); function startRuntimeErrorCollection(configuration, lifeCycle, bufferedDataObservable) { if (!configuration.forwardErrorsToLogs) { return { stop: browser_core_1.noop }; } const rawErrorSubscription = bufferedDataObservable.subscribe((bufferedData) => { if (bufferedData.type === 0 /* BufferedDataType.RUNTIME_ERROR */) { const error = bufferedData.error; lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, { rawLogsEvent: { message: error.message, date: error.startClocks.timeStamp, error: (0, createErrorFieldFromRawError_1.createErrorFieldFromRawError)(error), origin: browser_core_1.ErrorSource.SOURCE, status: isAuthorized_1.StatusType.error, }, messageContext: error.context, }); } }); return { stop: () => { rawErrorSubscription.unsubscribe(); }, }; } //# sourceMappingURL=runtimeErrorCollection.js.map