From 5fb7728098cb95052d40873f07b9f79e84d5bfd8 Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Fri, 8 Jan 2021 16:26:13 +0100 Subject: [PATCH] [RUMF-810] force alternate intake for us3 --- .../core/src/domain/configuration.spec.ts | 20 ++++++++++++++----- packages/core/src/domain/configuration.ts | 7 ++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/core/src/domain/configuration.spec.ts b/packages/core/src/domain/configuration.spec.ts index b9936680ba..94036cc764 100644 --- a/packages/core/src/domain/configuration.spec.ts +++ b/packages/core/src/domain/configuration.spec.ts @@ -133,17 +133,27 @@ describe('configuration', () => { }) it('should handle sites with subdomains and classic intake', () => { - const configuration = buildConfiguration({ clientToken, site: 'us3.datadoghq.com' }, usEnv) - expect(configuration.isIntakeUrl('https://rum-http-intake.logs.us3.datadoghq.com/v1/input/xxx')).toBe(true) - expect(configuration.isIntakeUrl('https://browser-http-intake.logs.us3.datadoghq.com/v1/input/xxx')).toBe(true) - expect(configuration.isIntakeUrl('https://public-trace-http-intake.logs.us3.datadoghq.com/v1/input/xxx')).toBe( + 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: 'us3.datadoghq.com', useAlternateIntakeDomains: true }, + { 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) diff --git a/packages/core/src/domain/configuration.ts b/packages/core/src/domain/configuration.ts index 63f1660d4d..85ad258ff8 100644 --- a/packages/core/src/domain/configuration.ts +++ b/packages/core/src/domain/configuration.ts @@ -139,7 +139,7 @@ export function buildConfiguration(userConfiguration: UserConfiguration, buildEn ? userConfiguration.enableExperimentalFeatures : [] - const intakeType: IntakeType = userConfiguration.useAlternateIntakeDomains ? 'alternate' : 'classic' + const intakeType: IntakeType = getIntakeType(transportConfiguration.site, userConfiguration) const intakeUrls = getIntakeUrls(intakeType, transportConfiguration, userConfiguration.replica !== undefined) const configuration: Configuration = { beforeSend: userConfiguration.beforeSend, @@ -256,6 +256,11 @@ function getHost(intakeType: IntakeType, endpointType: EndpointType, site: strin 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/`]