@adyen/kyc-components 2.36.0 → 2.36.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26257,7 +26257,7 @@ function CompanySearchDropinComponent({
26257
26257
  handleRefreshCompanyDataset,
26258
26258
  handleVerifyTin
26259
26259
  }) {
26260
- var _a, _b, _c;
26260
+ var _a, _b, _c, _d;
26261
26261
  const {
26262
26262
  state: {
26263
26263
  currentState
@@ -26343,10 +26343,11 @@ function CompanySearchDropinComponent({
26343
26343
  }, props);
26344
26344
  }
26345
26345
  }, [fieldConfigurations, problems == null ? void 0 : problems.remediationActions, problems == null ? void 0 : problems.missingData, legalEntityResponse, isExperimentEnabled, customRules, country2]);
26346
+ const isSkippingCompanyStructure = useEnableNewEntryFlow() && organizationTypesToSkipCompanyStructureForm.includes((_d = legalEntityResponse == null ? void 0 : legalEntityResponse.organization) == null ? void 0 : _d.type);
26346
26347
  const forms$1 = useMemo(() => {
26347
26348
  const requiredForms = getRequiredForms(forms, derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields);
26348
- return addValidityToForms(requiredForms, currentState.validityByForm, problems);
26349
- }, [derivedProps, problems, currentState.validityByForm]);
26349
+ return addValidityToForms(requiredForms, currentState.validityByForm, problems).filter((form) => isSkippingCompanyStructure ? form.formId !== "companyStructure" : true);
26350
+ }, [derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields, currentState.validityByForm, problems, isSkippingCompanyStructure]);
26350
26351
  const summaryData = useMemo(() => ({
26351
26352
  data: formatDataForSummary(currentState.data, forms$1, derivedProps == null ? void 0 : derivedProps.labels, i18n),
26352
26353
  omittedKeys: ["operationalAddressIsSame"]
@@ -33205,16 +33206,6 @@ const getAddress = async (context, addressId) => {
33205
33206
  }
33206
33207
  });
33207
33208
  };
33208
- const getAnalyticsSession = async (loadingContext, data) => httpPost({
33209
- loadingContext,
33210
- errorLevel: "warn",
33211
- errorMessage: `Failed to get analytics sessionId`,
33212
- path: `analytics/ui`,
33213
- authentication: "jwt",
33214
- headers: {
33215
- "Content-Type": "application/json"
33216
- }
33217
- }, data);
33218
33209
  const getIdverificationToken = async (context, request) => {
33219
33210
  const {
33220
33211
  loadingContext,
@@ -33285,16 +33276,6 @@ const idVerificationStartcheck = async (context, request) => {
33285
33276
  }
33286
33277
  }, request);
33287
33278
  };
33288
- const pushEvents = async (loadingContext, sessionId, event) => httpPost({
33289
- loadingContext,
33290
- errorLevel: "warn",
33291
- errorMessage: `Failed to push events`,
33292
- path: `analytics/ui/${sessionId}`,
33293
- authentication: "jwt",
33294
- headers: {
33295
- "Content-Type": "application/json"
33296
- }
33297
- }, event);
33298
33279
  const searchAddress = async (context, address2) => {
33299
33280
  const {
33300
33281
  loadingContext,
@@ -33354,9 +33335,7 @@ const useComponentApi = (rootLegalEntityId) => {
33354
33335
  getIdVerificationToken: async (legalEntityId, data) => getIdverificationToken(baseRequestContext, data),
33355
33336
  idVerificationStartCheck: async (legalEntityId, data) => idVerificationStartcheck(baseRequestContext, data),
33356
33337
  getOnboardingStatus: async () => getOnboardingStatus(baseRequestContext),
33357
- generateOnboardingLink: async (config) => generateOnboardingLink(baseRequestContext, config),
33358
- getAnalyticsSession: async (data) => getAnalyticsSession(loadingContext, data),
33359
- pushEvents: async (sessionId, event) => pushEvents(loadingContext, sessionId, event)
33338
+ generateOnboardingLink: async (config) => generateOnboardingLink(baseRequestContext, config)
33360
33339
  };
33361
33340
  }, [base, rootLegalEntityId]);
33362
33341
  };
@@ -33749,6 +33728,26 @@ const AuthProvider = ({
33749
33728
  children
33750
33729
  });
33751
33730
  };
33731
+ const getAnalyticsSession = async (loadingContext, data) => httpPost({
33732
+ loadingContext,
33733
+ errorLevel: "warn",
33734
+ errorMessage: `Failed to get analytics sessionId`,
33735
+ path: `analytics/ui`,
33736
+ authentication: "jwt",
33737
+ headers: {
33738
+ "Content-Type": "application/json"
33739
+ }
33740
+ }, data);
33741
+ const pushEvents = async (loadingContext, sessionId, event) => httpPost({
33742
+ loadingContext,
33743
+ errorLevel: "warn",
33744
+ errorMessage: `Failed to push events`,
33745
+ path: `analytics/ui/${sessionId}`,
33746
+ authentication: "jwt",
33747
+ headers: {
33748
+ "Content-Type": "application/json"
33749
+ }
33750
+ }, event);
33752
33751
  const convertToEmbeddedEvent = (eventQueueItem) => {
33753
33752
  const [eventType, event] = eventQueueItem;
33754
33753
  const hasEventData = typeof event === "object";
@@ -33763,28 +33762,33 @@ const convertToEmbeddedEvent = (eventQueueItem) => {
33763
33762
  };
33764
33763
  const useAnalytics = async ({
33765
33764
  onUserEvent,
33766
- isEmbeddedDropin,
33767
33765
  legalEntityId,
33768
33766
  sdkVersion,
33769
33767
  componentName
33770
33768
  }) => {
33771
33769
  const {
33772
- getAnalyticsSession: getAnalyticsSession2,
33773
- pushEvents: pushEvents2
33774
- } = useComponentApi(legalEntityId);
33770
+ isEmbeddedDropin,
33771
+ loadingContext: base
33772
+ } = useAuthContext();
33773
+ const loadingContext = `${base}api/${COMPONENTS_API_VERSION}/`;
33775
33774
  if (isEmbeddedDropin) {
33776
- const {
33777
- id: sessionId
33778
- } = await getAnalyticsSession2({
33779
- sdkVersion,
33780
- componentName,
33781
- userAgent: navigator.userAgent,
33782
- legalEntityId
33783
- });
33784
- userEvents.subscribe((data) => {
33785
- const eventItem = convertToEmbeddedEvent(data);
33786
- pushEvents2(sessionId, eventItem);
33787
- });
33775
+ try {
33776
+ const sessionResponse = await getAnalyticsSession(loadingContext, {
33777
+ sdkVersion,
33778
+ componentName,
33779
+ userAgent: navigator.userAgent,
33780
+ legalEntityId
33781
+ });
33782
+ if (!(sessionResponse == null ? void 0 : sessionResponse.id)) {
33783
+ throw Error("Analytics session Id not received");
33784
+ }
33785
+ userEvents.subscribe((data) => {
33786
+ const eventItem = convertToEmbeddedEvent(data);
33787
+ pushEvents(loadingContext, sessionResponse.id, eventItem);
33788
+ });
33789
+ } catch (e) {
33790
+ console.error("Failed to initiate analytics for component", e);
33791
+ }
33788
33792
  } else if (onUserEvent) {
33789
33793
  userEvents.subscribe(onUserEvent);
33790
33794
  }
@@ -34088,10 +34092,9 @@ const ConfigurationApiProvider = ({
34088
34092
  isEmbeddedDropin,
34089
34093
  loadingContext
34090
34094
  } = authContext;
34091
- const sdkVersion = "2.36.0";
34095
+ const sdkVersion = "2.36.3";
34092
34096
  useAnalytics({
34093
34097
  onUserEvent,
34094
- isEmbeddedDropin,
34095
34098
  legalEntityId: rootLegalEntityId,
34096
34099
  sdkVersion,
34097
34100
  componentName
@@ -1,11 +1,10 @@
1
1
  import { ComponentMap } from '../../components';
2
2
  import { EmbeddedEventItem, EventQueueItem, UserEventCallback } from '../user-events';
3
3
  export type useAnalyticsProps = {
4
- isEmbeddedDropin: boolean;
5
4
  legalEntityId: string;
6
5
  onUserEvent?: UserEventCallback;
7
6
  sdkVersion: string;
8
7
  componentName: keyof ComponentMap;
9
8
  };
10
9
  export declare const convertToEmbeddedEvent: (eventQueueItem: EventQueueItem) => EmbeddedEventItem;
11
- export declare const useAnalytics: ({ onUserEvent, isEmbeddedDropin, legalEntityId, sdkVersion, componentName, }: useAnalyticsProps) => Promise<void>;
10
+ export declare const useAnalytics: ({ onUserEvent, legalEntityId, sdkVersion, componentName, }: useAnalyticsProps) => Promise<void>;
@@ -1,7 +1,5 @@
1
1
  import { DropinAPIHandlers } from '../../components/Dropins/types';
2
- import { EmbeddedAnalyticsSessionRequest, EmbeddedAnalyticsSessionResponse } from '../models/api/analytics';
3
2
  import { BankVerificationErrorResponse, CreateTrustedTransferInstrumentResponse } from '../models/api/trusted-transferInstrument';
4
- import { EmbeddedEventItem } from '../user-events';
5
3
  export type ComponentApi = {
6
4
  getLegalEntity: Required<DropinAPIHandlers>['handleGetLegalEntity'];
7
5
  updateLegalEntity: Required<DropinAPIHandlers>['handleUpdateLegalEntity'];
@@ -21,8 +19,6 @@ export type ComponentApi = {
21
19
  handleBankVerificationError: (errorCode: string, errorMessage: string, state: string, metadata?: Map<string, string>) => Promise<BankVerificationErrorResponse>;
22
20
  getOnboardingStatus: Required<DropinAPIHandlers>['handleGetOnboardingStatus'];
23
21
  generateOnboardingLink: Required<DropinAPIHandlers>['handleGenerateOnboardingLink'];
24
- getAnalyticsSession(data: EmbeddedAnalyticsSessionRequest): Promise<EmbeddedAnalyticsSessionResponse>;
25
- pushEvents(sessionId: string, event: EmbeddedEventItem): Promise<void>;
26
22
  };
27
23
  export declare const COMPONENTS_API_VERSION = "v1";
28
24
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adyen/kyc-components",
3
- "version": "2.36.0",
3
+ "version": "2.36.3",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "files": [