-
Notifications
You must be signed in to change notification settings - Fork 2k
Help Center: Logged-Out Support for Support Guides and Odie #107902
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
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~502 bytes removed 📉 [gzipped]) DetailsCommon code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~305 bytes removed 📉 [gzipped]) DetailsSections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~289 bytes removed 📉 [gzipped]) DetailsReact components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
74f0bf9 to
6c4e2e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also removing these as it looks like they are not used here
6c4e2e2 to
980d800
Compare
| persistValueSafely( 'logged_out_help_center_preferences', preferences ); | ||
| } else if ( isLoggedIn ) { | ||
| // Delete local preferences when logged in to avoid conflicts. | ||
| persistValueSafely( 'logged_out_help_center_preferences', null ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put logged_out_help_center_preferences in a const somewhere? I see it being used a few times around
| if ( ! supportInteraction && chatId && ! isLoggedOutSession ) { | ||
| supportInteraction = await startNewInteraction( { | ||
| event_external_id: chatId.toString(), | ||
| event_source: 'odie', | ||
| } ); | ||
| } else if ( supportInteraction && ! odieId && chatId ) { | ||
| } else if ( supportInteraction && ! odieId && chatId && ! isLoggedOutSession ) { | ||
| supportInteraction = await addEventToInteraction( { | ||
| interactionId: supportInteraction.uuid, | ||
| eventData: { | ||
| event_external_id: chatId.toString(), | ||
| event_source: 'odie', | ||
| }, | ||
| } ); | ||
| } else if ( isLoggedOutSession ) { | ||
| // If the user is not logged in, we don't need to create a new support interaction. | ||
| updateLoggedOutSession( chatId.toString(), returnedChat.session_id, botSlug ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of
if ( isLoggedOutSession ) {
// If the user is not logged in, we don't need to create a new support interaction.
updateLoggedOutSession( chatId.toString(), returnedChat.session_id, botSlug );
} else {
if ( ! supportInteraction && chatId ) {
...
}
My brain works better this way, totally up to you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's much better!
| window.localStorage.removeItem( PREFERENCES_KEY + 'help_center_open' ); | ||
| window.localStorage.removeItem( PREFERENCES_KEY + 'help_center_minimized' ); | ||
| window.localStorage.removeItem( PREFERENCES_KEY + 'help_center_router_history' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: slightly better for maintainability
| window.localStorage.removeItem( PREFERENCES_KEY + 'help_center_open' ); | |
| window.localStorage.removeItem( PREFERENCES_KEY + 'help_center_minimized' ); | |
| window.localStorage.removeItem( PREFERENCES_KEY + 'help_center_router_history' ); | |
| try { | |
| const keys = Object.keys( memoryStore ) as Array< keyof Preferences[ 'calypso_preferences' ] >; | |
| keys.forEach( ( key ) => { | |
| window.localStorage.removeItem( PREFERENCES_KEY + key ); | |
| } ); |
heavyweight
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't find any blockers
Co-authored-by: Emanuele Buccelli <[email protected]>
Fixes dotcom-15390
Proposed Changes
This hooks up the Help Center and Odie client to the locally persisted chat and router states. In other words, this adds an alternative to Calypso preferences.
Why are these changes being made?
This allows logged out users to have coherent and continuous sessions.
Testing Instructions
Odie chats
Chat history
UI state
Chat continuity after logging in