Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sequence ID for sorting activities #4203

Merged
merged 37 commits into from
Apr 7, 2022

Conversation

compulim
Copy link
Contributor

@compulim compulim commented Mar 11, 2022

Fixes #4204.

Changelog Entry

Fixed

  • Fixes #4204. Sort using activity.channelData['webchat:sequence-id'] and fallback to epoch time of activity.timestamp, by @compulim, in PR #4203

Description

Today, we use activity.timestamp for sorting activities.

However, in ACS/Omnichannel, the server timestamp has a resolution too low for sorting (up to 1 second).

We are adding activity.channelData['webchat:sequence-id']: number and will use this integer value over activity.timestamp. If not provided, we will fallback to epoch of activity.timestamp.

Design

Please refer to the SORTING.md for design.

Specific Changes

  • Clock skew is no longer needed as we are using sequence ID
  • Post activity patch activity-in-transit slightly differently
    • Sequence ID is now required internally. For activity-in-transit, we will use the largest sequence ID in the chat history and increase it by 0.001
  • activities reducer now use sequence ID for sort keys
  • Move activity.channelData.clientTimestamp to activity.localTimestamp
    • clientTimestamp was used for "send failed, retry" prompts, using localTimestamp should have minimal impact
  • Fully implemented most types from Direct Line
  • Web Chat has a better-defined activity type, namely type WebChatActivity
    • The new type is compatible with type DirectLineActivity but better defined to handle channelData and other Web Chat-specific data structure
    • The new type will be exposed by Web Chat APIs
    • The existing type DirectLineActivity will be used only for communicating with DirectLineJS
  • Using import type {} and export type {} over import {} and export default for better tree-shaking
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@compulim compulim marked this pull request as ready for review March 15, 2022 11:45
@compulim compulim added the p1 Painful if we don't fix, won't block releasing label Mar 15, 2022
cwhitten
cwhitten previously approved these changes Mar 15, 2022
cwhitten
cwhitten previously approved these changes Apr 7, 2022
tdurnford
tdurnford previously approved these changes Apr 7, 2022
@compulim compulim dismissed stale reviews from tdurnford and cwhitten via dc12441 April 7, 2022 19:19
@compulim compulim merged commit e08c94b into microsoft:main Apr 7, 2022
@compulim compulim deleted the feat-sequence-id branch April 7, 2022 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1 Painful if we don't fix, won't block releasing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add activity.channelData['webchat:sequence-id'] for sort key
3 participants