Question

lots of $RCAnonymousID's

  • 3 January 2022
  • 3 replies
  • 260 views

Badge +5

Hi, if I understand the docs wel, we must do as soon as possible when the app starts do a Purchases.setup()

And then when we have our own UID (after logging into our backend) we do a Purchases.logIn(our_ID)

But when a user is logging out en back in again, another $RCAnonymousID is created and stored on the RC backend. That can add up and genereate a lot of unused $RCAnonymousID’s...or do I something wrong?

 

logging;

start the app for the first time.
====> APP didMount(): after Purchases.setup(), getAppUserID:  $RCAnonymousID:5cf2ccddfeb64208aca7e1c8a58ab9ab

here we do in the app a login into our own backend and recieve our UID for this customer

====> RC LOGIN: before Purchases.logIn(id), getAppUserID:  $RCAnonymousID:5cf2ccddfeb64208aca7e1c8a58ab9ab
====> RC LOGIN: after Purchases.logIn(id), getAppUserID:  615de0706b15db0ea9eb1555

logged in customer goes to the paywall and purchase
====> RC PAYWALL: before Purchases.getOfferings(), getAppUserID:  615de0706b15db0ea9eb1555
====> RC PAYWALL: before Purchases.purchasePackage(package), getAppUserID:  615de0706b15db0ea9eb1555

during the lifetime of the app, even after a restart of the app, the getAppUserID stays the same (must be cached on the phone)
and the entitlements are found.

====> APP didMount(): after Purchases.setup(), getAppUserID:  615de0706b15db0ea9eb1555


then i do logout inside our app (or the JWT tokens gets invalid and the customer needs to login again) 
and a new $RCAnonymousID get's created.
====> RC LOGOUT: before Purchases.logOut(), getAppUserID:  615de0706b15db0ea9eb1555
====> RC LOGOUT: after Purchases.logOut(), getAppUserID:  $RCAnonymousID:871a3ea51b8c4fca842ad0b976c5eecf


swipe app from memory, and restart app and AppUserID keeps same, so must again be stored at telephone
====> APP didMount(): after Purchases.setup(), getAppUserID:  $RCAnonymousID:871a3ea51b8c4fca842ad0b976c5eecf
====> RC LOGIN: before Purchases.logIn(id), getAppUserID:  $RCAnonymousID:871a3ea51b8c4fca842ad0b976c5eecf
====> RC LOGIN: after Purchases.logIn(id), getAppUserID:  615de0706b15db0ea9eb1555

back to the entiled user....


BUT...now there are 2 $RCAnonymousID's show up at our RC dashboard and those are groing when people are logging out of our app.
Is this normal? As designed?

 


3 replies

Badge +5

I will keep it like advised by do the setup() as soon as the app starts.

Can you explain why it is that when after I did a login(id) the AppUserID changed for Purchases.getAppUserID() to our own provided userid, but on de RC (web) dashboard in the customer profile there the AppUserID is the $RCAnonymous ID. Would be nice that the dashboard also is showing the provided (custom) userid als AppUserID

Badge +5

Thanks Sharif. Good to know about the transfer on restore.

I know that it is not advisable, but what if we do it like this:

  1. App starts: Purchases.setDebugLogsEnabled(true)
  2. People have to login into our app, otherwise they can’t use the app/content.
  3. After they successful login we have our own UID, then we do:
  4. Purchases.setup(key, UID)
  5. Purchases.login(UID), first time? we also set some RC attributes.
  6. When the JWT token stored local for our authentication is not valid any more they have to login en go to step 2
  7. Or people logout in the app via button (they can but don’t have to) and we call Purchases.logout() and they go to step 2

This way we don’t start with anonymous when user is first seen in RevenueCat, only after logout() there is a $RCAnonymous created but never used.

Is this a good idea?

Userlevel 5
Badge +9

This is expected behavior. Hopefully with the new transfer on restore setting there will be fewer anonymous users created but the way you’re currently doing it correctly sets the user as anonymous when they’re logged out and identified when they’re logged in. If you want, you can choose to “remember” the user’s email/username when the token expires and logs back in. In this case you only call logout when the user explicitly logs out (taps the logout button) or the token expired and they logged in with a new account.

Reply