Skip to content

Commit

Permalink
Merge pull request #1055 from CruGlobal/merge-master
Browse files Browse the repository at this point in the history
Merge master
  • Loading branch information
wrandall22 authored Sep 29, 2023
2 parents 0596d44 + 4d398d5 commit 366a6a4
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ModalInstanceCtrl {
this.facebookPixelId = facebookPixelId

this.suggestedAmounts = transform(suggestedAmounts, (result, value, key) => {
if (key === 'jcr:primaryType') { return }
if (key === 'jcr:primaryType' || !value?.amount) return
result.push({
amount: Number(value.amount),
description: value.description,
Expand All @@ -23,9 +23,9 @@ class ModalInstanceCtrl {
}

transformSuggestedAmounts () {
return transform(this.suggestedAmounts, (result, value, i) => {
const filterOutZeroAmounts = this.suggestedAmounts.filter((amount) => amount?.amount)
return transform(filterOutZeroAmounts, (result, value, i) => {
delete value.order
value.amount = value.amount || 0
result[i + 1] = value
}, {})
}
Expand Down
24 changes: 23 additions & 1 deletion src/app/designationEditor/pageOptionsModal/pageOptions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ describe('Designation Editor Page Options', function () {
facebookPixelId: '635334562464',
suggestedAmounts: { 'jcr:primaryType': 'nt:unstructured',
1: { 'jcr:primaryType': 'nt:unstructured', description: '1 Bible', amount: 100 },
2: { 'jcr:primaryType': 'nt:unstructured', description: '2 Bibles', amount: 200 } },
2: { 'jcr:primaryType': 'nt:unstructured', description: '2 Bibles', amount: 200 },
3: { 'jcr:primaryType': 'nt:unstructured', description: '2 Bibles', amount: 0 },
4: { }, },
$scope: $scope
})
}))
Expand All @@ -42,4 +44,24 @@ describe('Designation Editor Page Options', function () {
2: { amount: 200, description: '2 Bibles' }
})
})

it('should remove zero or empty objects', function () {
$ctrl.suggestedAmounts.push({
amount: 0,
description: '3 Bibles',
});
$ctrl.suggestedAmounts.push({
amount: 400,
description: '4 Bibles',
});
$ctrl.suggestedAmounts.push({ description: '5 Bibles' });

expect($ctrl.transformSuggestedAmounts()).toEqual({
1: { amount: 100, description: '1 Bible' },
2: { amount: 200, description: '2 Bibles' },
3: { amount: 400, description: '4 Bibles' }
})
})


})
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class ProductConfigFormController {

const suggestedAmountsObservable = this.designationsService.suggestedAmounts(this.code, this.itemConfig)
.do(suggestedAmounts => {
this.suggestedAmounts = suggestedAmounts
this.suggestedAmounts = suggestedAmounts.filter((amount) => amount?.amount)
this.useSuggestedAmounts = !isEmpty(this.suggestedAmounts)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('product config form component', function () {

jest.spyOn($ctrl.commonService, 'getNextDrawDate').mockReturnValue(Observable.of('2016-10-02'))

jest.spyOn($ctrl.designationsService, 'suggestedAmounts').mockReturnValue(Observable.of([{ amount: 5 }, { amount: 10 }]))
jest.spyOn($ctrl.designationsService, 'suggestedAmounts').mockReturnValue(Observable.of([{ amount: 5 }, { amount: 10 }, { amount: 0 }, { }]))

jest.spyOn($ctrl.designationsService, 'givingLinks').mockReturnValue(Observable.of([]))
jest.spyOn($ctrl.analyticsFactory, 'giveGiftModal').mockReturnValue(() => {})
Expand Down Expand Up @@ -231,6 +231,19 @@ describe('product config form component', function () {
})
})


describe('loadData but suggestedAmounts only has 0 amounts or empty objects', () => {
beforeEach(() => {
jest.spyOn($ctrl.designationsService, 'suggestedAmounts').mockReturnValue(Observable.of([{ amount: 0 }, { }]))
})

it('should use default amounts', () => {
$ctrl.loadData()
expect($ctrl.suggestedAmounts).toEqual([])
expect($ctrl.useSuggestedAmounts).toEqual(false)
})
})

describe('setDefaultAmount', () => {
beforeEach(() => {
$ctrl.itemConfig = {}
Expand Down
2 changes: 2 additions & 0 deletions src/common/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'angular-environment'
import 'angular-translate'

import rollbarConfig from './rollbar.config'
import dataDogConfig from './datadog.config.js'

const appConfig = /* @ngInject */ function (envServiceProvider, $compileProvider, $logProvider, $httpProvider, $locationProvider, $qProvider, $translateProvider) {
$httpProvider.useApplyAsync(true)
Expand Down Expand Up @@ -557,3 +558,4 @@ export default angular.module('appConfig', [
])
.config(appConfig)
.config(rollbarConfig)
.config(dataDogConfig)
26 changes: 26 additions & 0 deletions src/common/datadog.config.js
Original file line number Diff line number Diff line change
@@ -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('staging') ? 100 : 10,
sessionReplaySampleRate: envServiceProvider.is('staging') ? 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
}
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,26 @@
dependencies:
"@cspotcode/source-map-consumer" "0.8.0"

"@datadog/[email protected]":
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/[email protected]":
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"
Expand Down

0 comments on commit 366a6a4

Please sign in to comment.