tracklytic
Version:
Tracklytic Client - Real-time event tracking and analytics
189 lines (134 loc) โข 4.98 kB
Markdown
# ๐งช Tracklytic SDK Testing Guide
This guide will help you test the Tracklytic SDK to ensure it's working correctly with your Tracklytic instance.
## ๐ Prerequisites
1. **Tracklytic Account**: You need a Tracklytic account with a project set up
2. **API Token**: Get your API token from your Tracklytic dashboard
3. **Project ID**: Get your project ID from your Tracklytic dashboard
4. **Channel ID**: Get your channel ID from your Tracklytic dashboard
## ๐ Quick Start
### 1. Node.js Testing
```bash
# Navigate to the tl_js directory
cd tl_js
# Install dependencies (if not already done)
npm install
# Build the SDK
npm run build
# Edit the test file with your credentials
# Open test.js and replace:
# - 'your-api-token-here' with your actual API token
# - 'your-project-id' with your actual project ID
# - 'your-channel-id-here' with your actual channel ID
# Run the test
node test.js
```
### 2. Browser Testing
```bash
# Build the SDK for browser
npm run build:vite
# Open the browser test file
open test-browser.html
# or simply open test-browser.html in your browser
# Make sure to enter your API token, project ID, and channel ID in the form
```
## ๐ Test Coverage
The test files cover all major SDK functionality:
### Event Tracking
- โ
Simple event tracking
- โ
Page view tracking
- โ
Events with notifications
- โ
Events with custom tags
### User Identification
- โ
User profile creation/updates
- โ
Custom user properties
### Insights
- โ
Setting insight values
- โ
Incrementing insight values
### Development Mode
- โ
Testing with disabled tracking
- โ
Error handling
## ๐ง Configuration
### API Endpoint
The SDK is configured to use `https://api.tracklytic.de` as the base endpoint. If you need to change this, edit `src/constants.ts`:
```typescript
const TRACKLYTIC_BASE = 'https://your-api-endpoint.com';
```
### Development Mode
For development and testing, you can disable API calls:
```javascript
const tracklytic = new Tracklytic({
token: 'your-token',
project: 'your-project',
disableTracking: true // This prevents actual API calls
});
```
## ๐ Expected Results
### Successful Test Run
```
==================================================
Tracklytic SDK Test Suite
==================================================
๐ Starting Tracklytic SDK Tests...
๐ Test 1: Tracking a simple event...
โ
Event tracked successfully!
๐ Test 2: Tracking a page view...
โ
Page view tracked successfully!
๐ค Test 3: Identifying a user...
โ
User identified successfully!
๐ Test 4: Tracking an insight...
โ
Insight tracked successfully!
โ Test 5: Incrementing an insight...
โ
Insight incremented successfully!
๐ Test 6: Tracking an event with notification...
โ
Notification event tracked successfully!
๐ All tests completed successfully!
๐ Check your Tracklytic dashboard to see the events.
```
### Error Handling
If there are any issues, you'll see detailed error messages:
```
โ Test failed: HTTP Error Response: 401 Unauthorized
[Tracklytic] Failed to publish: : Please check our docs at https://docs.tracklytic.de
```
## ๐ Troubleshooting
### Common Issues
1. **401 Unauthorized**
- Check your API token is correct
- Ensure your token has the right permissions
2. **404 Not Found**
- Verify your project ID is correct
- Check if the project exists in your account
3. **Network Errors**
- Check your internet connection
- Verify the API endpoint is accessible
- Check if there are any firewall restrictions
4. **Build Errors**
- Run `npm install` to ensure all dependencies are installed
- Check that TypeScript is installed globally or locally
### Debug Mode
For more detailed debugging, you can modify the test files to log the full request/response:
```javascript
// Add this to see the actual API calls
console.log('Request body:', body);
console.log('Response status:', response.status);
console.log('Response body:', await response.text());
```
## ๐ฑ Browser Testing Tips
1. **Open Developer Tools**: Press F12 to open browser dev tools
2. **Check Network Tab**: Monitor API calls in the Network tab
3. **Console Logs**: Check the browser console for any errors
4. **CORS Issues**: If you see CORS errors, ensure your API endpoint allows browser requests
## ๐ฏ Next Steps
After successful testing:
1. **Integration**: Integrate the SDK into your application
2. **Production**: Update the API endpoint for production use
3. **Monitoring**: Set up monitoring for your Tracklytic events
4. **Documentation**: Check the main README.md for full API documentation
## ๐ Support
If you encounter any issues:
1. Check the [main README.md](README.md) for detailed documentation
2. Review the [Tracklytic API documentation](https://docs.tracklytic.de)
3. Check the browser console or Node.js logs for detailed error messages
4. Ensure your Tracklytic instance is running and accessible
Happy testing! ๐