Example #1
0
 public static string OptOutStatusToJson(DataPrivacy.OptOutStatus optOutStatus)
 {
     return(string.Format("{{\"OptOut\": {0},\"analyticsEnabled\": {1}, \"deviceStatsEnabled\": {2}, \"limitUserTracking\": {3}, \"performanceReportingEnabled\": {4} }}",
                          optOutStatus.optOut ? "true" : "false",
                          optOutStatus.analyticsEnabled ? "true" : "false",
                          optOutStatus.deviceStatsEnabled ? "true" : "false",
                          optOutStatus.limitUserTracking ? "true" : "false",
                          optOutStatus.performanceReportingEnabled ? "true" : "false"));
 }
Example #2
0
            public static void SetOptOutStatus(DataPrivacy.OptOutStatus optOutStatus)
            {
                try
                {
                    Analytics.enabled = Analytics.enabled && optOutStatus.analyticsEnabled;
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }

                try
                {
                    Analytics.deviceStatsEnabled = Analytics.deviceStatsEnabled && optOutStatus.deviceStatsEnabled;
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }

                try
                {
                    Analytics.limitUserTracking = Analytics.limitUserTracking || optOutStatus.limitUserTracking;
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
                #if UNITY_ANALYTICS
                try
                {
                    PerformanceReporting.enabled = PerformanceReporting.enabled && optOutStatus.performanceReportingEnabled;
                }
                catch (MissingMethodException)
                {
                    // Due to a broken binding, setting PerformanceReporting.enabled throws a
                    // MissingMethodException on 5.6 through 2017.2. A fix will be backported for all
                    // remaining supported versions (2017.1+), so try to set it anyway, and catch the
                    // exception if it happens.
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
                #endif
            }
Example #3
0
        internal static void SetOptOutStatus(DataPrivacy.OptOutStatus optOutStatus)
        {
            // Set each flag based on the settings passed in, but prioritize more restrictive
            // settings, so if a developer explicitly disables something in code, we don't
            // enable it with the default values passed back from the server.
            try
            {
                Analytics.enabled = Analytics.enabled && optOutStatus.analyticsEnabled;
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }

            try
            {
                Analytics.deviceStatsEnabled = Analytics.deviceStatsEnabled && optOutStatus.deviceStatsEnabled;
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }

            try
            {
                Analytics.limitUserTracking = Analytics.limitUserTracking || optOutStatus.limitUserTracking;
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
#if UNITY_ANALYTICS
            try
            {
                PerformanceReporting.enabled = PerformanceReporting.enabled && optOutStatus.performanceReportingEnabled;
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
#endif
        }
Example #4
0
            public static void SetOptOutStatus(DataPrivacy.OptOutStatus optOutStatus)
            {
                Type   sessionConfigType = null;
                object sessionConfig     = GetSessionConfigAndType(out sessionConfigType);

                if (sessionConfig == null || sessionConfigType == null)
                {
                    return;
                }

                FieldInfo enabledField = GetFieldUniversal(sessionConfigType, "m_AnalyticsEnabled", BindingFlags.Instance | BindingFlags.NonPublic);

                if (enabledField == null)
                {
                    return;
                }

                var currentValue = (bool)enabledField.GetValue(sessionConfig);

                enabledField.SetValue(sessionConfig, currentValue && optOutStatus.analyticsEnabled);
            }
Example #5
0
 public static string OptOutStatusToJson(DataPrivacy.OptOutStatus optOutStatus)
 {
     return(JsonUtility.ToJson(optOutStatus));
 }