GithubHelp home page GithubHelp logo

segment-integrations / analytics.js-integration-intercom Goto Github PK

View Code? Open in Web Editor NEW
7.0 22.0 13.0 31 KB

The Intercom analytics.js integration.

Home Page: https://segment.com/docs/integrations/intercom/

License: MIT License

Makefile 5.63% JavaScript 94.37%
migrated javascript analyticsjs

analytics.js-integration-intercom's Introduction

analytics.js-integration-intercom's People

Contributors

anoonan avatar hankim813 avatar ndhoule avatar peripheral1994 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

analytics.js-integration-intercom's Issues

Type-check the type of traits before formatting it

Moved from here - segment-boneyard/integration-intercom#12

We've seen a nasty bug where somehow our traits was not a JS object, but some HTML string. This was coming from our API endpoint that at one point—due to a bug—returned some HTML and we passed it through as the traits.

***This repo below is wrong as it's server-side.
This led to the following block of code being executed: https://github.com/segmentio/integration-intercom/blob/b522c0c5a4d7bed8c12c340c913402c790e83ce2/lib/index.js#L126-L140

Since traits here isn't type-checked, the string was iterated over as a list of chars, leading to the "formatted" result objects that looked like this:

{
  "0": "<",
  "1": "h",
  "2": "t",
  "3": "m",
  "4": "l",
  "5": ">",
  ...
}

Since this is a perfectly valid object, Intercom happily accepted it. The resulting object had almost 12K keys like this, and it crippled our Intercom dashboard (all users now has to load over 12,000 properties).

This could have been prevented by adding a type check to the input param here to be an object. I'm not sure if this is a more generic problem, or only exists in the Intercom integration.

Synthetic page views in SPA not recorded to Intercom

I have a single-page app, using react-router-redux. In all cases -- both physical and synthetic page loads -- I see requests fired to Segment and to Intercom, as I expect. However, for synthetic page loads, Intercom never seems to notice that the page view happened.

I've got snapshots via Safari's export as cURL for the network requests for both a physical pageview that did get recorded in Intercom, and a synthetic one that did not -- both being for the same URL. I'm a bit hesitant to paste them in since I don't know which magic values are sensitive in them and which are not.

Uncaught TypeError: Cannot read property 'id' of undefined

Getting tons of these errors. Also getting an error where it says cannot call appendChild of undefined and its trying to append to document.body before there ever is one.

I think it might be related to how soon the intercom JS is done loading. We might not see that issue for a week and then yesterday we got about three thousand of these.

There also seems to be a retry mechanism since the error can be fired 20 times/s.

Uncaught TypeError: Cannot read property 'id' of undefined
TypeError: Cannot read property 'id' of undefined
File https://js.intercomcdn.com/frame.f3ce5bab.js line 1 col 24183 in p
File https://js.intercomcdn.com/frame.f3ce5bab.js line 5 col 18572 in c
File https://js.intercomcdn.com/frame.f3ce5bab.js line 5 col 18873 in [anonymous]
File "(native)" line (unknown) in Array.map
File https://js.intercomcdn.com/frame.f3ce5bab.js line 5 col 18850 in [anonymous]
File https://js.intercomcdn.com/frame.f3ce5bab.js line 2 col 20257 in [anonymous]
File https://js.intercomcdn.com/frame.f3ce5bab.js line 2 col 19693 in [anonymous]
File https://js.intercomcdn.com/frame.f3ce5bab.js line 2 col 20462 in p
File https://js.intercomcdn.com/frame.f3ce5bab.js line 2 col 20421 in [anonymous]
File "(native)" line (unknown) in Array.map
File https://js.intercomcdn.com/frame.f3ce5bab.js line 2 col 20396 in p
File https://js.intercomcdn.com/frame.f3ce5bab.js line 17 col 27697 in Array.<anonymous>
File https://js.intercomcdn.com/frame.f3ce5bab.js line 9 col 18346 in l
File https://js.intercomcdn.com/frame.f3ce5bab.js line 17 col 25815 in [anonymous]
File https://js.intercomcdn.com/frame.f3ce5bab.js line 17 col 18338 in [anonymous]
File https://js.intercomcdn.com/frame.f3ce5bab.js line 17 col 25139 in [anonymous]
File https://js.intercomcdn.com/frame.f3ce5bab.js line 17 col 16825 in [anonymous]
File https://js.intercomcdn.com/frame.f3ce5bab.js line 17 col 24782 in [anonymous]
File https://js.intercomcdn.com/frame.f3ce5bab.js line 30 col 3767 in [anonymous]
File https://js.intercomcdn.com/frame.f3ce5bab.js line 5 col 14919 in onUserPresent
File https://js.intercomcdn.com/frame.f3ce5bab.js line 17 col 28650 in HTMLDocument.l
HTMLDocument.e._wrapped

Lead support

In our business, we are strongly using Intercom Leads, as we are using Intercom as CRM and storing in some information about the lead experience on our funnel.

But by migrating into Segment, we are loosing this possibility, as segment only allowing to use analytics.identify on Intercom users.

Any plan for supporting Intercom Leads ?

Intercom.io - "can't have more than 120 active events" error

I have several other Segment integrations that are sending more than 120 active events (Mixpanel being one of them). I just turned on the Intercom.io integration yesterday, and I'm getting the following error message in the response on our production app:

{"error_message":"Cannot have more than 120 active event names"}

Request URL:https://api-iam.intercom.io/vjs/users/events
Request Method:POST
Status Code:422 Unprocessable Entity
Remote Address:52.22.140.54:443

This is a lot of noise, and not something I'd like to see showing up on our live app. I'm stuck here, because I can't reduce the number of active events that we're tracking with other Segment integrations. Is there a way to turn off the noise, or at least selectively choose which events that are sent to Intercom.io?

Explicit setting of integrations prevents sending of `user_hash`.

We a have a code that dynamically turns on or off Intercom integration depending on the user.

We hit a condition when it should send it to Intercom but it doesn't. It does try to send it but it's missing the user_hash.

        analytics.identify('id', { ... }, {
          Intercom: { user_hash: 'x' },
          integrations: {
            All: true,
            ...,
            Intercom: true
          }
        });

Removing the explicit setting fixed it.

        analytics.identify('id', { ... }, {
          Intercom: { user_hash: 'x' },
          integrations: {
            All: true,
            ...
          }
        });

However that just a work around and it makes the backend code a bit more complicated now that it has to decide to include the Intercom key rather than just setting the value to either true or false.

It's also setting a trap for developers expecting it to just work.

Cannot read property 'indexOf' of undefined

I'm starting to experience a new error that i haven't seen before. As the Intercom source is minified, it's quite hard to backtrace, but here's my best bet.

It seems to happen when click the launch button (bottom-right), so it shouldn't be related to identify or track calls. Looking at the code in question, it looks like it's trying to read the Intercom app name and/or some settings related to that and perform an indexOf on that.

Here's my best bet at descrambling:

// Line 5:21844
{snip} [t]:void 0},e)}function o(e){var t=i(e,"app.name");return t.indexOf(/team/gi)<0&&A.isLocaleEnglish()?t+" Team":t}function r(e){return T.isEn {snip}
TypeError: Cannot read property 'indexOf' of undefined
  at o(/intercom.dd959f00.js:5:21844)
  at Object.get(/intercom.dd959f00.js:5:24004)
  at render(/intercom.dd959f00.js:14:18902)
  at renderLoading(/intercom.dd959f00.js:10:5108)
  at .renderLoading(/intercom.dd959f00.js:1:9784)
  at showLoading(/intercom.dd959f00.js:10:5591)
  at showLoading(/intercom.dd959f00.js:9:27444)
  at fetchConversations(/intercom.dd959f00.js:9:28909)
  at .fetchConversations(/intercom.dd959f00.js:1:9784)
  at show(/intercom.dd959f00.js:9:26304)
  at a.<anonymous>(/intercom.dd959f00.js:8:17177)
  at a.<anonymous>(/intercom.dd959f00.js:8:19880)
  at Object.<anonymous>(/intercom.dd959f00.js:3:8562)
  at m(/intercom.dd959f00.js:3:7182)
  at Object.add [as done](/intercom.dd959f00.js:3:7493)
  at Array.<anonymous>(/intercom.dd959f00.js:3:8539)
  at Function.each(/intercom.dd959f00.js:2:15557)
  at Object.<anonymous>(/intercom.dd959f00.js:3:8479)
  at Function.Deferred(/intercom.dd959f00.js:3:9069)
  at Object.then(/intercom.dd959f00.js:3:8455)
  at a.whenReady(/intercom.dd959f00.js:8:19770)
  at a.showWhenReady(/intercom.dd959f00.js:8:19823)
  at a.show(/intercom.dd959f00.js:8:17029)
  at a.onLauncherClicked(/intercom.dd959f00.js:8:19999)
  at u(/intercom.dd959f00.js:5:4489)
  at Object.trigger(/intercom.dd959f00.js:5:3807)
  at onClicked(/intercom.dd959f00.js:14:27621)
  at HTMLDivElement.dispatch(/intercom.dd959f00.js:3:18962)
  at HTMLDivElement.g.handle(/intercom.dd959f00.js:3:15637)
  at apply(raven.js:329:28)

I have no clue whether this is a Segment-specific issue or Intercom, but I couldn't find an issue tracker for Intercom's JS lib so I'm posting here first.

migrate intercom inbox activator

From @reinpk on May 7, 2014 21:34

from our side we have two different settings:

  • inbox (boolean, whether to show the inbox)
  • activator (string, custom css selector to use for the inbox)

Then Intercom added a UI checkbox to control whether the inbox shows. But! If an activator is passed, they’ll show it regardless of what their UI checkbox is set to.

So from the “right” way to do things, realistically their UI should just be the final decision on whether to show the inbox or not. But I guess they may have backwards compatibility issues with that, which is why they don’t do it?

From our side, we had been defaulting people to have the default activator of #IntercomDefaultWidget but that means that even if people turn off the inbox setting in Intercom, it will still be on cuz we’re sending an activator. So, if we want to fix it it will require a migration:

  1. Set the new default for the activator to empty string.
  2. Everyone with Intercom inbox off, and activator is #IntercomDefaultWidget replace the activator with empty string.
  3. Remove the Intercom inbox setting.

What we want to end up with in the end is that we don’t control the default inbox being on at all, we just let people use a custom activator if they want (which will turn the inbox on).

cc @yields @ianstormtaylor

Copied from original issue: segmentio/analytics.js-integrations#138

Single page app login/logout

From segment-boneyard/integration-intercom#6

I'm using segment with intercom on a single page app that allows the user to login/logout without refreshing the page. It doesn't look like this use case was thought through though (or I'm using things incorrectly).

When I call window.analytics.user().reset() to clear the user data for a logout, the standard intercom shutdown method (window.Intercom('shutdown')) isn't called. I've worked around this by intentionally invoking the shutdown method.

However, that's created a bug with logging back in where calling analytics.identify(...) doesn't invoke window.Intercom('boot', ...). I can't as easily manually call this because I don't know where the intercom key is.

Would y'all take a look at supporting this use case?

Intercom JS widget loaded prematurely

I'm an engineer at a Segment/Intercom client and we were receiving customer reports that the Intercom window wasn't opening from time to time. As background, we include the Segment script in <head> as recommended and have installed the Intercom integration.

As I was able to reproduce the issue sporadically, I tracked it down to the Intercom widget initializing when document.body was not available. With the above installation setup, this does not guarantee that body will be available by the time the Intercom integration loads, as required.

As Intercom advises, one way to solve the problem would be to include the Intercom script tag in <body>, rather than <head> which is what we see this integration doing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.