Skip to content

Commit

Permalink
👌 Support classic intake for sites with subdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
webNeat committed Dec 2, 2020
1 parent 48a0ffc commit 2bd74ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 10 additions & 1 deletion packages/core/src/domain/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,16 @@ describe('configuration', () => {
expect(configuration.isIntakeUrl('https://trace.browser-intake-datadoghq.com/v1/input/xxx')).toBe(true)
})

it('should handle sites with subdomains', () => {
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(
true
)
})

it('should handle sites with subdomains and alternate intake', () => {
const configuration = buildConfiguration(
{ clientToken, site: 'us3.datadoghq.com', useAlternateIntakeDomains: true },
usEnv
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/domain/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,12 @@ function getEndpoint(
function getHost(intakeType: IntakeType, endpointType: EndpointType, site: string) {
const middleDomain = INTAKE_MIDDLE_DOMAINS[intakeType]
const endpoint = ENDPOINTS[intakeType][endpointType]
const domainParts = site.split('.')
const ext = domainParts.pop()
return `${endpoint}${middleDomain}${domainParts.join('-')}.${ext}`
if (intakeType === 'alternate') {
const domainParts = site.split('.')
const ext = domainParts.pop()
site = domainParts.join('-') + '.' + ext
}
return `${endpoint}${middleDomain}${site}`
}

function getIntakeUrls(intakeType: IntakeType, conf: TransportConfiguration, withReplica: boolean) {
Expand Down

0 comments on commit 2bd74ed

Please sign in to comment.