Skip to content

Commit 4959a6e

Browse files
committed
polishing
1 parent 6756e4b commit 4959a6e

File tree

7 files changed

+56
-50
lines changed

7 files changed

+56
-50
lines changed

src/entities/sentry/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export type SentryContextApp = SentryTypes.AppContext
1616

1717
export type SentryDevice = Omit<SentryTypes.DeviceContext, 'orientation'> & {
1818
orientation: SentryTypes.DeviceContext['orientation'] | string
19+
language?: string
20+
id?: string
21+
timezone?: string
22+
battery_temperature?: string
23+
locale?: string
1924
}
2025

2126
type SentryLevel = SentryTypes.Breadcrumb['level'] | string

src/entities/sentry/ui/preview-card/preview-card.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Meta, Story } from "@storybook/vue3";
2-
import { PreviewCard } from '~/src/shared/ui';
32
import { useSentry } from "../../lib";
43
import { sentryMock, sentryJSEventMock, sentryLaravelMock, sentrySpiralMock } from '../../mocks';
4+
import PreviewCard from './preview-card.vue';
55

66
const { normalizeSentryEvent } = useSentry();
77

src/entities/sentry/ui/preview-card/preview-card.vue

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,25 @@ const props = withDefaults(defineProps<Props>(), {
1616
1717
const eventLink = computed(() => `/sentry/${props.event.id}`);
1818
19-
const hasException = computed(
20-
() => props.event?.payload?.exception?.values?.length > 0
19+
const exceptionValues = computed(
20+
() => props.event?.payload?.exception?.values || []
2121
);
2222
23-
const message = computed(() => props.event.payload?.message || "");
24-
25-
const exception: Ref<Exception> = computed(() => {
26-
const defaultException: object = {
27-
type: "Unknown",
28-
value: "Something went wrong",
29-
stacktrace: {
30-
frames: [],
31-
},
32-
};
23+
const hasException = computed(() => exceptionValues.value.length > 0);
3324
34-
const eventExceptionValues = props.event?.payload?.exception?.values;
25+
const message = computed(() => props.event.payload?.message || "");
3526
36-
return eventExceptionValues.length > 0
37-
? eventExceptionValues[0]
38-
: defaultException;
39-
});
27+
const exception: Ref<Exception> = computed(() =>
28+
exceptionValues.value.length > 0
29+
? exceptionValues.value[0]
30+
: {
31+
type: "Unknown",
32+
value: "Something went wrong",
33+
stacktrace: {
34+
frames: [],
35+
},
36+
}
37+
);
4038
</script>
4139

4240
<template>

src/screens/sentry/ui/sentry-page-device/sentry-page-device.vue

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,116 +22,119 @@ const formatBatteryLevel = (level: number) => `${parseInt(String(level), 10)}%`;
2222
<h3 class="sentry-page-device__title">device</h3>
2323

2424
<TableBase>
25-
<TableBaseRow v-if="device.arch" title="Architectures">
25+
<TableBaseRow v-if="device && device.arch" title="Architectures">
2626
<CodeSnippet class="mt-3" language="json" :code="device.arch" />
2727
</TableBaseRow>
2828

29-
<TableBaseRow v-if="device.battery_level" title="Battery Level">
29+
<TableBaseRow v-if="device && device.battery_level" title="Battery Level">
3030
{{ formatBatteryLevel(device.battery_level) }}
3131
</TableBaseRow>
3232

33-
<TableBaseRow v-if="device.boot_time" title="Boot Time">
33+
<TableBaseRow v-if="device && device.boot_time" title="Boot Time">
3434
{{ formatDate(device.boot_time) }}
3535
</TableBaseRow>
3636

37-
<TableBaseRow v-if="device.brand" title="Brand">
37+
<TableBaseRow v-if="device && device.brand" title="Brand">
3838
{{ device.brand }}
3939
</TableBaseRow>
4040

41-
<TableBaseRow v-if="device.charging" title="Charging">
41+
<TableBaseRow v-if="device && device.charging" title="Charging">
4242
{{ device.charging }}
4343
</TableBaseRow>
4444

45-
<TableBaseRow v-if="device.family" title="Family">
45+
<TableBaseRow v-if="device && device.family" title="Family">
4646
{{ device.family }}
4747
</TableBaseRow>
4848

49-
<TableBaseRow v-if="device.free_memory" title="Free Memory">
49+
<TableBaseRow v-if="device && device.free_memory" title="Free Memory">
5050
{{ formatFileSize(device.free_memory) }}
5151
</TableBaseRow>
5252

53-
<TableBaseRow v-if="device.free_storage" title="Free Storage">
53+
<TableBaseRow v-if="device && device.free_storage" title="Free Storage">
5454
{{ formatFileSize(device.free_storage) }}
5555
</TableBaseRow>
5656

57-
<TableBaseRow v-if="device.id" title="Id">
57+
<TableBaseRow v-if="device && device.id" title="Id">
5858
{{ device.id }}
5959
</TableBaseRow>
6060

61-
<TableBaseRow v-if="device.language" title="Language">
61+
<TableBaseRow v-if="device && device.language" title="Language">
6262
{{ device.language }}
6363
</TableBaseRow>
6464

65-
<TableBaseRow v-if="device.low_memory" title="Low Memory">
65+
<TableBaseRow v-if="device && device.low_memory" title="Low Memory">
6666
{{ device.low_memory }}
6767
</TableBaseRow>
6868

69-
<TableBaseRow v-if="device.manufacturer" title="Manufacturer">
69+
<TableBaseRow v-if="device && device.manufacturer" title="Manufacturer">
7070
{{ device.manufacturer }}
7171
</TableBaseRow>
7272

73-
<TableBaseRow v-if="device.memory_size" title="Memory Size">
73+
<TableBaseRow v-if="device && device.memory_size" title="Memory Size">
7474
{{ formatFileSize(device.memory_size) }}
7575
</TableBaseRow>
7676

77-
<TableBaseRow v-if="device.model" title="Model">
77+
<TableBaseRow v-if="device && device.model" title="Model">
7878
{{ device.model }}
7979
</TableBaseRow>
8080

81-
<TableBaseRow v-if="device.model_id" title="Model Id">
81+
<TableBaseRow v-if="device && device.model_id" title="Model Id">
8282
{{ device.model_id }}
8383
</TableBaseRow>
8484

85-
<TableBaseRow v-if="device.name" title="Name">
85+
<TableBaseRow v-if="device && device.name" title="Name">
8686
{{ device.name }}
8787
</TableBaseRow>
8888

89-
<TableBaseRow v-if="device.orientation" title="Orientation">
89+
<TableBaseRow v-if="device && device.orientation" title="Orientation">
9090
{{ device.orientation }}
9191
</TableBaseRow>
9292

93-
<TableBaseRow v-if="device.screen_density" title="Screen Density">
93+
<TableBaseRow
94+
v-if="device && device.screen_density"
95+
title="Screen Density"
96+
>
9497
{{ parseInt(String(device.screen_density)) }}
9598
</TableBaseRow>
9699

97-
<TableBaseRow v-if="device.screen_dpi" title="Screen DPI">
100+
<TableBaseRow v-if="device && device.screen_dpi" title="Screen DPI">
98101
{{ device.screen_dpi }}
99102
</TableBaseRow>
100103

101104
<TableBaseRow
102-
v-if="device.screen_height_pixels"
105+
v-if="device && device.screen_height_pixels"
103106
title="Screen Height Pixels"
104107
>
105108
{{ device.screen_height_pixels }}
106109
</TableBaseRow>
107110

108111
<TableBaseRow
109-
v-if="device.screen_width_pixels"
112+
v-if="device && device.screen_width_pixels"
110113
title="Screen Width Pixels"
111114
>
112115
{{ device.screen_width_pixels }}
113116
</TableBaseRow>
114117

115-
<TableBaseRow v-if="device.simulator" title="Simulator">
118+
<TableBaseRow v-if="device && device.simulator" title="Simulator">
116119
{{ device.simulator }}
117120
</TableBaseRow>
118121

119-
<TableBaseRow v-if="device.storage_size" title="Storage Size">
122+
<TableBaseRow v-if="device && device.storage_size" title="Storage Size">
120123
{{ formatFileSize(device.storage_size) }}
121124
</TableBaseRow>
122125

123-
<TableBaseRow v-if="device.timezone" title="Timezone">
126+
<TableBaseRow v-if="device && device.timezone" title="Timezone">
124127
{{ device.timezone }}
125128
</TableBaseRow>
126129

127130
<TableBaseRow
128-
v-if="device.battery_temperature"
131+
v-if="device && device.battery_temperature"
129132
title="Battery Temperature"
130133
>
131134
{{ device.battery_temperature }}
132135
</TableBaseRow>
133136

134-
<TableBaseRow v-if="device.locale" :title="'Locale'">
137+
<TableBaseRow v-if="device && device.locale" :title="'Locale'">
135138
{{ device.locale }}
136139
</TableBaseRow>
137140
</TableBase>

src/screens/sentry/ui/sentry-page-request/sentry-page-request.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ const Template: Story = (args) => ({
2323
export const Laravel = Template.bind({});
2424

2525
Laravel.args = {
26-
payload: normalizeSentryEvent(sentryLaravelMock).payload,
26+
request: normalizeSentryEvent(sentryLaravelMock).payload.request,
2727
};
2828

2929
export const Spiral = Template.bind({});
3030

3131
Spiral.args = {
32-
payload: normalizeSentryEvent(sentrySpiralMock).payload,
32+
request: normalizeSentryEvent(sentrySpiralMock).payload.request,
3333
};

src/screens/sentry/ui/sentry-page-request/sentry-page-request.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const normalizeHeaderValue = (value: unknown) =>
1616
<section class="sentry-page-request">
1717
<h3 class="sentry-page-request__title">request</h3>
1818

19-
<h3 class="sentry-page-request__url">
19+
<h3 v-if="request" class="sentry-page-request__url">
2020
<strong>{{ request.method || "GET" }}:</strong>
2121
{{ request.url }}
2222
</h3>
@@ -25,7 +25,7 @@ const normalizeHeaderValue = (value: unknown) =>
2525
headers
2626
</h3>
2727

28-
<TableBase v-if="request.headers">
28+
<TableBase v-if="request && request.headers">
2929
<TableBaseRow
3030
v-for="(value, title) in request.headers"
3131
:key="title"

src/screens/sentry/ui/sentry-page/sentry-page.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ const mainException = computed(
8888
/>
8989

9090
<SentryPageApp
91-
v-if="event.payload.contexts.app"
91+
v-if="event.payload.contexts && event.payload.contexts.app"
9292
:app="event.payload.contexts.app"
9393
class="sentry-page__section"
9494
/>
9595

9696
<SentryPageDevice
97-
v-if="event.payload.contexts.device"
97+
v-if="event.payload.contexts && event.payload.contexts.device"
9898
:device="event.payload.contexts.device"
9999
class="sentry-page__section"
100100
/>

0 commit comments

Comments
 (0)