Nativescript-plugin-firebase: Opt-Out / Opt-In for Crashlytics - GDPR

Created on 2 May 2019  Â·  7Comments  Â·  Source: EddyVerbruggen/nativescript-plugin-firebase

Hi!

Thank you for your work and your plugin.

To use the Crashlytics part of firebase in a GDPR compliant way, it should be possible to prevent the use of Crashlytics for the user. Unfortunately there is currently no way to manage the initialization of Crashlytics depending on user settings.

The documentation of Firbase describes a way to "enable opt in reporting":
https://firebase.google.com/docs/crashlytics/customize-crash-reports#enable_opt-in_reporting

So it would be great to reflect this in firebase.init properties as we can do for analytics ( https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/docs/ANALYTICS.md#analyticssetanalyticscollectionenabled )

Thanks in advance

Android Crashlytics enhancement iOS

All 7 comments

Thanks for the request. I've added it to 8.3.0 which I will publish to npm momentarily.

Docs here.

Wow, that was fast. Amazing. Thanks for the good work.

After testing the flag the Android implementation seems to work, but we have problems with iOS. The app is crashing during firebase init. This is the stacktrace:

*** JavaScript call stack:
(
0   with@[native code]
1   @file:///app/tns_modules/nativescript-plugin-firebase/firebase.js:314:28
2   initializePromise@:1:11
3   Promise@[native code]
4   init@file:///app/tns_modules/nativescript-plugin-firebase/firebase.js:291:23
5   @file:///app/app.js:22:40
6   notify@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:110:31
7   @[native code]
8   notifyAppStarted@file:///app/tns_modules/tns-core-modules/application/application.js:142:36
9   didFinishLaunchingWithOptions@file:///app/tns_modules/tns-core-modules/application/application.js:134:30
10  @[native code]
11  onReceive@file:///app/tns_modules/tns-core-modules/application/application.js:32:32
12  UIApplicationMain@[native code]
13  start@file:///app/tns_modules/tns-core-modules/application/application.js:275:26
14  run@file:///app/tns_modules/tns-core-modules/application/application.js:303:10
15  anonymous@file:///app/app.js:44:18
16  evaluate@[native code]
17  moduleEvaluation@:1:11
18  promiseRea<…>

After analysing the stacktrace we guess that this line is causing the error.

Maybe it is worth to say how the firebase init is implemented:

import {
  on as applicationOn,
  launchEvent,
  LaunchEventData,
} from 'tns-core-modules/application';
import {
  analyticsConsent
} from './globals/analytics-utils';
import { init as firebaseInit } from 'nativescript-plugin-firebase';

applicationOn(launchEvent, (args: LaunchEventData) => {
  firebaseInit({
    analyticsCollectionEnabled: false,
    crashlyticsCollectionEnabled: analyticsConsent
  }).then(
    _ => {
      …
    },
    error => {
      Logger.error('Error during init of firebase', error);
    }
  );
});

run({ moduleName: 'app-root' });

Perhaps try removing your platforms/ios folders and removing node_modules will help, because I just tried this in the demo app in this repo and all was fine (see the screenshot where I added some logging to check a few things).

Screenshot 2019-05-13 at 20 47 14

Hi, the described problem can occur if firebase.init is called before the didFinishLaunching-Event inside the NativeScript-App. In that case FIRApp.configure() has not already been called and the call to Fabric.with(NSArray.arrayWithObject(Crashlytics.class())); will fail with the shown error-message.
One easy way to fix this problem inside the plugin would be to change the firebase.init - method to first call the FIRApp.configure() if needed and afterwards call Fabric.with(NSArray.arrayWithObject(Crashlytics.class()));.

Change to firebase.init inside firebase.ios.ts could be:

if (!firebase._configured) {
   firebase._configured = true;
    if (typeof (FIRApp) !== "undefined") {
        FIRApp.configure();
    }
}
if (arg.crashlyticsCollectionEnabled && typeof (Crashlytics) !== "undefined") { 
    Fabric.with(NSArray.arrayWithObject(Crashlytics.class()));
}

Yeah that's an easy fix. Added this change to 8.4.0.

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dopefatimah picture dopefatimah  Â·  3Comments

phatakrajan picture phatakrajan  Â·  4Comments

romandragan picture romandragan  Â·  3Comments

jlooper picture jlooper  Â·  3Comments

NickIliev picture NickIliev  Â·  3Comments