@quantabit/tracking-sdk
v1.0.2
Published
QuantaBit Tracking SDK - User behavior event reporting and trajectory tracking
Maintainers
Readme
@quantabit/tracking-sdk
QuantaBit Tracking SDK - User behavior event reporting and trajectory tracking
📦 Installation
npm install @quantabit/tracking-sdk
# or
yarn add @quantabit/tracking-sdk🚀 Quick Start
1. Initialize
import { init, identify, track } from "@quantabit/tracking-sdk";
// Initialize tracker
init({
apiUrl: "/api/v1/track",
batchSize: 10,
flushInterval: 5000,
debug: true,
autoTrackPageView: true,
autoTrackError: true,
});
// Identify user after login
identify("user_did_12345", {
name: "John",
level: 10,
vip: true,
});2. Track Events
import {
track,
trackPageView,
trackClick,
trackExposure,
trackError,
trackPerformance,
} from "@quantabit/tracking-sdk";
// Custom event
track("button_click", {
button_id: "submit_order",
page: "checkout",
});
// Page view
trackPageView("Product Detail Page", { product_id: "12345" });
// Click tracking
trackClick("buy_now_button", { product_id: "12345" });
// Exposure tracking
trackExposure("product_12345", "product", { position: 1 });
// Error tracking
try {
// ...
} catch (error) {
trackError(error, { context: "checkout" });
}
// Performance tracking
trackPerformance();3. Global Properties
import { setGlobalProperties } from "@quantabit/tracking-sdk";
// Set global properties (included in every event)
setGlobalProperties({
app_version: "1.0.0",
platform: "web",
channel: "organic",
});⚙️ Configuration Options
| Option | Type | Default | Description |
| ------------------- | ------- | --------------- | ------------------------- |
| apiUrl | string | /api/v1/track | Reporting endpoint URL |
| batchSize | number | 10 | Batch report size |
| flushInterval | number | 5000 | Auto-report interval (ms) |
| maxQueueSize | number | 100 | Max queue size |
| debug | boolean | false | Debug mode |
| autoTrackPageView | boolean | true | Auto-track page views |
| autoTrackClick | boolean | false | Auto-track clicks |
| autoTrackError | boolean | true | Auto-track errors |
🏷️ Event Types
import { EventType } from "@quantabit/tracking-sdk";
EventType.PAGE_VIEW; // Page view
EventType.CLICK; // Click
EventType.SCROLL; // Scroll
EventType.EXPOSURE; // Exposure
EventType.ERROR; // Error
EventType.PERFORMANCE; // Performance
EventType.CUSTOM; // Custom📄 License
MIT License
🌐 Brand & Links
- Official Mainnet: QuantaBit Chain
- Developer Platform: Developer Platform
- Open Platform: Open Platform
- Payment Platform: Pay Platform
- Feedback: Feedback
