Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Analytics creating folders and files in iOS Documents folder, although turned off

Discussion in 'Unity Analytics' started by RDL-BOT, Nov 18, 2019.

  1. RDL-BOT

    RDL-BOT

    Joined:
    May 16, 2019
    Posts:
    3
    Hello community,

    I got a problem with iOS devices and Unity Analytics. My app copys a file from StreamingAssets to the Documents folder on iOS devices, so the user can have acess to it. I set up the plist.info so the whole Documents folder appears for the user in Apple's File Browser. Everything works and is fine, but Unity keeps creating the directories "Unity/xxxx/Analytics/..." (shown in the attached picture below). I totally turned off Analytics in Services, turned off Editor Analytics (I know it should have nothing to do with Services/Analytics, but still turned off). Even put this in a MonoBehaviour:

    Code (CSharp):
    1.     using UnityEngine.Analytics;
    2.  
    3. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]  //.BeforeSplashScreen doesn't compile on iOS
    4.     static void disableAnalytics()
    5.     {
    6.         Analytics.enabled = false;
    7.         Analytics.deviceStatsEnabled = false;
    8.         Debug.Log("Disabled Analytics!");
    9.     }
    But still Unity creates the folders and files. In the automatically created config file also Analytics.enabled is set to true. What is wrong? If it's not possible to completely turn off Analytics, maybe one can change its flush path? I just want that Unity stops creating files and folders in Documents on iOS :(

    upload_2019-11-18_16-40-2.png
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please turn off Analytics in the Services window and create a new build and see if you are seeing the same behavior.
     
  3. Boerdler

    Boerdler

    Joined:
    Nov 18, 2019
    Posts:
    2
    Like I said: I turned off the Analytics in the Services Window. Already created new builds, then deleted folders and files in Apple's File Browser first, then deleted the App and then reinstalled the new builds. Still same behaviour!

    EDIT: Oops, RDL-Bot and Boerdler are the same developer. Please don't get confused why I replied with this account.
     
    Last edited: Nov 18, 2019
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You mentioned that your app "copies a file" etc. Does is still occur on a new project (or on the same project) when you don't do that and don't modify the plist.info? Also, it does sound like Analytics is still enabled on the project. I trust your debug log statement shows as being executed? I would encourage you to confirm by using Charles Proxy also https://support.unity3d.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity .
     
  5. RDL-BOT

    RDL-BOT

    Joined:
    May 16, 2019
    Posts:
    3
    Okay.
    1. I created a new project.
    2. Didn't modify the plist.info.
    3. Disabled Analytics in Services Window.
    4. Disabled HW statistics in Player Settings.
    5. No Analytics in Package Manager.
    6. Added the "disable Analytics" code mentioned above (debug log statement fires: see first attached screenshot).
    Still same behaviour. Unity creates Analytics files and folders (see second attached screenshot).
    Screenshot 2019-11-21 at 10.05.21.png

    Screenshot 2019-11-21 at 10.01.25.png
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I know it's a bit of a pain to ask, but can you confirm that the build isn't actually still sending events using Charles Proxy? https://support.unity3d.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity
     
  7. RDL-BOT

    RDL-BOT

    Joined:
    May 16, 2019
    Posts:
    3
    Hey Jeff,

    I carried out your instructions. I noticed that the app is still executing an HTTP request at the very beginning. Then it doesn't happen anymore. In the following picture you can see what was triggered:

    Analytics Problem Charles 1.PNG


    For comparison I tested one of our apps with Analytics enabled. There are significantly more requests in a short time. See the following picture:

    Analytics Problem Charles 2 (Analytics enabled).PNG

    Apparently Analytics is not completely disabled. What else could I do?

    Regards
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    The call that you see is checking to see if Analytics or any of the other Unity services are enabled, and it is not. We are not collecting/storing any data, it's a read-only request.
     
  9. Boerdler

    Boerdler

    Joined:
    Nov 18, 2019
    Posts:
    2
    Thanks for the reply. But how can I refuse Analytics from creating any files or folders in documents folder on iOS now? In my oppinion the created files and folders should not be in the Documents rather in Library. :/
     
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Agreed, we will need to test and confirm.
     
  11. nimravid

    nimravid

    Joined:
    Nov 21, 2018
    Posts:
    1
    I'm encountering exactly the same problem on iOS as Boerdler. One additional piece of information is that if you delete the Unity directory in Documents using the Files app, the directory immediately gets recreated when the Unity-based app gets foregrounded again. The file that gets created is called "values" and the contents are a bunch of empty tags as follows:

    {"config_etag":"","app_info_hash":0,"app_installed":false,"engine_ver":"","app_ver":"","registered_events":[]}
     
  12. takezoff

    takezoff

    Joined:
    Apr 11, 2019
    Posts:
    5
    To JeffDUnity3D

    The app I'm currently developing also wants to expose the Documents folder to users on iOS, but faces similar issues.
    I am using Analytics and IAP on Unity2018.4.

    Can I know the following about this issue:
    1. Where can I see the status of this issue?
    2. Will it be supported by the policy of changing the location where Analytics creates files under the Library folder?
    3. Will IAP have the same problem?
     
  13. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    There currently is not a bug on this, please submit one and provide the ID. You might try disabling Analytics at runtime in the meantime. IAP requires Analytics during installation, but you can disable Analytics as mentioned at runtime. It is undetermined if this will stop the files from being written, but worth a test.

    https://docs.unity3d.com/ScriptReference/RuntimeInitializeOnLoadMethodAttribute.html

    Code (CSharp):
    1.  
    2. Analytics.initializeOnStartup = false;
    3. Analytics.enabled = false;
    4. PerformanceReporting.enabled = false;
    5. Analytics.limitUserTracking = false;
    6. Analytics.deviceStatsEnabled = false;
     
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you test with Unity 2019.3 with Ads, IAP, CrashReporting and Analytics disabled?
     
  15. takezoff

    takezoff

    Joined:
    Apr 11, 2019
    Posts:
    5
    Thank you for your support.
    I submitted a bug report about files and folders automatically created under the Documents folder.

    Regarding the test you taught,
    Analytics in the Services Window of UnityEditor remains ON (because IAP is turned off if it is turned off)
    I added the following code and tried it on Unity2018.4.15f1 and Unity2019.2.17f1.

    Code (CSharp):
    1. [RuntimeInitializeOnLoadMethod (RuntimeInitializeLoadType.BeforeSceneLoad)]
    2. static void DisableAnalytics ()
    3. {
    4.     Analytics.initializeOnStartup = false;
    5.     Analytics.enabled = false;
    6.     PerformanceReporting.enabled = false;
    7.     Analytics.limitUserTracking = false;
    8.     Analytics.deviceStatsEnabled = false;
    9.     Debug.Log ("Disabled Analytics!");
    10. }
    As a result, both versions created Unity folders and files under the Documents folder.

    Also, in Unity2019.3.0f5, I tested with Ads (original unused), IAP, Analytics disabled, but the result was the same.
    I tried the following code for CrashReporting, but I couldn't disable it because of an error when building the iOS target.

    Code (CSharp):
    1. UnityEditor.CrashReporting.CrashReportingSettings.enabled = false;
    First, watch the status of the report.
     
  16. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Do you have the bugID ? And I don't believe CrashReporting is under the UnityEditor namespace, I entered it just as I wrote above.
     
  17. takezoff

    takezoff

    Joined:
    Apr 11, 2019
    Posts:
    5
    Is bugID the following number?
    1211659
    https://fogbugz.unity3d.com/default.asp?1211659_9tlseftrih7ign4p

    Code (CSharp):
    1. UnityEditor.CrashReporting.CrashReportingSettings.enabled = false;
    I used this for
    https://docs.unity3d.com/2019.2/Doc...ce/CrashReporting.CrashReportingSettings.html

    Certainly I seem to be misunderstanding what CrashReporting is pointing to and how to disable it.
    Is CrashReporting the CloudDiagnostics in the Services window?

    In Unity2019.3.0f5, I turned off Ads, IAP, CloudDiagnostics, and Analytics and tried it.
    Confirmed that the Documents/Unity folder and folders and files under it were not created immediately after the application started.

    Please point out if anything is wrong.
     
  18. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Glad you got it working with 2019.3! I will update the bug.
     
  19. takezoff

    takezoff

    Joined:
    Apr 11, 2019
    Posts:
    5
    To JeffDUnity3D

    Any progress since then on bugID:1211659?

    I want to publish files created by users to users themselves in the app I'm delivering, but I haven't enabled the UISupportsDocumentBrowser setting because of this bug.
    If it's not likely to be fixed in the near future, I'm thinking of implementing a way to access user-created files in the app.
    The version of Unity we use in our app is 2019.2.18f1, but if it's already up to date and fixed, we'll consider updating it.
     
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I don't see this being fixed any time soon.
     
  21. takezoff

    takezoff

    Joined:
    Apr 11, 2019
    Posts:
    5
    OK. I will handle it on the application side. Thank you.
     
  22. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Same problem on Unity 2021. Do you know how to disable Analitycs or move outside Documents on iOS?
     
  23. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    There it was. I missed disabling the Crashes and Exceptions from the Cloud Diagnostics service.
     
    JeffDUnity3D likes this.