Skip to content

Commit f56202e

Browse files
authored
Merge pull request #41 from buggregator/hotfix/issue-40
[#40] Fixes problem with handling Sentry events
2 parents 35b2d7f + 38850e7 commit f56202e

File tree

8 files changed

+885
-15
lines changed

8 files changed

+885
-15
lines changed

components/SentryPage/SentryPage.stories.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Meta, Story } from "@storybook/vue3";
22
import { normalizeSentryEvent } from "~/utils/normalize-event";
3-
import sentryEventMock from '~/mocks/sentry-common.json'
3+
import sentryCommonMock from '~/mocks/sentry-common.json'
4+
import sentryEventMock from '~/mocks/sentry-event.json'
5+
import sentryJsEventMock from '~/mocks/sentry-js-event.json'
6+
import sentryJsMock from '~/mocks/sentry-js.json'
47
import SentryPage from '~/components/SentryPage/SentryPage.vue';
58

69
export default {
@@ -18,8 +21,27 @@ const Template: Story = (args) => ({
1821
template: `<SentryPage v-bind="args" />`,
1922
});
2023

21-
export const Page = Template.bind({});
24+
export const PageCommon = Template.bind({});
2225

23-
Page.args = {
26+
PageCommon.args = {
27+
event: normalizeSentryEvent(sentryCommonMock),
28+
};
29+
30+
export const PageEvent = Template.bind({});
31+
32+
PageEvent.args = {
2433
event: normalizeSentryEvent(sentryEventMock),
2534
};
35+
36+
export const PageJS = Template.bind({});
37+
38+
PageJS.args = {
39+
event: normalizeSentryEvent(sentryJsMock),
40+
};
41+
42+
export const PageJSEvent = Template.bind({});
43+
44+
PageJSEvent.args = {
45+
event: normalizeSentryEvent(sentryJsEventMock),
46+
};
47+

components/SentryPage/SentryPage.vue

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
<template>
22
<div class="sentry-page">
33
<main class="sentry-page__main">
4-
<header class="sentry-page__main-header">
5-
<h1 class="sentry-page__main-exception">{{ exception }}</h1>
4+
<header class="sentry-page__main-header" v-if="hasException">
5+
<h1 class="sentry-page__main-exception">{{ mainException.type }}</h1>
66

7+
<pre class="sentry-page__main-exception-message" v-html="mainException.value" />
8+
<p class="sentry-page__main-date">{{ date }}</p>
9+
</header>
10+
11+
<header class="sentry-page__main-header" v-if="hasMessage">
712
<pre class="sentry-page__main-exception-message" v-html="message" />
813
<p class="sentry-page__main-date">{{ date }}</p>
914
</header>
1015

1116
<SentryPageTags :event="event.payload" class="sentry-page__section" />
1217

13-
<section class="sentry-page__section">
18+
<section v-if="hasException" class="sentry-page__section">
1419
<h3 class="sentry-page__section-title">exceptions</h3>
1520

1621
<div class="sentry-page__section-exceptions">
@@ -60,14 +65,17 @@ export default defineComponent({
6065
},
6166
},
6267
computed: {
63-
mainException() {
64-
return this.event.payload.exception.values[0];
68+
hasMessage(): boolean {
69+
return this.event.payload.message !== "";
70+
},
71+
message(): boolean {
72+
return this.event.payload.message;
6573
},
66-
exception(): string {
67-
return this.mainException.type;
74+
hasException(): boolean {
75+
return this.event.payload.exception?.values?.length > 0;
6876
},
69-
message(): string {
70-
return this.mainException.value;
77+
mainException() {
78+
return this.event.payload.exception.values[0];
7179
},
7280
date(): string {
7381
return moment(this.event.payload.timestamp).toLocaleString();

components/SentryPageRequest/SentryPageRequest.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<h3 class="sentry-page-request__title">request</h3>
44

55
<h3 class="sentry-page-request__url">
6-
<strong>{{ event.request.method }}:</strong> {{ event.request.url }}
6+
<strong>{{ event.request.method || "GET" }}:</strong>
7+
{{ event.request.url }}
78
</h3>
89

910
<h3 class="sentry-page-request__title sentry-page-request__title--sub">
@@ -15,7 +16,7 @@
1516
:key="title"
1617
:title="title"
1718
>
18-
{{ value[0] || value }}
19+
{{ Array.isArray(value) ? value[0] || value : value }}
1920
</EventTableRow>
2021
</EventTable>
2122
</section>

components/SentryPreview/SentryPreview.stories.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Meta, Story } from "@storybook/vue3";
22
import { normalizeSentryEvent } from "~/utils/normalize-event";
33
import sentrySpiralEventMock from '~/mocks/sentry-spiral.json'
44
import sentryLaravelEventMock from '~/mocks/sentry-laravel.json'
5+
import sentryEventMock from '~/mocks/sentry-event.json'
6+
import sentryJsEventMock from '~/mocks/sentry-js-event.json'
57
import SentryPreview from '~/components/SentryPreview/SentryPreview.vue';
68

79
export default {
@@ -30,3 +32,16 @@ export const Laravel = Template.bind({});
3032
Laravel.args = {
3133
event: normalizeSentryEvent(sentryLaravelEventMock),
3234
};
35+
36+
export const Event = Template.bind({});
37+
38+
Event.args = {
39+
event: normalizeSentryEvent(sentryEventMock),
40+
};
41+
42+
export const JSEvent = Template.bind({});
43+
44+
JSEvent.args = {
45+
event: normalizeSentryEvent(sentryJsEventMock),
46+
};
47+

components/SentryPreview/SentryPreview.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<template>
22
<PreviewCard class="sentry-preview" :event="event">
3-
<SentryException :exception="exception" :max-frames="maxFrames">
3+
<SentryException
4+
v-if="hasException"
5+
:exception="exception"
6+
:max-frames="maxFrames"
7+
>
48
<NuxtLink tag="div" :to="eventLink" class="sentry-preview__link">
59
<h3 class="sentry-preview__title">
610
{{ exception.type }}
@@ -9,6 +13,11 @@
913
<pre class="sentry-preview__text" v-html="exception.value" />
1014
</NuxtLink>
1115
</SentryException>
16+
<div v-if="hasMessage">
17+
<NuxtLink tag="div" :to="eventLink" class="sentry-preview__link">
18+
<pre class="sentry-preview__text" v-html="message" />
19+
</NuxtLink>
20+
</div>
1221
</PreviewCard>
1322
</template>
1423

@@ -37,6 +46,15 @@ export default defineComponent({
3746
eventLink() {
3847
return `/sentry/${this.event.id}`;
3948
},
49+
hasException() {
50+
return this.event?.payload?.exception?.values?.length > 0;
51+
},
52+
hasMessage(): boolean {
53+
return this.event?.payload?.message !== "";
54+
},
55+
message(): boolean {
56+
return this.event.payload.message;
57+
},
4058
exception() {
4159
const defaultException: object = {
4260
type: "Unknown",

0 commit comments

Comments
 (0)