-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
9c8b594
to
2b848b8
Compare
@@ -43,5 +43,5 @@ export function getPreferences<T extends keyof PreferencesSettings>(userSettings | |||
|
|||
export function togglePreferences(key: keyof PreferencesSettings) { | |||
const flag = usePreferences(key) | |||
flag.value = !flag.value | |||
return flag.value = !flag.value |
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.
Added this explicit return so that I could use it in the toggleOptOut()
function later, will call it out
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.
Returning a variable assignment expression is a new one to me. Buut if it works, it works 👍
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.
I'm such a rubyist at heart. In Ruby, every method (function) returns the evaluated result of the last line that is executed. And it was my first modern language, so I often forget that javascript doesn't do what I think it should do sometimes, but really I'm just remembering back to my ruby days.
const env = useAppConfig().env | ||
const devMode = env === ('dev' || 'canary' || 'preview') | ||
const userSettings = useUserSettings() | ||
const allowGlean = getPreferences(userSettings.value, 'allowGlean') | ||
const uploadEnabled = devMode && allowGlean | ||
|
||
Glean.initialize(GLEAN_APP_ID, uploadEnabled, {}) | ||
Glean.initialize(GLEAN_APP_ID, uploadEnabled, { channel: env }) |
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.
- Updated
uploadEnabled
to check forallowGlean
user setting - Pass through
env
as thechannel
when initializing Glean - this is just a little bit more of identifying information (seeappChannel
in the glean initializing docs)
// reset identifiers if user opts back in | ||
if (user && allowGlean) { | ||
mastodonAccountHandle.set(user.account.acct) | ||
mastodonAccountId.set(user.account.id) | ||
userAgent.set(navigator.userAgent) | ||
} |
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.
Needed to add this because these identifiers were not getting reset when the user would opt out and then opt back in again.
const userSettings = useUserSettings() | ||
|
||
function toggleOptOut() { | ||
const allowGlean = togglePreferences('allowGlean') |
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.
This is where I'm using that explicit return from togglePreferences
. For some reason calling getPreferences
after doing the toggle wasn't returning the correct value and I didn't have the time or mental space to explore why
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.
Just wondering, did you try calling getPreferences
before doing the toggle?
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.
yes! and it frustratingly returns the same value both before the toggle and after the toggle.
import StringMetricType from "@mozilla/glean/private/metrics/string"; | ||
import EventMetricType from "@mozilla/glean/private/metrics/event"; |
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.
I swear these two generated files keep flipping back and forth even though they are supposed to be being ignored by eslint. A problem for another day...
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.
I checked out the branch and tried to break it but could not 😞 . Nice work!
const devMode = env === ('dev' || 'canary' || 'preview') | ||
const userSettings = useUserSettings() | ||
const allowGlean = getPreferences(userSettings.value, 'allowGlean') | ||
const uploadEnabled = devMode && allowGlean |
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.
Should this be an OR instead of AND?
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.
Right now, no - keeping the uploadEnabled
for dev only until we are ready to start collecting events in production
pages/settings/privacy/index.vue
Outdated
<MainContent back-on-small-screen no-beta-label> | ||
<template #title> | ||
<div text-lg font-bold flex items-center gap-2 @click="$scrollToTop"> | ||
<span>{{ $t('settings.interface.label') }}</span> |
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.
This translation string should settings.privacy.label
(Right now it renders as Interface
)
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.
Good catch! fixed
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.
I'm noticing a weird bug where you can't navigate to this page directly. I'm not sure if it should block this from releasing since it'll be hidden behind a flag, but it's strange.
To reproduce:
- Navigate to
/settings/privacy
- Refresh page
ProfitError
UPDATE
Determined the cause. Looks like there's a server error due to calling the window
object
ReferenceError: window is not defined
So we may want to use the onMounted
callback for this
@anthony-liddle re: the refresh bug - I've done some investigating and it's the |
Goal
Add a new privacy setting so that users can opt out of analytics tracking
MOSOWEB-42
To Do:
Settings -> Privacy
link & index page (show only indevMode
)allowGlean
toPreferencesSettings
(true
by default)allowGlean
user settingImplementation Decisions
I did not do the toggle switch that is designed in the ticket/figma. For the sake of time and consistency, I went with the existing checkbox pattern that
Settings -> Preferences
usesScreenshots/Gifs