Socket
Socket
Sign inDemoInstall

@datadog/browser-core

Package Overview
Dependencies
0
Maintainers
1
Versions
248
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0 to 5.1.0

cjs/domain/error/computeStackTrace.d.ts

2

cjs/boot/init.js

@@ -9,3 +9,3 @@ "use strict";

var publicApi = (0, polyfills_1.assign)({
version: "5.0.0",
version: "5.1.0",
// This API method is intentionally not monitored, since the only thing executed is the

@@ -12,0 +12,0 @@ // user-provided 'callback'. All SDK usages executed in the callback should be monitored, and

@@ -52,3 +52,3 @@ "use strict";

var retry = _b.retry, flushReason = _b.flushReason, encoding = _b.encoding;
var tags = ["sdk_version:".concat("5.0.0"), "api:".concat(api)].concat(configurationTags);
var tags = ["sdk_version:".concat("5.1.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.COLLECT_FLUSH_REASON)) {

@@ -64,3 +64,3 @@ tags.push("flush_reason:".concat(flushReason));

"dd-api-key=".concat(clientToken),
"dd-evp-origin-version=".concat(encodeURIComponent("5.0.0")),
"dd-evp-origin-version=".concat(encodeURIComponent("5.1.0")),
'dd-evp-origin=browser',

@@ -67,0 +67,0 @@ "dd-request-id=".concat((0, stringUtils_1.generateUUID)()),

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resetConsoleObservable = exports.initConsoleObservable = void 0;
var tracekit_1 = require("../tracekit");
var error_1 = require("../error/error");

@@ -12,2 +11,3 @@ var observable_1 = require("../../tools/observable");

var jsonStringify_1 = require("../../tools/serialisation/jsonStringify");
var computeStackTrace_1 = require("../error/computeStackTrace");
var consoleObservablesByApi = {};

@@ -54,3 +54,3 @@ function initConsoleObservable(apis) {

var firstErrorParam = (0, polyfills_1.find)(params, function (param) { return param instanceof Error; });
stack = firstErrorParam ? (0, error_1.toStackTraceString)((0, tracekit_1.computeStackTrace)(firstErrorParam)) : undefined;
stack = firstErrorParam ? (0, error_1.toStackTraceString)((0, computeStackTrace_1.computeStackTrace)(firstErrorParam)) : undefined;
fingerprint = (0, error_1.tryToGetFingerprint)(firstErrorParam);

@@ -71,3 +71,3 @@ }

if (param instanceof Error) {
return (0, error_1.formatErrorMessage)((0, tracekit_1.computeStackTrace)(param));
return (0, error_1.formatErrorMessage)((0, computeStackTrace_1.computeStackTrace)(param));
}

@@ -74,0 +74,0 @@ return (0, jsonStringify_1.jsonStringify)((0, sanitize_1.sanitize)(param), undefined, 2);

@@ -1,4 +0,4 @@

import type { StackTrace } from '../tracekit';
import type { ClocksState } from '../../tools/utils/timeUtils';
import type { ErrorSource, ErrorHandling, RawError, RawErrorCause, ErrorWithCause, NonErrorPrefix } from './error.types';
import type { StackTrace } from './computeStackTrace';
export declare const NO_ERROR_STACK_PRESENT_MESSAGE = "No stack, consider using an instance of Error";

@@ -5,0 +5,0 @@ type RawErrorParams = {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flattenErrorCauses = exports.createHandlingStack = exports.formatErrorMessage = exports.getFileFromStackTraceString = exports.toStackTraceString = exports.tryToGetFingerprint = exports.computeRawError = exports.NO_ERROR_STACK_PRESENT_MESSAGE = void 0;
var tracekit_1 = require("../tracekit");
var monitor_1 = require("../../tools/monitor");

@@ -9,2 +8,3 @@ var sanitize_1 = require("../../tools/serialisation/sanitize");

var jsonStringify_1 = require("../../tools/serialisation/jsonStringify");
var computeStackTrace_1 = require("./computeStackTrace");
exports.NO_ERROR_STACK_PRESENT_MESSAGE = 'No stack, consider using an instance of Error';

@@ -109,3 +109,3 @@ function computeRawError(_a) {

(0, monitor_1.callMonitored)(function () {
var stackTrace = (0, tracekit_1.computeStackTrace)(error);
var stackTrace = (0, computeStackTrace_1.computeStackTrace)(error);
stackTrace.stack = stackTrace.stack.slice(internalFramesToSkip);

@@ -121,3 +121,3 @@ formattedStack = toStackTraceString(stackTrace);

while ((currentError === null || currentError === void 0 ? void 0 : currentError.cause) instanceof Error && causes.length < 10) {
var stackTrace = (0, tracekit_1.computeStackTrace)(currentError.cause);
var stackTrace = (0, computeStackTrace_1.computeStackTrace)(currentError.cause);
causes.push({

@@ -124,0 +124,0 @@ message: currentError.cause.message,

import type { Observable } from '../../tools/observable';
import type { StackTrace } from './computeStackTrace';
import type { RawError } from './error.types';
export type UnhandledErrorCallback = (stackTrace: StackTrace, originalError?: any) => any;
export declare function trackRuntimeError(errorObservable: Observable<RawError>): {
stop: () => void;
};
export declare function instrumentOnError(callback: UnhandledErrorCallback): {
stop: () => void;
};
export declare function instrumentUnhandledRejection(callback: UnhandledErrorCallback): {
stop: () => void;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.trackRuntimeError = void 0;
exports.instrumentUnhandledRejection = exports.instrumentOnError = exports.trackRuntimeError = void 0;
var instrumentMethod_1 = require("../../tools/instrumentMethod");
var timeUtils_1 = require("../../tools/utils/timeUtils");
var tracekit_1 = require("../tracekit");
var computeStackTrace_1 = require("./computeStackTrace");
var error_1 = require("./error");
var error_types_1 = require("./error.types");
function trackRuntimeError(errorObservable) {
return (0, tracekit_1.startUnhandledErrorCollection)(function (stackTrace, originalError) {
errorObservable.notify((0, error_1.computeRawError)({
var handleRuntimeError = function (stackTrace, originalError) {
var test = (0, error_1.computeRawError)({
stackTrace: stackTrace,

@@ -17,6 +18,40 @@ originalError: originalError,

handling: "unhandled" /* ErrorHandling.UNHANDLED */,
}));
});
errorObservable.notify(test);
};
var stopInstrumentingOnError = instrumentOnError(handleRuntimeError).stop;
var stopInstrumentingOnUnhandledRejection = instrumentUnhandledRejection(handleRuntimeError).stop;
return {
stop: function () {
stopInstrumentingOnError();
stopInstrumentingOnUnhandledRejection();
},
};
}
exports.trackRuntimeError = trackRuntimeError;
function instrumentOnError(callback) {
return (0, instrumentMethod_1.instrumentMethodAndCallOriginal)(window, 'onerror', {
before: function (messageObj, url, line, column, errorObj) {
var stackTrace;
if (errorObj instanceof Error) {
stackTrace = (0, computeStackTrace_1.computeStackTrace)(errorObj);
}
else {
stackTrace = (0, computeStackTrace_1.computeStackTraceFromOnErrorMessage)(messageObj, url, line, column);
}
callback(stackTrace, errorObj !== null && errorObj !== void 0 ? errorObj : messageObj);
},
});
}
exports.trackRuntimeError = trackRuntimeError;
exports.instrumentOnError = instrumentOnError;
function instrumentUnhandledRejection(callback) {
return (0, instrumentMethod_1.instrumentMethodAndCallOriginal)(window, 'onunhandledrejection', {
before: function (e) {
var reason = e.reason || 'Empty reason';
var stack = (0, computeStackTrace_1.computeStackTrace)(reason);
callback(stack, reason);
},
});
}
exports.instrumentUnhandledRejection = instrumentUnhandledRejection;
//# sourceMappingURL=trackRuntimeError.js.map
import type { Context } from '../../tools/serialisation/context';
import type { Configuration } from '../configuration';
import type { StackTrace } from '../tracekit';
import { Observable } from '../../tools/observable';
import type { StackTrace } from '../error/computeStackTrace';
import type { TelemetryEvent } from './telemetryEvent.types';

@@ -6,0 +6,0 @@ import type { RawTelemetryConfiguration } from './rawTelemetryEvent.types';

@@ -8,3 +8,2 @@ "use strict";

var configuration_1 = require("../configuration");
var tracekit_1 = require("../tracekit");
var observable_1 = require("../../tools/observable");

@@ -18,2 +17,3 @@ var timeUtils_1 = require("../../tools/utils/timeUtils");

var mergeInto_1 = require("../../tools/mergeInto");
var computeStackTrace_1 = require("../error/computeStackTrace");
var rawTelemetryEvent_types_1 = require("./rawTelemetryEvent.types");

@@ -56,3 +56,3 @@ var ALLOWED_FRAME_URLS = [

service: telemetryService,
version: "5.0.0",
version: "5.1.0",
source: 'browser',

@@ -140,3 +140,3 @@ _dd: {

if (e instanceof Error) {
var stackTrace = (0, tracekit_1.computeStackTrace)(e);
var stackTrace = (0, computeStackTrace_1.computeStackTrace)(e);
return {

@@ -143,0 +143,0 @@ error: {

export { Configuration, InitConfiguration, validateAndBuildConfiguration, DefaultPrivacyLevel, EndpointBuilder, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, ExperimentalFeature, } from './tools/experimentalFeatures';
export { trackRuntimeError } from './domain/error/trackRuntimeError';
export { computeStackTrace, StackTrace } from './domain/tracekit';
export { computeStackTrace, StackTrace } from './domain/error/computeStackTrace';
export { defineGlobal, makePublicApi } from './boot/init';

@@ -6,0 +6,0 @@ export { initReportObservable, RawReport, RawReportType } from './domain/report/reportObservable';

@@ -35,4 +35,4 @@ "use strict";

Object.defineProperty(exports, "trackRuntimeError", { enumerable: true, get: function () { return trackRuntimeError_1.trackRuntimeError; } });
var tracekit_1 = require("./domain/tracekit");
Object.defineProperty(exports, "computeStackTrace", { enumerable: true, get: function () { return tracekit_1.computeStackTrace; } });
var computeStackTrace_1 = require("./domain/error/computeStackTrace");
Object.defineProperty(exports, "computeStackTrace", { enumerable: true, get: function () { return computeStackTrace_1.computeStackTrace; } });
var init_1 = require("./boot/init");

@@ -39,0 +39,0 @@ Object.defineProperty(exports, "defineGlobal", { enumerable: true, get: function () { return init_1.defineGlobal; } });

@@ -16,3 +16,2 @@ /**

SCROLLMAP = "scrollmap",
INTERACTION_TO_NEXT_PAINT = "interaction_to_next_paint",
WEB_VITALS_ATTRIBUTION = "web_vitals_attribution",

@@ -19,0 +18,0 @@ DISABLE_REPLAY_INLINE_CSS = "disable_replay_inline_css"

@@ -23,3 +23,2 @@ "use strict";

ExperimentalFeature["SCROLLMAP"] = "scrollmap";
ExperimentalFeature["INTERACTION_TO_NEXT_PAINT"] = "interaction_to_next_paint";
ExperimentalFeature["WEB_VITALS_ATTRIBUTION"] = "web_vitals_attribution";

@@ -26,0 +25,0 @@ ExperimentalFeature["DISABLE_REPLAY_INLINE_CSS"] = "disable_replay_inline_css";

@@ -1,2 +0,1 @@

import { noop } from '../utils/functionUtils';
/**

@@ -14,2 +13,2 @@ * Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that

}
export declare function detachToJsonMethod(value: object): typeof noop;
export declare function detachToJsonMethod(value: object): () => void;

@@ -6,3 +6,3 @@ import { catchUserErrors } from '../tools/catchUserErrors';

var publicApi = assign({
version: "5.0.0",
version: "5.1.0",
// This API method is intentionally not monitored, since the only thing executed is the

@@ -9,0 +9,0 @@ // user-provided 'callback'. All SDK usages executed in the callback should be monitored, and

@@ -48,3 +48,3 @@ import { timeStampNow } from '../../tools/utils/timeUtils';

var retry = _b.retry, flushReason = _b.flushReason, encoding = _b.encoding;
var tags = ["sdk_version:".concat("5.0.0"), "api:".concat(api)].concat(configurationTags);
var tags = ["sdk_version:".concat("5.1.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && isExperimentalFeatureEnabled(ExperimentalFeature.COLLECT_FLUSH_REASON)) {

@@ -60,3 +60,3 @@ tags.push("flush_reason:".concat(flushReason));

"dd-api-key=".concat(clientToken),
"dd-evp-origin-version=".concat(encodeURIComponent("5.0.0")),
"dd-evp-origin-version=".concat(encodeURIComponent("5.1.0")),
'dd-evp-origin=browser',

@@ -63,0 +63,0 @@ "dd-request-id=".concat(generateUUID()),

@@ -1,2 +0,1 @@

import { computeStackTrace } from '../tracekit';
import { createHandlingStack, formatErrorMessage, toStackTraceString, tryToGetFingerprint } from '../error/error';

@@ -9,2 +8,3 @@ import { mergeObservables, Observable } from '../../tools/observable';

import { jsonStringify } from '../../tools/serialisation/jsonStringify';
import { computeStackTrace } from '../error/computeStackTrace';
var consoleObservablesByApi = {};

@@ -11,0 +11,0 @@ export function initConsoleObservable(apis) {

@@ -1,4 +0,4 @@

import type { StackTrace } from '../tracekit';
import type { ClocksState } from '../../tools/utils/timeUtils';
import type { ErrorSource, ErrorHandling, RawError, RawErrorCause, ErrorWithCause, NonErrorPrefix } from './error.types';
import type { StackTrace } from './computeStackTrace';
export declare const NO_ERROR_STACK_PRESENT_MESSAGE = "No stack, consider using an instance of Error";

@@ -5,0 +5,0 @@ type RawErrorParams = {

@@ -1,2 +0,1 @@

import { computeStackTrace } from '../tracekit';
import { callMonitored } from '../../tools/monitor';

@@ -6,2 +5,3 @@ import { sanitize } from '../../tools/serialisation/sanitize';

import { jsonStringify } from '../../tools/serialisation/jsonStringify';
import { computeStackTrace } from './computeStackTrace';
export var NO_ERROR_STACK_PRESENT_MESSAGE = 'No stack, consider using an instance of Error';

@@ -8,0 +8,0 @@ export function computeRawError(_a) {

import type { Observable } from '../../tools/observable';
import type { StackTrace } from './computeStackTrace';
import type { RawError } from './error.types';
export type UnhandledErrorCallback = (stackTrace: StackTrace, originalError?: any) => any;
export declare function trackRuntimeError(errorObservable: Observable<RawError>): {
stop: () => void;
};
export declare function instrumentOnError(callback: UnhandledErrorCallback): {
stop: () => void;
};
export declare function instrumentUnhandledRejection(callback: UnhandledErrorCallback): {
stop: () => void;
};

@@ -0,8 +1,9 @@

import { instrumentMethodAndCallOriginal } from '../../tools/instrumentMethod';
import { clocksNow } from '../../tools/utils/timeUtils';
import { startUnhandledErrorCollection } from '../tracekit';
import { computeStackTrace, computeStackTraceFromOnErrorMessage } from './computeStackTrace';
import { computeRawError } from './error';
import { ErrorSource } from './error.types';
export function trackRuntimeError(errorObservable) {
return startUnhandledErrorCollection(function (stackTrace, originalError) {
errorObservable.notify(computeRawError({
var handleRuntimeError = function (stackTrace, originalError) {
var test = computeRawError({
stackTrace: stackTrace,

@@ -14,5 +15,37 @@ originalError: originalError,

handling: "unhandled" /* ErrorHandling.UNHANDLED */,
}));
});
errorObservable.notify(test);
};
var stopInstrumentingOnError = instrumentOnError(handleRuntimeError).stop;
var stopInstrumentingOnUnhandledRejection = instrumentUnhandledRejection(handleRuntimeError).stop;
return {
stop: function () {
stopInstrumentingOnError();
stopInstrumentingOnUnhandledRejection();
},
};
}
export function instrumentOnError(callback) {
return instrumentMethodAndCallOriginal(window, 'onerror', {
before: function (messageObj, url, line, column, errorObj) {
var stackTrace;
if (errorObj instanceof Error) {
stackTrace = computeStackTrace(errorObj);
}
else {
stackTrace = computeStackTraceFromOnErrorMessage(messageObj, url, line, column);
}
callback(stackTrace, errorObj !== null && errorObj !== void 0 ? errorObj : messageObj);
},
});
}
export function instrumentUnhandledRejection(callback) {
return instrumentMethodAndCallOriginal(window, 'onunhandledrejection', {
before: function (e) {
var reason = e.reason || 'Empty reason';
var stack = computeStackTrace(reason);
callback(stack, reason);
},
});
}
//# sourceMappingURL=trackRuntimeError.js.map
import type { Context } from '../../tools/serialisation/context';
import type { Configuration } from '../configuration';
import type { StackTrace } from '../tracekit';
import { Observable } from '../../tools/observable';
import type { StackTrace } from '../error/computeStackTrace';
import type { TelemetryEvent } from './telemetryEvent.types';

@@ -6,0 +6,0 @@ import type { RawTelemetryConfiguration } from './rawTelemetryEvent.types';

@@ -5,3 +5,2 @@ import { ConsoleApiName } from '../../tools/display';

import { INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../configuration';
import { computeStackTrace } from '../tracekit';
import { Observable } from '../../tools/observable';

@@ -15,2 +14,3 @@ import { timeStampNow } from '../../tools/utils/timeUtils';

import { combine } from '../../tools/mergeInto';
import { computeStackTrace } from '../error/computeStackTrace';
import { TelemetryType } from './rawTelemetryEvent.types';

@@ -53,3 +53,3 @@ var ALLOWED_FRAME_URLS = [

service: telemetryService,
version: "5.0.0",
version: "5.1.0",
source: 'browser',

@@ -56,0 +56,0 @@ _dd: {

export { Configuration, InitConfiguration, validateAndBuildConfiguration, DefaultPrivacyLevel, EndpointBuilder, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, ExperimentalFeature, } from './tools/experimentalFeatures';
export { trackRuntimeError } from './domain/error/trackRuntimeError';
export { computeStackTrace, StackTrace } from './domain/tracekit';
export { computeStackTrace, StackTrace } from './domain/error/computeStackTrace';
export { defineGlobal, makePublicApi } from './boot/init';

@@ -6,0 +6,0 @@ export { initReportObservable, RawReport, RawReportType } from './domain/report/reportObservable';

export { validateAndBuildConfiguration, DefaultPrivacyLevel, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, ExperimentalFeature, } from './tools/experimentalFeatures';
export { trackRuntimeError } from './domain/error/trackRuntimeError';
export { computeStackTrace } from './domain/tracekit';
export { computeStackTrace } from './domain/error/computeStackTrace';
export { defineGlobal, makePublicApi } from './boot/init';

@@ -6,0 +6,0 @@ export { initReportObservable, RawReportType } from './domain/report/reportObservable';

@@ -16,3 +16,2 @@ /**

SCROLLMAP = "scrollmap",
INTERACTION_TO_NEXT_PAINT = "interaction_to_next_paint",
WEB_VITALS_ATTRIBUTION = "web_vitals_attribution",

@@ -19,0 +18,0 @@ DISABLE_REPLAY_INLINE_CSS = "disable_replay_inline_css"

@@ -20,3 +20,2 @@ /**

ExperimentalFeature["SCROLLMAP"] = "scrollmap";
ExperimentalFeature["INTERACTION_TO_NEXT_PAINT"] = "interaction_to_next_paint";
ExperimentalFeature["WEB_VITALS_ATTRIBUTION"] = "web_vitals_attribution";

@@ -23,0 +22,0 @@ ExperimentalFeature["DISABLE_REPLAY_INLINE_CSS"] = "disable_replay_inline_css";

@@ -1,2 +0,1 @@

import { noop } from '../utils/functionUtils';
/**

@@ -14,2 +13,2 @@ * Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that

}
export declare function detachToJsonMethod(value: object): typeof noop;
export declare function detachToJsonMethod(value: object): () => void;
{
"name": "@datadog/browser-core",
"version": "5.0.0",
"version": "5.1.0",
"license": "Apache-2.0",

@@ -26,3 +26,3 @@ "main": "cjs/index.js",

},
"gitHead": "31b6e0946955b78ce0f8f090efb3d7dd11ff8f3f"
"gitHead": "3a31ebae7c56ed6d68cabf3cd96391ad57be0ab3"
}

@@ -1,2 +0,1 @@

import { computeStackTrace } from '../tracekit'
import { createHandlingStack, formatErrorMessage, toStackTraceString, tryToGetFingerprint } from '../error/error'

@@ -9,2 +8,3 @@ import { mergeObservables, Observable } from '../../tools/observable'

import { jsonStringify } from '../../tools/serialisation/jsonStringify'
import { computeStackTrace } from '../error/computeStackTrace'

@@ -11,0 +11,0 @@ export interface ConsoleLog {

@@ -1,3 +0,1 @@

import type { StackTrace } from '../tracekit'
import { computeStackTrace } from '../tracekit'
import { callMonitored } from '../../tools/monitor'

@@ -9,2 +7,4 @@ import { sanitize } from '../../tools/serialisation/sanitize'

import type { ErrorSource, ErrorHandling, RawError, RawErrorCause, ErrorWithCause, NonErrorPrefix } from './error.types'
import type { StackTrace } from './computeStackTrace'
import { computeStackTrace } from './computeStackTrace'

@@ -11,0 +11,0 @@ export const NO_ERROR_STACK_PRESENT_MESSAGE = 'No stack, consider using an instance of Error'

@@ -0,4 +1,6 @@

import { instrumentMethodAndCallOriginal } from '../../tools/instrumentMethod'
import type { Observable } from '../../tools/observable'
import { clocksNow } from '../../tools/utils/timeUtils'
import { startUnhandledErrorCollection } from '../tracekit'
import type { StackTrace } from './computeStackTrace'
import { computeStackTrace, computeStackTraceFromOnErrorMessage } from './computeStackTrace'
import { computeRawError } from './error'

@@ -8,15 +10,49 @@ import type { RawError } from './error.types'

export type UnhandledErrorCallback = (stackTrace: StackTrace, originalError?: any) => any
export function trackRuntimeError(errorObservable: Observable<RawError>) {
return startUnhandledErrorCollection((stackTrace, originalError) => {
errorObservable.notify(
computeRawError({
stackTrace,
originalError,
startClocks: clocksNow(),
nonErrorPrefix: NonErrorPrefix.UNCAUGHT,
source: ErrorSource.SOURCE,
handling: ErrorHandling.UNHANDLED,
})
)
const handleRuntimeError = (stackTrace: StackTrace, originalError?: any) => {
const test = computeRawError({
stackTrace,
originalError,
startClocks: clocksNow(),
nonErrorPrefix: NonErrorPrefix.UNCAUGHT,
source: ErrorSource.SOURCE,
handling: ErrorHandling.UNHANDLED,
})
errorObservable.notify(test)
}
const { stop: stopInstrumentingOnError } = instrumentOnError(handleRuntimeError)
const { stop: stopInstrumentingOnUnhandledRejection } = instrumentUnhandledRejection(handleRuntimeError)
return {
stop: () => {
stopInstrumentingOnError()
stopInstrumentingOnUnhandledRejection()
},
}
}
export function instrumentOnError(callback: UnhandledErrorCallback) {
return instrumentMethodAndCallOriginal(window, 'onerror', {
before(this: any, messageObj: unknown, url?: string, line?: number, column?: number, errorObj?: unknown) {
let stackTrace
if (errorObj instanceof Error) {
stackTrace = computeStackTrace(errorObj)
} else {
stackTrace = computeStackTraceFromOnErrorMessage(messageObj, url, line, column)
}
callback(stackTrace, errorObj ?? messageObj)
},
})
}
export function instrumentUnhandledRejection(callback: UnhandledErrorCallback) {
return instrumentMethodAndCallOriginal(window, 'onunhandledrejection', {
before(e: PromiseRejectionEvent) {
const reason = e.reason || 'Empty reason'
const stack = computeStackTrace(reason)
callback(stack, reason)
},
})
}

@@ -7,4 +7,2 @@ import type { Context } from '../../tools/serialisation/context'

import { INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../configuration'
import type { StackTrace } from '../tracekit'
import { computeStackTrace } from '../tracekit'
import { Observable } from '../../tools/observable'

@@ -19,2 +17,4 @@ import { timeStampNow } from '../../tools/utils/timeUtils'

import { NonErrorPrefix } from '../error/error.types'
import type { StackTrace } from '../error/computeStackTrace'
import { computeStackTrace } from '../error/computeStackTrace'
import type { TelemetryEvent } from './telemetryEvent.types'

@@ -21,0 +21,0 @@ import type { RawTelemetryConfiguration, RawTelemetryEvent, RuntimeEnvInfo } from './rawTelemetryEvent.types'

@@ -21,3 +21,3 @@ export {

export { trackRuntimeError } from './domain/error/trackRuntimeError'
export { computeStackTrace, StackTrace } from './domain/tracekit'
export { computeStackTrace, StackTrace } from './domain/error/computeStackTrace'
export { defineGlobal, makePublicApi } from './boot/init'

@@ -24,0 +24,0 @@ export { initReportObservable, RawReport, RawReportType } from './domain/report/reportObservable'

@@ -19,3 +19,2 @@ /**

SCROLLMAP = 'scrollmap',
INTERACTION_TO_NEXT_PAINT = 'interaction_to_next_paint',
WEB_VITALS_ATTRIBUTION = 'web_vitals_attribution',

@@ -22,0 +21,0 @@ DISABLE_REPLAY_INLINE_CSS = 'disable_replay_inline_css',

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc