Skip to content

Commit

Permalink
send browser info on commit (#2847)
Browse files Browse the repository at this point in the history
* send browser info on commit

* add changeset
  • Loading branch information
m1aw authored Sep 16, 2024
1 parent 5b9f288 commit 76692ce
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-timers-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@adyen/adyen-web': patch
---

send browserInfo in setup call
9 changes: 6 additions & 3 deletions packages/lib/src/core/CheckoutSession/CheckoutSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import {
CheckoutSessionOrdersResponse,
CheckoutSessionPaymentResponse,
CheckoutSessionSetupResponse,
SessionConfiguration
SessionConfiguration,
SetupSessionOptions
} from './types';
import cancelOrder from '../Services/sessions/cancel-order';
import { onOrderCancelData } from '../../components/Dropin/types';
import type { AdditionalDetailsData } from '../types';
import collectBrowserInfo from '../../utils/browserInfo';

class Session {
private readonly session: CheckoutSession;
Expand Down Expand Up @@ -66,8 +68,9 @@ class Session {
/**
* Fetches data from a session
*/
setupSession(options): Promise<CheckoutSessionSetupResponse> {
return setupSession(this, options).then(response => {
setupSession(options: SetupSessionOptions): Promise<CheckoutSessionSetupResponse> {
const mergedOptions = { ...options, browserInfo: collectBrowserInfo() }
return setupSession(this, mergedOptions).then(response => {
if (response.configuration) {
this.configuration = { ...response.configuration };
}
Expand Down
7 changes: 6 additions & 1 deletion packages/lib/src/core/CheckoutSession/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InstallmentOptions } from '../../components/Card/components/CardInput/components/types';
import { PaymentAction, PaymentAmount, ResultCode } from '../../types/global-types';
import { BrowserInfo, Order, PaymentAction, PaymentAmount, ResultCode } from '../../types/global-types';

export type CheckoutSession = {
id: string;
Expand Down Expand Up @@ -57,3 +57,8 @@ export type CheckoutSessionOrdersResponse = {
orderData: string;
pspReference: string;
};

export type SetupSessionOptions = {
browserInfo?: BrowserInfo,
order?: Order
}
5 changes: 3 additions & 2 deletions packages/lib/src/core/Services/sessions/setup-session.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { httpPost } from '../http';
import Session from '../../CheckoutSession';
import { CheckoutSessionSetupResponse } from '../../CheckoutSession/types';
import { CheckoutSessionSetupResponse, SetupSessionOptions } from '../../CheckoutSession/types';
import { API_VERSION } from './constants';

function setupSession(session: Session, options): Promise<CheckoutSessionSetupResponse> {
function setupSession(session: Session, options: SetupSessionOptions): Promise<CheckoutSessionSetupResponse> {
const path = `${API_VERSION}/sessions/${session.id}/setup?clientKey=${session.clientKey}`;
const data = {
browserInfo: options.browserInfo,
sessionData: session.data,
...(options.order
? {
Expand Down

0 comments on commit 76692ce

Please sign in to comment.