mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-30 23:14:37 +00:00
* Implement referral system with UI components and API integration - Added to document the referral system, including reward structure, rules, data model, migration, core services, and API endpoints. - Created component to display referral stats and allow users to apply referral codes. - Integrated referral functionality into the onboarding process with for applying referral codes. - Updated page to include the new . - Implemented API calls in for fetching referral stats and applying referral codes. - Added tests for the referral API to ensure proper functionality and data normalization. - Introduced device fingerprinting for referral code application to prevent abuse. This commit establishes a comprehensive referral system, enhancing user engagement and incentivizing referrals. * Update OLLAMA_BASE_URL to local development address * Enhance referral system and onboarding process - Added a new function to format reward rates from basis points to percentage for better display in the ReferralRewardsSection. - Improved loading state management in the referral stats loading process to prevent race conditions. - Updated the Onboarding component to handle referral step skipping more effectively, ensuring a smoother user experience. - Fixed a typo in the WelcomeStep component's button label for clarity. - Enhanced error handling in the referral API to provide clearer feedback on failures. These changes improve the usability and reliability of the referral system and onboarding experience.
21 lines
579 B
TypeScript
21 lines
579 B
TypeScript
const STORAGE_KEY = 'openhuman_device_fingerprint_v1';
|
|
|
|
/**
|
|
* Stable anonymous id for referral abuse signals (optional body/header on backend).
|
|
*/
|
|
export function getOrCreateDeviceFingerprint(): string {
|
|
try {
|
|
let v = localStorage.getItem(STORAGE_KEY);
|
|
if (!v) {
|
|
v =
|
|
typeof crypto !== 'undefined' && 'randomUUID' in crypto
|
|
? crypto.randomUUID()
|
|
: `fp_${Date.now()}_${Math.random().toString(36).slice(2, 12)}`;
|
|
localStorage.setItem(STORAGE_KEY, v);
|
|
}
|
|
return v;
|
|
} catch {
|
|
return `fp_ephemeral_${Date.now()}`;
|
|
}
|
|
}
|