segmentio/analytics.js-integrations — pull request #392 by ianstormtaylor (2014-08-22 23:25:02+00:00)
Title: fix olark phantom track/page calls

Long story short:

We were checking if the box was open, but there was a slight edge-case where the user had decided to open the box, but hadn't explicitly started a conversation with the operator. If they did that and then trigger an event or page view while the box was open, you'd get a phantom chat appear on the operator's side. At least that's my best guess.

Now we're using the Olark API to check whether the user `isConversing` every time. We also keep the "opened" check too because Olark doesn't actually swap `isConversing` to false when they're done, so if we didn't we'd end up keeping the conversations going forever until the user stopped sending any events or pages.

Also edited the tests so that they are a bit more fullproof, and updated the spy.

cc @lancejpollard @calvinfo