-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chat-headless: add support for session reinitialization
Adds session state management for the credentials returned by the underlying agent client, such that on agent client initialization, the returned credentials are saved in session storage. When chat-headless is reloaded and getNextMessage is called, the session in the agent client is reinitialized. Session credentials are cleared any time the client is reset. TEST=manual,auto Wrote new unit tests, saw them pass. Ran local test app with a Zendesk client, saw conversation persisted across page refreshes.
- Loading branch information
Showing
13 changed files
with
269 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,38 @@ | ||
## Testing Process | ||
|
||
### Unit Testing | ||
|
||
We use Jest as our framework for unit tests. Execute the unit tests with the following command: | ||
|
||
``` | ||
npm run test | ||
``` | ||
|
||
### Test Site | ||
|
||
To facilitate manual verification, a React test site has been set up in `apps/test-site`. This site currently already have an App component that interfaces with the local `chat-headless-react` library. | ||
|
||
To set up the test site, make sure you have a `.env` file configured following the `.sample.env` file. Then, run the following commands: | ||
|
||
``` | ||
npm i | ||
npm run start | ||
``` | ||
|
||
|
||
## Build Process | ||
|
||
Before initiating the build, run the linting process to identify and address any errors or warnings. Use the following command: | ||
|
||
``` | ||
npm run lint | ||
``` | ||
|
||
To build the library, execute: | ||
|
||
``` | ||
npm run build | ||
``` | ||
|
||
This will create the bundle in the `/dist` directory. This command will also generate documentation files and the `THIRD-PARTY-NOTICES` file. | ||
|
||
For guidelines on pull request and version publish process, visit Chat SDK wiki page. | ||
For guidelines on pull request and version publish process, visit Chat SDK wiki page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,9 +65,9 @@ SOFTWARE. | |
The following npm packages may be included in this product: | ||
|
||
- @types/[email protected] | ||
- @types/[email protected].12 | ||
- @types/[email protected].13 | ||
- @types/[email protected] | ||
- @types/[email protected].5 | ||
- @types/[email protected].9 | ||
- @types/[email protected] | ||
|
||
These packages each contain the following license and notice below: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,43 @@ | ||
## Testing Process | ||
|
||
### Unit Testing | ||
|
||
We use Jest as our framework for unit tests. Execute the unit tests with the following command: | ||
|
||
``` | ||
npm run test | ||
``` | ||
|
||
### Test Site | ||
|
||
To facilitate manual verification, a React test site has been set up in `apps/test-site`. This site currently already have an App component that interfaces with the local `chat-headless-react` library. There are two methods to test the `chat-headless` library: | ||
* Have chat-headless-react import the local chat-headless build. Then, the test site will receive the local changes when interfacing with chat-headless-react. | ||
* Update the test site import the local chat-headless to test state update. You would need to create a new component to interface with chat-headless library. | ||
|
||
- Have chat-headless-react import the local chat-headless build. Then, the test site will receive the local changes when interfacing with chat-headless-react. | ||
- Update the test site import the local chat-headless to test state update. You would need to create a new component to interface with chat-headless library. | ||
|
||
See Chat SDK wiki on how to link to local build. | ||
|
||
To set up the test site, make sure you have a `.env` file configured following the `.sample.env` file. Then, run the following commands: | ||
|
||
``` | ||
npm i | ||
npm run start | ||
``` | ||
|
||
|
||
## Build Process | ||
|
||
Before initiating the build, run the linting process to identify and address any errors or warnings. Use the following command: | ||
|
||
``` | ||
npm run lint | ||
``` | ||
|
||
To build the library, execute: | ||
|
||
``` | ||
npm run build | ||
``` | ||
|
||
This will create the bundle in the `/dist` directory. This command will also generate documentation files and the `THIRD-PARTY-NOTICES` file. | ||
|
||
For guidelines on pull request and version publish process, visit Chat SDK wiki page. | ||
For guidelines on pull request and version publish process, visit Chat SDK wiki page. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/chat-headless/docs/chat-headless.chateventclient.reinitializesession.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@yext/chat-headless](./chat-headless.md) > [ChatEventClient](./chat-headless.chateventclient.md) > [reinitializeSession](./chat-headless.chateventclient.reinitializesession.md) | ||
|
||
## ChatEventClient.reinitializeSession() method | ||
|
||
Reinitialize the session using existing session data. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
reinitializeSession(credentials: any): Promise<void>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| credentials | any | | | ||
|
||
**Returns:** | ||
|
||
Promise<void> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.