Skip to content

Commit

Permalink
fix(sentry): handle old integration tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
neSpecc committed Dec 21, 2024
1 parent 015c6e5 commit 450cc87
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/assets/catalog/sentry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion src/components/catalog/catchers/guides/sentry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@
</template>
<template #content>
{{ $t('components.catalog.hereIsDSN') }}
<TokenBlock :token="computedDSN" />
<TokenBlock v-if="computedDSN" :token="computedDSN" />
<template v-else>
<p style="color: var(--color-indicator-critical);">
{{ $t('projects.settings.integrations.sentryDSNTextNoToken') }}
</p>
<UiButton
:href="`/project/${project.id}/settings/integrations`"
:content="$t('projects.settings.general.title')"
/>
</template>
</template>
</GuideStepBlock>
<GuideStepBlock
Expand All @@ -42,13 +51,15 @@ import GuideStepBlock from '../../GuideStepBlock';
import GuideHeader from '../../GuidePageHeader';
import TokenBlock from '../../../project/TokenBlock';
import { getSentryDSN } from '../../../../utils';
import UiButton from '../../../utils/UiButton';
export default {
name: 'SetupJavascriptCatcher',
components: {
GuideStepBlock,
GuideHeader,
TokenBlock,
UiButton,
},
data() {
return {
Expand Down
4 changes: 4 additions & 0 deletions src/components/project/settings/Integrations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@
{{ $t('projects.settings.integrations.sentryDSNText') }}
</div>
<TokenBlock
v-if="sentryDSN"
class="projects-integrations-settings-page__token"
:token="sentryDSN"
/>
<p v-else style="color: var(--color-indicator-critical);">
{{ $t('projects.settings.integrations.sentryDSNTextNoToken') }}
</p>
</div>
</template>

Expand Down
3 changes: 2 additions & 1 deletion src/i18n/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@
"description": "After this action, Hawk will stop accepting events with the old integration token. You will need to replace it with a new one in your project."
},
"sentryDSN": "Sentry DSN",
"sentryDSNText": "If you use Sentry SDK, you can use this DSN to send errors to Hawk."
"sentryDSNText": "If you use Sentry SDK, you can use this DSN to send errors to Hawk.",
"sentryDSNTextNoToken": "It seems, you have an old integration token. Try to revoke it and get the new one."
},
"notifications": {
"title": "Notifications",
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/messages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@
"description": "После этого действия Хоук перестанет принимать ивенты со старым интеграционным токеном. Вам будет необходимо заменить его на новый в вашем проекте."
},
"sentryDSN": "Sentry DSN",
"sentryDSNText": "Если вы используете Sentry SDK, вы можете использовать этот DSN для того, чтобы отправлять ошибки в Хоук."
"sentryDSNText": "Если вы используете Sentry SDK, вы можете использовать этот DSN для того, чтобы отправлять ошибки в Хоук.",
"sentryDSNTextNoToken": "Кажется, у вас старый интеграционный токен. Попробуйте отозвать его и получить новый."
},
"notifications": {
"title": "Уведомления",
Expand Down
6 changes: 5 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,5 +509,9 @@ function getHexIntegrationToken(token: string): string {
* @param token - stringified integration token
*/
export function getSentryDSN(token: string): string {
return `https://${getHexIntegrationToken(token)}@k1.hawk.so/0`;
try {
return `https://${getHexIntegrationToken(token)}@k1.hawk.so/0`;
} catch (e) {
return '';
}
}

0 comments on commit 450cc87

Please sign in to comment.