Skip to content

Commit 6bc923e

Browse files
alex-vazquez-unity3dEvergreen
authored andcommitted
[content automatically redacted] touching PlatformDependent folder
1 parent e92ba39 commit 6bc923e

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

Packages/com.unity.render-pipelines.core/Editor/Analytics/AnalyticsUtils.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ static string[] ToStringArray(Dictionary<string, string> diff)
231231
/// <param name="current">The current object to obtain the fields and values.</param>
232232
/// <param name="compareAndSimplifyWithDefault">If a comparison against the default value must be done.</param>
233233
/// <returns>The nested columns in form of {key.nestedKey : value} </returns>
234-
/// <exception cref="ArgumentNullException"></exception>
235234
public static string[] ToNestedColumn<T>([DisallowNull] this T current, bool compareAndSimplifyWithDefault = false)
236235
where T : new()
237236
{
@@ -262,6 +261,28 @@ public static string[] ToNestedColumn<T>([DisallowNull] this T current, bool com
262261
return ToStringArray(diff);
263262
}
264263

264+
/// <summary>
265+
/// Obtains the Serialized fields and values in form of nested columns for BigQuery
266+
/// https://cloud.google.com/bigquery/docs/nested-repeated
267+
/// </summary>
268+
/// <typeparam name="T">The given type</typeparam>
269+
/// <param name="current">The current object to obtain the fields and values.</param>
270+
/// <param name="defaultInstance">The default instance to compare values</param>
271+
/// <returns>The nested columns in form of {key.nestedKey : value} </returns>
272+
public static string[] ToNestedColumn<T>([DisallowNull] this T current, T defaultInstance)
273+
{
274+
if (current == null)
275+
throw new ArgumentNullException(nameof(current));
276+
277+
if (defaultInstance == null)
278+
throw new ArgumentNullException(nameof(defaultInstance));
279+
280+
var type = current.GetType();
281+
282+
Dictionary<string, string> diff = GetDiffAsDictionary(type, current, defaultInstance);
283+
return ToStringArray(diff);
284+
}
285+
265286

266287
/// <summary>
267288
/// Obtains the Serialized fields and values in form of nested columns for BigQuery
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System;
2+
using UnityEditor.Build;
3+
using UnityEditor.Build.Reporting;
4+
using UnityEngine.Analytics;
5+
using UnityEngine.Rendering;
6+
7+
namespace UnityEditor.Rendering
8+
{
9+
class RenderPipelineGraphicsSettingsAnalytics : IPostprocessBuildWithReport
10+
{
11+
const int k_MaxEventsPerHour = 1000;
12+
const int k_MaxNumberOfElements = 1000;
13+
const string k_VendorKey = "unity.srp";
14+
const string k_EventName = "uRenderPipelineGraphicsSettingsUsage";
15+
16+
[AnalyticInfo(eventName: k_EventName, vendorKey: k_VendorKey, maxEventsPerHour: k_MaxEventsPerHour, maxNumberOfElements: k_MaxNumberOfElements)]
17+
public class Analytic : IAnalytic
18+
{
19+
[Serializable]
20+
public struct AnalyticsData : IAnalytic.IData
21+
{
22+
public string settings;
23+
public string[] usage;
24+
}
25+
26+
public bool TryGatherData(out IAnalytic.IData data, out Exception error)
27+
{
28+
data = GatherDataToBeSent();
29+
error = null;
30+
return true;
31+
}
32+
33+
public static IAnalytic.DataList<AnalyticsData> GatherDataToBeSent()
34+
{
35+
using (ListPool<AnalyticsData>.Get(out var tmp))
36+
{
37+
GraphicsSettings.ForEach(settings =>
38+
{
39+
var settingsType = settings.GetType();
40+
var usage = settings.ToNestedColumn(Activator.CreateInstance(settingsType));
41+
if (usage.Length != 0)
42+
tmp.Add(new AnalyticsData() { settings = settingsType.FullName, usage = usage });
43+
});
44+
45+
return new IAnalytic.DataList<AnalyticsData>(tmp.ToArray());
46+
}
47+
}
48+
}
49+
50+
static void SendUniversalEvent()
51+
{
52+
//The event shouldn't be able to report if this is disabled but if we know we're not going to report
53+
//Lets early out and not waste time gathering all the data
54+
if (!EditorAnalytics.enabled)
55+
return;
56+
57+
Analytic analytic = new Analytic();
58+
EditorAnalytics.SendAnalytic(analytic);
59+
}
60+
61+
public int callbackOrder { get; }
62+
public void OnPostprocessBuild(BuildReport report)
63+
{
64+
SendUniversalEvent();
65+
}
66+
}
67+
}

Packages/com.unity.render-pipelines.core/Editor/Analytics/RenderPipelineGraphicsSettingsAnalytics.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)