create-expo-updates-server 0.6.0 → 0.6.2

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 (36) hide show
  1. package/README.md +2 -2
  2. package/dist/template/README.md +1 -1
  3. package/dist/template/app/updates/devices/page.tsx +3 -3
  4. package/dist/template/docs/device-targeting.md +15 -0
  5. package/dist/template/docs/getting-started.md +1 -1
  6. package/dist/template/docs/migrations/2026-11-25-device-id-search.sql +159 -0
  7. package/dist/template/docs/migrations/schema.sql +160 -0
  8. package/dist/template/docs/npm-installer.md +3 -3
  9. package/dist/template/docs/operations-guide.md +1 -1
  10. package/dist/template/docs/ru/device-targeting.md +15 -0
  11. package/dist/template/docs/ru/getting-started.md +1 -1
  12. package/dist/template/docs/ru/npm-installer.md +3 -3
  13. package/dist/template/docs/ru/operations-guide.md +1 -1
  14. package/dist/template/docs/ru/publishing-npm-installer.md +1 -1
  15. package/dist/template/docs/uk/device-targeting.md +15 -0
  16. package/dist/template/docs/uk/getting-started.md +1 -1
  17. package/dist/template/docs/uk/npm-installer.md +3 -3
  18. package/dist/template/docs/uk/operations-guide.md +1 -1
  19. package/dist/template/docs/uk/publishing-npm-installer.md +1 -1
  20. package/dist/template/lib/audience-ids.ts +1 -0
  21. package/dist/template/scripts/tests/device-analytics-migrations.mjs +4 -0
  22. package/dist/template/scripts/tests/device-analytics.mjs +10 -1
  23. package/dist/template/scripts/tests/e2e/installations.mjs +7 -1
  24. package/dist/template/scripts/tests/e2e/release-matrix.mjs +23 -27
  25. package/dist/template/src/client/devices/registry.tsx +5 -0
  26. package/dist/template/src/client/devices/use-devices-report.ts +3 -2
  27. package/dist/template/src/client/i18n/en.json +2 -1
  28. package/dist/template/src/client/i18n/ru.json +2 -1
  29. package/dist/template/src/client/i18n/uk.json +2 -1
  30. package/dist/template/src/server/controllers/manifest.test.ts +2 -0
  31. package/dist/template/src/server/controllers/manifest.ts +1 -16
  32. package/dist/template/src/server/devices/report.test.ts +5 -1
  33. package/dist/template/src/server/devices/report.ts +2 -1
  34. package/dist/template/src/server/manifest/manifest-repository.ts +2 -10
  35. package/dist/template-manifest.json +63 -58
  36. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@ Create a standalone, self-hosted Expo Updates Server project from the
4
4
  versioned template bundled in this npm package.
5
5
 
6
6
  ```bash
7
- npx create-expo-updates-server@0.6.0 my-server
7
+ npx create-expo-updates-server@0.6.2 my-server
8
8
  cd my-server
9
9
  ```
10
10
 
@@ -13,7 +13,7 @@ To scaffold into an empty current directory instead:
13
13
  ```bash
14
14
  mkdir my-server
15
15
  cd my-server
16
- npx create-expo-updates-server@0.6.0 .
16
+ npx create-expo-updates-server@0.6.2 .
17
17
  ```
18
18
 
19
19
  The initializer performs no network requests, dependency installation, Git
@@ -14,7 +14,7 @@ panel, device targeting and installation analytics.
14
14
  Create a server project:
15
15
 
16
16
  ```bash
17
- npx create-expo-updates-server@0.6.0 my-server
17
+ npx create-expo-updates-server@0.6.2 my-server
18
18
  cd my-server
19
19
  ```
20
20
 
@@ -150,15 +150,15 @@ export default function DevicesPage() {
150
150
  />
151
151
  <div className="grid gap-2">
152
152
  <Label htmlFor="installation-search">
153
- {t("Installation ID")}
153
+ {t("Device ID / Installation ID")}
154
154
  </Label>
155
155
  <Input
156
156
  id="installation-search"
157
157
  placeholder={t("ID или часть ID")}
158
158
  value={filters.search}
159
- maxLength={36}
159
+ maxLength={64}
160
160
  pattern="[a-fA-F0-9\-]*"
161
- title={t("Часть UUID: цифры, буквы a–f и дефисы")}
161
+ title={t("Enter a Device ID prefix or part of an Installation ID")}
162
162
  onChange={(e) => update("search", e.target.value)}
163
163
  className="bg-background/40"
164
164
  />
@@ -50,6 +50,21 @@ Official API references: [Expo Application](https://docs.expo.dev/versions/v58.0
50
50
  [Expo SecureStore](https://docs.expo.dev/versions/v58.0.0/sdk/securestore/),
51
51
  [Expo extra parameters](https://docs.expo.dev/versions/v58.0.0/sdk/updates/#updatessetextraparamasynckey-value).
52
52
 
53
+ Show the first 12 characters of the SDK Device ID in app settings.
54
+
55
+ ```tsx
56
+ import { Text } from "react-native";
57
+ import { useOtaUpdates } from "expo-updates-server-client";
58
+
59
+ export function SettingsDeviceId() {
60
+ const { deviceId } = useOtaUpdates();
61
+ if (!deviceId) return null;
62
+ return <Text selectable>Device ID · {deviceId.slice(0, 12)}</Text>;
63
+ }
64
+ ```
65
+
66
+ After a heartbeat, search for this prefix in **Installations → Registry**, open the matching installation, and copy the full Device ID into the release audience. If several devices match, verify the platform and installation details. Apply `docs/migrations/2026-11-25-device-id-search.sql` after the device targeting migration for existing databases.
67
+
53
68
  ## Client initialization
54
69
 
55
70
  Generated entry calls `start()` automatically, persists installation identity and sets
@@ -13,7 +13,7 @@ SDK or macOS/Xcode. The server's Docker image does not provide the mobile toolch
13
13
  Create the server files, or use an existing source checkout:
14
14
 
15
15
  ```bash
16
- npx create-expo-updates-server@0.6.0 my-server
16
+ npx create-expo-updates-server@0.6.2 my-server
17
17
  cd my-server
18
18
  ```
19
19
 
@@ -0,0 +1,159 @@
1
+ -- Apply after device targeting. Match all installations sharing a Device ID prefix.
2
+ begin;
3
+
4
+ create or replace function public.ota_devices_report_v2(
5
+ p_days integer default 7, p_platform text default null, p_channel text default null,
6
+ p_runtime text default null, p_offset integer default 0,
7
+ p_launch_kind text default null, p_search text default null)
8
+ returns table(report jsonb) language sql stable set search_path = public as $$
9
+ with parameters as (
10
+ select (now() at time zone 'UTC')::date as today,
11
+ (now() at time zone 'UTC')::date - (p_days - 1) as first_day,
12
+ now() - make_interval(days => p_days) as window_start,
13
+ m.collection_started_at,
14
+ greatest((m.collection_started_at at time zone 'UTC')::date,
15
+ (now() at time zone 'UTC')::date - 89) as retained_from
16
+ from public.ota_device_analytics_metadata m where singleton
17
+ ), matching_devices as (
18
+ select platform, installation_id from public.ota_device_state
19
+ where p_search is not null and starts_with(device_id, lower(p_search))
20
+ ), recent as (
21
+ select s.* from public.ota_device_state s, parameters p
22
+ where s.last_sequence > 0 and s.last_seen_at >= p.window_start
23
+ ), filtered as (
24
+ select * from recent
25
+ where (p_platform is null or platform = p_platform)
26
+ and (p_channel is null or channel = p_channel)
27
+ and (p_runtime is null or runtime_version = p_runtime)
28
+ and (p_launch_kind is null or launch_kind = p_launch_kind)
29
+ and (p_search is null or position(lower(p_search) in lower(installation_id)) > 0
30
+ or (platform, installation_id) in (select platform, installation_id from matching_devices))
31
+ ), version_counts as (
32
+ select platform, channel, runtime_version, native_version, native_build, launch_kind,
33
+ coalesce(resolved_update_id, reported_update_id) as update_id,
34
+ max(update_label) as update_label, count(*) as installations
35
+ from filtered group by platform, channel, runtime_version, native_version, native_build,
36
+ launch_kind, coalesce(resolved_update_id, reported_update_id)
37
+ ), versions as (
38
+ select v.*, case when v.launch_kind = 'ota' then coalesce(
39
+ case when jsonb_typeof(u.manifest #> '{extra,expoClient,version}') = 'string'
40
+ then nullif(btrim(u.manifest #>> '{extra,expoClient,version}'), '') end,
41
+ case when jsonb_typeof(u.manifest #> '{expoClient,version}') = 'string'
42
+ then nullif(btrim(u.manifest #>> '{expoClient,version}'), '') end
43
+ ) when v.launch_kind = 'embedded' then coalesce(nullif(btrim(e.app_version), ''), v.native_version)
44
+ else null end as app_version
45
+ from version_counts v
46
+ left join public.ota_updates u on v.launch_kind = 'ota' and u.update_id = v.update_id
47
+ and u.runtime_version = v.runtime_version and u.channel = v.channel and u.platform = v.platform
48
+ left join public.ota_embedded_updates e on v.launch_kind = 'embedded' and e.embedded_update_id = v.update_id
49
+ and e.channel = v.channel and e.platform = v.platform
50
+ ), page as (
51
+ select * from filtered order by last_seen_at desc, installation_id, platform limit 50 offset p_offset
52
+ ), daily as (
53
+ select d.* from public.ota_device_activity_daily d, parameters p
54
+ where d.activity_date between greatest(p.first_day, p.retained_from) and p.today
55
+ ), filtered_daily as (
56
+ select d.* from daily d
57
+ where (p_platform is null or d.platform = p_platform)
58
+ and (p_channel is null or d.channel = p_channel)
59
+ and (p_runtime is null or d.runtime_version = p_runtime)
60
+ and (p_launch_kind is null or d.launch_kind = p_launch_kind)
61
+ and (p_search is null or position(lower(p_search) in lower(d.installation_id)) > 0
62
+ or (d.platform, d.installation_id) in (select platform, installation_id from matching_devices))
63
+ ), calendar as (
64
+ select p.first_day + n as date,
65
+ case when p.first_day + n < p.retained_from then 'unavailable'
66
+ when p.first_day + n = p.today
67
+ or ((p.first_day + n)::timestamp at time zone 'UTC') < p.collection_started_at then 'partial'
68
+ else 'complete' end as coverage
69
+ from parameters p cross join generate_series(0, p_days - 1) n
70
+ ), day_counts as (
71
+ select d.activity_date, count(*) as active,
72
+ count(*) filter (where (c.first_observed_at at time zone 'UTC')::date = d.activity_date) as newly_observed
73
+ from filtered_daily d left join public.ota_device_activity_cohorts c
74
+ on c.installation_id = d.installation_id and c.platform = d.platform
75
+ group by d.activity_date
76
+ ), activity as (
77
+ select c.date, c.coverage,
78
+ case when c.coverage <> 'unavailable' then coalesce(d.active, 0) end as active,
79
+ case when c.coverage <> 'unavailable' then coalesce(d.newly_observed, 0) end as newly_observed
80
+ from calendar c left join day_counts d on c.date = d.activity_date
81
+ ), cohort_source as (
82
+ select c.*, (c.first_observed_at at time zone 'UTC')::date as first_day,
83
+ date_trunc('week', c.first_observed_at at time zone 'UTC')::date as week_start
84
+ from public.ota_device_activity_cohorts c, parameters p
85
+ where c.first_observed_at >= p.collection_started_at
86
+ and (c.first_observed_at at time zone 'UTC')::date between p.retained_from and p.today
87
+ ), cohort_members as (
88
+ select * from cohort_source
89
+ where (p_platform is null or platform = p_platform)
90
+ and (p_channel is null or channel = p_channel)
91
+ and (p_runtime is null or runtime_version = p_runtime)
92
+ and (p_launch_kind is null or launch_kind = p_launch_kind)
93
+ and (p_search is null or position(lower(p_search) in lower(installation_id)) > 0
94
+ or (platform, installation_id) in (select platform, installation_id from matching_devices))
95
+ ), cohort_sizes as (
96
+ select week_start, count(*) as installations from cohort_members group by week_start
97
+ ), retention_members as (
98
+ select c.week_start, n.day,
99
+ (n.day = 0 or c.first_day + n.day < p.today) as eligible,
100
+ exists (select 1 from public.ota_device_activity_daily d
101
+ where d.installation_id = c.installation_id and d.platform = c.platform
102
+ and d.activity_date = c.first_day + n.day) as returned
103
+ from cohort_members c cross join (values (0), (1), (7), (14), (30)) n(day)
104
+ cross join parameters p
105
+ ), retention_counts as (
106
+ select week_start, day, count(*) filter (where eligible) as eligible,
107
+ count(*) filter (where eligible and returned) as retained
108
+ from retention_members group by week_start, day
109
+ ), retention_rows as (
110
+ select c.week_start, c.installations,
111
+ jsonb_agg(jsonb_build_object('day', r.day, 'eligibleInstallations', r.eligible,
112
+ 'retainedInstallations', case when r.eligible > 0 then r.retained end,
113
+ 'rate', case when r.eligible > 0 then r.retained::numeric / r.eligible end) order by r.day) as cells
114
+ from cohort_sizes c join retention_counts r using (week_start) group by c.week_start, c.installations
115
+ ), adoption as (
116
+ select date_trunc('week', first_seen_at at time zone 'UTC')::date as week_start,
117
+ count(*) as installations,
118
+ count(*) filter (where launch_kind = 'ota') as ota,
119
+ count(*) filter (where launch_kind = 'embedded') as embedded,
120
+ count(*) filter (where launch_kind = 'unknown') as unknown
121
+ from filtered group by date_trunc('week', first_seen_at at time zone 'UTC')::date
122
+ ), option_source as (
123
+ select platform, channel, runtime_version, launch_kind from recent
124
+ union select platform, channel, runtime_version, launch_kind from daily
125
+ union select platform, channel, runtime_version, launch_kind from cohort_source
126
+ )
127
+ select jsonb_build_object(
128
+ 'total', (select count(*) from filtered), 'pageSize', 50, 'offset', p_offset,
129
+ 'devices', coalesce((select jsonb_agg(to_jsonb(page) order by last_seen_at desc, installation_id, platform) from page), '[]'::jsonb),
130
+ 'versions', coalesce((select jsonb_agg(to_jsonb(versions) order by installations desc, platform, channel, runtime_version,
131
+ native_version, native_build, launch_kind, update_id) from versions), '[]'::jsonb),
132
+ 'filters', jsonb_build_object('days', p_days, 'platform', p_platform, 'channel', p_channel,
133
+ 'runtime', p_runtime, 'launchKind', p_launch_kind, 'search', p_search),
134
+ 'options', jsonb_build_object(
135
+ 'platforms', coalesce((select jsonb_agg(v order by v) from (select distinct platform as v from option_source) t), '[]'::jsonb),
136
+ 'channels', coalesce((select jsonb_agg(v order by v) from (select distinct channel as v from option_source) t), '[]'::jsonb),
137
+ 'runtimes', coalesce((select jsonb_agg(v order by v) from (select distinct runtime_version as v from option_source) t), '[]'::jsonb),
138
+ 'launchKinds', coalesce((select jsonb_agg(v order by v) from (select distinct launch_kind as v from option_source) t), '[]'::jsonb)),
139
+ 'summary', (select jsonb_build_object('activeInstallations', count(*),
140
+ 'newInstallations', count(*) filter (where first_seen_at >= (select window_start from parameters)),
141
+ 'otaInstallations', count(*) filter (where launch_kind = 'ota'),
142
+ 'embeddedInstallations', count(*) filter (where launch_kind = 'embedded'),
143
+ 'unknownInstallations', count(*) filter (where launch_kind = 'unknown'),
144
+ 'emergencyInstallations', count(*) filter (where emergency_launch),
145
+ 'reportedVersions', (select count(*) from versions)) from filtered),
146
+ 'activity', coalesce((select jsonb_agg(jsonb_build_object('date', date, 'activeInstallations', active,
147
+ 'newInstallations', newly_observed, 'coverage', coverage) order by date) from activity), '[]'::jsonb),
148
+ 'adoptionCohorts', coalesce((select jsonb_agg(jsonb_build_object('weekStart', week_start, 'installations', installations,
149
+ 'otaInstallations', ota, 'embeddedInstallations', embedded, 'unknownInstallations', unknown) order by week_start) from adoption), '[]'::jsonb),
150
+ 'cohorts', coalesce((select jsonb_agg(jsonb_build_object('weekStart', week_start, 'installations', installations,
151
+ 'cells', cells) order by week_start) from retention_rows), '[]'::jsonb),
152
+ 'coverage', (select jsonb_build_object('collectionStartedAt', collection_started_at, 'retainedFrom', retained_from,
153
+ 'timezone', 'UTC', 'retentionDays', 90, 'cohortWindowDays', 90, 'activityBasis', 'accepted-heartbeat-receipt',
154
+ 'cohortBasis', 'first-recorded-heartbeat', 'cohortFilters', 'entry-state', 'todayIsPartial', true,
155
+ 'generatedAt', now(), 'windowStartedAt', window_start) from parameters)
156
+ );
157
+ $$;
158
+
159
+ commit;
@@ -2131,3 +2131,163 @@ alter table public.ota_updates
2131
2131
  add constraint ota_updates_delivery_mode_chk
2132
2132
  check (delivery_mode in ('manual', 'background', 'manual-postpone')
2133
2133
  and (delivery_mode <> 'manual-postpone' or guard_action is null));
2134
+
2135
+ -- Apply after device targeting. Match all installations sharing a Device ID prefix.
2136
+ begin;
2137
+
2138
+ create or replace function public.ota_devices_report_v2(
2139
+ p_days integer default 7, p_platform text default null, p_channel text default null,
2140
+ p_runtime text default null, p_offset integer default 0,
2141
+ p_launch_kind text default null, p_search text default null)
2142
+ returns table(report jsonb) language sql stable set search_path = public as $$
2143
+ with parameters as (
2144
+ select (now() at time zone 'UTC')::date as today,
2145
+ (now() at time zone 'UTC')::date - (p_days - 1) as first_day,
2146
+ now() - make_interval(days => p_days) as window_start,
2147
+ m.collection_started_at,
2148
+ greatest((m.collection_started_at at time zone 'UTC')::date,
2149
+ (now() at time zone 'UTC')::date - 89) as retained_from
2150
+ from public.ota_device_analytics_metadata m where singleton
2151
+ ), matching_devices as (
2152
+ select platform, installation_id from public.ota_device_state
2153
+ where p_search is not null and starts_with(device_id, lower(p_search))
2154
+ ), recent as (
2155
+ select s.* from public.ota_device_state s, parameters p
2156
+ where s.last_sequence > 0 and s.last_seen_at >= p.window_start
2157
+ ), filtered as (
2158
+ select * from recent
2159
+ where (p_platform is null or platform = p_platform)
2160
+ and (p_channel is null or channel = p_channel)
2161
+ and (p_runtime is null or runtime_version = p_runtime)
2162
+ and (p_launch_kind is null or launch_kind = p_launch_kind)
2163
+ and (p_search is null or position(lower(p_search) in lower(installation_id)) > 0
2164
+ or (platform, installation_id) in (select platform, installation_id from matching_devices))
2165
+ ), version_counts as (
2166
+ select platform, channel, runtime_version, native_version, native_build, launch_kind,
2167
+ coalesce(resolved_update_id, reported_update_id) as update_id,
2168
+ max(update_label) as update_label, count(*) as installations
2169
+ from filtered group by platform, channel, runtime_version, native_version, native_build,
2170
+ launch_kind, coalesce(resolved_update_id, reported_update_id)
2171
+ ), versions as (
2172
+ select v.*, case when v.launch_kind = 'ota' then coalesce(
2173
+ case when jsonb_typeof(u.manifest #> '{extra,expoClient,version}') = 'string'
2174
+ then nullif(btrim(u.manifest #>> '{extra,expoClient,version}'), '') end,
2175
+ case when jsonb_typeof(u.manifest #> '{expoClient,version}') = 'string'
2176
+ then nullif(btrim(u.manifest #>> '{expoClient,version}'), '') end
2177
+ ) when v.launch_kind = 'embedded' then coalesce(nullif(btrim(e.app_version), ''), v.native_version)
2178
+ else null end as app_version
2179
+ from version_counts v
2180
+ left join public.ota_updates u on v.launch_kind = 'ota' and u.update_id = v.update_id
2181
+ and u.runtime_version = v.runtime_version and u.channel = v.channel and u.platform = v.platform
2182
+ left join public.ota_embedded_updates e on v.launch_kind = 'embedded' and e.embedded_update_id = v.update_id
2183
+ and e.channel = v.channel and e.platform = v.platform
2184
+ ), page as (
2185
+ select * from filtered order by last_seen_at desc, installation_id, platform limit 50 offset p_offset
2186
+ ), daily as (
2187
+ select d.* from public.ota_device_activity_daily d, parameters p
2188
+ where d.activity_date between greatest(p.first_day, p.retained_from) and p.today
2189
+ ), filtered_daily as (
2190
+ select d.* from daily d
2191
+ where (p_platform is null or d.platform = p_platform)
2192
+ and (p_channel is null or d.channel = p_channel)
2193
+ and (p_runtime is null or d.runtime_version = p_runtime)
2194
+ and (p_launch_kind is null or d.launch_kind = p_launch_kind)
2195
+ and (p_search is null or position(lower(p_search) in lower(d.installation_id)) > 0
2196
+ or (d.platform, d.installation_id) in (select platform, installation_id from matching_devices))
2197
+ ), calendar as (
2198
+ select p.first_day + n as date,
2199
+ case when p.first_day + n < p.retained_from then 'unavailable'
2200
+ when p.first_day + n = p.today
2201
+ or ((p.first_day + n)::timestamp at time zone 'UTC') < p.collection_started_at then 'partial'
2202
+ else 'complete' end as coverage
2203
+ from parameters p cross join generate_series(0, p_days - 1) n
2204
+ ), day_counts as (
2205
+ select d.activity_date, count(*) as active,
2206
+ count(*) filter (where (c.first_observed_at at time zone 'UTC')::date = d.activity_date) as newly_observed
2207
+ from filtered_daily d left join public.ota_device_activity_cohorts c
2208
+ on c.installation_id = d.installation_id and c.platform = d.platform
2209
+ group by d.activity_date
2210
+ ), activity as (
2211
+ select c.date, c.coverage,
2212
+ case when c.coverage <> 'unavailable' then coalesce(d.active, 0) end as active,
2213
+ case when c.coverage <> 'unavailable' then coalesce(d.newly_observed, 0) end as newly_observed
2214
+ from calendar c left join day_counts d on c.date = d.activity_date
2215
+ ), cohort_source as (
2216
+ select c.*, (c.first_observed_at at time zone 'UTC')::date as first_day,
2217
+ date_trunc('week', c.first_observed_at at time zone 'UTC')::date as week_start
2218
+ from public.ota_device_activity_cohorts c, parameters p
2219
+ where c.first_observed_at >= p.collection_started_at
2220
+ and (c.first_observed_at at time zone 'UTC')::date between p.retained_from and p.today
2221
+ ), cohort_members as (
2222
+ select * from cohort_source
2223
+ where (p_platform is null or platform = p_platform)
2224
+ and (p_channel is null or channel = p_channel)
2225
+ and (p_runtime is null or runtime_version = p_runtime)
2226
+ and (p_launch_kind is null or launch_kind = p_launch_kind)
2227
+ and (p_search is null or position(lower(p_search) in lower(installation_id)) > 0
2228
+ or (platform, installation_id) in (select platform, installation_id from matching_devices))
2229
+ ), cohort_sizes as (
2230
+ select week_start, count(*) as installations from cohort_members group by week_start
2231
+ ), retention_members as (
2232
+ select c.week_start, n.day,
2233
+ (n.day = 0 or c.first_day + n.day < p.today) as eligible,
2234
+ exists (select 1 from public.ota_device_activity_daily d
2235
+ where d.installation_id = c.installation_id and d.platform = c.platform
2236
+ and d.activity_date = c.first_day + n.day) as returned
2237
+ from cohort_members c cross join (values (0), (1), (7), (14), (30)) n(day)
2238
+ cross join parameters p
2239
+ ), retention_counts as (
2240
+ select week_start, day, count(*) filter (where eligible) as eligible,
2241
+ count(*) filter (where eligible and returned) as retained
2242
+ from retention_members group by week_start, day
2243
+ ), retention_rows as (
2244
+ select c.week_start, c.installations,
2245
+ jsonb_agg(jsonb_build_object('day', r.day, 'eligibleInstallations', r.eligible,
2246
+ 'retainedInstallations', case when r.eligible > 0 then r.retained end,
2247
+ 'rate', case when r.eligible > 0 then r.retained::numeric / r.eligible end) order by r.day) as cells
2248
+ from cohort_sizes c join retention_counts r using (week_start) group by c.week_start, c.installations
2249
+ ), adoption as (
2250
+ select date_trunc('week', first_seen_at at time zone 'UTC')::date as week_start,
2251
+ count(*) as installations,
2252
+ count(*) filter (where launch_kind = 'ota') as ota,
2253
+ count(*) filter (where launch_kind = 'embedded') as embedded,
2254
+ count(*) filter (where launch_kind = 'unknown') as unknown
2255
+ from filtered group by date_trunc('week', first_seen_at at time zone 'UTC')::date
2256
+ ), option_source as (
2257
+ select platform, channel, runtime_version, launch_kind from recent
2258
+ union select platform, channel, runtime_version, launch_kind from daily
2259
+ union select platform, channel, runtime_version, launch_kind from cohort_source
2260
+ )
2261
+ select jsonb_build_object(
2262
+ 'total', (select count(*) from filtered), 'pageSize', 50, 'offset', p_offset,
2263
+ 'devices', coalesce((select jsonb_agg(to_jsonb(page) order by last_seen_at desc, installation_id, platform) from page), '[]'::jsonb),
2264
+ 'versions', coalesce((select jsonb_agg(to_jsonb(versions) order by installations desc, platform, channel, runtime_version,
2265
+ native_version, native_build, launch_kind, update_id) from versions), '[]'::jsonb),
2266
+ 'filters', jsonb_build_object('days', p_days, 'platform', p_platform, 'channel', p_channel,
2267
+ 'runtime', p_runtime, 'launchKind', p_launch_kind, 'search', p_search),
2268
+ 'options', jsonb_build_object(
2269
+ 'platforms', coalesce((select jsonb_agg(v order by v) from (select distinct platform as v from option_source) t), '[]'::jsonb),
2270
+ 'channels', coalesce((select jsonb_agg(v order by v) from (select distinct channel as v from option_source) t), '[]'::jsonb),
2271
+ 'runtimes', coalesce((select jsonb_agg(v order by v) from (select distinct runtime_version as v from option_source) t), '[]'::jsonb),
2272
+ 'launchKinds', coalesce((select jsonb_agg(v order by v) from (select distinct launch_kind as v from option_source) t), '[]'::jsonb)),
2273
+ 'summary', (select jsonb_build_object('activeInstallations', count(*),
2274
+ 'newInstallations', count(*) filter (where first_seen_at >= (select window_start from parameters)),
2275
+ 'otaInstallations', count(*) filter (where launch_kind = 'ota'),
2276
+ 'embeddedInstallations', count(*) filter (where launch_kind = 'embedded'),
2277
+ 'unknownInstallations', count(*) filter (where launch_kind = 'unknown'),
2278
+ 'emergencyInstallations', count(*) filter (where emergency_launch),
2279
+ 'reportedVersions', (select count(*) from versions)) from filtered),
2280
+ 'activity', coalesce((select jsonb_agg(jsonb_build_object('date', date, 'activeInstallations', active,
2281
+ 'newInstallations', newly_observed, 'coverage', coverage) order by date) from activity), '[]'::jsonb),
2282
+ 'adoptionCohorts', coalesce((select jsonb_agg(jsonb_build_object('weekStart', week_start, 'installations', installations,
2283
+ 'otaInstallations', ota, 'embeddedInstallations', embedded, 'unknownInstallations', unknown) order by week_start) from adoption), '[]'::jsonb),
2284
+ 'cohorts', coalesce((select jsonb_agg(jsonb_build_object('weekStart', week_start, 'installations', installations,
2285
+ 'cells', cells) order by week_start) from retention_rows), '[]'::jsonb),
2286
+ 'coverage', (select jsonb_build_object('collectionStartedAt', collection_started_at, 'retainedFrom', retained_from,
2287
+ 'timezone', 'UTC', 'retentionDays', 90, 'cohortWindowDays', 90, 'activityBasis', 'accepted-heartbeat-receipt',
2288
+ 'cohortBasis', 'first-recorded-heartbeat', 'cohortFilters', 'entry-state', 'todayIsPartial', true,
2289
+ 'generatedAt', now(), 'windowStartedAt', window_start) from parameters)
2290
+ );
2291
+ $$;
2292
+
2293
+ commit;
@@ -1,10 +1,10 @@
1
1
  # Create a server with NPX
2
2
 
3
3
  The npm initializer is the quickest way to create a standalone copy of Expo
4
- Updates Server. Node.js 20.9 or newer is required. Version 0.6.0 creates a server whose `configure-app` command installs `expo-updates-server-client@0.1.0` in your Expo application.
4
+ Updates Server. Node.js 20.9 or newer is required. Version 0.6.2 creates a server whose `configure-app` command installs `expo-updates-server-client@0.1.0` in your Expo application.
5
5
 
6
6
  ```bash
7
- npx create-expo-updates-server@0.6.0 my-server
7
+ npx create-expo-updates-server@0.6.2 my-server
8
8
  cd my-server
9
9
  ```
10
10
 
@@ -13,7 +13,7 @@ You can also initialize an empty current directory:
13
13
  ```bash
14
14
  mkdir my-server
15
15
  cd my-server
16
- npx create-expo-updates-server@0.6.0 .
16
+ npx create-expo-updates-server@0.6.2 .
17
17
  ```
18
18
 
19
19
  `npx` downloads the published initializer package from npm. After it starts,
@@ -339,7 +339,7 @@ Activation advances the channel epoch even if its latest pointer is unchanged.
339
339
  Pointer changes and repeated rollback operations advance the epoch clock by
340
340
  at least one millisecond, so successive publications remain ordered for Expo.
341
341
 
342
- Reapply this repeatable migration when upgrading an existing installation. It also orders a fallback after a disabled patch when the publishing machine’s clock runs ahead of the server. Devices already on the fallback receive a no-update response.
342
+ Reapply this repeatable migration when upgrading an existing installation. Disabling an installed OTA leaves that version running. Restoring an older public release makes it available to eligible clients. To deliver it to devices already running a newer version, use an explicit **Rollback**.
343
343
 
344
344
  The server records the manifest-to-update mapping before returning a manifest.
345
345
  Missing mapping tables, lookup errors, or failed mapping writes now fail the
@@ -24,6 +24,21 @@
24
24
 
25
25
  Официальные справочники API: [Expo Application](https://docs.expo.dev/versions/v58.0.0/sdk/application/), [Expo SecureStore](https://docs.expo.dev/versions/v58.0.0/sdk/securestore/), [дополнительные параметры Expo](https://docs.expo.dev/versions/v58.0.0/sdk/updates/#updatessetextraparamasynckey-value).
26
26
 
27
+ В настройках приложения можно показать первые 12 символов Device ID из SDK.
28
+
29
+ ```tsx
30
+ import { Text } from "react-native";
31
+ import { useOtaUpdates } from "expo-updates-server-client";
32
+
33
+ export function SettingsDeviceId() {
34
+ const { deviceId } = useOtaUpdates();
35
+ if (!deviceId) return null;
36
+ return <Text selectable>Device ID · {deviceId.slice(0, 12)}</Text>;
37
+ }
38
+ ```
39
+
40
+ После heartbeat введите этот префикс в разделе **Установки → Реестр**, откройте подходящую установку и скопируйте полный ID устройства в аудиторию релиза. Если совпадений несколько, сверьте платформу и сведения об установке. Для существующей БД примените `docs/migrations/2026-11-25-device-id-search.sql` после миграции адресной раздачи.
41
+
27
42
  ## Инициализация клиента {#client-initialization}
28
43
 
29
44
  Сгенерированная точка входа автоматически вызывает `start()`, сохраняет идентификатор установки и задаёт `installation_id` / `device_id` через `Updates.setExtraParamAsync`. Сигнал активности добавляет необязательный `deviceId`. Надёжная очередь и монотонная последовательность для каждой установки не меняются. Недоступный ID устройства не останавливает телеметрию установок; доставка по устройствам при этом закрыта. После временного сбоя Keychain чтение ID на iOS повторяется без замены исходного значения.
@@ -9,7 +9,7 @@
9
9
  Создайте файлы сервера или используйте существующую копию исходников:
10
10
 
11
11
  ```bash
12
- npx create-expo-updates-server@0.6.0 my-server
12
+ npx create-expo-updates-server@0.6.2 my-server
13
13
  cd my-server
14
14
  ```
15
15
 
@@ -1,9 +1,9 @@
1
1
  # Создание сервера через NPX {#create-a-server-with-npx}
2
2
 
3
- npm-инициализатор — самый быстрый способ создать самостоятельную копию Expo Updates Server. Требуется Node.js 20.9 или новее. Версия 0.6.0 создаёт сервер, команда `configure-app` которого устанавливает `expo-updates-server-client@0.1.0` в приложение Expo.
3
+ npm-инициализатор — самый быстрый способ создать самостоятельную копию Expo Updates Server. Требуется Node.js 20.9 или новее. Версия 0.6.2 создаёт сервер, команда `configure-app` которого устанавливает `expo-updates-server-client@0.1.0` в приложение Expo.
4
4
 
5
5
  ```bash
6
- npx create-expo-updates-server@0.6.0 my-server
6
+ npx create-expo-updates-server@0.6.2 my-server
7
7
  cd my-server
8
8
  ```
9
9
 
@@ -12,7 +12,7 @@ cd my-server
12
12
  ```bash
13
13
  mkdir my-server
14
14
  cd my-server
15
- npx create-expo-updates-server@0.6.0 .
15
+ npx create-expo-updates-server@0.6.2 .
16
16
  ```
17
17
 
18
18
  `npx` скачивает опубликованный пакет инициализатора из npm. После запуска сам инициализатор не делает сетевых запросов: шаблон сервера и его манифест SHA-256 включены в пакет.
@@ -280,7 +280,7 @@ docker compose exec -T postgres \
280
280
 
281
281
  Каждый UUID манифеста теперь вычисляется из эпохи публикации канала и UUID реально выбранного обновления. Поэтому неактивная загрузка может использовать стабильное резервное обновление, не разделяя его ID манифеста с будущим активированным обновлением. Активация продвигает эпоху канала, даже если указатель latest не изменился. Изменения указателей и повторные откаты продвигают часы эпохи минимум на миллисекунду, сохраняя порядок публикаций для Expo.
282
282
 
283
- При обновлении существующего сервера повторно примените эту миграцию. Она сохраняет порядок резервного и отключённого патчей, даже если часы машины публикации опережают серверные. Устройства, на которых уже запущен резервный патч, получают ответ об отсутствии обновления.
283
+ При обновлении существующего сервера повторно примените эту миграцию. При отключении OTA устройство сохраняет установленную версию. Восстановление публичной раздачи снова делает прежний релиз доступным подходящим клиентам. Для перехода с уже установленной новой версии на старую используйте явную команду **Rollback**.
284
284
 
285
285
  Сервер записывает сопоставление манифеста с обновлением до возврата манифеста. Отсутствующие таблицы сопоставления, ошибки поиска или записи теперь завершают запрос ошибкой вместо незаметной смены ID или потери истории. Повтор одинакового сопоставления допустим; присвоение существующего ID манифеста другому обновлению или области отклоняется PostgreSQL. Ответам без обновления новое сопоставление не нужно.
286
286
 
@@ -40,7 +40,7 @@
40
40
  create-expo-updates-server-v<version>
41
41
  ```
42
42
 
43
- Например, для версии пакета `0.6.0` нужен тег `create-expo-updates-server-v0.6.0`.
43
+ Например, для версии пакета `0.6.2` нужен тег `create-expo-updates-server-v0.6.2`.
44
44
 
45
45
  Workflow, запускаемый только по тегу, сверяет тег с версией пакета, повторно собирает и тестирует детерминированный шаблон и проверяет, что отмеченный коммит является предком `origin/main`. Проверка выполняется до входа в защищённое окружение `npm-publish`. Создаётся один архив релиза; именно этот артефакт передаётся заданию публикации с защитой окружением и публикуется с публичным доступом и npm provenance через OIDC. Несовпадение тега, не включённый в main коммит или несовпадение SHA рабочей копии и события блокируют публикацию.
46
46
 
@@ -24,6 +24,21 @@
24
24
 
25
25
  Офіційні довідники API: [Expo Application](https://docs.expo.dev/versions/v58.0.0/sdk/application/), [Expo SecureStore](https://docs.expo.dev/versions/v58.0.0/sdk/securestore/), [додаткові параметри Expo](https://docs.expo.dev/versions/v58.0.0/sdk/updates/#updatessetextraparamasynckey-value).
26
26
 
27
+ У налаштуваннях застосунку можна показати перші 12 символів Device ID із SDK.
28
+
29
+ ```tsx
30
+ import { Text } from "react-native";
31
+ import { useOtaUpdates } from "expo-updates-server-client";
32
+
33
+ export function SettingsDeviceId() {
34
+ const { deviceId } = useOtaUpdates();
35
+ if (!deviceId) return null;
36
+ return <Text selectable>Device ID · {deviceId.slice(0, 12)}</Text>;
37
+ }
38
+ ```
39
+
40
+ Після heartbeat введіть цей префікс у розділі **Встановлення → Реєстр**, відкрийте потрібне встановлення й скопіюйте повний ID пристрою до аудиторії релізу. Якщо є кілька збігів, звірте платформу та відомості про встановлення. Для наявної БД застосуйте `docs/migrations/2026-11-25-device-id-search.sql` після міграції адресної доставки.
41
+
27
42
  ## Ініціалізація клієнта {#client-initialization}
28
43
 
29
44
  Згенерована точка входу автоматично викликає `start()`, зберігає ідентифікатор встановлення й задає `installation_id` / `device_id` через `Updates.setExtraParamAsync`. Сигнал активності додає необов’язковий `deviceId`. Надійна черга та монотонна послідовність для кожного встановлення не змінюються. Недоступний ID пристрою не зупиняє телеметрію встановлень; доставка за пристроями при цьому закрита. Після тимчасового збою Keychain читання ID на iOS повторюється без заміни початкового значення.
@@ -9,7 +9,7 @@
9
9
  Створіть файли сервера або використовуйте наявну копію вихідного коду:
10
10
 
11
11
  ```bash
12
- npx create-expo-updates-server@0.6.0 my-server
12
+ npx create-expo-updates-server@0.6.2 my-server
13
13
  cd my-server
14
14
  ```
15
15
 
@@ -1,9 +1,9 @@
1
1
  # Створення сервера через NPX {#create-a-server-with-npx}
2
2
 
3
- npm-ініціалізатор — найшвидший спосіб створити самостійну копію Expo Updates Server. Потрібен Node.js 20.9 або новіший. Версія 0.6.0 створює сервер, команда `configure-app` якого встановлює `expo-updates-server-client@0.1.0` у застосунок Expo.
3
+ npm-ініціалізатор — найшвидший спосіб створити самостійну копію Expo Updates Server. Потрібен Node.js 20.9 або новіший. Версія 0.6.2 створює сервер, команда `configure-app` якого встановлює `expo-updates-server-client@0.1.0` у застосунок Expo.
4
4
 
5
5
  ```bash
6
- npx create-expo-updates-server@0.6.0 my-server
6
+ npx create-expo-updates-server@0.6.2 my-server
7
7
  cd my-server
8
8
  ```
9
9
 
@@ -12,7 +12,7 @@ cd my-server
12
12
  ```bash
13
13
  mkdir my-server
14
14
  cd my-server
15
- npx create-expo-updates-server@0.6.0 .
15
+ npx create-expo-updates-server@0.6.2 .
16
16
  ```
17
17
 
18
18
  `npx` завантажує опублікований пакет ініціалізатора з npm. Після запуску сам ініціалізатор не робить мережевих запитів: шаблон сервера та його маніфест SHA-256 включені до пакета.
@@ -280,7 +280,7 @@ docker compose exec -T postgres \
280
280
 
281
281
  Кожен UUID маніфесту тепер обчислюється з епохи публікації каналу та UUID реально вибраного оновлення. Тому неактивне завантаження може використовувати стабільне резервне оновлення, не поділяючи його ID маніфесту з майбутнім активованим оновленням. Активація просуває епоху каналу, навіть якщо вказівник latest не змінився. Зміни вказівників і повторні відкати просувають годинник епохи щонайменше на мілісекунду, зберігаючи порядок публікацій для Expo.
282
282
 
283
- Під час оновлення наявного сервера повторно застосуйте цю міграцію. Вона зберігає порядок резервного та вимкненого патчів, навіть якщо годинник машини публікації випереджає серверний. Пристрої, на яких уже запущено резервний патч, отримують відповідь про відсутність оновлення.
283
+ Під час оновлення наявного сервера повторно застосуйте цю міграцію. Після вимкнення OTA пристрій зберігає встановлену версію. Відновлення публічної роздачі повертає попередній реліз для сумісних клієнтів. Для переходу з уже встановленої новішої версії на старішу скористайтеся явною командою **Rollback**.
284
284
 
285
285
  Сервер записує зіставлення маніфесту з оновленням до повернення маніфесту. Відсутні таблиці зіставлення, помилки пошуку або запису тепер завершують запит помилкою замість непомітної зміни ID або втрати історії. Повтор однакового зіставлення допустимий; призначення наявного ID маніфесту іншому оновленню або області відхиляється PostgreSQL. Відповідям без оновлення нове зіставлення не потрібне.
286
286
 
@@ -40,7 +40,7 @@
40
40
  create-expo-updates-server-v<version>
41
41
  ```
42
42
 
43
- Наприклад, для версії пакета `0.6.0` потрібен тег `create-expo-updates-server-v0.6.0`.
43
+ Наприклад, для версії пакета `0.6.2` потрібен тег `create-expo-updates-server-v0.6.2`.
44
44
 
45
45
  Workflow, що запускається лише за тегом, звіряє тег із версією пакета, повторно збирає й тестує детермінований шаблон і перевіряє, що позначений коміт є предком `origin/main`. Перевірка виконується до входу в захищене оточення `npm-publish`. Створюється один архів релізу; саме цей артефакт передається завданню публікації із захистом оточенням і публікується з публічним доступом та npm provenance через OIDC. Невідповідність тега, не включений до main коміт або невідповідність SHA робочої копії та події блокують публікацію.
46
46
 
@@ -1,4 +1,5 @@
1
1
  export const installationIdPattern =
2
2
  /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
3
+ export const registryIdSearchPattern = /^(?:[a-f0-9-]{1,36}|[a-f0-9]{1,64})$/i;
3
4
  export const deviceIdPattern = /^[0-9a-f]{64}$/;
4
5
  export const maxIdsPerKind = 100;