Release breakdown_comparisons_ui flag (#4774)

This commit is contained in:
Karl-Aksel Puulmann 2024-11-05 11:13:22 +02:00 committed by GitHub
parent dac9e3a0f0
commit af5eb720db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 27 deletions

View File

@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
## Unreleased
### Added
- Dashboard shows comparisons for all reports
### Removed
### Changed
### Fixed

View File

@ -27,7 +27,6 @@ export function parseSiteFromDataset(dataset: DOMStringMap): PlausibleSite {
type FeatureFlags = {
channels?: boolean
breakdown_comparisons_ui?: boolean
saved_segments?: boolean
}

View File

@ -166,7 +166,8 @@ export default function BreakdownModal<TListItem extends { name: string }>({
orderByDictionary,
toggleSortByMetric,
renderIcon,
getExternalLinkURL
getExternalLinkURL,
meta
]
)

View File

@ -1,14 +1,8 @@
/** @format */
import React from 'react'
import {
render as libraryRender,
screen,
fireEvent,
waitFor
} from '@testing-library/react'
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
import MetricValue from './metric-value'
import SiteContextProvider, { PlausibleSite } from '../../site-context'
jest.mock('@heroicons/react/24/solid', () => ({
ArrowUpRightIcon: () => <></>,
@ -254,13 +248,6 @@ function valueProps<T>(
} as any /* eslint-disable-line @typescript-eslint/no-explicit-any */
}
function render(ui: React.ReactNode) {
const site = {
flags: { breakdown_comparisons_ui: true }
} as unknown as PlausibleSite
libraryRender(<SiteContextProvider site={site}>{ui}</SiteContextProvider>)
}
async function renderWithTooltip(ui: React.ReactNode) {
render(ui)
await waitForTooltip()

View File

@ -11,7 +11,6 @@ import {
} from './metric-formatter'
import { BreakdownResultMeta, DashboardQuery } from '../../query'
import { useQueryContext } from '../../query-context'
import { PlausibleSite, useSiteContext } from '../../site-context'
type MetricValues = Record<Metric, ValueType>
@ -19,15 +18,11 @@ type ListItem = MetricValues & {
comparison: MetricValues & { change: Record<Metric, number> }
}
function valueRenderProps(
listItem: ListItem,
metric: Metric,
site: PlausibleSite
) {
function valueRenderProps(listItem: ListItem, metric: Metric) {
const value = listItem[metric]
let comparison = null
if (site.flags.breakdown_comparisons_ui && listItem.comparison) {
if (listItem.comparison) {
comparison = {
value: listItem.comparison[metric],
change: listItem.comparison.change[metric]
@ -45,12 +40,11 @@ export default function MetricValue(props: {
meta: BreakdownResultMeta
}) {
const { query } = useQueryContext()
const site = useSiteContext()
const { metric, listItem } = props
const { value, comparison } = useMemo(
() => valueRenderProps(listItem, metric, site),
[listItem, metric, site]
() => valueRenderProps(listItem, metric),
[listItem, metric]
)
const metricLabel = useMemo(() => props.renderLabel(query), [query, props])
const shortFormatter = props.formatter ?? MetricFormatterShort[metric]

View File

@ -366,7 +366,7 @@ defmodule PlausibleWeb.StatsController do
defp get_flags(user, site),
do:
[:channels, :breakdown_comparisons_ui, :saved_segments]
[:channels, :saved_segments]
|> Enum.map(fn flag ->
{flag, FunWithFlags.enabled?(flag, for: user) || FunWithFlags.enabled?(flag, for: site)}
end)