CDN Installation Guide
The Moss SDK supports CDN installation for applications that donโt use React or prefer a simple script tag approach. This method automatically configures the SDK using your application settings from the Moss Dashboard.Prerequisites
- A registered application in the Moss Dashboard
- Your Application ID (UUID format)
- A website where you want to install the SDK
๐ Quick Start
Basic Installation
The simplest way to get started is with a single script tag:Installation with User ID
For logged-in users, include the userId directly in the script URL:All-in-One Installation
- โ Automatically fetch configuration from your dashboard
- โ Use the provided user ID or generate anonymous one
- โ Display the floating assistant button
- โ Handle all initialization automatically
๐ Getting Your Application ID
- Sign up at Moss Dashboard
- Create a new application or select an existing one
- Copy the Application ID from your application settings
- Configure SDK settings in the dashboard (optional)
โ๏ธ Configuration Options
Method 1: Pre-load Configuration
Setwindow.mossSettings before the SDK loads to customize behavior:
Method 2: Page Sanitization
Configure how the SDK captures page content for better context accuracy by passing a sanitization function:Method 3: Custom API Base URL
If youโre using a custom backend deployment:๐ฎ Global API
Once loaded, the SDK exposes a globalMossSDK object for runtime control:
User Identification
Runtime Configuration
Lifecycle Management
๐ฑ Single Page App Integration
For SPAs, update the SDK when routes or user state changes:๐ Security & Domain Restrictions
Configure allowed domains in your dashboard to restrict where the SDK can be loaded:
The SDK will automatically check the requesting domain and block unauthorized usage.
๐ CDN vs NPM Installation
| Feature | CDN Installation | NPM Installation |
|---|---|---|
| Setup | Single script tag | npm install + import |
| Bundle Size | ~200KB (self-contained) | ~50KB (peer deps) |
| React Required | No | Yes |
| Auto-configuration | Yes (from dashboard) | Manual configuration |
| Global API | Yes | No |
| TypeScript Support | Limited | Full |
| Tree Shaking | No | Yes |
๐จ Troubleshooting
SDK Not Loading
- Check Network: Look for failed requests in DevTools Network tab
- Verify Application ID: Ensure it matches your dashboard exactly
- Check Domain: Make sure your domain is whitelisted (if configured)
- Console Errors: Look for JavaScript errors in the browser console
Configuration Not Applied
- Timing: Ensure
window.mossSettingsis set before the script tag - Validation: Check console for configuration validation errors
- Debug Mode: Enable debug mode to see detailed logs:
User Identification Issues
- Call After Load: Make sure to call
identify()after SDK initialization - Check Storage: User IDs are stored in localStorage for persistence
- Verify Format: Ensure user data follows the expected format
๐ง Advanced Configuration
Custom Configuration Fields
You can pass any custom data through the configuration object:Error Handling
๐ Analytics & Monitoring
The SDK automatically tracks:- Initialization success/failure
- User identification events
- Configuration updates
- Session management
- Error occurrences
๐ Next Steps
- Test Installation: Use the browser console to verify
window.MossSDKexists - Customize Settings: Configure your application in the Moss Dashboard
- Test User Flows: Try the
identify()andupdateConfig()methods - Monitor Usage: Check analytics in your dashboard
- Advanced Features: Explore the full SDK Reference
๐ Related Documentation
- NPM Installation - For React applications
- Quickstart Guide - Getting started with React
- SDK Reference - Complete API documentation
- Dashboard Guide - Managing your applications