Testing Your Integration
Verify attribution, webhooks, and commission tracking work correctly
Testing Checklist
- ✓ SDK initialization
- ✓ Attribution detection
- ✓ RevenueCat attribute setting
- ✓ Webhook processing
- ✓ Commission calculation
Test 1: SDK Initialization
Enable Debug Mode
await InfluTo.initialize({
apiKey: 'it_test_...', // Use test API key
debug: true // See all logs
});
// Look for:
// [InfluTo] Initializing SDK...
// [InfluTo] API URL: https://influ.to/api
// [InfluTo] SDK initialized successfully
// [InfluTo] Active campaigns: 1Verify API Key
// If invalid key:
// Error: "API request failed: 401 - Unauthorized"
// If valid:
// [InfluTo] SDK initialized successfullyTest 2: Link Attribution
Create Test Campaign
- Dashboard → Campaigns → Create Campaign
- Add test influencer or use your own email
- Get referral link:
https://influ.to/yourapp/TESTCODE
Test Attribution Flow
- Click link: Open referral link in mobile browser
- Install app: Or use existing installation
- Open app: Launch your app
- Check logs: Should see attribution detected
Expected Logs
[InfluTo] Attribution found in storage
// or
[InfluTo] Tracking install...
[InfluTo] ✅ Attribution found: TESTCODE
[InfluTo] ✅ Referral code set in RevenueCat automaticallyVerify in Code
const attribution = await InfluTo.checkAttribution();
console.log('Attributed:', attribution.attributed);
// Expected: true
console.log('Code:', attribution.referralCode);
// Expected: "TESTCODE"
console.log('Method:', attribution.attributionMethod);
// Expected: "ip_fingerprint_match"
// Verify in RevenueCat
const customerInfo = await Purchases.getCustomerInfo();
const attributes = customerInfo.entitlements.all;
console.log('RC attributes:', attributes);
// Expected: { referral_code: "TESTCODE" }Test 3: Manual Code Entry
Test validateCode()
const result = await InfluTo.validateCode('TESTCODE');
console.log('Valid:', result.valid);
// Expected: true
console.log('Campaign:', result.campaign);
// Expected: { name: "Test Campaign", commission_percentage: 30, ... }
console.log('Influencer:', result.influencer);
// Expected: { name: "...", social_handle: "...", ... }Test applyCode()
const result = await InfluTo.applyCode('TESTCODE', userId);
console.log('Valid:', result.valid);
// Expected: true
console.log('Applied:', result.applied);
// Expected: true
// Verify in RevenueCat
const customerInfo = await Purchases.getCustomerInfo();
console.log(customerInfo.entitlements.all.referral_code);
// Expected: "TESTCODE"Test 4: Webhook Processing
Make Test Purchase
- Use RevenueCat sandbox mode
- Set test referral code:
await Purchases.setAttributes( referral_code: TESTCODE ) - Make sandbox purchase
Verify Webhook Received
- Dashboard → Analytics → Recent Events
- Should see:
INITIAL_PURCHASEevent - Environment:
SANDBOX - Referral code:
TESTCODE - Status:
ProcessedorError
Check Processing Details
Event Details:
Type: INITIAL_PURCHASE
User ID: user_123
Product: premium_monthly
Price: $9.99
Referral Code: TESTCODE
Commission: $2.997 (30%)
Platform Fee: $0.50 (5%)
Status: Processed ✓Test 5: Commission Calculation
Verify Math
Subscription Price: $9.99
Commission Rate: 30%
Platform Fee: 5%
Expected Calculation:
Commission to influencer: $9.99 × 0.30 = $2.997
Platform fee: $9.99 × 0.05 = $0.4995 ≈ $0.50
Net to influencer: $2.997 - $0.00 = $2.997
Total cost to you: $2.997 + $0.50 = $3.497Check Dashboard
- Dashboard → Analytics → Conversions
- Find your test conversion
- Verify amounts match expected calculation
Test 6: Sandbox vs Production
Sandbox Mode
- Use for testing without real money
- Events logged but don't affect production stats
- No wallet charges
- No actual payouts
Production Mode
- Real purchases tracked
- Real commissions calculated
- Wallet charged
- Influencers paid monthly
Switch Modes
// Sandbox (for testing)
Purchases.configure({
apiKey: 'rcpk_ios_...',
environment: Purchases.SANDBOX // ← Sandbox mode
});
// Production (for real users)
Purchases.configure({
apiKey: 'rcpk_ios_...'
// No environment = production
});Test 7: End-to-End Flow
Complete Test Scenario
- Setup: Create test campaign with test code
- Attribution: Click link or enter code manually
- Verification: Check SDK detects code
- Purchase: Make sandbox purchase
- Webhook: Verify webhook received
- Commission: Check commission calculated
- Stats: Verify affiliate stats updated
Expected Results
✓ Attribution detected: TESTCODE
✓ RevenueCat attribute set: referral_code = TESTCODE
✓ Purchase completed: $9.99 sandbox
✓ Webhook received: INITIAL_PURCHASE
✓ Commission calculated: $2.997
✓ Affiliate stats updated:
Total conversions: 1
Total revenue: $9.99
Pending commission: $2.997Debugging Tools
SDK Debug Logs
await InfluTo.initialize({ debug: true });
// See all SDK activity:
// - API calls
// - Attribution matches
// - RevenueCat integration
// - Errors and warningsClear Attribution (Testing Only)
// Reset SDK state for testing
await InfluTo.clearAttribution();
// Now user appears as organic
const attribution = await InfluTo.checkAttribution();
// { attributed: false }
// WARNING: Never use in production!View Stored Data
import AsyncStorage from '@react-native-async-storage/async-storage';
// Get all InfluTo data
const keys = await AsyncStorage.getAllKeys();
const influtoKeys = keys.filter(k => k.startsWith('@influto/'));
const data = await AsyncStorage.multiGet(influtoKeys);
data.forEach(([key, value]) => {
console.log(key + ':', value);
});
// Output:
// @influto/attribution: {"attributed":true,"referralCode":"TESTCODE",...}
// @influto/referral_code: TESTCODE
// @influto/app_user_id: user_123Common Test Failures
Attribution Not Detected
- Clear app data and retry
- Check attribution window (72 hours default)
- Verify IP hasn't changed (VPN/proxy can break matching)
- Check device fingerprint hasn't changed
Webhook Not Received
- Check RevenueCat webhook logs
- Verify webhook URL is correct
- Check authorization header
- Look for 401/404 errors
Commission Not Calculated
- Verify referral_code in webhook payload
- Check campaign is active
- Verify wallet has balance
- Check for processing errors in dashboard
Production Testing
Soft Launch
- Start with 1-2 test influencers
- Use real (small) wallet funding
- Monitor closely for first week
- Verify payouts process correctly
- Scale up gradually
Monitoring
- Watch webhook logs daily
- Check attribution accuracy
- Verify commission calculations
- Monitor wallet burn rate