-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: Preserve search parameters in external links #258
Conversation
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Branch preview✅ Deployed to dev: |
I would extend this behaviour to the other links in the homepage if you could navigate to a campaign page from https://safe.global , otherwise I don't see a justification to attach campaign related UTM codes when navigating to https://app.safe.global/ |
|
Why?
The search params are not lost on page refresh. This approach is however necessary if we want to hydrate the links on all pages with the UTM params, right? |
Because the user can:
We lose the UTM params on steps 2 and 2a in your current implementation. Refreshing the page is less likely but navigating within the website is very likely. |
To clarify on the campaigns navigation:
Am I missing / overlooking something? |
Once again: the user can navigate to another internal page from the campaign page (e.g. via the links in the footer), at which point UTM params are lost. |
I'll outline again my proposed solution which I shared before you started working on this PR:
If you still disagree, please clarify the requiements with BI and marketing. |
dff062d
to
62db557
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing the context, the append function and calling said function for every link in every component with external links isn’t very maintainable don’t you think? Please propose an alternative solution to discuss.
The context needs tests.
I think having a HOC to call the context and append the search params is more maintainable, avoiding all the duplicated code. |
I don't see the need for a HoC. Just create a custom link component, e.g. |
const finalHref = appendSearchParamsToURL(href, searchParams) | ||
|
||
return ( | ||
<Link href={finalHref} target="_blank" rel="noreferrer"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove rel="noreferrer"
for app.safe.global links.
const SafeLink = ({ href, children }: { href: string; children: ReactNode }) => { | ||
const searchParams = useContext(SearchParamsContext) | ||
|
||
const finalHref = appendSearchParamsToURL(href, searchParams) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useMemo
perhaps?
Looks good to me. @usame-algan could you also take a look when you have a minute? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
I assume we use SafeLink
for all links to app.safe.global
but haven't checked each occurence.
Although for the Launch Wallet
button in the header it doesn't seem to be used. Is that intended?
I've included it inside of the ContextProvider. Good catch @usame-algan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Diogo.
In future reviews we should keep in mind that we should always use SafeLink instead of Link for all links except when 100% internal.
Definitely! |
What it solves
We want to preserve the search parameters when navigating the homepage.
How this PR fixes it
On page navigation the search parameters are merged and stored in the session storage key
SAFE__searchParams
and saved to a Context.All links navigating to https://app.safe.global include the stored search parameters.