Skip to content

Commit 9900a6a

Browse files
Merge main into release
2 parents d5428f3 + 51e7b48 commit 9900a6a

File tree

10 files changed

+35
-108
lines changed

10 files changed

+35
-108
lines changed

.changeset/blue-spies-visit.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@firebase/app-compat': patch
3+
'@firebase/app-check': patch
4+
'@firebase/app': patch
5+
---
6+
7+
Revert https://github.com/firebase/firebase-js-sdk/pull/8999

docs-devsite/app.firebaseappsettings.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ export interface FirebaseAppSettings
2222

2323
| Property | Type | Description |
2424
| --- | --- | --- |
25-
| [automaticDataCollectionEnabled](./app.firebaseappsettings.md#firebaseappsettingsautomaticdatacollectionenabled) | boolean | The settable config flag for GDPR opt-in/opt-out. Defaults to true. |
25+
| [automaticDataCollectionEnabled](./app.firebaseappsettings.md#firebaseappsettingsautomaticdatacollectionenabled) | boolean | The settable config flag for GDPR opt-in/opt-out |
2626
| [name](./app.firebaseappsettings.md#firebaseappsettingsname) | string | custom name for the Firebase App. The default value is <code>&quot;[DEFAULT]&quot;</code>. |
2727

2828
## FirebaseAppSettings.automaticDataCollectionEnabled
2929

30-
The settable config flag for GDPR opt-in/opt-out. Defaults to true.
30+
The settable config flag for GDPR opt-in/opt-out
3131

3232
<b>Signature:</b>
3333

packages/app-check/src/api.test.ts

+2-71
Original file line numberDiff line numberDiff line change
@@ -239,85 +239,16 @@ describe('api', () => {
239239
expect(getStateReference(app).activated).to.equal(true);
240240
});
241241

242-
it('global false + local unset = false', () => {
242+
it('isTokenAutoRefreshEnabled value defaults to global setting', () => {
243243
app.automaticDataCollectionEnabled = false;
244244
initializeAppCheck(app, {
245245
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY)
246246
});
247247
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.equal(false);
248248
});
249249

250-
it('global false + local true = false', () => {
251-
app.automaticDataCollectionEnabled = false;
252-
initializeAppCheck(app, {
253-
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY),
254-
isTokenAutoRefreshEnabled: true
255-
});
256-
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.equal(false);
257-
});
258-
259-
it('global false + local false = false', () => {
260-
app.automaticDataCollectionEnabled = false;
261-
initializeAppCheck(app, {
262-
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY),
263-
isTokenAutoRefreshEnabled: false
264-
});
265-
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.equal(false);
266-
});
267-
268-
it('global unset + local unset = false', () => {
269-
// Global unset should default to true.
270-
initializeAppCheck(app, {
271-
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY)
272-
});
273-
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.equal(false);
274-
});
275-
276-
it('global unset + local false = false', () => {
277-
// Global unset should default to true.
278-
initializeAppCheck(app, {
279-
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY),
280-
isTokenAutoRefreshEnabled: false
281-
});
282-
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.equal(false);
283-
});
284-
285-
it('global unset + local true = true', () => {
286-
// Global unset should default to true.
287-
initializeAppCheck(app, {
288-
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY),
289-
isTokenAutoRefreshEnabled: true
290-
});
291-
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.equal(true);
292-
});
293-
294-
it('global true + local unset = false', () => {
295-
app.automaticDataCollectionEnabled = true;
296-
initializeAppCheck(app, {
297-
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY)
298-
});
299-
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.equal(false);
300-
});
301-
302-
it('global true + local false = false', () => {
303-
app.automaticDataCollectionEnabled = true;
304-
initializeAppCheck(app, {
305-
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY),
306-
isTokenAutoRefreshEnabled: false
307-
});
308-
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.equal(false);
309-
});
310-
311-
it('global true + local true = true', () => {
312-
app.automaticDataCollectionEnabled = true;
313-
initializeAppCheck(app, {
314-
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY),
315-
isTokenAutoRefreshEnabled: true
316-
});
317-
expect(getStateReference(app).isTokenAutoRefreshEnabled).to.equal(true);
318-
});
319-
320250
it('sets isTokenAutoRefreshEnabled correctly, overriding global setting', () => {
251+
app.automaticDataCollectionEnabled = false;
321252
initializeAppCheck(app, {
322253
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY),
323254
isTokenAutoRefreshEnabled: true

packages/app-check/src/api.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import {
4343
} from './internal-api';
4444
import { readTokenFromStorage } from './storage';
4545
import { getDebugToken, initializeDebugMode, isDebugMode } from './debug';
46-
import { logger } from './logger';
4746

4847
declare module '@firebase/component' {
4948
interface NameServiceMapping {
@@ -133,7 +132,7 @@ export function initializeAppCheck(
133132
function _activate(
134133
app: FirebaseApp,
135134
provider: AppCheckProvider,
136-
isTokenAutoRefreshEnabled: boolean = false
135+
isTokenAutoRefreshEnabled?: boolean
137136
): void {
138137
// Create an entry in the APP_CHECK_STATES map. Further changes should
139138
// directly mutate this object.
@@ -150,18 +149,13 @@ function _activate(
150149
return cachedToken;
151150
});
152151

153-
// Global `automaticDataCollectionEnabled` (defaults to true) and
154-
// `isTokenAutoRefreshEnabled` must both be true.
152+
// Use value of global `automaticDataCollectionEnabled` (which
153+
// itself defaults to false if not specified in config) if
154+
// `isTokenAutoRefreshEnabled` param was not provided by user.
155155
state.isTokenAutoRefreshEnabled =
156-
isTokenAutoRefreshEnabled && app.automaticDataCollectionEnabled;
157-
158-
if (!app.automaticDataCollectionEnabled && isTokenAutoRefreshEnabled) {
159-
logger.warn(
160-
'`isTokenAutoRefreshEnabled` is true but ' +
161-
'`automaticDataCollectionEnabled` was set to false during' +
162-
' `initializeApp()`. This blocks automatic token refresh.'
163-
);
164-
}
156+
isTokenAutoRefreshEnabled === undefined
157+
? app.automaticDataCollectionEnabled
158+
: isTokenAutoRefreshEnabled;
165159

166160
state.provider.initialize(app);
167161
}

packages/app-compat/test/firebaseAppCompat.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -403,17 +403,17 @@ function firebaseAppTests(
403403
).throws(/'abc'.*exists/i);
404404
});
405405

406-
it('automaticDataCollectionEnabled is `true` by default', () => {
406+
it('automaticDataCollectionEnabled is `false` by default', () => {
407407
const app = firebase.initializeApp({}, 'my-app');
408-
expect(app.automaticDataCollectionEnabled).to.eq(true);
408+
expect(app.automaticDataCollectionEnabled).to.eq(false);
409409
});
410410

411411
it('automaticDataCollectionEnabled can be set via the config object', () => {
412412
const app = firebase.initializeApp(
413413
{},
414-
{ automaticDataCollectionEnabled: false }
414+
{ automaticDataCollectionEnabled: true }
415415
);
416-
expect(app.automaticDataCollectionEnabled).to.eq(false);
416+
expect(app.automaticDataCollectionEnabled).to.eq(true);
417417
});
418418

419419
it('Modifying options object does not change options.', () => {

packages/app/src/api.test.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ describe('API tests', () => {
128128
{
129129
apiKey: 'test1'
130130
},
131-
{ automaticDataCollectionEnabled: false }
131+
{ automaticDataCollectionEnabled: true }
132132
);
133133
expect(() =>
134134
initializeApp(
135135
{
136136
apiKey: 'test1'
137137
},
138-
{ automaticDataCollectionEnabled: true }
138+
{ automaticDataCollectionEnabled: false }
139139
)
140140
).throws(/\[DEFAULT\].*exists/i);
141141
});
@@ -146,14 +146,14 @@ describe('API tests', () => {
146146
{
147147
apiKey: 'test1'
148148
},
149-
{ name: appName, automaticDataCollectionEnabled: false }
149+
{ name: appName, automaticDataCollectionEnabled: true }
150150
);
151151
expect(() =>
152152
initializeApp(
153153
{
154154
apiKey: 'test1'
155155
},
156-
{ name: appName, automaticDataCollectionEnabled: true }
156+
{ name: appName, automaticDataCollectionEnabled: false }
157157
)
158158
).throws(/'MyApp'.*exists/i);
159159
});
@@ -164,16 +164,11 @@ describe('API tests', () => {
164164
expect(app.name).to.equal(appName);
165165
});
166166

167-
it('sets automaticDataCollectionEnabled to true by default', () => {
168-
const app = initializeApp({});
167+
it('sets automaticDataCollectionEnabled', () => {
168+
const app = initializeApp({}, { automaticDataCollectionEnabled: true });
169169
expect(app.automaticDataCollectionEnabled).to.be.true;
170170
});
171171

172-
it('sets a new automaticDataCollectionEnabled value if provided', () => {
173-
const app = initializeApp({}, { automaticDataCollectionEnabled: false });
174-
expect(app.automaticDataCollectionEnabled).to.be.false;
175-
});
176-
177172
it('adds registered components to App', () => {
178173
_clearComponents();
179174
const comp1 = createTestComponent('test1');
@@ -216,7 +211,7 @@ describe('API tests', () => {
216211

217212
const app = initializeServerApp(options, serverAppSettings);
218213
expect(app).to.not.equal(null);
219-
expect(app.automaticDataCollectionEnabled).to.be.true;
214+
expect(app.automaticDataCollectionEnabled).to.be.false;
220215
await deleteApp(app);
221216
expect((app as FirebaseServerAppImpl).isDeleted).to.be.true;
222217
});

packages/app/src/api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export function initializeApp(
143143

144144
const config: Required<FirebaseAppSettings> = {
145145
name: DEFAULT_ENTRY_NAME,
146-
automaticDataCollectionEnabled: true,
146+
automaticDataCollectionEnabled: false,
147147
...rawConfig
148148
};
149149
const name = config.name;
@@ -241,7 +241,7 @@ export function initializeServerApp(
241241
}
242242

243243
if (_serverAppConfig.automaticDataCollectionEnabled === undefined) {
244-
_serverAppConfig.automaticDataCollectionEnabled = true;
244+
_serverAppConfig.automaticDataCollectionEnabled = false;
245245
}
246246

247247
let appOptions: FirebaseOptions;

packages/app/src/firebaseApp.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ describe('FirebaseAppNext', () => {
2727
};
2828
const app = new FirebaseAppImpl(
2929
options,
30-
{ name: 'test', automaticDataCollectionEnabled: true },
30+
{ name: 'test', automaticDataCollectionEnabled: false },
3131
new ComponentContainer('test')
3232
);
3333

34-
expect(app.automaticDataCollectionEnabled).to.be.true;
34+
expect(app.automaticDataCollectionEnabled).to.be.false;
3535
expect(app.name).to.equal('test');
3636
expect(app.options).to.deep.equal(options);
3737
});

packages/app/src/firebaseServerApp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class FirebaseServerAppImpl
7474
const automaticDataCollectionEnabled =
7575
serverConfig.automaticDataCollectionEnabled !== undefined
7676
? serverConfig.automaticDataCollectionEnabled
77-
: true;
77+
: false;
7878

7979
// Create the FirebaseAppSettings object for the FirebaseAppImp constructor.
8080
const config: Required<FirebaseAppSettings> = {

packages/app/src/public-types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export interface FirebaseAppSettings {
165165
*/
166166
name?: string;
167167
/**
168-
* The settable config flag for GDPR opt-in/opt-out. Defaults to true.
168+
* The settable config flag for GDPR opt-in/opt-out
169169
*/
170170
automaticDataCollectionEnabled?: boolean;
171171
}

0 commit comments

Comments
 (0)