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: 1

Verify API Key

// If invalid key:
// Error: "API request failed: 401 - Unauthorized"

// If valid:
// [InfluTo] SDK initialized successfully

Test 2: Link Attribution

Create Test Campaign

  1. Dashboard → Campaigns → Create Campaign
  2. Add test influencer or use your own email
  3. Get referral link: https://influ.to/yourapp/TESTCODE

Test Attribution Flow

  1. Click link: Open referral link in mobile browser
  2. Install app: Or use existing installation
  3. Open app: Launch your app
  4. 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 automatically

Verify 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

  1. Use RevenueCat sandbox mode
  2. Set test referral code: await Purchases.setAttributes( referral_code: TESTCODE )
  3. Make sandbox purchase

Verify Webhook Received

  1. Dashboard → Analytics → Recent Events
  2. Should see: INITIAL_PURCHASE event
  3. Environment: SANDBOX
  4. Referral code: TESTCODE
  5. Status: Processed or Error

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.497

Check Dashboard

  1. Dashboard → Analytics → Conversions
  2. Find your test conversion
  3. 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

  1. Setup: Create test campaign with test code
  2. Attribution: Click link or enter code manually
  3. Verification: Check SDK detects code
  4. Purchase: Make sandbox purchase
  5. Webhook: Verify webhook received
  6. Commission: Check commission calculated
  7. 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.997

Debugging Tools

SDK Debug Logs

await InfluTo.initialize({ debug: true });

// See all SDK activity:
// - API calls
// - Attribution matches
// - RevenueCat integration
// - Errors and warnings

Clear 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_123

Common 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

  1. Start with 1-2 test influencers
  2. Use real (small) wallet funding
  3. Monitor closely for first week
  4. Verify payouts process correctly
  5. Scale up gradually

Monitoring

  • Watch webhook logs daily
  • Check attribution accuracy
  • Verify commission calculations
  • Monitor wallet burn rate

Next Steps

  1. Common issues and solutions
  2. Frequently asked questions