Code examples

Because there's no SDK, integration is just an HTTP request from wherever you catch errors.

curl

curl -X POST https://your-metricly.app/api/ingest \
  -H "Content-Type: application/json" \
  -H "X-Metricly-Key: mtr_your_project_key" \
  -d '{
    "level": "error",
    "exception": { "type": "TypeError", "value": "Cannot read properties of undefined" },
    "environment": "production",
    "release": "web@1.4.2",
    "user": { "id": "user_123" },
    "tags": { "route": "/checkout" }
  }'

JavaScript / TypeScript

// Wire into a global error handler — no SDK required.
async function reportError(err) {
  await fetch("https://your-metricly.app/api/ingest", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-Metricly-Key": process.env.METRICLY_KEY,
    },
    body: JSON.stringify({
      level: "error",
      exception: { type: err.name, value: err.message, stacktrace: err.stack },
      environment: process.env.NODE_ENV,
      release: process.env.APP_VERSION,
    }),
  });
}

process.on("uncaughtException", reportError);

Python

import os, requests, traceback

def report_error(exc: Exception):
    requests.post(
        "https://your-metricly.app/api/ingest",
        headers={"X-Metricly-Key": os.environ["METRICLY_KEY"]},
        json={
            "level": "error",
            "exception": {
                "type": type(exc).__name__,
                "value": str(exc),
                "stacktrace": "".join(traceback.format_tb(exc.__traceback__)),
            },
            "environment": "production",
        },
        timeout=5,
    )