Skip to content

Commit

Permalink
Remove duplicated plausible props (#2578)
Browse files Browse the repository at this point in the history
  • Loading branch information
zackkrida authored Jul 11, 2023
1 parent a11969e commit 53c2e70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
20 changes: 2 additions & 18 deletions frontend/src/composables/use-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useContext } from "@nuxtjs/composition-api"
import type { Events, EventName } from "~/types/analytics"
import { useUiStore } from "~/stores/ui"
import { useFeatureFlagStore } from "~/stores/feature-flag"
import { useI18n } from "~/composables/use-i18n"

import { log } from "~/utils/console"

Expand All @@ -13,8 +12,7 @@ import { log } from "~/utils/console"
* bounds of the composition API.
*/
export const useAnalytics = () => {
const { $plausible, $ua } = useContext()
const i18n = useI18n()
const { $plausible } = useContext()
const uiStore = useUiStore()
const featureFlagStore = useFeatureFlagStore()

Expand All @@ -27,18 +25,7 @@ export const useAnalytics = () => {
* client-side; This excludes props that need `window`.
*/
const isomorphicProps = computed(() => ({
timestamp: new Date().toISOString(),
language: i18n.locale,
breakpoint: uiStore.breakpoint,
...($ua
? {
ua: $ua.source,
os: $ua.os,
platform: $ua.platform,
browser: $ua.browser,
version: $ua.version,
}
: {}),
}))

/**
Expand All @@ -48,9 +35,6 @@ export const useAnalytics = () => {
const windowProps = computed(() =>
window
? {
origin: window.location.origin,
pathname: window.location.pathname,
referrer: window.document.referrer,
width: window.innerWidth,
height: window.innerHeight,
}
Expand All @@ -73,7 +57,7 @@ export const useAnalytics = () => {
props: {
...isomorphicProps.value,
...windowProps.value,
...payload, // can override mandatory props
...payload,
},
})
}
Expand Down
16 changes: 1 addition & 15 deletions packages/eslint-plugin/src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,7 @@ export const recommended = {
"@openverse/analytics-configuration": [
"error",
{
reservedPropNames: [
"timestamp",
"language",
"breakpoint",
"ua",
"os",
"platform",
"browser",
"version",
"origin",
"pathname",
"referrer",
"width",
"height",
],
reservedPropNames: ["width", "height"],
},
],
},
Expand Down

0 comments on commit 53c2e70

Please sign in to comment.