Debugging & Performance
Debug SDK issues with built-in logging and monitoring tools
The SDK provides debugging tools to help you troubleshoot issues and monitor API interactions during development.
Debug Mode
Enable detailed logging for development and troubleshooting:
Debug Output Examples
Custom Logging
Implement custom logging for production monitoring:
Response Utilities
The SDK provides utilities for working with Response objects:
Performance Monitoring
Request Timing
Monitor request duration in your application:
Memory Usage
Monitor SDK memory usage:
Common Issues & Solutions
Token Management Issues
Token refresh loops
Token refresh loops
Problem: Infinite token refresh attempts
Solution: Check token storage and refresh token validity
Cross-tab token sync issues
Cross-tab token sync issues
Problem: Tokens not syncing between browser tabs
Solution: Use BrowserTokenStorage which automatically syncs via localStorage
API Request Issues
CORS errors
CORS errors
Problem: Cross-origin request blocked
Solution: Verify your domain is allowlisted with Commerce Engine support
Network timeouts
Network timeouts
Problem: Requests timing out
Solution: Configure appropriate timeout and check network conditions
Error Monitoring
Integration with Error Tracking
Error Pattern Analysis
Environment-Specific Debugging
Development Environment
Production Environment
Best Practices
Enable Debug in Development
Always enable debug mode during development to catch issues early
Monitor Error Rates
Track error patterns and response times to identify performance issues
Use Appropriate Timeouts
Set reasonable timeouts based on your application’s needs and network conditions
Implement Custom Logging
Create custom loggers for different environments and monitoring requirements
Cross-References
- Error Handling: Error Handling Guide for comprehensive error management
- Token Management: Token Management for authentication debugging
- API Reference: API Reference for endpoint-specific debugging
The debugging features help you understand SDK behavior during development. For production applications, implement appropriate monitoring and error tracking to maintain visibility into API performance.