UNPKG

@datadog/browser-logs

Version:
34 lines 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.startReportCollection = startReportCollection; const browser_core_1 = require("@datadog/browser-core"); const isAuthorized_1 = require("../logger/isAuthorized"); const createErrorFieldFromRawError_1 = require("../createErrorFieldFromRawError"); function startReportCollection(configuration, lifeCycle) { const reportSubscription = (0, browser_core_1.initReportObservable)(configuration, configuration.forwardReports).subscribe((rawError) => { let message = rawError.message; let error; const status = rawError.originalError.type === 'deprecation' ? isAuthorized_1.StatusType.warn : isAuthorized_1.StatusType.error; if (status === isAuthorized_1.StatusType.error) { error = (0, createErrorFieldFromRawError_1.createErrorFieldFromRawError)(rawError); } else if (rawError.stack) { message += ` Found in ${(0, browser_core_1.getFileFromStackTraceString)(rawError.stack)}`; } lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, { rawLogsEvent: { date: (0, browser_core_1.timeStampNow)(), message, origin: browser_core_1.ErrorSource.REPORT, error, status, }, }); }); return { stop: () => { reportSubscription.unsubscribe(); }, }; } //# sourceMappingURL=reportCollection.js.map