TypeScript Types & Interfaces
Complete type definitions for the InfluTo SDK
Core Types
InfluToConfig
Configuration for SDK initialization
interface InfluToConfig {
apiKey: string // Your API key from dashboard
debug?: boolean // Enable debug logging (default: false)
apiUrl?: string // Internal use only
}
// Usage
await InfluTo.initialize({
apiKey: 'it_live_...',
debug: __DEV__
});AttributionResult
Result from checkAttribution()
interface AttributionResult {
attributed: boolean // Was user referred?
referralCode?: string // Referral code if attributed
attributionMethod?: string // e.g., "ip_fingerprint_match"
clickedAt?: string // ISO timestamp of click
confidence?: number // 0.0-1.0 confidence score
message?: string // Human-readable message
}
// Example
{
attributed: true,
referralCode: "FITGURU30",
attributionMethod: "ip_fingerprint_match",
clickedAt: "2026-01-01T10:30:00Z",
confidence: 0.95,
message: "Attribution found"
}Campaign
Campaign information from getActiveCampaigns()
interface Campaign {
id: string
name: string
description?: string
commission_percentage?: number
}
// Example
{
id: "campaign_123",
name: "Launch Campaign",
description: "30% commission for all influencers",
commission_percentage: 30.0
}TrackEventOptions
Parameters for trackEvent()
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
{
eventType: "trial_started",
appUserId: "user_123",
properties: {
trial_days: 7,
product_id: "premium_monthly"
},
referralCode: "FITGURU30"
}Promo Code Types
CodeValidationResult
Result from validateCode() and applyCode()
interface CodeValidationResult {
valid: boolean // Is code valid?
code?: string // Normalized code (uppercase)
campaign?: {
id: string
name: string
description?: string
commission_percentage: number
campaign_type: string
}
influencer?: {
name: string
social_handle?: string
follower_count?: number
}
custom_data?: Record<string, any>
message?: string // Success message
error?: string // Error message if invalid
error_code?: 'INVALID_FORMAT' | 'CODE_NOT_FOUND' | 'NETWORK_ERROR'
}
// Valid code example
{
valid: true,
code: "FITGURU30",
campaign: {
id: "camp_123",
name: "Fitness Program",
description: "Special trial offer",
commission_percentage: 30,
campaign_type: "public"
},
influencer: {
name: "John Doe",
social_handle: "@fitguru",
follower_count: 50000
},
message: "Valid code! Referred by John Doe"
}
// Invalid code example
{
valid: false,
error: "Code not found or inactive",
error_code: "CODE_NOT_FOUND"
}SetCodeResult
Result from setReferralCode()
interface SetCodeResult {
success: boolean // Was code set successfully?
code?: string // Normalized code
message: string // Success/error message
campaign?: {
id: string
name: string
}
}
// Success example
{
success: true,
code: "FITGURU30",
message: "Referral code set successfully",
campaign: {
id: "camp_123",
name: "Fitness Program"
}
}
// Error example
{
success: false,
message: "Failed to set code: Network error"
}UI Component Types
ReferralCodeInputProps
Props for <ReferralCodeInput /> component
interface ReferralCodeInputProps {
// Behavior
autoPrefill?: boolean
autoValidate?: boolean
showSkipButton?: boolean
validateOnBlur?: boolean
appUserId?: string
// Callbacks
onValidated?: (result: CodeValidationResult) => void
onApplied?: (result: CodeValidationResult) => void
onSkip?: () => void
// Styling
colors?: {
primary?: string
success?: string
error?: string
text?: string
textSecondary?: string
background?: string
border?: string
inputBackground?: string
}
fonts?: {
family?: string
sizeTitle?: number
sizeInput?: number
sizeButton?: number
sizeMessage?: number
}
labels?: {
title?: string
subtitle?: string
placeholder?: string
validateButton?: string
skipButton?: string
validatingMessage?: string
validMessage?: string
invalidMessage?: string
errorMessage?: string
prefilledMessage?: string
}
style?: {
container?: ViewStyle
titleContainer?: ViewStyle
title?: TextStyle
subtitle?: TextStyle
inputContainer?: ViewStyle
input?: TextStyle
buttonContainer?: ViewStyle
validateButton?: ViewStyle
validateButtonText?: TextStyle
skipButton?: ViewStyle
skipButtonText?: TextStyle
messageContainer?: ViewStyle
messageText?: TextStyle
}
}Internal Types
DeviceInfo
Device fingerprint data (internal)
interface DeviceInfo {
platform: 'ios' | 'android'
deviceId?: string
deviceBrand?: string
deviceModel?: string
osVersion?: string
screenResolution?: string
timezone?: string
language?: string
}Type Guards
Check Attribution Result
function isAttributed(result: AttributionResult): result is Required<AttributionResult> {
return result.attributed === true && !!result.referralCode;
}
// Usage
const attribution = await InfluTo.checkAttribution();
if (isAttributed(attribution)) {
// TypeScript knows referralCode exists
console.log(attribution.referralCode); // No optional chaining needed
}Check Validation Result
function isValidCode(result: CodeValidationResult): boolean {
return result.valid && !!result.campaign;
}
const validation = await InfluTo.validateCode(code);
if (isValidCode(validation)) {
// Safe to access campaign
const commission = validation.campaign.commission_percentage;
}Importing Types
Import Everything
import InfluTo from '@influto/react-native-sdk';
import type {
InfluToConfig,
AttributionResult,
Campaign,
TrackEventOptions,
CodeValidationResult,
SetCodeResult,
DeviceInfo
} from '@influto/react-native-sdk';Import UI Types
import { ReferralCodeInput } from '@influto/react-native-sdk/ui';
import type { ReferralCodeInputProps } from '@influto/react-native-sdk/ui';Generic Helpers
Type-Safe Event Tracking
type AppEvent =
| { type: 'trial_started'; trialDays: number }
| { type: 'paywall_viewed'; screen: string }
| { type: 'feature_used'; feature: string }
async function trackAppEvent(userId: string, event: AppEvent) {
await InfluTo.trackEvent({
eventType: event.type,
appUserId: userId,
properties: event
});
}
// Usage (type-safe!)
await trackAppEvent(userId, {
type: 'trial_started',
trialDays: 7 // TypeScript enforces this property
});