Zoro
Zoro

Reputation: 1

Firebase - RemoteConfig with custom user properties return wrong value

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.

Upvotes: 0

Views: 221

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599956

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.

Upvotes: 1

Related Questions