segment-integrations / analytics.js-integration-intercom

The Intercom analytics.js integration.
https://segment.com/docs/integrations/intercom/
MIT License
7 stars 12 forks source link

Uncaught TypeError: Cannot read property 'id' of undefined #24

Closed hakunin closed 7 years ago

hakunin commented 7 years ago

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
hankim813 commented 7 years ago

hi @hakunin, could you share what segment calls you are making to induce this error? Is this happening from just enabling Intercom and loading Segment on your website?

hakunin commented 7 years ago

We don't know, I can't reproduce it, but it "randomly" happens. Looking at the stack trace it seems like this is just from the inclusion of the script since there is nothing initiating it.

hankim813 commented 7 years ago

@hakunin hmm without a reproducible case, I'll close this issue. However, could you submit a ticket via https://segment.com/contact/requests/

I think this is better with our Success team; they should be able to help you debug as this might be happening for any number of reasons. This also looks like it's coming from the actual Intercom library so if it indeed was a reproducible bug, it'd have to be fixed by Intercom so might be better to open an issue in their repo as well

badogar commented 7 years ago

@hankim813 I am having exact same issue... Sales team pushed some manual notification from the Intercom and its causing js crash and then a lot of js based functionalities on my site have stopped working. I have a screenshot of the issue http://pasteboard.co/4Pl2850at.png @hakunin were you able to fix it ?

badogar commented 7 years ago

it is trying to make a call to getsentry?sentry_version=7 ....

hankim813 commented 7 years ago

@badogar yikes but without reproducible case in regards to the calls you are making to segment, this could be a uncaught exception that intercom needs to handle. Idk what your sales team pushed so that also makes it difficult to debug. as far as sentry goes, idk if you guys have that integration also enabled. Which is another reason to go through the segment support team via our segment.com/contacts form (since they will have this contextual information).

But more importantly regarding the uncaught... I'd contact intercom directly and ask whether this is a known uncaught exception (which they'll probably ask what you are doing). They shouldn't shrug off the request simply because it is loaded w segment. The stack trace shows that this is an error unhandled by their js sdk. We are still running their js sdk code in your browser so their library should not have a scenario where it breaks your entire website's JS.

badogar commented 7 years ago

thanks @hankim813 for quick response. So, I should be posting it to https://segment.com/contact/requests/ right ?

hankim813 commented 7 years ago

@badogar ah that is for integration requests. You want to go to tech support here: https://segment.com/help

there are content that may help you but if not you can open a ticket at the bottom of the page to get assistance from the Segment success team

laander commented 7 years ago

Just want to echo what @badogar and @hakunin said, same issue here. However I'm unsure whether it's the Segment analytics.js lib or Intercom that's causing the issue.

I know this might not be worth much, but here's a stacktrace: https://sentry.io/share/issue/37373838312e323933353438393636/

By inspecting screen recordings, I too see that it happens on pageload (or maybe in the window.analytics.identify() call). Hard to reproduce though, but I'll get back here if I'm able to

mike-seekwell commented 5 years ago

@hankim813 Can you reopen this? This is still an issue two years later. Segment is trying to load Intercom before the DOM / body is ready.

mike-seekwell commented 5 years ago

Here's a video of the script being loaded in head vs. body

https://www.loom.com/share/2d315014582b41118ad96f211bd02f90

mike-seekwell commented 5 years ago

@hankim813 Any word here? I still get this error frequently