kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Send username/id to Sentry
rodzic
2cdfaf4871
commit
a98dfd8c11
|
@ -1,4 +1,5 @@
|
||||||
import { selectAccount } from 'soapbox/selectors';
|
import { selectAccount } from 'soapbox/selectors';
|
||||||
|
import { setSentryAccount } from 'soapbox/sentry';
|
||||||
import KVStore from 'soapbox/storage/kv-store';
|
import KVStore from 'soapbox/storage/kv-store';
|
||||||
import { getAuthUserId, getAuthUserUrl } from 'soapbox/utils/auth';
|
import { getAuthUserId, getAuthUserUrl } from 'soapbox/utils/auth';
|
||||||
|
|
||||||
|
@ -8,6 +9,7 @@ import { loadCredentials } from './auth';
|
||||||
import { importFetchedAccount } from './importer';
|
import { importFetchedAccount } from './importer';
|
||||||
|
|
||||||
import type { AxiosError, RawAxiosRequestHeaders } from 'axios';
|
import type { AxiosError, RawAxiosRequestHeaders } from 'axios';
|
||||||
|
import type { Account } from 'soapbox/schemas';
|
||||||
import type { AppDispatch, RootState } from 'soapbox/store';
|
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||||
import type { APIEntity } from 'soapbox/types/entities';
|
import type { APIEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
@ -88,10 +90,14 @@ const fetchMeRequest = () => ({
|
||||||
type: ME_FETCH_REQUEST,
|
type: ME_FETCH_REQUEST,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchMeSuccess = (me: APIEntity) => ({
|
const fetchMeSuccess = (account: Account) => {
|
||||||
|
setSentryAccount(account);
|
||||||
|
|
||||||
|
return {
|
||||||
type: ME_FETCH_SUCCESS,
|
type: ME_FETCH_SUCCESS,
|
||||||
me,
|
me: account,
|
||||||
});
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const fetchMeFail = (error: APIEntity) => ({
|
const fetchMeFail = (error: APIEntity) => ({
|
||||||
type: ME_FETCH_FAIL,
|
type: ME_FETCH_FAIL,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import type { Account } from './schemas';
|
||||||
|
|
||||||
/** Start Sentry. */
|
/** Start Sentry. */
|
||||||
async function startSentry(dsn: string): Promise<void> {
|
async function startSentry(dsn: string): Promise<void> {
|
||||||
const [Sentry, { Integrations: Integrations }] = await Promise.all([
|
const [Sentry, { Integrations: Integrations }] = await Promise.all([
|
||||||
|
@ -36,4 +38,14 @@ async function startSentry(dsn: string): Promise<void> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export { startSentry };
|
/** Associate the account with Sentry events. */
|
||||||
|
async function setSentryAccount(account: Account) {
|
||||||
|
const Sentry = await import('@sentry/react');
|
||||||
|
|
||||||
|
Sentry.setUser({
|
||||||
|
id: account.id,
|
||||||
|
username: account.acct,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export { startSentry, setSentryAccount };
|
Ładowanie…
Reference in New Issue