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

refactor: do not send audit logs to tinybird #2206

Merged
merged 4 commits into from
Oct 5, 2024

Conversation

chronark
Copy link
Collaborator

@chronark chronark commented Oct 5, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new API endpoints for managing permissions and roles, including createPermission, deletePermission, createRole, and deleteRole.
    • Enhanced existing endpoints with additional fields and improved response schemas for better usability.
  • Bug Fixes

    • Removed outdated logging functionality to streamline audit logging processes across various features and functions.
  • Documentation

    • Updated API documentation to reflect new endpoints, modified definitions, and deprecated methods for clearer guidance.
  • Chores

    • Downgraded the @types/react-dom dependency version for improved compatibility.

Copy link

vercel bot commented Oct 5, 2024

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

Name Status Preview Comments Updated (UTC)
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 1:47pm
play ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 1:47pm
workflows ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 1:47pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 5, 2024 1:47pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
dashboard ⬜️ Ignored (Inspect) Visit Preview Oct 5, 2024 1:47pm

Copy link

changeset-bot bot commented Oct 5, 2024

⚠️ No Changeset found

Latest commit: 2ff6954

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Oct 5, 2024

Warning

Rate limit exceeded

@chronark has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between 2ce5353 and 2ff6954.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces significant changes across multiple files, primarily focusing on the removal of the ingestAuditLogsTinybird function calls from various mutation methods. This function was previously responsible for logging audit information to Tinybird, and its removal streamlines the audit logging process by consolidating it to the insertAuditLogs function. The overall logic and structure of the affected functions remain intact, ensuring that core functionalities and error handling mechanisms are preserved.

Changes

File Path Change Summary
apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx Removed ingestAuditLogsTinybird function call from StripeSuccess. Audit logging now handled by insertAuditLogs.
apps/dashboard/app/new/page.tsx Removed ingestAuditLogsTinybird function call during personal workspace creation. Logging now handled by insertAuditLogs.
apps/dashboard/lib/tinybird.ts Removed ingestAuditLogsTinybird function and associated imports. Updated import for unkeyAuditLogEvents to type-only.
apps/dashboard/lib/trpc/routers/api/create.ts Removed ingestAuditLogsTinybird function call in createApi. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/api/delete.ts Removed ingestAuditLogsTinybird function call in deleteApi. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/api/updateDeleteProtection.ts Removed ingestAuditLogsTinybird function call in updateAPIDeleteProtection. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/api/updateIpWhitelist.ts Removed ingestAuditLogsTinybird function call in updateApiIpWhitelist. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/api/updateName.ts Removed ingestAuditLogsTinybird function call in updateApiName. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/create.ts Removed ingestAuditLogsTinybird function call in createKey. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/createRootKey.ts Changed import for UnkeyAuditLog to type-only and removed ingestAuditLogsTinybird function call.
apps/dashboard/lib/trpc/routers/key/delete.ts Removed ingestAuditLogsTinybird function call in deleteKeys. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/deleteRootKey.ts Removed ingestAuditLogsTinybird function call in deleteRootKeys. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/updateEnabled.ts Removed ingestAuditLogsTinybird function call in updateKeyEnabled. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/updateExpiration.ts Removed ingestAuditLogsTinybird function call in updateKeyExpiration. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/updateMetadata.ts Removed ingestAuditLogsTinybird function call in updateKeyMetadata. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/updateName.ts Removed ingestAuditLogsTinybird function call in updateKeyName. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/updateOwnerId.ts Removed ingestAuditLogsTinybird function call in updateKeyOwnerId. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/updateRatelimit.ts Removed ingestAuditLogsTinybird function call in updateKeyRatelimit. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/updateRemaining.ts Removed ingestAuditLogsTinybird function call in updateKeyRemaining. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/key/updateRootKeyName.ts Removed ingestAuditLogsTinybird function call in updateRootKeyName. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/llmGateway/create.ts Removed ingestAuditLogsTinybird function call in createLlmGateway. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/llmGateway/delete.ts Removed ingestAuditLogsTinybird function call in deleteLlmGateway. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/ratelimit/createNamespace.ts Removed ingestAuditLogsTinybird function call in createNamespace. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/ratelimit/createOverride.ts Removed ingestAuditLogsTinybird function call in createOverride. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/ratelimit/deleteNamespace.ts Removed ingestAuditLogsTinybird function call in deleteNamespace. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/ratelimit/deleteOverride.ts Removed ingestAuditLogsTinybird function call in deleteOverride. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/ratelimit/updateNamespaceName.ts Removed ingestAuditLogsTinybird function call in updateNamespaceName. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/ratelimit/updateOverride.ts Removed ingestAuditLogsTinybird function call in updateOverride. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac.ts Removed ingestAuditLogsTinybird calls from various methods. Logging now handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/addPermissionToRootKey.ts Removed ingestAuditLogsTinybird function call in addPermissionToRootKey. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/connectRoleToKey.ts Removed ingestAuditLogsTinybird function call in connectRoleToKey. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/createPermission.ts Removed ingestAuditLogsTinybird function call in createPermission. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/createRole.ts Removed ingestAuditLogsTinybird function calls in createRole. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/deletePermission.ts Removed ingestAuditLogsTinybird function call in deletePermission. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/deleteRole.ts Removed ingestAuditLogsTinybird function call in deleteRole. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/disconnectPermissionFromRole.ts Removed ingestAuditLogsTinybird function call in disconnectPermissionFromRole. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/disconnectRoleFromKey.ts Removed ingestAuditLogsTinybird function call in disconnectRoleFromKey. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/removePermissionFromRootKey.ts Removed ingestAuditLogsTinybird function call in removePermissionFromRootKey. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/updatePermission.ts Removed ingestAuditLogsTinybird function call in updatePermission. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/updateRole.ts Removed ingestAuditLogsTinybird function call in updateRole. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/rbac/upsertPermission.ts Removed ingestAuditLogsTinybird function call in upsertPermission. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/vercel.ts Removed ingestAuditLogsTinybird function calls from various procedures. Logging now handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/workspace/changeName.ts Removed ingestAuditLogsTinybird function call in changeWorkspaceName. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/workspace/changePlan.ts Removed ingestAuditLogsTinybird function calls in changeWorkspacePlan. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/workspace/create.ts Removed ingestAuditLogsTinybird function call in createWorkspace. Logging handled by insertAuditLogs.
apps/dashboard/lib/trpc/routers/workspace/optIntoBeta.ts Removed ingestAuditLogsTinybird function call in optWorkspaceIntoBeta. Logging handled by insertAuditLogs.
apps/dashboard/package.json Downgraded @types/react-dom from 18.3.0 to 18.2.25.
packages/api/src/openapi.d.ts Comprehensive updates to the API structure, including new endpoints and schema modifications.

Possibly related PRs

Suggested labels

Bug, Core Team

Suggested reviewers

  • mcstepp
  • perkinsjr

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 do a full 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

github-actions bot commented Oct 5, 2024

Thank you for following the naming conventions for pull request titles! 🙏

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: 2

🧹 Outside diff range and nitpick comments (3)
apps/dashboard/lib/trpc/routers/key/createRootKey.ts (1)

3-3: LGTM! Consider removing unused imports.

The changes to the import statements are correct and align with the PR objective. The UnkeyAuditLog is now correctly imported as a type-only import, and the ingestAuditLogsTinybird import has been removed.

Consider removing any unused imports from the file to keep it clean. You can use a linter or IDE features to identify and remove unused imports automatically.

apps/dashboard/lib/tinybird.ts (1)

1-1: Summary of changes and potential impact

The main changes in this file involve the removal of the ingestAuditLogsTinybird function and its associated imports. This suggests a significant change in how audit logs are handled in the system. While the changes themselves look clean and straightforward, it's crucial to ensure that:

  1. The removal of this functionality doesn't create any gaps in the audit logging process.
  2. Any components or services that previously relied on this function have been updated accordingly.
  3. If this change is part of a larger refactoring effort, all related changes across the codebase have been implemented consistently.

Consider documenting this change in the project's changelog or architecture documentation, explaining the new approach to handling audit logs (if any) and the rationale behind this change.

apps/dashboard/lib/trpc/routers/llmGateway/create.ts~ (1)

71-71: Consider providing a more user-friendly error code

The error code used is "PRECONDITION_FAILED", which might not clearly indicate the nature of the error to the client. Consider using a more specific error code like "CONFLICT" to represent a duplicate resource conflict.

Apply this diff to adjust the error code:

 code:
-  "PRECONDITION_FAILED",
+  "CONFLICT",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between faf6db7 and 63d1314.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (49)
  • apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx (0 hunks)
  • apps/dashboard/app/new/page.tsx (0 hunks)
  • apps/dashboard/lib/tinybird.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/api/create.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/api/delete.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/api/updateDeleteProtection.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/api/updateIpWhitelist.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/api/updateName.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/create.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/createRootKey.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/key/delete.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/deleteRootKey.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/updateEnabled.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/updateExpiration.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/updateMetadata.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/updateName.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/updateOwnerId.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/updateRatelimit.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/updateRemaining.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/key/updateRootKeyName.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/llmGateway/create.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/llmGateway/create.ts~ (1 hunks)
  • apps/dashboard/lib/trpc/routers/llmGateway/delete.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/ratelimit/createNamespace.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/ratelimit/createOverride.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/ratelimit/deleteNamespace.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/ratelimit/deleteOverride.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/ratelimit/updateNamespaceName.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/ratelimit/updateOverride.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/addPermissionToRootKey.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/connectRoleToKey.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/createPermission.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/createRole.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/deletePermission.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/deleteRole.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/disconnectPermissionFromRole.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/disconnectRoleFromKey.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/removePermissionFromRootKey.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/updatePermission.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/updateRole.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/rbac/upsertPermission.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/vercel.ts (2 hunks)
  • apps/dashboard/lib/trpc/routers/workspace/changeName.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/workspace/changePlan.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/workspace/create.ts (0 hunks)
  • apps/dashboard/lib/trpc/routers/workspace/optIntoBeta.ts (0 hunks)
  • apps/dashboard/package.json (1 hunks)
  • packages/api/src/openapi.d.ts (1 hunks)
💤 Files with no reviewable changes (40)
  • apps/dashboard/app/(app)/settings/billing/stripe/success/page.tsx
  • apps/dashboard/app/new/page.tsx
  • apps/dashboard/lib/trpc/routers/api/create.ts
  • apps/dashboard/lib/trpc/routers/api/delete.ts
  • apps/dashboard/lib/trpc/routers/api/updateDeleteProtection.ts
  • apps/dashboard/lib/trpc/routers/api/updateIpWhitelist.ts
  • apps/dashboard/lib/trpc/routers/api/updateName.ts
  • apps/dashboard/lib/trpc/routers/key/create.ts
  • apps/dashboard/lib/trpc/routers/key/delete.ts
  • apps/dashboard/lib/trpc/routers/key/deleteRootKey.ts
  • apps/dashboard/lib/trpc/routers/key/updateEnabled.ts
  • apps/dashboard/lib/trpc/routers/key/updateExpiration.ts
  • apps/dashboard/lib/trpc/routers/key/updateMetadata.ts
  • apps/dashboard/lib/trpc/routers/key/updateName.ts
  • apps/dashboard/lib/trpc/routers/key/updateOwnerId.ts
  • apps/dashboard/lib/trpc/routers/key/updateRatelimit.ts
  • apps/dashboard/lib/trpc/routers/key/updateRemaining.ts
  • apps/dashboard/lib/trpc/routers/key/updateRootKeyName.ts
  • apps/dashboard/lib/trpc/routers/llmGateway/create.ts
  • apps/dashboard/lib/trpc/routers/llmGateway/delete.ts
  • apps/dashboard/lib/trpc/routers/ratelimit/createNamespace.ts
  • apps/dashboard/lib/trpc/routers/ratelimit/createOverride.ts
  • apps/dashboard/lib/trpc/routers/ratelimit/deleteNamespace.ts
  • apps/dashboard/lib/trpc/routers/ratelimit/deleteOverride.ts
  • apps/dashboard/lib/trpc/routers/ratelimit/updateNamespaceName.ts
  • apps/dashboard/lib/trpc/routers/ratelimit/updateOverride.ts
  • apps/dashboard/lib/trpc/routers/rbac/addPermissionToRootKey.ts
  • apps/dashboard/lib/trpc/routers/rbac/connectRoleToKey.ts
  • apps/dashboard/lib/trpc/routers/rbac/createPermission.ts
  • apps/dashboard/lib/trpc/routers/rbac/createRole.ts
  • apps/dashboard/lib/trpc/routers/rbac/deletePermission.ts
  • apps/dashboard/lib/trpc/routers/rbac/deleteRole.ts
  • apps/dashboard/lib/trpc/routers/rbac/disconnectPermissionFromRole.ts
  • apps/dashboard/lib/trpc/routers/rbac/disconnectRoleFromKey.ts
  • apps/dashboard/lib/trpc/routers/rbac/removePermissionFromRootKey.ts
  • apps/dashboard/lib/trpc/routers/rbac/updatePermission.ts
  • apps/dashboard/lib/trpc/routers/rbac/updateRole.ts
  • apps/dashboard/lib/trpc/routers/workspace/changePlan.ts
  • apps/dashboard/lib/trpc/routers/workspace/create.ts
  • apps/dashboard/lib/trpc/routers/workspace/optIntoBeta.ts
🔇 Additional comments (17)
apps/dashboard/lib/trpc/routers/workspace/changeName.ts (1)

Line range hint 1-70: LGTM! Changes align with PR objective.

The removal of the ingestAuditLogsTinybird function call successfully implements the PR objective of not sending audit logs to Tinybird. The insertAuditLogs function is still in place, ensuring that audit logs are recorded locally.

To ensure all Tinybird-related code has been removed, please run the following script:

If any Tinybird-related code or unused imports are found, please remove them to complete the refactoring process.

apps/dashboard/package.json (1)

127-127: Verify the reason for downgrading @types/react-dom

The change to downgrade @types/react-dom from 18.3.0 to 18.2.25 has been correctly implemented. However, I have a few points to consider:

  1. This change doesn't seem to relate to the PR objective of "refactor: do not send audit logs to tinybird". Could you clarify the reason for this modification?
  2. Downgrading type definitions is unusual and could potentially introduce type incompatibilities. Have you verified that this version is compatible with your current react-dom package version?
  3. If this change is necessary, consider adding a comment in the package.json file explaining why this specific version is required to prevent accidental updates in the future.

To ensure compatibility, please run the following command and verify that there are no type errors:

If this command doesn't exist, you can add it to your scripts in package.json:

"scripts": {
  "typecheck": "tsc --noEmit"
}

This will help catch any potential type incompatibilities introduced by this change.

apps/dashboard/lib/trpc/routers/key/createRootKey.ts (2)

Line range hint 1-200: Summary: Successfully refactored to remove Tinybird integration

The changes in this file successfully achieve the PR objective of not sending audit logs to Tinybird. The core functionality of creating a root key remains intact, and the refactoring appears to be clean and focused.

Key points:

  1. Removed Tinybird-related imports and function calls.
  2. Retained local audit log functionality.
  3. No apparent issues introduced by these changes.

Great job on this refactoring! The changes are focused and align well with the PR objective. Just ensure that all logging requirements are still met with the remaining audit log functionality.


Line range hint 1-200: Verify logging requirements after removing Tinybird ingestion.

The removal of the ingestAuditLogsTinybird(auditLogs) call aligns with the PR objective. However, it's important to ensure that this change doesn't impact any critical logging or auditing requirements.

Please confirm that:

  1. There are no compliance or security requirements that mandate sending these logs to an external service.
  2. The remaining audit log functionality (e.g., insertAuditLogs) is sufficient for your current needs.

Run the following script to check for any remaining references to Tinybird in the codebase:

If any results are found, please review them to ensure complete removal of Tinybird integration or add appropriate comments explaining why they remain.

apps/dashboard/lib/tinybird.ts (2)

1-1: Verify the impact of removing ingestAuditLogsTinybird function.

The ingestAuditLogsTinybird function has been removed, which suggests a change in the audit log ingestion process. Please ensure that:

  1. This removal doesn't break any existing functionality.
  2. There are no dangling references to this function elsewhere in the codebase.
  3. If necessary, an alternative method for audit log ingestion has been implemented or this functionality has been moved elsewhere.

Let's check for any remaining references to the removed function:

#!/bin/bash
# Search for any remaining references to ingestAuditLogsTinybird
rg --type typescript 'ingestAuditLogsTinybird'

Additionally, please provide information on how audit logs will be handled going forward, or if this functionality has been deprecated.


3-3: LGTM: Import changes look good.

The change to import unkeyAuditLogEvents as a type and the removal of unused imports (newId and auditLogSchemaV1) are appropriate given the removal of the ingestAuditLogsTinybird function.

Let's verify that these imports are not used elsewhere in the file:

✅ Verification successful

LGTM: Import removals are correctly implemented.

The imports newId and auditLogSchemaV1 are no longer used in apps/dashboard/lib/tinybird.ts, confirming that their removal is appropriate and does not affect the functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that removed imports are not used elsewhere in the file
rg --type typescript 'newId|auditLogSchemaV1' apps/dashboard/lib/tinybird.ts

Length of output: 218


Script:

#!/bin/bash
# Verify that removed imports are not used elsewhere in the file
rg 'newId|auditLogSchemaV1' apps/dashboard/lib/tinybird.ts

Length of output: 60

apps/dashboard/lib/trpc/routers/vercel.ts (3)

Line range hint 177-196: LGTM: Audit logging system updated

The changes look good. The ingestAuditLogsTinybird call has been replaced with insertAuditLogs, maintaining the audit logging functionality while shifting to a different system. The audit log information remains consistent with the previous implementation.


Line range hint 297-319: LGTM: Audit logging system updated

The changes look good. The ingestAuditLogsTinybird call has been replaced with insertAuditLogs, maintaining the audit logging functionality while shifting to a different system. The audit log information remains consistent with the previous implementation.


Line range hint 1-621: Overall changes: Audit logging system updated with some inconsistencies

The changes in this file align with the PR objective of not sending audit logs to Tinybird. The ingestAuditLogsTinybird function calls have been replaced with insertAuditLogs in the setupProject and upsertApiId procedures, maintaining the audit logging functionality while shifting to a different system.

However, there are inconsistencies between the AI-generated summary and the actual code changes:

  1. The summary mentioned changes to upsertNewRootKey, unbind, and disconnectProject procedures, but no changes are visible in the provided code snippets for these procedures.

Please verify if any changes were intended for these procedures and update the code or the summary accordingly.

apps/dashboard/lib/trpc/routers/rbac.ts (6)

4-4: LGTM: Import statement updated correctly

The import statement has been properly updated to remove ingestAuditLogsTinybird and change UnkeyAuditLog to a type-only import. This change aligns with the PR objective of not sending audit logs to Tinybird.


Line range hint 32-91: LGTM: Audit logging updated correctly in addPermissionToRootKey

The ingestAuditLogsTinybird call has been removed, and audit logging is now handled solely by insertAuditLogs. This change is consistent with the PR objective and maintains proper audit logging within the transaction.


Line range hint 364-437: LGTM: Audit logging updated correctly in createRole

The ingestAuditLogsTinybird calls have been removed, and audit logging is now handled solely by insertAuditLogs. This change is consistent with the PR objective and maintains proper audit logging within the transaction. The logic for creating roles and connecting permissions remains intact.


Line range hint 569-604: LGTM: Audit logging updated correctly in deletePermission

The ingestAuditLogsTinybird call has been removed, and audit logging is now handled solely by insertAuditLogs. This change is consistent with the PR objective and maintains proper audit logging within the transaction. The logic for deleting permissions remains intact.


Line range hint 485-520: LGTM: Audit logging updated correctly in createPermission

The ingestAuditLogsTinybird call has been removed, and audit logging is now handled solely by insertAuditLogs. This change is consistent with the PR objective and maintains proper audit logging within the transaction. The logic for creating permissions remains intact.


Line range hint 1-638: Summary: Successfully removed Tinybird audit logging

The changes in this file consistently remove all instances of ingestAuditLogsTinybird and replace them with insertAuditLogs. This modification achieves the PR objective of not sending audit logs to Tinybird while maintaining proper audit logging functionality. The changes are applied consistently across all relevant procedures, and the existing logic and data integrity are preserved. All modifications are made within transactions, ensuring data consistency.

Great job on implementing these changes consistently and maintaining the overall functionality of the RBAC system!

apps/dashboard/lib/trpc/routers/llmGateway/create.ts~ (1)

67-78: Ensure all database errors are appropriately handled

While duplicate entries are specifically caught, other potential database errors might not provide sufficient information to the client or might reveal internal details. Ensure that error handling does not expose sensitive information and that the client receives meaningful feedback.

Run the following script to check for unhandled database errors:

✅ Verification successful

All DatabaseError instances are appropriately handled.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other DatabaseError usages without specific handling.

# Expected: All DatabaseError instances are handled appropriately.

rg --type js --type ts 'DatabaseError' -A 5

Length of output: 5837

packages/api/src/openapi.d.ts (1)

4191-4191: ⚠️ Potential issue

Typo in the description comment

There is a typographical error in the description on line 4191. The word "identifiy" should be "identify".

Please apply the following fix:

- * @description The name of the key, give keys a name to easily identifiy their purpose
+ * @description The name of the key, give keys a name to easily identify their purpose

Likely invalid or redundant comment.

apps/dashboard/lib/trpc/routers/llmGateway/create.ts~ Outdated Show resolved Hide resolved
apps/dashboard/lib/trpc/routers/llmGateway/create.ts~ Outdated Show resolved Hide resolved
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: 4

🧹 Outside diff range and nitpick comments (1)
apps/workflows/jobs/refill-daily.ts (1)

64-64: Ensure consistent usage of date objects

In the audit log insertion, time is set using Date.now(), which returns a timestamp in milliseconds. If the time field expects a Date object, consider using new Date() for consistency with other date fields like lastRefillAt.

Apply this change if appropriate:

- time: Date.now(),
+ time: new Date(),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 63d1314 and 2ce5353.

📒 Files selected for processing (8)
  • apps/workflows/jobs/create-invoice.ts (0 hunks)
  • apps/workflows/jobs/downgrade-requests.ts (0 hunks)
  • apps/workflows/jobs/end-trials.ts (0 hunks)
  • apps/workflows/jobs/index.ts (0 hunks)
  • apps/workflows/jobs/invoicing.ts.disabled (0 hunks)
  • apps/workflows/jobs/refill-daily.ts (2 hunks)
  • apps/workflows/jobs/refill-monthly.ts (2 hunks)
  • apps/workflows/lib/tinybird.ts (0 hunks)
💤 Files with no reviewable changes (6)
  • apps/workflows/jobs/create-invoice.ts
  • apps/workflows/jobs/downgrade-requests.ts
  • apps/workflows/jobs/end-trials.ts
  • apps/workflows/jobs/index.ts
  • apps/workflows/jobs/invoicing.ts.disabled
  • apps/workflows/lib/tinybird.ts
🔇 Additional comments (2)
apps/workflows/jobs/refill-daily.ts (1)

4-4: Importing newId is appropriate

The addition of newId from @unkey/id is necessary for generating unique identifiers for audit logs.

apps/workflows/jobs/refill-monthly.ts (1)

47-85: Good use of transactions to ensure atomicity

Wrapping the refill operation and audit logging within a database transaction ensures that both updates are performed atomically, which is essential for data integrity.

apps/workflows/jobs/refill-daily.ts Outdated Show resolved Hide resolved
apps/workflows/jobs/refill-monthly.ts Show resolved Hide resolved
apps/workflows/jobs/refill-monthly.ts Outdated Show resolved Hide resolved
@chronark chronark disabled auto-merge October 5, 2024 14:48
@chronark chronark merged commit 2288ebf into main Oct 5, 2024
26 checks passed
@chronark chronark deleted the remove-tinybird-auditlogs branch October 5, 2024 14:48
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