From a933dc268788208fdbc9a582d2bc3f6ab447a990 Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Wed, 20 Jan 2021 16:48:42 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[RUMF-809]=20url=20encode=20tags=20?= =?UTF-8?q?in=20intake=20requests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/domain/configuration.spec.ts | 18 +++++++++--------- packages/core/src/domain/configuration.ts | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/core/src/domain/configuration.spec.ts b/packages/core/src/domain/configuration.spec.ts index be1fe9e864..e4f413e906 100644 --- a/packages/core/src/domain/configuration.spec.ts +++ b/packages/core/src/domain/configuration.spec.ts @@ -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` ) }) diff --git a/packages/core/src/domain/configuration.ts b/packages/core/src/domain/configuration.ts index a95a4071f2..de44086719 100644 --- a/packages/core/src/domain/configuration.ts +++ b/packages/core/src/domain/configuration.ts @@ -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}` }