Send username/id to Sentry
This commit is contained in:
parent
2cdfaf4871
commit
a98dfd8c11
2 changed files with 23 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
|||
import { selectAccount } from 'soapbox/selectors';
|
||||
import { setSentryAccount } from 'soapbox/sentry';
|
||||
import KVStore from 'soapbox/storage/kv-store';
|
||||
import { getAuthUserId, getAuthUserUrl } from 'soapbox/utils/auth';
|
||||
|
||||
|
@ -8,6 +9,7 @@ import { loadCredentials } from './auth';
|
|||
import { importFetchedAccount } from './importer';
|
||||
|
||||
import type { AxiosError, RawAxiosRequestHeaders } from 'axios';
|
||||
import type { Account } from 'soapbox/schemas';
|
||||
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||
import type { APIEntity } from 'soapbox/types/entities';
|
||||
|
||||
|
@ -88,10 +90,14 @@ const fetchMeRequest = () => ({
|
|||
type: ME_FETCH_REQUEST,
|
||||
});
|
||||
|
||||
const fetchMeSuccess = (me: APIEntity) => ({
|
||||
type: ME_FETCH_SUCCESS,
|
||||
me,
|
||||
});
|
||||
const fetchMeSuccess = (account: Account) => {
|
||||
setSentryAccount(account);
|
||||
|
||||
return {
|
||||
type: ME_FETCH_SUCCESS,
|
||||
me: account,
|
||||
};
|
||||
};
|
||||
|
||||
const fetchMeFail = (error: APIEntity) => ({
|
||||
type: ME_FETCH_FAIL,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import type { Account } from './schemas';
|
||||
|
||||
/** Start Sentry. */
|
||||
async function startSentry(dsn: string): Promise<void> {
|
||||
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 };
|
Loading…
Reference in a new issue