Sublyzer One — SDK Guide

End‑to‑end guide to integrate the Sublyzer SDKs. Covers initialization, event collection, performance metrics, error tracking, security signals, and best practices.

1) Download the SDK and place it in your site

Use the SDK Customizer (Dashboard → SDK Customizer) and click Download. Save the file as sublyzer.js under your app's public assets, for example:

frontend/public/sdks/sublyzer.js

In Next.js, anything inside public/ is served statically. The SDK will then be available at /sdks/sublyzer.js.

2) Add the HTML tag to your site

Paste this into your HTML (e.g., custom Document, layout, or template):

<script
  src="/sdks/sublyzer.js"
  data-integration-code="YOUR_24_CHAR_CODE"
  data-api-url="http://localhost:3001">
</script>

On page load, the SDK initializes and starts collecting performance and error signals automatically.

3) Get your Integration Code

Create an Integration in the dashboard and copy the 24‑char Integration Code. Replace YOUR_24_CHAR_CODE above with it.

4) Now just run your site

Once you've added the HTML tag with your Integration Code, simply start your development server or deploy your site. The SDK will automatically:

  • Initialize on page load
  • Start collecting performance metrics (Core Web Vitals)
  • Capture JavaScript errors and stack traces
  • Track user interactions (clicks, page views, sessions)
  • Send data to your Sublyzer backend every 10 seconds

You can view all collected data in the Dashboard under your Integration.

Advanced: JavaScript/TypeScript (npm)
npm install sublyzer-sdk
import Sublyzer from 'sublyzer-sdk';

const sublyzer = new Sublyzer({
  integrationCode: 'YOUR_CODE',
  apiUrl: 'http://localhost:3001',
  flushInterval: 10000, // default 10s
  enablePerformance: true,
  enableErrors: true,
  enableVulnerabilities: true,
  enableUserMetrics: true,
});

sublyzer.init(); // start collection

// custom events
sublyzer.track('button_click', { id: 'buy-now' });
Advanced: Error Tracking (Web)
// Global JS errors
window.addEventListener('error', (event) => {
  sublyzer.collectError({
    message: event.message,
    filename: event.filename,
    lineno: event.lineno,
    colno: event.colno,
    stack: event.error?.stack,
  });
});

// Unhandled promise rejections
window.addEventListener('unhandledrejection', (event) => {
  sublyzer.collectError({
    message: event.reason?.message || 'Unhandled Promise Rejection',
    type: 'promise_rejection',
    stack: event.reason?.stack,
  });
});
Advanced: Performance Metrics

Core Web Vitals are captured automatically. You can also send custom timings.

sublyzer.collectPerformance({
  loadTime: 1500,
  firstContentfulPaint: 800,
  largestContentfulPaint: 1200,
  cumulativeLayoutShift: 0.05,
  firstInputDelay: 40,
});
Advanced: Backend SDKs

All backends follow a similar API; initialize and send events.

Python

pip install sublyzer-sdk

from sublyzer_sdk import Sublyzer
sublyzer = Sublyzer(integration_code='YOUR_CODE', api_url='http://localhost:3001')
sublyzer.init()
sublyzer.collect_error({ 'message': 'Something went wrong', 'type': 'RuntimeError' })

PHP

composer require sublyzer/sdk

use SublyzerSDKSublyzer;
$sublyzer = new Sublyzer(['integration_code' => 'YOUR_CODE', 'api_url' => 'http://localhost:3001']);
$sublyzer->init();
$sublyzer->collectError([ 'message' => 'DB connection failed' ]);

Go

go get github.com/sublyzer/sdk

config := sublyzer.Config{ IntegrationCode: "YOUR_CODE", APIURL: "http://localhost:3001" }
client := sublyzer.New(config)
client.Init()
client.CollectError(map[string]any{"message": "timeout"})

Rust

use sublyzer_sdk::Sublyzer;
let sub = Sublyzer::new_default("YOUR_CODE", "http://localhost:3001");
sub.init().await;
Best Practices
  • Do not include secrets in client SDKs. Use only the public integration code.
  • Default flush interval is 10s. Use sublyzer.flush() on page hide to avoid data loss.
  • Deduplicate repeated errors using a fingerprint constructed from message + first stack line.
  • Include sdkVersion and basic deviceInfo for better diagnostics.
  • Respect user privacy. Enable IP anonymization if required by your policies.
Troubleshooting
  • Nothing shows up? Verify NEXT_PUBLIC_API_URL in the frontend and CORS on the API.
  • Events seem doubled? Ensure click handlers guard against bubbling using a handled flag.
  • Security list empty after reload? The dashboard keeps the last non‑empty dataset; check filters.