0

I am setting userProperties for custom defined property (scope user) and userId in analytics using setUserProperties and setUserId, and fetching remote config based on the setted properties. but i am getting default config at first, but when any user comes again then it returned config are as per previous setted properties irrespective of the user.

This is the code snippet.

const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const remoteConfig = getRemoteConfig(app);

export const firebaseInit = async (userId, testProperty) => {
  // setting userId and userProperties
  setUserId(analytics, userId);
  setUserProperties(analytics, { testProperty: testProperty });

  // Fetching and activationg config
  remoteConfig.settings.minimumFetchIntervalMillis = 1000;
  const isActivated = await activate(remoteConfig);
  await fetchConfig(remoteConfig);
  const allConfig = getAll(remoteConfig);
};

I was expecting get correct config based and setted properties and i was setting userId to identify the user when it comes next time and get correct config.

1 Answer 1

0

My guess is that the first values you get are the ones you specified in the Firebase console, as those are bundled into your application at build time and used the first time the app runs.

At that first run you app fetches the user-specific values from Remote Config, but those won't be used until the next time the app is loaded. While Firebase Remote Config does now have a real-time mechanism to immediately apply those settings in the app, that mechanism is only available for iOS and Android - not for web.

So you will have to roll your own mechanism for detecting this initial state.

Not the answer you're looking for? Browse other questions tagged or ask your own question.