Last active
June 19, 2018 12:47
-
-
Save BrandesEric/b8e970178276a68526ed70f3f4b8b35f to your computer and use it in GitHub Desktop.
TrackJS onError sending to third party API first, before tracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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