Feature/indicate when analytics disabled (#2290)

* Send 'do-not-track' as value for checkoutAttemptId when analytics is disabled

* adding .changeset

* Fixing e2e tests
This commit is contained in:
sponglord
2023-08-14 10:52:27 +02:00
committed by GitHub
parent 410a4ee13e
commit c871798907
4 changed files with 16 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
'@adyen/adyen-web': patch
---
Send 'do-not-track' as value for checkoutAttemptId when analytics is disabled

View File

@@ -56,7 +56,8 @@ class BaseElement<P extends BaseElementProps> {
*/
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();

View File

@@ -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', () => {

View File

@@ -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 () => {