Single Error Metadata

Usually, metadata is added to all errors in a session, but you may want to add it only to a single error. For example, maybe you want to additionally capture the name of the error. The name is something like “SyntaxError” or “TypeError”. This can be useful to track so you can group and filter by all instances of SyntaxError, for example.

window.TrackJS && TrackJS.install({
    token: "YOUR_TOKEN",
    onError: function(payload, error){
        payload.metadata.push({
            key: "Error Name",
            value: error.name || "Not Defined"
        });
        return true;
    }
});
Add single metadata
import { TrackJS } from "trackjs";
TrackJS.install({
    token: "YOUR_TOKEN",
    onError: function(payload, error){
        payload.metadata.push({
            key: "Error Name",
            value: error.name || "Not Defined"
        });
        return true;
    }
});
Add single metadata
<script>
window._trackJs = {
    token: "YOUR_TOKEN",
    onError: function(payload, error){
        payload.metadata.push({
            key: "Error Name",
            value: error.name || "Not Defined"
        });
        return true;
    }
};
</script>
<script src="https://cdn.trackjs.com/releases/current/tracker.js"></script>
Add single metadata