Skip to main content
Solved

Subscripber attributes sometimes missing in Webhook

  • 26 November 2021
  • 3 replies
  • 190 views

Forum|alt.badge.img+8

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"
      }
    }}

 

Best answer by ryan

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.

View original
Did this post help you find an answer to your question?

3 replies

Forum|alt.badge.img+8
  • Author
  • Dedicated Member
  • 19 replies
  • November 29, 2021

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.


ryan
RevenueCat Staff
Forum|alt.badge.img+9
  • RevenueCat Staff
  • 391 replies
  • Answer
  • November 29, 2021

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.


cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 492 replies
  • December 17, 2021

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


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