trackJs Destination


Track JS monitors your web applications for JavaScript errors, alerting you with amazing context about how the user, application, and network got into trouble. The analytics.js trackJs Destination is open-source. You can browse the code on GitHub.

This document was last updated on November 26, 2018. If you notice any gaps, outdated information or simply want to leave some feedback to help us improve our documentation, please let us know!

Getting Started

The first step is to make sure Track JS supports the source type and connection mode you’ve chosen to implement. You can learn more about what dictates the connection modes we support here.

Web Mobile Server
📱 Device-mode
☁️ Cloud-mode
  1. From your Segment UI’s Destinations page click on “Add Destination”.
  2. Search for “Track JS” within the Destinations Catalog and confirm the Source you’d like to connect to.
  3. Drop in your Token as retrieved from your Track JS setup page.
  4. Our CDN is updated within 45 minutes. Then our snippet will start asynchronously loading Track JS onto your page. This means you should remove Track JS’ snippet from your page.
  5. The Track JS Destination doesn’t utilize any Segment API calls (e.g. identify, track, etc) so, once it’s loaded, it will automatically start recording error data.

Non-supported options

We do not currently support Track JS’ onError and serialize options because they pose a XSS vulnerability.

To work around this issue, however, you can directly set these options in the window._trackJs object on your page. These options will be merged with the settings you have configured in the interface once the Track JS script is loaded.

We also do not support version, or sessionId. These can either be set prior to initialization as described above, or can be set after the snippet has been loaded with the ready callback

analytics.ready(function(){
  window.trackJs.configure({ sessionId: '123456', version: '1.0' });
});

Note that the userId parameter is automatically determined.

Settings

Segment lets you change these destination settings from your Segment dashboard without having to touch any code.

Application Key

Optional. The name of the section of your application that this Segment project encompasses. For more info see here

Console Display

Whether calls to console.log and other console functions should be displayed into the browser’s console.

Console Enabled

Whether TrackJS should wrap and watch the console for events. If disabled, window.console is not guaranteed to exist in all browsers.

Console Error

Whether TrackJS should transmit errors on calls to console.error.

Enabled

Whether to enable TrackJS for the page. If false, the TrackJS watchers will not be set up. The window.trackJs API will still be available and function locally, but no errors will be transmitted from the browser

Network Error

Whether TrackJS should transmit errors when an AJAX call completes with a ‘failing’ status code, 400 or greater. If you wish to customize the list of status codes you want to capture errors from, set this to true and filter out status codes using the onError callback.

Callback BindStack

Whether TrackJS should record the stacktrace for how a callback came to be bound, allowing the creation of an ‘async stacktrace’ in the TrackJS UI. This gives you more context of how the application arrived at the function that failed. Enabling this has a nontrivial performance penalty, test before enabling in production

Callback Enabled

Whether TrackJS should watch for errors on host-function callbacks, such as addEventListener, and setTimeout. Disabling this greatly decreases the likelihood of recording a stacktrace for an error.

Network Enabled

Whether TrackJS should wrap and watch AJAX calls. If disabled, network events will not appear in your Telemetry Timeline.

Token

You can find your token under Track JS setup page.

Visitor Enabled

Whether TrackJS should watch visitor interaction events, such as clicks and field input.

Window Enabled

Whether TrackJS should watch window.onerror for global errors

Get started with Segment

Segment is the easiest way to integrate your websites & mobile apps data to over 300 analytics and growth tools.
or
Create free account