Skip to content

feat(rc): Web support for ABT & Rollouts#9449

Merged
hsubox76 merged 1 commit intomainfrom
web-experiment
Jan 13, 2026
Merged

feat(rc): Web support for ABT & Rollouts#9449
hsubox76 merged 1 commit intomainfrom
web-experiment

Conversation

@athiramanu
Copy link
Contributor

This change is part of the feature to support Web Experiments in Remote Config. Changes can be broken down as below:

Introduces the experiment details in the fetch response type
Extracts experiments received from the fetch response and saves in indexedDB
Sets the experiment and variant received as user property

Design doc (internal): go/experiments-web

@athiramanu athiramanu requested review from a team and erikeldridge as code owners January 13, 2026 10:23
@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2026

🦋 Changeset detected

Latest commit: cf6e3d8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/remote-config Minor
firebase Minor
@firebase/remote-config-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @athiramanu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances Firebase Remote Config by adding full web support for A/B Testing and Rollouts. It modifies the core data structures to accommodate experiment metadata, introduces a dedicated class for managing the lifecycle of these experiments, and integrates with Firebase Analytics to provide crucial user property tracking. These changes allow web applications to leverage Remote Config for advanced experimentation and controlled feature rollouts, aligning the web SDK with capabilities available on other platforms.

Highlights

  • Web Support for ABT & Rollouts: This pull request introduces comprehensive web support for A/B Testing (ABT) and Remote Config Rollouts, enabling dynamic experimentation and feature deployment on web platforms.
  • Experiment Data Integration: The FetchResponse interface now includes an experiments field, which carries FirebaseExperimentDescription objects. These objects detail experiment IDs, variant IDs, start times, and other metadata.
  • Experiment Management and Analytics: A new Experiment class has been added to manage active experiments. It extracts experiment details from the fetch response, stores them in IndexedDB, and sets experiment and variant information as user properties in Firebase Analytics, facilitating experiment tracking.
  • API and Documentation Updates: The public API and documentation have been updated to reflect the new FirebaseExperimentDescription interface and the experiments field in FetchResponse, ensuring clarity and consistency for developers.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces web support for A/B Testing and Rollouts in Remote Config. The changes include updating the fetch response to include experiment details, storing these details in IndexedDB, and setting experiment data as user properties in Firebase Analytics. The implementation looks solid, but I have a few suggestions to improve documentation, API design, and code efficiency. Specifically, I've recommended using TSDoc for better public API documentation, refining the Experiment class for better performance, and cleaning up a minor redundancy in the tests.

Comment on lines +57 to +68
// (undocumented)
affectedParameterKeys?: string[];
// (undocumented)
experimentId: string;
// (undocumented)
experimentStartTime: string;
// (undocumented)
timeToLiveMillis: string;
// (undocumented)
triggerTimeoutMillis: string;
// (undocumented)
variantId: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The properties of the FirebaseExperimentDescription interface are marked as (undocumented). This is likely because the source code in packages/remote-config/src/public_types.ts uses // comments instead of TSDoc blocks (/** ... */). To ensure the public API is properly documented, please update the comments to TSDoc format. This will allow the API extractor to generate complete documentation.

Comment on lines +25 to +30
| [affectedParameterKeys](./remote-config.firebaseexperimentdescription.md#firebaseexperimentdescriptionaffectedparameterkeys) | string\[\] | |
| [experimentId](./remote-config.firebaseexperimentdescription.md#firebaseexperimentdescriptionexperimentid) | string | |
| [experimentStartTime](./remote-config.firebaseexperimentdescription.md#firebaseexperimentdescriptionexperimentstarttime) | string | |
| [timeToLiveMillis](./remote-config.firebaseexperimentdescription.md#firebaseexperimentdescriptiontimetolivemillis) | string | |
| [triggerTimeoutMillis](./remote-config.firebaseexperimentdescription.md#firebaseexperimentdescriptiontriggertimeoutmillis) | string | |
| [variantId](./remote-config.firebaseexperimentdescription.md#firebaseexperimentdescriptionvariantid) | string | |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The property descriptions in this generated documentation file are empty. This is a result of the API extractor not picking up the comments from the source interface (FirebaseExperimentDescription in packages/remote-config/src/public_types.ts). To fix this, the comments in the source file should be converted to TSDoc format (/** ... */).

Comment on lines +36 to +45
async updateActiveExperiments(
latestExperiments: FirebaseExperimentDescription[]
): Promise<void> {
const currentActiveExperiments =
(await this.storage.getActiveExperiments()) || new Set<string>();
const experimentInfoMap = this.createExperimentInfoMap(latestExperiments);
this.addActiveExperiments(experimentInfoMap);
this.removeInactiveExperiments(currentActiveExperiments, experimentInfoMap);
return this.storage.setActiveExperiments(new Set(experimentInfoMap.keys()));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The updateActiveExperiments method currently calls addActiveExperiments and removeInactiveExperiments, which results in two separate calls to analytics.setUserProperties. This can be optimized by consolidating the logic to build a single map of property changes and making only one call to setUserProperties. This improves both performance and code clarity.

With the suggested change below, the addActiveExperiments and removeInactiveExperiments methods will no longer be needed and can be removed.

  async updateActiveExperiments(
    latestExperiments: FirebaseExperimentDescription[]
  ): Promise<void> {
    const currentActiveExperiments =
      (await this.storage.getActiveExperiments()) || new Set<string>();
    const experimentInfoMap = this.createExperimentInfoMap(latestExperiments);

    const customProperties: Record<string, string | null> = {};

    // Set properties for all latest experiments.
    for (const [experimentId, experimentInfo] of experimentInfoMap.entries()) {
      customProperties[`firebase${experimentId}`] = experimentInfo.variantId;
    }

    // Set null for experiments that are no longer active.
    for (const experimentId of currentActiveExperiments) {
      if (!experimentInfoMap.has(experimentId)) {
        customProperties[`firebase${experimentId}`] = null;
      }
    }

    this.addExperimentToAnalytics(customProperties);

    return this.storage.setActiveExperiments(new Set(experimentInfoMap.keys()));
  }

Comment on lines +67 to +87
export interface FirebaseExperimentDescription {
// A string of max length 22 characters and of format: _exp_<experiment_id>
experimentId: string;

// The variant of the experiment assigned to the app instance.
variantId: string;

// When the experiment was started.
experimentStartTime: string;

// How long the experiment can remain in STANDBY state. Valid range from 1 ms
// to 6 months.
triggerTimeoutMillis: string;

// How long the experiment can remain in ON state. Valid range from 1 ms to 6
// months.
timeToLiveMillis: string;

// Which all parameters are affected by this experiment.
affectedParameterKeys?: string[];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comments for the properties within FirebaseExperimentDescription are using // which are not picked up by API documentation generators. To ensure these are properly documented, they should be converted to TSDoc format (/** ... */).

Additionally, properties like triggerTimeoutMillis and timeToLiveMillis are defined as string. For better type safety and clarity in a public API, consider using the number type for millisecond values. If they must remain strings (e.g., to handle 64-bit integers without precision loss), this should be clearly explained in their TSDoc comments.

export interface FirebaseExperimentDescription {
  /** A string of max length 22 characters and of format: _exp_<experiment_id> */
  experimentId: string;

  /** The variant of the experiment assigned to the app instance. */
  variantId: string;

  /** When the experiment was started. This is a UTC timestamp in ISO 8601 format. */
  experimentStartTime: string;

  /**
   * How long the experiment can remain in STANDBY state.
   * This is a string representation of a duration in milliseconds.
   */
  triggerTimeoutMillis: string;

  /**
   * How long the experiment can remain in ON state.
   * This is a string representation of a duration in milliseconds.
   */
  timeToLiveMillis: string;

  /** Which all parameters are affected by this experiment. */
  affectedParameterKeys?: string[];
}

Comment on lines +447 to +449
afterEach(() => {
sandbox.restore();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This afterEach block is a duplicate of the one just above it. One of them can be removed to avoid redundancy.

@google-oss-bot
Copy link
Collaborator

Size Report 1

Affected Products

  • @firebase/remote-config

    TypeBase (5579b38)Merge (4ad9ccf)Diff
    browser39.0 kB41.5 kB+2.47 kB (+6.3%)
    main40.2 kB42.7 kB+2.47 kB (+6.1%)
    module39.0 kB41.5 kB+2.47 kB (+6.3%)
  • bundle

    TypeBase (5579b38)Merge (4ad9ccf)Diff
    remote-config (getAndFetch)59.4 kB61.0 kB+1.58 kB (+2.7%)
  • firebase

    TypeBase (5579b38)Merge (4ad9ccf)Diff
    firebase-compat.js810 kB812 kB+1.50 kB (+0.2%)
    firebase-remote-config-compat.js38.7 kB40.2 kB+1.50 kB (+3.9%)
    firebase-remote-config.js43.5 kB45.1 kB+1.55 kB (+3.6%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/U7RBNKtwo7.html

@google-oss-bot
Copy link
Collaborator

Size Analysis Report 1

Affected Products

  • @firebase/remote-config

    • activate

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size23.5 kB25.1 kB+1.57 kB (+6.7%)
      size-with-ext-deps50.0 kB51.6 kB+1.58 kB (+3.2%)

      Dependency

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      classes

      12 dependencies

      CachingClient
      EventEmitter
      InMemoryStorage
      IndexedDbStorage
      RealtimeHandler
      RemoteConfig
      RemoteConfigAbortSignal
      RestClient
      RetryingClient
      Storage
      StorageCache
      VisibilityMonitor

      13 dependencies

      CachingClient
      EventEmitter
      Experiment
      InMemoryStorage
      IndexedDbStorage
      RealtimeHandler
      RemoteConfig
      RemoteConfigAbortSignal
      RestClient
      RetryingClient
      Storage
      StorageCache
      VisibilityMonitor

      + Experiment

    • ensureInitialized

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size23.1 kB23.5 kB+347 B (+1.5%)
      size-with-ext-deps49.6 kB50.0 kB+347 B (+0.7%)
    • fetchAndActivate

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size24.2 kB25.7 kB+1.58 kB (+6.5%)
      size-with-ext-deps50.7 kB52.2 kB+1.58 kB (+3.1%)

      Dependency

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      classes

      12 dependencies

      CachingClient
      EventEmitter
      InMemoryStorage
      IndexedDbStorage
      RealtimeHandler
      RemoteConfig
      RemoteConfigAbortSignal
      RestClient
      RetryingClient
      Storage
      StorageCache
      VisibilityMonitor

      13 dependencies

      CachingClient
      EventEmitter
      Experiment
      InMemoryStorage
      IndexedDbStorage
      RealtimeHandler
      RemoteConfig
      RemoteConfigAbortSignal
      RestClient
      RetryingClient
      Storage
      StorageCache
      VisibilityMonitor

      + Experiment

    • fetchConfig

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size23.7 kB24.1 kB+347 B (+1.5%)
      size-with-ext-deps50.2 kB50.6 kB+347 B (+0.7%)
    • getAll

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size24.3 kB24.7 kB+347 B (+1.4%)
      size-with-ext-deps50.8 kB51.1 kB+347 B (+0.7%)
    • getBoolean

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size24.2 kB24.5 kB+347 B (+1.4%)
      size-with-ext-deps50.7 kB51.0 kB+347 B (+0.7%)
    • getNumber

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size24.2 kB24.5 kB+347 B (+1.4%)
      size-with-ext-deps50.7 kB51.0 kB+347 B (+0.7%)
    • getRemoteConfig

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size23.9 kB24.3 kB+347 B (+1.5%)
      size-with-ext-deps57.3 kB57.7 kB+347 B (+0.6%)
    • getString

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size24.2 kB24.5 kB+347 B (+1.4%)
      size-with-ext-deps50.7 kB51.0 kB+347 B (+0.7%)
    • getValue

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size24.1 kB24.5 kB+347 B (+1.4%)
      size-with-ext-deps50.6 kB51.0 kB+347 B (+0.7%)
    • isSupported

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size23.3 kB23.6 kB+347 B (+1.5%)
      size-with-ext-deps49.7 kB50.1 kB+347 B (+0.7%)
    • onConfigUpdate

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size23.3 kB23.6 kB+347 B (+1.5%)
      size-with-ext-deps49.7 kB50.1 kB+347 B (+0.7%)
    • setCustomSignals

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size23.6 kB24.0 kB+347 B (+1.5%)
      size-with-ext-deps50.1 kB50.5 kB+347 B (+0.7%)
    • setLogLevel

      Size

      TypeBase (5579b38)Merge (4ad9ccf)Diff
      size23.3 kB23.6 kB+347 B (+1.5%)
      size-with-ext-deps49.8 kB50.1 kB+347 B (+0.7%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/jD4QSn1ZTK.html

@hsubox76 hsubox76 merged commit b282744 into main Jan 13, 2026
38 checks passed
@hsubox76 hsubox76 deleted the web-experiment branch January 13, 2026 15:41
@google-oss-bot google-oss-bot mentioned this pull request Jan 14, 2026
maneesht pushed a commit that referenced this pull request Feb 6, 2026
Co-authored-by: Athira M <athiramanu@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants