adaptyteam / AdaptySDK-Flutter

SDK for growing mobile in-app purchases
https://docs.adapty.io/docs/quickstart
MIT License
95 stars 17 forks source link

Maximum of 10 attributes for the profile #46

Closed otopba closed 2 years ago

otopba commented 2 years ago

Hi!

It seems if the following problem: If the profile already had 10 custom attributes and I try to update the custom attributes to other, but also in quantity of 10, I get an error "Maximum of 10 attributes for the profile".

Probably old parameters are not overwritten, and new ones are added to them. Because of this, the total sum of parameters becomes more than 10

x401om commented 2 years ago

Hi, @otopba! As I understood the issue right, you are making something like this:

1) Adding ten custom attributes:

        var builder = ProfileParameterBuilder()
        builder = builder.withCustomAttributes(
            [
                "key_1": "value_1",
                "key_2": "value_2",
                "key_3": "value_3",
                "key_4": "value_4",
                "key_5": "value_5",
                "key_6": "value_6",
                "key_7": "value_7",
                "key_8": "value_8",
                "key_9": "value_9",
                "key_10": "value_10",
            ]
        )

        Adapty.updateProfile(params: builder)

2) Trying to update one of them:

var builder = ProfileParameterBuilder()
        builder = builder.withCustomAttributes(
            [
                "key_1": "value_1001",
            ]
        )

        Adapty.updateProfile(params: builder)

3) Getting the error:

Error Domain=com.adapty.AdaptySDK Code=400 "Status: invalid. Details: Maximum of 10 attributes for the profile" UserInfo={NSLocalizedDescription=Status: invalid. Details: Maximum of 10 attributes for the profile}

I tested this with my environment and actually everything is fine. The value for the key_1 was overwritten without any error. But if you already have ten custom attributes, trying to add one more will cause the mentioned issue. If the issue is exactly as I described in the above steps, could you please enable verbose logging provide all the logs from the Adapty SDK?

otopba commented 2 years ago

@x401om Hi! Almost like this, I do the following:

        var builder = ProfileParameterBuilder()
        builder = builder.withCustomAttributes(
            [
                "key_1": "value_1",
                "key_2": "value_2",
                "key_3": "value_3",
                "key_4": "value_4",
                "key_5": "value_5",
                "key_6": "value_6",
                "key_7": "value_7",
                "key_8": "value_8",
                "key_9": "value_9",
                "key_10": "value_10",
            ]
        )

        Adapty.updateProfile(params: builder)

Trying to update like this:

        var builder = ProfileParameterBuilder()
        builder = builder.withCustomAttributes(
            [
                "key_1": "value_1",
                "key_2": "value_2",
                "key_3": "value_3",
                "key_4": "value_4",
                "key_5": "value_5",
                "key_6": "value_6",
                "key_7": "value_7",
                "key_8": "value_8",
                "key_9": "value_9",
                "key_11": "value_11",
            ]
        )

        Adapty.updateProfile(params: builder)

Note the last value

x401om commented 2 years ago

@otopba I see what the problem is. You are trying to create a new key_11, but nothing happens to the old key_10, so the system thinks you have reached the attribute limit. At the moment we don't have a special method for removing attributes, but you can pass an empty string instead of the value of the attribute you want to remove. Hope this helps.

We'll think about how to make it clearer to remove custom attributes.

otopba commented 2 years ago

@x401om

Yes, I understand. But it looks like a problem. It turns out I need to know which keys I'll ever use. And to clear all of them. That's very inconvenient.

I think it is enough to make a method not to update the keys, but to overwrite the keys