Skip to content

Commit fd5ca38

Browse files
authored
fix(context): Render more known context fields appropriately (#87329)
Adds a few context to `app` from #87238. While working on it I noticed a few missing from `device` as well, so updated those. Resolves #87238 <img width="537" alt="image" src="https://github.com/user-attachments/assets/c2bc72d4-4505-4cf5-81e5-0be3c74c0178" /> <img width="551" alt="image" src="https://github.com/user-attachments/assets/756e2f86-5429-4ac7-a429-e3940af78d57" />
1 parent b8e7c61 commit fd5ca38

File tree

2 files changed

+79
-4
lines changed

2 files changed

+79
-4
lines changed

static/app/components/events/contexts/knownContext/app.tsx

+21-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {Event} from 'sentry/types/event';
77
import type {KeyValueListData} from 'sentry/types/group';
88
import {formatBytesBase2} from 'sentry/utils/bytes/formatBytesBase2';
99

10+
// https://github.com/getsentry/relay/blob/25.3.0/relay-event-schema/src/protocol/contexts/app.rs
1011
enum AppContextKeys {
1112
ID = 'app_id',
1213
START_TIME = 'app_start_time',
@@ -17,8 +18,11 @@ enum AppContextKeys {
1718
VERSION = 'app_version',
1819
BUILD = 'app_build',
1920
IN_FOREGROUND = 'in_foreground',
20-
MEMORY = 'app_memory',
21+
APP_MEMORY = 'app_memory',
2122
VIEW_NAMES = 'view_names',
23+
// XXX: From https://github.com/getsentry/sentry/issues/87238, not in the schema yet.
24+
FREE_MEMORY = 'free_memory',
25+
ARCHITECTURE = 'app_arch',
2226
}
2327

2428
export interface AppContext {
@@ -33,8 +37,10 @@ export interface AppContext {
3337
[AppContextKeys.TYPE]?: string;
3438
[AppContextKeys.DEVICE_HASH]?: string;
3539
[AppContextKeys.IN_FOREGROUND]?: boolean;
36-
[AppContextKeys.MEMORY]?: number;
40+
[AppContextKeys.APP_MEMORY]?: number;
3741
[AppContextKeys.VIEW_NAMES]?: string[];
42+
[AppContextKeys.FREE_MEMORY]?: number;
43+
[AppContextKeys.ARCHITECTURE]?: string;
3844
}
3945

4046
// https://github.com/getsentry/relay/blob/24.10.0/relay-event-schema/src/protocol/contexts/app.rs#L37
@@ -113,7 +119,7 @@ export function getAppContextData({
113119
subject: t('In Foreground'),
114120
value: data.in_foreground,
115121
};
116-
case AppContextKeys.MEMORY:
122+
case AppContextKeys.APP_MEMORY:
117123
return {
118124
key: ctxKey,
119125
subject: t('Memory Usage'),
@@ -125,6 +131,18 @@ export function getAppContextData({
125131
subject: t('View Names'),
126132
value: data.view_names,
127133
};
134+
case AppContextKeys.FREE_MEMORY:
135+
return {
136+
key: ctxKey,
137+
subject: t('Free Memory'),
138+
value: data.free_memory ? formatMemory(data.free_memory) : undefined,
139+
};
140+
case AppContextKeys.ARCHITECTURE:
141+
return {
142+
key: ctxKey,
143+
subject: t('Architecture'),
144+
value: data.app_arch,
145+
};
128146
default:
129147
return {
130148
key: ctxKey,

static/app/components/events/contexts/knownContext/device.tsx

+58-1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ export function getDeviceContextData({
264264
) : undefined,
265265
};
266266
}
267+
case DeviceContextKey.EXTERNAL_TOTAL_STORAGE: {
268+
return {
269+
key: ctxKey,
270+
subject: t('External Total Storage'),
271+
value: data.external_total_storage ? (
272+
<FileSize bytes={data.external_total_storage} />
273+
) : undefined,
274+
};
275+
}
267276
case DeviceContextKey.SIMULATOR:
268277
return {
269278
key: ctxKey,
@@ -285,6 +294,12 @@ export function getDeviceContextData({
285294
subject: t('Device Type'),
286295
value: data.device_type,
287296
};
297+
case DeviceContextKey.DEVICE_UNIQUE_IDENTIFIER:
298+
return {
299+
key: ctxKey,
300+
subject: t('Device UID'),
301+
value: data.device_unique_identifier,
302+
};
288303
case DeviceContextKey.BRAND:
289304
return {
290305
key: ctxKey,
@@ -363,7 +378,49 @@ export function getDeviceContextData({
363378
subject: t('Screen Width Pixels'),
364379
value: data.screen_width_pixels,
365380
};
366-
381+
case DeviceContextKey.PROCESSOR_COUNT:
382+
return {
383+
key: ctxKey,
384+
subject: t('Processor Count'),
385+
value: data.processor_count,
386+
};
387+
case DeviceContextKey.PROCESSOR_FREQUENCY:
388+
return {
389+
key: ctxKey,
390+
// https://github.com/getsentry/relay/blob/25.3.0/relay-event-schema/src/protocol/contexts/device.rs#L137
391+
subject: t('Processor Frequency (MHz)'),
392+
value: data.processor_frequency,
393+
};
394+
case DeviceContextKey.SUPPORTS_ACCELEROMETER:
395+
return {
396+
key: ctxKey,
397+
subject: t('Supports Accelerometer'),
398+
value: data.supports_accelerometer,
399+
};
400+
case DeviceContextKey.SUPPORTS_AUDIO:
401+
return {
402+
key: ctxKey,
403+
subject: t('Supports Audio'),
404+
value: data.supports_audio,
405+
};
406+
case DeviceContextKey.SUPPORTS_GYROSCOPE:
407+
return {
408+
key: ctxKey,
409+
subject: t('Supports Gyroscope'),
410+
value: data.supports_gyroscope,
411+
};
412+
case DeviceContextKey.SUPPORTS_LOCATION_SERVICE:
413+
return {
414+
key: ctxKey,
415+
subject: t('Supports Location Service'),
416+
value: data.supports_location_service,
417+
};
418+
case DeviceContextKey.SUPPORTS_VIBRATION:
419+
return {
420+
key: ctxKey,
421+
subject: t('Supports Vibration'),
422+
value: data.supports_vibration,
423+
};
367424
default:
368425
return {
369426
key: ctxKey,

0 commit comments

Comments
 (0)