Skip to content

Commit 4c4e8dd

Browse files
committed
Renamed analytic class and event to reflect the event of exiting play mode to allow for extensions.
1 parent e10d470 commit 4c4e8dd

File tree

6 files changed

+44
-45
lines changed

6 files changed

+44
-45
lines changed

Assets/Tests/InputSystem/CoreTests_Analytics.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -667,48 +667,48 @@ public void Analytics_ShouldReportPlayerInputManagerData()
667667
[Category("Analytics")]
668668
public void Analytics_ShouldReportCodeAuthoringAnalytic()
669669
{
670-
CollectAnalytics(InputActionCodeAuthoringAnalytic.kEventName);
670+
CollectAnalytics(InputExitPlayModeAnalytic.kEventName);
671671

672672
// NOTE: We do not want to trigger entering/exiting play-mode for this small data-sanity check
673673
// so just stick to triggering it explicitly. A better test would have been an editor test
674674
// going in and out of play-mode for real but not clear if this is really possible.
675675

676676
// Pretend we are entering play-mode
677-
InputActionCodeAuthoringAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode);
678-
InputActionCodeAuthoringAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode);
677+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode);
678+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode);
679679

680680
// Assert no data received
681681
Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(0));
682682

683683
// Pretend we are exiting play-mode
684-
InputActionCodeAuthoringAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode);
685-
InputActionCodeAuthoringAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode);
684+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode);
685+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode);
686686

687687
// Assert: Data received
688688
Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(1));
689-
Assert.That(sentAnalyticsEvents[0].name, Is.EqualTo(InputActionCodeAuthoringAnalytic.kEventName));
690-
Assert.That(sentAnalyticsEvents[0].data, Is.TypeOf<InputActionCodeAuthoringAnalytic.Data>());
689+
Assert.That(sentAnalyticsEvents[0].name, Is.EqualTo(InputExitPlayModeAnalytic.kEventName));
690+
Assert.That(sentAnalyticsEvents[0].data, Is.TypeOf<InputExitPlayModeAnalytic.Data>());
691691

692-
var data0 = (InputActionCodeAuthoringAnalytic.Data)sentAnalyticsEvents[0].data;
692+
var data0 = (InputExitPlayModeAnalytic.Data)sentAnalyticsEvents[0].data;
693693
Assert.That(data0.uses_code_authoring, Is.False);
694694

695695
// Pretend we are entering play-mode
696-
InputActionCodeAuthoringAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode);
697-
InputActionCodeAuthoringAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode);
696+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode);
697+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode);
698698

699699
var action = new InputAction("Dance");
700700
action.AddBinding("<Keyboard>/Space");
701701

702702
// Pretend we are exiting play-mode
703-
InputActionCodeAuthoringAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode);
704-
InputActionCodeAuthoringAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode);
703+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode);
704+
InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode);
705705

706706
// Assert: Data received
707707
Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(2));
708-
Assert.That(sentAnalyticsEvents[1].name, Is.EqualTo(InputActionCodeAuthoringAnalytic.kEventName));
709-
Assert.That(sentAnalyticsEvents[1].data, Is.TypeOf<InputActionCodeAuthoringAnalytic.Data>());
708+
Assert.That(sentAnalyticsEvents[1].name, Is.EqualTo(InputExitPlayModeAnalytic.kEventName));
709+
Assert.That(sentAnalyticsEvents[1].data, Is.TypeOf<InputExitPlayModeAnalytic.Data>());
710710

711-
var data1 = (InputActionCodeAuthoringAnalytic.Data)sentAnalyticsEvents[1].data;
711+
var data1 = (InputExitPlayModeAnalytic.Data)sentAnalyticsEvents[1].data;
712712
Assert.That(data1.uses_code_authoring, Is.True);
713713
}
714714

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionSetupExtensions.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ public static BindingSyntax AddBinding(this InputAction action, string path, str
316316
/// be incorrectly registered.
317317
/// </remarks>
318318
#if UNITY_EDITOR
319-
private static void RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api api)
319+
private static void RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api api)
320320
{
321-
UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Register(api);
321+
UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Register(api);
322322
}
323323

324324
#endif
@@ -367,7 +367,7 @@ public static BindingSyntax AddBinding(this InputAction action, InputControl con
367367
public static BindingSyntax AddBinding(this InputAction action, InputBinding binding = default)
368368
{
369369
#if UNITY_EDITOR
370-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.AddBinding);
370+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddBinding);
371371
#endif
372372

373373
if (action == null)
@@ -500,7 +500,7 @@ public static BindingSyntax AddBinding(this InputActionMap actionMap, string pat
500500
public static BindingSyntax AddBinding(this InputActionMap actionMap, InputBinding binding)
501501
{
502502
#if UNITY_EDITOR
503-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.AddBinding);
503+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddBinding);
504504
#endif
505505

506506
if (actionMap == null)
@@ -527,7 +527,7 @@ public static CompositeSyntax AddCompositeBinding(this InputAction action, strin
527527
string interactions = null, string processors = null)
528528
{
529529
#if UNITY_EDITOR
530-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.AddCompositeBinding);
530+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddCompositeBinding);
531531
#endif
532532

533533
if (action == null)
@@ -610,7 +610,7 @@ private static int AddBindingInternal(InputActionMap map, InputBinding binding,
610610
public static BindingSyntax ChangeBinding(this InputAction action, int index)
611611
{
612612
#if UNITY_EDITOR
613-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.ChangeBinding);
613+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeBinding);
614614
#endif
615615

616616
if (action == null)
@@ -672,7 +672,7 @@ public static BindingSyntax ChangeBinding(this InputAction action, string name)
672672
public static BindingSyntax ChangeBinding(this InputActionMap actionMap, int index)
673673
{
674674
#if UNITY_EDITOR
675-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.ChangeBinding);
675+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeBinding);
676676
#endif
677677

678678
if (actionMap == null)
@@ -874,7 +874,7 @@ public static BindingSyntax ChangeBinding(this InputAction action, InputBinding
874874
public static BindingSyntax ChangeCompositeBinding(this InputAction action, string compositeName)
875875
{
876876
#if UNITY_EDITOR
877-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.ChangeCompositeBinding);
877+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeCompositeBinding);
878878
#endif
879879

880880
if (action == null)
@@ -919,7 +919,7 @@ public static BindingSyntax ChangeCompositeBinding(this InputAction action, stri
919919
public static void Rename(this InputAction action, string newName)
920920
{
921921
#if UNITY_EDITOR
922-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.Rename);
922+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.Rename);
923923
#endif
924924

925925
if (action == null)
@@ -965,7 +965,7 @@ public static void Rename(this InputAction action, string newName)
965965
public static void AddControlScheme(this InputActionAsset asset, InputControlScheme controlScheme)
966966
{
967967
#if UNITY_EDITOR
968-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.AddControlScheme);
968+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddControlScheme);
969969
#endif
970970

971971
if (asset == null)
@@ -1037,7 +1037,7 @@ public static ControlSchemeSyntax AddControlScheme(this InputActionAsset asset,
10371037
public static void RemoveControlScheme(this InputActionAsset asset, string name)
10381038
{
10391039
#if UNITY_EDITOR
1040-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.RemoveControlScheme);
1040+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.RemoveControlScheme);
10411041
#endif
10421042

10431043
if (asset == null)
@@ -1061,7 +1061,7 @@ public static void RemoveControlScheme(this InputActionAsset asset, string name)
10611061
public static InputControlScheme WithBindingGroup(this InputControlScheme scheme, string bindingGroup)
10621062
{
10631063
#if UNITY_EDITOR
1064-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.ControlSchemeWithBindingGroup);
1064+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithBindingGroup);
10651065
#endif
10661066

10671067
return new ControlSchemeSyntax(scheme).WithBindingGroup(bindingGroup).Done();
@@ -1070,7 +1070,7 @@ public static InputControlScheme WithBindingGroup(this InputControlScheme scheme
10701070
public static InputControlScheme WithDevice(this InputControlScheme scheme, string controlPath, bool required)
10711071
{
10721072
#if UNITY_EDITOR
1073-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.ControlSchemeWithDevice);
1073+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithDevice);
10741074
#endif
10751075

10761076
if (required)
@@ -1081,7 +1081,7 @@ public static InputControlScheme WithDevice(this InputControlScheme scheme, stri
10811081
public static InputControlScheme WithRequiredDevice(this InputControlScheme scheme, string controlPath)
10821082
{
10831083
#if UNITY_EDITOR
1084-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.ControlSchemeWithRequiredDevice);
1084+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithRequiredDevice);
10851085
#endif
10861086

10871087
return new ControlSchemeSyntax(scheme).WithRequiredDevice(controlPath).Done();
@@ -1090,7 +1090,7 @@ public static InputControlScheme WithRequiredDevice(this InputControlScheme sche
10901090
public static InputControlScheme WithOptionalDevice(this InputControlScheme scheme, string controlPath)
10911091
{
10921092
#if UNITY_EDITOR
1093-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.ControlSchemeWithOptionalDevice);
1093+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithOptionalDevice);
10941094
#endif
10951095

10961096
return new ControlSchemeSyntax(scheme).WithOptionalDevice(controlPath).Done();
@@ -1099,7 +1099,7 @@ public static InputControlScheme WithOptionalDevice(this InputControlScheme sche
10991099
public static InputControlScheme OrWithRequiredDevice(this InputControlScheme scheme, string controlPath)
11001100
{
11011101
#if UNITY_EDITOR
1102-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.ControlSchemeOrWithRequiredDevice);
1102+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeOrWithRequiredDevice);
11031103
#endif
11041104

11051105
return new ControlSchemeSyntax(scheme).OrWithRequiredDevice(controlPath).Done();
@@ -1108,7 +1108,7 @@ public static InputControlScheme OrWithRequiredDevice(this InputControlScheme sc
11081108
public static InputControlScheme OrWithOptionalDevice(this InputControlScheme scheme, string controlPath)
11091109
{
11101110
#if UNITY_EDITOR
1111-
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputActionCodeAuthoringAnalytic.Api.ControlSchemeOrWithOptionalDevice);
1111+
RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeOrWithOptionalDevice);
11121112
#endif
11131113

11141114
return new ControlSchemeSyntax(scheme).OrWithOptionalDevice(controlPath).Done();
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace UnityEngine.InputSystem.Editor
1010
[UnityEngine.Analytics.AnalyticInfo(eventName: kEventName, maxEventsPerHour: kMaxEventsPerHour,
1111
maxNumberOfElements: kMaxNumberOfElements, vendorKey: UnityEngine.InputSystem.InputAnalytics.kVendorKey)]
1212
#endif // UNITY_2023_2_OR_NEWER
13-
internal class InputActionCodeAuthoringAnalytic : UnityEngine.InputSystem.InputAnalytics.IInputAnalytic
13+
internal class InputExitPlayModeAnalytic : UnityEngine.InputSystem.InputAnalytics.IInputAnalytic
1414
{
15-
public const string kEventName = "input_action_code_authoring";
15+
public const string kEventName = "input_exit_playmode";
1616
public const int kMaxEventsPerHour = 100; // default: 1000
1717
public const int kMaxNumberOfElements = 100; // default: 1000
1818

@@ -71,7 +71,6 @@ public static bool suppress
7171
// Note: Internal visibility to simplify unit testing
7272
internal static void OnPlayModeStateChange(PlayModeStateChange change)
7373
{
74-
Debug.Log("Play mode state change: " + change);
7574
if (change == PlayModeStateChange.ExitingEditMode)
7675
{
7776
// Reset all counters when exiting edit mode
@@ -85,7 +84,7 @@ internal static void OnPlayModeStateChange(PlayModeStateChange change)
8584
{
8685
// Send analytics and unhook delegate when exiting play-mode
8786
EditorApplication.playModeStateChanged -= PlayModeChanged;
88-
new InputActionCodeAuthoringAnalytic().Send();
87+
new InputExitPlayModeAnalytic().Send();
8988

9089
// No reason to not suppress
9190
suppress = true;
@@ -100,13 +99,13 @@ private static void Hook()
10099
EditorApplication.playModeStateChanged += PlayModeChanged;
101100
}
102101

103-
private InputActionCodeAuthoringAnalytic()
102+
private InputExitPlayModeAnalytic()
104103
{
105104
info = new InputAnalytics.InputAnalyticInfo(kEventName, kMaxEventsPerHour, kMaxNumberOfElements);
106105
}
107106

108107
/// <summary>
109-
/// Represents InputAction code authoring editor data.
108+
/// Represents data collected when exiting play-mode..
110109
/// </summary>
111110
/// <remarks>
112111
/// Ideally this struct should be readonly but then Unity cannot serialize/deserialize it.
@@ -117,7 +116,7 @@ public struct Data : UnityEngine.InputSystem.InputAnalytics.IInputAnalyticData
117116
/// <summary>
118117
/// Creates a new <c>Data</c> instance.
119118
/// </summary>
120-
/// <param name="usesCodeAuthoring">Specifies whether code authoring has been used.</param>
119+
/// <param name="usesCodeAuthoring">Specifies whether code authoring has been used during play-mode.</param>
121120
public Data(bool usesCodeAuthoring)
122121
{
123122
uses_code_authoring = usesCodeAuthoring;

Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ private void Start()
9292
m_PointerDownAction = new InputAction();
9393

9494
#if UNITY_EDITOR
95-
InputActionCodeAuthoringAnalytic.suppress = true;
95+
InputExitPlayModeAnalytic.suppress = true;
9696
#endif
9797
m_PointerDownAction.AddBinding("<Mouse>/leftButton");
9898
m_PointerDownAction.AddBinding("<Pen>/tip");
9999
m_PointerDownAction.AddBinding("<Touchscreen>/touch*/press");
100100
m_PointerDownAction.AddBinding("<XRController>/trigger");
101101
#if UNITY_EDITOR
102-
InputActionCodeAuthoringAnalytic.suppress = false;
102+
InputExitPlayModeAnalytic.suppress = false;
103103
#endif
104104
}
105105

@@ -109,13 +109,13 @@ private void Start()
109109
m_PointerMoveAction = new InputAction();
110110

111111
#if UNITY_EDITOR
112-
InputActionCodeAuthoringAnalytic.suppress = true;
112+
InputExitPlayModeAnalytic.suppress = true;
113113
#endif
114114
m_PointerMoveAction.AddBinding("<Mouse>/position");
115115
m_PointerMoveAction.AddBinding("<Pen>/position");
116116
m_PointerMoveAction.AddBinding("<Touchscreen>/touch*/position");
117117
#if UNITY_EDITOR
118-
InputActionCodeAuthoringAnalytic.suppress = false;
118+
InputExitPlayModeAnalytic.suppress = false;
119119
#endif
120120
}
121121

Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ void BindTrackingState()
310310
private void RenameAndEnable(InputAction action, string name)
311311
{
312312
#if UNITY_EDITOR
313-
Editor.InputActionCodeAuthoringAnalytic.suppress = true;
313+
Editor.InputExitPlayModeAnalytic.suppress = true;
314314
#endif
315315
action.Rename(name);
316316
#if UNITY_EDITOR
317-
Editor.InputActionCodeAuthoringAnalytic.suppress = false;
317+
Editor.InputExitPlayModeAnalytic.suppress = false;
318318
#endif
319319
action.Enable();
320320
}

0 commit comments

Comments
 (0)