appcenter-sdk-dotnet
                                
                                 appcenter-sdk-dotnet copied to clipboard
                                
                                    appcenter-sdk-dotnet copied to clipboard
                            
                            
                            
                        Analytics.TrackEvent - allow different property types (besides string)
Hi!
C# Analytics class allows us to track events with some extra properties.
However,  properties are accepted in a format of Dictionary<string,string>.
https://github.com/Microsoft/AppCenter-SDK-DotNet/blob/develop/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.iOS/Analytics.cs#L64
https://github.com/Microsoft/AppCenter-SDK-DotNet/blob/develop/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Android/Analytics.cs#L62
I was ok with that but then noticed in device logs this:
01-31 14:13:11.512: V/AppCenter(6888):       "properties": [
01-31 14:13:11.512: V/AppCenter(6888):         {
01-31 14:13:11.512: V/AppCenter(6888):           "name": "DriverId",
01-31 14:13:11.512: V/AppCenter(6888):           "type": "number",
01-31 14:13:11.512: V/AppCenter(6888):           "value": 163
01-31 14:13:11.512: V/AppCenter(6888):         },
01-31 14:13:11.512: V/AppCenter(6888):         {
01-31 14:13:11.512: V/AppCenter(6888):           "name": "ENV",
01-31 14:13:11.512: V/AppCenter(6888):           "type": "string",
01-31 14:13:11.512: V/AppCenter(6888):           "value": "INT"
01-31 14:13:11.512: V/AppCenter(6888):         }
So I assume AppCenter SDK tries to understand type of a data from string and then send it to the AppCenter API.
On the other hand, in the app code, we have to call .ToString() on anything that is not a string yet.
Feels like useless actions. We could have Dictionary<string, object> and you would have your type information without guessing and we would not have to call .ToString() all the time.
Maybe, somehow related is, that sometimes we have to send a string property with DateTime value inside (DateTime.UtcNow.ToString("u"))  and AppCenter sees that as a DateTime and then tries to recreate a DateTime.
And when it does, it creates a DateTime of a different kind (Kind = Local or Kind = Unspecified) and then this aligned UTC DateTime gets lost and misinterpreted by analytics.
Hi,
These logs related to custom properties API. We provide API for set different types for custom properties. You can see it here: https://github.com/Microsoft/AppCenter-SDK-DotNet/blob/develop/SDK/AppCenter/Microsoft.AppCenter.Android/CustomProperties.cs
Best, Ivan
Analytics do not support strong typed properties, yet, for now only strings values are supported. It has been considered but I am not aware of any ETA for now. Also this is more backend work than SDK work to make that happen.
@MatkovIvan @guperrot I see. Sorry for the confusion. That indeed looks like session parameters. I would not want to have that developed if it's not yet there. So I'm good with as it is.
Is there a way I can see them somehow in Event Flow or anywhere in Analytics?
I can see only CUSTOMPROPERTY {} and that's it.
Also, regarding datetime values in custom event properties in AppCenter portal - this probably is not an issue with the SDK but rather portal.
The server understands only string for event properties. Log flow does not support showing custom property details, if you want to request a feature on anything that is not SDK related, please contact us using the blue chat button on any page of https://appcenter.ms.
@guperrot so where can I see custom properties then and why would I care using them? Is it only related to push audiences?
For now its used only in Push audiences. The API was put in core as in the future we expect it to be used in Analytics, but there is no plan short term.
Thank you for the help. We can close the issue since everything works as it was designed and only comments left are related to the portal.
Well, in the future we plan to have strong typed properties for events (I think this has been requested before but not on github). But there is no short term plan. I feel like other people will request this anyway so we can keep it open. Up to you if you want to close.
Am I correct in my understanding that the properties of a custom event can only be a string? So if I send JSON object as properties it will be treated as a string? Any ETA when this will be updated?
@MattiasFindwise You are correct - we only support string as property type for custom events. We are looking to supporting other data types as well, however, there is no ETA yet. We will keep this thread posted once we decide to support it in App Center.
I see, at least on macOS, that there is a trackEvent with withTypedProperties, does .NET have this too now, and if so, what does it do? Or is everything still handled as strings internally? And if so, what is the use then for this?
@mylemans .NET SDK doesn't support strongly typed properties for events. Apple and Android platform supports typed properties but that is in preparation work for a future change in transmission protocol and endpoint for Analytics data. There is no impact on your current workflow when using App Center.
@elamalani, @guperrot any update on this? Especially time is a very important value to track instead splitting it in intervals like 1-10s etc..
Hello @gsgou, and thank you for ping. We will clarify your question and update this conversation with results.
Hi @gsgou , we confirmed with the backend team that the feature also requires changes on the backend side. Unfortunately there is no ETA for this feature at this moment, but we are keeping an eye on this thread. See more info in our Roadmap.
As we do not have plans to add support for this feature in the next year, I'm closing the issue.