Skip to main content
Solved

Is there any way to get an event trigger when logging in with a custom app user id?

  • November 4, 2024
  • 4 replies
  • 43 views

Forum|alt.badge.img+4

Hello, my user flow is like this:
- user purchases subscription (not logging in with Purchases.logIn() )→ Revenuecat generates an anonymous id → INITIAL_PURCHASE event is triggered

​​​- after purchase: the user logs in with Firebase auth (logging in with Purchases.logIn() after account creation) → No event trigger

I’m grating users credits on INITIAL_PURCHASE. My issue is now that there is no event triggered when logging in with custom app user id. I don’t have any reference to between the anonymous id and custom user id. 

Is there any way to get aliases with the custom user id as a query from the backend, or am I missing something?

Best answer by Michael Fogel

Hey There,

 

One thing that you can do is with your current workflow, after the purchase happens and the users logs in, you call syncPurchases or have the restore purchase. This should create a transfer event which will help link that purchase to the new logged in app user ID. The event that woudl be generated by this would be a TRANSFER event. TRANSFER events happen when a transfer of transactions and entitlements was initiated between one App User ID(s) to another. Please note: The webhook will only be sent for the destination user despite us displaying this event in both customer histories because the event body is exactly the same for both users.  

 

Calling login will not generate an event, so another good workaround for this will be changing your flow to make the purchase after configuring the SDK with the specific ID or after logging in. That way the purchase will be linked to the proper account from the beginning and you wouldnt need to restore or syncPurchases.

View original
Did this post help you find an answer to your question?
This post has been closed for comments

4 replies

Michael Fogel
Forum|alt.badge.img+6
  • Dedicated Contributor
  • 382 replies
  • Answer
  • November 6, 2024

Hey There,

 

One thing that you can do is with your current workflow, after the purchase happens and the users logs in, you call syncPurchases or have the restore purchase. This should create a transfer event which will help link that purchase to the new logged in app user ID. The event that woudl be generated by this would be a TRANSFER event. TRANSFER events happen when a transfer of transactions and entitlements was initiated between one App User ID(s) to another. Please note: The webhook will only be sent for the destination user despite us displaying this event in both customer histories because the event body is exactly the same for both users.  

 

Calling login will not generate an event, so another good workaround for this will be changing your flow to make the purchase after configuring the SDK with the specific ID or after logging in. That way the purchase will be linked to the proper account from the beginning and you wouldnt need to restore or syncPurchases.


Forum|alt.badge.img+4
  • Author
  • Member
  • 5 replies
  • November 13, 2024

Hey thanks for the reply! I added syncPurchases after login but it doesn’t seem to trigger a TRANSFER event.

Any idea why that is?


Michael Fogel
Forum|alt.badge.img+6
  • Dedicated Contributor
  • 382 replies
  • November 20, 2024

Hey ​@cemck ,

 

When then sync happens here is there a new app user ID for the user? Can you possibly provide a screenshot of the customer history for this user after the sync? 


Forum|alt.badge.img+4
  • Author
  • Member
  • 5 replies
  • November 21, 2024

Hey, 

I changed the backend flow. Im granting credits now with user create trigger and not using INITIAL_PURCHASE as before.

Thanks for the help though


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings