Installation
TraceScout can be installed in multiple ways depending on your project setup and requirements.
CDN Installation (Recommended)
The simplest way to add TraceScout is via our CDN. This is recommended for most use cases.
Production Build
<script src="https://cdn.tracescout.com/sdk/tracescout.min.js"></script>
- Size: ~140KB minified
- Best for: Production environments
Development Build
<script src="https://cdn.tracescout.com/sdk/tracescout.dev.umd.js"></script>
- Size: ~480KB with source maps
- Best for: Development and debugging
- Features: Verbose logging, source maps, auto-initialization
npm Installation
For modern JavaScript projects using bundlers like webpack, Vite, or Rollup:
npm install @tracescout/suite
Or with yarn:
yarn add @tracescout/suite
Then import and initialize:
import TraceScout from '@tracescout/suite';
TraceScout.init({
apiKey: 'ts_api_xxx',
organizationId: 'your-organization-id',
projectId: 'your-project-id',
environment: 'production'
});
Package Options
TraceScout offers different packages for different needs:
| Package | Size | Description |
|---------|------|-------------|
| @tracescout/suite | ~140KB | Full SDK with all features |
| @tracescout/core | ~110KB | Core monitoring without recording |
| @tracescout/lite | ~70KB | Lightweight version for performance-critical apps |
Self-Hosted CDN
If you prefer to host the SDK yourself:
- Download the SDK from the dashboard
- Host on your own CDN or server
- Reference your hosted version:
<script src="https://your-cdn.com/tracescout.min.js"></script>
Version Updates
When self-hosting, remember to update the SDK manually when new versions are released.
Environment Variables
For framework projects, we recommend using environment variables:
# .env.local
NEXT_PUBLIC_TRACESCOUT_API_KEY=ts_api_xxx
NEXT_PUBLIC_TRACESCOUT_ORGANIZATION_ID=xxx-xxx-xxx
NEXT_PUBLIC_TRACESCOUT_PROJECT_ID=xxx-xxx-xxx
Then in your code:
TraceScout.init({
apiKey: process.env.NEXT_PUBLIC_TRACESCOUT_API_KEY,
organizationId: process.env.NEXT_PUBLIC_TRACESCOUT_ORGANIZATION_ID,
projectId: process.env.NEXT_PUBLIC_TRACESCOUT_PROJECT_ID,
environment: process.env.NODE_ENV
});
Verification
After installation, verify the SDK is working:
- Open browser developer tools
- Check the Console tab for initialization messages
- Check the Network tab for requests to
api.tracescout.com
[TraceScout] ✅ SDK Initialized Successfully
[TraceScout] Session ID: ts_1234567890_abc123
Troubleshooting
SDK Not Loading
If the SDK isn't loading, check:
- Script tag is placed correctly in your HTML
- No Content Security Policy (CSP) blocking the CDN
- No JavaScript errors before the SDK loads
CORS Issues
If you see CORS errors, ensure your domain is whitelisted in the project settings.