Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@datadog/browser-core

Package Overview
Dependencies
Maintainers
1
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-core - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

10

cjs/boot/init.d.ts
import { CookieOptions } from '../browser/cookie';
import { UserConfiguration } from '../domain/configuration';
import { Datacenter } from '../domain/transportConfiguration';
export declare function makePublicApi<T>(stub: T): T & {

@@ -7,11 +8,2 @@ onReady(callback: () => void): void;

export declare function defineGlobal<Global, Name extends keyof Global>(global: Global, name: Name, api: Global[Name]): void;
export declare const Datacenter: {
readonly EU: "eu";
readonly US: "us";
};
export declare type Datacenter = typeof Datacenter[keyof typeof Datacenter];
export declare const INTAKE_SITE: {
eu: string;
us: string;
};
export declare enum BuildMode {

@@ -18,0 +10,0 @@ RELEASE = "release",

"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -35,10 +34,2 @@ var tslib_1 = require("tslib");

exports.defineGlobal = defineGlobal;
exports.Datacenter = {
EU: 'eu',
US: 'us',
};
exports.INTAKE_SITE = (_a = {},
_a[exports.Datacenter.EU] = 'datadoghq.eu',
_a[exports.Datacenter.US] = 'datadoghq.com',
_a);
var BuildMode;

@@ -45,0 +36,0 @@ (function (BuildMode) {

3

cjs/domain/configuration.d.ts

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

import { BuildEnv, Datacenter } from '../boot/init';
import { BuildEnv } from '../boot/init';
import { CookieOptions } from '../browser/cookie';
import { Datacenter } from './transportConfiguration';
export declare const DEFAULT_CONFIGURATION: {

@@ -4,0 +5,0 @@ allowedTracingOrigins: (string | RegExp)[];

import { BuildEnv } from '../boot/init';
import { TransportConfiguration, UserConfiguration } from './configuration';
export declare const Datacenter: {
readonly EU: "eu";
readonly US: "us";
};
export declare type Datacenter = typeof Datacenter[keyof typeof Datacenter];
export declare const INTAKE_SITE: {
eu: string;
us: string;
};
export declare function computeTransportConfiguration(userConfiguration: UserConfiguration, buildEnv: BuildEnv): TransportConfiguration;
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var init_1 = require("../boot/init");
var utils_1 = require("../tools/utils");
var ENDPOINTS = {

@@ -20,2 +22,11 @@ alternate: {

};
exports.Datacenter = {
EU: 'eu',
US: 'us',
};
exports.INTAKE_SITE = (_a = {},
_a[exports.Datacenter.EU] = 'datadoghq.eu',
_a[exports.Datacenter.US] = 'datadoghq.com',
_a);
var CLASSIC_ALLOWED_SITES = [exports.INTAKE_SITE[exports.Datacenter.US], exports.INTAKE_SITE[exports.Datacenter.EU]];
function computeTransportConfiguration(userConfiguration, buildEnv) {

@@ -30,3 +41,3 @@ var transportSettings = {

service: userConfiguration.service,
site: userConfiguration.site || init_1.INTAKE_SITE[userConfiguration.datacenter || buildEnv.datacenter],
site: userConfiguration.site || exports.INTAKE_SITE[userConfiguration.datacenter || buildEnv.datacenter],
version: userConfiguration.version,

@@ -54,3 +65,3 @@ };

if (userConfiguration.replica !== undefined) {
var replicaTransportSettings = tslib_1.__assign(tslib_1.__assign({}, transportSettings), { applicationId: userConfiguration.replica.applicationId, clientToken: userConfiguration.replica.clientToken, site: init_1.INTAKE_SITE[init_1.Datacenter.US] });
var replicaTransportSettings = tslib_1.__assign(tslib_1.__assign({}, transportSettings), { applicationId: userConfiguration.replica.applicationId, clientToken: userConfiguration.replica.clientToken, site: exports.INTAKE_SITE[exports.Datacenter.US] });
configuration.replica = {

@@ -68,4 +79,3 @@ applicationId: userConfiguration.replica.applicationId,

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';
return !userConfiguration.useAlternateIntakeDomains && utils_1.includes(CLASSIC_ALLOWED_SITES, site) ? 'classic' : 'alternate';
}

@@ -78,3 +88,3 @@ function getIntakeUrls(intakeType, settings, withReplica) {

if (settings.buildMode === init_1.BuildMode.STAGING && withReplica) {
sites.push(init_1.INTAKE_SITE[init_1.Datacenter.US]);
sites.push(exports.INTAKE_SITE[exports.Datacenter.US]);
}

@@ -81,0 +91,0 @@ var urls = [];

export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, buildCookieOptions } from './domain/configuration';
export { startAutomaticErrorCollection, ErrorObservable } from './domain/automaticErrorCollection';
export { computeStackTrace } from './domain/tracekit';
export { BuildEnv, BuildMode, Datacenter, defineGlobal, makePublicApi, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './boot/init';
export { BuildEnv, BuildMode, defineGlobal, makePublicApi, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './boot/init';
export { InternalMonitoring, MonitoringMessage, monitored, monitor, addMonitoringMessage, setDebugMode, } from './domain/internalMonitoring';

@@ -20,1 +20,2 @@ export { Observable } from './tools/observable';

export * from './tools/specHelper';
export { Datacenter } from './domain/transportConfiguration';

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

exports.BuildMode = init_1.BuildMode;
exports.Datacenter = init_1.Datacenter;
exports.defineGlobal = init_1.defineGlobal;

@@ -63,2 +62,4 @@ exports.makePublicApi = init_1.makePublicApi;

tslib_1.__exportStar(require("./tools/specHelper"), exports);
var transportConfiguration_1 = require("./domain/transportConfiguration");
exports.Datacenter = transportConfiguration_1.Datacenter;
//# sourceMappingURL=index.js.map
import { CookieOptions } from '../browser/cookie';
import { UserConfiguration } from '../domain/configuration';
import { Datacenter } from '../domain/transportConfiguration';
export declare function makePublicApi<T>(stub: T): T & {

@@ -7,11 +8,2 @@ onReady(callback: () => void): void;

export declare function defineGlobal<Global, Name extends keyof Global>(global: Global, name: Name, api: Global[Name]): void;
export declare const Datacenter: {
readonly EU: "eu";
readonly US: "us";
};
export declare type Datacenter = typeof Datacenter[keyof typeof Datacenter];
export declare const INTAKE_SITE: {
eu: string;
us: string;
};
export declare enum BuildMode {

@@ -18,0 +10,0 @@ RELEASE = "release",

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

var _a;
import { __assign } from "tslib";

@@ -31,10 +30,2 @@ import { areCookiesAuthorized } from '../browser/cookie';

}
export var Datacenter = {
EU: 'eu',
US: 'us',
};
export var INTAKE_SITE = (_a = {},
_a[Datacenter.EU] = 'datadoghq.eu',
_a[Datacenter.US] = 'datadoghq.com',
_a);
export var BuildMode;

@@ -41,0 +32,0 @@ (function (BuildMode) {

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

import { BuildEnv, Datacenter } from '../boot/init';
import { BuildEnv } from '../boot/init';
import { CookieOptions } from '../browser/cookie';
import { Datacenter } from './transportConfiguration';
export declare const DEFAULT_CONFIGURATION: {

@@ -4,0 +5,0 @@ allowedTracingOrigins: (string | RegExp)[];

import { BuildEnv } from '../boot/init';
import { TransportConfiguration, UserConfiguration } from './configuration';
export declare const Datacenter: {
readonly EU: "eu";
readonly US: "us";
};
export declare type Datacenter = typeof Datacenter[keyof typeof Datacenter];
export declare const INTAKE_SITE: {
eu: string;
us: string;
};
export declare function computeTransportConfiguration(userConfiguration: UserConfiguration, buildEnv: BuildEnv): TransportConfiguration;

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

var _a;
import { __assign } from "tslib";
import { BuildMode, Datacenter, INTAKE_SITE } from '../boot/init';
import { BuildMode } from '../boot/init';
import { includes } from '../tools/utils';
var ENDPOINTS = {

@@ -18,2 +20,11 @@ alternate: {

};
export var Datacenter = {
EU: 'eu',
US: 'us',
};
export var INTAKE_SITE = (_a = {},
_a[Datacenter.EU] = 'datadoghq.eu',
_a[Datacenter.US] = 'datadoghq.com',
_a);
var CLASSIC_ALLOWED_SITES = [INTAKE_SITE[Datacenter.US], INTAKE_SITE[Datacenter.EU]];
export function computeTransportConfiguration(userConfiguration, buildEnv) {

@@ -63,4 +74,3 @@ var transportSettings = {

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';
return !userConfiguration.useAlternateIntakeDomains && includes(CLASSIC_ALLOWED_SITES, site) ? 'classic' : 'alternate';
}

@@ -67,0 +77,0 @@ function getIntakeUrls(intakeType, settings, withReplica) {

export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, buildCookieOptions } from './domain/configuration';
export { startAutomaticErrorCollection, ErrorObservable } from './domain/automaticErrorCollection';
export { computeStackTrace } from './domain/tracekit';
export { BuildEnv, BuildMode, Datacenter, defineGlobal, makePublicApi, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './boot/init';
export { BuildEnv, BuildMode, defineGlobal, makePublicApi, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './boot/init';
export { InternalMonitoring, MonitoringMessage, monitored, monitor, addMonitoringMessage, setDebugMode, } from './domain/internalMonitoring';

@@ -20,1 +20,2 @@ export { Observable } from './tools/observable';

export * from './tools/specHelper';
export { Datacenter } from './domain/transportConfiguration';
export { DEFAULT_CONFIGURATION, buildCookieOptions } from './domain/configuration';
export { startAutomaticErrorCollection } from './domain/automaticErrorCollection';
export { computeStackTrace } from './domain/tracekit';
export { BuildMode, Datacenter, defineGlobal, makePublicApi, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './boot/init';
export { BuildMode, defineGlobal, makePublicApi, commonInit, checkCookiesAuthorized, checkIsNotLocalFile, } from './boot/init';
export { monitored, monitor, addMonitoringMessage, setDebugMode, } from './domain/internalMonitoring';

@@ -22,2 +22,3 @@ export { Observable } from './tools/observable';

export * from './tools/specHelper';
export { Datacenter } from './domain/transportConfiguration';
//# sourceMappingURL=index.js.map
{
"name": "@datadog/browser-core",
"version": "2.3.0",
"version": "2.3.1",
"license": "Apache-2.0",

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

},
"gitHead": "f92ef270e80cbe49abf97e08622228ae46681518"
"gitHead": "0945f79292357d1db56e96a88be7736cc4a83e6d"
}
import { areCookiesAuthorized, CookieOptions } from '../browser/cookie'
import { buildConfiguration, UserConfiguration } from '../domain/configuration'
import { setDebugMode, startInternalMonitoring } from '../domain/internalMonitoring'
import { Datacenter } from '../domain/transportConfiguration'

@@ -37,14 +38,2 @@ export function makePublicApi<T>(stub: T): T & { onReady(callback: () => void): void } {

export const Datacenter = {
EU: 'eu',
US: 'us',
} as const
export type Datacenter = typeof Datacenter[keyof typeof Datacenter]
export const INTAKE_SITE = {
[Datacenter.EU]: 'datadoghq.eu',
[Datacenter.US]: 'datadoghq.com',
}
export enum BuildMode {

@@ -51,0 +40,0 @@ RELEASE = 'release',

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

import { BuildEnv, BuildMode, Datacenter } from '../boot/init'
import { BuildEnv, BuildMode } from '../boot/init'
import { buildConfiguration } from './configuration'
import { Datacenter } from './transportConfiguration'

@@ -4,0 +5,0 @@ describe('configuration', () => {

@@ -1,5 +0,5 @@

import { BuildEnv, Datacenter } from '../boot/init'
import { BuildEnv } from '../boot/init'
import { CookieOptions, getCurrentSite } from '../browser/cookie'
import { includes, ONE_KILO_BYTE, ONE_SECOND } from '../tools/utils'
import { computeTransportConfiguration } from './transportConfiguration'
import { computeTransportConfiguration, Datacenter } from './transportConfiguration'

@@ -6,0 +6,0 @@ export const DEFAULT_CONFIGURATION = {

@@ -108,3 +108,3 @@ import { BuildEnv, BuildMode, Datacenter } from '@datadog/browser-core'

it('should detect intake request for EU site', () => {
it('should detect intake request for classic EU site', () => {
const configuration = computeTransportConfiguration({ clientToken, site: 'datadoghq.eu' }, usEnv)

@@ -117,3 +117,3 @@ expect(configuration.isIntakeUrl('https://rum-http-intake.logs.datadoghq.eu/v1/input/xxx')).toBe(true)

it('should detect intake request for US site', () => {
it('should detect intake request for classic US site', () => {
const configuration = computeTransportConfiguration({ clientToken }, usEnv)

@@ -135,19 +135,28 @@

it('should handle sites with subdomains and classic intake', () => {
const configuration = computeTransportConfiguration({ 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 detect alternate intake domains for EU site', () => {
const configuration = computeTransportConfiguration({ 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)
expect(configuration.isIntakeUrl('https://session-replay.browser-intake-datadoghq.com/v1/input/xxx')).toBe(true)
})
it('should force alternate intake domains for other sites', () => {
let configuration = computeTransportConfiguration(
{ clientToken, site: 'us3.datadoghq.com', useAlternateIntakeDomains: false },
usEnv
)
expect(configuration.isIntakeUrl('https://session-replay.browser-intake-foo-datadoghq.com/v1/input/xxx')).toBe(
true
expect(configuration.isIntakeUrl('https://rum.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(true)
expect(configuration.isIntakeUrl('https://rum-http-intake.logs.us3.datadoghq.com/v1/input/xxx')).toBe(false)
configuration = computeTransportConfiguration(
{ clientToken, site: 'ddog-gov.com', useAlternateIntakeDomains: false },
usEnv
)
expect(configuration.isIntakeUrl('https://rum.browser-intake-ddog-gov.com/v1/input/xxx')).toBe(true)
expect(configuration.isIntakeUrl('https://rum-http-intake.logs.ddog-gov.com/v1/input/xxx')).toBe(false)
})
it('should handle sites with subdomains and alternate intake', () => {
const configuration = computeTransportConfiguration(
{ clientToken, site: 'foo.datadoghq.com', useAlternateIntakeDomains: true },
usEnv
)
it('should handle sites with subdomains', () => {
const configuration = computeTransportConfiguration({ clientToken, site: 'foo.datadoghq.com' }, usEnv)
expect(configuration.isIntakeUrl('https://rum.browser-intake-foo-datadoghq.com/v1/input/xxx')).toBe(true)

@@ -161,15 +170,2 @@ expect(configuration.isIntakeUrl('https://logs.browser-intake-foo-datadoghq.com/v1/input/xxx')).toBe(true)

it('should force alternate intake for us3', () => {
const configuration = computeTransportConfiguration(
{ 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)
expect(configuration.isIntakeUrl('https://session-replay.browser-intake-us3-datadoghq.com/v1/input/xxx')).toBe(
true
)
})
it('should detect proxy intake request', () => {

@@ -192,11 +188,11 @@ let configuration = computeTransportConfiguration({ clientToken, proxyHost: 'www.proxy.com' }, usEnv)

it('should detect replica intake request', () => {
it('should detect replica intake request with classic intake domains', () => {
const configuration = computeTransportConfiguration(
{ clientToken, site: 'foo.com', replica: { clientToken } },
{ clientToken, site: 'datadoghq.eu', 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://session-replay.browser-intake-foo.com/v1/input/xxx')).toBe(true)
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)
expect(configuration.isIntakeUrl('https://session-replay.browser-intake-datadoghq.eu/v1/input/xxx')).toBe(true)

@@ -209,3 +205,3 @@ expect(configuration.isIntakeUrl('https://rum-http-intake.logs.datadoghq.com/v1/input/xxx')).toBe(true)

const configuration = computeTransportConfiguration(
{ clientToken, site: 'foo.com', replica: { clientToken }, useAlternateIntakeDomains: true },
{ clientToken, site: 'foo.com', replica: { clientToken } },
{ ...usEnv, buildMode: BuildMode.STAGING }

@@ -212,0 +208,0 @@ )

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

import { BuildEnv, BuildMode, Datacenter, INTAKE_SITE } from '../boot/init'
import { BuildEnv, BuildMode } from '../boot/init'
import { includes } from '../tools/utils'
import { TransportConfiguration, UserConfiguration } from './configuration'

@@ -19,2 +20,17 @@

}
export const Datacenter = {
EU: 'eu',
US: 'us',
} as const
export type Datacenter = typeof Datacenter[keyof typeof Datacenter]
export const INTAKE_SITE = {
[Datacenter.EU]: 'datadoghq.eu',
[Datacenter.US]: 'datadoghq.com',
}
const CLASSIC_ALLOWED_SITES = [INTAKE_SITE[Datacenter.US], INTAKE_SITE[Datacenter.EU]]
type IntakeType = keyof typeof ENDPOINTS

@@ -102,4 +118,3 @@ type EndpointType = keyof typeof ENDPOINTS[IntakeType]

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'
return !userConfiguration.useAlternateIntakeDomains && includes(CLASSIC_ALLOWED_SITES, site) ? 'classic' : 'alternate'
}

@@ -106,0 +121,0 @@

@@ -7,3 +7,2 @@ export { DEFAULT_CONFIGURATION, Configuration, UserConfiguration, buildCookieOptions } from './domain/configuration'

BuildMode,
Datacenter,
defineGlobal,

@@ -50,1 +49,2 @@ makePublicApi,

export * from './tools/specHelper'
export { Datacenter } from './domain/transportConfiguration'

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc