@mattab opened this Issue on April 10th 2014 Owner

Using the new powerful Event Tracking functionality, we can implement Javascript Errors Tracking within piwik.js.

The goal of this feature is to keep track automatically of any javascript errors or exception that happen during the rendering of the page, or any time after the initial rendering.

There are lots of tools that provide Error tracking and we would like to implement a basic, yet useful, alternative as part of Piwik Data Analytics platform!

Todo

  • FAQ
  • User Guide?
  • JS test
@tsteur commented on April 10th 2014 Owner

In 588e68948a3b68223ceecc7a2575db4a220be8c4: refs #4977 added a new method to the tracker to enableJSErrorTracking. This is beta... feedback is welcome...

@tsteur commented on April 10th 2014 Owner

In 128d75a58139168f77089be7e68fd5818e6b8d59: refs #4977 enable JS error tracking in Piwik UI (if tracking in Piwik UI is activated)

@tsteur commented on April 10th 2014 Owner

In 5ef610b382d6717e388a8e4a5cc3e8e9ba82cba1: refs #4977 include piwik tracker as early as possible to make sure we track js errors

@tsteur commented on April 10th 2014 Owner

In 5d74768e6c20b564101e0212eeb4d5b21fbe0a6d: refs #4977 make JSLint happy

@hpvd commented on April 10th 2014

Replying to Thomas Steur:

include piwik tracker as early as possible to make sure we track js errors

makes sense, but may result in problems if users use tools to protect their privacy (like extension "ghostery" in FF ) which blocks piwik.

If Piwik script is blocked sometimes the complete site is not usable any more because the following js is blocked/broken too..

@tsteur commented on April 11th 2014 Owner

In 0f43631624d1bbb37f49c2fadebe8d5dfed24e9a: refs #4977 make clear that only uncaught errors are tracked

@mattab commented on April 17th 2014 Owner

Interesting, Google Analytics just released Javascript Exception Tracking as well! https://developers.google.com/analytics/devguides/collection/analyticsjs/exceptions

@mattab commented on May 28th 2014 Owner

See also #5257 Application Performance Management & Monitoring

@mattab commented on December 1st 2014 Owner

There are now many tools offering useful and usable JavaScript error tracking such as airbrake.io or raygun.io

@szepeviktor commented on July 31st 2015

Is it a working feature or a planned one?
If you're planning, please consider stealing code from https://github.com/MindscapeHQ/raygun4js (AJAX error, stack trace etc.)
https://github.com/getsentry/raven-js is also using https://github.com/csnover/TraceKit
But there is https://github.com/stacktracejs/stacktrace.js also.

@tsteur commented on July 31st 2015 Owner

It is working in general but only very basic. We simply track all errors as events for now but hope to provide similar enhanced features some day than others do

@hpvd commented on April 4th 2016

"it is working in general but only very basic"
is there any doc how to use it? Do one has to enable it or should it work without any config directly "out of box"?

@tsteur commented on April 4th 2016 Owner

Looks like there is no documentation for it indeed. There's a bit of documentation here: https://github.com/piwik/piwik/blob/2.16.0/js/piwik.js#L5869-L5886 and to activate it you can call _paq.push(['enableJSErrorTracking']);.

It is very very basic though and I would suggest to first give it a try as it will add many different event actions and event names to your event reports in case you are using them for something else currently (it could give you a less good overview of action and names in event reports)

@wei1215583760 commented on August 15th 2017

_paq.push(['enableJSErrorTracking']); after i add this sentence in my website, i want to know where i can check the result in my piwik. thanks!

@tsteur commented on August 15th 2017 Owner

You can see some basic reporting in the "Actions => Event" reports

@wei1215583760 commented on August 15th 2017

7aa36a59dd72494fa0dd5a554f098129
this is my test website which i track it with piwik, and there is an error. I have added _paq.push(['enableJSErrorTracking']) in the tracking code.

i want to track the error, but it shows nothing in piwik
b956709a57e5f447933cb56377be783e

do you know why?
thanks a lot if you can help me

@wei1215583760 commented on August 15th 2017

8f5e9532bfbced41ae5dd11fb5cc07ca

@wei1215583760 commented on August 15th 2017

adea27f37245e34f86f90ae622f9d8c6
this is my website

@tsteur commented on August 15th 2017 Owner

Maybe Piwik is loaded after the error occurred.

To capture all JS errors we recommend to include the Piwik JavaScript tracker in the HTML as early as possible. If possible directly in

before loading any other JavaScript

The thing is Piwik is loaded async by default so it might still not capture all errors unless you loaded it sync which is not recommended.

@wei1215583760 commented on August 15th 2017

thank a lot for telling me about this, do you know how to loaded it sync? i want to have it a try to test this function. And do you know where can we find some demos to show the errors being tracked? i have a job to use piwik proficiently

@wei1215583760 commented on August 15th 2017

i define many errors in my website, but i cannot find any one in the piwik action->event, which confuses me. Which type of error does the piwik track?

@wei1215583760 commented on August 15th 2017

i want to know when i enablejserrortracking function, which table will store the data from website in piwik? Can you help me? thanks!

@RMastop commented on August 15th 2017 Contributor

Hi @wei1215583760,

If you navigate the website containing errors, could you check, using development tools, if you see any requests to your Piwik server?

@wei1215583760 commented on August 15th 2017

thanks for your reply @RMastop
9fe2ec4ca3eaa5459acd8a634deddd92
there are responses to piwik, but it did not carry error message. Can you give me some advice?

@wei1215583760 commented on August 15th 2017

d31e8c9c62f7b94287b0578a936710da
@RMastop

this is full image

@RMastop commented on August 15th 2017 Contributor

@wei1215583760 When should the js error occur? Could you post the HTML of the page?

@wei1215583760 commented on August 15th 2017

this is my website code, index.html. And i add an error

t>, ths whole

@wei1215583760 commented on August 15th 2017

@RMastop
f4c0c82f22434f40a2536331f8511fbc
this is the page in chrome browser

@wei1215583760 commented on August 15th 2017

@RMastop do you know where i the error message it stores as log data?

@RMastop commented on August 15th 2017 Contributor

@wei1215583760 I tried to reproduce the issue, but no call is triggered after the JS error. Without the call to the piwik server, no need to search for it in the database.

@wei1215583760 commented on August 15th 2017

thanks a lot for your patience, but i still do not know how to track the error, maybe this error can not be tracked? do you know what kind of error can be tracked?

@wei1215583760 commented on August 15th 2017

Now i want to make sure that this function can track errors and show it with piwik dashboard. if you have some examples, can you give me example errors?@RMastop

@RMastop commented on August 15th 2017 Contributor

Hi @wei1215583760,

As documented, Could you put the Piwik tracking code all the way to the top op the HTML, just below <HEAD>
After this change Javascript errors are tracked as events.

e_c:JavaScript Errors
e_a:http://127.0.0.1:8888/jserrordemo/:164:3
e_n:Uncaught ReferenceError: a is not defined
idsite:4
rec:1

@wei1215583760 commented on August 15th 2017

do you mean put the tracking code like this ? but it still have no reponse ...sad
where do you get your message? in action=>event?
@RMastop

@Findus23 commented on August 15th 2017 Member

You can also try running the tracking script non async/deferred as explained here: https://developer.piwik.org/guides/ab-tests/browser

This will slow down your site a bit but will make sure that piwik is loaded before the error occurs.

@RMastop commented on August 15th 2017 Contributor

@wei1215583760 just below the opening <HEAD>
image

@wei1215583760 commented on August 15th 2017

thanks for your help, @Findus23 @RMastop , I change the tracking script using synchronous method, and it worked.
image
thanks a lot for your kind heart

@Findus23 commented on August 15th 2017 Member

maybe now that we have a documentation on how to run piwik non-asynchronous, we should maybe we should also document this feature. (And warn about the performance decline)

@wei1215583760 commented on August 15th 2017

Yes, but asynchronous method did not work for error tracking in my case. Maybe this case will be a good guide for other users

@wei1215583760 commented on August 16th 2017

82bb9f56ee563244b873f09993e70add
Additionaly, i can track js error as the following picture shows, but how can i track the full trace back including at "at abc (demo1.js:11) at efg (demo1.js:16)" @RMastop @Findus23
25f45f6048e3e248ae720a8cb405b8b5

@wei1215583760 commented on August 16th 2017

If i want to make sure where the error happened, i need to know the accurate message

@wei1215583760 commented on August 16th 2017

@tsteur do you know how to track full trace back using js? If there are some errors, I want to find it more easily with trace back information.

@Findus23 commented on August 16th 2017 Member

@wei1215583760
Currently piwik doesn't add the stacktrace, but it shouldn't be that hard to add:

Check https://github.com/piwik/piwik/blob/3.x-dev/js/piwik.js#L6500-L6543
and https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror

At least in chrome (I am not sure about other browsers) the stacktrace should be accessable via error.stack

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Stack
https://stackoverflow.com/a/4200200

@wei1215583760 commented on August 23rd 2017

I have used error tracking for several days, it worked well. And I want to know where the information placed in the datatable. Do you know where these error strings are stored? @Findus23 @RMastop I am sorry to trouble you.

@wei1215583760 commented on August 23rd 2017

again

@mattab commented on September 18th 2017 Owner

Do you know where these error strings are stored?

They're stored as Actions in log_link_visit_action and log_action tables see: https://developer.piwik.org/guides/persistence-and-the-mysql-backend#action-types

Powered by GitHub Issue Mirror