Solved

Subscripber attributes sometimes missing in Webhook

  • 26 November 2021
  • 3 replies
  • 20 views

Badge +5

In my React Native I set subscriber attributes before I make a purchase. However in the “NON_RENEWING_PURCHASE” webhook the attributes are sometimes missing. Is this a race condition in your system? 

When I process the webhook I use the attributes to perform certain actions. What would you suggest is the most reliable way of making sure the attributes are synced correctly? Should I use the REST API within the webhook to fetch the attributes?

 

Code snippet from my app

Purchases.setAttributes(userAttributes)
log.info('Set user attributed', userAttributes)
await Purchases.purchaseProduct(productId, null, Purchases.PURCHASE_TYPE.INAPP)

 

 

An example of the subscriber_attributes I am expecting back in the webhook are:

{"subscriber_attributes": {
"ability": {
"updated_at_ms": 1637782170690,
"value": "BEGINNER"
},
"age": {
"updated_at_ms": 1637781232715,
"value": "24"
},
"custom_group_id": {
"updated_at_ms": 1637781232716,
"value": "abc123"
},
"days": {
"updated_at_ms": 1637782170688,
"value": "[\"Mondays\",\"Tuesdays\"]"
},
"goal": {
"updated_at_ms": 1637782170686,
"value": "FIVE_K"
},
"longRun": {
"updated_at_ms": 1637782170693,
"value": "Mondays"
},
"measurementSystem": {
"updated_at_ms": 1637782170696,
"value": "KILOMETERS"
},
"name": {
"updated_at_ms": 1637782170698,
"value": "Walter"
},
"numberOfDays": {
"updated_at_ms": 1637782170695,
"value": "2"
},
"planId": {
"updated_at_ms": 1637782170684,
"value": "EIGHT_WEEK_5K_IMPROVEMENT"
},
"planName": {
"updated_at_ms": 1637789290600,
"value": "8 Week 5k Improvement Plan"
},
"raceDay": {
"updated_at_ms": 1637782170687,
"value": "Saturday"
},
"raceTime": {
"updated_at_ms": 1637782170692,
"value": "20:00"
},
"raceTimeType": {
"updated_at_ms": 1637782170691,
"value": "5k"
}
}}

 

icon

Best answer by ryan 29 November 2021, 19:25

View original

3 replies

Badge +5

One workaround that I can see is to use the REST API within the webhook handler to get the latest attributes for the certain `app_user_id`.

 

e.g. call the `https://api.revenuecat.com/v1/subscribers/app_user_id` GET API which should return the array of `subscriber_attributes` for that user. 

This will ensure that you are getting the latest attributes that are saved in the RevenueCat DB and wont be lost from the race condition. You could even put a retry in the API call to retry 2-3 times until all the `subscriber_attributes` are been propagated through.

Userlevel 5
Badge +9

Hey @Walter Holohan!

The subscriber attributes are designed to be synced on a conversion event so they’re passed in the webhook - you shouldn’t need to build your own workaround for this.  

 

You should be able to check out the debug logs and see some output that the attributes are being synced: https://docs.revenuecat.com/docs/debugging. Another thing to check is through the GET /subscribers API (using a secret key) that the subscriber attributes are updated before the purchase timestamp.

Userlevel 4
Badge +8

Hey @Walter Holohan!

Are you still having issues here, or were you able to find some debug logs reproducing the issue so we can investigate further?

Reply