Created
December 6, 2021 08:59
-
-
Save jim-at-jibba/a6957a5e34c7089ce219d59eb4d2c648 to your computer and use it in GitHub Desktop.
Pendo Nav implimentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
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