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

Commit

Permalink
fix(glean): add additional engagement event details
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfluckey committed Oct 6, 2023
1 parent e6b7b7b commit 898dc74
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion components/settings/SettingsColorMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const modes = [
<button
v-for="{ icon, label, mode } in modes"
:key="mode"
:data-glean="`settings.interface.colorMode.${mode}`"
data-glean="settings.interface.colorMode"
:data-glean-value="`${mode}`"
btn-text flex-1 flex="~ gap-1 center" p4 border="~ base rounded" bg-base ws-nowrap
:tabindex="colorMode.preference === mode ? 0 : -1"
:class="colorMode.preference === mode ? 'pointer-events-none' : 'filter-saturate-0'"
Expand Down
3 changes: 2 additions & 1 deletion components/settings/SettingsFontSize.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function setFontSize(e: Event) {
:min="0"
:max="sizes.length - 1"
:step="1"
:data-glean="`settings.interface.fontSize.${sizes.indexOf(userSettings.fontSize)}`"
data-glean="settings.interface.fontSize"
:data-glean-value="`${sizes.indexOf(userSettings.fontSize)}`"
type="range"
focus:outline-none
appearance-none bg-transparent
Expand Down
3 changes: 2 additions & 1 deletion components/settings/SettingsThemeColors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function updateTheme(theme: ThemeColors) {
}"
:class="currentTheme === key ? 'ring-2' : 'scale-90'"
:title="key"
:data-glean="`settings.interface.themeColor.${key}`"
data-glean="settings.interface.themeColor"
:data-glean-value="`${key}`"
w-8 h-8 rounded-full transition-all
ring="$local-ring-color offset-3 offset-$c-bg-base"
@click="updateTheme(theme)"
Expand Down
18 changes: 17 additions & 1 deletion modules/glean/runtime/glean-plugin.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,27 @@ export default defineNuxtPlugin((nuxtApp) => {
const eventTarget = ev?.target as Element
const closestButton = eventTarget.closest('button')

interface EngagementDetails {
[propName: string]: {
engagement_type: string
ui_additional_detail: string
}
}

const engagementDetails: EngagementDetails = {
'settings.interface.colorMode': {
engagement_type: 'general',
ui_additional_detail: 'additional deets go here', // todo
},
}

if (closestButton?.hasAttribute('href'))
linkClick.record({ target_url: closestButton.getAttribute('href') || '' })

const data = eventTarget?.getAttribute('data-glean') || ''
const value = eventTarget?.getAttribute('data-glean-value') || ''
if (eventTarget.hasAttribute('data-glean'))
engagement.record({ ui_identifier: eventTarget?.getAttribute('data-glean') || '' })
engagement.record({ ui_identifier: data, engagement_value: value, ...engagementDetails[data] })
}

function handleLinkClick(ev: MouseEvent) {
Expand Down

0 comments on commit 898dc74

Please sign in to comment.