Display custom link preview titles in the analytics#2216
Merged
steven-tey merged 5 commits intomainfrom Mar 28, 2025
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
steven-tey
approved these changes
Mar 28, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enables the display of custom link preview titles in the analytics view by introducing a new title field and adapting related functionality.
- Introduces a new hook dependency for workspace preferences and a callback function for determining link titles.
- Adds a title field to the analytics response schema and maps it from analytics data.
- Modifies the useWorkspacePreferences hook to make its defaultValue parameter optional.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/web/ui/analytics/top-links.tsx | Implements a useCallback to determine which title to display based on preferences and tab value. |
| apps/web/lib/zod/schemas/analytics-response.ts | Adds a new, nullish title field to the analytics response schema. |
| apps/web/lib/swr/use-workspace-preferences.ts | Updates the hook signature to make the defaultValue parameter optional. |
| apps/web/lib/analytics/get-analytics.ts | Maps the new title field from analytics data with a fallback to null. |
Comments suppressed due to low confidence (3)
apps/web/ui/analytics/top-links.tsx:67
- [nitpick] Avoid using 'as any' and consider defining a proper type for the parameter; also, renaming 'd' to a more descriptive name (e.g. 'linkData') would improve readability.
title: shortLinkTitle(d as any),
apps/web/lib/swr/use-workspace-preferences.ts:22
- The defaultValue parameter is now optional, so please ensure that all callers of useWorkspacePreferences handle the possibility of an undefined defaultValue appropriately.
defaultValue?: D,
apps/web/lib/analytics/get-analytics.ts:175
- [nitpick] Consider using the nullish coalescing operator (??) instead of the logical OR (||) to ensure that empty strings are preserved as valid titles rather than being coerced to null.
title: link.title || null,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.