appcenter-sdk-dotnet icon indicating copy to clipboard operation
appcenter-sdk-dotnet copied to clipboard

Analytics.TrackEvent - allow different property types (besides string)

Open alexsorokoletov opened this issue 7 years ago • 15 comments

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.

alexsorokoletov avatar Jan 31 '18 14:01 alexsorokoletov

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

MatkovIvan avatar Jan 31 '18 14:01 MatkovIvan

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.

guperrot avatar Jan 31 '18 21:01 guperrot

@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.

alexsorokoletov avatar Jan 31 '18 21:01 alexsorokoletov

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 avatar Jan 31 '18 21:01 guperrot

@guperrot so where can I see custom properties then and why would I care using them? Is it only related to push audiences?

alexsorokoletov avatar Jan 31 '18 21:01 alexsorokoletov

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.

guperrot avatar Jan 31 '18 21:01 guperrot

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.

alexsorokoletov avatar Jan 31 '18 22:01 alexsorokoletov

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.

guperrot avatar Jan 31 '18 22:01 guperrot

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 avatar Jun 23 '18 22:06 MattiasFindwise

@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.

elamalani avatar Jun 23 '18 22:06 elamalani

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 avatar May 17 '19 11:05 mylemans

@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 avatar May 20 '19 19:05 elamalani

@elamalani, @guperrot any update on this? Especially time is a very important value to track instead splitting it in intervals like 1-10s etc..

gsgou avatar Oct 06 '21 08:10 gsgou

Hello @gsgou, and thank you for ping. We will clarify your question and update this conversation with results.

AnatolyPristensky avatar Oct 07 '21 11:10 AnatolyPristensky

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.

DmitriyKirakosyan avatar Oct 12 '21 14:10 DmitriyKirakosyan

As we do not have plans to add support for this feature in the next year, I'm closing the issue.

DmitriyKirakosyan avatar Sep 22 '23 06:09 DmitriyKirakosyan