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

feat: firefox extension permission ui #3864

Merged
merged 25 commits into from
Nov 27, 2024
Merged

feat: firefox extension permission ui #3864

merged 25 commits into from
Nov 27, 2024

Conversation

sshanzel
Copy link
Member

@sshanzel sshanzel commented Nov 21, 2024

Changes

  • Check whether the extension is Firefox.
    • If so, we check cache whether the user has accepted the permission popup.
    • If not, show the prompt.

Events

Did you introduce any new tracking events?

Experiment

Did you introduce any new experiments?

Manual Testing

Caution

Please make sure existing components are not breaking/affected by this PR

MI-613

Preview domain

https://mi-631.preview.app.daily.dev

Copy link

vercel bot commented Nov 21, 2024

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

Name Status Preview Updated (UTC)
daily-webapp 🛑 Canceled (Inspect) Nov 27, 2024 2:24pm
1 Skipped Deployment
Name Status Preview Updated (UTC)
storybook ⬜️ Ignored (Inspect) Nov 27, 2024 2:24pm

Copy link
Contributor

@AmarTrebinjac AmarTrebinjac left a comment

Choose a reason for hiding this comment

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

Looking good! 👏🏼

Left a few comments for consideration 😊

export const checkIsFirefox = (): boolean =>
typeof globalThis?.navigator !== 'undefined' &&
/firefox/i.test(globalThis?.navigator.userAgent);

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we maybe add "firefox" to the UserAgent enum and use checkIsBrowser instead?

Copy link
Member Author

@sshanzel sshanzel Nov 22, 2024

Choose a reason for hiding this comment

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

Yeah, I thought of it at first but decided to use the one specifically for Firefox. Maybe yeah it is better to keep them on the same function by lowercasing the values from the userAgent.

You can{' '}
<button type="button" className="text-text-link" onClick={onGoBack}>
go back
</button>{' '}
Copy link
Contributor

@AmarTrebinjac AmarTrebinjac Nov 21, 2024

Choose a reason for hiding this comment

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

Are these intentional or just the linter? if you wrap "you can" and "and accept the required permissions." in spans, then just having a regular space between the elements will separate the words naturally. But it should also work to just have a regular space without any wrapping or {' '}

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, intentional by the linter :lolsob: , they get joined together without it. Not normally a fan adding a wrap without any additional attributes, but I'm open to it 👀

Copy link
Contributor

@rebelchris rebelchris left a comment

Choose a reason for hiding this comment

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

Don't we want to do all this in extension only maybe?
As they are the only ones complaining, not specific firefox

packages/extension/src/newtab/App.tsx Show resolved Hide resolved
@@ -106,6 +117,7 @@ function InternalApp(): ReactElement {
const isPageReady =
(growthbook?.ready && router?.isReady && isAuthReady) || isTesting;
const shouldRedirectOnboarding = !user && isPageReady && !isTesting;
const isFirefox = checkIsBrowser(UserAgent.Firefox);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you use the existing one?
isFirefoxExtension?

I think in this new flow we don't auto spool webapp right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise remember nensi also added some more extended browser detection one time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. Makes sense, we can actually use that to simplify.

<FirefoxPermissionItem
className="mt-2"
title="Ads pixel tracking"
description="Enable pixel tracking for fewer, non-intrusive ads, helping us in keeping the experience free and relevant."
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe raise with product if they don't want to add people can also buy plus and no ads are shown here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Let me check.

@@ -95,10 +95,11 @@ export const sortAlphabeticallyByProperty =
export enum UserAgent {
Chrome = 'Chrome',
Edge = 'Edg', // intended to be Edg, not Edge
Firefox = 'Firefox', // intended to be Edg, not Edge
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment shouldn't be here.

/>
<div className="flex w-full max-w-[35rem] flex-col items-center gap-4">
<span className="h-36 max-w-[16.25rem]">
<img src={cloudinaryGenericErrorDark} alt="You declined (FML)" />
Copy link
Member

Choose a reason for hiding this comment

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

(FML) 😂

>
You can{' '}
<button type="button" className="text-text-link" onClick={onGoBack}>
go back
Copy link
Member

Choose a reason for hiding this comment

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

Since the user has already declined, maybe we should also show a link to the webapp as an alternative?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I can also raise it to the product team 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

Added! 🚀

Comment on lines 84 to 86
if (isFirefox && permission !== FirefoxPermissionType.Accepted) {
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@idoshamun we are now stopping the send of analytics until it is accepted, only of course for Firefox.

Copy link
Member

Choose a reason for hiding this comment

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

we just need to make sure this doesn't apply to the firefox browser. just the extension

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The isFirefox variable checks the process.env.TARGET_BROWSER which is only applied to extension builds.

Copy link
Member

Choose a reason for hiding this comment

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

Perfect!

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's change the naming in that case, you can already see it's confusing :)

Copy link
Contributor

@AmarTrebinjac AmarTrebinjac left a comment

Choose a reason for hiding this comment

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

Looks good to me, just one comment on the copytext, but non-blocking!

🚀

color={TypographyColor.Tertiary}
>
Ready to go? 🟢 Give us the green signal by accepting the below
permissions. Enhance your daily.dev experience with personalized
Copy link
Contributor

Choose a reason for hiding this comment

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

"by accepting the permissions below" is more natural sounding.

Copy link
Contributor

@rebelchris rebelchris left a comment

Choose a reason for hiding this comment

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

Just naming improvements, otherwise good so approving already

@@ -106,6 +89,7 @@ function InternalApp(): ReactElement {
const isPageReady =
(growthbook?.ready && router?.isReady && isAuthReady) || isTesting;
const shouldRedirectOnboarding = !user && isPageReady && !isTesting;
const isFirefox = process.env.TARGET_BROWSER === 'firefox';
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably globally export isFirefoxExtension and maybe make it more explicit.
We only target firefox extension, reading this might make you think otherwise.

@@ -31,6 +36,10 @@ export default function useLogQueue({
queueRef: MutableRefObject<LogEvent[]>;
sendBeacon: () => void;
} {
const isFirefox = process.env.TARGET_BROWSER === 'firefox';
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, make it isFirefoxExtension and global imported?

Comment on lines 84 to 86
if (isFirefox && permission !== FirefoxPermissionType.Accepted) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's change the naming in that case, you can already see it's confusing :)

@sshanzel sshanzel merged commit 1693d38 into main Nov 27, 2024
10 checks passed
@sshanzel sshanzel deleted the MI-631 branch November 27, 2024 14:38
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.

5 participants