DataClaus React Native SDK - User identity, ad revenue sharing, sensor data collection, and fraud detection
npm install @dataclaus/sdk-react-native> React Native SDK for DataClaus - Monetize user data fairly with revenue sharing.


DataClaus enables developers to share advertising and data revenue with their users. This SDK provides:
- User Identity Linking - Connect your users to DataClaus accounts for earnings tracking
- Ad Revenue Components - Banner, interstitial, and rewarded ads with automatic revenue sharing
- Sensor Data Collection - Collect behavioral data to earn from data marketplace
- Fraud Detection - AI-powered bot detection to ensure payouts go to real humans
``bash`
npm install @dataclaus/sdk-react-nativeor
yarn add @dataclaus/sdk-react-native
`bash`
npm install react react-native
For enhanced device fingerprinting:
`bash`
npm install react-native-device-info
For sensor data collection:
`bash`
npm install expo-sensors
After user authentication, link them to DataClaus:
`tsx
import { useIdentity } from '@dataclaus/sdk-react-native';
function AfterLogin({ user }) {
const { linkUser, isLinked, earnings } = useIdentity({
apiUrl: 'https://api.dataclaus.io',
applicationId: 'YOUR_APP_ID',
});
useEffect(() => {
linkUser({
externalUserId: user.id,
email: user.email, // Optional, helps cross-app matching
});
}, [user]);
return (
{isLinked && (
)}
);
}
`
Wrap your app with AdProvider and display ads:
`tsx
import { AdProvider, BannerAd, useRewardedAd } from '@dataclaus/sdk-react-native';
// In your app root
function App() {
const { linkedUser } = useIdentity({ ... });
if (!linkedUser) return
return (
applicationId: 'YOUR_APP_ID',
userToken: linkedUser.userToken,
testMode: __DEV__,
}}>
);
}
// In your screens
function HomeScreen() {
const { isLoaded, load, show } = useRewardedAd({
onRewarded: (reward) => {
// Give user in-app currency
addCoins(reward.amount);
},
onPaidEvent: (impression) => {
console.log(Ad earned $${impression.revenue});
},
});
useEffect(() => { load(); }, []);
return (
{/ Banner at bottom of screen /}
{/ Rewarded ad button /}
disabled={!isLoaded}
>
);
}
`
For higher earnings, collect behavioral data:
`tsx
import { useDataClaus, useSensorTracking } from '@dataclaus/sdk-react-native';
import { Accelerometer, Gyroscope } from 'expo-sensors';
function DataCollection() {
const { collector, startCollection, stopCollection } = useDataClaus({
backendUrl: 'https://your-backend.com',
userId: user.id,
debug: __DEV__,
});
// Auto-track sensors
useSensorTracking(collector, { Accelerometer, Gyroscope });
useEffect(() => {
startCollection();
return () => stopCollection();
}, []);
return
}
`
#### useIdentity(config)
React hook for user identity management.
`ts
interface UserIdentityConfig {
apiUrl: string; // DataClaus API URL
applicationId: string; // Your app ID from dashboard
debug?: boolean; // Enable console logging
}
interface UseIdentityResult {
linkedUser: LinkedUser | null;
linkUser: (request: LinkUserRequest) => Promise
earnings: UserEarnings | null;
refreshEarnings: () => Promise
isLoading: boolean;
isLinked: boolean;
logout: () => void;
error: string | null;
}
`
#### linkUser(request)
Links an external user to DataClaus.
`ts
interface LinkUserRequest {
externalUserId: string; // Your user ID
email?: string; // Optional email for cross-app matching
phone?: string; // Optional phone for matching
}
interface LinkedUser {
dataclausUserId: string;
userToken: string; // Use for ad requests
isNewUser: boolean;
walletId: string;
}
`
#### AdProvider
Context provider for ads.
`tsx`
applicationId: string;
userToken: string;
testMode?: boolean; // Default: true
debug?: boolean;
}}>
{children}
#### BannerAd
Display a banner advertisement.
`tsx`
onAdLoaded={() => {}}
onAdError={(error) => {}}
onPaidEvent={(impression) => {}}
style={ViewStyle}
/>
#### useInterstitialAd()
Hook for full-screen interstitial ads.
`ts
const { isLoaded, isLoading, load, show, error } = useInterstitialAd();
// Load when screen mounts
useEffect(() => { load(); }, []);
// Show at natural break point
const handleLevelComplete = () => {
if (isLoaded) show();
};
`
#### useRewardedAd(options)
Hook for rewarded ads where users watch for rewards.
`tsUser earned ${reward.amount} ${reward.type}
const { isLoaded, load, show, reward } = useRewardedAd({
onRewarded: (reward) => {
console.log();Ad revenue: $${impression.revenue}
},
onPaidEvent: (impression) => {
console.log();`
},
});
#### useDataClaus(config)
Main hook for data collection.
`ts`
const {
collector,
isCollecting,
startCollection,
stopCollection,
trackScreenView,
trackCustomEvent,
} = useDataClaus({
backendUrl: string;
userId: string;
sessionId?: string;
collectionInterval?: number; // Default: 100ms
batchSize?: number; // Default: 50 events
flushInterval?: number; // Default: 5000ms
debug?: boolean;
});
#### useSensorTracking(collector, sensors)
Automatically tracks accelerometer and gyroscope data.
`ts
import { Accelerometer, Gyroscope } from 'expo-sensors';
useSensorTracking(collector, { Accelerometer, Gyroscope }, {
interval: 100, // Collection interval in ms
});
`
#### useFraudDetection(config)
Monitor for bot/emulator signals.
`ts
const { fraudScore, isBot, signals } = useFraudDetection({
sensitivityLevel: 'medium',
});
if (isBot) {
// Don't send data - won't earn rewards anyway
}
`
When ads are shown, revenue is split automatically:
| Recipient | Share | Example ($10 CPM) |
|-----------|-------|-------------------|
| User | 50-90% (configurable) | $7.00 |
| Developer | 5-45% | $2.50 |
| Platform | 5% (fixed) | $0.50 |
Configure your app's revenue share in the DataClaus dashboard.
Ads won't track properly without a linked user:
`tsx
// ❌ Bad - ads won't attribute revenue
// ✅ Good - wait for user linking
{linkedUser && (
)}
`
`tsx`
testMode: __DEV__, // Uses test ads and simulated revenue
}}>
`tsx
const { error } = useIdentity(config);
if (error) {
// Still let users use the app
return
}
`
`tsx
// Load immediately when screen mounts
useEffect(() => {
load();
}, []);
// Reload after showing
const handlePress = async () => {
await show();
load(); // Preload next ad
};
`
This package includes TypeScript definitions. All exports are fully typed.
`ts`
import type {
LinkedUser,
UserEarnings,
AdImpression,
AdType
} from '@dataclaus/sdk-react-native';
1. Check your applicationId is correct
2. Ensure ads are enabled in the dashboard
3. Verify your app is approved for production ads
1. Check network connectivity
2. Verify apiUrl` points to correct server
3. Check application ID matches dashboard
Users with scores below 0.5 don't earn rewards:
- Encourage natural app usage
- Don't incentivize fake engagement
- Our AI detects automated patterns
- Documentation: docs.dataclaus.io
- Dashboard: dashboard.dataclaus.io
- Discord: discord.gg/dataclaus
- Email: support@dataclaus.io
MIT © DataClaus