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

🛂 (billing) Add isPastDue field in workspace #1046

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

baptisteArno
Copy link
Owner

@baptisteArno baptisteArno commented Nov 21, 2023

Closes #1039

Summary by CodeRabbit

  • New Features

    • Introduced a new status indicator for workspaces to show if they are past due.
    • Added a new page to inform users when their workspace is past due and provide a direct link to the billing portal.
  • Enhancements

    • Expanded workspace information to include quarantine status, due status, and member details across various API functions.
    • Improved telemetry event processing to include workspace past due status.
  • Bug Fixes

    • Corrected the redirection logic in the WorkspaceProvider to handle suspended and past due workspaces appropriately.
  • Refactor

    • Updated functions to handle workspace-related data more comprehensively, replacing workspaceId with a nested workspace object.
  • Documentation

    • Updated workspace schema to reflect the new isPastDue boolean property.
  • Chores

    • Database migrations to add the isPastDue field to the Workspace table in both MySQL and PostgreSQL schemas.

Copy link

coderabbitai bot commented Nov 21, 2023

Walkthrough

The changes across multiple files in the codebase are focused on integrating the isPastDue status of workspaces into various functions and components. This includes updating API functions to handle workspace-related data with additional checks for the isPastDue status, modifying schemas to include the new field, and adjusting UI components to redirect users based on the past due status of their workspace. The overarching goal is to manage access and functionality based on the subscription status of the workspace.

Changes

File(s) Change Summary
apps/builder/src/features/.../api/*.ts Updated API functions to include workspace object with isQuarantined, isPastDue, and members fields instead of workspaceId.
apps/builder/src/features/.../helpers/*.ts Modified helper functions to check isPastDue status within the workspace object and updated logic accordingly.
apps/builder/src/features/workspace/WorkspaceProvider.tsx Updated useEffect to handle redirects based on isSuspended and isPastDue status.
apps/builder/src/pages/api/stripe/webhook.ts Refactored Stripe webhook handler to manage workspace isPastDue status based on subscription and invoice events.
apps/builder/src/pages/past-due.tsx and apps/builder/src/pages/suspended.tsx Added new page components and logic to redirect users based on workspace status.
packages/prisma/.../schema.prisma and packages/prisma/.../migrations/*.sql Added isPastDue field to the Workspace model in Prisma schemas and migrations.
packages/schemas/features/telemetry.ts and packages/schemas/features/workspace.ts Updated schemas to include isPastDue field and related telemetry event schemas.

Assessment against linked issues

Objective Addressed Explanation
Block access to past due subscription workspace (#1039) The changes include checks for the isPastDue status in various API functions, UI components, and webhook handlers, which align with the objective to block access to workspaces with past due subscriptions.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

Copy link

vercel bot commented Nov 21, 2023

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

Name Status Preview Comments Updated (UTC)
builder-v2 🛑 Canceled (Inspect) Nov 23, 2023 7:16am
docs 🛑 Canceled (Inspect) Nov 23, 2023 7:16am
landing-page-v2 🛑 Canceled (Inspect) Nov 23, 2023 7:16am
viewer-v2 🛑 Canceled (Inspect) Nov 23, 2023 7:16am

Copy link

@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.

Review Status

Actionable comments generated: 7

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 94886ca and 55cb6e8.
Files ignored due to filter (1)
  • apps/docs/openapi/builder/spec.json
Files selected for processing (24)
  • apps/builder/src/features/blocks/logic/typebotLink/api/getLinkedTypebots.ts (2 hunks)
  • apps/builder/src/features/collaboration/api/getCollaborators.ts (1 hunks)
  • apps/builder/src/features/results/api/deleteResults.ts (1 hunks)
  • apps/builder/src/features/results/api/getResult.ts (1 hunks)
  • apps/builder/src/features/results/api/getResultLogs.ts (1 hunks)
  • apps/builder/src/features/results/api/getResults.ts (1 hunks)
  • apps/builder/src/features/typebot/api/deleteTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/getPublishedTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/getTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/publishTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/unpublishTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/updateTypebot.ts (3 hunks)
  • apps/builder/src/features/typebot/helpers/isReadTypebotForbidden.ts (1 hunks)
  • apps/builder/src/features/typebot/helpers/isWriteTypebotForbidden.ts (1 hunks)
  • apps/builder/src/features/upload/api/generateUploadUrl.ts (1 hunks)
  • apps/builder/src/features/whatsapp/startWhatsAppPreview.ts (1 hunks)
  • apps/builder/src/features/workspace/WorkspaceProvider.tsx (2 hunks)
  • apps/builder/src/pages/api/stripe/webhook.ts (1 hunks)
  • apps/builder/src/pages/past-due.tsx (1 hunks)
  • apps/builder/src/pages/suspended.tsx (2 hunks)
  • packages/prisma/mysql/schema.prisma (1 hunks)
  • packages/prisma/postgresql/migrations/20231121154057_add_is_past_due_field/migration.sql (1 hunks)
  • packages/prisma/postgresql/schema.prisma (1 hunks)
  • packages/schemas/features/workspace.ts (1 hunks)
Files skipped from review due to trivial changes (3)
  • apps/builder/src/features/typebot/api/getPublishedTypebot.ts
  • packages/prisma/mysql/schema.prisma
  • packages/prisma/postgresql/migrations/20231121154057_add_is_past_due_field/migration.sql
Additional comments: 22
packages/schemas/features/workspace.ts (1)
  • 50-54: The addition of the isPastDue field to the workspaceSchema is correctly implemented as a boolean. This change aligns with the summary provided, indicating that the field is intended to represent whether a workspace's payment status is overdue. The schema update is necessary for consistency across the application's data models and will facilitate the new functionality described in the pull request summary.
packages/prisma/postgresql/schema.prisma (1)
  • 91-94: The addition of the isPastDue field to the Workspace model is correctly implemented with a default value of false. This ensures that existing workspaces will not be marked as past due when the migration is applied. It's important to verify that all related application logic that depends on the Workspace model is updated to handle this new field appropriately.
apps/builder/src/features/workspace/WorkspaceProvider.tsx (1)
  • 138-149: The useEffect hook correctly handles the redirection based on the isSuspended and isPastDue properties of the workspace. However, it's important to ensure that these redirects do not interfere with other routing logic in the application, especially if there are other conditions that might trigger a redirect. It's also worth considering how this logic will behave in the case of deep linking, where a user might want to navigate directly to a specific page within a suspended or past-due workspace. If the application has not accounted for these scenarios, it could lead to a poor user experience.
apps/builder/src/features/results/api/deleteResults.ts (1)
  • 36-54: The select statement has been updated to include the workspace object with the new fields isQuarantined, isPastDue, and members. This change aligns with the new requirements to check workspace status before performing write operations. However, ensure that the removal of workspaceId does not affect other parts of the code that may rely on this field. If workspaceId is still needed elsewhere, consider keeping it in the select statement alongside the new fields.
apps/builder/src/features/whatsapp/startWhatsAppPreview.ts (1)
  • 57-73: The code correctly replaces the direct use of workspaceId with a nested workspace object that includes the new isPastDue field, as well as isQuarantined and members fields. This change aligns with the pull request's goal to integrate the isPastDue field into various components and functionalities. However, ensure that the rest of the application's logic that interacts with this function is updated to handle the new structure of the workspace object.
apps/builder/src/features/typebot/helpers/isReadTypebotForbidden.ts (1)
  • 1-25: The refactoring of the isReadTypebotForbidden function to use the nested workspace object within the typebot parameter is a good approach to encapsulate workspace-related properties. This change improves the maintainability of the code by making it easier to add or modify workspace-related checks in the future. However, ensure that all usages of this function across the codebase have been updated to pass the new typebot object structure instead of just the workspaceId. This is crucial to prevent runtime errors due to the change in the function signature.
apps/builder/src/features/results/api/getResult.ts (1)
  • 33-50: The changes to the select object within the prisma.typebot.findUnique call reflect the updated data requirements for the typebot object. The addition of the workspace object with isQuarantined, isPastDue, and members fields indicates that the function now retrieves more detailed information about the workspace associated with the typebot. This is likely to support the new functionality related to the isPastDue field. Ensure that the additional data being fetched is necessary for the operation of the getResult function and that it does not introduce any performance issues due to the increased payload size or database query complexity.
apps/builder/src/features/results/api/getResultLogs.ts (1)
  • 28-45: The changes to the getResultLogs function reflect the addition of the workspace object with the isQuarantined, isPastDue, and members fields. This is consistent with the pull request's goal of integrating the isPastDue field into various components. However, ensure that the frontend and any other parts of the application that consume this API are updated to handle the new nested workspace object structure. Additionally, verify that the inclusion of members with userId is necessary for the functionality of this endpoint, as it could potentially introduce privacy concerns or performance issues if the members' data is not required.
apps/builder/src/features/typebot/helpers/isWriteTypebotForbidden.ts (1)
  • 9-31: The refactored isWriteTypebotForbidden function now correctly checks for the isQuarantined and isPastDue flags on the workspace object associated with the typebot. It also checks if the user has write access and is not a guest in the workspace. This change aligns with the new requirements to consider the payment status of a workspace when determining write permissions. Ensure that all usages of this function have been updated to pass the correct arguments, especially the nested workspace object within typebot.
apps/builder/src/features/typebot/api/deleteTypebot.ts (1)
  • 33-51: The code has been updated to include the workspace object with nested selections for isQuarantined, isPastDue, and members. This change aligns with the pull request's goal to integrate the isPastDue field into various components. However, ensure that the logic within isWriteTypebotForbidden and other parts of the system correctly handle the new nested structure of the workspace object. If the function expects a flat structure, it may need to be updated to accommodate these changes.
apps/builder/src/pages/suspended.tsx (2)
  • 12-15: The useEffect hook correctly checks if the workspace is not suspended and redirects the user to the '/typebots' page. However, it's important to ensure that the workspace.isSuspended field is consistent with the new isPastDue field and that the logic here aligns with the intended behavior for handling past due workspaces. If isPastDue should also trigger a redirect, this logic may need to be updated to include that condition.

  • 1-28: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [1-39]

The changes in this file remove the WorkspaceProvider and replace it with the useWorkspace hook, which is a good refactor for simplifying the component and making use of the React hook for accessing workspace data. The useEffect hook is used to handle redirection based on the workspace's suspension status, and the UI is updated to inform the user that their workspace has been suspended. The changes appear to be correct and consistent with the pull request's goal of handling workspaces that are past due or suspended.

apps/builder/src/pages/past-due.tsx (2)
  • 9-16: The useEffect hook correctly checks if the workspace is not past due before redirecting. However, it's important to ensure that the workspace object always has the isPastDue field after the recent changes. If there's any scenario where the workspace object could be missing this field, it could lead to incorrect redirection behavior. Please verify that the workspace object is always fully populated with the isPastDue field in all cases.

  • 30-31: The conditional rendering checks for workspace?.id which is good for guarding against null or undefined workspace. However, it might be more appropriate to also check for workspace.isPastDue here, as the BillingPortalButton should only be shown if the workspace is indeed past due. If this is intentional and there are cases where workspace.id is present but isPastDue is not true, then this is fine as is.

apps/builder/src/features/collaboration/api/getCollaborators.ts (2)
  • 32-47: The code correctly fetches the workspace object with the new isQuarantined, isPastDue, and members fields. This change aligns with the pull request's goal to replace the direct use of workspaceId with a nested workspace object. However, ensure that the additional data fetched does not introduce any performance issues, especially if the members list can be large. Consider if all the retrieved data is necessary for the operation or if it can be optimized to fetch only what is needed.

  • 48-48: The error handling for a missing typebot or forbidden read access is appropriate. It throws a NOT_FOUND error with a clear message, which is a good practice for API error responses. However, ensure that the isReadTypebotForbidden function has been updated to handle the new isPastDue field correctly, as it now plays a role in determining read permissions.

apps/builder/src/features/typebot/api/publishTypebot.ts (1)
  • 46-58: The inclusion of the workspace object with isQuarantined, isPastDue, and members fields in the publishTypebot function indicates that the function now has access to more detailed workspace information. This change likely affects the logic within the function, particularly in how it determines whether a typebot can be published. It is important to ensure that the new fields are being used appropriately within the function to enforce any new business rules related to the workspace's status.
apps/builder/src/features/blocks/logic/typebotLink/api/getLinkedTypebots.ts (2)
  • 56-72: The workspace object is now being selected with additional fields isQuarantined, isPastDue, and members. This change aligns with the pull request summary, which indicates that the workspaceId is being replaced with a more detailed workspace object. Ensure that all the necessary permissions and checks are in place when accessing these new fields, especially isPastDue, as it may have implications on the visibility and accessibility of the typebots linked to the workspace.

  • 107-123: Similar to the previous hunk, the workspace object is selected with the new fields. It is important to verify that the logic that consumes this data is updated to handle the nested structure and that the additional information is used appropriately in the context of the application's business logic.

apps/builder/src/features/results/api/getResults.ts (1)
  • 44-66: The select block for the workspace object is retrieving isQuarantined, isPastDue, and members. Ensure that the inclusion of these fields is necessary for the getResults function's logic. If any of these fields are not used, they should be removed to reduce unnecessary database load and potential information leakage. Additionally, verify that appropriate permissions checks are in place to prevent unauthorized access to sensitive workspace information.
    [PERFORMANCE][SECURITY]
apps/builder/src/features/typebot/api/updateTypebot.ts (2)
  • 87-102: The addition of the workspace object with its nested fields is a significant change. It is important to ensure that the rest of the codebase is updated to handle this new structure, especially since existingTypebot.workspaceId is replaced with existingTypebot.workspace.id. This change could potentially break existing functionality if not handled properly in all places where workspaceId is used.

  • 168-174: The call to sanitizeGroups function is now passing existingTypebot.workspace.id instead of existingTypebot.workspaceId. This is a logical change that aligns with the updated structure of existingTypebot. However, ensure that the sanitizeGroups function is updated to handle the new parameter if it was previously expecting a direct workspaceId.

apps/builder/src/pages/api/stripe/webhook.ts Show resolved Hide resolved
Comment on lines +151 to +169
if (!workspace?.isPastDue)
return res.send({ message: 'Workspace not past_due, skipping.' })
const outstandingInvoices = await stripe.invoices.list({
customer: invoice.customer as string,
status: 'open',
})
if (outstandingInvoices.data.length > 0)
return res.send({
Copy link

Choose a reason for hiding this comment

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

The logic here assumes that if there are any open invoices, the workspace should remain marked as past due. However, this does not account for the possibility that the paid invoice could be the last outstanding invoice, and the workspace should no longer be considered past due. The check for outstanding invoices should be done before marking the workspace as not past due, and if there are no other open invoices, the isPastDue field should be updated to false.

-          if (outstandingInvoices.data.length > 0)
+          if (outstandingInvoices.data.length > 1 || (outstandingInvoices.data.length === 1 && outstandingInvoices.data[0].id !== invoice.id))

This change ensures that if the current invoice is the only open invoice, the workspace is no longer considered past due after it is paid.


Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if (!workspace?.isPastDue)
return res.send({ message: 'Workspace not past_due, skipping.' })
const outstandingInvoices = await stripe.invoices.list({
customer: invoice.customer as string,
status: 'open',
})
if (outstandingInvoices.data.length > 0)
return res.send({
if (!workspace?.isPastDue)
return res.send({ message: 'Workspace not past_due, skipping.' })
const outstandingInvoices = await stripe.invoices.list({
customer: invoice.customer as string,
status: 'open',
})
if (outstandingInvoices.data.length > 1 || (outstandingInvoices.data.length === 1 && outstandingInvoices.data[0].id !== invoice.id))
return res.send({

@vercel vercel bot temporarily deployed to Preview – builder-v2 November 23, 2023 07:15 Inactive
@vercel vercel bot temporarily deployed to Preview – viewer-v2 November 23, 2023 07:15 Inactive
@vercel vercel bot temporarily deployed to Preview – landing-page-v2 November 23, 2023 07:16 Inactive
@vercel vercel bot temporarily deployed to Preview – docs November 23, 2023 07:16 Inactive
@baptisteArno baptisteArno merged commit ca79934 into main Nov 23, 2023
2 of 6 checks passed
@baptisteArno baptisteArno deleted the past-due-restriction branch November 23, 2023 07:16
Copy link

@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.

Review Status

Actionable comments generated: 5

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 94886ca and 57b041b.
Files ignored due to filter (1)
  • apps/docs/openapi/builder/spec.json
Files selected for processing (26)
  • apps/builder/src/features/blocks/logic/typebotLink/api/getLinkedTypebots.ts (2 hunks)
  • apps/builder/src/features/collaboration/api/getCollaborators.ts (1 hunks)
  • apps/builder/src/features/results/api/deleteResults.ts (1 hunks)
  • apps/builder/src/features/results/api/getResult.ts (1 hunks)
  • apps/builder/src/features/results/api/getResultLogs.ts (1 hunks)
  • apps/builder/src/features/results/api/getResults.ts (1 hunks)
  • apps/builder/src/features/telemetry/api/processTelemetryEvent.ts (1 hunks)
  • apps/builder/src/features/typebot/api/deleteTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/getPublishedTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/getTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/publishTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/unpublishTypebot.ts (1 hunks)
  • apps/builder/src/features/typebot/api/updateTypebot.ts (3 hunks)
  • apps/builder/src/features/typebot/helpers/isReadTypebotForbidden.ts (1 hunks)
  • apps/builder/src/features/typebot/helpers/isWriteTypebotForbidden.ts (1 hunks)
  • apps/builder/src/features/upload/api/generateUploadUrl.ts (1 hunks)
  • apps/builder/src/features/whatsapp/startWhatsAppPreview.ts (1 hunks)
  • apps/builder/src/features/workspace/WorkspaceProvider.tsx (2 hunks)
  • apps/builder/src/pages/api/stripe/webhook.ts (3 hunks)
  • apps/builder/src/pages/past-due.tsx (1 hunks)
  • apps/builder/src/pages/suspended.tsx (2 hunks)
  • packages/prisma/mysql/schema.prisma (1 hunks)
  • packages/prisma/postgresql/migrations/20231121154057_add_is_past_due_field/migration.sql (1 hunks)
  • packages/prisma/postgresql/schema.prisma (1 hunks)
  • packages/schemas/features/telemetry.ts (2 hunks)
  • packages/schemas/features/workspace.ts (1 hunks)
Files skipped from review due to trivial changes (3)
  • packages/prisma/mysql/schema.prisma
  • packages/prisma/postgresql/schema.prisma
  • packages/schemas/features/telemetry.ts
Additional comments: 26
packages/schemas/features/workspace.ts (1)
  • 50-54: The addition of the isPastDue field to the workspaceSchema is correctly implemented as a boolean type. Ensure that all parts of the application that use the Workspace type are updated to handle this new field.
apps/builder/src/features/typebot/api/getPublishedTypebot.ts (1)
  • 52-66: The getPublishedTypebot function has been updated to include workspace details such as isQuarantined, isPastDue, and members. Ensure that the additional data being fetched is used appropriately and that any necessary permissions checks are in place to prevent unauthorized access to this sensitive information.
apps/builder/src/features/typebot/api/getTypebot.ts (1)
  • 41-56:
    The previous comment regarding permissions checks and privacy considerations for the additional workspace information still stands. Ensure that the implementation includes these checks to prevent unauthorized access to sensitive data.
packages/prisma/postgresql/migrations/20231121154057_add_is_past_due_field/migration.sql (1)
  • 1-2:
    The SQL migration script correctly adds the isPastDue field to the Workspace table with the appropriate constraints and default value.
apps/builder/src/features/collaboration/api/getCollaborators.ts (1)
  • 32-47:
    The inclusion of isQuarantined, isPastDue, and members with userId in the workspace selection is consistent with the pull request's goal to enhance workspace-related information retrieval.
apps/builder/src/features/results/api/getResultLogs.ts (1)
  • 28-45:
    Ensure that the removal of workspaceId and the addition of the workspace object with its nested fields do not break any existing functionality that relies on workspaceId. Also, verify that the isReadTypebotForbidden function properly handles the new structure of the typebot object.
apps/builder/src/features/typebot/api/publishTypebot.ts (1)
  • 46-57: The workspace object now includes additional fields: isQuarantined, isPastDue, and members. Ensure that the logic of the publishTypebot function properly handles these new fields, especially isPastDue, which may affect the ability to publish a typebot if the workspace's payment status is past due. This might require additional checks and error handling to prevent publishing in such cases.
apps/builder/src/features/workspace/WorkspaceProvider.tsx (1)
  • 136-149: The useEffect hook correctly handles the redirection based on the workspace?.isSuspended and workspace?.isPastDue conditions. However, it's important to ensure that there are no other parts of the application that rely on the previous behavior where workspaceId was used instead of the workspace object. This change could potentially break functionality if not all instances were updated accordingly.
apps/builder/src/features/whatsapp/startWhatsAppPreview.ts (1)
  • 57-73: The code correctly retrieves the new workspace object with the isQuarantined, isPastDue, and members fields. However, ensure that the logic within the startWhatsAppPreview function properly handles the scenarios when isQuarantined or isPastDue is true. If the workspace is quarantined or past due, the function may need to prevent the WhatsApp preview from starting or handle it differently.
apps/builder/src/features/telemetry/api/processTelemetryEvent.ts (1)
  • 81-86:
    The conditional assignment of properties is a good practice to avoid potential undefined errors when data is not present in the event.
apps/builder/src/features/blocks/logic/typebotLink/api/getLinkedTypebots.ts (2)
  • 56-72: The selection of workspace-related fields has been expanded to include isQuarantined, isPastDue, and members. Ensure that the inclusion of these fields is consistent with the application's data access patterns and that any necessary permissions checks are in place to prevent unauthorized access to sensitive information.

  • 107-123: Similar to the previous hunk, the selection of workspace-related fields has been expanded here as well. Verify that the additional data being retrieved is used appropriately and that it does not introduce any performance issues, especially since the members field could potentially return a large dataset.

apps/builder/src/features/typebot/api/deleteTypebot.ts (1)
  • 33-51:
    The deleteTypebot function now correctly includes the workspace object with the new isPastDue field and nested members properties in its query. Ensure that the logic within the function and any other part of the application that depends on the deleteTypebot function's output is updated to handle these changes.
apps/builder/src/features/results/api/getResult.ts (1)
  • 33-50:
    The changes to the select block to include workspace with nested select for isQuarantined, isPastDue, and members are consistent with the pull request summary. Ensure that the removal of workspaceId and the addition of userId within members align with the intended data access patterns and that all dependent code has been updated accordingly.
apps/builder/src/features/typebot/helpers/isWriteTypebotForbidden.ts (1)
  • 1-31:

The refactored isWriteTypebotForbidden function correctly implements the new logic to check the workspace's isQuarantined and isPastDue status, as well as the user's role and collaboration type. Ensure that the global availability of prisma is configured correctly since the direct import has been removed.

apps/builder/src/features/results/api/deleteResults.ts (1)
  • 36-54:

Ensure that the newly selected fields (isQuarantined, isPastDue, and members) are being used appropriately in the context of the deleteResults function and that there are no privacy or security issues with exposing this information.

apps/builder/src/features/typebot/helpers/isReadTypebotForbidden.ts (1)
  • 1-25:

The refactored isReadTypebotForbidden function correctly implements the new workspace object structure and checks for isQuarantined and isPastDue status. The use of some for checking if the user is a collaborator or member is efficient.

apps/builder/src/features/upload/api/generateUploadUrl.ts (1)
  • 147-160:
    Verify if the plan, isQuarantined, isPastDue, and members fields are necessary for the operation of the parseFilePath function. If they are not used, consider removing them from the select query to optimize performance.
apps/builder/src/pages/past-due.tsx (2)
  • 9-16:
    Verify that the redirection logic in the useEffect hook aligns with the intended user flow, especially in cases where the workspace might be suspended or in other states that are not accounted for in the current condition.

  • 30-31:
    The conditional rendering of BillingPortalButton is correctly implemented to only display when there is a valid workspace.id.

apps/builder/src/pages/suspended.tsx (3)
  • 1-6:
    The import statements have been correctly updated to include necessary hooks and components for the new functionality.

  • 8-15:
    The logic within the useEffect hook correctly checks for the workspace's suspension status and redirects if the workspace is not suspended.

  • 1-28: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [17-38]

The WorkspaceProvider component has been successfully replaced with the useWorkspace hook, and the page content has been updated accordingly.

apps/builder/src/features/typebot/api/updateTypebot.ts (1)
  • 171-171: The sanitizeGroups function is being called with existingTypebot.workspace.id, which is correct according to the change summary. However, ensure that the sanitizeGroups function has been updated to accept a workspace object instead of a workspaceId if that is the new expected parameter.
apps/builder/src/pages/api/stripe/webhook.ts (2)
  • 126-127: The previous comment about handling all possible subscription statuses is still valid. Ensure that the isPastDue field is updated to reflect the current status of the subscription, not just when it is past_due.

  • 162-171: The previous comment about checking for outstanding invoices before marking the workspace as not past due is still valid. Ensure that the logic accounts for the possibility that the paid invoice could be the last outstanding invoice.

Comment on lines 32 to 47
include: {
collaborators: true,
publishedTypebot: true,
workspace: {
select: {
isQuarantined: true,
isPastDue: true,
members: {
select: {
userId: true,
role: true,
},
},
},
},
},
Copy link

Choose a reason for hiding this comment

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

The workspace object is included in the query, but there is no logic that uses the isQuarantined or isPastDue fields. If these fields are intended to affect the unpublishing process, the code should be updated to include the necessary checks. Otherwise, remove the unused fields to optimize performance.

Comment on lines 79 to 84
id: true,
customDomain: true,
publicId: true,
workspaceId: true,
collaborators: {
select: {
userId: true,
Copy link

Choose a reason for hiding this comment

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

The previous comment about the missing closing bracket for the select block in collaborators is still valid. The closing bracket is indeed missing, which will cause a syntax error.

-              type: true,
+              type: true
+            }

Commitable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
id: true,
customDomain: true,
publicId: true,
workspaceId: true,
collaborators: {
select: {
userId: true,
id: true,
customDomain: true,
publicId: true,
collaborators: {
select: {
userId: true,
type: true
}

},
},
},
},
},
})
if (!typebot || (await isReadTypebotForbidden(typebot, user)))
Copy link

Choose a reason for hiding this comment

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

The error message 'Typebot not found' is still used for both a missing typebot and forbidden read access. Consider implementing the previously suggested changes to provide clearer feedback to the client.

- throw new TRPCError({ code: 'NOT_FOUND', message: 'Typebot not found' })
+ if (!typebot) {
+   throw new TRPCError({ code: 'NOT_FOUND', message: 'Typebot not found' });
+ } else if (await isReadTypebotForbidden(typebot, user)) {
+   throw new TRPCError({ code: 'FORBIDDEN', message: 'Read access to typebot is forbidden' });
+ }

Commitable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if (!typebot || (await isReadTypebotForbidden(typebot, user)))
if (!typebot) {
throw new TRPCError({ code: 'NOT_FOUND', message: 'Typebot not found' });
} else if (await isReadTypebotForbidden(typebot, user)) {
throw new TRPCError({ code: 'FORBIDDEN', message: 'Read access to typebot is forbidden' });
}

Comment on lines 66 to 75
},
include: {
members: {
select: { user: { select: { id: true } } },
select: { userId: true },
where: {
role: WorkspaceRole.ADMIN,
},
},
},
})
Copy link

Choose a reason for hiding this comment

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

The include statement for members is redundant if you're only selecting userId. Consider using a simpler select statement to improve performance.

-              include: {
-                members: {
-                  select: { userId: true },
-                  where: {
-                    role: WorkspaceRole.ADMIN,
-                  },
-                },
-              },
+              select: {
+                members: {
+                  select: { userId: true },
+                  where: {
+                    role: WorkspaceRole.ADMIN,
+                  },
+                },
+              },

Commitable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
},
include: {
members: {
select: { user: { select: { id: true } } },
select: { userId: true },
where: {
role: WorkspaceRole.ADMIN,
},
},
},
})
select: {
members: {
select: { userId: true },
where: {
role: WorkspaceRole.ADMIN,
},
},
},
})

Comment on lines 222 to 231
},
include: {
members: {
select: { user: { select: { id: true } } },
select: { userId: true },
where: {
role: WorkspaceRole.ADMIN,
},
},
},
})
Copy link

Choose a reason for hiding this comment

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

Similar to the previous comment on lines 66-75, the include statement for members is redundant if you're only selecting userId. Use a select statement instead to improve performance.

-            include: {
-              members: {
-                select: { userId: true },
-                where: {
-                  role: WorkspaceRole.ADMIN,
-                },
-              },
-            },
+            select: {
+              members: {
+                select: { userId: true },
+                where: {
+                  role: WorkspaceRole.ADMIN,
+                },
+              },
+            },

Commitable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
},
include: {
members: {
select: { user: { select: { id: true } } },
select: { userId: true },
where: {
role: WorkspaceRole.ADMIN,
},
},
},
})
select: {
members: {
select: { userId: true },
where: {
role: WorkspaceRole.ADMIN,
},
},
},

kweripx added a commit to toolzzlabzz/toolzzchat-builder that referenced this pull request Dec 11, 2023
* 🚸 (typebotLink) Make sure variables from child bots are merged if necessary

* ⚡ (customDomain) Add configuration modal for domain verification

Closes baptisteArno#742

* 🐛 Fix bubble icon file upload

* 🚸 (results) Use header id as table accessor to allow duplicate names

* 🐛 (payment) Fix postalCode camel case issue

Closes baptisteArno#822

* 🐛 (results) Fix result modal content display

* ⚡ (whatsapp) Improve WhatsApp preview management

Closes baptisteArno#800

* 🛂 (fileUpload) Improve file upload size limit enforcement

Closes baptisteArno#799, closes baptisteArno#797

* 📝 Change googleSheets date system var name

* ♻️ Export bot-engine code into its own package

* ♻️ Remove storage limit related code

* 🚑 Fix file upload expiration issue

* 🚑 (upload) Fix upload in embed

* 📝 Add custom domain troobleshoot section

* 👷 (vercel) Increase max execution duration for webhooks

* ⚡ (whatsapp) Improve whatsApp management and media collection

Closes baptisteArno#796

* 💚 Rename back viewer

* 👷 Only build docker images on tag push

* ✨ (whatsapp) Add custom session expiration (baptisteArno#842)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

- New Feature: Introduced session expiry timeout for WhatsApp
integration, allowing users to set the duration after which a session
expires.
- New Feature: Added an option to enable/disable the start bot condition
in WhatsApp integration settings.
- Refactor: Enhanced error handling by throwing specific errors when
necessary conditions are not met.
- Refactor: Improved UI components like `NumberInput` and
`SwitchWithLabel` for better usability.
- Bug Fix: Fixed issues related to session resumption and message
sending in expired sessions. Now, if a session is expired, a new one
will be started instead of attempting to resume the old one.
- Chore: Updated various schemas to reflect changes in session
management and WhatsApp settings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🚑 (billing) Fix disabled upgrade buttons

* ♿ (embed) Add aria-label to bubble button

* ⚡ (wordpress) Add query params exclusion support

* 🐛 (bot) Fix reactivity issue when filtering single choices

Closes baptisteArno#803

* ⚡ Auto continue bot on whatsApp if starting block is input  (baptisteArno#849)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

**New Features:**
- Added WhatsApp integration feature to the Pro plan.

**Refactor:**
- Introduced the ability to exclude specific plans from being displayed
in the Change Plan Modal.
- Renamed the function `isProPlan` to `hasProPerks`, enhancing code
readability and maintainability.
- Updated the `EmbedButton` component to handle a new `lockTagPlan`
property and use the `modal` function instead of the `Modal` component.

**Chore:**
- Removed the `whatsAppPhoneNumberId` field from the `Typebot` model
across various files, simplifying the data structure of the model.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🚑 (fileUpload) Fix file upload in linked typebots

* ⚡ (setVariable) Add "Environment name" value in Set variable block (baptisteArno#850)

Closes baptisteArno#848
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

- New Feature: Added "Environment name" as a new value type in the
SetVariable function, allowing users to distinguish between 'web' and
'whatsapp' environments.
- Refactor: Simplified session state handling in `resumeWhatsAppFlow.ts`
for improved code clarity.
- Refactor: Updated `startWhatsAppSession.ts` to include an initial
session state with WhatsApp contact and expiry timeout, enhancing
session management.
- Bug Fix: Improved null handling in `executeSetVariable.ts` for
'Contact name' and 'Phone number', preventing potential issues with
falsy values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🛂 Improve editor authorization feedback (baptisteArno#856)

Closes baptisteArno#844, closes baptisteArno#839

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

- New Feature: Added a `logOut` function to the user context for
improved logout handling.
- Refactor: Updated the redirect path in the `SignInForm` component for
better user redirection after authentication.
- New Feature: Enhanced the "Add" button and "Connect new" menu item in
`CredentialsDropdown` with role-based access control.
- Refactor: Replaced the `signOut` function with the `logOut` function
from the `useUser` hook in `DashboardHeader`.
- Bug Fix: Prevented execution of certain code blocks in
`TypebotProvider` when `typebotData` is read-only.
- Refactor: Optimized the `handleObserver` function in `ResultsTable`
with a `useCallback` hook.
- Bug Fix: Improved router readiness check in `WorkspaceProvider` to
prevent premature execution of certain operations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🚸 Better random IDs generation in setVariable

* 🐛 (pixel) Fix multiple Meta pixels tracking

Closes baptisteArno#846

* 📝 (whatsapp) Add a "Create WhatsApp app" guide

* 🚸 (whatsapp) Improve upgrade plan for whatsapp notice

* 🐛 (preview) Fix always displayed start props toast

* 🐛 (whatsapp) Fix preview failing to start and wait timeo…

* 🚸 (pictureChoice) Improve single picture choice with same titles

Closes baptisteArno#859

* 🚸 (pictureChoice) Allow dynamic picture choice with… (baptisteArno#865)

… string variables
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

- Refactor: Updated `GoogleSheetsNodeContent` component to use the
`options` prop instead of `action`, and integrated the `useTypebot` hook
for better functionality.
- Style: Improved UI text and layout in `GoogleSheetsSettings.tsx`,
enhancing user experience when selecting rows.
- Refactor: Simplified rendering logic in `BlockNodeContent.tsx` by
directly calling `GoogleSheetsNodeContent` component, improving code
readability.
- Bug Fix: Enhanced `injectVariableValuesInPictureChoiceBlock` function
to handle different types of values for titles, descriptions, and
picture sources, fixing issues with variable value injection.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🐛 (whatsapp) Fix auto start input where it didn't display next bu… (baptisteArno#869)

…bbles
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

**Release Notes**

- New Feature: Enhanced WhatsApp integration with improved phone number
formatting and session ID generation.
- Refactor: Updated the `startWhatsAppPreview` and
`receiveMessagePreview` functions for better consistency and
readability.
- Bug Fix: Added a check for `phoneNumberId` in the `receiveMessage`
function to prevent errors when it's undefined.
- Documentation: Expanded the WhatsApp integration guide and FAQs in the
docs, providing more detailed instructions and addressing common
queries.
- Chore: Introduced a new `metadata` field in the
`whatsAppWebhookRequestBodySchema` to store the `phone_number_id`.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🐛 (typebotLink) Fix nested typebot link pop

* 📝 (typebotLink) Add instructions about shared variables and merge answers

* 🛂 (whatsapp) Remove feature flag

Closes baptisteArno#401

* 🚑 (js) Fix dependency issue preventing user to install @typebot.io/js

Closes baptisteArno#871

* 🚸 (whatsapp) Improve how the whatsapp preview behaves (baptisteArno#873)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

- New Feature: Updated WhatsApp logo with a new design and color scheme.
- New Feature: Added a help button in the UI linking to documentation,
enhancing user guidance.
- New Feature: Introduced an alert message indicating that the WhatsApp
integration is in beta testing.
- New Feature: Implemented a button to open WhatsApp Web directly from
the application, improving user convenience.
- Refactor: Adjusted the retrieval of `contactPhoneNumber` in
`receiveMessagePreview` function for better data structure
compatibility.
- Refactor: Optimized the initialization and management of the WhatsApp
session in `startWhatsAppPreview`.
- Refactor: Improved the `parseButtonsReply` function by refining
condition checks.
- Refactor: Enhanced the readability of serialized rich text in
`convertRichTextToWhatsAppText` by introducing newline characters.
- Bug Fix: Ensured preservation of `contact` information when resuming
the WhatsApp flow in `resumeWhatsAppFlow`.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 📝 Update About page content

Closes baptisteArno#757

* 🐛 (builder) Fix system color mode not syncing properly

* 🔖 Release v2.18.0

* 🚸 (sendEmail) Rename username SMTP creds label to avoid confusion

* 🐳 Bump Postgres version in official docker compose file

* 📝 (whatsapp) Re-organize whatsapp overview doc

* 📝 (vercel) Add a note on function maxDuration for Hobby plans

* 📝 (docker) Update postgres image name

* 🚑 (whatsapp) Fix start whatsapp session when user has multiple whatsapp enabled

* 🛂 (whatsapp) Disable whatsapp by default on duplication

* 🛂 (whatsapp) Set default whatsapp expiry to 4 hours

* 🚸 (videoBubble) Reparse variable video URL to correctly detect provider

* 🐛 (whatsapp) Fix force create session when flow is completed at first round

* 🧑‍💻 Improve invalid environment variable insight on build fail

* 🐳 Remove wait-for-it script to avoid edge cases issues

* 🚑 (results) Fix broken infinite scroll

* ♻️ (api) Auto start bot if starting with input

Closes baptisteArno#877, closes baptisteArno#884

* ✨ Automatically parse markdown from variables in text bubbles

Closes baptisteArno#539

* 📝 (whatsapp) Remove private beta mention

* 🚑 Fix text styling parsing on variables

* 🐛 New sendMessage version for the new parser

Make sure old client still communicate with old parser

* 🔖 (wordpress) Deploy v3.4.0

* ⬆️ (openai) Replace openai-edge with openai and upgrade next

* 🐛 Enable stream again by migrating endpoint to route handler

https://vercel.com/docs/functions/edge-functions/streaming#streaming-data-with-edge-functions

* 🚸 (openai) Improve streamed message lists CSS

* 🔥 Remove streamer Pages API endpoint

* 🐛 Add no cache instructions to streamer

Attempt to fix buffering issue when Cloudflare proxy is enabled

* 💄 Better parsing of lists and code in streaming bubbles

* ♻️ Remove sentry client monitoring in viewer

* 🚸 (condition) Don't show value in node content if operator is "set" or "empty"

* 📝 (embed) Add note about non-embeddable websites

* ⬆️ Upgrade sentry and improve its reliability

* 🐛 (editor) Fix default branding settings on cre…

* 🛂 Sanitize custom CSS and head code to avoid modification of lite badge

* 📝 (s3) Add s3 configuration detailed instructions

* 🚑 Fix custom CSS sanitization

* 🚸 (openai) Improve streaming bubble sequence and visual

* 💚 Fix docker build when Sentry not enabled

* 🔖 Release v2.18.1

* 🚑 Fix empty bubble issue when plate element does not have a type attribute

* 🐛 (openai) Fix 2 openai streaming back to back

* 📝 (openai) Add "Multiple OpenAI blocks" video section

* ⚡ (video) Allow changing video height when resolved to an iframe

* 🐛 Fix link parsing when using variables

Closes baptisteArno#764

* 🐛 (textBubble) Fix overflow with long links

Closes baptisteArno#764

* 🐛 (videoBubble) Fix youtube parsing for IDs containing a "-"

* 🐳 Force Next.js apps local hostname

Closes baptisteArno#911

* 🔖 Release v2.18.2

* 🐛 (webhook) Fix webhook response data key number parsing

* 📝 Add bounties info in README

* ⚡ (billing) Automatic usage-based billing (baptisteArno#924)

BREAKING CHANGE: Stripe environment variables simplified. Check out the
new configs to adapt your existing system.

Closes baptisteArno#906





<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

**New Features:**
- Introduced a usage-based billing system, providing more flexibility
and options for users.
- Integrated with Stripe for a smoother and more secure payment process.
- Enhanced the user interface with improvements to the billing,
workspace, and pricing pages for a more intuitive experience.

**Improvements:**
- Simplified the billing logic, removing additional chats and yearly
billing for a more streamlined user experience.
- Updated email notifications to keep users informed about their usage
and limits.
- Improved pricing and currency formatting for better clarity and
understanding.

**Testing:**
- Updated tests and specifications to ensure the reliability of new
features and improvements.

**Note:** These changes aim to provide a more flexible and user-friendly
billing system, with clearer pricing and improved notifications. Users
should find the new system more intuitive and easier to navigate.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🚑 (billing) Fix chats pricing tiers incremental flat amou…

* 👷 Improve getUsage accuracy in check cron job

* 🐛 (results) Lower the max limit in getResults endpoint to avoid payload size error

Closes baptisteArno#908

* 💚 Fix send email in CI "React is not defined"

* 🐛 Freeze body overflow when opening a Popup embed (baptisteArno#937)

fix baptisteArno#763
/claim baptisteArno#763

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

- **Enhancement**: Improved the visibility management of the bot in the
popup. This update ensures a smoother and more intuitive user experience
when interacting with the bot.
- **Bug Fix**: Resolved an issue where certain styles could interfere
with the bot's visibility in the popup. The update prioritizes the
necessary style settings, ensuring the bot's visibility is maintained as
expected, regardless of other conflicting styles.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🐛 Fixed pinch zooming mouse issue (with ctrl key) (baptisteArno#940)

**Fixed the drastic zoom increase decrease on ctrl + mouse scroll.**

The issue was occuring due to the "scale" property in the pinch gesture.
The scale was getting bigger values, leading to more zooming.
What I did was, made sure that maximum scale difference between current
and last value cannot be more than the scaling factor used in
zoomin/zoomout buttons. That is. 0.2
Also, the pinch zoom would work as expected.

/claim baptisteArno#567
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

- Improvement: Enhanced zoom precision in the Graph component. This
update allows for more accurate scaling when adjusting the view in the
graph builder. The change ensures that the zoom level adjusts more
precisely, providing a smoother and more controlled user experience when
interacting with graphs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* Fix audio content overflow in windows. (baptisteArno#944)

/claim baptisteArno#667

The volume slider in audio element in windows chrome overflows.
Possible fixes:
1. Change the width of audio blocks. (Not suggested, as the width of all
blocks should be consistent)
2. Adjust the audio sub elements, so it doesn't overflow.(IMPLEMENTED)

It's not so straightforward to apply customization to audio tag element.
The best possible way I could find, to make the app look good, is by
hiding the timeline track in the audio. It was showing up very small
anyway(due to block width), so there shouldn't be an issue.
Please look at the before & after videos below.


https://github.com/baptisteArno/typebot.io/assets/29385192/f61c5b58-834d-470f-b684-bd82181e07f4



https://github.com/baptisteArno/typebot.io/assets/29385192/88f932eb-dc7e-4346-bf64-6405a015013e


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
### Summary by CodeRabbit

- Style: Improved the visual layout of the audio player on Windows. The
update includes a cleaner interface by hiding the track timeline and
adjusting the media controls panel. This change enhances the user
experience by providing a more streamlined and intuitive audio player
design.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* ♻️ Update import contact to brevo script

* 👷 Add convenient script for migrating Stripe prices

* 🩹 Surround logs saving in a try catch block

It seems that in some particular set up the logs saving is failing.

* 🚸 (buttons) Trim items content when parsing reply for better consistency

Closes baptisteArno#948

* 🔖 Release v2.18.3

* ✏️ Fix popup blocked toast typo

* 🧑‍💻 (whatsapp) Improve whatsapp start log

* 🐛 (numberInput) Fix input clearing out on dot or comma press

* 🚑 Fix can invite new members in workspace bool

Closes baptisteArno#964

* 🔖 Release v2.18.4

* 🐛 Fix graph flickering on high res displays (baptisteArno#959)

This PR fixes the flickering and improves the performance so panning
around the graph is much smoother than before.



https://github.com/baptisteArno/typebot.io/assets/62795688/56b91e20-1eb0-44b5-9a4a-c07525c2ba48


/claim baptisteArno#575
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

### Summary by CodeRabbit

- Refactor: Improved the Graph component's scaling calculation for
enhanced readability and maintenance.
- Style: Updated the Graph component's style properties to ensure better
compatibility and visual performance on webkit browsers.

These changes aim to enhance the user experience by ensuring the Graph
component displays consistently across different web browsers. The
refactoring of the scaling calculation also makes the code easier to
understand and maintain, potentially leading to quicker updates and bug
fixes in the future.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Baptiste Arnaud <contact@baptiste-arnaud.fr>

* ✏️ Fix manual deployment doc start script typo

Closes baptisteArno#969

* 💚 Fix checkAndReportChatsUsage script sending multiple emails at once

* 🧑‍💻 Fix type resolution for @typebot.io/react and nextjs

Closes baptisteArno#968

* 🧑‍💻 Migrate to Tolgee (baptisteArno#976)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

### Summary by CodeRabbit

- Refactor: Transitioned to a new translation library (`@tolgee/react`)
across the application, enhancing the localization capabilities and
consistency.
- New Feature: Introduced a JSON configuration file for application
settings, improving customization and flexibility.
- Refactor: Updated SVG attribute naming convention in the
`WhatsAppLogo` component to align with React standards.
- Chore: Adjusted the `.gitignore` file and added a new line at the end.
- Documentation: Added instructions for setting up environment variables
for the Tolgee i18n contribution dev tool, improving the self-hosting
configuration guide.
- Style: Updated the `CollaborationMenuButton` to hide the
`PopoverContent` component by scaling it down to zero.
- Refactor: Simplified error handling logic for fetching and updating
typebots in `TypebotProvider.tsx`, improving code readability and
maintenance.
- Refactor: Removed the dependency on the `parseGroupTitle` function,
simplifying the code in several components.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🐛 Fix group duplicate new title bug

* 📝 Add webhook configuration tuto video

* 🐛 (number) Fix number input validation with variables

* 📝 Add text link section in text bubble doc

* ✏️ Fix CORSRules content typo for S3 config

* 🐛 Fix formatted message in input block when input is retried

* ⚡ Add cache-control header on newly uploaded files

* ✏️ (billing) Fix plan name typo

* 🚑 Move cache control header into the post policy

* 🔖 Release v2.19.0

* 📝 Add UTM params forwarding video tutorial

* 📦 Add strict package versioning to avoid incompatibility in workspace

* ⬆️ Upgrade Sentry to mitigate security issue

https://github.com/getsentry/sentry-javascript/security?mkt_tok=Nzc2LU1KTi01MDEAAAGPNi0ooiOxT0sphdzXd6xHU63d5z5Sc75FNR8cH-6EK-zlvUsUuUqP1YsmnxivxEyXnGZS2cN8XkpuNNGi3NIfoDnwoHci-31tbyJQB8y0Cg

* ⚡ (chatwoot) Unmount Typebot embed bubble when opening chatwoot

Closes baptisteArno#1007

* 🚑 Fix weird env parsing on Firefox making it crash

* 🛂 Update Cache-Control header in generatePresignedPostPolicy

* fix: whole page overflowing on the x axis and displaying a horizontal scrollbar (baptisteArno#1011)

this PR fixes issue
baptisteArno#1008 by making the
position of `HandDrawnArrow`'s parent relative, which confines the
absolute position of its children to be within the bounds of the parent,
causing layout not shift due to `right -30px`

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Updated the layout behavior of the `RealTimeResults` component on the
landing page for better user experience.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* ♻️ Introduce typebot v6 with events (baptisteArno#1013)

Closes baptisteArno#885

* 🚑 Fix parsing issue with new events field on ongoing session states

* 🐛 (import) Fix import typebot files that does not have name field

* 🚸 (typebotLink) Make "current" option work like typebot links instead of jump

* 🐛 Fix typebot publishing endpoint events parsing

* 🐛 Fix default initial items in TableList

* 🚑 (editor) Fix move block with outgoing edge

* 🚑 (zapier) Fix execute webhook endpoint too strict on block type check

* 🐛 (typebotLink) Fix link to first group with start event

* 🚑 (webhook) Fix webhook execution with default method

* 🐛 (editor) Fix edge delete with undefined groupIndex

* 🐛 Sort variables to parse to fix text bubble parsing issue

* 🐛 Fix theme background and font default selection

* 💄 Fix multi choice checkbox UI on small screens

* 📝 Add breaking changes and OpenAI block improvements docs

* ⚡ Add more video supports (baptisteArno#1023)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
	- Introduced a new layout option for the TextInput component.
- Added support for GUMLET and TIKTOK video content types in
VideoBubbleContent.
- Enhanced VideoUploadContent to handle new properties like aspectRatio
and maxWidth.
- Updated VideoBubble to include aspect-ratio and max-width styles based
on content properties.
- **Refactor**
- Changed the extension used for internationalization (i18n) in the VS
Code environment.
	- Modified how environment variables are accessed in tolgee.tsx.
- Updated parseVideoUrl function to include a new property
videoSizeSuggestion.
- **Chores**
- Updated the tolgeeEnv object in env.ts and added a new optional
parameter to the getRuntimeVariable function.
- Expanded video handling capabilities by introducing new video content
types and associated regular expressions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Closes baptisteArno#978 baptisteArno#936 baptisteArno#926

* 🛂 Reduce sendMessage serverless function max memory

* 🐛 (webhook) Fix legacy webhook {{state}} body parsing

* 🧑‍💻 (chat) Introduce startChat and continueChat endpoints

Closes baptisteArno#1030

* ⏪ Revert new authentication method for preview bot

* 📝 Add OpenAI Dialogue option in breaking change doc

* ⚡ Add maxWidth and maxHeight bubble them props

Closes baptisteArno#458

* 📝 Change community URLs, introduce Discord server

Closes baptisteArno#866

* 🐛 (textBubble) Fix variable parsing when starting or finishing by spaces

* ⏪ (wordpress) Revert to specific non breaking version for self-hosters

* 🐛 (billing) Set invoicing behavior to "always invoice" to fix double payment issue

* 🐛 (js) Fix default theme values css variables

Closes baptisteArno#1031

* 🐛 (fileUpload) Fix results file display if name contains comma

Closes baptisteArno#955

* ⬆️ (date) Upgrade date parser package

* 📝 Update Discord invite link

* 🚸 Auto scroll once picture choice images are fully loaded

* ♿ Show scrollbar on searchable items

* 🐛 Fix typebot parsing for legacy columnsWidth setting

* 🐛 (wordpress) Fix version mismatch for self-hosters for Standard embed as well

Closes baptisteArno#1038

* 🐛 (typebotLink) Fix variables merging with new values

* 🐛 (editor) Fix AB test items not connectable

* 🔊 Add response debug log for failing requests without errors

* 💚 Fix docker build missing ts target in schemas

* 🔖 Release v2.19.1

* ✏️ Fix typebot v7 breaking changes doc typo

* 🌐 Add es and ro support

* ✨ (openai) Add create speech OpenAI action

Closes baptisteArno#1025

* 🐛 (chatwoot) Fix email prefill when Chatwoot contact already exist

* 🛂 (billing) Add isPastDue field in workspace (baptisteArno#1046)

Closes baptisteArno#1039

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
  - Workspaces now include additional status indicator: `isPastDue`.
- New pages for handling workspaces that are past due. Meaning, an
invoice is unpaid.

- **Bug Fixes**
- Fixed issues with workspace status checks and redirections for
suspended workspaces.

- **Refactor**
- Refactored workspace-related API functions to accommodate new status
fields.
- Improved permission checks for reading and writing typebots based on
workspace status.

- **Chores**
  - Database schema updated to include `isPastDue` field for workspaces.
- Implemented new webhook event handling for subscription and invoice
updates.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🚑 (editor) Fix typebot update permission

* ✨ Allow user to share a flow publicly and make it duplicatable

Closes baptisteArno#360

* 🐛 (pictureChoice) Fix choice parsing too unrestrictive

* 🔥 Remove VIEWER_URL_INTERNAL variable

BREAKING CHANGE: NEXT_PUBLIC_VIEWER_INTERNAL does not exist anymore as typebot.io now directly points to the viewer project

* 🚑 (billing) Fix stripe webhook "invoice.paid" typo

* 🐛 Fix processTelemetry endpoint not reachable

* ⚡ (billing) Improve past_due workspace checking webhook

* 📝 Add new start and continue endpoints in the API runtime instructions

* 🚸 (redirect) Make sure the redirection is always done on top frame

* 🔧 Increase builder request max size to 4MB

* 💚 Update broken action-autotag package

* 🚑 (pictureChoice) Fix pic choice multi select parsing

* 📝 Improve WP prefilled var explanation

* 🐛 Fix default webhook body with multi inputs groups

* 🛂 Allow app admin to read a typebot

* 🐛 (share) Fix duplicate folderId issue

* 🚸 (fileUpload) Properly encode commas from uploaded file urls

Closes baptisteArno#955

* ⚡ (wordpress) Add lib_version prop in shortcode

Closes baptisteArno#1035

* 📝 Add flow share docs

* 🔖 Release v2.20.0

* ⚗️ (docs) Replace Algolia search with Community Search

* Updated vercel deployment guide. (baptisteArno#1075)

Adding explanation text about builder and viewer.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Documentation**
- Enhanced the self-hosting guide with additional explanatory notes on
deploying both the Builder and Viewer components for Typebot, clarifying
their distinct roles in service flow creation and user interaction.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 🐛 (editor) Fix old typebot flash when changing the typebot

* 🐛 Fix multiple item dragged issue

* 🐛 Fix right click in bubble text editor selects the group

Closes baptisteArno#920

* ✏️ Fix invalid ending comma in API instructions

Closes baptisteArno#1022

* 🧑‍💻 Automatically guess env URLs for Vercel preview deploy… (baptisteArno#1076)

…ments

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced new URL processing logic to enhance compatibility with
Vercel preview environments.
- Improved handling of environment-specific URLs for authentication and
viewer services.

- **Enhancements**
- Streamlined environment variable management for more reliable
deployment configurations.

- **Documentation**
- Updated documentation to reflect new environment variable processing
functions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* 📝 Add node prerequisite in Contributing guide

* 🛂 (billing) Past due status only for unpaid invoices with additional usage

* 🚸 (docs) Open community search docs results in same tab

* ♻️ Remove references to old s3 URLs

* 🔧 Update vercel.json to reflect new api path

* 🛂 Hide workspace members list from guest

* update typebot

* update typebot

* 🔧 Update main viewer domain to typebot.co

* Delete apps/landing-page/public/favicon.png

* Add files via upload

* Delete apps/builder/public/favicon.png

* Add files via upload

* Delete apps/viewer/public/favicon.png

* Add files via upload

* Add files via upload

* Delete apps/builder/public/favicon.png

* Add files via upload

* Add files via upload

* translate

* app.chatwoot.com

* options.baseUrl

* ⚡ Add dynamic timeout to bot engine api

* 🐛 (sheets) Init OAuth client inside a function to avoid potential conflict

* 🐛 Fix change language not working in the editor

* ✨ Introducing Radar, fraud detection

* Update publishTypebot.ts

* 📝 (docs): fix typo in Unsplash description (baptisteArno#1094)

Documentation

This PR updates the documentation to fix an incorrect description for
the Unsplash configuration.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Documentation**
- Corrected a hyperlink and associated text in the self-hosting
configuration guide, changing "Giphy" to "Unsplash" for image search
references.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Victor Santos <vsantos.py@gmail.com>

* 📈 Only send suspicious bot alert if risk level is below 100

* 🛂 Auto ban IP on suspected bot publishing (baptisteArno#1095)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced sign-in error handling with specific messages for different
error types.
- Implemented IP-based restrictions for authentication and publishing
actions.

- **Bug Fixes**
- Updated the retrieval of user session information to improve
reliability.

- **Documentation**
- Updated usage instructions for `getServerSession` to reflect the new
authentication options.

- **Refactor**
- Replaced direct usage of `authOptions` with a new function
`getAuthOptions` to dynamically generate authentication options.
- Improved IP address extraction logic to handle various header formats.

- **Chores**
- Added a new `BannedIp` model to the database schema for managing
IP-based restrictions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* feat: toolzz logo on sigin and header

---------

Signed-off-by: Victor Santos <vsantos.py@gmail.com>
Co-authored-by: Baptiste Arnaud <contact@baptiste-arnaud.fr>
Co-authored-by: Rishi Raj Jain <rishi18304@iiitd.ac.in>
Co-authored-by: Prateek Kalra <prateekkalra1997@gmail.com>
Co-authored-by: neo773 <62795688+neo773@users.noreply.github.com>
Co-authored-by: onFire(Abhi) <40654066+AbhiShake1@users.noreply.github.com>
Co-authored-by: Thiago Mendonça <thiagomendonca09@gmail.com>
Co-authored-by: lucasbuges <123869629+lucasbuges@users.noreply.github.com>
Co-authored-by: Baptiste Arnaud <baptiste.arnaud95@gmail.com>
Co-authored-by: Victor Santos <vsantos.py@gmail.com>
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.

Block access to past due subscription workspace
1 participant