@mxenabled/connect-widget 2.5.2 → 2.5.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.
package/dist/index.es.js CHANGED
@@ -73878,12 +73878,14 @@ const DEFAULT_POLLING_STATE = {
73878
73878
  // previous response from last poll
73879
73879
  currentResponse: {},
73880
73880
  // current response
73881
- jobIsDone: false,
73881
+ pollingIsDone: false,
73882
73882
  // whether or not we should stop polling
73883
- userMessage: CONNECTING_MESSAGES.STARTING
73883
+ userMessage: CONNECTING_MESSAGES.STARTING,
73884
73884
  // message to show the end user
73885
+ initialDataReady: false
73886
+ // whether the initial data ready event has been sent
73885
73887
  };
73886
- function pollMember(memberGuid, api, onPostMessage, sendAnalyticsEvent, clientLocale) {
73888
+ function pollMember(memberGuid, api, clientLocale) {
73887
73889
  return interval(3e3).pipe(
73888
73890
  switchMap(
73889
73891
  () => (
@@ -73892,13 +73894,7 @@ function pollMember(memberGuid, api, onPostMessage, sendAnalyticsEvent, clientLo
73892
73894
  defer(() => api.loadMemberByGuid(memberGuid, clientLocale)).pipe(
73893
73895
  mergeMap(
73894
73896
  (member) => defer(() => api.loadJob(member.most_recent_job_guid)).pipe(
73895
- map((job) => {
73896
- if (job.async_account_data_ready) {
73897
- onPostMessage("connect/initialDataReady", { member_guid: member.guid });
73898
- sendAnalyticsEvent(AnalyticEvents.INITIAL_DATA_READY, { member_guid: member.guid });
73899
- }
73900
- return member;
73901
- })
73897
+ map((job) => ({ member, job }))
73902
73898
  )
73903
73899
  ),
73904
73900
  catchError((error) => of(error))
@@ -73916,13 +73912,18 @@ function pollMember(memberGuid, api, onPostMessage, sendAnalyticsEvent, clientLo
73916
73912
  // dont update previous response if this is an error
73917
73913
  previousResponse: isError ? acc.previousResponse : acc.currentResponse,
73918
73914
  // dont update current response if this is an error
73919
- currentResponse: isError ? acc.currentResponse : response
73915
+ currentResponse: isError ? acc.currentResponse : response,
73916
+ // preserve the initialDataReadySent flag
73917
+ initialDataReady: acc.initialDataReady
73920
73918
  };
73919
+ if (!isError && !acc.initialDataReady && response?.job?.async_account_data_ready) {
73920
+ pollingState.initialDataReady = true;
73921
+ }
73921
73922
  const [shouldStopPolling, messageKey] = handlePollingResponse(pollingState);
73922
73923
  return {
73923
73924
  ...pollingState,
73924
73925
  // we should keep polling based on the member
73925
- jobIsDone: isError ? false : shouldStopPolling,
73926
+ pollingIsDone: isError ? false : shouldStopPolling,
73926
73927
  userMessage: messageKey
73927
73928
  };
73928
73929
  },
@@ -73931,8 +73932,9 @@ function pollMember(memberGuid, api, onPostMessage, sendAnalyticsEvent, clientLo
73931
73932
  );
73932
73933
  }
73933
73934
  function handlePollingResponse(pollingState) {
73934
- const polledMember = pollingState.currentResponse;
73935
- const previousMember = pollingState.previousResponse;
73935
+ const polledMember = pollingState.currentResponse?.member || {};
73936
+ const previousMember = pollingState.previousResponse?.member || {};
73937
+ const polledJob = pollingState.currentResponse?.job || {};
73936
73938
  const justFinishedAggregating = previousMember.is_being_aggregated === true && polledMember.is_being_aggregated === false;
73937
73939
  const isNotAggregatingAtAll = previousMember.is_being_aggregated === false && polledMember.is_being_aggregated === false;
73938
73940
  if (polledMember.connection_status === ReadableStatuses$1.CHALLENGED) {
@@ -73941,6 +73943,9 @@ function handlePollingResponse(pollingState) {
73941
73943
  if (ProcessingStatuses.indexOf(polledMember.connection_status) !== -1) {
73942
73944
  return [false, CONNECTING_MESSAGES.VERIFYING];
73943
73945
  }
73946
+ if (polledJob.async_account_data_ready) {
73947
+ return [true, CONNECTING_MESSAGES.FINISHING];
73948
+ }
73944
73949
  if (polledMember.connection_status === ReadableStatuses$1.CONNECTED) {
73945
73950
  if (polledMember.is_being_aggregated) {
73946
73951
  return [false, CONNECTING_MESSAGES.SYNCING];
@@ -76367,25 +76372,33 @@ const Connecting = (props) => {
76367
76372
  const activeJob = getActiveJob(jobSchedule);
76368
76373
  const needsToInitializeJobSchedule = jobSchedule.isInitialized === false;
76369
76374
  function handleMemberPoll(pollingState) {
76370
- if (pollingState.pollingCount > 15 && pollingState.currentResponse?.connection_status !== ReadableStatuses$1.PENDING) {
76375
+ if (pollingState.pollingCount > 15 && pollingState.currentResponse?.member?.connection_status !== ReadableStatuses$1.PENDING) {
76371
76376
  setTimedOut(true);
76372
76377
  }
76373
76378
  const overrideStatusChanged = postMessageEventOverrides?.memberStatusUpdate?.getHasStatusChanged({
76374
- currentMember: pollingState.currentResponse,
76375
- previousMember: pollingState.previousResponse
76379
+ currentMember: pollingState.currentResponse?.member,
76380
+ previousMember: pollingState.previousResponse?.member
76376
76381
  });
76377
76382
  const overrideEventData = postMessageEventOverrides?.memberStatusUpdate?.createEventData?.({
76378
76383
  institution: selectedInstitution,
76379
- member: pollingState.currentResponse
76384
+ member: pollingState.currentResponse?.member
76380
76385
  });
76381
- const statusChanged = pollingState.previousResponse?.connection_status !== pollingState.currentResponse?.connection_status;
76386
+ const statusChanged = pollingState.previousResponse?.member?.connection_status !== pollingState.currentResponse?.member?.connection_status;
76382
76387
  const eventData = overrideEventData || {
76383
- member_guid: pollingState.currentResponse.guid,
76384
- connection_status: pollingState.currentResponse.connection_status
76388
+ member_guid: pollingState.currentResponse?.member?.guid,
76389
+ connection_status: pollingState.currentResponse?.member?.connection_status
76385
76390
  };
76386
76391
  if (pollingState.previousResponse != null && (statusChanged || overrideStatusChanged)) {
76387
76392
  onPostMessage("connect/memberStatusUpdate", eventData);
76388
76393
  }
76394
+ if (pollingState.initialDataReady) {
76395
+ onPostMessage("connect/initialDataReady", {
76396
+ member_guid: pollingState.currentResponse?.member?.guid
76397
+ });
76398
+ sendAnalyticsEvent(AnalyticEvents.INITIAL_DATA_READY, {
76399
+ member_guid: pollingState.currentResponse?.member?.guid
76400
+ });
76401
+ }
76389
76402
  setMessage(pollingState.userMessage);
76390
76403
  }
76391
76404
  useEffect(() => {
@@ -76485,14 +76498,14 @@ const Connecting = (props) => {
76485
76498
  return needsJobStarted ? startJob$ : of(currentMember);
76486
76499
  }).pipe(
76487
76500
  concatMap(
76488
- (member) => pollMember(member.guid, api, onPostMessage, sendAnalyticsEvent, clientLocale).pipe(
76501
+ (member) => pollMember(member.guid, api, clientLocale).pipe(
76489
76502
  tap((pollingState) => handleMemberPoll(pollingState)),
76490
- filter((pollingState) => pollingState.jobIsDone),
76503
+ filter((pollingState) => pollingState.pollingIsDone),
76491
76504
  pluck("currentResponse"),
76492
76505
  take(1),
76493
- mergeMap((polledMember) => {
76506
+ mergeMap((polledResponse) => {
76494
76507
  const loadLatestJob$ = defer(() => api.loadJob(member.most_recent_job_guid)).pipe(
76495
- map((job) => ({ member: polledMember, job }))
76508
+ map((job) => ({ member: polledResponse.member, job }))
76496
76509
  );
76497
76510
  return loadLatestJob$;
76498
76511
  })