Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Support for targeting user properties in real time with Remote Config (parity with iOS & Android SDKs) #8662

Open
pete-murphy opened this issue Dec 3, 2024 · 2 comments · May be fixed by derrickbeining/firebase-js-sdk#1

Comments

@pete-murphy
Copy link

pete-murphy commented Dec 3, 2024

Operating System

MacOS

Environment (if applicable)

Any browser

Firebase SDK Version

10.9.0

Firebase SDK Product(s)

Analytics, Remote-Config

Project Tooling

Elm app

Detailed Problem Description

Our app has mobile clients on iOS and Android which use firebase-ios-sdk and firebase-android-sdk for feature flagging. The way feature flagging works on those platforms is:

  • we have parameters in Remote Config with conditions based on user properties (something like app.userProperty['some_prop'].exactlyMatches(['some_value']))
  • when a user logs in, we set the user property
  • we then fetch the Remote Config with a minimumFetchInterval of 0 and activate to get the updated values specific to that user

We recently implemented a web app that uses the firebase-js-sdk and realized that this approach to feature flagging is not supported on Web because there's a delay between setting the user property and seeing the correct Remote Config value for that user property in the response from getValue.

This has been reported as a bug a few times already:

The response to the bug reports has been that this is expected behavior, and it is noted in the documentation that the JS SDK differs from the mobile SDKs on this. (I think that's what this is saying:

Note: On Web, it can take several hours for a property to be available for targeting. See the documentation for user properties on Web/JavaScript for more information.

?)

I'm submitting this as a feature request in case there's any plan of supporting this functionality in the web/JS SDK.

Steps and code to reproduce issue

See the repro steps here and here:

  • create a user property in Remote Config (foo)
  • create a condition matching on that property (app.userProperty['foo'].exactlyMatches(['bar'])) and a string parameter baz that branches on that condition to return values 'foo is bar' when the condition is true, 'default value' as default
  • fetch and activate Remote Config from a JS client using remoteConfig.settings.minimumFetchIntervalMillis = 0
  • set user property (call setUserProperty(analytics, { foo: 'bar' }))
  • fetch and activate again (call fetchAndActivate(remoteConfig))
  • see that the boolean returned is false indicating the config did not activate despite new user property
  • call getValue(remoteConfig, 'baz')
  • see that the value is the default 'default value'
@pete-murphy pete-murphy added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Dec 3, 2024
@pete-murphy pete-murphy changed the title FR: Support for targeting user properties in real time (parity with iOS & Android SDKs) FR: Support for targeting user properties in real time with Remote Config (parity with iOS & Android SDKs) Dec 3, 2024
@DavidCorrado
Copy link

We did find that remote config firebase API request is different on web vs Mobile. Mobile in the request for remote config firebase API request appends the user properties in the body in this format
"analyticsUserProperties":{"XXX":"YYYY"}
It would be great if the remote config library supported this on web as otherwise we lose the ability to have user properties reflect immediately.

I would think that it would require caching the user properties and sending it via the request.

Also if there is any other work arounds you can suggest for web let us know. If we could somehow manually call this route or append params to the body easily that would be helpful.

@jbalidiong jbalidiong added needs-attention api: remoteconfig and removed question new A new issue that hasn't be categoirzed as question, bug or feature request labels Dec 4, 2024
derrickbeining pushed a commit to derrickbeining/firebase-js-sdk that referenced this issue Dec 18, 2024
@derrickbeining
Copy link

derrickbeining commented Dec 24, 2024

For anyone else who runs into this issue, I've forked the firebase-js-sdk repo and made a PR here with the minimal changes necessary to allow you to specify analytics user properties when calling fetchConfig or fetchAndActivate. This circumvents the issue by telling the remote config backend what the user properties are synchronously in the request rather than waiting for the remote config backend to be notified about changes to user properties asynchronously. The easiest way to get these changes into your project is probably by using patch-package to apply my changes to the firebase package in node_modules during the postinstall phase of installing dependencies. The steps roughly are as follows:

  1. Clone the forked firebase-js-sdk repo locally
  2. cd into packages/remote-config
  3. Run npm install, npm run build, and then npm link (or do the yarn equivalients)
  4. Switch to your project that depends on firebase-js-sdk
  5. Run npm link @firebase/remote-config to install the locally built version of the @firebase/remote-config that you ran npm link for earlier
  6. Run npm install --save-dev patch-package
  7. Run npx patch-package @firebase/remote-config to derive the patch file, which you need to check into git
  8. Add npx patch-package to your package.scripts.postinstall script so that the patch gets applied when anyone clones and install your package
  9. Update any call sites of remoteConfig.fetchConfig or remoteConfig.fetchAndActivate to pass in { analyticsUserProperies: object } as the second argument.

Then when you run or build your project, it should use our forked version of @firebase/remote-config and the staleness issue should be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants