Skip to content

Commit

Permalink
Merge pull request #203 from Countly/UserPropertiesNullWarning
Browse files Browse the repository at this point in the history
User Properties Null Warning
  • Loading branch information
turtledreams authored Mar 26, 2024
2 parents 2bf4d43 + ce3a1d7 commit 2ad9ad5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
17 changes: 3 additions & 14 deletions Assets/Countly/Example/Scripts/UserDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ public async void SetUserDetail()

public async void SetCustomUserDetail()
{
Dictionary<string, object> userCustomDetail = null;

Countly.Instance.UserDetails.SetCustomUserDetails(userCustomDetail);
userCustomDetail = new Dictionary<string, object> {
Dictionary<string, object> userCustomDetail = new Dictionary<string, object> {
{ "Language", "English" },
{ "Height", "5.9" },
{ "Empty Value", "" }, // valid
{ "Null Value", null } // invalid
};
Countly.Instance.UserDetails.SetCustomUserDetails(userCustomDetail);

Expand All @@ -46,64 +45,55 @@ public async void SetPropertyOnce()
{
Countly.Instance.UserDetails.SetOnce("Distance", "10KM");
await Countly.Instance.UserDetails.SaveAsync();

}

public async void IncrementValue()
{
Countly.Instance.UserDetails.Increment("Weight");
await Countly.Instance.UserDetails.SaveAsync();

}

public async void IncrementBy()
{
Countly.Instance.UserDetails.IncrementBy("ShoeSize", 2);
await Countly.Instance.UserDetails.SaveAsync();

}

public async void Multiply()
{
Countly.Instance.UserDetails.Multiply("PetNumber", 2);
await Countly.Instance.UserDetails.SaveAsync();

}

public async void Max()
{
Countly.Instance.UserDetails.Max("TravelDistance", 90);
await Countly.Instance.UserDetails.SaveAsync();

}

public async void Min()
{
Countly.Instance.UserDetails.Min("YearsExperience", 10);
await Countly.Instance.UserDetails.SaveAsync();

}

public async void Push()
{
Countly.Instance.UserDetails.Push("Area", new string[] { "width", "height" });
await Countly.Instance.UserDetails.SaveAsync();

}

public async void PushUnique()
{
Countly.Instance.UserDetails.PushUnique("Mole", new string[] { "Left Cheek", "Right Cheek" });
await Countly.Instance.UserDetails.SaveAsync();

}

public async void Pull()
{
//Remove one or many values
Countly.Instance.UserDetails.Pull("Cat", new string[] { "Claw" });
await Countly.Instance.UserDetails.SaveAsync();

}

public async void RecordMultiple()
Expand All @@ -113,6 +103,5 @@ public async void RecordMultiple()
Countly.Instance.UserDetails.SetOnce("FavoriteColor", "Blue");
Countly.Instance.UserDetails.Push("Inventory", new string[] { "Sword", "Shield", "Armor" });
await Countly.Instance.UserDetails.SaveAsync();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ protected IDictionary<string, object> FixSegmentKeysAndValues(IDictionary<string
string k = item.Key;
object v = item.Value;

if (k == null || k.Length == 0 || v == null) {
if (k == null || k.Length == 0) {
Log.Warning($"[{GetType().Name}] FixSegmentKeysAndValues: Provided key is {(k == null ? "null" : "empty")}, will be skipped.");
continue;
}
if (v == null) {
Log.Warning($"[{GetType().Name}] FixSegmentKeysAndValues: Provided value for '{k}' is null, will be skipped.");
continue;
}

Expand Down

0 comments on commit 2ad9ad5

Please sign in to comment.