Skip to content

Add basic tier for bulk unsubcribe#188

Merged
elie222 merged 4 commits intomainfrom
bulk-unsubcribe-premium
May 28, 2024
Merged

Add basic tier for bulk unsubcribe#188
elie222 merged 4 commits intomainfrom
bulk-unsubcribe-premium

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented May 28, 2024

Summary by CodeRabbit

  • New Features

    • Introduced BASIC_MONTHLY and BASIC_ANNUALLY premium tiers.
    • Added bulkUnsubscribeAccess feature to user premium settings.
  • Enhancements

    • Updated pricing details and discount display for premium tiers.
    • Improved logic and conditions for premium features access.
  • Bug Fixes

    • Corrected environment variable for unsubscribe credits.
  • Refactor

    • Simplified premium status determination logic.

@vercel
Copy link

vercel bot commented May 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
inbox-zero ✅ Ready (Inspect) Visit Preview May 28, 2024 6:31pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 28, 2024

Walkthrough

The recent updates introduce two new premium tiers, BASIC_MONTHLY and BASIC_ANNUALLY, into the application. These changes span across various files, including form components, validation schemas, pricing configurations, and environment variables. Additionally, adjustments were made to user access logic, premium feature access, and database migrations to support these new tiers.

Changes

File(s) Change Summary
.../AdminUpgradeUserForm.tsx, .../validation.tsx Added options for BASIC_ANNUALLY and BASIC_MONTHLY premium tiers.
.../Pricing.tsx, .../config.ts Updated discount display, URL generation logic, and added pricing for new tiers.
.../usage/usage.tsx, .../actions/premium.ts, .../turbo.json Renamed NEXT_PUBLIC_UNSUBSCRIBE_CREDITS to NEXT_PUBLIC_FREE_UNSUBSCRIBE_CREDITS.
.../route.ts, .../PremiumAlert.tsx, .../premium/index.ts, .../premium/server.ts Updated user access logic and premium feature access based on new premium tiers.
.../env.mjs Added environment variables for new premium tiers and renamed unsubscribe credits variable.
.../schema.prisma, .../migration.sql Added new premium tiers to the PremiumTier enum and bulkUnsubscribeAccess to the Premium model.

Poem

In the code, new tiers arise,
BASIC_MONTHLY, BASIC_ANNUALLY, a pleasant surprise.
Discounts dance, URLs align,
Premium features, now refined.
Unsubscribe credits, renamed with care,
A digital garden, with changes to share.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (3)
apps/web/app/(app)/admin/AdminUpgradeUserForm.tsx (2)

Line range hint 37-37: Consider removing the template literal in the toastSuccess call since there's no variable interpolation.

- description: data.upgrade ? `Upgraded!` : `Downgraded!`,
+ description: data.upgrade ? "Upgraded!" : "Downgraded!",

Line range hint 39-39: Specify a more explicit type instead of any for the error handling in the catch block to enhance type safety.

- } catch (error: any) {
+ } catch (error: unknown) {
apps/web/utils/actions/premium.ts (1)

Line range hint 242-248: Replace parseInt with Number.parseInt for better clarity and consistency with modern JavaScript practices.

- lemonSqueezySubscriptionId = parseInt(subscription.id);
+ lemonSqueezySubscriptionId = Number.parseInt(subscription.id);
- lemonSqueezyOrderId = parseInt(attributes.order_id);
+ lemonSkeezyOrderId = Number.parseInt(attributes.order_id);
- lemonSqueezyProductId = parseInt(attributes.product_id);
+ lemonSqueezyProductId = Number.parseInt(attributes.product_id);
- lemonSqueezyVariantId = parseInt(attributes.variant_id);
+ lemonSqueezyVariantId = Number.parseInt(attributes.variant_id);
- lemonSqueezySubscriptionItemId = attributes.first_subscription_item.id ? parseInt(attributes.first_subscription_item.id) : null;
+ lemonSqueezySubscriptionItemId = attributes.first_subscription_item.id ? Number.parseInt(attributes.first_subscription_item.id) : null;
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 36c8f87 and 55b47ef.
Files selected for processing (14)
  • apps/web/app/(app)/admin/AdminUpgradeUserForm.tsx (1 hunks)
  • apps/web/app/(app)/admin/validation.tsx (1 hunks)
  • apps/web/app/(app)/premium/Pricing.tsx (4 hunks)
  • apps/web/app/(app)/premium/config.ts (7 hunks)
  • apps/web/app/(app)/usage/usage.tsx (1 hunks)
  • apps/web/app/api/user/me/route.ts (1 hunks)
  • apps/web/components/PremiumAlert.tsx (1 hunks)
  • apps/web/env.mjs (4 hunks)
  • apps/web/prisma/migrations/20240528181840_premium_basic/migration.sql (1 hunks)
  • apps/web/prisma/schema.prisma (2 hunks)
  • apps/web/utils/actions/premium.ts (1 hunks)
  • apps/web/utils/premium/index.ts (3 hunks)
  • apps/web/utils/premium/server.ts (3 hunks)
  • turbo.json (1 hunks)
Files skipped from review due to trivial changes (2)
  • apps/web/prisma/migrations/20240528181840_premium_basic/migration.sql
  • turbo.json
Additional Context Used
Biome (19)
apps/web/app/(app)/admin/AdminUpgradeUserForm.tsx (4)

37-37: Do not use template literals if interpolation and special-character handling are not needed.


37-37: Do not use template literals if interpolation and special-character handling are not needed.


39-39: Unexpected any. Specify a different type.


3-4: Some named imports are only used as types.

apps/web/app/(app)/premium/Pricing.tsx (4)

151-151: Forbidden non-null assertion.


211-211: Using the role attribute 'list' on the 'ul' element is redundant, because it is implied by the semantic 'ul' element.


289-290: Using the role attribute 'list' on the 'ul' element is redundant, because it is implied by the semantic 'ul' element.


340-341: Avoid using target="_blank" without rel="noreferrer".

apps/web/components/PremiumAlert.tsx (1)

7-8: All these imports are only used as types.

apps/web/utils/actions/premium.ts (8)

72-72: void is not valid as a constituent in a union type


243-243: Unexpected any. Specify a different type.


9-10: All these imports are only used as types.


242-242: Use Number.parseInt instead of the equivalent global.


244-244: Use Number.parseInt instead of the equivalent global.


245-245: Use Number.parseInt instead of the equivalent global.


246-246: Use Number.parseInt instead of the equivalent global.


248-248: Use Number.parseInt instead of the equivalent global.

apps/web/utils/premium/index.ts (1)

1-1: Some named imports are only used as types.

apps/web/utils/premium/server.ts (1)

44-53: This else clause can be omitted because previous branches break early.

Additional comments not posted (14)
apps/web/app/(app)/admin/validation.tsx (1)

15-16: The addition of BASIC_MONTHLY and BASIC_ANNUALLY to the premium tier enum is correctly implemented.

apps/web/app/api/user/me/route.ts (1)

26-26: The addition of bulkUnsubscribeAccess to the user object retrieval is correctly implemented.

apps/web/app/(app)/usage/usage.tsx (1)

29-29: The update to use NEXT_PUBLIC_FREE_UNSUBSCRIBE_CREDITS is correctly implemented and aligns with the changes in environment configuration.

apps/web/utils/premium/index.ts (2)

45-54: The updated logic for hasUnsubscribeAccess correctly handles the new conditions for bulk unsubscribe access.


59-59: The updates to hasAiAccess, hasColdEmailAccess, and the tier ranking in isOnHigherTier are correctly implemented and align with the new premium tier structure.

Also applies to: 71-71, 88-94

apps/web/components/PremiumAlert.tsx (1)

21-45: The restructuring of the usePremium function and the addition of new conditions for premium access are correctly implemented and enhance the component's functionality.

apps/web/utils/premium/server.ts (2)

114-137: The updates to the getTierAccess function correctly define access levels for the new premium tiers.


81-81: The update to the cancelPremium function to reset access levels upon cancellation is correctly implemented.

apps/web/app/(app)/admin/AdminUpgradeUserForm.tsx (1)

93-100: The addition of BASIC_MONTHLY and BASIC_ANNUALLY options to the premium tier dropdown is correctly implemented.

apps/web/app/(app)/premium/config.ts (1)

10-11: The configuration updates for BASIC_MONTHLY and BASIC_ANNUALLY tiers are correctly implemented, including pricing and additional email pricing.

Also applies to: 20-21, 35-57

apps/web/env.mjs (1)

43-47: The environment variable configurations for BASIC_MONTHLY and BASIC_ANNUALLY are correctly implemented, including payment links and variant IDs.

Also applies to: 71-71, 93-101, 138-139

apps/web/utils/actions/premium.ts (1)

54-54: The update to use NEXT_PUBLIC_FREE_UNSUBSCRIBE_CREDITS in the decrementUnsubscribeCredit function is correctly implemented.

apps/web/prisma/schema.prisma (1)

346-347: The updates to the PremiumTier enum to include BASIC_MONTHLY and BASIC_ANNUALLY are correctly implemented.

apps/web/app/(app)/premium/Pricing.tsx (1)

135-135: The updates to the discount percentage display in the Pricing component are correctly implemented.

Also applies to: 196-198

@elie222 elie222 merged commit f6b3e69 into main May 28, 2024
@elie222 elie222 deleted the bulk-unsubcribe-premium branch May 28, 2024 18:32
@coderabbitai coderabbitai bot mentioned this pull request Oct 16, 2024
@coderabbitai coderabbitai bot mentioned this pull request Jan 1, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 10, 2025
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.

1 participant

Comments