Skip to content

Instantly share code, notes, and snippets.

@BrandesEric
Last active June 19, 2018 12:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrandesEric/b8e970178276a68526ed70f3f4b8b35f to your computer and use it in GitHub Desktop.
Save BrandesEric/b8e970178276a68526ed70f3f4b8b35f to your computer and use it in GitHub Desktop.
TrackJS onError sending to third party API first, before tracking
let filename = ''
let jsonURL = 'https://api.myjson.com/bins'
let token = 'YOUR_TOKEN_HERE'
let trackJsCaptureUrl = `https://capture.trackjs.com/capture?token=${token}`
let actions = []
export function configureTracker () {
window.trackJs.configure({
onError: (payload, error) => {
axios.post(jsonURL, {actions})
.then(function (response) {
filename = response.data.uri
let data = {message: filename, severity: 'log', timestamp: ''}
payload.console.push(data)
// Just send the payload manually
fetch(trackJsCaptureUrl, {
method: 'post',
body: JSON.stringify(payload)
});
});
return false; // We will send the payload ourselves
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment