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

Support: send initial info on chat start #471

Merged
merged 3 commits into from Mar 10, 2020
Merged

Conversation

adekbadek
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

In order for HEs to know that they're dealing with a Newspack customer, an "event" will be sent at the beginning of the chat. Events are used for messages like "user is navigating to billing page", but here we'll use this feature to "mark" a Newspack customer.

Screenshot 2020-03-05 at 14 43 52

Also, the "user info" is added here for convenience. It has a link to the site, as well as some browser information.

How to test the changes in this Pull Request:

  1. Follow the testing outline from Support: add Happychat #466
  2. See that at the beginning of the chat, user info and a [ Newspack customer ] message are prepended.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@adekbadek adekbadek added the [Status] Needs Review The issue or pull request needs to be reviewed label Mar 5, 2020
Copy link
Contributor

@claudiulodro claudiulodro left a comment

Choose a reason for hiding this comment

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

With master branch the chat works, but on this branch I get some sort of infinite loop from the happychat-client library crashing the chat (Uncaught RangeError: Maximum call stack size exceeded).

As best I can tell from going through the stack trace, the Happychat.sendUserInfo call here is triggering the 'availability' event, resulting in an infinite loop. Moving didSendInitialInfo = true; to line 56 (above Happychat.sendUserInfo) solves the issue.

Screen Shot 2020-03-06 at 10 54 19 AM

@claudiulodro claudiulodro added [Status] Needs changes or feedback The issue or pull request needs action from the original creator and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Mar 6, 2020
let didSendInitialInfo;
Happychat.on( 'availability', availability => {
if ( ! didSendInitialInfo && availability ) {
Happychat.sendUserInfo( {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Happychat.sendUserInfo( {
didSendInitialInfo = true;
Happychat.sendUserInfo( {

This change will prevent an infinite loop without otherwise affecting the behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed: f37bc85

@adekbadek adekbadek added [Status] Needs Review The issue or pull request needs to be reviewed and removed [Status] Needs changes or feedback The issue or pull request needs action from the original creator labels Mar 9, 2020
Copy link
Contributor

@claudiulodro claudiulodro left a comment

Choose a reason for hiding this comment

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

Latest version works great!

@claudiulodro claudiulodro added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Mar 9, 2020
@adekbadek adekbadek merged commit 1392452 into master Mar 10, 2020
@adekbadek adekbadek deleted the add/chat-init-message branch March 10, 2020 08:04
matticbot pushed a commit that referenced this pull request Mar 10, 2020
# [1.1.0](v1.0.0...v1.1.0) (2020-03-10)

### Bug Fixes

* fix Site Kit module deactivation ([96787e9](96787e9))
* standardize REST API namespace usage ([44d15b2](44d15b2))

### Features

* **support:** add a link to support docs ([#470](#470)) ([af4754d](af4754d))
* **support:** send initial info on chat start ([#471](#471)) ([1392452](1392452))
* **support:** update subject string for support tickets ([aca9963](aca9963))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released [Status] Approved The pull request has been reviewed and is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants