Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // AuthHelper.js
- export const setUserIdentifiers = async () => {
- /** @type {import('amazon-cognito-identity-js').CognitoUser} */
- const userData = getCurrentUser();
- if (userData) {
- const userId = userData?.username;
- // ...
- setUserIdentifierForBraze(userId);
- // ...
- }
- };
- const setUserIdentifierForBraze = (userId) => {
- Braze.changeUser(userId);
- };
- export const refreshThirdPartyData = async () => {
- try {
- await setUserIdentifiers();
- } catch (err) {
- log.warn("refreshThirdPartyData", err.toString());
- }
- };
- // Startup.js
- const StartupManager = () => {
- // this is called as part of our startup process
- const finishSetupWithUser = useCallback(
- async () => {
- log.trace("[Startup] - Finish Setup With User Data");
- log.trace("[Startup] - Set User Identifiers");
- await setUserIdentifiers();
- // ...
- },
- [
- /* ... */
- ]
- );
- useNonInitialEffect(() => {
- // If we cold started while offline but we're no longer offline
- // then rerun authentication as well as third party connections
- if (!isOffline) {
- log.trace("Refresh Third Party Data");
- const refreshUserData = async () => {
- await refreshThirdPartyData();
- };
- refreshUserData();
- }
- }, [isOffline]);
- };
- // SignInSignOutHelper.js
- export const signIn = async (opts) => {
- try {
- // ...
- await setUserIdentifiers();
- // ...
- } catch (err) {
- // ...
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement