diff --git a/.changeset/neat-pandas-mix.md b/.changeset/neat-pandas-mix.md new file mode 100644 index 00000000..663f6f9a --- /dev/null +++ b/.changeset/neat-pandas-mix.md @@ -0,0 +1,5 @@ +--- +'@adyen/adyen-web': patch +--- + +Send 'do-not-track' as value for checkoutAttemptId when analytics is disabled diff --git a/packages/lib/src/components/BaseElement.ts b/packages/lib/src/components/BaseElement.ts index aaef172f..b820f2d4 100644 --- a/packages/lib/src/components/BaseElement.ts +++ b/packages/lib/src/components/BaseElement.ts @@ -56,7 +56,8 @@ class BaseElement
{ */ get data(): PaymentData | RiskData { const clientData = getProp(this.props, 'modules.risk.data'); - const checkoutAttemptId = getProp(this.props, 'modules.analytics.checkoutAttemptId'); + const useAnalytics = !!getProp(this.props, 'modules.analytics.props.enabled'); + const checkoutAttemptId = useAnalytics ? getProp(this.props, 'modules.analytics.checkoutAttemptId') : 'do-not-track'; const order = this.state.order || this.props.order; const componentData = this.formatData(); diff --git a/packages/lib/src/components/PayPal/Paypal.test.ts b/packages/lib/src/components/PayPal/Paypal.test.ts index 185be59e..84204d4b 100644 --- a/packages/lib/src/components/PayPal/Paypal.test.ts +++ b/packages/lib/src/components/PayPal/Paypal.test.ts @@ -3,12 +3,18 @@ import Paypal from './Paypal'; describe('Paypal', () => { test('Returns a data object', () => { const paypal = new Paypal({}); - expect(paypal.data).toEqual({ clientStateDataIndicator: true, paymentMethod: { subtype: 'sdk', type: 'paypal' } }); + expect(paypal.data).toEqual({ + clientStateDataIndicator: true, + paymentMethod: { subtype: 'sdk', type: 'paypal', checkoutAttemptId: 'do-not-track' } + }); }); test('should return subtype express if isExpress flag is set', () => { const paypal = new Paypal({ isExpress: true }); - expect(paypal.data).toEqual({ clientStateDataIndicator: true, paymentMethod: { subtype: 'express', type: 'paypal' } }); + expect(paypal.data).toEqual({ + clientStateDataIndicator: true, + paymentMethod: { subtype: 'express', type: 'paypal', checkoutAttemptId: 'do-not-track' } + }); }); test('Is always valid', () => { diff --git a/packages/lib/src/components/Pix/Pix.test.ts b/packages/lib/src/components/Pix/Pix.test.ts index b41e8c93..6d5b9138 100644 --- a/packages/lib/src/components/Pix/Pix.test.ts +++ b/packages/lib/src/components/Pix/Pix.test.ts @@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event'; test('should return only payment type if personalDetails is not required', async () => { const pixElement = new Pix({}); - expect(pixElement.data).toEqual({ clientStateDataIndicator: true, paymentMethod: { type: 'pix' } }); + expect(pixElement.data).toEqual({ clientStateDataIndicator: true, paymentMethod: { type: 'pix', checkoutAttemptId: 'do-not-track' } }); }); test('should show personal details form if enabled', async () => {