SDK Core Methods
Complete API reference for all InfluTo SDK methods
Method Overview
The InfluTo SDK provides 11 methods for attribution and event tracking:
| Method | Purpose | Required |
|---|---|---|
initialize() | Initialize SDK | Yes |
checkAttribution() | Check if user came from referral | Yes |
identifyUser() | Link user ID | Recommended |
trackEvent() | Track custom events | Optional |
getActiveCampaigns() | Get campaign list | Optional |
getReferralCode() | Get stored code | Optional |
getPrefilledCode() | Get code for pre-fill | Optional |
validateCode() | Validate promo code | Optional |
setReferralCode() | Apply promo code | Optional |
applyCode() | Validate + apply code | Optional |
clearAttribution() | Clear stored data | Testing only |
initialize(config)
Initialize the InfluTo SDK
Parameters
interface InfluToConfig {
apiKey: string // Required: Your API key from dashboard
debug?: boolean // Optional: Enable debug logging (default: false)
apiUrl?: string // Internal: Custom API URL (testing only)
}Returns
Promise<void>
Example
await InfluTo.initialize({
apiKey: 'it_live_abc123...',
debug: __DEV__ // Enable logs in development
});
// SDK is now ready to useWhen to Call
- Call once when app starts
- After user grants tracking permission (iOS 14+)
- Before calling any other SDK methods
Errors
Invalid API key- Check key is correctNetwork error- Check internet connection
checkAttribution()
Check if user was referred by an influencer
Returns
Promise<AttributionResult>
interface AttributionResult {
attributed: boolean // Was user referred?
referralCode?: string // Referral code if attributed
attributionMethod?: string // How attribution was matched
clickedAt?: string // When link was clicked
confidence?: number // Attribution confidence (0.0-1.0)
message?: string // Human-readable message
}Example - Attributed User
const attribution = await InfluTo.checkAttribution();
if (attribution.attributed) {
console.log('Referral code:', attribution.referralCode);
// "FITGURU30"
console.log('Clicked at:', attribution.clickedAt);
// "2026-01-01T10:30:00Z"
console.log('Method:', attribution.attributionMethod);
// "ip_fingerprint_match"
// ✅ SDK automatically set this in RevenueCat:
// await Purchases.setAttributes({ referral_code: 'FITGURU30' });
showTrialPaywall();
} else {
console.log('Organic user');
showRegularPaywall();
}Example - Organic User
const attribution = await InfluTo.checkAttribution();
// {
// attributed: false,
// message: "No attribution found"
// }
// User installed app directly (no influencer link)How It Works
- Sends device fingerprint to InfluTo API
- Matches against recent link clicks (72-hour window)
- If match found: Returns referral code
- Automatically sets code in RevenueCat
- Caches result locally (no repeated calls)
When to Call
- During app onboarding (first launch)
- After
initialize() - Only needed once (result is cached)
identifyUser(appUserId, properties?)
Link user with their app user ID
Parameters
appUserId: string // Required: User's ID
properties?: Record<string, any> // Optional: Custom user propertiesReturns
Promise<void>
Example
// Basic identification
const customerInfo = await Purchases.getCustomerInfo();
await InfluTo.identifyUser(customerInfo.originalAppUserId);
// With custom properties
await InfluTo.identifyUser(userId, {
plan: 'premium',
registration_date: '2026-01-01',
user_segment: 'high_value'
});When to Call
- After user completes onboarding
- When you have their RevenueCat ID
- Before user makes first purchase
Why It's Important
This links the device fingerprint with the actual user ID that RevenueCat will send in webhooks, ensuring accurate attribution.
trackEvent(options)
Track custom analytics events
Parameters
interface TrackEventOptions {
eventType: string // Required: Event name
appUserId: string // Required: User ID
properties?: Record<string, any> // Optional: Event data
referralCode?: string // Optional: Associated code
}Example
// Trial started
await InfluTo.trackEvent({
eventType: 'trial_started',
appUserId: userId,
properties: {
trial_days: 7,
product_id: 'monthly_premium',
source: 'onboarding'
}
});
// Feature usage
await InfluTo.trackEvent({
eventType: 'workout_completed',
appUserId: userId,
properties: {
workout_type: 'strength',
duration_minutes: 45
},
referralCode: referralCode // Optional: link to referral
});Common Events
trial_startedpaywall_viewedsubscription_initiatedonboarding_completedfeature_discovered
getActiveCampaigns()
Get list of active public campaigns
Returns
Promise<Campaign[]>
interface Campaign {
id: string
name: string
description?: string
commission_percentage?: number
}Example
const campaigns = await InfluTo.getActiveCampaigns();
campaigns.forEach(campaign => {
console.log(`${campaign.name}: ${campaign.commission_percentage}%`);
});
// Output:
// Launch Campaign: 30%
// VIP Program: 35%Use Cases
- Show available promotions in-app
- Let users choose which campaign to join
- Display commission rates
getReferralCode()
Get stored referral code
Returns
Promise<string | null>
Example
const code = await InfluTo.getReferralCode();
if (code) {
console.log('Stored code:', code); // "FITGURU30"
} else {
console.log('No code stored');
}Use Cases
- Display current referral code in UI
- Check if user has a code applied
- Conditional UI based on code existence
clearAttribution()
Clear all stored attribution data
Returns
Promise<void>
Example
await InfluTo.clearAttribution();
// Now user appears as organic
const attribution = await InfluTo.checkAttribution();
// { attributed: false }Use Cases
- Testing: Reset state between tests
- User logout: Clear user-specific data
- Development: Test different attribution scenarios
⚠️ Production Warning
Don't call this in production! It will break attribution for users who legitimately clicked referral links. Only use for testing and development.
Error Handling
Network Errors
try {
await InfluTo.initialize({ apiKey: '...' });
} catch (error) {
console.error('SDK init failed:', error);
// Continue anyway - SDK will work offline
// Attribution will retry on next launch
}Invalid API Key
// SDK throws error immediately
await InfluTo.initialize({ apiKey: 'invalid' });
// Error: "API request failed: 401 - Unauthorized"
// Check your API key in dashboardSDK Not Initialized
// Calling methods before initialize()
const attribution = await InfluTo.checkAttribution();
// Error: "InfluTo SDK not initialized. Call InfluTo.initialize() first."Debug Mode
Enable Logging
await InfluTo.initialize({
apiKey: '...',
debug: true // or __DEV__ for development only
});
// You'll see logs like:
// [InfluTo] Initializing SDK...
// [InfluTo] SDK initialized successfully
// [InfluTo] Active campaigns: 3
// [InfluTo] ✅ Attribution found: FITGURU30
// [InfluTo] ✅ Referral code set in RevenueCat automaticallyProduction Logs
await InfluTo.initialize({
apiKey: '...',
debug: false // No logs in production
});
// Only errors are logged
// No performance impactBest Practices
Initialization
- ✓ Initialize once on app start
- ✓ Initialize RevenueCat first, then InfluTo
- ✓ Use environment variables for API keys
- ✗ Don't initialize multiple times
- ✗ Don't hardcode API keys
Attribution Checking
- ✓ Call during onboarding flow
- ✓ Check result before showing paywall
- ✓ Use attribution to customize user experience
- ✗ Don't call on every app launch (cached)
User Identification
- ✓ Use RevenueCat's
originalAppUserId - ✓ Call after user completes signup
- ✓ Include useful properties for segmentation
- ✗ Don't use email or PII as user ID
TypeScript Support
Full TypeScript definitions included:
import InfluTo from '@influto/react-native-sdk';
import type {
InfluToConfig,
AttributionResult,
Campaign,
TrackEventOptions,
CodeValidationResult
} from '@influto/react-native-sdk';
// Full autocomplete and type safety!
const result: AttributionResult = await InfluTo.checkAttribution();Performance
Network Calls
initialize(): 1 call per app launch (~50ms)checkAttribution(): 1 call per install (~100ms, then cached)identifyUser(): 1 call per user (~50ms)trackEvent(): Fire-and-forget (~30ms)
Storage
- Attribution: Stored in AsyncStorage (~1KB)
- Offline-first: Works without network
- Auto-retry: Failed calls retry automatically