Debug Mode

Use Debug Mode to see detailed logs, test your integration, and troubleshoot issues during development.

âš ī¸ Development Only: Debug mode logs sensitive information and affects performance. Always disable it in production!

Enable Debug Mode

Call enableDebug() before initializing the SDK:

JavaScript
// Enable debug mode FIRST
RewardedAd.enableDebug();

// Then initialize
RewardedAd.init({
    appId: "YOUR_APP_ID",
    apiKey: "YOUR_API_KEY",
    userId: "user_12345",
    
    onReward: function(reward) {
        console.log('Reward!', reward);
    }
});

What You'll See

With debug mode enabled, the console will show:

🐛 [BZZE Ads] Debug mode enabled
🔧 [BZZE Ads] Initializing SDK v2.0.0
✅ [BZZE Ads] SDK initialized successfully
đŸ“Ļ [BZZE Ads] Preloading 1 ad(s)...
🌐 [BZZE Ads] API Request: POST /v1/ads/request
📊 [BZZE Ads] Request params: {appId: "APP_123", userId: "user_456"}
✅ [BZZE Ads] Ad loaded: House Campaign (30s)
đŸ“ē [BZZE Ads] Showing ad: House Campaign
đŸ‘ī¸ [BZZE Ads] Ad is 50%+ visible for 2+ seconds (viewable impression tracked)
đŸŽŦ [BZZE Ads] Ad progress: 25%
đŸŽŦ [BZZE Ads] Ad progress: 50%
đŸŽŦ [BZZE Ads] Ad progress: 75%
✅ [BZZE Ads] Ad completed! User earned reward
💰 [BZZE Ads] Reward granted: {earned: true, timestamp: 1698789012345}

Disable Debug Mode

Turn off debug mode anytime:

JavaScript
// Disable debug logging
RewardedAd.disableDebug();

Debug Methods

getInfo()

Get SDK version and configuration:

JavaScript
const info = RewardedAd.getInfo();
console.log(info);

// Output:
// {
//     version: "2.0.0",
//     initialized: true,
//     appId: "APP_1234567890_abc",
//     userId: "user_12345",
//     preloadedAds: 1
// }

getAnalytics()

Get session analytics:

JavaScript
const analytics = RewardedAd.getAnalytics();
console.log(analytics);

// Output:
// {
//     impressions: 5,
//     completions: 4,
//     clicks: 1,
//     errors: 0,
//     viewableImpressions: 5,
//     fillRate: 100
// }

isAdAvailable()

Check if ads are ready:

JavaScript
if (RewardedAd.isAdAvailable()) {
    console.log('✅ Ads are ready!');
    enableAdButton();
} else {
    console.log('❌ No ads available');
    disableAdButton();
}

Common Debug Scenarios

Test Successful Ad Flow

JavaScript
RewardedAd.enableDebug();

RewardedAd.init({
    appId: "APP_1760726660483_6ohdjjgqm",
    apiKey: "bzze_fgpwe6uofk9",
    userId: "test_user_" + Date.now(),
    
    onAdLoaded: function(count) {
        console.log('✅ Test: Ad loaded!', count);
    },
    
    onAdShown: function() {
        console.log('✅ Test: Ad is playing');
    },
    
    onReward: function(reward) {
        console.log('✅ Test: Reward earned!', reward);
    },
    
    onClose: function() {
        console.log('â„šī¸ Test: Ad closed');
    }
});

// Show ad after 2 seconds
setTimeout(() => {
    console.log('đŸŽŦ Test: Showing ad...');
    RewardedAd.showAd({
        rewardPreview: "TEST: 100 coins"
    });
}, 2000);

Test Error Handling

JavaScript
RewardedAd.init({
    appId: "INVALID_APP_ID", // ❌ Intentionally wrong
    apiKey: "INVALID_KEY",
    userId: "test_user",
    
    onError: function(error) {
        console.error('✅ Test: Error caught!', error);
        console.log('Error code:', error.code);
        console.log('Error message:', error.message);
    }
});

RewardedAd.showAd(); // This will trigger onError

Test Rate Limiting

JavaScript
// Show 11 ads rapidly to trigger hourly limit (default: 10/hour)
for (let i = 0; i < 11; i++) {
    setTimeout(() => {
        console.log(\`Attempt \${i + 1}/11\`);
        RewardedAd.showAd();
    }, i * 3000); // 3 seconds apart
}

// After 10 ads, you should see:
// ⏰ [BZZE Ads] Rate limit reached. Wait 60 seconds.

Production Checklist

Before going live, make sure to:

  • ✅ Remove RewardedAd.enableDebug() call
  • ✅ Remove all console.log() test statements
  • ✅ Test with real App ID and API Key
  • ✅ Verify GDPR/COPPA compliance if needed
  • ✅ Test on mobile devices
  • ✅ Test with slow 3G network

Debug Tips

  • Open console early: Press F12 before loading your game
  • Filter logs: Type "BZZE" in console filter to see only SDK logs
  • Test on different devices: iOS, Android, Desktop
  • Simulate no-fill: Pause all campaigns in dashboard
  • Test VAST errors: Use invalid VAST URLs to trigger error codes

See Also