Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use purchases.subscriptionsv2 for Android Feast subscriptions #1545

Merged
merged 4 commits into from
Jun 10, 2024

Conversation

tjmw
Copy link
Member

@tjmw tjmw commented Jun 7, 2024

What does this change?

Use the purchases.subscriptionsv2 endpoint to retrieve data about Android Feast subs, instead of purchases.subscriptions v1 (which we use for the live app).

The reason for the migration is that when using the v1 endpoint, we rely on being able to map a product ID to a billing duration. This mapping is defined here:

export const PRODUCT_BILLING_PERIOD: {[productId: string]: string} = {
. This isn't very robust (in the past, new products have been added in the Play store, but not reflected here, meaning we get rows without a billing period). Furthermore, the was the Feast app has been configured in the Play store, it's not actually possible to map things this way. Instead, if we use the v2 endpoint, we can retrieve the billing period using Play store APIs.

Some back story on the v2 endpont: Tom Wadeson did some work to implement the v2 endpoint. In product there's a test which uses the v2 endpoint in parallel with the v1 endpoint for x% of requests to the subscriptions endpoint. There's a draft PR #1338 to use the new libs everywhere, but not merged yet. Using this for Feast feels like a nice step in the migration path as we're using it for real but in a focused context.

How to test

I've updated the Jest tests and tested in CODE (and can now see the billing duration being correctly set).

How can we measure success?

Have we considered potential risks?

Images

Accessibility

@tjmw tjmw force-pushed the tw/v2-feast-android-subscription-purchase-endpoint branch from ac2873c to 795e9aa Compare June 7, 2024 16:31
Base automatically changed from tw/parse-obfuscated-account-id-from-google-response to main June 10, 2024 08:21
@tjmw tjmw force-pushed the tw/v2-feast-android-subscription-purchase-endpoint branch from 795e9aa to 1b0bc21 Compare June 10, 2024 08:25
@tjmw tjmw changed the title WIP: Experiment with using purchases.subscriptionsv2 for Android Feast Use purchases.subscriptionsv2 for Android Feast subscriptions Jun 10, 2024
const promises = event.Records.map(async (sqsRecord: SQSRecord) => {
try {
const subscriptions = await fetchSubscriptionDetails(sqsRecord); // Subscription[]
await Promise.all(subscriptions.map(sub => putSubscription(sub)));
// TODO: parse this using zod to get validation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO is for a future PR.

@tjmw tjmw marked this pull request as ready for review June 10, 2024 09:00
Copy link
Contributor

@ecguardian ecguardian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@MaelGNM MaelGNM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@tjmw tjmw merged commit 799fd84 into main Jun 10, 2024
1 check passed
@tjmw tjmw deleted the tw/v2-feast-android-subscription-purchase-endpoint branch June 10, 2024 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants