Skip to content

Comments

Display custom link preview titles in the analytics#2216

Merged
steven-tey merged 5 commits intomainfrom
custom-link-preview
Mar 28, 2025
Merged

Display custom link preview titles in the analytics#2216
steven-tey merged 5 commits intomainfrom
custom-link-preview

Conversation

@devkiran
Copy link
Collaborator

No description provided.

@vercel
Copy link
Contributor

vercel bot commented Mar 27, 2025

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

Name Status Preview Updated (UTC)
dub ✅ Ready (Inspect) Visit Preview Mar 28, 2025 3:57pm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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,

@steven-tey steven-tey merged commit 890938f into main Mar 28, 2025
6 checks passed
@steven-tey steven-tey deleted the custom-link-preview branch March 28, 2025 16:08
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