Intercom integration for Analytics.js.
Released under the MIT license.
The Intercom analytics.js integration.
Home Page: https://segment.com/docs/integrations/intercom/
License: MIT License
Intercom integration for Analytics.js.
Released under the MIT license.
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.
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?
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?
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.
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 ?
From @sperand-io on September 29, 2014 20:3
Hey y'all. Great job on the server-side intercom fixes!
Noticed that over there you're using a monthlySpend
trait to populate revenue -- can we add that on client side tracking as well so that we have parity before adding that to docs?
cc/ @amillet89 @harrietgrace @DirtyAnalytics
Copied from original issue: segmentio/analytics.js-integrations#422
There are two Intercom settings, app_id and language_override. The latter is missing in this integration.
From @ianstormtaylor on June 11, 2014 23:13
Server-side we do this so that Intercom users can see nicely formatted dates, since Intercom doesn't recognize them automatically from the JSON sent. So we should change the client-side integration to do this as well.
We'll need to make it backwards compatible with the old traits as well.
Copied from original issue: segmentio/analytics.js-integrations#209
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.
The server side integration send custom traits on identify, clientside should as well.
https://github.com/segmentio/integration-intercom/blob/master/lib/mapper.js#L26
From @reinpk on May 7, 2014 21:34
from our side we have two different settings:
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:
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).
Copied from original issue: segmentio/analytics.js-integrations#138
See segmentio/analytics.js-integrations#526 for details.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.