RevenueCat/firestore-revenuecat-purchases

Incorrect data in customers collection

snehsagarajput opened this issue Β· 9 comments

entitlements and subscriptions object have incorrect data when promo entitlement is revoked!

Steps to reproduce :

  1. Grant 2 promo entitlements to a user.
  2. Revoke any 1 promo entitlement from the same user.
  3. entitlements and subscriptions object will still show (In firestore customers collection) that user is subscribed to these entitlement/subscription.

When I debugged the issue, I found that using the SetOption - { merge: true } is causing the error; as merge doesn't remove an existing key from an object when more than 1 keys are present!

Thanks for reporting this @snehsagarajput , we have a ticket internally to look at this ASAP!

I'll let you know when I know more.

Confirmed that I got some time to reproduce the issue, and working on a fix now.

@alfondotnet Thanks for the quick fix ☺️. When can I expect the latest fix to be available?

Also want to know that the request body payload received by firebase-extension and custom webhook are same or different?

@alfondotnet Thanks for the quick fix ☺️. When can I expect the latest fix to be available?

No problem, sorry for the inconveniences, I'll ship a new version in a few hours.

Also want to know that the request body payload received by firebase-extension and custom webhook are same or different?

The object under the key event is the same that the webhook receives.

We added an additional key in here customer_info which it's the same as the response you get from calling our GET /v1/subscribers/{app_user_id}

@snehsagarajput expect the new version to be shipped in the following hour, and you'll be able to upgrade!

reapz commented

@alfondotnet Because you now override customer data instead of merging, we should no longer use our current users collection as they won't merge?

This is the description from the plugin settings page for Location of the customers collection:

This can be the location of an existing user collection, the extension will not overwrite your existing data but rather merge the RevenueCat data into your existing firestore documents.

Hi @reapz,

You are right, I now believe this wasn't at all how this fix should have gone, and in fact at the bare minimum it should have been a breaking change.

I think something like this #34 (comment) could take care of most use cases in which we allow complete control over where the collection goes, and then we merge only the first level keys (entitlements, subscriptions, etc...).

Just for safety, I'll push an update reverting this change and tomorrow I'll discuss with the team a more robust solution.

Thanks for bringing this up

Just published 0.1.3 which basically reverts the changes added in 0.1.2.

For the time being, @snehsagarajput you can keep using 0.1.2, I'll reopen this issue and next week we'll address this issue more holistically.