Skip to content

Commit f7b1ba2

Browse files
author
Athira M
committed
feat: Process experiment metadata in RC fetch response
1 parent 1933324 commit f7b1ba2

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

packages/remote-config/src/client/rest_client.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import {
1919
CustomSignals,
2020
FetchResponse,
21-
FirebaseRemoteConfigObject
21+
FirebaseRemoteConfigObject,
22+
FirebaseExperimentDescription
2223
} from '../public_types';
2324
import {
2425
RemoteConfigFetchClient,
@@ -140,6 +141,7 @@ export class RestClient implements RemoteConfigFetchClient {
140141

141142
let config: FirebaseRemoteConfigObject | undefined;
142143
let state: string | undefined;
144+
let experiments: FirebaseExperimentDescription[] | undefined;
143145

144146
// JSON parsing throws SyntaxError if the response body isn't a JSON string.
145147
// Requesting application/json and checking for a 200 ensures there's JSON data.
@@ -154,6 +156,7 @@ export class RestClient implements RemoteConfigFetchClient {
154156
}
155157
config = responseBody['entries'];
156158
state = responseBody['state'];
159+
experiments = responseBody['experimentDescriptions'];
157160
}
158161

159162
// Normalizes based on legacy state.
@@ -176,6 +179,6 @@ export class RestClient implements RemoteConfigFetchClient {
176179
});
177180
}
178181

179-
return { status, eTag: responseEtag, config };
182+
return { status, eTag: responseEtag, config, experiments };
180183
}
181184
}

packages/remote-config/src/public_types.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,32 @@ export interface FirebaseRemoteConfigObject {
5757
[key: string]: string;
5858
}
5959

60+
/**
61+
* Defines experiment and variant attached to a config parameter.
62+
*/
63+
export interface FirebaseExperimentDescription {
64+
// A string of max length 22 characters and of format: _exp_<experiment_id>
65+
experimentId: string;
66+
67+
// The variant of the experiment assigned to the app instance.
68+
variantId: string;
69+
70+
// When the experiment was started.
71+
experimentStartTime: string;
72+
73+
// How long the experiment can remain in STANDBY state. Valid range from 1 ms
74+
// to 6 months.
75+
triggerTimeoutMillis: string;
76+
77+
// How long the experiment can remain in ON state. Valid range from 1 ms to 6
78+
// months.
79+
timeToLiveMillis: string;
80+
81+
// A repeated of Remote Config parameter keys that this experiment is
82+
// affecting the value of.
83+
affectedParameterKeys?: string[];
84+
}
85+
6086
/**
6187
* Defines a successful response (200 or 304).
6288
*
@@ -90,8 +116,12 @@ export interface FetchResponse {
90116
*/
91117
config?: FirebaseRemoteConfigObject;
92118

93-
// Note: we're not extracting experiment metadata until
94-
// ABT and Analytics have Web SDKs.
119+
/**
120+
* A/B Test and Rollout experiment metadata.
121+
*
122+
* <p>Only defined for 200 responses.
123+
*/
124+
experiments?: FirebaseExperimentDescription[];
95125
}
96126

97127
/**

0 commit comments

Comments
 (0)