bayanista-sdk
v2.1.0
Published
Bayanista Analytics SDK - AI-powered product intelligence
Maintainers
Readme
Bayanista SDK
Zero-Config Semantic Auto-Capture Analytics
One line of code. Automatic event tracking. AI-powered classification.
The Problem
Traditional analytics (Segment, Mixpanel, Amplitude) require:
// You have to write this EVERYWHERE
analytics.track('Button Clicked', {
button_name: 'signup',
page: 'pricing',
plan: 'pro'
});This is tedious, error-prone, and a constant maintenance burden.
The Solution
<!-- Add this single line. That's it. -->
<script src="https://cdn.jsdelivr.net/gh/kmohsen11/bayanista-sdk@main/dist/bayanista.min.js" data-project="YOUR_PROJECT_ID" data-auto-init></script>Bayanista automatically:
- Captures all user interactions (clicks, forms, navigation, etc.)
- Understands what each interaction means semantically
- Extracts relevant properties from context
- Sends clean, meaningful events to your dashboard
Installation
Option 1: Script Tag (Easiest)
<script
src="https://cdn.jsdelivr.net/gh/kmohsen11/bayanista-sdk@main/dist/bayanista.min.js"
data-project="YOUR_PROJECT_ID"
data-auto-init
></script>Option 2: NPM
npm install bayanista-sdkimport Bayanista from 'bayanista-sdk';
Bayanista.init({
projectId: 'YOUR_PROJECT_ID',
apiEndpoint: 'https://bayanista-api.onrender.com'
});Option 3: Self-Hosted
# Download the SDK
curl -o bayanista.min.js https://cdn.jsdelivr.net/gh/kmohsen11/bayanista-sdk@main/dist/bayanista.min.js<!-- Add to your HTML -->
<script src="/path/to/bayanista.min.js" data-project="YOUR_PROJECT_ID" data-auto-init></script>What Gets Captured Automatically
Clicks
- Button clicks:
signup_button_clicked,add_to_cart_clicked - Link clicks:
pricing_link_clicked,external_link_clicked - Navigation:
nav_features_clicked,tab_monthly_selected - Cards/Products:
product_card_clickedwith product details
Forms
- Form submissions:
signup_form_submitted,checkout_form_submitted - Form starts:
contact_form_started - Field interactions:
email_field_changed,search_field_changed
Navigation
- Page views:
pricing_page_viewed,product_page_viewed - Route changes: SPA navigation tracked automatically
Engagement
- Scroll depth:
scroll_depth_25,scroll_depth_50, etc. - Rage clicks:
user_rage_clicked(frustration signal) - Dead clicks:
user_dead_clicked(UX issue signal)
Errors
- JavaScript errors: Captured with context
- Network failures: API errors tracked
Semantic Classification
Bayanista doesn't just capture raw events. It understands them:
| Raw Event | Semantic Event | Category |
|-----------|---------------|----------|
| Click on <button>Get Started</button> | signup_cta_clicked | conversion |
| Form submit with email, password | signup_form_submitted | conversion |
| Click on nav item "Pricing" | nav_pricing_clicked | navigation |
| 5 clicks in 1 second on same element | user_rage_clicked | frustration |
| Click on product card | product_item_3_clicked | engagement |
Configuration Options
Bayanista.init({
projectId: 'YOUR_PROJECT_ID',
// API endpoint (for self-hosted)
apiEndpoint: 'https://api.bayanista.ai',
// What to capture
captureClicks: true,
captureForms: true,
captureNavigation: true,
captureNetwork: true,
captureErrors: true,
captureScrollDepth: true,
captureRageClicks: true,
captureDeadClicks: true,
// Privacy
respectDoNotTrack: true,
maskSensitiveData: true,
// Debug mode
debug: false,
});User Identification
When a user logs in:
Bayanista.identify('user_123', {
email: '[email protected]',
name: 'John Doe',
plan: 'pro'
});On logout:
Bayanista.reset();Manual Events (Escape Hatch)
For events that can't be auto-captured:
Bayanista.track('video_played', {
videoId: 'abc123',
duration: 120,
quality: '1080p'
});Privacy & Security
- Sensitive data masking: Passwords, credit cards, etc. are never captured
- Do Not Track: Respects browser DNT setting
- GDPR compliant: No PII captured without consent
- Offline support: Events queued when offline, sent when back online
How It Works
┌─────────────────────────────────────────────────────────────┐
│ Your Website │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Bayanista SDK (Auto-Capture) │ │
│ │ ┌───────────┐ ┌───────────┐ ┌───────────────┐ │ │
│ │ │ Capture │ │ Classify │ │ Transport │ │ │
│ │ │ Engine │──│ (AI/Rules)│──│ Layer │ │ │
│ │ └───────────┘ └───────────┘ └───────────────┘ │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────┐ │
│ │ Bayanista Backend │ │
│ │ (AI Insight Engine) │ │
│ └─────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────┐ │
│ │ Plain-English Insights │ │
│ │ "73% drop off at │ │
│ │ pricing page" │ │
│ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘Comparison
| Feature | Segment | Mixpanel | PostHog | Bayanista | |---------|---------|----------|---------|---------------| | Manual tracking required | Yes | Yes | Partial | No | | Semantic understanding | No | No | No | Yes | | AI-powered insights | No | No | No | Yes | | Zero-config setup | No | No | No | Yes | | Works without engineers | No | No | No | Yes |
Size
- Minified: ~15KB
- Gzipped: ~5KB
Browser Support
- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
License
MIT
Support
- Website: https://bayanista.com
- Issues: https://github.com/kmohsen11/bayanista-sdk/issues
- Email: [email protected]
