Merge pull request #436 from Discours/feature/glitchtip

error collector connected
This commit is contained in:
Tony 2024-05-06 17:46:15 +03:00 committed by GitHub
commit a024080661
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 58 additions and 65 deletions

View File

@ -13,7 +13,7 @@ jobs:
run: npm ci
- name: Check types
run: npm run typecheck
run: npm run check:types
- name: Lint with Biome
run: npm run check:code

View File

@ -24,8 +24,8 @@
"lint:styles:fix": "stylelint **/*.{scss,css} --fix",
"preview": "vite preview",
"start": "vite",
"typecheck": "tsc --noEmit",
"typecheck:watch": "tsc --noEmit --watch"
"check:types": "tsc --noEmit",
"check:types:watch": "tsc --noEmit --watch"
},
"dependencies": {
"form-data": "4.0.0",

View File

@ -97,7 +97,12 @@ export const LoginForm = () => {
const { errors } = await signIn({ email: email(), password: password() })
console.error('[signIn errors]', errors)
if (errors?.length > 0) {
if (errors.some((error) => error.message.includes('bad user credentials'))) {
if (
errors.some(
(error) =>
error.message.includes('bad user credentials') || error.message.includes('user not found'),
)
) {
setValidationErrors((prev) => ({
...prev,
password: t('Something went wrong, check email and password'),

View File

@ -61,7 +61,12 @@ export const SendResetLinkForm = () => {
redirect_uri: window.location.origin,
})
console.debug('[SendResetLinkForm] authorizer response:', data)
if (errors?.some((error) => error.message.includes('bad user credentials'))) {
if (
errors?.some(
(error) =>
error.message.includes('bad user credentials') || error.message.includes('user not found'),
)
) {
setIsUserNotFound(true)
}
if (data.message) setMessage(data.message)

View File

@ -57,6 +57,7 @@ export const HeaderAuth = (props: Props) => {
toggleEditorPanel()
}
// FIXME: use or remove
const handleSaveClick = () => {
const hasTopics = form.selectedTopics?.length > 0
if (hasTopics) {
@ -110,7 +111,13 @@ export const HeaderAuth = (props: Props) => {
<div class={clsx('col-auto col-lg-7', styles.usernav)}>
<div class={styles.userControl}>
<Show when={isCreatePostButtonVisible() && author()?.id}>
<div class={clsx(styles.userControlItem, styles.userControlItemVerbose)}>
<div
class={clsx(
styles.userControlItem,
styles.userControlItemVerbose,
// styles.userControlItemCreate,
)}
>
<a href={getPagePath(router, 'create')}>
<span class={styles.textLabel}>{t('Create post')}</span>
<Icon name="pencil-outline" class={styles.icon} />
@ -217,8 +224,14 @@ export const HeaderAuth = (props: Props) => {
</div>
</Show>
<Show when={isCreatePostButtonVisible() && !author()?.id}>
<div class={clsx(styles.userControlItem, styles.userControlItemVerbose)}>
<Show when={isCreatePostButtonVisible() && !!author()?.id}>
<div
class={clsx(
styles.userControlItem,
styles.userControlItemVerbose,
// styles.userControlItemCreate,
)}
>
<a href={getPagePath(router, 'create')}>
<span class={styles.textLabel}>{t('Create post')}</span>
<Icon name="pencil-outline" class={styles.icon} />
@ -241,25 +254,19 @@ export const HeaderAuth = (props: Props) => {
</Show>
}
>
<Show
when={isSaveButtonVisible()}
fallback={
<div class={clsx(styles.userControlItem)}>
<a href={getPagePath(router, 'inbox')}>
<div classList={{ entered: page().path === '/inbox' }}>
<Icon name="inbox-white" class={styles.icon} />
<Icon name="inbox-white-hover" class={clsx(styles.icon, styles.iconHover)} />
</div>
</a>
</div>
}
>
<div class={clsx(styles.userControlItem, styles.userControlItemVerbose)}>
<button onClick={handleSaveClick}>
<span class={styles.textLabel}>{t('Save')}</span>
<Icon name="save" class={styles.icon} />
<Icon name="save" class={clsx(styles.icon, styles.iconHover)} />
</button>
<Show when={!isSaveButtonVisible()}>
<div
class={clsx(
styles.userControlItem,
// styles.userControlItemInbox
)}
>
<a href={getPagePath(router, 'inbox')}>
<div classList={{ entered: page().path === '/inbox' }}>
<Icon name="inbox-white" class={styles.icon} />
<Icon name="inbox-white-hover" class={clsx(styles.icon, styles.iconHover)} />
</div>
</a>
</div>
</Show>
</Show>

View File

@ -48,7 +48,7 @@ export const TopicBadge = (props: Props) => {
lang() === 'en' ? capitalize(props.topic.slug.replaceAll('-', ' ')) : props.topic.title
return (
<div class={clsx(styles.TopicBadge, { [styles.TopicBadgeSubscriptionsMode]: props.subscriptionsMode })}>
<div class={clsx(styles.TopicBadge, props.subscriptionsMode)}>
<div class={styles.content}>
<div class={styles.basicInfo}>
<Show when={props.subscriptionsMode}>

View File

@ -1,28 +0,0 @@
import { gql } from '@urql/core'
export default gql`
query MySubscriptionsQuery {
get_my_followed {
topics {
id
title
body
slug
}
authors {
id
name
slug
pic
created_at
}
communities {
id
name
slug
pic
created_at
}
}
}
`

View File

@ -1,7 +1,7 @@
import type { PageContextBuiltInClientWithClientRouting } from 'vike/types'
import type { PageContext } from './types'
// import * as Sentry from '@sentry/browser'
import { init as SentryInit, replayIntegration } from '@sentry/browser'
import i18next from 'i18next'
import HttpApi from 'i18next-http-backend'
import ICU from 'i18next-icu'
@ -9,7 +9,7 @@ import { hydrate } from 'solid-js/web'
import { App } from '../components/App'
import { initRouter } from '../stores/router'
// import { SENTRY_DSN } from '../utils/config'
import { GLITCHTIP_DSN } from '../utils/config'
import { resolveHydrationPromise } from '../utils/hydrationPromise'
let layoutReady = false
@ -20,13 +20,16 @@ export const render = async (pageContext: PageContextBuiltInClientWithClientRout
const { pathname, search } = window.location
const searchParams = Object.fromEntries(new URLSearchParams(search))
initRouter(pathname, searchParams)
/*
if (SENTRY_DSN) {
Sentry.init({
dsn: SENTRY_DSN,
})
}
*/
SentryInit({
dsn: GLITCHTIP_DSN,
tracesSampleRate: 0.01,
integrations: [replayIntegration()],
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
})
// eslint-disable-next-line import/no-named-as-default-member
await i18next
.use(HttpApi)

View File

@ -5,6 +5,7 @@ export const cdnUrl = 'https://cdn.discours.io'
export const thumborUrl = import.meta.env.PUBLIC_THUMBOR_URL || defaultThumborUrl
export const SENTRY_DSN = import.meta.env.PUBLIC_SENTRY_DSN || ''
export const GLITCHTIP_DSN = import.meta.env.PUBLIC_GLITCHTIP_DSN || ''
const defaultSearchUrl = 'https://search.discours.io'
export const searchUrl = import.meta.env.PUBLIC_SEARCH_URL || defaultSearchUrl