APXOR React Native API Guide
APIs
Add the following import statement in every component where you use Apxor APIs
import RNApxorSDK from 'react-native-apxor-sdk';
UserId
Sets a unique user identifier. You can set it when user logged into application and reset it when users logged out
// Syntax
RNApxorSDK.setUserIdentifier("STRING");
// Example
RNApxorSDK.setUserIdentifier("<unique_user_id>");
To track events
// Syntax
RNApxorSDK.logAppEvent(event_name, properties[, isAggreagte]);
// Example
RNApxorSDK.logAppEvent("ADD_TO_CART", {
"userId": "johnwick@example.com",
"value": 1299,
"item": "Sony Head Phone 1201"
}[, false]);
To track client events
// Syntax
RNApxorSDK.logClientEvent(event_name, properties);
// Example
RNApxorSDK.logClientEvent("ADD_TO_CART", {
"userId": "johnwick@example.com",
"value": 1299,
"item": "Sony Head Phone 1201"
});
User Properties
Set unique user properties only when you need to add or update them. All the properties whose value is null
or undefined
will be ignored
// Syntax
RNApxorSDK.setUserCustomInfo(properties);
// Example
RNApxorSDK.setUserCustomInfo({
"Age": 10,
"Name": "John Wick"
});
Track Navigation
@react-navigation
, Apxor SDK automatically tracks screen navigation if you follow below mentioned steps
If you are already using Apxor's ApxNavigationContainer
is just a wrapper over NavigationContainer
which internally handles the route navigations (nested route navigations too) and take necessary actions within RNApxorSDK
To automatically track navigations, use ApxNavigationContainer
and pass the same props you pass to NavigationContainer
like below
Note
If you don't use
ApxNavigationContainer
and didn't log navigation events, walkthroughs might not work as expected.
import { ApxNavigationContainer } from 'react-native-apxor-sdk';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
function App() {
return (
<ApxNavigationContainer theme={yourTheme} linking={yourLinkingOptions} fallback={yourFallbackNode} {...others}>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name={"Home"} component={Home} />
<Stack.Screen name="Details" component={DetailsScreen}/>
<Stack.Screen name="FlatList" component={FlatListSample}/>
</Stack.Navigator>
</ApxNavigationContainer>
);
}
Otherwise use the following API to track navigations
// Syntax
RNApxorSDK.logNavigationEvent(screen_name);
// Example
RNApxorSDK.logNavigationEvent("LoginScreen");