Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 8d9833c

Browse files
committed
Added vsattribution
1 parent 73c0449 commit 8d9833c

10 files changed

+434
-0
lines changed

Editor.meta

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

Editor/Resources.meta

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

Editor/Resources/dolby.io-logo.png

Lines changed: 3 additions & 0 deletions
Loading

Editor/Resources/dolby.io-logo.png.meta

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

Editor/VSAttribution.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using UnityEngine.Analytics;
3+
4+
namespace UnityEditor.VSAttribution.DolbyIO
5+
{
6+
public static class VSAttribution
7+
{
8+
const int k_VersionId = 4;
9+
const int k_MaxEventsPerHour = 10;
10+
const int k_MaxNumberOfElements = 1000;
11+
12+
const string k_VendorKey = "unity.vsp-attribution";
13+
const string k_EventName = "vspAttribution";
14+
const string k_partnerName = "DolbyIO";
15+
16+
static bool RegisterEvent()
17+
{
18+
AnalyticsResult result = EditorAnalytics.RegisterEventWithLimit(k_EventName, k_MaxEventsPerHour,
19+
k_MaxNumberOfElements, k_VendorKey, k_VersionId);
20+
21+
var isResultOk = result == AnalyticsResult.Ok;
22+
return isResultOk;
23+
}
24+
25+
[Serializable]
26+
struct VSAttributionData
27+
{
28+
public string actionName;
29+
public string partnerName;
30+
public string customerUid;
31+
public string extra;
32+
}
33+
34+
/// <summary>
35+
/// Registers and attempts to send a Verified Solutions Attribution event.
36+
/// </summary>
37+
/// <param name="actionName">Name of the action, identifying a place this event was called from.</param>
38+
/// <param name="partnerName">Identifiable Verified Solutions Partner's name.</param>
39+
/// <param name="customerUid">Unique identifier of the customer using Partner's Verified Solution.</param>
40+
public static AnalyticsResult SendAttributionEvent(string actionName, string customerUid)
41+
{
42+
try
43+
{
44+
// Are Editor Analytics enabled ? (Preferences)
45+
if (!EditorAnalytics.enabled)
46+
return AnalyticsResult.AnalyticsDisabled;
47+
48+
if (!RegisterEvent())
49+
return AnalyticsResult.InvalidData;
50+
51+
// Create an expected data object
52+
var eventData = new VSAttributionData
53+
{
54+
actionName = actionName,
55+
partnerName = k_partnerName,
56+
customerUid = customerUid,
57+
extra = "{}"
58+
};
59+
60+
return EditorAnalytics.SendEventWithLimit(k_EventName, eventData, k_VersionId);
61+
}
62+
catch
63+
{
64+
// Fail silently
65+
return AnalyticsResult.AnalyticsDisabled;
66+
}
67+
}
68+
}
69+
}

Editor/VSAttribution.cs.meta

Lines changed: 11 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)