create-expo-updates-server 0.3.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/README.md +4 -2
  2. package/dist/template/Dockerfile +4 -6
  3. package/dist/template/README.md +5 -10
  4. package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
  5. package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
  6. package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
  7. package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
  8. package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
  9. package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
  10. package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
  11. package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
  12. package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
  13. package/dist/template/app/api/admin/updates/route.test.ts +21 -0
  14. package/dist/template/app/api/admin/updates/route.ts +12 -1
  15. package/dist/template/app/globals.css +65 -68
  16. package/dist/template/app/login/page.tsx +66 -42
  17. package/dist/template/app/updates/[encodedKey]/page.tsx +382 -248
  18. package/dist/template/app/updates/devices/page.tsx +187 -145
  19. package/dist/template/app/updates/embedded/page.tsx +80 -34
  20. package/dist/template/app/updates/emergency-redirects/page.tsx +138 -71
  21. package/dist/template/app/updates/layout.tsx +2 -1
  22. package/dist/template/app/updates/page.tsx +385 -274
  23. package/dist/template/app/updates/releases.test.tsx +156 -0
  24. package/dist/template/components/admin/admin-role.ts +5 -0
  25. package/dist/template/components/admin/admin-shell.tsx +166 -95
  26. package/dist/template/components/admin/confirm-action.tsx +123 -0
  27. package/dist/template/components/admin/language-switcher.tsx +27 -16
  28. package/dist/template/components/admin/release-badges.test.tsx +50 -0
  29. package/dist/template/components/admin/release-badges.tsx +101 -0
  30. package/dist/template/components/ui/alert.tsx +10 -3
  31. package/dist/template/components/ui/avatar.tsx +108 -0
  32. package/dist/template/components/ui/badge.tsx +2 -2
  33. package/dist/template/components/ui/breadcrumb.tsx +108 -0
  34. package/dist/template/components/ui/button.tsx +5 -5
  35. package/dist/template/components/ui/card.tsx +2 -2
  36. package/dist/template/components/ui/chart.tsx +1 -1
  37. package/dist/template/components/ui/collapsible.tsx +7 -0
  38. package/dist/template/components/ui/dialog.tsx +13 -4
  39. package/dist/template/components/ui/empty.tsx +103 -0
  40. package/dist/template/components/ui/field.tsx +248 -0
  41. package/dist/template/components/ui/input-group.tsx +170 -0
  42. package/dist/template/components/ui/input.tsx +1 -1
  43. package/dist/template/components/ui/native-select.tsx +1 -1
  44. package/dist/template/components/ui/radio-group.tsx +41 -0
  45. package/dist/template/components/ui/sheet.tsx +6 -2
  46. package/dist/template/components/ui/sidebar.tsx +62 -17
  47. package/dist/template/components/ui/status-tones.ts +15 -0
  48. package/dist/template/components/ui/table.tsx +1 -1
  49. package/dist/template/components/ui/textarea.tsx +1 -1
  50. package/dist/template/docs/admin-ui.md +22 -24
  51. package/dist/template/docs/device-targeting.md +6 -12
  52. package/dist/template/docs/doctor.md +2 -2
  53. package/dist/template/docs/expo-app-setup.md +9 -27
  54. package/dist/template/docs/getting-started.md +3 -4
  55. package/dist/template/docs/getting-started.ru.md +11 -544
  56. package/dist/template/docs/index.md +1 -1
  57. package/dist/template/docs/installation-telemetry.md +6 -12
  58. package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
  59. package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
  60. package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
  61. package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
  62. package/dist/template/docs/migrations/schema.sql +349 -0
  63. package/dist/template/docs/npm-installer.md +3 -3
  64. package/dist/template/docs/operations-guide.md +9 -7
  65. package/dist/template/docs/ota-client-lifecycle.md +30 -68
  66. package/dist/template/docs/ota-emergency-recovery.md +34 -57
  67. package/dist/template/docs/ota-update-policy.md +9 -20
  68. package/dist/template/docs/ru/admin-ui.md +33 -0
  69. package/dist/template/docs/ru/device-targeting.md +59 -0
  70. package/dist/template/docs/ru/doctor.md +98 -0
  71. package/dist/template/docs/ru/expo-app-setup.md +497 -0
  72. package/dist/template/docs/ru/getting-started.md +391 -0
  73. package/dist/template/docs/ru/index.md +50 -0
  74. package/dist/template/docs/ru/installation-telemetry.md +125 -0
  75. package/dist/template/docs/ru/npm-installer.md +71 -0
  76. package/dist/template/docs/ru/operations-guide.md +322 -0
  77. package/dist/template/docs/ru/ota-client-lifecycle.md +162 -0
  78. package/dist/template/docs/ru/ota-emergency-recovery.md +108 -0
  79. package/dist/template/docs/ru/ota-update-policy.md +69 -0
  80. package/dist/template/docs/ru/publishing-npm-installer.md +49 -0
  81. package/dist/template/docs/ru/supabase-setup.md +120 -0
  82. package/dist/template/docs/uk/admin-ui.md +33 -0
  83. package/dist/template/docs/uk/device-targeting.md +59 -0
  84. package/dist/template/docs/uk/doctor.md +98 -0
  85. package/dist/template/docs/uk/expo-app-setup.md +497 -0
  86. package/dist/template/docs/uk/getting-started.md +391 -0
  87. package/dist/template/docs/uk/index.md +50 -0
  88. package/dist/template/docs/uk/installation-telemetry.md +125 -0
  89. package/dist/template/docs/uk/npm-installer.md +71 -0
  90. package/dist/template/docs/uk/operations-guide.md +322 -0
  91. package/dist/template/docs/uk/ota-client-lifecycle.md +162 -0
  92. package/dist/template/docs/uk/ota-emergency-recovery.md +108 -0
  93. package/dist/template/docs/uk/ota-update-policy.md +69 -0
  94. package/dist/template/docs/uk/publishing-npm-installer.md +49 -0
  95. package/dist/template/docs/uk/supabase-setup.md +120 -0
  96. package/dist/template/lib/audience-ids.ts +4 -0
  97. package/dist/template/package-lock.json +46 -0
  98. package/dist/template/package.json +4 -1
  99. package/dist/template/scripts/configure-expo-app.mjs +3 -3
  100. package/dist/template/scripts/create-access-token.mjs +1 -1
  101. package/dist/template/scripts/lib/doctor.mjs +10 -7
  102. package/dist/template/scripts/lib/doctor.test.mjs +7 -5
  103. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
  104. package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
  105. package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
  106. package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
  107. package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
  108. package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
  109. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
  110. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
  111. package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
  112. package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
  113. package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
  114. package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
  115. package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
  116. package/dist/template/scripts/tests/e2e/console.mjs +86 -0
  117. package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
  118. package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
  119. package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
  120. package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
  121. package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
  122. package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
  123. package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
  124. package/dist/template/scripts/tests/e2e/run.mjs +224 -0
  125. package/dist/template/scripts/tests/manifest-identity.sql +7 -5
  126. package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
  127. package/dist/template/src/client/admin-api.ts +45 -10
  128. package/dist/template/src/client/admin-types.ts +35 -1
  129. package/dist/template/src/client/devices/analytics.tsx +169 -219
  130. package/dist/template/src/client/devices/cohorts.tsx +181 -0
  131. package/dist/template/src/client/devices/device-name.tsx +37 -21
  132. package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
  133. package/dist/template/src/client/devices/registry.tsx +265 -233
  134. package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
  135. package/dist/template/src/client/devices/use-devices-report.ts +53 -82
  136. package/dist/template/src/client/devices/version-adoption-chart.tsx +48 -38
  137. package/dist/template/src/client/distribution-control.tsx +98 -53
  138. package/dist/template/src/client/distribution-history.tsx +353 -0
  139. package/dist/template/src/client/guard-action-catalog.tsx +183 -0
  140. package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
  141. package/dist/template/src/client/guard-action-combobox.tsx +134 -234
  142. package/dist/template/src/client/guard-action-options.ts +4 -6
  143. package/dist/template/src/client/i18n/en.json +335 -2
  144. package/dist/template/src/client/i18n/language-switching.test.tsx +233 -0
  145. package/dist/template/src/client/i18n/messages.test.ts +102 -19
  146. package/dist/template/src/client/i18n/messages.ts +31 -16
  147. package/dist/template/src/client/i18n/provider.tsx +6 -3
  148. package/dist/template/src/client/i18n/ru.json +619 -0
  149. package/dist/template/src/client/i18n/uk.json +619 -0
  150. package/dist/template/src/client/i18n/use-formatters.ts +5 -0
  151. package/dist/template/src/client/logout-button.tsx +3 -3
  152. package/dist/template/src/client/policy-draft.ts +138 -0
  153. package/dist/template/src/client/update-audience-editor.tsx +597 -199
  154. package/dist/template/src/client/update-policy-editor.test.ts +101 -29
  155. package/dist/template/src/client/update-policy-editor.tsx +466 -307
  156. package/dist/template/src/client/use-filtered-results.ts +55 -0
  157. package/dist/template/src/server/controllers/manifest.test.ts +23 -3
  158. package/dist/template/src/server/controllers/manifest.ts +15 -1
  159. package/dist/template/src/server/devices/audience.ts +9 -5
  160. package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
  161. package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
  162. package/dist/template/src/server/lib/admin-updates.ts +160 -534
  163. package/dist/template/src/server/lib/distribution-history.ts +97 -0
  164. package/dist/template/src/server/lib/supabase.js +24 -0
  165. package/dist/template/src/server/lib/supabase.test.ts +38 -1
  166. package/dist/template/src/server/lib/update-policy.test.ts +20 -0
  167. package/dist/template/src/server/lib/update-policy.ts +23 -10
  168. package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
  169. package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
  170. package/dist/template/src/server/manifest/manifest-values.ts +21 -13
  171. package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
  172. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
  173. package/dist/template/tsconfig.json +2 -2
  174. package/dist/template-manifest.json +571 -271
  175. package/package.json +1 -1
  176. package/dist/template/scripts/lib/device-identity.test.ts +0 -29
  177. package/dist/template/scripts/lib/ota-client.test.ts +0 -55
  178. package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
  179. package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
  180. package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
  181. package/dist/template/templates/expo-app/ota-client/README.md +0 -73
  182. package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
  183. package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
  184. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
  185. package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
  186. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
  187. package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
  188. package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
  189. package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
  190. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
  191. package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
@@ -2,7 +2,27 @@
2
2
  import { useFormatters } from "@/src/client/i18n/use-formatters";
3
3
  import { useI18n } from "@/src/client/i18n/provider";
4
4
 
5
- import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts";
5
+ import {
6
+ Collapsible,
7
+ CollapsibleTrigger,
8
+ CollapsibleContent,
9
+ } from "@/components/ui/collapsible";
10
+ import { Button } from "@/components/ui/button";
11
+ import {
12
+ ChevronDown,
13
+ Activity,
14
+ CircleArrowDown,
15
+ Layers3,
16
+ Smartphone,
17
+ } from "lucide-react";
18
+ import {
19
+ Area,
20
+ AreaChart,
21
+ CartesianGrid,
22
+ ReferenceLine,
23
+ XAxis,
24
+ YAxis,
25
+ } from "recharts";
6
26
  import {
7
27
  ChartContainer,
8
28
  ChartTooltip,
@@ -15,7 +35,6 @@ import {
15
35
  CardHeader,
16
36
  CardTitle,
17
37
  } from "@/components/ui/card";
18
- import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
19
38
  import {
20
39
  Table,
21
40
  TableBody,
@@ -24,26 +43,24 @@ import {
24
43
  TableHeader,
25
44
  TableRow,
26
45
  } from "@/components/ui/table";
27
- import { VersionAdoptionChart } from "./version-adoption-chart";
46
+
28
47
  import type { DevicesReport } from "@/src/server/devices/report-types";
29
- export const percent = (n: number, total: number) =>
30
- total ? `${Math.round((n / total) * 100)}%` : "—";
31
48
  export function useKindNames() {
32
49
  const { t } = useI18n();
33
50
  return {
34
51
  ota: "OTA",
35
- embedded: "Embedded",
52
+ embedded: t("Embedded"),
36
53
  unknown: t("Не определён"),
37
54
  };
38
55
  }
39
- export function Analytics({ report }: { report: DevicesReport }) {
40
- const { number, date } = useFormatters();
56
+ export function Overview({ report }: { report: DevicesReport }) {
57
+ const { number, date, share } = useFormatters();
41
58
  const { t } = useI18n();
42
59
  const { summary: s } = report;
43
60
  const kinds = [
44
61
  { label: "OTA", value: s.otaInstallations, color: "var(--chart-1)" },
45
62
  {
46
- label: "Embedded",
63
+ label: t("Embedded"),
47
64
  value: s.embeddedInstallations,
48
65
  color: "var(--chart-2)",
49
66
  },
@@ -55,9 +72,10 @@ export function Analytics({ report }: { report: DevicesReport }) {
55
72
  ];
56
73
  return (
57
74
  <>
58
- <div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
75
+ <div className="grid grid-cols-2 gap-px overflow-hidden rounded-xl border bg-border xl:grid-cols-4">
59
76
  {[
60
77
  {
78
+ icon: Smartphone,
61
79
  label: t("Активные установки"),
62
80
  value: number(s.activeInstallations),
63
81
  detail: t("Heartbeat за последние {0}", [
@@ -67,46 +85,52 @@ export function Analytics({ report }: { report: DevicesReport }) {
67
85
  ]),
68
86
  },
69
87
  {
88
+ icon: CircleArrowDown,
70
89
  label: t("Используют OTA"),
71
- value: percent(s.otaInstallations, s.activeInstallations),
90
+ value: share(s.otaInstallations, s.activeInstallations),
72
91
  detail: t("{0} из {1} установок", [
73
92
  number(s.otaInstallations),
74
93
  number(s.activeInstallations),
75
94
  ]),
76
95
  },
77
96
  {
78
- label: t("Встроенная версия"),
79
- value: number(s.embeddedInstallations),
80
- detail: t("Сочетаний версий в выборке: {0}", [
81
- number(s.reportedVersions),
82
- ]),
97
+ icon: Activity,
98
+ label: t("New installations"),
99
+ value: number(s.newInstallations),
100
+ detail: t("First seen during this period"),
83
101
  },
84
102
  {
85
- label: t("Аварийный запуск"),
86
- value: number(s.emergencyInstallations),
87
- detail: t("Не определён тип запуска: {0}", [
88
- number(s.unknownInstallations),
89
- ]),
103
+ icon: Layers3,
104
+ label: t("Reported versions"),
105
+ value: number(s.reportedVersions),
106
+ detail: t("Distinct version combinations"),
90
107
  },
91
108
  ].map((kpi) => (
92
- <Card key={kpi.label} className="gap-3 py-5 shadow-none">
93
- <CardHeader className="px-5">
94
- <CardDescription>{kpi.label}</CardDescription>
109
+ <Card key={kpi.label} className="min-w-0 gap-2 rounded-none border-0 py-4 sm:py-5">
110
+ <CardHeader className="gap-3 px-4">
111
+ <CardDescription className="flex items-center justify-between gap-1 text-xs font-medium">
112
+ {kpi.label}
113
+ <kpi.icon
114
+ className="size-4 shrink-0 text-muted-foreground"
115
+ aria-hidden="true"
116
+ />
117
+ </CardDescription>
95
118
  <CardTitle className="text-3xl font-semibold tracking-tight tabular-nums">
96
119
  {kpi.value}
97
120
  </CardTitle>
98
121
  </CardHeader>
99
- <CardContent className="px-5 text-xs text-muted-foreground">
122
+ <CardContent className="px-4 text-xs text-muted-foreground">
100
123
  {kpi.detail}
101
124
  </CardContent>
102
125
  </Card>
103
126
  ))}
104
127
  </div>
105
- <VersionAdoptionChart report={report} />
106
- <div className="grid min-w-0 gap-4 xl:grid-cols-[1.25fr_1fr]">
128
+ <div className="grid min-w-0 gap-4">
107
129
  <Card className="min-w-0 shadow-none">
108
130
  <CardHeader>
109
- <CardTitle>{t("Активность установок")}</CardTitle>
131
+ <CardTitle>
132
+ <h2>{t("Активность установок")}</h2>
133
+ </CardTitle>
110
134
  <CardDescription>
111
135
  {t("Уникальные установки с heartbeat за день · UTC")}
112
136
  </CardDescription>
@@ -123,15 +147,15 @@ export function Analytics({ report }: { report: DevicesReport }) {
123
147
  color: "var(--chart-2)",
124
148
  },
125
149
  }}
126
- className="h-52 w-full"
150
+ className="aspect-auto h-52 w-full sm:h-64 lg:h-72"
127
151
  aria-label={t("График ежедневных активных и новых установок")}
128
152
  >
129
153
  <AreaChart
130
154
  accessibilityLayer
131
155
  data={report.activity}
132
- margin={{ top: 12, right: 12, left: -24, bottom: 0 }}
156
+ margin={{ top: 12, right: 16, left: 0, bottom: 0 }}
133
157
  >
134
- <CartesianGrid vertical={false} />
158
+ <CartesianGrid vertical={false} stroke="var(--border)" />
135
159
  <XAxis
136
160
  dataKey="date"
137
161
  tickFormatter={date}
@@ -141,15 +165,33 @@ export function Analytics({ report }: { report: DevicesReport }) {
141
165
  minTickGap={24}
142
166
  />
143
167
  <YAxis
168
+ width="auto"
144
169
  allowDecimals={false}
145
170
  axisLine={false}
146
171
  tickLine={false}
147
172
  tick={{ fill: "var(--muted-foreground)" }}
148
173
  />
174
+ {report.activity
175
+ .filter((day) => day.coverage === "partial")
176
+ .map((day) => (
177
+ <ReferenceLine
178
+ key={day.date}
179
+ x={day.date}
180
+ stroke="var(--muted-foreground)"
181
+ strokeDasharray="3 4"
182
+ />
183
+ ))}
149
184
  <ChartTooltip
150
185
  content={
151
186
  <ChartTooltipContent
152
- labelFormatter={(value) => date(String(value))}
187
+ labelFormatter={(value) => {
188
+ const day = report.activity.find(
189
+ (entry) => entry.date === value,
190
+ );
191
+ return day?.coverage === "partial"
192
+ ? `${date(day.date)} · ${t("Неполный день")}`
193
+ : date(String(value));
194
+ }}
153
195
  />
154
196
  }
155
197
  />
@@ -160,7 +202,7 @@ export function Analytics({ report }: { report: DevicesReport }) {
160
202
  fill="var(--color-activeInstallations)"
161
203
  fillOpacity={0.12}
162
204
  strokeWidth={2}
163
- dot={{ r: 3 }}
205
+ dot={{ r: 2, fill: "var(--color-activeInstallations)" }}
164
206
  connectNulls={false}
165
207
  isAnimationActive={false}
166
208
  />
@@ -171,7 +213,8 @@ export function Analytics({ report }: { report: DevicesReport }) {
171
213
  fill="var(--color-newInstallations)"
172
214
  fillOpacity={0.05}
173
215
  strokeWidth={2}
174
- dot={{ r: 2 }}
216
+ strokeDasharray="5 3"
217
+ dot={{ r: 2, fill: "var(--color-newInstallations)" }}
175
218
  connectNulls={false}
176
219
  isAnimationActive={false}
177
220
  />
@@ -179,13 +222,26 @@ export function Analytics({ report }: { report: DevicesReport }) {
179
222
  </ChartContainer>
180
223
  <div className="mt-3 flex flex-wrap gap-4 text-xs text-muted-foreground">
181
224
  <span>
182
- <i className="mr-2 inline-block size-2 rounded-full bg-chart-1" />
225
+ <i
226
+ aria-hidden="true"
227
+ className="mr-2 inline-block w-4 align-middle border-t-2 border-chart-1"
228
+ />
183
229
  {t("Активные")}
184
230
  </span>
185
231
  <span>
186
- <i className="mr-2 inline-block size-2 rounded-full bg-chart-2" />
232
+ <i
233
+ aria-hidden="true"
234
+ className="mr-2 inline-block w-4 align-middle border-t-2 border-dashed border-chart-2"
235
+ />
187
236
  {t("Новые")}
188
237
  </span>
238
+ <span>
239
+ <i
240
+ aria-hidden="true"
241
+ className="mr-2 inline-block h-3 align-middle border-l border-dashed border-muted-foreground"
242
+ />
243
+ {t("Неполный день")}
244
+ </span>
189
245
  </div>
190
246
  <p className="mt-3 text-xs leading-5 text-muted-foreground">
191
247
  {t("Сбор с ")}
@@ -194,49 +250,70 @@ export function Analytics({ report }: { report: DevicesReport }) {
194
250
  " · Сегодня — неполный день. До начала сбора данных нет; история хранится 90 дней.",
195
251
  )}
196
252
  </p>
197
- <details className="mt-3 text-xs text-muted-foreground">
198
- <summary className="cursor-pointer">
199
- {t("Показать значения по дням")}
200
- </summary>
201
- <Table className="mt-2">
202
- <TableHeader>
203
- <TableRow>
204
- <TableHead>{t("Дата UTC")}</TableHead>
205
- <TableHead>{t("Активные")}</TableHead>
206
- <TableHead>{t("Новые")}</TableHead>
207
- <TableHead>{t("Покрытие")}</TableHead>
208
- </TableRow>
209
- </TableHeader>
210
- <TableBody>
211
- {report.activity.map((day) => (
212
- <TableRow key={day.date}>
213
- <TableCell>{date(day.date)}</TableCell>
214
- <TableCell>{day.activeInstallations ?? "—"}</TableCell>
215
- <TableCell>{day.newInstallations ?? "—"}</TableCell>
216
- <TableCell>
217
- {day.coverage === "complete"
218
- ? t("Полный день")
219
- : day.coverage === "partial"
220
- ? t("Неполный день")
221
- : t("Нет данных")}
222
- </TableCell>
253
+ <Collapsible className="group/daily mt-3 text-xs text-muted-foreground">
254
+ <CollapsibleTrigger asChild>
255
+ <Button size="sm" variant="outline">
256
+ <ChevronDown
257
+ className="group-data-[state=open]/daily:rotate-180"
258
+ aria-hidden="true"
259
+ />
260
+ {t("Показать значения по дням")}
261
+ </Button>
262
+ </CollapsibleTrigger>
263
+ <CollapsibleContent>
264
+ <Table
265
+ className="mt-2"
266
+ aria-label={t("Показать значения по дням")}
267
+ >
268
+ <TableHeader>
269
+ <TableRow>
270
+ <TableHead>{t("Дата UTC")}</TableHead>
271
+ <TableHead>{t("Активные")}</TableHead>
272
+ <TableHead>{t("Новые")}</TableHead>
273
+ <TableHead>{t("Покрытие")}</TableHead>
223
274
  </TableRow>
224
- ))}
225
- </TableBody>
226
- </Table>
227
- </details>
275
+ </TableHeader>
276
+ <TableBody>
277
+ {report.activity.map((day) => (
278
+ <TableRow key={day.date}>
279
+ <TableCell>{date(day.date)}</TableCell>
280
+ <TableCell>
281
+ {day.activeInstallations === null
282
+ ? "—"
283
+ : number(day.activeInstallations)}
284
+ </TableCell>
285
+ <TableCell>
286
+ {day.newInstallations === null
287
+ ? "—"
288
+ : number(day.newInstallations)}
289
+ </TableCell>
290
+ <TableCell>
291
+ {day.coverage === "complete"
292
+ ? t("Полный день")
293
+ : day.coverage === "partial"
294
+ ? t("Неполный день")
295
+ : t("Нет данных")}
296
+ </TableCell>
297
+ </TableRow>
298
+ ))}
299
+ </TableBody>
300
+ </Table>
301
+ </CollapsibleContent>
302
+ </Collapsible>
228
303
  </CardContent>
229
304
  </Card>
230
305
  <Card className="min-w-0 shadow-none">
231
306
  <CardHeader>
232
- <CardTitle>{t("Тип запуска")}</CardTitle>
307
+ <CardTitle>
308
+ <h2>{t("Тип запуска")}</h2>
309
+ </CardTitle>
233
310
  <CardDescription>
234
311
  {t("Текущее состояние активных установок")}
235
312
  </CardDescription>
236
313
  </CardHeader>
237
- <CardContent className="space-y-5">
314
+ <CardContent className="space-y-4">
238
315
  <div
239
- className="flex h-3 overflow-hidden rounded-full bg-muted"
316
+ className="flex h-2 overflow-hidden rounded-sm bg-muted"
240
317
  role="img"
241
318
  aria-label={kinds.map((k) => `${k.label}: ${k.value}`).join(", ")}
242
319
  >
@@ -252,9 +329,12 @@ export function Analytics({ report }: { report: DevicesReport }) {
252
329
  />
253
330
  ))}
254
331
  </div>
255
- <div className="grid grid-cols-3 gap-2">
332
+ <div className="grid divide-y sm:grid-cols-3 sm:divide-x sm:divide-y-0">
256
333
  {kinds.map((k) => (
257
- <div key={k.label}>
334
+ <div
335
+ key={k.label}
336
+ className="flex flex-wrap items-center justify-between gap-2 py-2 sm:px-4 sm:first:pl-0 sm:last:pr-0"
337
+ >
258
338
  <p className="text-xs text-muted-foreground">
259
339
  <i
260
340
  className="mr-1.5 inline-block size-2 rounded-full"
@@ -262,15 +342,30 @@ export function Analytics({ report }: { report: DevicesReport }) {
262
342
  />
263
343
  {k.label}
264
344
  </p>
265
- <p className="mt-1 text-lg font-semibold tabular-nums">
345
+ <p className="text-base font-semibold tabular-nums">
266
346
  {number(k.value)}{" "}
267
- <span className="text-xs font-normal text-muted-foreground">
268
- {percent(k.value, s.activeInstallations)}
347
+ <span className="inline-block min-w-12 text-right text-xs font-normal text-muted-foreground">
348
+ {share(k.value, s.activeInstallations)}
269
349
  </span>
270
350
  </p>
271
351
  </div>
272
352
  ))}
273
353
  </div>
354
+ <div className={
355
+ "flex items-center justify-between gap-3 rounded-md border px-3 py-2 text-xs " +
356
+ (s.emergencyInstallations ? "border-destructive/40 bg-destructive/10" : "bg-muted/40")
357
+ }>
358
+ <span>{t("Аварийный запуск")}</span>
359
+ <strong
360
+ className={
361
+ s.emergencyInstallations
362
+ ? "text-destructive"
363
+ : "text-foreground"
364
+ }
365
+ >
366
+ {number(s.emergencyInstallations)}
367
+ </strong>
368
+ </div>
274
369
  {!report.total && (
275
370
  <p className="text-sm text-muted-foreground">
276
371
  {t("Нет установок с выбранными фильтрами.")}
@@ -279,151 +374,6 @@ export function Analytics({ report }: { report: DevicesReport }) {
279
374
  </CardContent>
280
375
  </Card>
281
376
  </div>
282
- <Card className="min-w-0 shadow-none">
283
- <CardHeader>
284
- <CardTitle>{t("Когорты установок")}</CardTitle>
285
- <CardDescription>
286
- {t(
287
- "Группы по неделе первого heartbeat. Одна установка — одна запись, переустановка может создать новую.",
288
- )}
289
- </CardDescription>
290
- </CardHeader>
291
- <CardContent>
292
- <Tabs defaultValue="adoption">
293
- <TabsList className="mb-4">
294
- <TabsTrigger value="adoption">{t("Текущие версии")}</TabsTrigger>
295
- <TabsTrigger value="retention">{t("Возвращаемость")}</TabsTrigger>
296
- </TabsList>
297
- <TabsContent value="adoption">
298
- <p className="mb-3 text-xs text-muted-foreground">
299
- {t(
300
- "Активные за выбранный период, сгруппированные по неделе первого появления. Проценты внутри каждой когорты.",
301
- )}
302
- </p>
303
- <Table>
304
- <TableHeader>
305
- <TableRow>
306
- <TableHead>{t("Неделя · UTC")}</TableHead>
307
- <TableHead>{t("Установки")}</TableHead>
308
- <TableHead>OTA</TableHead>
309
- <TableHead>Embedded</TableHead>
310
- <TableHead>{t("Не определён")}</TableHead>
311
- </TableRow>
312
- </TableHeader>
313
- <TableBody>
314
- {report.adoptionCohorts.map((c) => (
315
- <TableRow key={c.weekStart}>
316
- <TableCell className="font-medium">
317
- {date(c.weekStart)}
318
- </TableCell>
319
- <TableCell className="tabular-nums">
320
- {number(c.installations)}
321
- </TableCell>
322
- {[
323
- c.otaInstallations,
324
- c.embeddedInstallations,
325
- c.unknownInstallations,
326
- ].map((count, i) => (
327
- <TableCell key={i}>
328
- <div
329
- className="rounded-md px-3 py-2 text-center tabular-nums"
330
- style={{
331
- background: `color-mix(in srgb, var(--chart-${i + 1}) ${c.installations ? 5 + (count / c.installations) * 20 : 0}%, transparent)`,
332
- }}
333
- >
334
- {percent(count, c.installations)}{" "}
335
- <span className="ml-1 text-xs text-muted-foreground">
336
- ({number(count)})
337
- </span>
338
- </div>
339
- </TableCell>
340
- ))}
341
- </TableRow>
342
- ))}
343
- </TableBody>
344
- </Table>
345
- {!report.adoptionCohorts.length && (
346
- <p className="py-6 text-center text-sm text-muted-foreground">
347
- {t("Пока нет когорт для этой выборки.")}
348
- </p>
349
- )}
350
- </TabsContent>
351
- <TabsContent value="retention">
352
- <p className="mb-3 max-w-4xl text-xs leading-5 text-muted-foreground">
353
- {t(
354
- "Новые установки за последние 90 дней после начала сбора. Фильтры платформы, канала, runtime и типа запуска применяются на момент первого heartbeat. D1/D7 — heartbeat ровно через 1/7 дней, даже если версия изменилась. D0 — исходная когорта (100%); для D1 и дальше неполные дни исключены. «—» означает, что день ещё не наблюдался полностью.",
355
- )}
356
- </p>
357
- <Table>
358
- <TableHeader>
359
- <TableRow>
360
- <TableHead>{t("Неделя · UTC")}</TableHead>
361
- <TableHead>{t("Новые")}</TableHead>
362
- {[0, 1, 7, 14, 30].map((d) => (
363
- <TableHead key={d} className="text-center">
364
- D{d}
365
- </TableHead>
366
- ))}
367
- </TableRow>
368
- </TableHeader>
369
- <TableBody>
370
- {report.cohorts.map((c) => (
371
- <TableRow key={c.weekStart}>
372
- <TableCell>{date(c.weekStart)}</TableCell>
373
- <TableCell>{number(c.installations)}</TableCell>
374
- {c.cells.map((cell) => (
375
- <TableCell key={cell.day}>
376
- <div
377
- className="rounded-md px-2 py-2 text-center tabular-nums"
378
- title={
379
- cell.rate === null
380
- ? t("Нет полностью наблюдаемых дней")
381
- : cell.day === 0
382
- ? t(
383
- "D0: исходная когорта, включая сегодняшние установки",
384
- )
385
- : t(
386
- "{0} из {1} установок с полностью наблюдаемым днём",
387
- [
388
- cell.retainedInstallations,
389
- cell.eligibleInstallations,
390
- ],
391
- )
392
- }
393
- style={{
394
- background:
395
- cell.rate === null
396
- ? "var(--muted)"
397
- : `color-mix(in srgb, var(--chart-1) ${5 + cell.rate * 25}%, transparent)`,
398
- }}
399
- >
400
- {cell.rate === null
401
- ? "—"
402
- : `${Math.round(cell.rate * 100)}%`}
403
- <span className="block text-[10px] text-muted-foreground">
404
- {cell.rate === null
405
- ? t("нет данных")
406
- : `${cell.retainedInstallations}/${cell.eligibleInstallations}`}
407
- </span>
408
- </div>
409
- </TableCell>
410
- ))}
411
- </TableRow>
412
- ))}
413
- </TableBody>
414
- </Table>
415
- {!report.cohorts.length && (
416
- <p className="py-6 text-center text-sm text-muted-foreground">
417
- {t(
418
- "Возвращаемость появится для новых установок после начала сбора",
419
- )}{" "}
420
- {date(report.coverage.collectionStartedAt)}.
421
- </p>
422
- )}
423
- </TabsContent>
424
- </Tabs>
425
- </CardContent>
426
- </Card>
427
377
  </>
428
378
  );
429
379
  }