-
-
Notifications
You must be signed in to change notification settings - Fork 134
feat(console): surface how many devices have a bundle #3032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bcae176
feat(console): surface how many devices have a bundle
riderx d089e15
fix(backend): type device adoption reduce as number
riderx b37efc1
docs: add bundle reach preview for PR 3032
riderx 6ac1019
fix(console): use native progress for bundle reach
riderx d09d918
fix(console): keep bundle reach numbers honest
riderx c501f7a
test: cover bundle reach links and fractional percents
riderx b3de5b3
fix(console): keep bundle reach on Observe only
riderx 3d44828
docs: refresh Observe reach screenshot
riderx fcdd7eb
fix(console): shrink Observe reach to a metric tile
riderx 652d018
fix(console): keep Observe metrics on one row
riderx 59cba7c
fix(console): keep Observe reach name from visible text
riderx ab92495
fix(i18n): drop unused view-bundle-devices context
riderx e598c0d
fix(console): open channel stats from Observe reach
riderx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { expect, test } from '../support/commands' | ||
|
|
||
| test.describe('Bundle reach', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.login('test@capgo.app', 'testtest') | ||
| }) | ||
|
|
||
| test('shows reach on observe updater', async ({ page }) => { | ||
| await page.goto('/app/com.demo.app/observe/updater') | ||
| const reachCard = page.locator('[data-test="bundle-adoption-card"]').first() | ||
| await expect(reachCard).toBeVisible() | ||
| await expect(reachCard).toContainText('Bundle reach') | ||
|
|
||
| await reachCard.click() | ||
| await expect(page).toHaveURL(/\/app\/com\.demo\.app\/channel\/\d+\/statistics/) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| <script setup lang="ts"> | ||
| import { computed, ref, watch } from 'vue' | ||
| import { useI18n } from 'vue-i18n' | ||
| import { useRouter } from 'vue-router' | ||
| import IconPackage from '~icons/lucide/package' | ||
| import { getLatestDayVersionAdoption } from '~/services/bundleAdoption' | ||
| import { useChartData } from '~/services/chartDataService' | ||
| import { getChartDateRange } from '~/services/date' | ||
| import { formatNumberValue } from '~/services/formatLocale' | ||
| import { useSupabase } from '~/services/supabase' | ||
|
|
||
| const props = defineProps<{ | ||
| appId: string | ||
| versionName: string | ||
| linkedChannelId?: number | null | ||
| }>() | ||
|
|
||
| const { t } = useI18n() | ||
| const router = useRouter() | ||
| const supabase = useSupabase() | ||
|
|
||
| const loading = ref(true) | ||
| const loadError = ref(false) | ||
| const adoption = ref<ReturnType<typeof getLatestDayVersionAdoption>>(null) | ||
| let requestToken = 0 | ||
|
|
||
| const percentLabel = computed(() => { | ||
| const percent = adoption.value?.percent ?? 0 | ||
| return `${formatNumberValue(percent, { minimumFractionDigits: 1, maximumFractionDigits: 1 })}%` | ||
| }) | ||
|
|
||
| const countLabel = computed(() => formatNumberValue(adoption.value?.count ?? 0)) | ||
| const totalLabel = computed(() => formatNumberValue(adoption.value?.total ?? 0)) | ||
| const hasDevices = computed(() => (adoption.value?.total ?? 0) > 0) | ||
|
|
||
| const valueLabel = computed(() => { | ||
| if (loading.value || loadError.value || !hasDevices.value) | ||
| return '—' | ||
| return percentLabel.value | ||
| }) | ||
|
|
||
| const detailLabel = computed(() => { | ||
| if (loading.value) | ||
| return t('loading-statistics') | ||
| if (loadError.value) | ||
| return t('bundle-adoption-error', { version: props.versionName }) | ||
| if (!hasDevices.value) | ||
| return t('bundle-adoption-empty', { version: props.versionName }) | ||
| return `${t('bundle-adoption-devices', { count: countLabel.value, total: totalLabel.value })} · ${props.versionName}` | ||
| }) | ||
|
|
||
| async function loadAdoption() { | ||
| if (!props.appId || !props.versionName) { | ||
| adoption.value = null | ||
| loadError.value = false | ||
| loading.value = false | ||
| return | ||
| } | ||
|
|
||
| const currentToken = ++requestToken | ||
| loading.value = true | ||
| loadError.value = false | ||
| try { | ||
| const { startDate, endDate } = getChartDateRange(false) | ||
| const data = await useChartData(supabase, props.appId, startDate, endDate, 'bundle') | ||
| if (currentToken !== requestToken) | ||
| return | ||
| if (!data) { | ||
| loadError.value = true | ||
| adoption.value = null | ||
| return | ||
| } | ||
| adoption.value = getLatestDayVersionAdoption(data.datasets ?? [], props.versionName) | ||
| } | ||
| catch (error) { | ||
| console.error('[BundleAdoptionCard] Failed to load adoption', error) | ||
| if (currentToken !== requestToken) | ||
| return | ||
| loadError.value = true | ||
| adoption.value = null | ||
| } | ||
| finally { | ||
| if (currentToken === requestToken) | ||
| loading.value = false | ||
| } | ||
| } | ||
|
|
||
| function openAnalytics() { | ||
| if (props.linkedChannelId) { | ||
| router.push(`/app/${props.appId}/channel/${props.linkedChannelId}/statistics`) | ||
| return | ||
| } | ||
| router.push({ | ||
| path: `/app/${props.appId}/devices`, | ||
| query: { version: props.versionName }, | ||
| }) | ||
| } | ||
|
|
||
| watch(() => [props.appId, props.versionName] as const, () => { | ||
| void loadAdoption() | ||
| }, { immediate: true }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <button | ||
| type="button" | ||
| data-test="bundle-adoption-card" | ||
| class="p-4 text-left bg-white border rounded-lg shadow-sm cursor-pointer dark:bg-slate-800 border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-700/40" | ||
| @click="openAnalytics" | ||
| > | ||
| <div class="flex items-center gap-2 text-sm text-slate-600 dark:text-slate-400"> | ||
| <IconPackage class="w-4 h-4" /> | ||
| {{ t('bundle-adoption') }} | ||
| </div> | ||
| <div class="mt-2 text-lg font-semibold tabular-nums text-slate-900 dark:text-white"> | ||
| {{ valueLabel }} | ||
| </div> | ||
| <div class="mt-1 text-xs truncate text-slate-500 dark:text-slate-400"> | ||
| {{ detailLabel }} | ||
| </div> | ||
| </button> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.