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

Remove appUserId from storage if the user has a userId #591

Merged
merged 2 commits into from Aug 16, 2017

Conversation

lemieux
Copy link
Member

@lemieux lemieux commented Aug 16, 2017

Pretty much what the title and the comment in the code say.

@lemieux
Copy link
Member Author

lemieux commented Aug 16, 2017

I'm adding tests for handleUserConversationResponse

@lemieux lemieux merged commit 54b8c17 into f/compat-expansion Aug 16, 2017
@lemieux lemieux deleted the f/clean-up-storage-login branch August 16, 2017 19:37
lemieux added a commit that referenced this pull request Aug 29, 2017
* Remove appUserId from storage if the user has a userId

* Add tests for handleUserConversationResponse
lemieux added a commit that referenced this pull request Sep 5, 2017
* Remove appUserId from storage if the user has a userId

* Add tests for handleUserConversationResponse
lemieux added a commit that referenced this pull request Sep 18, 2017
* Remove appUserId from storage if the user has a userId

* Add tests for handleUserConversationResponse
lemieux added a commit that referenced this pull request Sep 18, 2017
* Render widget in iframe - button version

* Upgrade to webpack 2

* Split codebase in two parts

* Bridge host and iframe

* Rename iframe to just frame

* Fix widget sizing

* Try to make media queries work

* Refactor frame lib to not use a class

* Nail responsiveness inside iframe with enquire.js

* Fix opening/closing animations

* Fix close animations

* Remove commented instructions

* Iframe - tab & embedded (#539)

* Move link generation to host page

* Move embedded to widget state

* Implement tab version

* Make embedded mode work again

* Clean up lib properly on destroy

* New build process (#540)

* Update babel configs

* Make build configs

* Update build setup for npm

* Clean up unnecessary steps in release process

* Fix package.json indentation

* Rewrite some logic in webpack config builder

* Update fileloader limit

* Replace options.npmRelease

* Vendor in react-stripe-checkout (#541)

* Basic code splitting & optimization pass (#542)

* Split up css and js for frame part

* Clean up dependencies, do a light pass of code splitting in obvious places

* Revert webpack code splitting

* Improve tree shaking with webpack

* Add Sentry support (#543)

* Add Raven to frame lib

* Add sentry to deployment

* Fix DSN variable in webpack, set raven context on login

* Bring back the tests (#544)

* Update test paths, upgrade karma-webpack

* Update dependencies for React 15.5

* Update dependencies, use babel-rewrite for dep injection, fix smooch.jsx test suite

* Fix dependency injection in test - part 2

* Make test run again - part 3

* Fix conversation service tests

* Fix ReplyActions tests

* Fix smooch.jsx test, again

* Fix action tests, again

* Fix tests for user service

* Fix Stripe service tests

* Fix integrations service tests

* Fix tests for faye service

* Fix tests for header component

* Fix Email setting component tests

* Fix ChatInput tests

* Fix ConnectNotification tests g

* Fix dom utils tests

* Fix tests for phantomjs

* Update sinon, clean up deps

* Make utils for thunk stubs

* Test on Chrome on circle

* Not use built ins in dev

* Add script loader (#545)

* Make dev setup work with script loader

* Fix loader lib substitution

* Update dev server to allow serving minified version of the loader

* Fix indentation in html files

* Remove useless dependencies

* Format file correctly

* Format file correctly

* Deployment updates (#546)

* Replace grunt-s3 with direct awscli calls

* Add render method on the script loader

* Add babel-eslint to dev deps

* Update some build dependencies and clean up grunt (#557)

* Update some build dependencies and clean up grunt

* Add .env file to gitignore

* Fix release steps

* Remove flags from webpack commands

* Fix channel and settings page closing issue (#559)

* Fix sourcemap generation (#558)

* Fix channel page sizing (#560)

* Fix iframe sizing in embedded mode (#561)

* Remove deprecated email capture feature (#562)

* Remove email capture feature

* Fix tests

* Remove unused style

* Remove more text keys from reducer

* Fix image upload animation (#563)

* Remove url from badge filter id (#564)

* Remove url from badge filter id

* Fix tests

* Fix box-shadow and responsiveness handling in FF (#565)

* Fix jumpy input on ios (#566)

* Fix loader for IE10

* Fix rounded corners (#567)

* Remove all redundant suffixes from filenames (#569)

* Use default exports and capitalize filenames (#570)

* Remove track API (#568)

* Remove track API

* Removing missing references

* Merge services with actions (#571)

* First pass at moving services to actions

* Fix tests

* Fix app state actions references

* First pass at Web SDK refactoring (#572)

* First pass at moving services to actions

* Refactor config storage - wip

* Refactor init, move config to own reducer

* Move http to actions and leverage config values

* Implement startConversation - wip

* Handle conversationStarted flow

* Fix init tests

* Skip bad tests in smooch spec

* Fix sendMessage test suite

* Fix uploadImage test suite

* Fix sendLocation test suite

* Fix postPostback test suite

* Fix getMessages test suite

* Fix handleConnectNotification test suite

* Fix connectFayeConversation test suite

* Fix connectFayeUser

* Fix disconnectFaye test suite

* Fix resendMessage test suite

* Finish conversation actions clean up

* Fix AppState actions test suite

* Fix faye test suite

* Fix integration test suite

* Fix stipe test suite

* Fix user actions test suite

* Fix auth actions test suite

* Fix chat input test suite

* Fix Action component test suite

* Fix conversation component test suite

* Fix header component test suite

* Skip introduction component as data is missing

* Fix Messenger button component

* Fix ReplyAction test suite

* Fix Widget compoenent test suite

* Fix Channel test suite

* Fix AuthReducer test suite

* Fix Conversation Reducer test suite

* Fix app utils test suite

* Fix storage test suite

* Fix user utils test suite

* Fix rebase issues

* Add http tests

* Login flow refactor (#573)

* Implement first part of login flow

* Wipe session token on successful login

* Rename device to client

* Send client info on login

* Fix tests

* Fetch anonymous user + conversation flow (#574)

* Add tests to cover fetch convo and user from init

* Add test for fetchUserConversation

* Update test deps.

* Stub http

* Return promise in test

* Remove unused deepFreeze func

* Send message refactor (#576)

* Fix send message endpoint

* Persist appUserId and sessionToken

* Fix connect notification test

* Adjust send message payload

* Skip faye tests, fix postback test expectations

* Add default http headers

* Set messages from http responseg (#578)

* Port calls to API from Smooch Core (#577)

* Port smooch-core calls to new endpoints

* Fix integration actions tests

* Fix Stripe tests

* Remove smooch-core from package.json

* Fix config base url

* Code review

* Fix bad use of deconstruction

* Refactor Faye for new event format and channel (#581)

* Refactor how faye connects with the server

* Fix faye tests

* Add faye message event handling for new format

* Add handling for conversation activity

* Stripe Refactor (#582)

* Use app name and icon from Stripe, remove esformatter-semicolons

* Fix tests

* Remove unused action

* Remove test

* Kill unused prop

* Remove unused import

* Handle linking events where current user is the survivor (#583)

* Obey app status from config

* Fix components to use new store structure

* Fix tests

* Add back Twilio and MessageBird linking (#584)

1. Updated the format of the `POST /clients` call to include all
   required props
2. Fix handling of link errors to correctly use the returned error
3. Fix handling of link cancellations - apparently `batchActions`
   doesn't play nice with async actions
4. Change ping and unlink calls to use `clients.id` instead of
   `clients._id`
5. Fix fresh user creation - there is no messages array returned, but
   we were expecting it to exist.

* Respect user profile config returned by the server (#587)

1. Use `config.profile.uploadInterval` instead of hardcoded value for
   user props throttling
2. Do not upload user props if `config.profile.enabled` is false
3. Wait to upload user props if the user has not been created yet
4. Fix `isDirty` check being dirty too often
5. Upload any pending user props after a user is created
6. Fix `update` tests to mock `setTimeout` instead of relying on
   broken sinon timers

* Handle link event when the appUser _id changes (#585)

When a link completes, it's possible for an appUser's `_id` to change.
The SDK should be aware of this and be able to recover from such a
change. I've added two new pieces of logic:

1. When a `link` event comes through faye and the user _id changes,
   we change internal state to point to the new user, and
   re-initialize (via login if the user has a `userId`, or via a user
   fetch if the user is using a `sessionToken`)
2. When initializing the SDK with an anonymous user, if the server
   returns an `invalid_auth` error (e.g. if the stored appUserId or
   sessionToken are invalid), we clear any local state and allow
   execution to continue with a new anonymous user. This covers the
   case where an anonymous user has been merged out of existence via
   linking.

* Add proper handling of switch user flows (#586)

1. Fixed handling of `login` response, and clean up some state that
   was incorrectly preserved between users. Also fixed `login`
   incorrectly clearing the `jwt` after a successful call
2. Added full implementation of `logout`
3. Fix `startConversation` when a `userId` and `jwt` are supplied in
   `init`
4. Fix settings page when the user has not been created yet

* Enable channel linking for users that have not started a convo (#588)

Users that have not been created yet on the server should still be
allowed to link channels. This change forces user creation when a
linking action is initiated. Linking actions include generating a
transfer request, requesting a QR code for WeChat or Viber, or calling
the `POST /clients` to start SMS linking.

If a user has already been created, but the faye connection does not
exist for some reason, we instead force a connection to faye when a
linking action is initiated.

This change also modifies a few views that were refusing to render
themselves when the smooch user id did not exist, to make them
compatible with a non-existing user.

* Fix link events with user switching (#589)

While addressing code review comments from #585 and #587 I realized
that link events were handled incorrectly when the user changed. The
`login` event now expects a `userId` and `jwt` as params, which we
weren't passing. Also, we were still connected to the the faye channel
for the old discarded user.

* Fix handling server response when creating convo for pre-created user (#590)

* Remove appUserId from storage if the user has a userId (#591)

* Remove appUserId from storage if the user has a userId

* Add tests for handleUserConversationResponse

* Add support for vendor id (#592)

* Add vendor id to webpack config and use it in the http action

* Fix tests

* Use promise rejections instead of throwing (#593)

* Use promise rejections instead of throwing

* Return promises in test

* Make source code more generic (#594)

* Make source code more generic

* Remove sk- prefixes everywhere

* Add task to generate customized loader

* Use vendorId variable in banner

* Allowed passing license info to build

* Unmount widget on destroy (#596)

* Fix image upload (#597)

* Use smoochAddress instead of genericAddress

* Add sender to image payload, extract metadata only with it

* Fix PR comments

* Make fake promises chainable (#595)

* Make fake promises chainable

* Rethrow init error

* Fix tests

* Change assertion of failed promises

* Fix tests

* Revert change of logic, fix test assertion

* Throw error if missing parameter (#599)

* Include appUserId in call to login API (#600)

* Throw error if app is inactive (#598)

* Throw error if app is inactive

* Add an isInitialized guard for public methodsg

* Fix copy paste error

* Add upgrade flow for non-enterprise sdk users (#601)

Added logic to upgrade non-enterprise sdk users into enterprise sdk
users by calling the upgrade user endpoint. To detect if an upgrade is
necessary, we check for a legacy client id stored in the browser
storage. If an id is found, we call the upgrade endpoint to
retrieve the user.

If the call is successful, we use the returned appUserId and
sessionToken to continue the initialization flow. If the call is
unsuccessful, we continue as a new anonymous user. In either case, the
clientId is moved out of legacy storage and into the new storage,
meaning this API will not be called again the next time the page is
loaded.

* Fix image upload progress spinner (#602)

`sk` stands for SpinKit!

* Branding changes (#603)

* Add utilities for branding

* Make version configurable at build time

* Make isBranded more explicit

* Allow version to be passed in the options

* Removed unused config variable in webpack config

* Use urljoin to build urls (#607)

* Remove mentions of AMD and bower (#608)

* Update path for create conversation endpoint (#610)

* Recover from more errors when appUserId or sessionToken is invalid (#611)

* Update README to reflect new behavior (#612)

* Fix loader generation task, update readme

* Fix loader generation task, update readme

* Remove unnecessary props in init docs

* Fix undispatched resetUnreadCount actions (#613)

* Replace smooch-js with smooch-web (#616)

* Update release notes for 4.0.0 (#615)

* Update release notes for 4.0.0

* Some polish to release notes

* Add before/after to init section

* Update post-review

* update intro, remove the from

* Code review edits

* Backticks back (alright!)

* Fix message spacing for appMakers (#618)

* Add `dsbo` to matching cases (#620)

* Enable easy custom builds for forkers (#619)
lemieux added a commit that referenced this pull request Sep 18, 2017
* Render widget in iframe - button version

* Upgrade to webpack 2

* Split codebase in two parts

* Bridge host and iframe

* Rename iframe to just frame

* Fix widget sizing

* Try to make media queries work

* Refactor frame lib to not use a class

* Nail responsiveness inside iframe with enquire.js

* Fix opening/closing animations

* Fix close animations

* Remove commented instructions

* Iframe - tab & embedded (#539)

* Move link generation to host page

* Move embedded to widget state

* Implement tab version

* Make embedded mode work again

* Clean up lib properly on destroy

* New build process (#540)

* Update babel configs

* Make build configs

* Update build setup for npm

* Clean up unnecessary steps in release process

* Fix package.json indentation

* Rewrite some logic in webpack config builder

* Update fileloader limit

* Replace options.npmRelease

* Vendor in react-stripe-checkout (#541)

* Basic code splitting & optimization pass (#542)

* Split up css and js for frame part

* Clean up dependencies, do a light pass of code splitting in obvious places

* Revert webpack code splitting

* Improve tree shaking with webpack

* Add Sentry support (#543)

* Add Raven to frame lib

* Add sentry to deployment

* Fix DSN variable in webpack, set raven context on login

* Bring back the tests (#544)

* Update test paths, upgrade karma-webpack

* Update dependencies for React 15.5

* Update dependencies, use babel-rewrite for dep injection, fix smooch.jsx test suite

* Fix dependency injection in test - part 2

* Make test run again - part 3

* Fix conversation service tests

* Fix ReplyActions tests

* Fix smooch.jsx test, again

* Fix action tests, again

* Fix tests for user service

* Fix Stripe service tests

* Fix integrations service tests

* Fix tests for faye service

* Fix tests for header component

* Fix Email setting component tests

* Fix ChatInput tests

* Fix ConnectNotification tests g

* Fix dom utils tests

* Fix tests for phantomjs

* Update sinon, clean up deps

* Make utils for thunk stubs

* Test on Chrome on circle

* Not use built ins in dev

* Add script loader (#545)

* Make dev setup work with script loader

* Fix loader lib substitution

* Update dev server to allow serving minified version of the loader

* Fix indentation in html files

* Remove useless dependencies

* Format file correctly

* Format file correctly

* Deployment updates (#546)

* Replace grunt-s3 with direct awscli calls

* Add render method on the script loader

* Add babel-eslint to dev deps

* Update some build dependencies and clean up grunt (#557)

* Update some build dependencies and clean up grunt

* Add .env file to gitignore

* Fix release steps

* Remove flags from webpack commands

* Fix channel and settings page closing issue (#559)

* Fix sourcemap generation (#558)

* Fix channel page sizing (#560)

* Fix iframe sizing in embedded mode (#561)

* Remove deprecated email capture feature (#562)

* Remove email capture feature

* Fix tests

* Remove unused style

* Remove more text keys from reducer

* Fix image upload animation (#563)

* Remove url from badge filter id (#564)

* Remove url from badge filter id

* Fix tests

* Fix box-shadow and responsiveness handling in FF (#565)

* Fix jumpy input on ios (#566)

* Fix loader for IE10

* Fix rounded corners (#567)

* Remove all redundant suffixes from filenames (#569)

* Use default exports and capitalize filenames (#570)

* Remove track API (#568)

* Remove track API

* Removing missing references

* Merge services with actions (#571)

* First pass at moving services to actions

* Fix tests

* Fix app state actions references

* First pass at Web SDK refactoring (#572)

* First pass at moving services to actions

* Refactor config storage - wip

* Refactor init, move config to own reducer

* Move http to actions and leverage config values

* Implement startConversation - wip

* Handle conversationStarted flow

* Fix init tests

* Skip bad tests in smooch spec

* Fix sendMessage test suite

* Fix uploadImage test suite

* Fix sendLocation test suite

* Fix postPostback test suite

* Fix getMessages test suite

* Fix handleConnectNotification test suite

* Fix connectFayeConversation test suite

* Fix connectFayeUser

* Fix disconnectFaye test suite

* Fix resendMessage test suite

* Finish conversation actions clean up

* Fix AppState actions test suite

* Fix faye test suite

* Fix integration test suite

* Fix stipe test suite

* Fix user actions test suite

* Fix auth actions test suite

* Fix chat input test suite

* Fix Action component test suite

* Fix conversation component test suite

* Fix header component test suite

* Skip introduction component as data is missing

* Fix Messenger button component

* Fix ReplyAction test suite

* Fix Widget compoenent test suite

* Fix Channel test suite

* Fix AuthReducer test suite

* Fix Conversation Reducer test suite

* Fix app utils test suite

* Fix storage test suite

* Fix user utils test suite

* Fix rebase issues

* Add http tests

* Login flow refactor (#573)

* Implement first part of login flow

* Wipe session token on successful login

* Rename device to client

* Send client info on login

* Fix tests

* Fetch anonymous user + conversation flow (#574)

* Add tests to cover fetch convo and user from init

* Add test for fetchUserConversation

* Update test deps.

* Stub http

* Return promise in test

* Remove unused deepFreeze func

* Send message refactor (#576)

* Fix send message endpoint

* Persist appUserId and sessionToken

* Fix connect notification test

* Adjust send message payload

* Skip faye tests, fix postback test expectations

* Add default http headers

* Set messages from http responseg (#578)

* Port calls to API from Smooch Core (#577)

* Port smooch-core calls to new endpoints

* Fix integration actions tests

* Fix Stripe tests

* Remove smooch-core from package.json

* Fix config base url

* Code review

* Fix bad use of deconstruction

* Refactor Faye for new event format and channel (#581)

* Refactor how faye connects with the server

* Fix faye tests

* Add faye message event handling for new format

* Add handling for conversation activity

* Stripe Refactor (#582)

* Use app name and icon from Stripe, remove esformatter-semicolons

* Fix tests

* Remove unused action

* Remove test

* Kill unused prop

* Remove unused import

* Handle linking events where current user is the survivor (#583)

* Obey app status from config

* Fix components to use new store structure

* Fix tests

* Add back Twilio and MessageBird linking (#584)

1. Updated the format of the `POST /clients` call to include all
   required props
2. Fix handling of link errors to correctly use the returned error
3. Fix handling of link cancellations - apparently `batchActions`
   doesn't play nice with async actions
4. Change ping and unlink calls to use `clients.id` instead of
   `clients._id`
5. Fix fresh user creation - there is no messages array returned, but
   we were expecting it to exist.

* Respect user profile config returned by the server (#587)

1. Use `config.profile.uploadInterval` instead of hardcoded value for
   user props throttling
2. Do not upload user props if `config.profile.enabled` is false
3. Wait to upload user props if the user has not been created yet
4. Fix `isDirty` check being dirty too often
5. Upload any pending user props after a user is created
6. Fix `update` tests to mock `setTimeout` instead of relying on
   broken sinon timers

* Handle link event when the appUser _id changes (#585)

When a link completes, it's possible for an appUser's `_id` to change.
The SDK should be aware of this and be able to recover from such a
change. I've added two new pieces of logic:

1. When a `link` event comes through faye and the user _id changes,
   we change internal state to point to the new user, and
   re-initialize (via login if the user has a `userId`, or via a user
   fetch if the user is using a `sessionToken`)
2. When initializing the SDK with an anonymous user, if the server
   returns an `invalid_auth` error (e.g. if the stored appUserId or
   sessionToken are invalid), we clear any local state and allow
   execution to continue with a new anonymous user. This covers the
   case where an anonymous user has been merged out of existence via
   linking.

* Add proper handling of switch user flows (#586)

1. Fixed handling of `login` response, and clean up some state that
   was incorrectly preserved between users. Also fixed `login`
   incorrectly clearing the `jwt` after a successful call
2. Added full implementation of `logout`
3. Fix `startConversation` when a `userId` and `jwt` are supplied in
   `init`
4. Fix settings page when the user has not been created yet

* Enable channel linking for users that have not started a convo (#588)

Users that have not been created yet on the server should still be
allowed to link channels. This change forces user creation when a
linking action is initiated. Linking actions include generating a
transfer request, requesting a QR code for WeChat or Viber, or calling
the `POST /clients` to start SMS linking.

If a user has already been created, but the faye connection does not
exist for some reason, we instead force a connection to faye when a
linking action is initiated.

This change also modifies a few views that were refusing to render
themselves when the smooch user id did not exist, to make them
compatible with a non-existing user.

* Fix link events with user switching (#589)

While addressing code review comments from #585 and #587 I realized
that link events were handled incorrectly when the user changed. The
`login` event now expects a `userId` and `jwt` as params, which we
weren't passing. Also, we were still connected to the the faye channel
for the old discarded user.

* Fix handling server response when creating convo for pre-created user (#590)

* Remove appUserId from storage if the user has a userId (#591)

* Remove appUserId from storage if the user has a userId

* Add tests for handleUserConversationResponse

* Add support for vendor id (#592)

* Add vendor id to webpack config and use it in the http action

* Fix tests

* Use promise rejections instead of throwing (#593)

* Use promise rejections instead of throwing

* Return promises in test

* Make source code more generic (#594)

* Make source code more generic

* Remove sk- prefixes everywhere

* Add task to generate customized loader

* Use vendorId variable in banner

* Allowed passing license info to build

* Unmount widget on destroy (#596)

* Fix image upload (#597)

* Use smoochAddress instead of genericAddress

* Add sender to image payload, extract metadata only with it

* Fix PR comments

* Make fake promises chainable (#595)

* Make fake promises chainable

* Rethrow init error

* Fix tests

* Change assertion of failed promises

* Fix tests

* Revert change of logic, fix test assertion

* Throw error if missing parameter (#599)

* Include appUserId in call to login API (#600)

* Throw error if app is inactive (#598)

* Throw error if app is inactive

* Add an isInitialized guard for public methodsg

* Fix copy paste error

* Add upgrade flow for non-enterprise sdk users (#601)

Added logic to upgrade non-enterprise sdk users into enterprise sdk
users by calling the upgrade user endpoint. To detect if an upgrade is
necessary, we check for a legacy client id stored in the browser
storage. If an id is found, we call the upgrade endpoint to
retrieve the user.

If the call is successful, we use the returned appUserId and
sessionToken to continue the initialization flow. If the call is
unsuccessful, we continue as a new anonymous user. In either case, the
clientId is moved out of legacy storage and into the new storage,
meaning this API will not be called again the next time the page is
loaded.

* Fix image upload progress spinner (#602)

`sk` stands for SpinKit!

* Branding changes (#603)

* Add utilities for branding

* Make version configurable at build time

* Make isBranded more explicit

* Allow version to be passed in the options

* Removed unused config variable in webpack config

* Use urljoin to build urls (#607)

* Remove mentions of AMD and bower (#608)

* Update path for create conversation endpoint (#610)

* Recover from more errors when appUserId or sessionToken is invalid (#611)

* Update README to reflect new behavior (#612)

* Fix loader generation task, update readme

* Fix loader generation task, update readme

* Remove unnecessary props in init docs

* Fix undispatched resetUnreadCount actions (#613)

* Replace smooch-js with smooch-web (#616)

* Update release notes for 4.0.0 (#615)

* Update release notes for 4.0.0

* Some polish to release notes

* Add before/after to init section

* Update post-review

* update intro, remove the from

* Code review edits

* Backticks back (alright!)

* Fix message spacing for appMakers (#618)

* Add `dsbo` to matching cases (#620)

* Enable easy custom builds for forkers (#619)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants