Search Unity

Is it possible to enable and disable Analytics through an editor script?

Discussion in 'Unity Analytics' started by Carpet_Head, Dec 30, 2017.

  1. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    97
    We are using Unity Analytics in our project, but do not want it to be active on certain platforms. Is it possible to switch it on and off via editor script?

    In a similar way to how we can write an editor script to change platform

    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);

    Is there some api similar to this:

    // EditorSettings.Analytics.Disable()
    // EditorSettings.PerformanceReporting.Disable()
     
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,198
    unityjingyao likes this.
  3. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    97
    is there any update to this? is it possible to disable it at build time. This would really help our build pipeline. Disabling it first thing as the player starts up still seems to send some analytics data

    Same for crash reporting
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,895
    You could try to manually edit the /ProjectSettings/UnityConnectSettings.Asset file
     
  5. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    97
    PerformanceReportingSettings.enabled = false;
    AnalyticsSettings.enabled = false;
    CrashReportingSettings.enabled = false;

    Looks like a new API was added ^
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,895
    Not sure what API you are referring to, but those settings should indeed disable Analytics.
     
  7. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    995

    Hi,

    Didn't start a new thread as think this is related.

    Not sure if those Api's are working. I used the following in my game;

    CB CODE.png


    The Disable HW Statistics selected;

    CB Disabled HW STATS.png

    I did a windows standalone build. Closed down the editor. Ran the build and monitored with Charles Proxy.

    Charles proxy shows that the build is still showing communication attempts to Unity;

    CB Charles result no clinet.png

    If this is normal then how do we get access to the information shared between our games and unity as this is a legal requirement for the newish USA export compliance and French equivalent.

    Thanks
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,895
    If you installed the Charles root certificate and rebooted, you should be able to view the contents of the request and response to see exactly what is being sent. You can find more information here https://unity3d.com/legal/gdpr You can email GDPR@unity3d.com with your GDPR related questions.
     
  9. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    995
    Hi @JeffDUnity3D,

    Thanks for the reply. I've read the links you referred to. It seems to be related to apps that have ads, marketing etc switched on. From what I understand the question relating to this thread (which is the same as mine) is how to make sure that no data is shared and no network communications attempted. Hence the need to switch of analytics through code as the thread starter asked. In my game I have attempted to turn off all network communications using the Unity provided API so the game is isolated with no need for any users to have to opt out of any such data collection etc.

    From following the API, unity manual and tutorials I thought this was achievable but it seems to not be the case demonstrated by charles proxy showing network communication generated by unity and not my code even though I am sure to have done everything required for this.

    The links you gave are not clear or helpful regarding this situation. I would have thought the APIs and selecting' Disable H W stats' would be enough

    Could you clarify then. Is it possible to stop unity collecting data? If not then are we devs expected to complete the requirements of the USA export compliance and french equivalents even when it's unity and not us that are collected the data. If this is the case could you provide an easy way for us to access the data you have gathered and providing that information to these USA and French regulatory agencies. Or when submitting products for distribution are we exempt from these legal requirements as it's unity who collect and have the data and not us?

    Thanks again.
     
  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,895
    The code that I shared should disable all data collection. As mentioned, any further questions should be directed to the GDPR team, thanks for understanding.
     
  11. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    995
    Sorry I missed the email you linked to, my fault. I'll contact them re the getting access to the data question.

    Re the code you referred to - Analytics.enabled = false;

    Should that have not stopped all the communication? This is what I'm finding confusing. I would have thought Charles proxy would report no connection attempts. Is this possible bug or am I misunderstanding it's full use?

    Thanks
     
  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,895
    Are you able to view the request and response content? We would not be expected to be collecting any data, perhaps it is a call simply to check internet access or your login. It is not a Unity Analytics end point. If you disable the Internet, do you get an error?
     
  13. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    995
    Unplugging the internet gives the following report

    No internet.png

    Previously with the internet on the Request and Response info as highlighted.

    WithResonseAndRequest.png

    No obvious info showing but seems like attempts of some kind made.

    Thanks
     
  14. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,895
    Agreed and likely as I stated. Please show the actual request and response content. You are only showing the Overview. Click the Structure tab on the left, then the Request and Response tabs will show the unencrypted data.
     
  15. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    995
    @JeffDUnity3D, It's only showing as encrypted info not plain text. Think would need to add the SSL location in ssl proxy settings for that. In case this is only a personal issue and not affecting others I can start a conversation as I don't want to spam this thread. Anything that maybe useful to/affectng others I can add post later.
     
  16. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,895
    Please see my previous post today at 5:35 pm. You need to install the Charles root certificate and reboot. Help/SSL Proxying/Install Charles Root Certificate. As mentioned, this is not an Analytics endpoint.
     
  17. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    995
    Got it. Will do all the tests again tomorrow. Thanks again.
     
  18. coshea

    coshea

    Joined:
    Dec 20, 2012
    Posts:
    251
    @docsavage hey, curious if you did any more testing with turning analytics off at run-time and any data sent out by Unity via Charles proxy?

    I'm going to look at this myself doing some test builds, curious to hear what you've found so far.

    Thanks
     
  19. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    995

    Hi,

    I didn't change anything other than using the API and disable HW statistics. For some reason the game always tries to connect with the network no matter what I do. I know this because the firewall tells me. In spite of this Charles proxy says there's no data transmitting. I'd prefer it to have a straightforward one command API that completely cut off any network access attempts. Basically a network kill switch for the built app. Unfortunately it doesn't seem to have one. Or at least if the ones that already exist should do this they aren't doing it that effectively.

    Thanks
     
  20. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,895
    Completely disabling the network is a separate issue. If you are looking to be compliant, the steps in this thread should suffice. This article discusses how to use Charles, and what to do if the events are still encrypted. https://support.unity3d.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity . However even if the requests are encrypted, you'll be able to see which endpoints are being hit which is sufficient for confirming. Please provide this information.
     
  21. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    995

    Hi @JeffDUnity3D,

    Thanks for this. I did those steps described in the article back in april. Retrying with the charles certificates etc that you advised (1st april). It still showed no data transferred but the connection attempts still occurring. Unfortunately I've can't get you the requested info with the endpoints info as currently in the middle of some massive PC housekeeping and rebuilds since finishing the game.

    You said completely disabling the network is a separate issue. Is it possible to completely disable the network for any build? If there is a way to kill any connection with any network for the builds that would be great to know.

    Thanks