Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Feedback Not liking user attributes limited to structs

Discussion in 'Unity Remote Config' started by tessellation, Sep 8, 2021.

  1. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    383
    We already have systems in place to create user attributes (properties) for analytics. These work by building up key-value-pairs in a dictionary and sending updates. These key/values are set at various places throughout the code from different systems in the game. For example, when the language is changed, we update the user's language from the localization system. Yes we know 'unity.language' already exists but ours is more precise than the ISO 639-1 one, and this is just one example.

    We'd like to to be able to just pass this dictionary to Remote Config so we can use it in campaigns. But right now the API requires a struct in the generic FetchConfigs() method. This requires us to define a struct at compile time instead of a more flexible dictionary-type. Internally you're already using JObject, which seems like it should be able to handle any kind of IEnumerable type, if it doesn't already.

    Thanks for listening.
     
  2. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    383
    I worked around this with a reflection hack and I confirmed this works using Charles Proxy:

    Code (CSharp):
    1. System.Type tt = typeof(ConfigManager);
    2. var _manager = (ConfigManagerImpl)tt.GetField("_configmanagerImpl", BF.Static | BF.NonPublic).GetValue(null);
    3. var userAttributes = new Dictionary<string, object>() { { "language", "en-US" }, { "sessions": 23 } };
    4. _manager.FetchConfigs(userAttributes, null);
    Please consider exposing this more flexible API in ConfigManager or creating an API that supports Dictionary<string, object>.