Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

feat(glean): enable glean in prod - SOCWEB-145 #92

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions modules/glean/runtime/glean-plugin.client.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import Glean from '@mozilla/glean/web'
import * as log from 'tauri-plugin-log-api'

import { linkClick, pageUrl, pageView, referrerUrl } from '../../../telemetry/generated/web'
import { userAgent } from '../../../telemetry/generated/identifiers'
import { engagement } from '../../../telemetry/generated/ui'
import { engagementDetails } from '../../../telemetry/engagementDetails'
import { userAgent } from '~~/telemetry/generated/identifiers'
Copy link
Collaborator

Choose a reason for hiding this comment

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

the ~~ syntax is new and exciting to me! Are you able to share documentation on how this works? Does it work in all environments? Unix/Windows etc?

If this is a home path, can we be sure it leads to the same place, vs traversing relatively?

Copy link
Author

Choose a reason for hiding this comment

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

This was a fun one to track down! It's built into Nuxt actually: https://nuxt.com/docs/api/nuxt-config#alias. It looks like the ~~ will always lead to /<rootDir>

import { engagement } from '~~/telemetry/generated/ui'
import { linkClick, pageUrl, pageView, referrerUrl } from '~~/telemetry/generated/web'
import { engagementDetails } from '~~/telemetry/engagementDetails'

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('app:mounted', () => {
log.info('Glean: App mounted, start initing glean')

const GLEAN_APP_ID = 'moso-mastodon-web'
const env = useAppConfig().env
const devMode = env === ('dev' || 'canary' || 'preview')
const env = useBuildInfo().env
const devMode = env === 'dev'
const userSettings = useUserSettings()
const allowGlean = getPreferences(userSettings.value, 'allowGlean')
const uploadEnabled = devMode && allowGlean
const userAllowGlean = getPreferences(userSettings.value, 'allowGlean')
const uploadEnabled = userAllowGlean
Comment on lines +14 to +18
Copy link
Author

Choose a reason for hiding this comment

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

I have removed the environment check from uploadEnabled because I'm not confident that stage and production will get represented correctly from either useBuildInfo or useAppConfig. In order to test this and help us understand it better, I'm passing the channel: env when initializing Glean - this will allow us to find out what that env gets set as in the other environments.


Glean.initialize(GLEAN_APP_ID, uploadEnabled, { channel: env })
userAgent.set(navigator.userAgent)
Expand Down
2 changes: 0 additions & 2 deletions pages/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ useHydratedHead({
const route = useRoute()

const isRootPath = computedEager(() => route.name === 'settings')
const devMode = useAppConfig().env === ('dev' || 'canary' || 'preview')
Copy link
Author

Choose a reason for hiding this comment

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

Removing the env check here so the link to the Privacy page will now always show up regardless of environment

Screenshot 2023-11-29 at 2 39 50 PM

</script>

<template>
Expand Down Expand Up @@ -65,7 +64,6 @@ const devMode = useAppConfig().env === ('dev' || 'canary' || 'preview')
:match="$route.path.startsWith('/settings/preferences/')"
/>
<SettingsItem
v-if="devMode"
command
icon="i-ri-lock-line"
:text="isHydrated ? $t('settings.privacy.label') : ''"
Expand Down
Loading