Capture

The Capture API takes error reports from remote agents for processing into the Dashboard. Due to the volume of data this API processes, it will return a 200 OK or 202 ACCEPTED regardless of whether the data is valid, as it cannot be processed at the time of the response.

The API accepts POST requests of the Payload less than 100 KB.

The API does not require authentication.

URI

POST https://capture.trackjs.com/capture?token={TOKEN}&v={AGENT_VERSION}

The following querystring parameters are accepted:

token

String

Required

Identifies error traffic for your account. Get this from the install page.

v

Semver

Optional

Indicates to the server how to respond. If v is 3.3.0 or greater, the server may respond with a 202 ACCEPTED response.


Request Payload

The total size of the payload cannot be larger than 100 KB.

{
    /**
     * The source platform of the capture. Typically "browser" or "node".
     * {String}
     */
    "agentPlatform": "",

    /**
     * Async Stack Trace content.
     * {String}
     */
    "bindStack": "",

    /**
     * Timestamp when the "bindStack" was generated.
     * {ISO 8601 String}
     */
    "bindTime": "0000-00-00T00:00:00.000Z",

    /**
     * Console Telemetry events.
     * {Array[Object]}
     */
    "console": [{
        /**
         * Formatted console message string.
         * {String}
         */
        "message": "text",

        /**
         * Severity of the console event.
         * {String:"log","debug","info","warn","error"}
         */
        "severity": "log",

        /**
         * Timestamp of the console event.
         * {String ISO 8601}
         */
        "timestamp": "0000-00-00T00:00:00.000Z"
    }],

    "customer": {
        /**
         * Application key. Generated this in your TrackJS Dashboard.
         * {String}
         */
        "application": "",

        /**
         * Auto-generated ID for matching visitor to multiple errors.
         * {String}
         */
        "correlationId": "",

        /**
         * Customer-generated Id for the current browser session.
         * {String}
         */
        "sessionId": "",

        /**
         * Your account token, generated by TrackJS.
         * {String}
         */
        "token": "",

        /**
         * Customer-generated Id for the current user.
         * {String}
         */
        "userId": "",

        /**
         * Customer-generated Id for the current application version.
         * {String}
         */
        "version": ""
    },

    /**
     * Entry point of the error.
     * {String:"ajax","direct","catch","console","window"}
     */
    "entry": "direct",

    "environment": {
        /**
         * Time elapsed from the page load until the error in milliseconds.
         * {Number}
         */
        "age": 0,

        /**
         * List of other libraries in the document.
         * {HashMap:{String:name}:{String:version}}
         */
        "dependencies": {
            "name": "1.0.0"
        },

        /**
         * URL of the document when the page loaded.
         * {String URL}
         */
        "originalUrl": "http://example.com/",

        /**
         * Referrer URL to this document.
         * {String URL}
         */
        "referrer": "http://example.com/",

        /**
         * Browser User Agent string.
         * {String UserAgent}
         */
        "userAgent": "",

        /**
         * Visitor viewport height.
         * {Number}
         */
        "viewportHeight": 0,

        /**
         * Visitor viewport width.
         * {Number}
         */
        "viewportWidth": 0
    },

    /**
     * Filename originating the error.
     * {String filename}
     */
    "file": "",

    /**
     * Error message.
     * {String}
     */
    "message": "",

    /**
     * Customer-provided metadata keys describing the current context.
     * {Array[Object]}
     */
    "metadata": [{
        /**
         * Metadata key.
         * {String}
         */
        "key": "",

        /**
         * Metadata value.
         * {String}
         */
        "value": ""
    }],

    /**
     * Navigation Telemetry events.
     * {Array[Object]}
     */
    "nav": [{
        /**
         * Previous page URI.
         * {String URI Path}
         */
        "from": "",

        /**
         * Event time.
         * {String ISO 8601}
         */
        "on": "0000-00-00T00:00:00.000Z",

        /**
         * Next page URI.
         * {String URI Path}
         */
        "to": "",

        /**
         * Type of navigation replacement.
         * {String:"replaceState","popstate","pushState"}
         */
        "type": ""
    }],

    /**
     * Network Telemetry events.
     * {Array[Object]}
     */
    "network": [{
        /**
         * Network Request complete time.
         * {String ISO 8601}
         */
        "completedOn": "0000-00-00T00:00:00.000Z",

        /**
         * HTTP Method of the request.
         * {String:"GET","POST","UPDATE","DELETE","..."}
         */
        "method": "",

        /**
         * The correlationId from a TrackJS agent on the other side of this
         * request. This is used to tie client and server errors together.
         * {String}
         */
        "requestCorrelationId": ""

        /**
         * Network Request start time.
         * {String ISO 8601}
         */
        "startedOn": "0000-00-00T00:00:00.000Z",

        /**
         * HTTP Status code of the completed request.
         * {NUMBER}
         */
        "statusCode": 200,

        /**
         * HTTP Status text of the completed request.
         * {String}
         */
        "statusText": "OK",

        /**
         * Network API that was used for the request.
         * {String}
         */
        "type": "xhr"

        /**
         * URL destination of the request.
         * {String URL}
         */
        "url": "http://example.com/"
    }],

    /**
     * URL of the document when the error occurred.
     * {String URL}
     */
    "url": "http://example.com/",

    /**
     * Stack trace of the error
     * {String}
     */
    "stack": "",

    /**
     * Number of errors that have been dropped by the agent throttles before
     * this one.
     * {Number}
     */
    "throttled": 0,

    /**
     * Timestamp when the error occurred.
     * {String ISO 8601}
     */
    "timestamp": "0000-00-00T00:00:00.000Z",

    /**
     * Visitor Telemetry events.
     * {Array[Object]}
     */
    "visitor": [{
        /**
         * Visitor Action type
         * {String:"input","click"}
         */
        "action": "input",

        /**
         * Element the visitor interacted with
         * {Object}
         */
        "element": {
            /**
             * Element attributes. IE "type","class","id","placeholder", etc
             * {HashMap:{String:attribute}:{String:value}}
             */
            "attributes": {
                "attribute": "value"
            },

            /**
             * Element tagName
             * {String}
             */
            "tag": "",

            /**
             * Element value metadata
             * {Object}
             */
            "value": {
                /**
                 * Length of the value string.
                 * {Number}
                 */
                "length": 0,

                /**
                 * The pattern matching the value string.
                 * {String:"empty","email","date","usphone","whitespace","numeric","alpha","alphanumeric","characters"}
                 */
                "pattern": ""
            }
        },

        /**
         * Timestamp of the visitor event.
         * {String ISO 8601}
         */
        "timestamp": "0000-00-00T00:00:00.000Z"
    }],

    /**
     * Version of the TrackJS Agent.
     * {String Semver}
     */
    "version": "0.0.0"
}

Example

Here is an example of posting a custom error report directly to the Capture API using fetch.

fetch("https://capture.trackjs.com/capture?token={TOKEN}", {
    method: "POST",
    body: JSON.stringify({
        "console": [{
            "message": "a console message",
            "severity": "log",
            "timestamp": "2018-11-27T12:11:20.932Z"
        }],
        "customer": {
            "application": "app-prod",
            "correlationId": "123",
            "sessionId": "",
            "token": "YOUR_TOKEN",
            "userId": "sam@example.com",
            "version": ""
        },
        "entry": "direct",
        "environment": {
            "age": 320032,
            "dependencies": {
                "moment": "2.10.6"
            },
            "originalUrl": "https://docs.trackjs.com/",
            "referrer": "",
            "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36",
            "viewportHeight": 768,
            "viewportWidth": 1024
        },
        "file": "/assets/js/main.js",
        "message": "TypeError: e is undefined",
        "metadata": [{
            "key": "subscription",
            "value": "professional"
        }],
        "nav": [{
            "from": "/browser-agent/",
            "on": "2018-11-27T12:34:21.313Z",
            "to": "/browser-agent/installation/",
            "type": "pushState"
        }],
        "network": [{
            "completedOn": "2018-11-27T12:11:21.313Z",
            "method": "GET",
            "startedOn": "2018-11-27T12:11:20.932Z",
            "statusCode": 200,
            "statusText": "OK",
            "url": "https://docs.trackjs.com/"
        }],
        "url": "https://docs.trackjs.com/",
        "stack": "TypeError: Cannot read property id of undefined\nat v (https://docs.trackjs.com/assets/js/main.js:1:182029)\nat dispatch\n(https://docs.trackjs.com/assets/js/main.js:1:57019)\nat y.handle (https://docs.trackjs.com/assets/js/main.js:1:53767)\nat b (https://cdn.trackjs.com/agent/v3/canary/t.js:4:462)",
        "throttled": 0,
        "timestamp": "2018-11-27T12:11:22.313Z",
        "visitor": [{
            "action": "input",
            "element": {
                "attributes": {
                    "type": "text",
                    "name": "name",
                    "id": "name-input"
                },
                "tag": "input",
                "value": {
                    "length": 6,
                    "pattern": "alpha"
                }
            },
            "timestamp": "2018-11-27T12:11:20.932Z"
        }],
        "version": "3.0.0"
    })
})