Skip to content

Commit ff99a7c

Browse files
Add unit test + improve public API documentation
- Removed changes to firebase/compat and remote-config-compat packages.
1 parent 95df4e4 commit ff99a7c

File tree

10 files changed

+26
-50
lines changed

10 files changed

+26
-50
lines changed

common/api-review/remote-config.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function activate(remoteConfig: RemoteConfig): Promise<boolean>;
1212
// @public
1313
export interface CustomSignals {
1414
// (undocumented)
15-
[key: string]: string | number;
15+
[key: string]: string | number | null;
1616
}
1717

1818
// @public

docs-devsite/remote-config.customsignals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Defines the type for representing custom signals and their values.
1414

1515
<p>The values in CustomSignals must be one of the following types:
1616

17-
<ul> <li><code>string</code> <li><code>number</code> </ul>
17+
<ul> <li><code>string</code> <li><code>number</code> <li><code>null</code> </ul>
1818

1919
<b>Signature:</b>
2020

docs-devsite/remote-config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The Firebase Remote Config Web SDK. This SDK does not work in a Node.js environm
3737

3838
| Interface | Description |
3939
| --- | --- |
40-
| [CustomSignals](./remote-config.customsignals.md#customsignals_interface) | Defines the type for representing custom signals and their values.<p>The values in CustomSignals must be one of the following types:<ul> <li><code>string</code> <li><code>number</code> </ul> |
40+
| [CustomSignals](./remote-config.customsignals.md#customsignals_interface) | Defines the type for representing custom signals and their values.<p>The values in CustomSignals must be one of the following types:<ul> <li><code>string</code> <li><code>number</code> <li><code>null</code> </ul> |
4141
| [RemoteConfig](./remote-config.remoteconfig.md#remoteconfig_interface) | The Firebase Remote Config service interface. |
4242
| [RemoteConfigSettings](./remote-config.remoteconfigsettings.md#remoteconfigsettings_interface) | Defines configuration options for the Remote Config SDK. |
4343
| [Value](./remote-config.value.md#value_interface) | Wraps a value with metadata and type-safe getters. |
@@ -293,7 +293,7 @@ export declare function setCustomSignals(remoteConfig: RemoteConfig, customSigna
293293
| Parameter | Type | Description |
294294
| --- | --- | --- |
295295
| remoteConfig | [RemoteConfig](./remote-config.remoteconfig.md#remoteconfig_interface) | The [RemoteConfig](./remote-config.remoteconfig.md#remoteconfig_interface) instance. |
296-
| customSignals | [CustomSignals](./remote-config.customsignals.md#customsignals_interface) | Map (key, value) of the custom signals to be set for the app instance. |
296+
| customSignals | [CustomSignals](./remote-config.customsignals.md#customsignals_interface) | Map (key, value) of the custom signals to be set for the app instance. If a key already exists, the value is overwritten. Setting the value of a custom signal null unsets the signal. The signals will be persisted locally on the client. |
297297

298298
<b>Returns:</b>
299299

packages/firebase/compat/index.d.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,11 +1971,6 @@ declare namespace firebase.remoteConfig {
19711971
* Defines the log level to use.
19721972
*/
19731973
setLogLevel(logLevel: LogLevel): void;
1974-
1975-
/**
1976-
* Sets custom signals for the Remote Config instance.
1977-
*/
1978-
setCustomSignals(customSignals: CustomSignals): Promise<void>;
19791974
}
19801975

19811976
/**
@@ -2052,18 +2047,6 @@ declare namespace firebase.remoteConfig {
20522047
*/
20532048
export type LogLevel = 'debug' | 'error' | 'silent';
20542049

2055-
/**
2056-
* Defines the type for representing custom signals and their values.
2057-
*
2058-
* <p>The values in CustomSignals must be one of the following types:
2059-
*
2060-
* <ul>
2061-
* <li><code>string</code>
2062-
* <li><code>number</code>
2063-
* </ul>
2064-
*/
2065-
export type CustomSignals = { [key: string]: string | number };
2066-
20672050
/**
20682051
* This method provides two different checks:
20692052
*

packages/remote-config-compat/src/remoteConfig.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,4 @@ describe('Remote Config Compat', () => {
157157
'debug'
158158
);
159159
});
160-
161-
it('setCustomSignals() calls modular setCustomSignals()', async () => {
162-
const modularSetCustomSignalsStub = stub(
163-
modularApi,
164-
'setCustomSignals'
165-
).callsFake(() => Promise.resolve());
166-
await remoteConfig.setCustomSignals({ 'customSignal': 'value' });
167-
168-
expect(modularSetCustomSignalsStub).to.have.been.calledWithExactly(
169-
fakeModularRemoteConfig,
170-
{ 'customSignal': 'value' }
171-
);
172-
});
173160
});

packages/remote-config-compat/src/remoteConfig.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import {
2121
FetchStatus as FetchSTatusCompat,
2222
Settings as SettingsCompat,
2323
LogLevel as RemoteConfigLogLevel,
24-
RemoteConfig as RemoteConfigCompat,
25-
CustomSignals as RemoteConfigCustomSignals
24+
RemoteConfig as RemoteConfigCompat
2625
} from '@firebase/remote-config-types';
2726
import {
2827
RemoteConfig,
@@ -36,8 +35,7 @@ import {
3635
getNumber,
3736
getString,
3837
getValue,
39-
isSupported,
40-
setCustomSignals
38+
isSupported
4139
} from '@firebase/remote-config';
4240

4341
export { isSupported };
@@ -117,8 +115,4 @@ export class RemoteConfigCompatImpl
117115
setLogLevel(logLevel: RemoteConfigLogLevel): void {
118116
setLogLevel(this._delegate, logLevel);
119117
}
120-
121-
setCustomSignals(customSignals: RemoteConfigCustomSignals): Promise<void> {
122-
return setCustomSignals(this._delegate, customSignals);
123-
}
124118
}

packages/remote-config-types/index.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ export interface RemoteConfig {
9797
* Defines the log level to use.
9898
*/
9999
setLogLevel(logLevel: LogLevel): void;
100-
101-
/**
102-
* Sets custom signals for the Remote Config instance.
103-
*/
104-
setCustomSignals(customSignals: CustomSignals): Promise<void>;
105100
}
106101

107102
/**
@@ -186,9 +181,10 @@ export type LogLevel = 'debug' | 'error' | 'silent';
186181
* <ul>
187182
* <li><code>string</code>
188183
* <li><code>number</code>
184+
* <li><code>null</code>
189185
* </ul>
190186
*/
191-
export type CustomSignals = { [key: string]: string | number };
187+
export type CustomSignals = { [key: string]: string | number | null };
192188

193189
declare module '@firebase/component' {
194190
interface NameServiceMapping {

packages/remote-config/src/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ function getAllKeys(obj1: {} = {}, obj2: {} = {}): string[] {
265265
* Sets the custom signals for the app instance.
266266
*
267267
* @param remoteConfig - The {@link RemoteConfig} instance.
268-
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance.
268+
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If
269+
* a key already exists, the value is overwritten. Setting the value of a custom signal null unsets
270+
* the signal. The signals will be persisted locally on the client.
269271
*
270272
* @public
271273
*/

packages/remote-config/src/public_types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,13 @@ export type LogLevel = 'debug' | 'error' | 'silent';
142142
* <ul>
143143
* <li><code>string</code>
144144
* <li><code>number</code>
145+
* <li><code>null</code>
145146
* </ul>
146147
*
147148
* @public
148149
*/
149150
export interface CustomSignals {
150-
[key: string]: string | number;
151+
[key: string]: string | number | null;
151152
}
152153

153154
declare module '@firebase/component' {

packages/remote-config/test/storage/storage.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,17 @@ describe('Storage', () => {
140140

141141
expect(storedCustomSignals).to.deep.eq(updatedSignals);
142142
});
143+
144+
it('deletes custom signal when value supplied is null', async () => {
145+
const customSignals = { key: 'value', key1: 'value1' };
146+
const updatedSignals = { key: 'value' };
147+
148+
await storage.setCustomSignals(customSignals);
149+
150+
await storage.setCustomSignals({ key1: null });
151+
152+
const storedCustomSignals = await storage.getCustomSignals();
153+
154+
expect(storedCustomSignals).to.deep.eq(updatedSignals);
155+
});
143156
});

0 commit comments

Comments
 (0)