This project now includes comprehensive observability through OpenTelemetry and Kubiks.
otel-init.js- OpenTelemetry SDK initializationotel-utils.js- Telemetry utility functions for custom trackingpackage.json- Dependencies for web-based OpenTelemetry.env.example- Environment variable templateTELEMETRY_SETUP.md- This file
- Updated
index.htmlto initialize OpenTelemetry on page load
npm installCreate a .env.local file (or use .env for Vercel):
REACT_APP_KUBIKS_KEY=kubiks_c71a0c0b7664f11a0aa477f86d4840a909ae805d8f83059f977fe92aadbcb540
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.kubiks.app
OTEL_SERVICE_NAME=fastcash-webOpen your browser console and you should see:
OpenTelemetry initialized for FastCash
import { trackTabChange } from './otel-utils.js';
// When user clicks a tab
document.querySelector('[data-tab="dashboard"]').addEventListener('click', () => {
trackTabChange('dashboard');
});import { trackUserAction } from './otel-utils.js';
trackUserAction('button_click', {
button_name: 'submit',
form_type: 'signup'
});import { trackAPICall } from './otel-utils.js';
const apiCall = trackAPICall('https://api.example.com/data', 'GET');
try {
const response = await fetch('https://api.example.com/data');
apiCall.end(response.status, 150); // status code and duration
} catch (error) {
apiCall.recordError(error);
}import { trackError } from './otel-utils.js';
try {
// some code
} catch (error) {
trackError('DataFetchError', error.message, error.stack);
}import { trackPageMetrics } from './otel-utils.js';
// Call after page loads
window.addEventListener('load', () => {
trackPageMetrics();
});- Go to Vercel Project Settings → Functions → Web Analytics
- Configure to send logs to Kubiks endpoint
- Go to Vercel Project Settings → Integrations → OpenTelemetry
- Configure trace exporter endpoint
- Page load performance metrics
- Navigation events
- All HTTP requests and responses
- Errors and exceptions
- Resource performance
- User interactions
- Form submissions
- Business events
- Custom metrics
| Variable | Description | Required |
|---|---|---|
REACT_APP_KUBIKS_KEY |
Kubiks API key for authentication | Yes |
OTEL_EXPORTER_OTLP_ENDPOINT |
Kubiks ingestion endpoint | Yes |
OTEL_SERVICE_NAME |
Your service name in Kubiks | No (default: fastcash-web) |
- Open your app in browser
- Check browser console for initialization message
- Interact with the page
- Open Network tab in DevTools - you should see requests to
ingest.kubiks.app - Check Kubiks dashboard for incoming telemetry data
- Remove
console.logtelemetry messages (or set NODE_ENV=production) - Set proper API key in production environment
- Test on staging environment first
- Configure appropriate sampling if needed
- Set up alerts in Kubiks dashboard
- Check browser console for errors
- Verify API key is correct
- Check Network tab for failed requests to
ingest.kubiks.app - Ensure CORS is enabled
- Reduce event frequency by adjusting sampling
- Filter out non-essential events
- Batch events before sending