React Native
Advanced Configuration
Learn about advanced configuration options for FeatureBuddy for React Native
Setting user data
You can set user data by calling the setUserData
function. This function takes an object with the following properties:
email
: The user's email.userMeta
: The user's metadata.
You can use the userMeta
to store any additional information about the user, e.g. their name, subscription tier & status, etc.
import { setUserData } from '@featurebuddy/react-native';
const apiKey = 'your-api-key';
await setUserData(apiKey, {
email: '[email protected]',
userMeta: { 'custom-key': 'custom-value' },
});
Sending metadata with requests
You can send metadata with requests by providing a meta
object to the Features
component.
It can be any key-value pairs.
Here is an example of some useful metadata you can send using the expo-application
and expo-device
packages:
import * as Device from 'expo-device';
import * as Application from 'expo-application';
import { Features } from '@featurebuddy/react-native';
const apiKey = 'your-api-key';
const meta = {
appVersion: Application.nativeApplicationVersion,
appBuild: Application.nativeBuildVersion,
deviceBrand: Device.brand,
deviceType: Device.deviceType ? Device.DeviceType : 'Unknown',
deviceYearClass: Device.deviceYearClass?.toString(),
deviceModelName: Device.modelName,
osName: Device.osName,
osVersion: Device.osVersion,
platformApiLevel: Device.platformApiLevel?.toString(),
}
export const FeedbackScreen = () => {
return <Features apiKey={apiKey} meta={meta} />;
};