Skip to content

Commit 5dde564

Browse files
committed
fix(analytics): allow more than 25 event parameters
it is useful for google analytics 360 customers Related #5676 Re-ordered tests at the same time, so that DebugView was able to reliably record events during e2e test runs
1 parent 71a6d6d commit 5dde564

File tree

5 files changed

+28
-32
lines changed

5 files changed

+28
-32
lines changed

jest.setup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jest.doMock('react-native', () => {
99
},
1010
NativeModules: {
1111
...ReactNative.NativeModules,
12+
RNFBAnalyticsModule: {
13+
logEvent: jest.fn(),
14+
},
1215
RNFBAppModule: {
1316
NATIVE_FIREBASE_APPS: [
1417
{

packages/analytics/__tests__/analytics.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,6 @@ describe('Analytics', function () {
130130
);
131131
});
132132

133-
it('errors if more than 25 params provided', function () {
134-
expect(() =>
135-
firebase.analytics().logEvent('invertase', Object.assign({}, new Array(26).fill(1))),
136-
).toThrowError(
137-
"firebase.analytics().logEvent(_, *) 'params' maximum number of parameters exceeded (25).",
138-
);
139-
});
140-
141133
describe('logScreenView()', function () {
142134
it('errors if param is not an object', function () {
143135
// @ts-ignore test

packages/analytics/e2e/analytics.e2e.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,6 @@ describe('analytics()', function () {
3232
});
3333
});
3434

35-
describe('setAnalyticsCollectionEnabled()', function () {
36-
it('true', async function () {
37-
await firebase.analytics().setAnalyticsCollectionEnabled(true);
38-
});
39-
40-
it('false', async function () {
41-
await firebase.analytics().setAnalyticsCollectionEnabled(false);
42-
});
43-
});
44-
45-
describe('resetAnalyticsData()', function () {
46-
it('calls native fn without error', async function () {
47-
await firebase.analytics().resetAnalyticsData();
48-
});
49-
});
50-
5135
describe('setSessionTimeoutDuration()', function () {
5236
it('default duration', async function () {
5337
await firebase.analytics().setSessionTimeoutDuration();
@@ -432,4 +416,23 @@ describe('analytics()', function () {
432416
await firebase.analytics().setDefaultEventParameters({ number: 1, stringn: '123' });
433417
});
434418
});
419+
420+
// Test this one near end so all the previous hits are visible in DebugView is that is enabled
421+
describe('resetAnalyticsData()', function () {
422+
it('calls native fn without error', async function () {
423+
await firebase.analytics().resetAnalyticsData();
424+
});
425+
});
426+
427+
// Test this last so it does not stop delivery to DebugView
428+
describe('setAnalyticsCollectionEnabled()', function () {
429+
it('false', async function () {
430+
await firebase.analytics().setAnalyticsCollectionEnabled(false);
431+
});
432+
433+
// Enable as the last action, so the rest of the hits are visible in DebugView if enabled
434+
it('true', async function () {
435+
await firebase.analytics().setAnalyticsCollectionEnabled(true);
436+
});
437+
});
435438
});

packages/analytics/lib/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,12 @@ export namespace FirebaseAnalyticsTypes {
642642
*/
643643
export class Module extends FirebaseModule {
644644
/**
645-
* Log a custom event with optional params.
645+
* Log a custom event with optional params. Note that there are various limits that applied
646+
* to event parameters (total parameter count, etc), but analytics applies the limits during
647+
* cloud processing, the errors will not be seen as Promise rejections when you call logEvent.
648+
* While integrating this API in your app you are strongly encouraged to enable
649+
* [DebugView](https://firebase.google.com/docs/analytics/debugview) -
650+
* any errors in your events will show up in the firebase web console with links to relevant documentation
646651
*
647652
* #### Example
648653
*

packages/analytics/lib/index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,6 @@ class FirebaseAnalyticsModule extends FirebaseModule {
9494
);
9595
}
9696

97-
// maximum number of allowed params check
98-
if (params && Object.keys(params).length > 25) {
99-
throw new Error(
100-
"firebase.analytics().logEvent(_, *) 'params' maximum number of parameters exceeded (25).",
101-
);
102-
}
103-
10497
return this.native.logEvent(name, params);
10598
}
10699

0 commit comments

Comments
 (0)