firebase / firebase/firebase-ios-sdk
Screen Views are being captured after deleteApp on default app.
- Dominant language
- C++
- Stars
- 6.7k
- Forks
- 1.8k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 72
Description
### [READ] Step 1: Are you in the right place?
* I was asked to file an issue from the stack overflow thread where I posted my question. Link to the stack overflow thread is https://stackoverflow.com/questions/58386149/firebase-what-happens-when-we-call-delete-app-on-firapp-defaultapp?noredirect=1#comment103122091_58386149
### [REQUIRED] Step 2: Describe your environment
* Xcode version: Version 11.1 (11A1027)
* Firebase SDK version: 6.10.0
* Firebase Component: Firebase Analytics (Google Analytics)
* Component version: 6.1.3
### [REQUIRED] Step 3:
We are integrating Firebase Analytics into our application as we are moving from Google Analytics to Firebase Analytics. We initialize the FIRApp instance when user logs into the application and we want to delete the FIRApp instance when user logs out of the application.
We are doing this because in our application user can switch environments (Production/Staging/QA) and we do not want to capture Production Analytics when they switch environment to say Staging. So we only initialize the default FIRApp instance when we detect that user logs into the Production Environment and delete the default FIRApp instance when they logout. We are assuming that once the default FIRApp is deleted, the tracking should stop. But when we look at the analytics, it seems to capture the screens even when the user has deleted the FIRApp instance. I haven't seen any events being captured, but screens are being captured when I delete the FIRApp instance while the app is still running. **I can see the screen_views being reported in debug view.**
#### Steps to reproduce:
- On firebase console, choose an app and go to Analytics --> Debug View
- Now in iOS code, Initialize the default FIRApp instance using `[FIRApp config];` on a particular event say click of "Enable Analytics Button".
- Start navigating across the application and you will see that debug view will show screens being reported.
- Now delete the default FIRApp instance using `[FIRApp defaultApp] deleteApp:^(BOOL success){}];` on a click of another button say "Disable Analytics Button". This should happen while application is still running and is not restarted or killed.
- Start navigating across the application and in sometime you will see the screens being still captured in the debug view.
#### Relevant Code:
```
(void)initializeAnalyticsApp {
if ([CommonUtil isProductionServer]) {
if (![self isAnalyticsAppConfigured]) {
[FIRApp configure];
}
}
}
- (void)invalidateAnalyticsApp {
if ([self isAnalyticsAppConfigured]) {
[[FIRApp defaultApp] deleteApp:^(BOOL success) {
if (success) {
NSLog(@"Firebase Analytics App Deleted.");
}
}];
}
}
- (BOOL)isAnalyticsAppConfigured {
return [FIRApp defaultApp] != nil;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.