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

chore: sync key usage on upload #998

Merged
merged 2 commits into from
Oct 7, 2024
Merged

Conversation

juliusmarminge
Copy link
Collaborator

@juliusmarminge juliusmarminge commented Oct 7, 2024

ref: https://discord.com/channels/966627436387266600/1292693436184531061

Summary by CodeRabbit

  • New Features
    • Enhanced upload requests by including version information in the headers for better tracking and debugging.
  • Bug Fixes
    • Improved consistency in upload functionality across different methods.
  • Improvements
    • Version information is now accurately displayed on the dashboard during uploads.

Copy link

changeset-bot bot commented Oct 7, 2024

🦋 Changeset detected

Latest commit: 5ea847a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
uploadthing Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link

vercel bot commented Oct 7, 2024

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

Name Status Preview Comments Updated (UTC)
docs-uploadthing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 8:51pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
legacy-docs-uploadthing ⬜️ Ignored (Inspect) Visit Preview Oct 7, 2024 8:51pm

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes in this pull request involve the addition of a new import for the version from package.json in two files: upload.browser.ts and upload.server.ts. In both files, the uploadWithProgress and uploadWithoutProgress functions respectively have been updated to include a new header, x-uploadthing-version, in their HTTP requests. This change allows for the tracking of the version during uploads without altering the existing function signatures or overall logic.

Changes

File Change Summary
packages/uploadthing/src/internal/... Added import for version from package.json and included x-uploadthing-version header in uploadWithProgress and uploadWithoutProgress functions.

Possibly related PRs

  • fix: Fix withUt in monorepos #987: The changes in this PR involve modifications to the withUt function in the packages/uploadthing/src/tw.ts file, which may relate to the overall upload functionality, similar to the enhancements made in the main PR regarding version tracking in upload requests.

Suggested labels

📚 documentation, examples

Poem

In the land of uploads, so bright and keen,
A version was added, a header unseen.
With x-uploadthing-version, we track with delight,
Each file that we send takes a wondrous flight!
So hop along, friends, let the uploads commence,
With versioning magic, we leap o'er the fence! 🐇✨


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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
packages/uploadthing/src/internal/upload.server.ts (2)

27-27: LGTM: Version header added correctly.

The new header x-uploadthing-version is correctly implemented, allowing for version tracking during uploads. This is valuable for debugging and analytics purposes.

Consider adding a brief comment explaining the purpose of this header for future maintainers:

+ // Add version header for tracking and debugging purposes
HttpClientRequest.setHeader("x-uploadthing-version", version),

11-11: Overall impact: Positive addition for version tracking.

The changes introduce version tracking for uploads without altering existing functionality. This aligns well with the PR objective of synchronizing key usage on upload and provides valuable information for debugging and analytics.

Consider documenting this new version header in your API documentation, if applicable, to inform consumers of your upload API about this additional metadata.

Also applies to: 27-27

packages/uploadthing/src/internal/upload.browser.ts (1)

30-30: LGTM: Version header added to XMLHttpRequest

The addition of the "x-uploadthing-version" header is a good practice. It allows the server to identify the client version, which can be useful for debugging and maintaining backwards compatibility.

Consider adding a try-catch block around the setRequestHeader call to handle potential errors, although they are unlikely in this case:

try {
  xhr.setRequestHeader("x-uploadthing-version", version);
} catch (error) {
  console.warn("Failed to set x-uploadthing-version header:", error);
}

This would ensure that the upload process continues even if setting the header fails for any reason.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a3fa6af and 794a8a2.

📒 Files selected for processing (2)
  • packages/uploadthing/src/internal/upload.browser.ts (2 hunks)
  • packages/uploadthing/src/internal/upload.server.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (3)
packages/uploadthing/src/internal/upload.server.ts (1)

11-11: LGTM: Version import added correctly.

The import statement for the version from package.json is correctly implemented. This is a good practice for accessing the package version in the code.

packages/uploadthing/src/internal/upload.browser.ts (2)

7-7: LGTM: Version import added

The addition of the version import from package.json is a good practice. It allows the code to use the current package version, which can be helpful for tracking or debugging purposes.


Line range hint 1-184: Overall assessment: Changes look good

The changes made to this file are minimal and well-implemented. They improve version tracking by adding the package version to the upload request headers. This can be valuable for debugging and maintaining backwards compatibility. The changes don't introduce any breaking modifications to the existing functionality.

Copy link

pkg-pr-new bot commented Oct 7, 2024

Copy link
Contributor

github-actions bot commented Oct 7, 2024

📦 Bundle size comparison

Bundle Size (gzip) Visualization
Main 26.03KB See Treemap 📊
PR (b11a12f) 26.04KB See Treemap 📊
Diff ↑5.00B

Copy link
Contributor

github-actions bot commented Oct 7, 2024

A new canary is available for testing. You can install this latest build in your project with:

pnpm add @uploadthing/expo@7.0.3-canary.463ce07
pnpm add @uploadthing/mime-types@0.3.1-canary.463ce07
pnpm add @uploadthing/nuxt@7.0.3-canary.463ce07
pnpm add @uploadthing/react@7.0.3-canary.463ce07
pnpm add @uploadthing/shared@7.0.3-canary.463ce07
pnpm add @uploadthing/solid@7.0.3-canary.463ce07
pnpm add @uploadthing/svelte@7.0.3-canary.463ce07
pnpm add uploadthing@7.0.3-canary.463ce07
pnpm add @uploadthing/vue@7.0.3-canary.463ce07

@github-actions github-actions bot removed the release canary Trigger a canary release to npm label Oct 7, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
.changeset/popular-forks-speak.md (1)

5-5: Minor grammatical improvement suggested.

Consider adding the article "the" before "dashboard" for improved readability.

Here's the suggested change:

- chore: send version header when uploading to have accurate version shown on dashboard
+ chore: send version header when uploading to have accurate version shown on the dashboard
🧰 Tools
🪛 LanguageTool

[uncategorized] ~5-~5: You might be missing the article “the” here.
Context: ...ading to have accurate version shown on dashboard

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 794a8a2 and 5ea847a.

📒 Files selected for processing (1)
  • .changeset/popular-forks-speak.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/popular-forks-speak.md

[uncategorized] ~5-~5: You might be missing the article “the” here.
Context: ...ading to have accurate version shown on dashboard

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

🔇 Additional comments (1)
.changeset/popular-forks-speak.md (1)

1-5: LGTM: Changeset correctly documents the patch update.

The changeset file accurately describes the patch update for the "uploadthing" package, which aligns with the PR objectives and the changes summarized in the AI-generated summary.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~5-~5: You might be missing the article “the” here.
Context: ...ading to have accurate version shown on dashboard

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

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.

2 participants