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

fix(core/react): retrieve agent messages after connection loss and HubtypeService refactor #1360

Merged
merged 9 commits into from
Mar 24, 2021

Conversation

vanbasten17
Copy link
Contributor

@vanbasten17 vanbasten17 commented Mar 12, 2021

Description

  • Solve issue regarding enduser not receiving some agent messages when connection was lost.

Approach

  • Moving onConnectionRegained logic within HubtypeService. Every time the event subcription_succeeded is received, we can asure that the auth call has been done. Hence, onConnectionRegained should be called at that point.
  • Pusher headers are not refreshed automatically, only when HubtypeService.init() is called. So when the state of pusher is connecting we must be sure to update the corresponding headers.

Considerations:

  • The first approach of destroying pusher and then initialize it again in onConnectionRegained breaks the capability of pusher to detect that the application has been reconnected.
  • The process is the following:
    Connecting --> update auth headers --> Connected --> Do auth call --> subscription:suceeded --> call logic when connection is regained

References:

Next steps:

@codecov
Copy link

codecov bot commented Mar 12, 2021

Codecov Report

Merging #1360 (9b6bcf0) into master (4e22f77) will decrease coverage by 0.00%.
The diff coverage is 15.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1360      +/-   ##
==========================================
- Coverage   63.14%   63.13%   -0.01%     
==========================================
  Files         251      251              
  Lines        7076     7083       +7     
  Branches     1186     1186              
==========================================
+ Hits         4468     4472       +4     
- Misses       2266     2270       +4     
+ Partials      342      341       -1     
Flag Coverage Δ
botonic-react 57.50% <30.43%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/botonic-core/src/hubtype-service.js 0.00% <0.00%> (ø)
packages/botonic-react/src/components/message.jsx 36.69% <0.00%> (-1.49%) ⬇️
...ages/botonic-react/src/webchat/messages-reducer.js 68.96% <28.57%> (-12.86%) ⬇️
packages/botonic-react/src/webchat-app.jsx 46.71% <37.50%> (-0.30%) ⬇️
packages/botonic-react/src/webchat/webchat.jsx 47.85% <50.00%> (+0.59%) ⬆️
...plugin-contentful/src/contentful/cms-contentful.ts 88.65% <0.00%> (+1.03%) ⬆️
...lugin-contentful/src/contentful/contents/button.ts 78.84% <0.00%> (+1.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e22f77...9b6bcf0. Read the comment docs.

Copy link
Contributor

@dpinol dpinol left a comment

Choose a reason for hiding this comment

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

can fix the type of WebchatState.lastMessageUpdate in webchat/index.d.ts? now it's undefined

Copy link
Contributor

@asastre asastre left a comment

Choose a reason for hiding this comment

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

👏 👏

packages/botonic-react/src/webchat-app.jsx Outdated Show resolved Hide resolved
packages/botonic-react/src/webchat-app.jsx Outdated Show resolved Hide resolved
@vanbasten17 vanbasten17 changed the title fix(core/reactt): resend agent messages on connection lost fix(core/react): resend agent messages on connection lost Mar 16, 2021
@vanbasten17 vanbasten17 force-pushed the fix/agent-messages-not-received branch from beebafa to 4d56bd6 Compare March 16, 2021 16:30
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

Unit Test Results

  1 files    6 suites   3m 27s ⏱️
30 tests 30 ✔️ 0 💤 0 ❌

Results for commit 4d56bd6.

@vanbasten17 vanbasten17 force-pushed the fix/agent-messages-not-received branch from e07517f to dc58045 Compare March 23, 2021 14:34
Copy link
Contributor

@ericmarcos ericmarcos left a comment

Choose a reason for hiding this comment

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

Nice work!

@vanbasten17 vanbasten17 changed the title fix(core/react): resend agent messages on connection lost fix(core/react): retrieve agent messages after connection loss and HubtypeService refactor Mar 23, 2021
@vanbasten17 vanbasten17 force-pushed the fix/agent-messages-not-received branch from 80c352b to a07d20a Compare March 24, 2021 10:25
Copy link

@marcpdw marcpdw left a comment

Choose a reason for hiding this comment

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

It looks good overall, but have a look to one of my comments to be sure we can't have a potential bug there

packages/botonic-react/src/webchat/webchat.jsx Outdated Show resolved Hide resolved
packages/botonic-react/src/webchat-app.jsx Outdated Show resolved Hide resolved
@vanbasten17 vanbasten17 merged commit ec0c8a1 into master Mar 24, 2021
@vanbasten17 vanbasten17 deleted the fix/agent-messages-not-received branch March 24, 2021 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants