@datadog/browser-core
Advanced tools
Comparing version 5.19.0 to 5.20.0
@@ -1,5 +0,14 @@ | ||
export declare function makePublicApi<T>(stub: T): T & { | ||
onReady(callback: () => void): void; | ||
export interface PublicApi { | ||
/** | ||
* Version of the Logs browser SDK | ||
*/ | ||
version: string; | ||
}; | ||
/** | ||
* [For CDN async setup] Early RUM API calls must be wrapped in the `window.DD_RUM.onReady()` callback. This ensures the code only gets executed once the SDK is properly loaded. | ||
* | ||
* See [CDN async setup](https://docs.datadoghq.com/real_user_monitoring/browser/#cdn-async) for further information. | ||
*/ | ||
onReady: (callback: () => void) => void; | ||
} | ||
export declare function makePublicApi<T extends PublicApi>(stub: Omit<T, keyof PublicApi>): T; | ||
export declare function defineGlobal<Global, Name extends keyof Global>(global: Global, name: Name, api: Global[Name]): void; |
@@ -7,5 +7,6 @@ "use strict"; | ||
var polyfills_1 = require("../tools/utils/polyfills"); | ||
var display_1 = require("../tools/display"); | ||
function makePublicApi(stub) { | ||
var publicApi = (0, polyfills_1.assign)({ | ||
version: "5.19.0", | ||
version: "5.20.0", | ||
// This API method is intentionally not monitored, since the only thing executed is the | ||
@@ -31,2 +32,5 @@ // user-provided 'callback'. All SDK usages executed in the callback should be monitored, and | ||
var existingGlobalVariable = global[name]; | ||
if (existingGlobalVariable && !existingGlobalVariable.q && existingGlobalVariable.version) { | ||
display_1.display.warn('SDK is loaded more than once. This is unsupported and might have unexpected behavior.'); | ||
} | ||
global[name] = api; | ||
@@ -33,0 +37,0 @@ if (existingGlobalVariable && existingGlobalVariable.q) { |
@@ -9,2 +9,3 @@ import { Observable } from '../tools/observable'; | ||
url: string; | ||
handlingStack?: string; | ||
} | ||
@@ -11,0 +12,0 @@ export interface FetchStartContext extends FetchContextBase { |
@@ -22,3 +22,5 @@ "use strict"; | ||
} | ||
var stop = (0, instrumentMethod_1.instrumentMethod)(window, 'fetch', function (call) { return beforeSend(call, observable); }).stop; | ||
var stop = (0, instrumentMethod_1.instrumentMethod)(window, 'fetch', function (call) { return beforeSend(call, observable); }, { | ||
computeHandlingStack: true, | ||
}).stop; | ||
return stop; | ||
@@ -28,3 +30,3 @@ }); | ||
function beforeSend(_a, observable) { | ||
var parameters = _a.parameters, onPostCall = _a.onPostCall; | ||
var parameters = _a.parameters, onPostCall = _a.onPostCall, handlingStack = _a.handlingStack; | ||
var input = parameters[0], init = parameters[1]; | ||
@@ -45,2 +47,3 @@ var methodFromParams = init && init.method; | ||
url: url, | ||
handlingStack: handlingStack, | ||
}; | ||
@@ -47,0 +50,0 @@ observable.notify(context); |
@@ -14,2 +14,3 @@ import { Observable } from '../tools/observable'; | ||
xhr: XMLHttpRequest; | ||
handlingStack?: string; | ||
} | ||
@@ -16,0 +17,0 @@ export interface XhrCompleteContext extends Omit<XhrStartContext, 'state'> { |
@@ -24,3 +24,3 @@ "use strict"; | ||
sendXhr(call, configuration, observable); | ||
}).stop; | ||
}, { computeHandlingStack: true }).stop; | ||
var stopInstrumentingAbort = (0, instrumentMethod_1.instrumentMethod)(XMLHttpRequest.prototype, 'abort', abortXhr).stop; | ||
@@ -43,3 +43,3 @@ return function () { | ||
function sendXhr(_a, configuration, observable) { | ||
var xhr = _a.target; | ||
var xhr = _a.target, handlingStack = _a.handlingStack; | ||
var context = xhrContexts.get(xhr); | ||
@@ -54,2 +54,3 @@ if (!context) { | ||
startContext.xhr = xhr; | ||
startContext.handlingStack = handlingStack; | ||
var hasBeenReported = false; | ||
@@ -56,0 +57,0 @@ var stopInstrumentingOnReadyStateChange = (0, instrumentMethod_1.instrumentMethod)(xhr, 'onreadystatechange', function () { |
@@ -5,3 +5,2 @@ import type { Duration } from '../../tools/utils/timeUtils'; | ||
import type { TransportConfiguration } from './transportConfiguration'; | ||
export declare const DOC_LINK = "https://docs.datadoghq.com/getting_started/site/"; | ||
export declare const DefaultPrivacyLevel: { | ||
@@ -8,0 +7,0 @@ readonly ALLOW: "allow"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serializeConfiguration = exports.validateAndBuildConfiguration = exports.TraceContextInjection = exports.DefaultPrivacyLevel = exports.DOC_LINK = void 0; | ||
exports.serializeConfiguration = exports.validateAndBuildConfiguration = exports.TraceContextInjection = exports.DefaultPrivacyLevel = void 0; | ||
var catchUserErrors_1 = require("../../tools/catchUserErrors"); | ||
@@ -15,3 +15,2 @@ var display_1 = require("../../tools/display"); | ||
var transportConfiguration_1 = require("./transportConfiguration"); | ||
exports.DOC_LINK = 'https://docs.datadoghq.com/getting_started/site/'; | ||
exports.DefaultPrivacyLevel = { | ||
@@ -75,3 +74,3 @@ ALLOW: 'allow', | ||
if (initConfiguration.site && !isDatadogSite(initConfiguration.site)) { | ||
display_1.display.error("Site should be a valid Datadog site. Learn more here: ".concat(exports.DOC_LINK, ".")); | ||
display_1.display.error("Site should be a valid Datadog site. Learn more here: ".concat(display_1.DOCS_ORIGIN, "/getting_started/site/.")); | ||
return; | ||
@@ -78,0 +77,0 @@ } |
@@ -60,3 +60,3 @@ "use strict"; | ||
var retry = _b.retry, encoding = _b.encoding; | ||
var tags = ["sdk_version:".concat("5.19.0"), "api:".concat(api)].concat(configurationTags); | ||
var tags = ["sdk_version:".concat("5.20.0"), "api:".concat(api)].concat(configurationTags); | ||
if (retry) { | ||
@@ -69,3 +69,3 @@ tags.push("retry_count:".concat(retry.count), "retry_after:".concat(retry.lastFailureStatus)); | ||
"dd-api-key=".concat(clientToken), | ||
"dd-evp-origin-version=".concat(encodeURIComponent("5.19.0")), | ||
"dd-evp-origin-version=".concat(encodeURIComponent("5.20.0")), | ||
'dd-evp-origin=browser', | ||
@@ -72,0 +72,0 @@ "dd-request-id=".concat((0, stringUtils_1.generateUUID)()), |
@@ -31,3 +31,3 @@ "use strict"; | ||
if (rawValue.length > valueSizeLimit || FORBIDDEN_CHARACTERS.test(rawValue)) { | ||
display_1.display.warn("".concat(key, " value doesn't meet tag requirements and will be sanitized")); | ||
display_1.display.warn("".concat(key, " value doesn't meet tag requirements and will be sanitized. More details: ").concat(display_1.DOCS_ORIGIN, "/getting_started/tagging/#defining-tags")); | ||
} | ||
@@ -34,0 +34,0 @@ // Let the backend do most of the sanitization, but still make sure multiple tags can't be crafted |
@@ -105,4 +105,4 @@ "use strict"; | ||
function displayCustomerDataLimitReachedWarning(bytesCountLimit) { | ||
display_1.display.warn("Customer data exceeds the recommended ".concat(bytesCountLimit / byteUtils_1.ONE_KIBI_BYTE, "KiB threshold. More details: https://docs.datadoghq.com/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-threshold-warning")); | ||
display_1.display.warn("Customer data exceeds the recommended ".concat(bytesCountLimit / byteUtils_1.ONE_KIBI_BYTE, "KiB threshold. More details: ").concat(display_1.DOCS_ORIGIN, "/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-threshold-warning")); | ||
} | ||
//# sourceMappingURL=customerDataTracker.js.map |
@@ -64,3 +64,3 @@ "use strict"; | ||
service: telemetryService, | ||
version: "5.19.0", | ||
version: "5.20.0", | ||
source: 'browser', | ||
@@ -67,0 +67,0 @@ _dd: { |
@@ -6,3 +6,3 @@ export { Configuration, InitConfiguration, validateAndBuildConfiguration, DefaultPrivacyLevel, TraceContextInjection, EndpointBuilder, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration'; | ||
export { computeStackTrace, StackTrace } from './tools/stackTrace/computeStackTrace'; | ||
export { defineGlobal, makePublicApi } from './boot/init'; | ||
export { defineGlobal, makePublicApi, PublicApi } from './boot/init'; | ||
export { displayAlreadyInitializedError } from './boot/displayAlreadyInitializedError'; | ||
@@ -9,0 +9,0 @@ export { initReportObservable, RawReport, RawReportType } from './domain/report/reportObservable'; |
@@ -35,2 +35,3 @@ /** | ||
export declare const display: Display; | ||
export declare const DOCS_ORIGIN = "https://docs.datadoghq.com"; | ||
export {}; |
@@ -11,3 +11,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.display = exports.originalConsoleMethods = exports.globalConsole = exports.ConsoleApiName = void 0; | ||
exports.DOCS_ORIGIN = exports.display = exports.originalConsoleMethods = exports.globalConsole = exports.ConsoleApiName = void 0; | ||
exports.ConsoleApiName = { | ||
@@ -42,2 +42,3 @@ log: 'log', | ||
}; | ||
exports.DOCS_ORIGIN = 'https://docs.datadoghq.com'; | ||
//# sourceMappingURL=display.js.map |
@@ -13,3 +13,4 @@ /** | ||
CUSTOM_VITALS = "custom_vitals", | ||
TOLERANT_RESOURCE_TIMINGS = "tolerant_resource_timings" | ||
TOLERANT_RESOURCE_TIMINGS = "tolerant_resource_timings", | ||
MICRO_FRONTEND = "micro_frontend" | ||
} | ||
@@ -16,0 +17,0 @@ export declare function addExperimentalFeatures(enabledFeatures: ExperimentalFeature[]): void; |
@@ -21,2 +21,3 @@ "use strict"; | ||
ExperimentalFeature["TOLERANT_RESOURCE_TIMINGS"] = "tolerant_resource_timings"; | ||
ExperimentalFeature["MICRO_FRONTEND"] = "micro_frontend"; | ||
})(ExperimentalFeature || (exports.ExperimentalFeature = ExperimentalFeature = {})); | ||
@@ -23,0 +24,0 @@ var enabledExperimentalFeatures = new Set(); |
@@ -24,2 +24,6 @@ import { noop } from './utils/functionUtils'; | ||
onPostCall: (callback: PostCallCallback<TARGET, METHOD>) => void; | ||
/** | ||
* The stack trace of the method call. | ||
*/ | ||
handlingStack?: string; | ||
}; | ||
@@ -62,3 +66,5 @@ type PostCallCallback<TARGET extends { | ||
[key: string]: any; | ||
}, METHOD extends keyof TARGET & string>(targetPrototype: TARGET, method: METHOD, onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void): { | ||
}, METHOD extends keyof TARGET & string>(targetPrototype: TARGET, method: METHOD, onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void, { computeHandlingStack }?: { | ||
computeHandlingStack?: boolean; | ||
}): { | ||
stop: typeof noop; | ||
@@ -65,0 +71,0 @@ }; |
@@ -8,2 +8,3 @@ "use strict"; | ||
var polyfills_1 = require("./utils/polyfills"); | ||
var handlingStack_1 = require("./stackTrace/handlingStack"); | ||
/** | ||
@@ -40,3 +41,4 @@ * Instruments a method on a object, calling the given callback before the original method is | ||
*/ | ||
function instrumentMethod(targetPrototype, method, onPreCall) { | ||
function instrumentMethod(targetPrototype, method, onPreCall, _a) { | ||
var _b = _a === void 0 ? {} : _a, computeHandlingStack = _b.computeHandlingStack; | ||
var original = targetPrototype[method]; | ||
@@ -51,26 +53,8 @@ if (typeof original !== 'function') { | ||
} | ||
var instrumentation = createInstrumentedMethod(original, onPreCall); | ||
var instrumentationWrapper = function () { | ||
if (typeof instrumentation !== 'function') { | ||
return undefined; | ||
var stopped = false; | ||
var instrumentation = function () { | ||
if (stopped) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call | ||
return original.apply(this, arguments); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call | ||
return instrumentation.apply(this, arguments); | ||
}; | ||
targetPrototype[method] = instrumentationWrapper; | ||
return { | ||
stop: function () { | ||
if (targetPrototype[method] === instrumentationWrapper) { | ||
targetPrototype[method] = original; | ||
} | ||
else { | ||
instrumentation = original; | ||
} | ||
}, | ||
}; | ||
} | ||
exports.instrumentMethod = instrumentMethod; | ||
function createInstrumentedMethod(original, onPreCall) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return function () { | ||
var parameters = (0, polyfills_1.arrayFrom)(arguments); | ||
@@ -85,2 +69,3 @@ var postCallCallback; | ||
}, | ||
handlingStack: computeHandlingStack ? (0, handlingStack_1.createHandlingStack)() : undefined, | ||
}, | ||
@@ -96,3 +81,14 @@ ]); | ||
}; | ||
targetPrototype[method] = instrumentation; | ||
return { | ||
stop: function () { | ||
stopped = true; | ||
// If the instrumentation has been removed by a third party, keep the last one | ||
if (targetPrototype[method] === instrumentation) { | ||
targetPrototype[method] = original; | ||
} | ||
}, | ||
}; | ||
} | ||
exports.instrumentMethod = instrumentMethod; | ||
function instrumentSetter(targetPrototype, property, after) { | ||
@@ -99,0 +95,0 @@ var originalDescriptor = Object.getOwnPropertyDescriptor(targetPrototype, property); |
@@ -66,3 +66,3 @@ "use strict"; | ||
if (estimatedMessageBytesCount >= this.messageBytesLimit) { | ||
display_1.display.warn("Discarded a message whose size was bigger than the maximum allowed size ".concat(this.messageBytesLimit, "KB.")); | ||
display_1.display.warn("Discarded a message whose size was bigger than the maximum allowed size ".concat(this.messageBytesLimit, "KB. More details: ").concat(display_1.DOCS_ORIGIN, "/real_user_monitoring/browser/troubleshooting/#technical-limitations")); | ||
return; | ||
@@ -69,0 +69,0 @@ } |
@@ -1,5 +0,14 @@ | ||
export declare function makePublicApi<T>(stub: T): T & { | ||
onReady(callback: () => void): void; | ||
export interface PublicApi { | ||
/** | ||
* Version of the Logs browser SDK | ||
*/ | ||
version: string; | ||
}; | ||
/** | ||
* [For CDN async setup] Early RUM API calls must be wrapped in the `window.DD_RUM.onReady()` callback. This ensures the code only gets executed once the SDK is properly loaded. | ||
* | ||
* See [CDN async setup](https://docs.datadoghq.com/real_user_monitoring/browser/#cdn-async) for further information. | ||
*/ | ||
onReady: (callback: () => void) => void; | ||
} | ||
export declare function makePublicApi<T extends PublicApi>(stub: Omit<T, keyof PublicApi>): T; | ||
export declare function defineGlobal<Global, Name extends keyof Global>(global: Global, name: Name, api: Global[Name]): void; |
import { catchUserErrors } from '../tools/catchUserErrors'; | ||
import { setDebugMode } from '../tools/monitor'; | ||
import { assign } from '../tools/utils/polyfills'; | ||
import { display } from '../tools/display'; | ||
export function makePublicApi(stub) { | ||
var publicApi = assign({ | ||
version: "5.19.0", | ||
version: "5.20.0", | ||
// This API method is intentionally not monitored, since the only thing executed is the | ||
@@ -26,2 +27,5 @@ // user-provided 'callback'. All SDK usages executed in the callback should be monitored, and | ||
var existingGlobalVariable = global[name]; | ||
if (existingGlobalVariable && !existingGlobalVariable.q && existingGlobalVariable.version) { | ||
display.warn('SDK is loaded more than once. This is unsupported and might have unexpected behavior.'); | ||
} | ||
global[name] = api; | ||
@@ -28,0 +32,0 @@ if (existingGlobalVariable && existingGlobalVariable.q) { |
@@ -9,2 +9,3 @@ import { Observable } from '../tools/observable'; | ||
url: string; | ||
handlingStack?: string; | ||
} | ||
@@ -11,0 +12,0 @@ export interface FetchStartContext extends FetchContextBase { |
@@ -18,3 +18,5 @@ import { instrumentMethod } from '../tools/instrumentMethod'; | ||
} | ||
var stop = instrumentMethod(window, 'fetch', function (call) { return beforeSend(call, observable); }).stop; | ||
var stop = instrumentMethod(window, 'fetch', function (call) { return beforeSend(call, observable); }, { | ||
computeHandlingStack: true, | ||
}).stop; | ||
return stop; | ||
@@ -24,3 +26,3 @@ }); | ||
function beforeSend(_a, observable) { | ||
var parameters = _a.parameters, onPostCall = _a.onPostCall; | ||
var parameters = _a.parameters, onPostCall = _a.onPostCall, handlingStack = _a.handlingStack; | ||
var input = parameters[0], init = parameters[1]; | ||
@@ -41,2 +43,3 @@ var methodFromParams = init && init.method; | ||
url: url, | ||
handlingStack: handlingStack, | ||
}; | ||
@@ -43,0 +46,0 @@ observable.notify(context); |
@@ -14,2 +14,3 @@ import { Observable } from '../tools/observable'; | ||
xhr: XMLHttpRequest; | ||
handlingStack?: string; | ||
} | ||
@@ -16,0 +17,0 @@ export interface XhrCompleteContext extends Omit<XhrStartContext, 'state'> { |
@@ -20,3 +20,3 @@ import { instrumentMethod } from '../tools/instrumentMethod'; | ||
sendXhr(call, configuration, observable); | ||
}).stop; | ||
}, { computeHandlingStack: true }).stop; | ||
var stopInstrumentingAbort = instrumentMethod(XMLHttpRequest.prototype, 'abort', abortXhr).stop; | ||
@@ -39,3 +39,3 @@ return function () { | ||
function sendXhr(_a, configuration, observable) { | ||
var xhr = _a.target; | ||
var xhr = _a.target, handlingStack = _a.handlingStack; | ||
var context = xhrContexts.get(xhr); | ||
@@ -50,2 +50,3 @@ if (!context) { | ||
startContext.xhr = xhr; | ||
startContext.handlingStack = handlingStack; | ||
var hasBeenReported = false; | ||
@@ -52,0 +53,0 @@ var stopInstrumentingOnReadyStateChange = instrumentMethod(xhr, 'onreadystatechange', function () { |
@@ -5,3 +5,2 @@ import type { Duration } from '../../tools/utils/timeUtils'; | ||
import type { TransportConfiguration } from './transportConfiguration'; | ||
export declare const DOC_LINK = "https://docs.datadoghq.com/getting_started/site/"; | ||
export declare const DefaultPrivacyLevel: { | ||
@@ -8,0 +7,0 @@ readonly ALLOW: "allow"; |
import { catchUserErrors } from '../../tools/catchUserErrors'; | ||
import { display } from '../../tools/display'; | ||
import { DOCS_ORIGIN, display } from '../../tools/display'; | ||
import { ExperimentalFeature, addExperimentalFeatures } from '../../tools/experimentalFeatures'; | ||
@@ -12,3 +12,2 @@ import { ONE_SECOND } from '../../tools/utils/timeUtils'; | ||
import { computeTransportConfiguration } from './transportConfiguration'; | ||
export var DOC_LINK = 'https://docs.datadoghq.com/getting_started/site/'; | ||
export var DefaultPrivacyLevel = { | ||
@@ -72,3 +71,3 @@ ALLOW: 'allow', | ||
if (initConfiguration.site && !isDatadogSite(initConfiguration.site)) { | ||
display.error("Site should be a valid Datadog site. Learn more here: ".concat(DOC_LINK, ".")); | ||
display.error("Site should be a valid Datadog site. Learn more here: ".concat(DOCS_ORIGIN, "/getting_started/site/.")); | ||
return; | ||
@@ -75,0 +74,0 @@ } |
@@ -56,3 +56,3 @@ import { timeStampNow } from '../../tools/utils/timeUtils'; | ||
var retry = _b.retry, encoding = _b.encoding; | ||
var tags = ["sdk_version:".concat("5.19.0"), "api:".concat(api)].concat(configurationTags); | ||
var tags = ["sdk_version:".concat("5.20.0"), "api:".concat(api)].concat(configurationTags); | ||
if (retry) { | ||
@@ -65,3 +65,3 @@ tags.push("retry_count:".concat(retry.count), "retry_after:".concat(retry.lastFailureStatus)); | ||
"dd-api-key=".concat(clientToken), | ||
"dd-evp-origin-version=".concat(encodeURIComponent("5.19.0")), | ||
"dd-evp-origin-version=".concat(encodeURIComponent("5.20.0")), | ||
'dd-evp-origin=browser', | ||
@@ -68,0 +68,0 @@ "dd-request-id=".concat(generateUUID()), |
@@ -1,2 +0,2 @@ | ||
import { display } from '../../tools/display'; | ||
import { DOCS_ORIGIN, display } from '../../tools/display'; | ||
export var TAG_SIZE_LIMIT = 200; | ||
@@ -27,3 +27,3 @@ export function buildTags(configuration) { | ||
if (rawValue.length > valueSizeLimit || FORBIDDEN_CHARACTERS.test(rawValue)) { | ||
display.warn("".concat(key, " value doesn't meet tag requirements and will be sanitized")); | ||
display.warn("".concat(key, " value doesn't meet tag requirements and will be sanitized. More details: ").concat(DOCS_ORIGIN, "/getting_started/tagging/#defining-tags")); | ||
} | ||
@@ -30,0 +30,0 @@ // Let the backend do most of the sanitization, but still make sure multiple tags can't be crafted |
import { ONE_KIBI_BYTE, computeBytesCount } from '../../tools/utils/byteUtils'; | ||
import { throttle } from '../../tools/utils/functionUtils'; | ||
import { jsonStringify } from '../../tools/serialisation/jsonStringify'; | ||
import { display } from '../../tools/display'; | ||
import { DOCS_ORIGIN, display } from '../../tools/display'; | ||
import { isEmptyObject } from '../../tools/utils/objectUtils'; | ||
@@ -100,4 +100,4 @@ // RUM and logs batch bytes limit is 16KB | ||
function displayCustomerDataLimitReachedWarning(bytesCountLimit) { | ||
display.warn("Customer data exceeds the recommended ".concat(bytesCountLimit / ONE_KIBI_BYTE, "KiB threshold. More details: https://docs.datadoghq.com/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-threshold-warning")); | ||
display.warn("Customer data exceeds the recommended ".concat(bytesCountLimit / ONE_KIBI_BYTE, "KiB threshold. More details: ").concat(DOCS_ORIGIN, "/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-threshold-warning")); | ||
} | ||
//# sourceMappingURL=customerDataTracker.js.map |
@@ -61,3 +61,3 @@ import { ConsoleApiName } from '../../tools/display'; | ||
service: telemetryService, | ||
version: "5.19.0", | ||
version: "5.20.0", | ||
source: 'browser', | ||
@@ -64,0 +64,0 @@ _dd: { |
@@ -6,3 +6,3 @@ export { Configuration, InitConfiguration, validateAndBuildConfiguration, DefaultPrivacyLevel, TraceContextInjection, EndpointBuilder, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration'; | ||
export { computeStackTrace, StackTrace } from './tools/stackTrace/computeStackTrace'; | ||
export { defineGlobal, makePublicApi } from './boot/init'; | ||
export { defineGlobal, makePublicApi, PublicApi } from './boot/init'; | ||
export { displayAlreadyInitializedError } from './boot/displayAlreadyInitializedError'; | ||
@@ -9,0 +9,0 @@ export { initReportObservable, RawReport, RawReportType } from './domain/report/reportObservable'; |
@@ -35,2 +35,3 @@ /** | ||
export declare const display: Display; | ||
export declare const DOCS_ORIGIN = "https://docs.datadoghq.com"; | ||
export {}; |
@@ -38,2 +38,3 @@ /* eslint-disable local-rules/disallow-side-effects */ | ||
}; | ||
export var DOCS_ORIGIN = 'https://docs.datadoghq.com'; | ||
//# sourceMappingURL=display.js.map |
@@ -13,3 +13,4 @@ /** | ||
CUSTOM_VITALS = "custom_vitals", | ||
TOLERANT_RESOURCE_TIMINGS = "tolerant_resource_timings" | ||
TOLERANT_RESOURCE_TIMINGS = "tolerant_resource_timings", | ||
MICRO_FRONTEND = "micro_frontend" | ||
} | ||
@@ -16,0 +17,0 @@ export declare function addExperimentalFeatures(enabledFeatures: ExperimentalFeature[]): void; |
@@ -18,2 +18,3 @@ /** | ||
ExperimentalFeature["TOLERANT_RESOURCE_TIMINGS"] = "tolerant_resource_timings"; | ||
ExperimentalFeature["MICRO_FRONTEND"] = "micro_frontend"; | ||
})(ExperimentalFeature || (ExperimentalFeature = {})); | ||
@@ -20,0 +21,0 @@ var enabledExperimentalFeatures = new Set(); |
@@ -24,2 +24,6 @@ import { noop } from './utils/functionUtils'; | ||
onPostCall: (callback: PostCallCallback<TARGET, METHOD>) => void; | ||
/** | ||
* The stack trace of the method call. | ||
*/ | ||
handlingStack?: string; | ||
}; | ||
@@ -62,3 +66,5 @@ type PostCallCallback<TARGET extends { | ||
[key: string]: any; | ||
}, METHOD extends keyof TARGET & string>(targetPrototype: TARGET, method: METHOD, onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void): { | ||
}, METHOD extends keyof TARGET & string>(targetPrototype: TARGET, method: METHOD, onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void, { computeHandlingStack }?: { | ||
computeHandlingStack?: boolean; | ||
}): { | ||
stop: typeof noop; | ||
@@ -65,0 +71,0 @@ }; |
@@ -5,2 +5,3 @@ import { setTimeout } from './timer'; | ||
import { arrayFrom, startsWith } from './utils/polyfills'; | ||
import { createHandlingStack } from './stackTrace/handlingStack'; | ||
/** | ||
@@ -37,3 +38,4 @@ * Instruments a method on a object, calling the given callback before the original method is | ||
*/ | ||
export function instrumentMethod(targetPrototype, method, onPreCall) { | ||
export function instrumentMethod(targetPrototype, method, onPreCall, _a) { | ||
var _b = _a === void 0 ? {} : _a, computeHandlingStack = _b.computeHandlingStack; | ||
var original = targetPrototype[method]; | ||
@@ -48,25 +50,8 @@ if (typeof original !== 'function') { | ||
} | ||
var instrumentation = createInstrumentedMethod(original, onPreCall); | ||
var instrumentationWrapper = function () { | ||
if (typeof instrumentation !== 'function') { | ||
return undefined; | ||
var stopped = false; | ||
var instrumentation = function () { | ||
if (stopped) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call | ||
return original.apply(this, arguments); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call | ||
return instrumentation.apply(this, arguments); | ||
}; | ||
targetPrototype[method] = instrumentationWrapper; | ||
return { | ||
stop: function () { | ||
if (targetPrototype[method] === instrumentationWrapper) { | ||
targetPrototype[method] = original; | ||
} | ||
else { | ||
instrumentation = original; | ||
} | ||
}, | ||
}; | ||
} | ||
function createInstrumentedMethod(original, onPreCall) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return function () { | ||
var parameters = arrayFrom(arguments); | ||
@@ -81,2 +66,3 @@ var postCallCallback; | ||
}, | ||
handlingStack: computeHandlingStack ? createHandlingStack() : undefined, | ||
}, | ||
@@ -92,2 +78,12 @@ ]); | ||
}; | ||
targetPrototype[method] = instrumentation; | ||
return { | ||
stop: function () { | ||
stopped = true; | ||
// If the instrumentation has been removed by a third party, keep the last one | ||
if (targetPrototype[method] === instrumentation) { | ||
targetPrototype[method] = original; | ||
} | ||
}, | ||
}; | ||
} | ||
@@ -94,0 +90,0 @@ export function instrumentSetter(targetPrototype, property, after) { |
@@ -1,2 +0,2 @@ | ||
import { display } from '../tools/display'; | ||
import { DOCS_ORIGIN, display } from '../tools/display'; | ||
import { objectValues } from '../tools/utils/polyfills'; | ||
@@ -63,3 +63,3 @@ import { isPageExitReason } from '../browser/pageExitObservable'; | ||
if (estimatedMessageBytesCount >= this.messageBytesLimit) { | ||
display.warn("Discarded a message whose size was bigger than the maximum allowed size ".concat(this.messageBytesLimit, "KB.")); | ||
display.warn("Discarded a message whose size was bigger than the maximum allowed size ".concat(this.messageBytesLimit, "KB. More details: ").concat(DOCS_ORIGIN, "/real_user_monitoring/browser/troubleshooting/#technical-limitations")); | ||
return; | ||
@@ -66,0 +66,0 @@ } |
{ | ||
"name": "@datadog/browser-core", | ||
"version": "5.19.0", | ||
"version": "5.20.0", | ||
"license": "Apache-2.0", | ||
@@ -26,3 +26,3 @@ "main": "cjs/index.js", | ||
}, | ||
"gitHead": "ce92533465ebb3c3d0142f0c7d83af471572a818" | ||
"gitHead": "1dafdcfbf43a0f0ed8a0cbd5f13d16ba68378074" | ||
} |
import { catchUserErrors } from '../tools/catchUserErrors' | ||
import { setDebugMode } from '../tools/monitor' | ||
import { assign } from '../tools/utils/polyfills' | ||
import { display } from '../tools/display' | ||
@@ -8,3 +9,17 @@ // replaced at build time | ||
export function makePublicApi<T>(stub: T): T & { onReady(callback: () => void): void; version: string } { | ||
export interface PublicApi { | ||
/** | ||
* Version of the Logs browser SDK | ||
*/ | ||
version: string | ||
/** | ||
* [For CDN async setup] Early RUM API calls must be wrapped in the `window.DD_RUM.onReady()` callback. This ensures the code only gets executed once the SDK is properly loaded. | ||
* | ||
* See [CDN async setup](https://docs.datadoghq.com/real_user_monitoring/browser/#cdn-async) for further information. | ||
*/ | ||
onReady: (callback: () => void) => void | ||
} | ||
export function makePublicApi<T extends PublicApi>(stub: Omit<T, keyof PublicApi>): T { | ||
const publicApi = assign( | ||
@@ -33,7 +48,10 @@ { | ||
return publicApi | ||
return publicApi as T | ||
} | ||
export function defineGlobal<Global, Name extends keyof Global>(global: Global, name: Name, api: Global[Name]) { | ||
const existingGlobalVariable = global[name] as { q?: Array<() => void> } | undefined | ||
const existingGlobalVariable = global[name] as { q?: Array<() => void>; version?: string } | undefined | ||
if (existingGlobalVariable && !existingGlobalVariable.q && existingGlobalVariable.version) { | ||
display.warn('SDK is loaded more than once. This is unsupported and might have unexpected behavior.') | ||
} | ||
global[name] = api | ||
@@ -40,0 +58,0 @@ if (existingGlobalVariable && existingGlobalVariable.q) { |
@@ -15,2 +15,3 @@ import type { InstrumentedMethodCall } from '../tools/instrumentMethod' | ||
url: string | ||
handlingStack?: string | ||
} | ||
@@ -48,3 +49,5 @@ | ||
const { stop } = instrumentMethod(window, 'fetch', (call) => beforeSend(call, observable)) | ||
const { stop } = instrumentMethod(window, 'fetch', (call) => beforeSend(call, observable), { | ||
computeHandlingStack: true, | ||
}) | ||
@@ -56,3 +59,3 @@ return stop | ||
function beforeSend( | ||
{ parameters, onPostCall }: InstrumentedMethodCall<Window, 'fetch'>, | ||
{ parameters, onPostCall, handlingStack }: InstrumentedMethodCall<Window, 'fetch'>, | ||
observable: Observable<FetchContext> | ||
@@ -78,2 +81,3 @@ ) { | ||
url, | ||
handlingStack, | ||
} | ||
@@ -80,0 +84,0 @@ |
@@ -22,2 +22,3 @@ import type { InstrumentedMethodCall } from '../tools/instrumentMethod' | ||
xhr: XMLHttpRequest | ||
handlingStack?: string | ||
} | ||
@@ -47,5 +48,10 @@ | ||
const { stop: stopInstrumentingSend } = instrumentMethod(XMLHttpRequest.prototype, 'send', (call) => { | ||
sendXhr(call, configuration, observable) | ||
}) | ||
const { stop: stopInstrumentingSend } = instrumentMethod( | ||
XMLHttpRequest.prototype, | ||
'send', | ||
(call) => { | ||
sendXhr(call, configuration, observable) | ||
}, | ||
{ computeHandlingStack: true } | ||
) | ||
@@ -71,3 +77,3 @@ const { stop: stopInstrumentingAbort } = instrumentMethod(XMLHttpRequest.prototype, 'abort', abortXhr) | ||
function sendXhr( | ||
{ target: xhr }: InstrumentedMethodCall<XMLHttpRequest, 'send'>, | ||
{ target: xhr, handlingStack }: InstrumentedMethodCall<XMLHttpRequest, 'send'>, | ||
configuration: Configuration, | ||
@@ -86,2 +92,3 @@ observable: Observable<XhrContext> | ||
startContext.xhr = xhr | ||
startContext.handlingStack = handlingStack | ||
@@ -88,0 +95,0 @@ let hasBeenReported = false |
import { catchUserErrors } from '../../tools/catchUserErrors' | ||
import { display } from '../../tools/display' | ||
import { DOCS_ORIGIN, display } from '../../tools/display' | ||
import type { RawTelemetryConfiguration } from '../telemetry' | ||
@@ -17,3 +17,2 @@ import { ExperimentalFeature, addExperimentalFeatures } from '../../tools/experimentalFeatures' | ||
export const DOC_LINK = 'https://docs.datadoghq.com/getting_started/site/' | ||
export const DefaultPrivacyLevel = { | ||
@@ -178,3 +177,3 @@ ALLOW: 'allow', | ||
if (initConfiguration.site && !isDatadogSite(initConfiguration.site)) { | ||
display.error(`Site should be a valid Datadog site. Learn more here: ${DOC_LINK}.`) | ||
display.error(`Site should be a valid Datadog site. Learn more here: ${DOCS_ORIGIN}/getting_started/site/.`) | ||
return | ||
@@ -181,0 +180,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { display } from '../../tools/display' | ||
import { DOCS_ORIGIN, display } from '../../tools/display' | ||
import type { InitConfiguration } from './configuration' | ||
@@ -35,3 +35,5 @@ | ||
if (rawValue.length > valueSizeLimit || FORBIDDEN_CHARACTERS.test(rawValue)) { | ||
display.warn(`${key} value doesn't meet tag requirements and will be sanitized`) | ||
display.warn( | ||
`${key} value doesn't meet tag requirements and will be sanitized. More details: ${DOCS_ORIGIN}/getting_started/tagging/#defining-tags` | ||
) | ||
} | ||
@@ -38,0 +40,0 @@ |
@@ -5,3 +5,3 @@ import { ONE_KIBI_BYTE, computeBytesCount } from '../../tools/utils/byteUtils' | ||
import { jsonStringify } from '../../tools/serialisation/jsonStringify' | ||
import { display } from '../../tools/display' | ||
import { DOCS_ORIGIN, display } from '../../tools/display' | ||
import { isEmptyObject } from '../../tools/utils/objectUtils' | ||
@@ -133,4 +133,4 @@ import type { CustomerDataType } from './contextConstants' | ||
bytesCountLimit / ONE_KIBI_BYTE | ||
}KiB threshold. More details: https://docs.datadoghq.com/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-threshold-warning` | ||
}KiB threshold. More details: ${DOCS_ORIGIN}/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-threshold-warning` | ||
) | ||
} |
@@ -24,3 +24,3 @@ export { | ||
export { computeStackTrace, StackTrace } from './tools/stackTrace/computeStackTrace' | ||
export { defineGlobal, makePublicApi } from './boot/init' | ||
export { defineGlobal, makePublicApi, PublicApi } from './boot/init' | ||
export { displayAlreadyInitializedError } from './boot/displayAlreadyInitializedError' | ||
@@ -27,0 +27,0 @@ export { initReportObservable, RawReport, RawReportType } from './domain/report/reportObservable' |
@@ -53,1 +53,3 @@ /* eslint-disable local-rules/disallow-side-effects */ | ||
} | ||
export const DOCS_ORIGIN = 'https://docs.datadoghq.com' |
@@ -17,2 +17,3 @@ /** | ||
TOLERANT_RESOURCE_TIMINGS = 'tolerant_resource_timings', | ||
MICRO_FRONTEND = 'micro_frontend', | ||
} | ||
@@ -19,0 +20,0 @@ |
@@ -5,2 +5,3 @@ import { setTimeout } from './timer' | ||
import { arrayFrom, startsWith } from './utils/polyfills' | ||
import { createHandlingStack } from './stackTrace/handlingStack' | ||
@@ -29,2 +30,7 @@ /** | ||
onPostCall: (callback: PostCallCallback<TARGET, METHOD>) => void | ||
/** | ||
* The stack trace of the method call. | ||
*/ | ||
handlingStack?: string | ||
} | ||
@@ -70,3 +76,4 @@ | ||
method: METHOD, | ||
onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void | ||
onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void, | ||
{ computeHandlingStack }: { computeHandlingStack?: boolean } = {} | ||
) { | ||
@@ -83,30 +90,10 @@ let original = targetPrototype[method] | ||
let instrumentation = createInstrumentedMethod(original, onPreCall) | ||
let stopped = false | ||
const instrumentationWrapper = function (this: TARGET): ReturnType<TARGET[METHOD]> | undefined { | ||
if (typeof instrumentation !== 'function') { | ||
return undefined | ||
const instrumentation = function (this: TARGET): ReturnType<TARGET[METHOD]> | undefined { | ||
if (stopped) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call | ||
return original.apply(this, arguments as unknown as Parameters<TARGET[METHOD]>) | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call | ||
return instrumentation.apply(this, arguments as unknown as Parameters<TARGET[METHOD]>) | ||
} | ||
targetPrototype[method] = instrumentationWrapper as TARGET[METHOD] | ||
return { | ||
stop: () => { | ||
if (targetPrototype[method] === instrumentationWrapper) { | ||
targetPrototype[method] = original | ||
} else { | ||
instrumentation = original | ||
} | ||
}, | ||
} | ||
} | ||
function createInstrumentedMethod<TARGET extends { [key: string]: any }, METHOD extends keyof TARGET>( | ||
original: TARGET[METHOD], | ||
onPreCall: (this: null, callInfos: InstrumentedMethodCall<TARGET, METHOD>) => void | ||
): TARGET[METHOD] { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return function (this: TARGET) { | ||
const parameters = arrayFrom(arguments) as Parameters<TARGET[METHOD]> | ||
@@ -123,2 +110,3 @@ | ||
}, | ||
handlingStack: computeHandlingStack ? createHandlingStack() : undefined, | ||
}, | ||
@@ -136,3 +124,15 @@ ]) | ||
return result | ||
} as TARGET[METHOD] | ||
} | ||
targetPrototype[method] = instrumentation as TARGET[METHOD] | ||
return { | ||
stop: () => { | ||
stopped = true | ||
// If the instrumentation has been removed by a third party, keep the last one | ||
if (targetPrototype[method] === instrumentation) { | ||
targetPrototype[method] = original | ||
} | ||
}, | ||
} | ||
} | ||
@@ -139,0 +139,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { display } from '../tools/display' | ||
import { DOCS_ORIGIN, display } from '../tools/display' | ||
import type { Context } from '../tools/serialisation/context' | ||
@@ -84,3 +84,3 @@ import { objectValues } from '../tools/utils/polyfills' | ||
display.warn( | ||
`Discarded a message whose size was bigger than the maximum allowed size ${this.messageBytesLimit}KB.` | ||
`Discarded a message whose size was bigger than the maximum allowed size ${this.messageBytesLimit}KB. More details: ${DOCS_ORIGIN}/real_user_monitoring/browser/troubleshooting/#technical-limitations` | ||
) | ||
@@ -87,0 +87,0 @@ return |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1111138
19810