Search Unity

Question Providing custom implementation of IAnalyticsService?

Discussion in 'Unity Analytics' started by tbcoins, Jun 10, 2022.

  1. tbcoins

    tbcoins

    Joined:
    May 31, 2022
    Posts:
    11
    We're implementing our own analytics system and would like to not have developers report telemetry twice, once through Unity's APIs and once through our own.

    Is there a way we can provide our own implementation of IAnalyticsService that the Unity engine can use so that developers can target only the Unity APIs and use ours only when custom telemetry extensions are needed? It would make it easier for our developers to send telemetry while reducing the amount of code we need to maintain.

    Thanks in advance!
     
  2. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Hi tbcoins,
    thanks for posting on the forums.
    Could you provide a little more details on your use case? Id like to gather more information before submitting a feature request to our engineering team.
     
  3. tbcoins

    tbcoins

    Joined:
    May 31, 2022
    Posts:
    11
    Hey, thanks for replying!

    Before getting into the use case, I have a question that will probably help: does Unity use its own analytics APIs under the hood to report its own telemetry? Meaning, is the engine's stock analytics system that is exposed via AnalyticsService.Instance the same analytics system that the engine itself uses privately to handle its own telemetry (if at all)? The reason I'm asking hopefully will become clear when I explain our use case.

    We have our own cross-platform analytics system that we need to use, as it interfaces with multiple engines and we would like to allow developers to use each engine's native analytics APIs to keep things consistent within each engine. Meaning, Unity devs use Unity's APIs, and Unreal devs use Unreal's APIs, instead of everyone using our own custom APIs regardless of engine.

    There's a few reasons for this, one of them being engines and editors tend to already be tightly integrated with their own native analytics APIs (e.g. Unreal exposes its analytics functionality to Blueprint via a simple plugin: https://docs.unrealengine.com/4.27/en-US/TestingAndOptimization/Analytics/Blueprints/ ). But we'd rather not have to also maintain an Unreal plugin on top of everything else we already have to maintain, so we're opting to implement their IAnalyticsProvider interface and just letting the engine run with that. This hopefully explains why we are also curious if Unity can consume a custom implementation of AnalyticsService.Instance.

    Ideally, for any given engine, we would implement its native analytics interfaces and everything already built on top of the engine Just Works(tm). It's quite possible that Unity already enables this and that I'm just missing the docs and/or code that explains how to go about it.
     
  4. unity_Ctri

    unity_Ctri

    Unity Technologies

    Joined:
    Oct 20, 2020
    Posts:
    83
    Hey TBcoins,

    The UGS Analytics service is engine agnostic, and you can send data in from any game even if it's not made with unity.
    Whilst we don't provide SDKs for other engines, we have documented the underlying Rest API that the analytics package uses.

    Read more about it here: https://docs.unity.com/analytics/AnalyticsRestAPI.html

    You can use that to ingest events from any source, be that from a player device running a game not made with Unity, or from a back-end that you're using to record some events that are server authoratitive in nature.

    Hope that answers the question!
     
  5. tbcoins

    tbcoins

    Joined:
    May 31, 2022
    Posts:
    11
    Hey unity_Ctri, thanks for the info! That's helpful to know.

    The area that I'm asking about is in C# in the Unity engine itself. We'd like to be able to provide our own implementation of the Unity interface specified in C# so that any of our games built on Unity would simply use the Unity C# API to send up telemetry (to whatever service). This would achieve a few goals, one of them being that our Unity devs won't have to learn a new telemetry API or use two telemetry APIs at every call site. It also means, if the Unity engine does this, that any telemetry the Unity engine itself also sends would go through our implementation before being sent up (as I said, if that's even what the engine does, and it may not).

    Hopefully I'm explaining this clearly enough. I'm happy to answer more questions.
     
  6. tbcoins

    tbcoins

    Joined:
    May 31, 2022
    Posts:
    11
    Hi, just pinging to see if anyone can shed some light on this. Thanks!