Skip to content

Hoist error tracking to composite level#3286

Merged
JamesBurnside merged 9 commits intomainfrom
jaburnsi/persist-error-dismissals
Jul 10, 2023
Merged

Hoist error tracking to composite level#3286
JamesBurnside merged 9 commits intomainfrom
jaburnsi/persist-error-dismissals

Conversation

@JamesBurnside
Copy link
Copy Markdown
Member

@JamesBurnside JamesBurnside commented Jun 28, 2023

What

Hoist error dismissed tracking to composite level

Why

We had two issues:

  1. Errors would reappear on different pages. If I dismissed an error on the lobby page, it would reappear on the call page. This was because the error bar would be unmounted and remounted thus losing the fact it had previously tracked an error had been dismissed.
  2. Errors now appear in the side pane instead of the call screen, but the same error shows on the call screen if the side pane is closed without dismissing the error. Because these are two separate components there was no shared knowledge that an error was dismissed.

How Tested

Locally:

howtested-errchanges.mp4

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 28, 2023

Chat bundle size is increased❗.

  • Current size: 2248531
  • Base size: 2248428
  • Diff size: 103

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 28, 2023

CallWithChat bundle size is increased❗.

  • Current size: 10660934
  • Base size: 10660319
  • Diff size: 615

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 28, 2023

Calling bundle size is increased❗.

  • Current size: 10019589
  • Base size: 10018974
  • Diff size: 615

@github-actions
Copy link
Copy Markdown
Contributor

Failed to pass the UI Test. If this PR is for UI change and the error is snapshot mismatch, please add "update_snapshots" label to the PR for updating the snapshot.

const initialState = defaultMockCallAdapterState();
initialState.latestErrors = {
'Call.unmute': {
timestamp: new Date(Date.now() + 3600 * 1000 * 24),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change was necessary because the error tracking checks the timestamp when the error was dismissed, these mock errors were set way in the future so the dismissedAt timestamp was way earlier than this mock timestamp.

@github-actions
Copy link
Copy Markdown
Contributor

}

/** @private */
export type TrackedErrors = Partial<Record<ErrorType, ErrorTrackingInfo>>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not requesting a change here but we should think about the typing here. We had a ARB comment recently around types defined as { [key: string]: Object } that is just essentially just a Record<string, Object>. do we know which typing we want to align with to not confuse the ARB? (We currently observe the former)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point, no idea on this. Do you have a link to the apiview comment? They should update the azure policies if they have a strong preference but I'm also curious what the difference is!
(This is private so at least doesn't matter for this PR but is a good callout to highlight for everyone across the repo)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 5, 2023

const activeErrors = usePropsFor(ErrorBar).activeErrorMessages;
const [trackedErrors, setTrackedErrors] = useState<TrackedErrors>({} as TrackedErrors);
useEffect(() => {
setTrackedErrors((prev) => updateTrackedErrorsWithActiveErrors(prev, activeErrors));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do the tracked errors signify and are these internal to the call composite. Shouldn't we only have active and dismissed errors maintained globally?

Copy link
Copy Markdown
Member Author

@JamesBurnside JamesBurnside Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TrackedErrors is the mapping of any errors that have been triggered to information about the timestamp when they were last active, and the timestamp when it was last dismissed. trackedErrors maps the error type to an object containing:

  mostRecentlyActive: Date;
  lastDismissedAt?: Date;

So, for example, when a new error comes in, that error will be added to set:

trackedErrors = {
  newError1: {
    lastActive: Date.now()
  }
}

Then if another error comes in:

trackedErrors = {
  newError1: {
    lastActive: <oldTimestampA>
  },
  newError2: {
    lastActive: Date.now()
  }
}

Then if error1 is dismissed but is still active (e.g. no headphones are still plugged in but the error was dismissed):

trackedErrors = {
  newError1: {
    lastActive: <oldTimestampA>,
    dismissedAt: Date.now()
  },
  newError2: {
    lastActive: <oldTimeStampB>
  }
}

If error1 is resolved and no longer exists in stateful, its removed from the set of errors being tracked:

trackedErrors = {
  newError2: {
    lastActive: <oldTimeStampB>
  }
}

If it reappears again, it gets added as normal, and will reappear to the user to be dismissed again:

trackedErrors = {
  newError1: {
    lastActive: Date.now()
  },
  newError2: {
    lastActive: <oldTimeStampB>
  }
}

Copy link
Copy Markdown
Member Author

@JamesBurnside JamesBurnside Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tracking is local to the CallComposite, if someone plugged the same adapter into a new CallComposite the errors would reappear to be dimissed (an argument for moving error tracking to adapter layer but that can be a future improvement)

<VideoEffectsPaneContent
onDismissError={onDismissVideoEffectError}
activeVideoEffectError={activeVideoEffectError}
setActiveVideoEffect={setActiveVideoEffect}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have removed set active video effects, don't we need that information for the pane anymore?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good point, currently it is only used to track errors, so when I removed the error tracking code it was dead code so I removed it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into it, the VideoEffectsPaneContent tracks everything internally so yep not needed

@github-actions
Copy link
Copy Markdown
Contributor

@JamesBurnside JamesBurnside enabled auto-merge (squash) July 10, 2023 17:11
@github-actions
Copy link
Copy Markdown
Contributor

@JamesBurnside JamesBurnside merged commit 81ea9c6 into main Jul 10, 2023
@JamesBurnside JamesBurnside deleted the jaburnsi/persist-error-dismissals branch July 10, 2023 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants