Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Google Analytics in iOS simulator

Google Analytics is running in the iOS simulator.

This causes pollution in the console log which I can be looking for useful debugging information. Also, the data sent to Google is not indicative of an actual user using our app.

How can I disable the Google Analytics reporting just while running the app in iOS simulator?

like image 544
William Entriken Avatar asked Feb 26 '14 04:02

William Entriken


People also ask

How do I turn off a Google Analytics switch?

From the homepage, go to Nintendo's eShop and log in to your profile. Next, tap your profile icon and scroll to the bottom of the page that loads up on the next screen. Under Google Analytics Preferences, tap Change. Select Don't Share on the next screen.

How do I turn off Google Analytics flutter?

In summary, to disable temporarily, set FIREBASE_ANALYTICS_COLLECTION_ENABLED to NO in the GoogleServices-Info. plist file. To disable permanently, set FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES in the same plist file.

Does Firebase Analytics work on iOS simulator?

Yes, both simulator or device will work. Analytics clusters your events unless you specify it is a custom event.


3 Answers

Simple, this is taken straight from the Google Analytics webpage :

[[GAI sharedInstance] setDryRun:YES];

Dry Run :
The SDK provides a dryRun flag that when set, prevents any data from being sent to Google Analytics. The dryRun flag should be set whenever you are testing or debugging an implementation and do not want test data to appear in your Google Analytics reports.

Hope this helps

like image 152
Andy Avatar answered Oct 30 '22 04:10

Andy


Yes, Setting DryRun to YES will fix this issue.

@Full Decent - Is there a way to also not have Google Analytics pollute my console logs?

We can disable Google Analytics logging in Xcode console using the below method.

[[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelNone];

Or in Swift:

GAI.sharedInstance().logger.logLevel = GAILogLevel.None

like image 41
user2613441 Avatar answered Oct 30 '22 04:10

user2613441


Wrapping it in #if TARGET_IPHONE_SIMULATOR #endif will not work in swift, as that flag is for objective-c only. What you could do is follow this guide

Detect if app is being built for device or simulator in Swift

like image 38
Bogdan Razvan Avatar answered Oct 30 '22 02:10

Bogdan Razvan