Skip to content

Instantly share code, notes, and snippets.

@jim-at-jibba
Created December 6, 2021 08:59
Show Gist options
  • Save jim-at-jibba/a6957a5e34c7089ce219d59eb4d2c648 to your computer and use it in GitHub Desktop.
Save jim-at-jibba/a6957a5e34c7089ce219d59eb4d2c648 to your computer and use it in GitHub Desktop.
Pendo Nav implimentation
function* getPendoUserData(userInfo: UserInfoQuery["userInfo"]) {
const { firstName, lastName } = userInfo;
const activeBusinessUnit = userInfo?.businessUnits[0];
const farmAnimalTypes = activeBusinessUnit?.farmAnimalTypes.map((species) => species.name);
console.log({ activeBusinessUnit });
const pendoUser = {
visitorId: `${firstName} ${lastName}`,
accountId: activeBusinessUnit?.id,
visitorData: {
firstName,
lastName,
businessUnitName: activeBusinessUnit?.name,
postcode: activeBusinessUnit?.postcode,
country: activeBusinessUnit?.country?.name,
farmAnimalTypes,
animalCount: 0,
grownStage: activeBusinessUnit?.grownStage,
subscription: activeBusinessUnit?.subscription,
},
};
console.log({ pendoUser });
yield call(PendoSDK.switchVisitor(pendoUser));
}
[...]
return (
<SafeAreaProvider>
<NavigationContainer
theme={MyTheme}
ref={navigationRef}
linking={linking}
onReady={() => {
routeNameRef.current = navigationRef.getCurrentRoute().name;
props.onReady();
}}
onStateChange={async () => {
const previousRouteName = routeNameRef.current;
const currentRouteName = navigationRef.getCurrentRoute().name;
onNavigationStateChange(currentRouteName, previousRouteName);
routeNameRef.current = currentRouteName;
const state = navigationRef.current.getRootState();
return props.onStateChange(state);
}}
>
<Routes />
</NavigationContainer>
</SafeAreaProvider>
);
}
export default withPendo(Navigation);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment