Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android][FirebaseAnalytics] Adds Null Params Handling to Firebase's logEvent #7897

Merged
merged 1 commit into from Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions apps/test-suite/tests/FirebaseAnalytics.js
Expand Up @@ -44,6 +44,26 @@ export async function test({ describe, beforeAll, afterAll, it, xit, expect }) {
expect(error).not.toBeNull();
});
});
describe('logEvent() - without optional properties', async () => {
itWhenConfigured(`runs`, async () => {
let error = null;
try {
await Analytics.logEvent('event_name');
} catch (e) {
error = e;
}
expect(error).toBeNull();
});
itWhenNotConfigured('fails when not configured', async () => {
let error = null;
try {
await Analytics.logEvent('event_name');
} catch (e) {
error = e;
}
expect(error).not.toBeNull();
});
});
describe('setCurrentScreen()', async () => {
itWhenConfigured(`runs`, async () => {
let error = null;
Expand Down
4 changes: 3 additions & 1 deletion packages/expo-firebase-analytics/CHANGELOG.md
Expand Up @@ -12,4 +12,6 @@

- Fix no events recorded on the Expo client when running on certain Android devices. ([#7679](https://github.com/expo/expo/pull/7679) by [@IjzerenHein](https://github.com/IjzerenHein))
- Fix `setAnalyticsCollectionEnabled` throwing an error.
- Fixes & improvements to the pure JS analytics client. ([#7796](https://github.com/expo/expo/pull/7796) by [@IjzerenHein](https://github.com/IjzerenHein))
- Fixes & improvements to the pure JS analytics client. ([#7796](https://github.com/expo/expo/pull/7796) by [@IjzerenHein](https://github.com/IjzerenHein))
- Fixed logEvent in `expo-firebase-analytics` for Android. logEvent's optional properties parameter was causing a NPE on Android when not provided. ([#7897](https://github.com/expo/expo/pull/7897) by [@thorbenprimke](https://github.com/thorbenprimke))

Expand Up @@ -81,7 +81,7 @@ public void logEvent(final String name, @Nullable Map<String, Object> params, Pr
FirebaseAnalytics analytics = getFirebaseAnalyticsOrReject(promise);
if (analytics == null)
return;
analytics.logEvent(name, new MapArguments(params).toBundle());
analytics.logEvent(name, params == null ? null : new MapArguments(params).toBundle());
promise.resolve(null);
} catch (Exception e) {
promise.reject(e);
Expand Down