From 49664f81dbecd80277c48851c79df90a2c6ab956 Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Tue, 12 Sep 2023 15:00:41 -0700 Subject: [PATCH 1/9] Add datadog rum --- package.json | 1 + src/common/datadog.config.js | 18 ++++++++++++++++++ yarn.lock | 20 ++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 src/common/datadog.config.js diff --git a/package.json b/package.json index 08a5318cb..430e5f851 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "@babel/polyfill": "^7.7.0", "@babel/runtime-corejs2": "^7.0.0", "@cruglobal/cru-payments": "^1.2.4", + "@datadog/browser-rum": "^4.48.2", "angular": "^1.8.2", "angular-cookies": "^1.8.2", "angular-environment": "https://github.com/jonshaffer/angular-environment.git#d3082c06fb16804d324faac9b7e753fd64a44e5d", diff --git a/src/common/datadog.config.js b/src/common/datadog.config.js new file mode 100644 index 000000000..658a61ce2 --- /dev/null +++ b/src/common/datadog.config.js @@ -0,0 +1,18 @@ +import { datadogRum } from '@datadog/browser-rum'; + +datadogRum.init({ + applicationId: '3937053e-386b-4b5b-ab4a-c83217d2f953', + clientToken: process.env.DATADOG_CLIENT_TOKEN, + site: 'datadoghq.com', + service:'give-web', + env: process.env.NODE_ENV, + version: process.env.GITHUB_SHA, + sessionSampleRate:100, + sessionReplaySampleRate: 20, + trackUserInteractions: true, + trackResources: true, + trackLongTasks: true, + defaultPrivacyLevel:'mask-user-input' +}); + +datadogRum.startSessionReplayRecording(); diff --git a/yarn.lock b/yarn.lock index bfa232497..6e66470c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1544,6 +1544,26 @@ dependencies: "@cspotcode/source-map-consumer" "0.8.0" +"@datadog/browser-core@4.48.2": + version "4.48.2" + resolved "https://registry.yarnpkg.com/@datadog/browser-core/-/browser-core-4.48.2.tgz#6606878660a2dad528a7c5c4aa5465169cb2c33a" + integrity sha512-ewQDLouh9jymJPTRq5M8Hz0FFzMaVlJCwHHY5gMUmGyIaBEzS8wd3AeZ56kQ32ZOcyz83au1/yZ/zcIB8LDoyA== + +"@datadog/browser-rum-core@4.48.2": + version "4.48.2" + resolved "https://registry.yarnpkg.com/@datadog/browser-rum-core/-/browser-rum-core-4.48.2.tgz#4fc13aedc6170d51c3c024327da27af937fd0186" + integrity sha512-LUlaYAC7MGXZbIPT6LvSVxaZBG0irer+meQp1LfJBdSy/lLb4OrNowrc9dcHeh4Fw9rNNLWl2Pz+4dBqRtR87g== + dependencies: + "@datadog/browser-core" "4.48.2" + +"@datadog/browser-rum@^4.48.2": + version "4.48.2" + resolved "https://registry.yarnpkg.com/@datadog/browser-rum/-/browser-rum-4.48.2.tgz#95ab72a0fd6b9f82b69cca6a351d9a91bcd8d5da" + integrity sha512-SGxjKJLUJq8AjWedhHTQicIr4rvAcDMwBr6gHvZr3h9llCBpDxPzd/RPKCK69HMxBGt/Cw7KCpjAjy9IaCURWQ== + dependencies: + "@datadog/browser-core" "4.48.2" + "@datadog/browser-rum-core" "4.48.2" + "@eslint/eslintrc@^0.3.0": version "0.3.0" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.3.0.tgz#d736d6963d7003b6514e6324bec9c602ac340318" From 99dd3aa2831ce930ba376abbc46b4febe46b2bfe Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Wed, 13 Sep 2023 17:18:31 -0700 Subject: [PATCH 2/9] Change rates --- src/common/datadog.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/datadog.config.js b/src/common/datadog.config.js index 658a61ce2..35a1f899b 100644 --- a/src/common/datadog.config.js +++ b/src/common/datadog.config.js @@ -7,8 +7,8 @@ datadogRum.init({ service:'give-web', env: process.env.NODE_ENV, version: process.env.GITHUB_SHA, - sessionSampleRate:100, - sessionReplaySampleRate: 20, + sessionSampleRate: 10, + sessionReplaySampleRate: 1, trackUserInteractions: true, trackResources: true, trackLongTasks: true, From 66fa67b8729d0caa53c69543b7ee5c857ebcfe41 Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Thu, 14 Sep 2023 18:30:38 -0700 Subject: [PATCH 3/9] Move config to app.config and change sample rates --- src/common/app.config.js | 18 ++++++++++++++++++ src/common/datadog.config.js | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 src/common/datadog.config.js diff --git a/src/common/app.config.js b/src/common/app.config.js index c2c0e68e6..cfac8444f 100644 --- a/src/common/app.config.js +++ b/src/common/app.config.js @@ -3,6 +3,7 @@ import 'angular-environment' import 'angular-translate' import rollbarConfig from './rollbar.config' +import { datadogRum } from '@datadog/browser-rum'; const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider, $logProvider, $httpProvider, $locationProvider, $qProvider, $translateProvider) { $httpProvider.useApplyAsync(true) @@ -535,6 +536,23 @@ const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider PREFERRED_RADIO_STATION: 'Preferred Radio Station: ' }) $translateProvider.preferredLanguage('en') + + window.datadogRum && window.datadogRum.init({ + applicationId: '3937053e-386b-4b5b-ab4a-c83217d2f953', + clientToken: process.env.DATADOG_RUM_CLIENT_TOKEN, + site: 'datadoghq.com', + service:'give-web', + env: process.env.NODE_ENV, + version: process.env.GITHUB_SHA, + sessionSampleRate: process.env.NODE_ENV == "staging" ? 100 : 10, + sessionReplaySampleRate: process.env.NODE_ENV == "staging" ? 100 : 1, + trackUserInteractions: true, + trackResources: true, + trackLongTasks: true, + defaultPrivacyLevel:'mask-user-input' +}); + +window.datadogRum && window.datadogRum.startSessionReplayRecording(); } export default angular.module('appConfig', [ diff --git a/src/common/datadog.config.js b/src/common/datadog.config.js deleted file mode 100644 index 35a1f899b..000000000 --- a/src/common/datadog.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import { datadogRum } from '@datadog/browser-rum'; - -datadogRum.init({ - applicationId: '3937053e-386b-4b5b-ab4a-c83217d2f953', - clientToken: process.env.DATADOG_CLIENT_TOKEN, - site: 'datadoghq.com', - service:'give-web', - env: process.env.NODE_ENV, - version: process.env.GITHUB_SHA, - sessionSampleRate: 10, - sessionReplaySampleRate: 1, - trackUserInteractions: true, - trackResources: true, - trackLongTasks: true, - defaultPrivacyLevel:'mask-user-input' -}); - -datadogRum.startSessionReplayRecording(); From d1836b787c02cad5f3b21e4acb72568702d1a3ad Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Thu, 14 Sep 2023 18:40:33 -0700 Subject: [PATCH 4/9] Fix lint issues --- src/common/app.config.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/app.config.js b/src/common/app.config.js index cfac8444f..9e39b4b21 100644 --- a/src/common/app.config.js +++ b/src/common/app.config.js @@ -3,7 +3,7 @@ import 'angular-environment' import 'angular-translate' import rollbarConfig from './rollbar.config' -import { datadogRum } from '@datadog/browser-rum'; +// import { datadogRum } from '@datadog/browser-rum' const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider, $logProvider, $httpProvider, $locationProvider, $qProvider, $translateProvider) { $httpProvider.useApplyAsync(true) @@ -541,18 +541,18 @@ const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider applicationId: '3937053e-386b-4b5b-ab4a-c83217d2f953', clientToken: process.env.DATADOG_RUM_CLIENT_TOKEN, site: 'datadoghq.com', - service:'give-web', + service: 'give-web', env: process.env.NODE_ENV, version: process.env.GITHUB_SHA, - sessionSampleRate: process.env.NODE_ENV == "staging" ? 100 : 10, - sessionReplaySampleRate: process.env.NODE_ENV == "staging" ? 100 : 1, + sessionSampleRate: process.env.NODE_ENV === 'staging' ? 100 : 10, + sessionReplaySampleRate: process.env.NODE_ENV === 'staging' ? 100 : 1, trackUserInteractions: true, trackResources: true, trackLongTasks: true, - defaultPrivacyLevel:'mask-user-input' -}); - -window.datadogRum && window.datadogRum.startSessionReplayRecording(); + defaultPrivacyLevel: 'mask-user-input' + }) + + window.datadogRum && window.datadogRum.startSessionReplayRecording() } export default angular.module('appConfig', [ From b7313b2d52887a660ad37521fea174581facfbbb Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Fri, 15 Sep 2023 08:41:57 -0700 Subject: [PATCH 5/9] Add datadogRum to window --- src/common/app.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/app.config.js b/src/common/app.config.js index 9e39b4b21..b5ee96fc2 100644 --- a/src/common/app.config.js +++ b/src/common/app.config.js @@ -3,7 +3,7 @@ import 'angular-environment' import 'angular-translate' import rollbarConfig from './rollbar.config' -// import { datadogRum } from '@datadog/browser-rum' +import { datadogRum } from '@datadog/browser-rum' const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider, $logProvider, $httpProvider, $locationProvider, $qProvider, $translateProvider) { $httpProvider.useApplyAsync(true) @@ -537,6 +537,7 @@ const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider }) $translateProvider.preferredLanguage('en') + window.datadogRum = datadogRum; window.datadogRum && window.datadogRum.init({ applicationId: '3937053e-386b-4b5b-ab4a-c83217d2f953', clientToken: process.env.DATADOG_RUM_CLIENT_TOKEN, From 0906cd97e7b3492d67ab437f6cfd88e305f6352b Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Fri, 15 Sep 2023 08:49:32 -0700 Subject: [PATCH 6/9] Fix lint --- src/common/app.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/app.config.js b/src/common/app.config.js index b5ee96fc2..da0f7ae8f 100644 --- a/src/common/app.config.js +++ b/src/common/app.config.js @@ -537,7 +537,7 @@ const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider }) $translateProvider.preferredLanguage('en') - window.datadogRum = datadogRum; + window.datadogRum = datadogRum window.datadogRum && window.datadogRum.init({ applicationId: '3937053e-386b-4b5b-ab4a-c83217d2f953', clientToken: process.env.DATADOG_RUM_CLIENT_TOKEN, From 3e5d88378c23876d2edf6e905a04f40e3796240b Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Fri, 15 Sep 2023 12:07:40 -0700 Subject: [PATCH 7/9] add datadog client token to webpack config and yml --- .github/workflows/build.yml | 1 + src/common/app.config.js | 1 + webpack.config.js | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8fcee162..f4950e60c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,6 +67,7 @@ jobs: env: S3_GIVE_DOMAIN: //${{ secrets.GIVE_WEB_HOSTNAME }} ROLLBAR_ACCESS_TOKEN: ${{ secrets.ROLLBAR_ACCESS_TOKEN }} + DATADOG_RUM_CLIENT_TOKEN: ${{ secrets.DATADOG_RUM_CLIENT_TOKEN }} run: yarn run build - name: Configure AWS Credentials diff --git a/src/common/app.config.js b/src/common/app.config.js index da0f7ae8f..393dc6714 100644 --- a/src/common/app.config.js +++ b/src/common/app.config.js @@ -554,6 +554,7 @@ const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider }) window.datadogRum && window.datadogRum.startSessionReplayRecording() + console.log('node env: ', process.env.NODE_ENV) } export default angular.module('appConfig', [ diff --git a/webpack.config.js b/webpack.config.js index 7f04c9310..8fb4400af 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -55,7 +55,8 @@ const sharedConfig = { new webpack.EnvironmentPlugin({ GITHUB_SHA: 'development', S3_GIVE_DOMAIN: '', - ROLLBAR_ACCESS_TOKEN: JSON.stringify(process.env.ROLLBAR_ACCESS_TOKEN) || 'development-token' + ROLLBAR_ACCESS_TOKEN: JSON.stringify(process.env.ROLLBAR_ACCESS_TOKEN) || 'development-token', + DATADOG_RUM_CLIENT_TOKEN: process.env.DATADOG_RUM_CLIENT_TOKEN || '' }), // To strip all locales except “en” new MomentLocalesPlugin() From bd9944087e83b5e15441b44a34badcc0c9e74d85 Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Fri, 15 Sep 2023 12:35:37 -0700 Subject: [PATCH 8/9] Move datadog config to a new file --- src/common/app.config.js | 22 ++-------------------- src/common/datadog.config.js | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 src/common/datadog.config.js diff --git a/src/common/app.config.js b/src/common/app.config.js index 393dc6714..59d7c22d8 100644 --- a/src/common/app.config.js +++ b/src/common/app.config.js @@ -3,7 +3,7 @@ import 'angular-environment' import 'angular-translate' import rollbarConfig from './rollbar.config' -import { datadogRum } from '@datadog/browser-rum' +import dataDogConfig from './datadog.config.js' const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider, $logProvider, $httpProvider, $locationProvider, $qProvider, $translateProvider) { $httpProvider.useApplyAsync(true) @@ -536,25 +536,6 @@ const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider PREFERRED_RADIO_STATION: 'Preferred Radio Station: ' }) $translateProvider.preferredLanguage('en') - - window.datadogRum = datadogRum - window.datadogRum && window.datadogRum.init({ - applicationId: '3937053e-386b-4b5b-ab4a-c83217d2f953', - clientToken: process.env.DATADOG_RUM_CLIENT_TOKEN, - site: 'datadoghq.com', - service: 'give-web', - env: process.env.NODE_ENV, - version: process.env.GITHUB_SHA, - sessionSampleRate: process.env.NODE_ENV === 'staging' ? 100 : 10, - sessionReplaySampleRate: process.env.NODE_ENV === 'staging' ? 100 : 1, - trackUserInteractions: true, - trackResources: true, - trackLongTasks: true, - defaultPrivacyLevel: 'mask-user-input' - }) - - window.datadogRum && window.datadogRum.startSessionReplayRecording() - console.log('node env: ', process.env.NODE_ENV) } export default angular.module('appConfig', [ @@ -563,3 +544,4 @@ export default angular.module('appConfig', [ ]) .config(appConfig) .config(rollbarConfig) + .config(dataDogConfig) diff --git a/src/common/datadog.config.js b/src/common/datadog.config.js new file mode 100644 index 000000000..36ceb652f --- /dev/null +++ b/src/common/datadog.config.js @@ -0,0 +1,26 @@ +import 'angular-environment' +import { datadogRum } from '@datadog/browser-rum' + +const dataDogConfig = /* @ngInject */ function (envServiceProvider) { + const config = { + applicationId: '3937053e-386b-4b5b-ab4a-c83217d2f953', + clientToken: process.env.DATADOG_RUM_CLIENT_TOKEN, + site: 'datadoghq.com', + service: 'give-web', + env: envServiceProvider.get(), + version: process.env.GITHUB_SHA, + sessionSampleRate: envServiceProvider.is('development') ? 100 : 10, + sessionReplaySampleRate: envServiceProvider.is('development') ? 100 : 1, + trackUserInteractions: true, + trackResources: true, + trackLongTasks: true, + defaultPrivacyLevel: 'mask-user-input' + } + + window.datadogRum = datadogRum + window.datadogRum && window.datadogRum.init(config) + window.datadogRum && window.datadogRum.startSessionReplayRecording() +} +export { + dataDogConfig as default +} From b1912acaab4a140fa23d98d73d4c4e9d9fff8d99 Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Fri, 15 Sep 2023 12:54:36 -0700 Subject: [PATCH 9/9] change sample rate on staging --- src/common/datadog.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/datadog.config.js b/src/common/datadog.config.js index 36ceb652f..935458bc1 100644 --- a/src/common/datadog.config.js +++ b/src/common/datadog.config.js @@ -9,8 +9,8 @@ const dataDogConfig = /* @ngInject */ function (envServiceProvider) { service: 'give-web', env: envServiceProvider.get(), version: process.env.GITHUB_SHA, - sessionSampleRate: envServiceProvider.is('development') ? 100 : 10, - sessionReplaySampleRate: envServiceProvider.is('development') ? 100 : 1, + sessionSampleRate: envServiceProvider.is('staging') ? 100 : 10, + sessionReplaySampleRate: envServiceProvider.is('staging') ? 100 : 1, trackUserInteractions: true, trackResources: true, trackLongTasks: true,