Question

When should I set subscriber attributes?

  • 19 January 2023
  • 2 replies
  • 26 views

Badge +1

In the docs it says:

Subscriber attributes are only synced with RevenueCat servers on app launch, app backgrounded, and when purchases are made or restored.

https://www.revenuecat.com/docs/subscriber-attributes 

 

Is “App launch” meant literally or do they mean once `Purchases.configure(‘SDK_KEY’);` is called?

When exactly should I call `Purchases.setAttributes({ "age" : "24", "custom_group_id" : "abc123" });` then? Before `Purchases.configure();`, or after, or does it not matter because the app has already “launched” and the attributes will only be synced later?

 


2 replies

Userlevel 4
Badge +9

Hello!

Thanks for your feedback, I updated the docs to say “when Purchases.configure() is called” instead of “app launch” as that is more correct.

It’s impossible to set attributes before configure is called so you have to wait until after configure, but I would recommend setting the attributes as soon as you have them. Really what’s going on here is efficient batching and sending of subscriber attributes, so it’s less about timing and more about adding attributes to the queue as soon as you have them so that the next time the SDK sends attributes to the API, your attributes get sent.

You can sidestep this behavior by calling our API endpoint directly, although you lose out on efficiency and simplicity.

Badge +1

 

It’s impossible to set attributes before configure is called so you have to wait until after configure, but I would recommend setting the attributes as soon as you have them.

Well, in my case that would be before I call configure 😃 To clarify, if I do…

Purchases.configure(‘SDK_KEY’);
Purchases.setAttributes({"age" : "24", "custom_group_id" : "abc123"});

...will the attributes be set immediately or only the next time the app is backgrounded or there is a change to the user/subscription (purchase/restore/renewal/cancelation/etc)?

 

Reply