Skip to content

Commit

Permalink
🐛[RUMF-809] url encode tags in intake requests
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Jan 20, 2021
1 parent 5ec440e commit a933dc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions packages/core/src/domain/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ describe('configuration', () => {
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(decodeURIComponent(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:')
expect(decodeURIComponent(configuration.rumEndpoint)).not.toContain(',env:')
expect(decodeURIComponent(configuration.rumEndpoint)).not.toContain(',service:')
expect(decodeURIComponent(configuration.rumEndpoint)).not.toContain(',version:')
expect(decodeURIComponent(configuration.logsEndpoint)).not.toContain(',env:')
expect(decodeURIComponent(configuration.logsEndpoint)).not.toContain(',service:')
expect(decodeURIComponent(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(
expect(decodeURIComponent(configuration.rumEndpoint)).toContain(
`&ddtags=sdk_version:${usEnv.sdkVersion},env:foo,service:bar,version:baz`
)
expect(configuration.logsEndpoint).toContain(
expect(decodeURIComponent(configuration.logsEndpoint)).toContain(
`&ddtags=sdk_version:${usEnv.sdkVersion},env:foo,service:bar,version:baz`
)
})
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/domain/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ function getEndpoint(
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}`
const parameters = `${applicationIdParameter}${proxyParameter}ddsource=${
source || 'browser'
}&ddtags=${encodeURIComponent(tags)}`

return `https://${host}/v1/input/${conf.clientToken}?${parameters}`
}
Expand Down

0 comments on commit a933dc2

Please sign in to comment.