Skip to content

Conversation

ekcoh
Copy link
Collaborator

@ekcoh ekcoh commented Aug 29, 2024

Description

An attempt to revisit #1971 narrowing the introduced conditional compile guard to allow player analytics to pass through (like previous to 1.9.0) but gate editor analytics to when ENABLE_CLOUD_SERVICES_ANALYTICS is defined. See internal ticket ISX-2092 for reasoning. Still confused why this would make a difference for the target platform in the linked issue though, so still uncertain whether this is a correct fix.

Changes made

Narrowed scope of define introduced to not attempt to send editor analytics when platform not having it enabled.

Testing

Would need assistance, @lewish-unity if this tweak still resolves the build issue on consoles or if it reintroduces it.

Risk

Please describe the potential risks of your changes for the reviewers.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

Copy link
Collaborator

@lyndon-unity lyndon-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs testing to verify as I'm not convinced this is correct

Copy link
Collaborator

@lewish-unity lewish-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the errors that I was getting before the original fix and our Input Automated test suites pass.

However, I would like Consoles QA to have a proper test of this before it is merged as they have better test projects than me.

#endif // UNITY_INPUT_SYSTEM_ENABLE_ANALYTICS || UNITY_2023_1_OR_NEWER
#endif // UNITY_2023_2_OR_NEWER
#elif (UNITY_ANALYTICS) // Implicitly: !UNITY_EDITOR
#elif (ENABLE_CLOUD_SERVICES_ANALYTICS) // Implicitly: !UNITY_EDITOR && UNITY_ANALYTICS
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up, logged into a console VM and built a basically empty project for target hardware.

Interestingly enough I got these results in editor (build profile set to console profile):

UNITY_EDITOR:True, UNITY_ANALYTICS:False, ENABLE_CLOUD_SERVICES_ANALYTICS:False
UnityEngine.Debug:Log (object)
Symbols:Start () (at Assets/Symbols.cs:26)

And on target device (player):

UNITY_EDITOR:False, UNITY_ANALYTICS:False, ENABLE_CLOUD_SERVICES_ANALYTICS:False
UnityEngine.Debug:Log (object)
Symbols:Start () (at Assets/Symbols.cs:26)

Additionally, I removed the ENABLE_CLOUD_SERVICES_ANALYTICS check completely from NativeInputRuntime.cs and I could still build for the console without issues, both in editor and player based on how it's currently defined. This confused me since the original fix states this was not possible?

I then removed all checks/code but the Analytics.XXX part and that fails to build in editor in this case. Hence, guarding this with ENABLE_CLOUD_SERVICES_ANALYTICS makes sense.
Note: Previously guarded with UNITY_ANALYTICS which also happen to be false and hence why observation in paragraph above worked to compile as-is.

I then removed all but the EditorAnalytics part. This compiles/runs fine in editor and is excluded in player since guarded with UNITY_EDITOR.

Hence it boils down to ENABLE_CLOUD_SERVICES_ANALYTICS should be used for access to Analytics, i.e. the analytics module. However, whether UNITY_ANALYTICS should be checked or not remains an enigma to me. Probably it should since we had it there previously?

@ekcoh ekcoh requested a review from lyndon-unity September 11, 2024 21:35
#endif // UNITY_EDITOR

#if UNITY_ANALYTICS || UNITY_EDITOR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question remains whether UNITY_ANALYTICS should be a precondition here...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line #392

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on git history I would just assume it should, e.g. before I started to edit this it looked like this (dates back to 2018 when it was introduced) 6df6e11:

        public void RegisterAnalyticsEvent(string name, int maxPerHour, int maxPropertiesPerEvent)
        {
            #if UNITY_ANALYTICS
            const string vendorKey = "unity.input";
            #if UNITY_EDITOR
            EditorAnalytics.RegisterEventWithLimit(name, maxPerHour, maxPropertiesPerEvent, vendorKey);
            #else
            Analytics.Analytics.RegisterEvent(name, maxPerHour, maxPropertiesPerEvent, vendorKey);
            #endif // UNITY_EDITOR
            #endif // UNITY_ANALYTICS
        }

        public void SendAnalyticsEvent(string name, object data)
        {
            #if UNITY_ANALYTICS
            #if UNITY_EDITOR
            EditorAnalytics.SendEventWithLimit(name, data);
            #else
            Analytics.Analytics.SendEvent(name, data);
            #endif // UNITY_EDITOR
            #endif // UNITY_ANALYTICS
        }

Copy link
Collaborator

@lyndon-unity lyndon-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks simpler and tidier and what I would expect.

Not sure the CHANGELOG should be fix in the same commit but I don't have a problem with it either.

@ekcoh
Copy link
Collaborator Author

ekcoh commented Sep 12, 2024

@lewish-unity do you have some recommendations for console QA to verify the updated fix? I am pretty confident this is how it should be now.

@Pauliusd01
Copy link
Collaborator

Hi @cristian-murarescu could you help us with the playstation platform testing? Just need to see if there's any issues building/running its player

Copy link
Collaborator

@cristian-murarescu cristian-murarescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested PS4 & PS5 player builds & runs successfully.

Copy link
Collaborator

@Pauliusd01 Pauliusd01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, here's some things I checked:

  • tried deploying to Xbox VM without issues
  • checked that Analytics debugger shows same events as before when interacting with input related things (although I have to note that they seem kinda sparse in both versions, I don't know if I needed to enable anything extra but there wasn't anything for setting bindings, changing control schemes, etc. Things that were logged were context menu actions, interaction/processor adding and file saving)
  • checked basic actions window functionality and testing scenes on Windows

@ekcoh
Copy link
Collaborator Author

ekcoh commented Sep 23, 2024

LGTM, here's some things I checked:

  • tried deploying to Xbox VM without issues
  • checked that Analytics debugger shows same events as before when interacting with input related things (although I have to note that they seem kinda sparse in both versions, I don't know if I needed to enable anything extra but there wasn't anything for setting bindings, changing control schemes, etc. Things that were logged were context menu actions, interaction/processor adding and file saving)
  • checked basic actions window functionality and testing scenes on Windows

Hmmm that sounds odd, I will do a final check myself on desktop before merging then.

@ekcoh
Copy link
Collaborator Author

ekcoh commented Sep 23, 2024

@Pauliusd01 I checked this branch with Analytics debugger but couldn't see anything that looked odd to me.

@ekcoh ekcoh merged commit 7735517 into develop Sep 23, 2024
77 checks passed
@ekcoh ekcoh deleted the isx-2092 branch September 23, 2024 20:27
Pauliusd01 added a commit that referenced this pull request Oct 3, 2024
Pauliusd01 added a commit that referenced this pull request Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants