Integration Guide

Send errors from any language or framework to NexaGaze Tracer.

How it works

Every integration sends a POST request to the same webhook endpoint. You just need your API key and the error details.

POST https://tracer.nexagaze.com/api/webhook

{
  "api_key": "et_your_project_key",
  "message": "Something went wrong",
  "stack": "Error: Something went wrong\n    at handleClick (app/page.js:42)",
  "url": "https://mysite.com/page",
  "line": 42,
  "col": 12,
  "user_agent": "Mozilla/5.0 ...",
  "language": "javascript",
  "breadcrumbs": []
}

Browser (CDN)

Drop this in your HTML. Catches JS errors, promise rejections, and console.error automatically.

<script
  src="https://tracer.nexagaze.com/cdn/tracker.js"
  data-key="et_your_api_key_here"
  crossorigin="anonymous"
></script>

Next.js (App Router)

import Script from "next/script"

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        {process.env.NODE_ENV === "production" && (
          <Script
            src="https://tracer.nexagaze.com/cdn/tracker.js"
            data-key={process.env.NEXT_PUBLIC_NEXTGAZE_TRACER_API}
            strategy="afterInteractive"
            crossOrigin="anonymous"
          />
        )}
      </body>
    </html>
  )
}

Node.js (Express, Next.js API routes, etc.)

const NEXTGAZE_TRACER_API = "et_your_api_key_here"
const NEXTGAZE_TRACER_URL = "https://tracer.nexagaze.com/api/webhook"

async function reportError(error, req) {
  await fetch(NEXTGAZE_TRACER_URL, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      api_key: NEXTGAZE_TRACER_API,
      message: error.message,
      stack: error.stack,
      url: req?.url || "",
      language: "node",
    }),
  })
}

// Express middleware
app.use((err, req, res, next) => {
  reportError(err, req)
  res.status(500).send("Something broke")
})

Python (Django / Flask / FastAPI)

import requests
import traceback

NEXTGAZE_TRACER_API = "et_your_api_key_here"
NEXTGAZE_TRACER_URL = "https://tracer.nexagaze.com/api/webhook"

def report_error(error, request=None):
    requests.post(NEXTGAZE_TRACER_URL, json={
        "api_key": NEXTGAZE_TRACER_API,
        "message": str(error),
        "stack": traceback.format_exc(),
        "url": request.url if request else "",
        "language": "python",
    })

# Django middleware example
class NexaGazeTracerMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        return self.get_response(request)

    def process_exception(self, request, exception):
        report_error(exception, request)

PHP (Laravel / plain PHP)

function reportError($error, $url = '') {
    $ch = curl_init('https://tracer.nexagaze.com/api/webhook');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
        'api_key' => 'et_your_api_key_here',
        'message' => $error->getMessage(),
        'stack' => $error->getTraceAsString(),
        'url' => $url,
        'language' => 'php',
    ]));
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_exec($ch);
    curl_close($ch);
}

// Laravel exception handler
// app/Exceptions/Handler.php
public function register() {
    $this->reportable(function (Throwable $e) {
        reportError($e, request()->url());
    });
}

Ruby on Rails

require 'net/http'
require 'json'

NEXTGAZE_TRACER_API = "et_your_api_key_here"
NEXTGAZE_TRACER_URL = "https://tracer.nexagaze.com/api/webhook"

def report_error(error, request = nil)
  uri = URI(NEXTGAZE_TRACER_URL)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  req = Net::HTTP::Post.new(uri)
  req['Content-Type'] = 'application/json'
  req.body = {
    api_key: NEXTGAZE_TRACER_API,
    message: error.message,
    stack: error.backtrace&.join("\n"),
    url: request&.url || '',
    language: 'ruby'
  }.to_json
  http.request(req)
end

Go

package main

import (
    "bytes"
    "encoding/json"
    "net/http"
)

const NEXTGAZE_TRACER_API = "et_your_api_key_here"
const NEXTGAZE_TRACER_URL = "https://tracer.nexagaze.com/api/webhook"

func reportError(message string, stack string, url string) {
    body, _ := json.Marshal(map[string]interface{}{
        "api_key":  NEXTGAZE_TRACER_API,
        "message":  message,
        "stack":    stack,
        "url":      url,
        "language": "go",
    })
    http.Post(NEXTGAZE_TRACER_URL, "application/json", bytes.NewBuffer(body))
}

Available fields

FieldRequiredDescription
api_keyyesYour project API key
messageyesError message string
stacknoFull stack trace
urlnoURL where error occurred
linenoLine number
colnoColumn number
user_agentnoBrowser user agent
languagenoLanguage/framework (node, python, php, ruby, go)
breadcrumbsnoArray of previous events