summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/error_tracking/components/error_details_info.vue
blob: bbc7b0de7cfba649f2fe59b438fa01d222fa3d49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<script>
import { GlLink, GlIcon, GlCard, GlTooltipDirective } from '@gitlab/ui';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import TrackEventDirective from '~/vue_shared/directives/track_event';
import { trackClickErrorLinkToSentryOptions } from '../utils';

const CARD_CLASS = 'gl-mr-7 gl-w-15p gl-min-w-fit-content';
const HEADER_CLASS =
  'gl-p-2 gl-font-weight-bold gl-display-flex gl-justify-content-center gl-align-items-center';
const BODY_CLASS =
  'gl-display-flex gl-justify-content-center gl-align-items-center gl-flex-direction-column gl-my-0 gl-p-4 gl-font-weight-bold gl-text-center gl-flex-grow-1 gl-font-lg';

export default {
  components: {
    GlCard,
    GlLink,
    TimeAgoTooltip,
    GlIcon,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
    TrackEvent: TrackEventDirective,
  },
  props: {
    error: {
      type: Object,
      required: true,
    },
  },
  computed: {
    firstReleaseLink() {
      return `${this.error.externalBaseUrl}/releases/${this.error.firstReleaseVersion}`;
    },
    lastReleaseLink() {
      return `${this.error.externalBaseUrl}/releases/${this.error.lastReleaseVersion}`;
    },
    firstCommitLink() {
      return `${this.error.externalBaseUrl}/-/commit/${this.error.firstReleaseVersion}`;
    },
    lastCommitLink() {
      return `${this.error.externalBaseUrl}/-/commit/${this.error.lastReleaseVersion}`;
    },
    shortFirstReleaseVersion() {
      return this.error.firstReleaseVersion.substr(0, 10);
    },
    shortLastReleaseVersion() {
      return this.error.lastReleaseVersion.substr(0, 10);
    },
    shortGitlabCommit() {
      return this.error.gitlabCommit.substr(0, 10);
    },
  },
  methods: {
    trackClickErrorLinkToSentryOptions,
  },
  CARD_CLASS,
  HEADER_CLASS,
  BODY_CLASS,
};
</script>

<template>
  <div>
    <div
      v-if="error"
      class="gl-display-flex gl-flex-wrap gl-justify-content-center gl-my-7 gl-row-gap-6"
    >
      <gl-card
        :class="$options.CARD_CLASS"
        :body-class="$options.BODY_CLASS"
        :header-class="$options.HEADER_CLASS"
        data-testid="error-count-card"
      >
        <template #header>
          <span>{{ __('Events') }}</span>
        </template>

        <template #default>
          <span>{{ error.count }}</span>
        </template>
      </gl-card>

      <gl-card
        :class="$options.CARD_CLASS"
        :body-class="$options.BODY_CLASS"
        :header-class="$options.HEADER_CLASS"
        data-testid="user-count-card"
      >
        <template #header>
          <span>{{ __('Users') }}</span>
        </template>

        <template #default>
          <span>{{ error.userCount }}</span>
        </template>
      </gl-card>

      <gl-card
        v-if="error.firstReleaseVersion"
        :class="$options.CARD_CLASS"
        :body-class="$options.BODY_CLASS"
        :header-class="$options.HEADER_CLASS"
        data-testid="first-release-card"
      >
        <template #header>
          <gl-icon v-gl-tooltip :title="shortFirstReleaseVersion" name="commit" class="gl-mr-1" />
          <span>{{ __('First seen') }}</span>
        </template>

        <template #default>
          <gl-link v-if="error.integrated" :href="firstCommitLink" class="gl-font-lg">
            <time-ago-tooltip :time="error.firstSeen" />
          </gl-link>

          <gl-link v-else :href="firstReleaseLink" target="_blank" class="gl-font-lg">
            <time-ago-tooltip :time="error.firstSeen" />
          </gl-link>
        </template>
      </gl-card>

      <gl-card
        v-if="error.lastReleaseVersion"
        :class="$options.CARD_CLASS"
        :body-class="$options.BODY_CLASS"
        :header-class="$options.HEADER_CLASS"
        data-testid="last-release-card"
      >
        <template #header>
          <gl-icon v-gl-tooltip :title="shortLastReleaseVersion" name="commit" class="gl-mr-1" />
          {{ __('Last seen') }}
        </template>

        <template #default>
          <gl-link v-if="error.integrated" :href="lastCommitLink" class="gl-font-lg">
            <time-ago-tooltip :time="error.lastSeen" />
          </gl-link>
          <gl-link v-else :href="lastReleaseLink" target="_blank" class="gl-font-lg">
            <time-ago-tooltip :time="error.lastSeen" />
          </gl-link>
        </template>
      </gl-card>

      <gl-card
        v-if="error.gitlabCommit"
        :class="$options.CARD_CLASS"
        :body-class="$options.BODY_CLASS"
        :header-class="$options.HEADER_CLASS"
        data-testid="gitlab-commit-card"
      >
        <template #header>
          {{ __('GitLab commit') }}
        </template>

        <template #default>
          <gl-link :href="error.gitlabCommitPath" class="gl-font-lg">
            {{ shortGitlabCommit }}
          </gl-link>
        </template>
      </gl-card>
    </div>
    <div v-if="!error.integrated" class="py-3">
      <span class="gl-font-weight-bold">{{ __('Sentry event') }}:</span>
      <gl-link
        v-track-event="trackClickErrorLinkToSentryOptions(error.externalUrl)"
        :href="error.externalUrl"
        target="_blank"
        data-testid="external-url-link"
      >
        <span class="text-truncate">{{ error.externalUrl }}</span>
        <gl-icon name="external-link" class="ml-1 flex-shrink-0" />
      </gl-link>
    </div>
  </div>
</template>