Skip to content

Commit 76692ce

Browse files
authored
send browser info on commit (#2847)
* send browser info on commit * add changeset
1 parent 5b9f288 commit 76692ce

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

.changeset/polite-timers-sniff.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@adyen/adyen-web': patch
3+
---
4+
5+
send browserInfo in setup call

packages/lib/src/core/CheckoutSession/CheckoutSession.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import {
1212
CheckoutSessionOrdersResponse,
1313
CheckoutSessionPaymentResponse,
1414
CheckoutSessionSetupResponse,
15-
SessionConfiguration
15+
SessionConfiguration,
16+
SetupSessionOptions
1617
} from './types';
1718
import cancelOrder from '../Services/sessions/cancel-order';
1819
import { onOrderCancelData } from '../../components/Dropin/types';
1920
import type { AdditionalDetailsData } from '../types';
21+
import collectBrowserInfo from '../../utils/browserInfo';
2022

2123
class Session {
2224
private readonly session: CheckoutSession;
@@ -66,8 +68,9 @@ class Session {
6668
/**
6769
* Fetches data from a session
6870
*/
69-
setupSession(options): Promise<CheckoutSessionSetupResponse> {
70-
return setupSession(this, options).then(response => {
71+
setupSession(options: SetupSessionOptions): Promise<CheckoutSessionSetupResponse> {
72+
const mergedOptions = { ...options, browserInfo: collectBrowserInfo() }
73+
return setupSession(this, mergedOptions).then(response => {
7174
if (response.configuration) {
7275
this.configuration = { ...response.configuration };
7376
}

packages/lib/src/core/CheckoutSession/types.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { InstallmentOptions } from '../../components/Card/components/CardInput/components/types';
2-
import { PaymentAction, PaymentAmount, ResultCode } from '../../types/global-types';
2+
import { BrowserInfo, Order, PaymentAction, PaymentAmount, ResultCode } from '../../types/global-types';
33

44
export type CheckoutSession = {
55
id: string;
@@ -57,3 +57,8 @@ export type CheckoutSessionOrdersResponse = {
5757
orderData: string;
5858
pspReference: string;
5959
};
60+
61+
export type SetupSessionOptions = {
62+
browserInfo?: BrowserInfo,
63+
order?: Order
64+
}

packages/lib/src/core/Services/sessions/setup-session.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { httpPost } from '../http';
22
import Session from '../../CheckoutSession';
3-
import { CheckoutSessionSetupResponse } from '../../CheckoutSession/types';
3+
import { CheckoutSessionSetupResponse, SetupSessionOptions } from '../../CheckoutSession/types';
44
import { API_VERSION } from './constants';
55

6-
function setupSession(session: Session, options): Promise<CheckoutSessionSetupResponse> {
6+
function setupSession(session: Session, options: SetupSessionOptions): Promise<CheckoutSessionSetupResponse> {
77
const path = `${API_VERSION}/sessions/${session.id}/setup?clientKey=${session.clientKey}`;
88
const data = {
9+
browserInfo: options.browserInfo,
910
sessionData: session.data,
1011
...(options.order
1112
? {

0 commit comments

Comments
 (0)