@datadog/browser-core
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -8,2 +8,3 @@ export interface FetchProxy<StartContext extends FetchStartContext = FetchStartContext, CompleteContext extends FetchCompleteContext = FetchCompleteContext> { | ||
startTime: number; | ||
input: RequestInfo; | ||
init?: RequestInit; | ||
@@ -10,0 +11,0 @@ url: string; |
@@ -49,2 +49,3 @@ "use strict"; | ||
init: init, | ||
input: input, | ||
method: method, | ||
@@ -90,3 +91,3 @@ startTime: startTime, | ||
beforeSendCallbacks.forEach(function (callback) { return callback(context); }); | ||
var responsePromise = originalFetch.call(this, input, context.init); | ||
var responsePromise = originalFetch.call(this, context.input, context.init); | ||
responsePromise.then(internalMonitoring_1.monitor(reportFetch), internalMonitoring_1.monitor(reportFetch)); | ||
@@ -93,0 +94,0 @@ return responsePromise; |
@@ -59,15 +59,17 @@ import { BuildEnv, Datacenter } from '../boot/init'; | ||
} | ||
export declare type Configuration = typeof DEFAULT_CONFIGURATION & { | ||
export declare type Configuration = typeof DEFAULT_CONFIGURATION & TransportConfiguration & { | ||
cookieOptions: CookieOptions; | ||
service?: string; | ||
beforeSend?: (event: any) => void; | ||
isEnabled: (feature: string) => boolean; | ||
}; | ||
export interface TransportConfiguration { | ||
logsEndpoint: string; | ||
rumEndpoint: string; | ||
traceEndpoint: string; | ||
sessionReplayEndpoint: string; | ||
internalMonitoringEndpoint?: string; | ||
proxyHost?: string; | ||
service?: string; | ||
beforeSend?: (event: any) => void; | ||
isEnabled: (feature: string) => boolean; | ||
isIntakeUrl: (url: string) => boolean; | ||
replica?: ReplicaConfiguration; | ||
}; | ||
} | ||
interface ReplicaConfiguration { | ||
@@ -74,0 +76,0 @@ applicationId?: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var init_1 = require("../boot/init"); | ||
var cookie_1 = require("../browser/cookie"); | ||
var utils_1 = require("../tools/utils"); | ||
var transportConfiguration_1 = require("./transportConfiguration"); | ||
exports.DEFAULT_CONFIGURATION = { | ||
@@ -35,37 +35,9 @@ allowedTracingOrigins: [], | ||
}; | ||
var ENDPOINTS = { | ||
alternate: { | ||
logs: 'logs', | ||
rum: 'rum', | ||
trace: 'trace', | ||
}, | ||
classic: { | ||
logs: 'browser', | ||
rum: 'rum', | ||
trace: 'public-trace', | ||
}, | ||
}; | ||
function buildConfiguration(userConfiguration, buildEnv) { | ||
var transportConfiguration = { | ||
applicationId: userConfiguration.applicationId, | ||
buildMode: buildEnv.buildMode, | ||
clientToken: userConfiguration.clientToken, | ||
env: userConfiguration.env, | ||
proxyHost: userConfiguration.proxyHost, | ||
sdkVersion: buildEnv.sdkVersion, | ||
service: userConfiguration.service, | ||
site: userConfiguration.site || init_1.INTAKE_SITE[userConfiguration.datacenter || buildEnv.datacenter], | ||
version: userConfiguration.version, | ||
}; | ||
var enableExperimentalFeatures = Array.isArray(userConfiguration.enableExperimentalFeatures) | ||
? userConfiguration.enableExperimentalFeatures | ||
: []; | ||
var intakeType = getIntakeType(transportConfiguration.site, userConfiguration); | ||
var intakeUrls = getIntakeUrls(intakeType, transportConfiguration, userConfiguration.replica !== undefined); | ||
var configuration = tslib_1.__assign({ beforeSend: userConfiguration.beforeSend, cookieOptions: buildCookieOptions(userConfiguration), isEnabled: function (feature) { | ||
var configuration = tslib_1.__assign(tslib_1.__assign({ beforeSend: userConfiguration.beforeSend, cookieOptions: buildCookieOptions(userConfiguration), isEnabled: function (feature) { | ||
return utils_1.includes(enableExperimentalFeatures, feature); | ||
}, logsEndpoint: getEndpoint(intakeType, 'logs', transportConfiguration), proxyHost: userConfiguration.proxyHost, rumEndpoint: getEndpoint(intakeType, 'rum', transportConfiguration), service: userConfiguration.service, traceEndpoint: getEndpoint(intakeType, 'trace', transportConfiguration), isIntakeUrl: function (url) { return intakeUrls.some(function (intakeUrl) { return url.indexOf(intakeUrl) === 0; }); } }, exports.DEFAULT_CONFIGURATION); | ||
if (userConfiguration.internalMonitoringApiKey) { | ||
configuration.internalMonitoringEndpoint = getEndpoint(intakeType, 'logs', transportConfiguration, 'browser-agent-internal-monitoring'); | ||
} | ||
}, service: userConfiguration.service }, transportConfiguration_1.computeTransportConfiguration(userConfiguration, buildEnv)), exports.DEFAULT_CONFIGURATION); | ||
if ('allowedTracingOrigins' in userConfiguration) { | ||
@@ -83,18 +55,2 @@ configuration.allowedTracingOrigins = userConfiguration.allowedTracingOrigins; | ||
} | ||
if (transportConfiguration.buildMode === init_1.BuildMode.E2E_TEST) { | ||
configuration.internalMonitoringEndpoint = '<<< E2E INTERNAL MONITORING ENDPOINT >>>'; | ||
configuration.logsEndpoint = '<<< E2E LOGS ENDPOINT >>>'; | ||
configuration.rumEndpoint = '<<< E2E RUM ENDPOINT >>>'; | ||
} | ||
if (transportConfiguration.buildMode === init_1.BuildMode.STAGING) { | ||
if (userConfiguration.replica !== undefined) { | ||
var replicaTransportConfiguration = tslib_1.__assign(tslib_1.__assign({}, transportConfiguration), { applicationId: userConfiguration.replica.applicationId, clientToken: userConfiguration.replica.clientToken, site: init_1.INTAKE_SITE[init_1.Datacenter.US] }); | ||
configuration.replica = { | ||
applicationId: userConfiguration.replica.applicationId, | ||
internalMonitoringEndpoint: getEndpoint(intakeType, 'logs', replicaTransportConfiguration, 'browser-agent-internal-monitoring'), | ||
logsEndpoint: getEndpoint(intakeType, 'logs', replicaTransportConfiguration), | ||
rumEndpoint: getEndpoint(intakeType, 'rum', replicaTransportConfiguration), | ||
}; | ||
} | ||
} | ||
return configuration; | ||
@@ -113,47 +69,2 @@ } | ||
exports.buildCookieOptions = buildCookieOptions; | ||
function getEndpoint(intakeType, endpointType, conf, source) { | ||
var tags = "sdk_version:" + conf.sdkVersion + | ||
("" + (conf.env ? ",env:" + conf.env : '')) + | ||
("" + (conf.service ? ",service:" + conf.service : '')) + | ||
("" + (conf.version ? ",version:" + conf.version : '')); | ||
var datadogHost = getHost(intakeType, endpointType, conf.site); | ||
var host = conf.proxyHost ? conf.proxyHost : datadogHost; | ||
var proxyParameter = conf.proxyHost ? "ddhost=" + datadogHost + "&" : ''; | ||
var applicationIdParameter = conf.applicationId ? "_dd.application_id=" + conf.applicationId + "&" : ''; | ||
var parameters = "" + applicationIdParameter + proxyParameter + "ddsource=" + (source || 'browser') + "&ddtags=" + tags; | ||
return "https://" + host + "/v1/input/" + conf.clientToken + "?" + parameters; | ||
} | ||
function getHost(intakeType, endpointType, site) { | ||
var endpoint = ENDPOINTS[intakeType][endpointType]; | ||
if (intakeType === 'classic') { | ||
return endpoint + "-http-intake.logs." + site; | ||
} | ||
var domainParts = site.split('.'); | ||
var extension = domainParts.pop(); | ||
var suffix = domainParts.join('-') + "." + extension; | ||
return endpoint + ".browser-intake-" + suffix; | ||
} | ||
function getIntakeType(site, userConfiguration) { | ||
// TODO when new intake will be available for gov, only allow classic intake for us and eu | ||
return userConfiguration.useAlternateIntakeDomains || site === 'us3.datadoghq.com' ? 'alternate' : 'classic'; | ||
} | ||
function getIntakeUrls(intakeType, conf, withReplica) { | ||
if (conf.proxyHost) { | ||
return ["https://" + conf.proxyHost + "/v1/input/"]; | ||
} | ||
var sites = [conf.site]; | ||
if (conf.buildMode === init_1.BuildMode.STAGING && withReplica) { | ||
sites.push(init_1.INTAKE_SITE[init_1.Datacenter.US]); | ||
} | ||
var urls = []; | ||
var endpointTypes = Object.keys(ENDPOINTS[intakeType]); | ||
for (var _i = 0, sites_1 = sites; _i < sites_1.length; _i++) { | ||
var site = sites_1[_i]; | ||
for (var _a = 0, endpointTypes_1 = endpointTypes; _a < endpointTypes_1.length; _a++) { | ||
var endpointType = endpointTypes_1[_a]; | ||
urls.push("https://" + getHost(intakeType, endpointType, site) + "/v1/input/"); | ||
} | ||
} | ||
return urls; | ||
} | ||
function mustUseSecureCookie(userConfiguration) { | ||
@@ -160,0 +71,0 @@ return !!userConfiguration.useSecureSessionCookie || !!userConfiguration.useCrossSiteSessionCookie; |
@@ -416,3 +416,3 @@ "use strict"; | ||
// tslint:disable-next-line max-line-length | ||
var gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i; | ||
var gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i; | ||
// tslint:disable-next-line max-line-length | ||
@@ -419,0 +419,0 @@ var winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i; |
@@ -5,3 +5,3 @@ export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, buildCookieOptions } from './domain/configuration'; | ||
export { BuildEnv, BuildMode, Datacenter, defineGlobal, makePublicApi, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './boot/init'; | ||
export { InternalMonitoring, MonitoringMessage, monitored, monitor, addMonitoringMessage, } from './domain/internalMonitoring'; | ||
export { InternalMonitoring, MonitoringMessage, monitored, monitor, addMonitoringMessage, setDebugMode, } from './domain/internalMonitoring'; | ||
export { Observable } from './tools/observable'; | ||
@@ -8,0 +8,0 @@ export { startSessionManagement, SESSION_TIME_OUT_DELAY, SESSION_COOKIE_NAME, stopSessionManagement, } from './domain/sessionManagement'; |
@@ -23,2 +23,3 @@ "use strict"; | ||
exports.addMonitoringMessage = internalMonitoring_1.addMonitoringMessage; | ||
exports.setDebugMode = internalMonitoring_1.setDebugMode; | ||
var observable_1 = require("./tools/observable"); | ||
@@ -25,0 +26,0 @@ exports.Observable = observable_1.Observable; |
@@ -18,4 +18,4 @@ import { Configuration } from '../domain/configuration'; | ||
export interface FetchStubPromise extends Promise<Response> { | ||
resolveWith: (response: ResponseStub) => Promise<ResponseStub>; | ||
rejectWith: (error: Error) => Promise<Error>; | ||
resolveWith: (response: ResponseStub) => void; | ||
rejectWith: (error: Error) => void; | ||
} | ||
@@ -22,0 +22,0 @@ declare class StubXhr { |
@@ -57,31 +57,22 @@ "use strict"; | ||
}); | ||
promise.resolveWith = function (response) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var resolved; | ||
var _this = this; | ||
return tslib_1.__generator(this, function (_a) { | ||
resolved = resolve(tslib_1.__assign(tslib_1.__assign({}, response), { clone: function () { | ||
var cloned = { | ||
text: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
if (response.responseTextError) { | ||
throw response.responseTextError; | ||
} | ||
return [2 /*return*/, response.responseText]; | ||
}); | ||
}); }, | ||
}; | ||
return cloned; | ||
} })); | ||
onRequestEnd(); | ||
return [2 /*return*/, resolved]; | ||
}); | ||
}); }; | ||
promise.rejectWith = function (error) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var rejected; | ||
return tslib_1.__generator(this, function (_a) { | ||
rejected = reject(error); | ||
onRequestEnd(); | ||
return [2 /*return*/, rejected]; | ||
}); | ||
}); }; | ||
promise.resolveWith = function (response) { | ||
resolve(tslib_1.__assign(tslib_1.__assign({}, response), { clone: function () { | ||
var cloned = { | ||
text: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
if (response.responseTextError) { | ||
throw response.responseTextError; | ||
} | ||
return [2 /*return*/, response.responseText]; | ||
}); | ||
}); }, | ||
}; | ||
return cloned; | ||
} })); | ||
onRequestEnd(); | ||
}; | ||
promise.rejectWith = function (error) { | ||
reject(error); | ||
onRequestEnd(); | ||
}; | ||
return promise; | ||
@@ -88,0 +79,0 @@ }); |
@@ -15,3 +15,3 @@ import { Context } from '../tools/context'; | ||
constructor(endpointUrl: string, bytesLimit: number, withBatchTime?: boolean); | ||
send(data: string, size: number): void; | ||
send(data: string | FormData, size: number): void; | ||
} | ||
@@ -18,0 +18,0 @@ export declare class Batch { |
@@ -8,2 +8,3 @@ export interface FetchProxy<StartContext extends FetchStartContext = FetchStartContext, CompleteContext extends FetchCompleteContext = FetchCompleteContext> { | ||
startTime: number; | ||
input: RequestInfo; | ||
init?: RequestInit; | ||
@@ -10,0 +11,0 @@ url: string; |
@@ -45,2 +45,3 @@ import { __awaiter, __generator } from "tslib"; | ||
init: init, | ||
input: input, | ||
method: method, | ||
@@ -86,3 +87,3 @@ startTime: startTime, | ||
beforeSendCallbacks.forEach(function (callback) { return callback(context); }); | ||
var responsePromise = originalFetch.call(this, input, context.init); | ||
var responsePromise = originalFetch.call(this, context.input, context.init); | ||
responsePromise.then(monitor(reportFetch), monitor(reportFetch)); | ||
@@ -89,0 +90,0 @@ return responsePromise; |
@@ -59,15 +59,17 @@ import { BuildEnv, Datacenter } from '../boot/init'; | ||
} | ||
export declare type Configuration = typeof DEFAULT_CONFIGURATION & { | ||
export declare type Configuration = typeof DEFAULT_CONFIGURATION & TransportConfiguration & { | ||
cookieOptions: CookieOptions; | ||
service?: string; | ||
beforeSend?: (event: any) => void; | ||
isEnabled: (feature: string) => boolean; | ||
}; | ||
export interface TransportConfiguration { | ||
logsEndpoint: string; | ||
rumEndpoint: string; | ||
traceEndpoint: string; | ||
sessionReplayEndpoint: string; | ||
internalMonitoringEndpoint?: string; | ||
proxyHost?: string; | ||
service?: string; | ||
beforeSend?: (event: any) => void; | ||
isEnabled: (feature: string) => boolean; | ||
isIntakeUrl: (url: string) => boolean; | ||
replica?: ReplicaConfiguration; | ||
}; | ||
} | ||
interface ReplicaConfiguration { | ||
@@ -74,0 +76,0 @@ applicationId?: string; |
import { __assign } from "tslib"; | ||
import { BuildMode, Datacenter, INTAKE_SITE } from '../boot/init'; | ||
import { getCurrentSite } from '../browser/cookie'; | ||
import { includes, ONE_KILO_BYTE, ONE_SECOND } from '../tools/utils'; | ||
import { computeTransportConfiguration } from './transportConfiguration'; | ||
export var DEFAULT_CONFIGURATION = { | ||
@@ -33,37 +33,9 @@ allowedTracingOrigins: [], | ||
}; | ||
var ENDPOINTS = { | ||
alternate: { | ||
logs: 'logs', | ||
rum: 'rum', | ||
trace: 'trace', | ||
}, | ||
classic: { | ||
logs: 'browser', | ||
rum: 'rum', | ||
trace: 'public-trace', | ||
}, | ||
}; | ||
export function buildConfiguration(userConfiguration, buildEnv) { | ||
var transportConfiguration = { | ||
applicationId: userConfiguration.applicationId, | ||
buildMode: buildEnv.buildMode, | ||
clientToken: userConfiguration.clientToken, | ||
env: userConfiguration.env, | ||
proxyHost: userConfiguration.proxyHost, | ||
sdkVersion: buildEnv.sdkVersion, | ||
service: userConfiguration.service, | ||
site: userConfiguration.site || INTAKE_SITE[userConfiguration.datacenter || buildEnv.datacenter], | ||
version: userConfiguration.version, | ||
}; | ||
var enableExperimentalFeatures = Array.isArray(userConfiguration.enableExperimentalFeatures) | ||
? userConfiguration.enableExperimentalFeatures | ||
: []; | ||
var intakeType = getIntakeType(transportConfiguration.site, userConfiguration); | ||
var intakeUrls = getIntakeUrls(intakeType, transportConfiguration, userConfiguration.replica !== undefined); | ||
var configuration = __assign({ beforeSend: userConfiguration.beforeSend, cookieOptions: buildCookieOptions(userConfiguration), isEnabled: function (feature) { | ||
var configuration = __assign(__assign({ beforeSend: userConfiguration.beforeSend, cookieOptions: buildCookieOptions(userConfiguration), isEnabled: function (feature) { | ||
return includes(enableExperimentalFeatures, feature); | ||
}, logsEndpoint: getEndpoint(intakeType, 'logs', transportConfiguration), proxyHost: userConfiguration.proxyHost, rumEndpoint: getEndpoint(intakeType, 'rum', transportConfiguration), service: userConfiguration.service, traceEndpoint: getEndpoint(intakeType, 'trace', transportConfiguration), isIntakeUrl: function (url) { return intakeUrls.some(function (intakeUrl) { return url.indexOf(intakeUrl) === 0; }); } }, DEFAULT_CONFIGURATION); | ||
if (userConfiguration.internalMonitoringApiKey) { | ||
configuration.internalMonitoringEndpoint = getEndpoint(intakeType, 'logs', transportConfiguration, 'browser-agent-internal-monitoring'); | ||
} | ||
}, service: userConfiguration.service }, computeTransportConfiguration(userConfiguration, buildEnv)), DEFAULT_CONFIGURATION); | ||
if ('allowedTracingOrigins' in userConfiguration) { | ||
@@ -81,18 +53,2 @@ configuration.allowedTracingOrigins = userConfiguration.allowedTracingOrigins; | ||
} | ||
if (transportConfiguration.buildMode === BuildMode.E2E_TEST) { | ||
configuration.internalMonitoringEndpoint = '<<< E2E INTERNAL MONITORING ENDPOINT >>>'; | ||
configuration.logsEndpoint = '<<< E2E LOGS ENDPOINT >>>'; | ||
configuration.rumEndpoint = '<<< E2E RUM ENDPOINT >>>'; | ||
} | ||
if (transportConfiguration.buildMode === BuildMode.STAGING) { | ||
if (userConfiguration.replica !== undefined) { | ||
var replicaTransportConfiguration = __assign(__assign({}, transportConfiguration), { applicationId: userConfiguration.replica.applicationId, clientToken: userConfiguration.replica.clientToken, site: INTAKE_SITE[Datacenter.US] }); | ||
configuration.replica = { | ||
applicationId: userConfiguration.replica.applicationId, | ||
internalMonitoringEndpoint: getEndpoint(intakeType, 'logs', replicaTransportConfiguration, 'browser-agent-internal-monitoring'), | ||
logsEndpoint: getEndpoint(intakeType, 'logs', replicaTransportConfiguration), | ||
rumEndpoint: getEndpoint(intakeType, 'rum', replicaTransportConfiguration), | ||
}; | ||
} | ||
} | ||
return configuration; | ||
@@ -109,47 +65,2 @@ } | ||
} | ||
function getEndpoint(intakeType, endpointType, conf, source) { | ||
var tags = "sdk_version:" + conf.sdkVersion + | ||
("" + (conf.env ? ",env:" + conf.env : '')) + | ||
("" + (conf.service ? ",service:" + conf.service : '')) + | ||
("" + (conf.version ? ",version:" + conf.version : '')); | ||
var datadogHost = getHost(intakeType, endpointType, conf.site); | ||
var host = conf.proxyHost ? conf.proxyHost : datadogHost; | ||
var proxyParameter = conf.proxyHost ? "ddhost=" + datadogHost + "&" : ''; | ||
var applicationIdParameter = conf.applicationId ? "_dd.application_id=" + conf.applicationId + "&" : ''; | ||
var parameters = "" + applicationIdParameter + proxyParameter + "ddsource=" + (source || 'browser') + "&ddtags=" + tags; | ||
return "https://" + host + "/v1/input/" + conf.clientToken + "?" + parameters; | ||
} | ||
function getHost(intakeType, endpointType, site) { | ||
var endpoint = ENDPOINTS[intakeType][endpointType]; | ||
if (intakeType === 'classic') { | ||
return endpoint + "-http-intake.logs." + site; | ||
} | ||
var domainParts = site.split('.'); | ||
var extension = domainParts.pop(); | ||
var suffix = domainParts.join('-') + "." + extension; | ||
return endpoint + ".browser-intake-" + suffix; | ||
} | ||
function getIntakeType(site, userConfiguration) { | ||
// TODO when new intake will be available for gov, only allow classic intake for us and eu | ||
return userConfiguration.useAlternateIntakeDomains || site === 'us3.datadoghq.com' ? 'alternate' : 'classic'; | ||
} | ||
function getIntakeUrls(intakeType, conf, withReplica) { | ||
if (conf.proxyHost) { | ||
return ["https://" + conf.proxyHost + "/v1/input/"]; | ||
} | ||
var sites = [conf.site]; | ||
if (conf.buildMode === BuildMode.STAGING && withReplica) { | ||
sites.push(INTAKE_SITE[Datacenter.US]); | ||
} | ||
var urls = []; | ||
var endpointTypes = Object.keys(ENDPOINTS[intakeType]); | ||
for (var _i = 0, sites_1 = sites; _i < sites_1.length; _i++) { | ||
var site = sites_1[_i]; | ||
for (var _a = 0, endpointTypes_1 = endpointTypes; _a < endpointTypes_1.length; _a++) { | ||
var endpointType = endpointTypes_1[_a]; | ||
urls.push("https://" + getHost(intakeType, endpointType, site) + "/v1/input/"); | ||
} | ||
} | ||
return urls; | ||
} | ||
function mustUseSecureCookie(userConfiguration) { | ||
@@ -156,0 +67,0 @@ return !!userConfiguration.useSecureSessionCookie || !!userConfiguration.useCrossSiteSessionCookie; |
@@ -413,3 +413,3 @@ // tslint:disable no-unsafe-any | ||
// tslint:disable-next-line max-line-length | ||
var gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i; | ||
var gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i; | ||
// tslint:disable-next-line max-line-length | ||
@@ -416,0 +416,0 @@ var winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i; |
@@ -5,3 +5,3 @@ export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, buildCookieOptions } from './domain/configuration'; | ||
export { BuildEnv, BuildMode, Datacenter, defineGlobal, makePublicApi, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './boot/init'; | ||
export { InternalMonitoring, MonitoringMessage, monitored, monitor, addMonitoringMessage, } from './domain/internalMonitoring'; | ||
export { InternalMonitoring, MonitoringMessage, monitored, monitor, addMonitoringMessage, setDebugMode, } from './domain/internalMonitoring'; | ||
export { Observable } from './tools/observable'; | ||
@@ -8,0 +8,0 @@ export { startSessionManagement, SESSION_TIME_OUT_DELAY, SESSION_COOKIE_NAME, stopSessionManagement, } from './domain/sessionManagement'; |
@@ -5,3 +5,3 @@ export { DEFAULT_CONFIGURATION, buildCookieOptions } from './domain/configuration'; | ||
export { BuildMode, Datacenter, defineGlobal, makePublicApi, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './boot/init'; | ||
export { monitored, monitor, addMonitoringMessage, } from './domain/internalMonitoring'; | ||
export { monitored, monitor, addMonitoringMessage, setDebugMode, } from './domain/internalMonitoring'; | ||
export { Observable } from './tools/observable'; | ||
@@ -8,0 +8,0 @@ export { startSessionManagement, SESSION_TIME_OUT_DELAY, |
@@ -18,4 +18,4 @@ import { Configuration } from '../domain/configuration'; | ||
export interface FetchStubPromise extends Promise<Response> { | ||
resolveWith: (response: ResponseStub) => Promise<ResponseStub>; | ||
rejectWith: (error: Error) => Promise<Error>; | ||
resolveWith: (response: ResponseStub) => void; | ||
rejectWith: (error: Error) => void; | ||
} | ||
@@ -22,0 +22,0 @@ declare class StubXhr { |
@@ -51,31 +51,22 @@ import { __assign, __awaiter, __generator } from "tslib"; | ||
}); | ||
promise.resolveWith = function (response) { return __awaiter(_this, void 0, void 0, function () { | ||
var resolved; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
resolved = resolve(__assign(__assign({}, response), { clone: function () { | ||
var cloned = { | ||
text: function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
if (response.responseTextError) { | ||
throw response.responseTextError; | ||
} | ||
return [2 /*return*/, response.responseText]; | ||
}); | ||
}); }, | ||
}; | ||
return cloned; | ||
} })); | ||
onRequestEnd(); | ||
return [2 /*return*/, resolved]; | ||
}); | ||
}); }; | ||
promise.rejectWith = function (error) { return __awaiter(_this, void 0, void 0, function () { | ||
var rejected; | ||
return __generator(this, function (_a) { | ||
rejected = reject(error); | ||
onRequestEnd(); | ||
return [2 /*return*/, rejected]; | ||
}); | ||
}); }; | ||
promise.resolveWith = function (response) { | ||
resolve(__assign(__assign({}, response), { clone: function () { | ||
var cloned = { | ||
text: function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
if (response.responseTextError) { | ||
throw response.responseTextError; | ||
} | ||
return [2 /*return*/, response.responseText]; | ||
}); | ||
}); }, | ||
}; | ||
return cloned; | ||
} })); | ||
onRequestEnd(); | ||
}; | ||
promise.rejectWith = function (error) { | ||
reject(error); | ||
onRequestEnd(); | ||
}; | ||
return promise; | ||
@@ -82,0 +73,0 @@ }); |
@@ -15,3 +15,3 @@ import { Context } from '../tools/context'; | ||
constructor(endpointUrl: string, bytesLimit: number, withBatchTime?: boolean); | ||
send(data: string, size: number): void; | ||
send(data: string | FormData, size: number): void; | ||
} | ||
@@ -18,0 +18,0 @@ export declare class Batch { |
{ | ||
"name": "@datadog/browser-core", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"license": "Apache-2.0", | ||
@@ -26,3 +26,3 @@ "main": "cjs/index.js", | ||
}, | ||
"gitHead": "129bd33e18a2e07fefb995b090254fcc32e601f6" | ||
"gitHead": "f92ef270e80cbe49abf97e08622228ae46681518" | ||
} |
@@ -17,2 +17,3 @@ import { monitor } from '../domain/internalMonitoring' | ||
startTime: number | ||
input: RequestInfo | ||
init?: RequestInit | ||
@@ -81,2 +82,3 @@ url: string | ||
init, | ||
input, | ||
method, | ||
@@ -111,3 +113,3 @@ startTime, | ||
const responsePromise = originalFetch.call(this, input, context.init) | ||
const responsePromise = originalFetch.call(this, context.input, context.init) | ||
responsePromise.then(monitor(reportFetch), monitor(reportFetch)) | ||
@@ -114,0 +116,0 @@ return responsePromise |
@@ -12,75 +12,2 @@ import { BuildEnv, BuildMode, Datacenter } from '../boot/init' | ||
describe('internal monitoring endpoint', () => { | ||
it('should only be defined when api key is provided', () => { | ||
let configuration = buildConfiguration({ clientToken }, usEnv) | ||
expect(configuration.internalMonitoringEndpoint).toBeUndefined() | ||
configuration = buildConfiguration({ clientToken, internalMonitoringApiKey: clientToken }, usEnv) | ||
expect(configuration.internalMonitoringEndpoint).toContain(clientToken) | ||
}) | ||
}) | ||
describe('endpoint overload', () => { | ||
it('should be available for e2e-test build mode', () => { | ||
const e2eEnv = { | ||
buildMode: BuildMode.E2E_TEST, | ||
datacenter: Datacenter.US, | ||
sdkVersion: 'some_version', | ||
} | ||
const configuration = buildConfiguration({ clientToken }, e2eEnv) | ||
expect(configuration.rumEndpoint).toEqual('<<< E2E RUM ENDPOINT >>>') | ||
expect(configuration.logsEndpoint).toEqual('<<< E2E LOGS ENDPOINT >>>') | ||
expect(configuration.internalMonitoringEndpoint).toEqual('<<< E2E INTERNAL MONITORING ENDPOINT >>>') | ||
}) | ||
}) | ||
describe('site', () => { | ||
it('should use buildEnv value by default', () => { | ||
const configuration = buildConfiguration({ clientToken }, usEnv) | ||
expect(configuration.rumEndpoint).toContain('datadoghq.com') | ||
}) | ||
it('should use datacenter value when set', () => { | ||
const configuration = buildConfiguration({ clientToken, datacenter: Datacenter.EU }, usEnv) | ||
expect(configuration.rumEndpoint).toContain('datadoghq.eu') | ||
}) | ||
it('should use site value when set', () => { | ||
const configuration = buildConfiguration({ clientToken, datacenter: Datacenter.EU, site: 'foo.com' }, usEnv) | ||
expect(configuration.rumEndpoint).toContain('foo.com') | ||
}) | ||
}) | ||
describe('proxyHost', () => { | ||
it('should replace endpoint host add set it as a query parameter', () => { | ||
const configuration = buildConfiguration({ clientToken, site: 'datadoghq.eu', proxyHost: 'proxy.io' }, usEnv) | ||
expect(configuration.rumEndpoint).toMatch(/^https:\/\/proxy\.io\//) | ||
expect(configuration.rumEndpoint).toContain('?ddhost=rum-http-intake.logs.datadoghq.eu&') | ||
}) | ||
}) | ||
describe('sdk_version, env, version and service', () => { | ||
it('should not modify the logs and rum endpoints tags when not defined', () => { | ||
const configuration = buildConfiguration({ clientToken }, usEnv) | ||
expect(configuration.rumEndpoint).toContain(`&ddtags=sdk_version:${usEnv.sdkVersion}`) | ||
expect(configuration.rumEndpoint).not.toContain(',env:') | ||
expect(configuration.rumEndpoint).not.toContain(',service:') | ||
expect(configuration.rumEndpoint).not.toContain(',version:') | ||
expect(configuration.logsEndpoint).not.toContain(',env:') | ||
expect(configuration.logsEndpoint).not.toContain(',service:') | ||
expect(configuration.logsEndpoint).not.toContain(',version:') | ||
}) | ||
it('should be set as tags in the logs and rum endpoints', () => { | ||
const configuration = buildConfiguration({ clientToken, env: 'foo', service: 'bar', version: 'baz' }, usEnv) | ||
expect(configuration.rumEndpoint).toContain( | ||
`&ddtags=sdk_version:${usEnv.sdkVersion},env:foo,service:bar,version:baz` | ||
) | ||
expect(configuration.logsEndpoint).toContain( | ||
`&ddtags=sdk_version:${usEnv.sdkVersion},env:foo,service:bar,version:baz` | ||
) | ||
}) | ||
}) | ||
describe('cookie options', () => { | ||
@@ -107,103 +34,2 @@ it('should not be secure nor crossSite by default', () => { | ||
}) | ||
describe('isIntakeUrl', () => { | ||
it('should not detect non intake request', () => { | ||
const configuration = buildConfiguration({ clientToken }, usEnv) | ||
expect(configuration.isIntakeUrl('https://www.foo.com')).toBe(false) | ||
}) | ||
it('should detect intake request for EU site', () => { | ||
const configuration = buildConfiguration({ clientToken, site: 'datadoghq.eu' }, usEnv) | ||
expect(configuration.isIntakeUrl('https://rum-http-intake.logs.datadoghq.eu/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://browser-http-intake.logs.datadoghq.eu/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://public-trace-http-intake.logs.datadoghq.eu/v1/input/xxx')).toBe(true) | ||
}) | ||
it('should detect intake request for US site', () => { | ||
const configuration = buildConfiguration({ clientToken }, usEnv) | ||
expect(configuration.isIntakeUrl('https://rum-http-intake.logs.datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://browser-http-intake.logs.datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://public-trace-http-intake.logs.datadoghq.com/v1/input/xxx')).toBe(true) | ||
}) | ||
it('should detect alternate intake domains for US site', () => { | ||
const configuration = buildConfiguration({ clientToken, useAlternateIntakeDomains: true }, usEnv) | ||
expect(configuration.isIntakeUrl('https://rum.browser-intake-datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://logs.browser-intake-datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://trace.browser-intake-datadoghq.com/v1/input/xxx')).toBe(true) | ||
}) | ||
it('should handle sites with subdomains and classic intake', () => { | ||
const configuration = buildConfiguration({ clientToken, site: 'foo.datadoghq.com' }, usEnv) | ||
expect(configuration.isIntakeUrl('https://rum-http-intake.logs.foo.datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://browser-http-intake.logs.foo.datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://public-trace-http-intake.logs.foo.datadoghq.com/v1/input/xxx')).toBe( | ||
true | ||
) | ||
}) | ||
it('should handle sites with subdomains and alternate intake', () => { | ||
const configuration = buildConfiguration( | ||
{ clientToken, site: 'foo.datadoghq.com', useAlternateIntakeDomains: true }, | ||
usEnv | ||
) | ||
expect(configuration.isIntakeUrl('https://rum.browser-intake-foo-datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://logs.browser-intake-foo-datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://trace.browser-intake-foo-datadoghq.com/v1/input/xxx')).toBe(true) | ||
}) | ||
it('should force alternate intake for us3', () => { | ||
const configuration = buildConfiguration( | ||
{ clientToken, site: 'us3.datadoghq.com', useAlternateIntakeDomains: false }, | ||
usEnv | ||
) | ||
expect(configuration.isIntakeUrl('https://rum.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://logs.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://trace.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true) | ||
}) | ||
it('should detect proxy intake request', () => { | ||
let configuration = buildConfiguration({ clientToken, proxyHost: 'www.proxy.com' }, usEnv) | ||
expect(configuration.isIntakeUrl('https://www.proxy.com/v1/input/xxx')).toBe(true) | ||
configuration = buildConfiguration( | ||
{ clientToken, proxyHost: 'www.proxy.com', useAlternateIntakeDomains: true }, | ||
usEnv | ||
) | ||
expect(configuration.isIntakeUrl('https://www.proxy.com/v1/input/xxx')).toBe(true) | ||
configuration = buildConfiguration({ clientToken, proxyHost: 'www.proxy.com/custom/path' }, usEnv) | ||
expect(configuration.isIntakeUrl('https://www.proxy.com/custom/path/v1/input/xxx')).toBe(true) | ||
}) | ||
it('should not detect request done on the same host as the proxy', () => { | ||
const configuration = buildConfiguration({ clientToken, proxyHost: 'www.proxy.com' }, usEnv) | ||
expect(configuration.isIntakeUrl('https://www.proxy.com/foo')).toBe(false) | ||
}) | ||
it('should detect replica intake request', () => { | ||
const configuration = buildConfiguration( | ||
{ clientToken, site: 'foo.com', replica: { clientToken } }, | ||
{ ...usEnv, buildMode: BuildMode.STAGING } | ||
) | ||
expect(configuration.isIntakeUrl('https://rum-http-intake.logs.foo.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://browser-http-intake.logs.foo.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://public-trace-http-intake.logs.foo.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://rum-http-intake.logs.datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://browser-http-intake.logs.datadoghq.com/v1/input/xxx')).toBe(true) | ||
}) | ||
it('should detect replica intake request with alternate intake domains', () => { | ||
const configuration = buildConfiguration( | ||
{ clientToken, site: 'foo.com', replica: { clientToken }, useAlternateIntakeDomains: true }, | ||
{ ...usEnv, buildMode: BuildMode.STAGING } | ||
) | ||
expect(configuration.isIntakeUrl('https://rum.browser-intake-foo.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://logs.browser-intake-foo.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://trace.browser-intake-foo.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://rum.browser-intake-datadoghq.com/v1/input/xxx')).toBe(true) | ||
expect(configuration.isIntakeUrl('https://logs.browser-intake-datadoghq.com/v1/input/xxx')).toBe(true) | ||
}) | ||
}) | ||
}) |
@@ -1,4 +0,5 @@ | ||
import { BuildEnv, BuildMode, Datacenter, INTAKE_SITE } from '../boot/init' | ||
import { BuildEnv, Datacenter } from '../boot/init' | ||
import { CookieOptions, getCurrentSite } from '../browser/cookie' | ||
import { includes, ONE_KILO_BYTE, ONE_SECOND } from '../tools/utils' | ||
import { computeTransportConfiguration } from './transportConfiguration' | ||
@@ -72,14 +73,18 @@ export const DEFAULT_CONFIGURATION = { | ||
export type Configuration = typeof DEFAULT_CONFIGURATION & { | ||
cookieOptions: CookieOptions | ||
export type Configuration = typeof DEFAULT_CONFIGURATION & | ||
TransportConfiguration & { | ||
cookieOptions: CookieOptions | ||
service?: string | ||
beforeSend?: (event: any) => void | ||
isEnabled: (feature: string) => boolean | ||
} | ||
export interface TransportConfiguration { | ||
logsEndpoint: string | ||
rumEndpoint: string | ||
traceEndpoint: string | ||
sessionReplayEndpoint: string | ||
internalMonitoringEndpoint?: string | ||
proxyHost?: string | ||
service?: string | ||
beforeSend?: (event: any) => void | ||
isEnabled: (feature: string) => boolean | ||
isIntakeUrl: (url: string) => boolean | ||
@@ -98,43 +103,3 @@ | ||
interface TransportConfiguration { | ||
clientToken: string | ||
site: string | ||
buildMode: BuildMode | ||
sdkVersion: string | ||
applicationId?: string | ||
proxyHost?: string | ||
service?: string | ||
env?: string | ||
version?: string | ||
} | ||
const ENDPOINTS = { | ||
alternate: { | ||
logs: 'logs', | ||
rum: 'rum', | ||
trace: 'trace', | ||
}, | ||
classic: { | ||
logs: 'browser', | ||
rum: 'rum', | ||
trace: 'public-trace', | ||
}, | ||
} | ||
type IntakeType = keyof typeof ENDPOINTS | ||
type EndpointType = keyof typeof ENDPOINTS[IntakeType] | ||
export function buildConfiguration(userConfiguration: UserConfiguration, buildEnv: BuildEnv): Configuration { | ||
const transportConfiguration: TransportConfiguration = { | ||
applicationId: userConfiguration.applicationId, | ||
buildMode: buildEnv.buildMode, | ||
clientToken: userConfiguration.clientToken, | ||
env: userConfiguration.env, | ||
proxyHost: userConfiguration.proxyHost, | ||
sdkVersion: buildEnv.sdkVersion, | ||
service: userConfiguration.service, | ||
site: userConfiguration.site || INTAKE_SITE[userConfiguration.datacenter || buildEnv.datacenter], | ||
version: userConfiguration.version, | ||
} | ||
const enableExperimentalFeatures = Array.isArray(userConfiguration.enableExperimentalFeatures) | ||
@@ -144,4 +109,2 @@ ? userConfiguration.enableExperimentalFeatures | ||
const intakeType: IntakeType = getIntakeType(transportConfiguration.site, userConfiguration) | ||
const intakeUrls = getIntakeUrls(intakeType, transportConfiguration, userConfiguration.replica !== undefined) | ||
const configuration: Configuration = { | ||
@@ -153,19 +116,6 @@ beforeSend: userConfiguration.beforeSend, | ||
}, | ||
logsEndpoint: getEndpoint(intakeType, 'logs', transportConfiguration), | ||
proxyHost: userConfiguration.proxyHost, | ||
rumEndpoint: getEndpoint(intakeType, 'rum', transportConfiguration), | ||
service: userConfiguration.service, | ||
traceEndpoint: getEndpoint(intakeType, 'trace', transportConfiguration), | ||
isIntakeUrl: (url) => intakeUrls.some((intakeUrl) => url.indexOf(intakeUrl) === 0), | ||
...computeTransportConfiguration(userConfiguration, buildEnv), | ||
...DEFAULT_CONFIGURATION, | ||
} | ||
if (userConfiguration.internalMonitoringApiKey) { | ||
configuration.internalMonitoringEndpoint = getEndpoint( | ||
intakeType, | ||
'logs', | ||
transportConfiguration, | ||
'browser-agent-internal-monitoring' | ||
) | ||
} | ||
@@ -188,30 +138,2 @@ if ('allowedTracingOrigins' in userConfiguration) { | ||
if (transportConfiguration.buildMode === BuildMode.E2E_TEST) { | ||
configuration.internalMonitoringEndpoint = '<<< E2E INTERNAL MONITORING ENDPOINT >>>' | ||
configuration.logsEndpoint = '<<< E2E LOGS ENDPOINT >>>' | ||
configuration.rumEndpoint = '<<< E2E RUM ENDPOINT >>>' | ||
} | ||
if (transportConfiguration.buildMode === BuildMode.STAGING) { | ||
if (userConfiguration.replica !== undefined) { | ||
const replicaTransportConfiguration: TransportConfiguration = { | ||
...transportConfiguration, | ||
applicationId: userConfiguration.replica.applicationId, | ||
clientToken: userConfiguration.replica.clientToken, | ||
site: INTAKE_SITE[Datacenter.US], | ||
} | ||
configuration.replica = { | ||
applicationId: userConfiguration.replica.applicationId, | ||
internalMonitoringEndpoint: getEndpoint( | ||
intakeType, | ||
'logs', | ||
replicaTransportConfiguration, | ||
'browser-agent-internal-monitoring' | ||
), | ||
logsEndpoint: getEndpoint(intakeType, 'logs', replicaTransportConfiguration), | ||
rumEndpoint: getEndpoint(intakeType, 'rum', replicaTransportConfiguration), | ||
} | ||
} | ||
} | ||
return configuration | ||
@@ -233,58 +155,4 @@ } | ||
function getEndpoint( | ||
intakeType: IntakeType, | ||
endpointType: EndpointType, | ||
conf: TransportConfiguration, | ||
source?: string | ||
) { | ||
const tags = | ||
`sdk_version:${conf.sdkVersion}` + | ||
`${conf.env ? `,env:${conf.env}` : ''}` + | ||
`${conf.service ? `,service:${conf.service}` : ''}` + | ||
`${conf.version ? `,version:${conf.version}` : ''}` | ||
const datadogHost = getHost(intakeType, endpointType, conf.site) | ||
const host = conf.proxyHost ? conf.proxyHost : datadogHost | ||
const proxyParameter = conf.proxyHost ? `ddhost=${datadogHost}&` : '' | ||
const applicationIdParameter = conf.applicationId ? `_dd.application_id=${conf.applicationId}&` : '' | ||
const parameters = `${applicationIdParameter}${proxyParameter}ddsource=${source || 'browser'}&ddtags=${tags}` | ||
return `https://${host}/v1/input/${conf.clientToken}?${parameters}` | ||
} | ||
function getHost(intakeType: IntakeType, endpointType: EndpointType, site: string) { | ||
const endpoint = ENDPOINTS[intakeType][endpointType] | ||
if (intakeType === 'classic') { | ||
return `${endpoint}-http-intake.logs.${site}` | ||
} | ||
const domainParts = site.split('.') | ||
const extension = domainParts.pop() | ||
const suffix = `${domainParts.join('-')}.${extension}` | ||
return `${endpoint}.browser-intake-${suffix}` | ||
} | ||
function getIntakeType(site: string, userConfiguration: UserConfiguration) { | ||
// TODO when new intake will be available for gov, only allow classic intake for us and eu | ||
return userConfiguration.useAlternateIntakeDomains || site === 'us3.datadoghq.com' ? 'alternate' : 'classic' | ||
} | ||
function getIntakeUrls(intakeType: IntakeType, conf: TransportConfiguration, withReplica: boolean) { | ||
if (conf.proxyHost) { | ||
return [`https://${conf.proxyHost}/v1/input/`] | ||
} | ||
const sites = [conf.site] | ||
if (conf.buildMode === BuildMode.STAGING && withReplica) { | ||
sites.push(INTAKE_SITE[Datacenter.US]) | ||
} | ||
const urls = [] | ||
const endpointTypes = Object.keys(ENDPOINTS[intakeType]) as EndpointType[] | ||
for (const site of sites) { | ||
for (const endpointType of endpointTypes) { | ||
urls.push(`https://${getHost(intakeType, endpointType, site)}/v1/input/`) | ||
} | ||
} | ||
return urls | ||
} | ||
function mustUseSecureCookie(userConfiguration: UserConfiguration) { | ||
return !!userConfiguration.useSecureSessionCookie || !!userConfiguration.useCrossSiteSessionCookie | ||
} |
@@ -505,3 +505,3 @@ // tslint:disable no-unsafe-any | ||
// tslint:disable-next-line max-line-length | ||
const gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i | ||
const gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i | ||
// tslint:disable-next-line max-line-length | ||
@@ -508,0 +508,0 @@ const winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i |
@@ -1154,2 +1154,22 @@ // tslint:disable no-unsafe-any | ||
}) | ||
it('should parse iOS capacitor', () => { | ||
const stackFrames = computeStackTrace(CapturedExceptions.IOS_CAPACITOR) | ||
expect(stackFrames.stack.length).toEqual(2) | ||
expect(stackFrames.stack[0]).toEqual({ | ||
args: [], | ||
column: 99546, | ||
func: '?', | ||
line: 34, | ||
url: 'capacitor://localhost/media/dist/bundle.js', | ||
}) | ||
expect(stackFrames.stack[1]).toEqual({ | ||
args: [], | ||
column: 47950, | ||
func: 'r', | ||
line: 34, | ||
url: 'capacitor://localhost/media/dist/bundle.js', | ||
}) | ||
}) | ||
}) |
@@ -20,2 +20,3 @@ export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, buildCookieOptions } from './domain/configuration' | ||
addMonitoringMessage, | ||
setDebugMode, | ||
} from './domain/internalMonitoring' | ||
@@ -22,0 +23,0 @@ export { Observable } from './tools/observable' |
@@ -64,4 +64,4 @@ import { Configuration } from '../domain/configuration' | ||
}) | ||
;(promise as FetchStubPromise).resolveWith = async (response: ResponseStub) => { | ||
const resolved = resolve({ | ||
;(promise as FetchStubPromise).resolveWith = (response: ResponseStub) => { | ||
resolve({ | ||
...response, | ||
@@ -79,10 +79,8 @@ clone: () => { | ||
}, | ||
}) as Promise<ResponseStub> | ||
}) | ||
onRequestEnd() | ||
return resolved | ||
} | ||
;(promise as FetchStubPromise).rejectWith = async (error: Error) => { | ||
const rejected = reject(error) as Promise<Error> | ||
;(promise as FetchStubPromise).rejectWith = (error: Error) => { | ||
reject(error) | ||
onRequestEnd() | ||
return rejected | ||
} | ||
@@ -111,4 +109,4 @@ return promise | ||
export interface FetchStubPromise extends Promise<Response> { | ||
resolveWith: (response: ResponseStub) => Promise<ResponseStub> | ||
rejectWith: (error: Error) => Promise<Error> | ||
resolveWith: (response: ResponseStub) => void | ||
rejectWith: (error: Error) => void | ||
} | ||
@@ -115,0 +113,0 @@ |
@@ -19,3 +19,3 @@ import { monitor } from '../domain/internalMonitoring' | ||
send(data: string, size: number) { | ||
send(data: string | FormData, size: number) { | ||
const url = this.withBatchTime ? addBatchTime(this.endpointUrl) : this.endpointUrl | ||
@@ -22,0 +22,0 @@ if (navigator.sendBeacon && size < this.bytesLimit) { |
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
682094
176
13915