Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions packages/core/src/domain/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,6 @@ export interface InitConfiguration {
*/
datacenter?: string

/**
* [Internal option] Datadog internal analytics subdomain
*
* @internal
*/
// TODO next major: remove this option and replace usages by proxyFn
internalAnalyticsSubdomain?: string

/**
* [Internal option] The percentage of telemetry configuration sent. A value between 0 and 100.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ describe('endpointBuilder', () => {
).toContain('&dd-evp-encoding=deflate')
})

it('should not start with ddsource for internal analytics mode', () => {
const url = createEndpointBuilder({ ...initConfiguration, internalAnalyticsSubdomain: 'foo' }, 'rum').build(
'fetch',
DEFAULT_PAYLOAD
)
expect(url).not.toContain('/rum?ddsource')
expect(url).toContain('ddsource=browser')
})
Comment on lines -41 to -48
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we were doing this (found RUMF-1464, but it's not very clear), but this does not seems to be replicated in web-ui.

Image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'll replicate in web-ui


it('accepts extra parameters', () => {
const extraParameters = ['application.id=1234', 'application.version=1.0.0']
const url = createEndpointBuilder(initConfiguration, 'rum', extraParameters).build('fetch', DEFAULT_PAYLOAD)
Expand Down
18 changes: 3 additions & 15 deletions packages/core/src/domain/configuration/endpointBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Payload } from '../../transport'
import { timeStampNow } from '../../tools/utils/timeUtils'
import { normalizeUrl } from '../../tools/utils/urlPolyfill'
import { generateUUID } from '../../tools/utils/stringUtils'
import { INTAKE_SITE_FED_STAGING, INTAKE_SITE_US1 } from '../intakeSites'
import { INTAKE_SITE_US1 } from '../intakeSites'
import type { InitConfiguration } from './configuration'

// replaced at build time
Expand Down Expand Up @@ -57,15 +57,7 @@ function createEndpointUrlWithParametersBuilder(
}

export function buildEndpointHost(initConfiguration: InitConfiguration) {
const { site = INTAKE_SITE_US1, internalAnalyticsSubdomain } = initConfiguration

if (internalAnalyticsSubdomain && site === INTAKE_SITE_US1) {
return `${internalAnalyticsSubdomain}.${INTAKE_SITE_US1}`
}

if (site === INTAKE_SITE_FED_STAGING) {
return `http-intake.logs.${site}`
}
const { site = INTAKE_SITE_US1 } = initConfiguration

const domainParts = site.split('.')
const extension = domainParts.pop()
Expand All @@ -77,7 +69,7 @@ export function buildEndpointHost(initConfiguration: InitConfiguration) {
* request, as they change randomly.
*/
function buildEndpointParameters(
{ clientToken, internalAnalyticsSubdomain, source = 'browser' }: InitConfiguration,
{ clientToken, source = 'browser' }: InitConfiguration,
trackType: TrackType,
api: ApiType,
{ retry, encoding }: Payload,
Expand All @@ -103,9 +95,5 @@ function buildEndpointParameters(
}
}

if (internalAnalyticsSubdomain) {
parameters.reverse()
}

return parameters.join('&')
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { INTAKE_SITE_FED_STAGING } from '../intakeSites'
import type { Payload } from '../../transport'
import { computeTransportConfiguration, isIntakeUrl } from './transportConfiguration'

const DEFAULT_PAYLOAD = {} as Payload

describe('transportConfiguration', () => {
const clientToken = 'some_client_token'
const internalAnalyticsSubdomain = 'ia-rum-intake'
const intakeParameters = 'ddsource=browser&dd-api-key=xxxx&dd-request-id=1234567890'

describe('site', () => {
Expand All @@ -16,40 +14,13 @@ describe('transportConfiguration', () => {
expect(configuration.site).toBe('datadoghq.com')
})

it('should use logs intake domain for fed staging', () => {
const configuration = computeTransportConfiguration({ clientToken, site: INTAKE_SITE_FED_STAGING })
expect(configuration.rumEndpointBuilder.build('fetch', DEFAULT_PAYLOAD)).toContain(
'http-intake.logs.dd0g-gov.com'
)
expect(configuration.site).toBe(INTAKE_SITE_FED_STAGING)
})

it('should use site value when set', () => {
const configuration = computeTransportConfiguration({ clientToken, site: 'datadoghq.com' })
expect(configuration.rumEndpointBuilder.build('fetch', DEFAULT_PAYLOAD)).toContain('datadoghq.com')
expect(configuration.site).toBe('datadoghq.com')
})
})

describe('internalAnalyticsSubdomain', () => {
it('should use internal analytics subdomain value when set for datadoghq.com site', () => {
const configuration = computeTransportConfiguration({
clientToken,
internalAnalyticsSubdomain,
})
expect(configuration.rumEndpointBuilder.build('fetch', DEFAULT_PAYLOAD)).toContain(internalAnalyticsSubdomain)
})

it('should not use internal analytics subdomain value when set for other sites', () => {
const configuration = computeTransportConfiguration({
clientToken,
site: 'us3.datadoghq.com',
internalAnalyticsSubdomain,
})
expect(configuration.rumEndpointBuilder.build('fetch', DEFAULT_PAYLOAD)).not.toContain(internalAnalyticsSubdomain)
})
})

it('adds the replica application id to the rum replica endpoint', () => {
const replicaApplicationId = 'replica-application-id'
const configuration = computeTransportConfiguration({
Expand All @@ -74,7 +45,6 @@ describe('transportConfiguration', () => {
{ site: 'ap1.datadoghq.com', intakeDomain: 'browser-intake-ap1-datadoghq.com' },
{ site: 'ddog-gov.com', intakeDomain: 'browser-intake-ddog-gov.com' },
{ site: 'datad0g.com', intakeDomain: 'browser-intake-datad0g.com' },
{ site: 'dd0g-gov.com', intakeDomain: 'http-intake.logs.dd0g-gov.com' },
].forEach(({ site, intakeDomain }) => {
it(`should detect intake request to ${intakeDomain} for site ${site}`, () => {
expect(isIntakeUrl(`https://${intakeDomain}/api/v2/rum?${intakeParameters}`)).toBe(true)
Expand All @@ -96,12 +66,6 @@ describe('transportConfiguration', () => {
})
})

it('should detect internal analytics intake request for datadoghq.com site', () => {
expect(isIntakeUrl(`https://${internalAnalyticsSubdomain}.datadoghq.com/api/v2/rum?${intakeParameters}`)).toBe(
true
)
})

it('should not detect non intake request', () => {
expect(isIntakeUrl('https://www.foo.com')).toBe(false)
})
Expand Down Expand Up @@ -129,15 +93,9 @@ describe('transportConfiguration', () => {
{ site: 'ap1.datadoghq.com' },
].forEach(({ site }) => {
it(`should detect replica intake request for site ${site}`, () => {
expect(isIntakeUrl(`https://${internalAnalyticsSubdomain}.datadoghq.com/api/v2/rum?${intakeParameters}`)).toBe(
true
)
expect(isIntakeUrl(`https://${internalAnalyticsSubdomain}.datadoghq.com/api/v2/logs?${intakeParameters}`)).toBe(
true
)
expect(
isIntakeUrl(`https://${internalAnalyticsSubdomain}.datadoghq.com/api/v2/replay?${intakeParameters}`)
).toBe(true)
expect(isIntakeUrl(`https://browser-intake-datadoghq.com/api/v2/rum?${intakeParameters}`)).toBe(true)
expect(isIntakeUrl(`https://browser-intake-datadoghq.com/api/v2/logs?${intakeParameters}`)).toBe(true)
expect(isIntakeUrl(`https://browser-intake-datadoghq.com/api/v2/replay?${intakeParameters}`)).toBe(true)
})
})
})
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/domain/intakeSites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type Site =
| (string & {})

export const INTAKE_SITE_STAGING: Site = 'datad0g.com'
export const INTAKE_SITE_FED_STAGING: Site = 'dd0g-gov.com'
export const INTAKE_SITE_US1: Site = 'datadoghq.com'
export const INTAKE_SITE_EU1: Site = 'datadoghq.eu'
export const INTAKE_SITE_US1_FED: Site = 'ddog-gov.com'
Expand Down
2 changes: 0 additions & 2 deletions packages/core/test/coreConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const EXHAUSTIVE_INIT_CONFIGURATION: Required<InitConfiguration> = {
clientToken: 'yes',
},
datacenter: 'datacenter',
internalAnalyticsSubdomain: 'internal-analytics-subdomain.com',
telemetryConfigurationSampleRate: 70,
telemetryUsageSampleRate: 80,
allowedTrackingOrigins: ['chrome-extension://example'],
Expand Down Expand Up @@ -79,7 +78,6 @@ export type MapInitConfigurationKey<Key extends string> =
| 'env'
| 'version'
| 'datacenter'
| 'internalAnalyticsSubdomain'
| 'replica'
| 'enableExperimentalFeatures'
? never
Expand Down
Loading