export electron sentry user id to ui
This commit is contained in:
parent
84e10837c0
commit
8ddf6a8820
|
@ -10,3 +10,5 @@ export const selectRootDirectory = async (): Promise<string> => {
|
|||
};
|
||||
|
||||
export { logToDisk, openLogDirectory } from '../services/logging';
|
||||
|
||||
export { getSentryUserID } from '../services/sentry';
|
||||
|
|
|
@ -39,7 +39,12 @@ import {
|
|||
setExportRecord,
|
||||
exists,
|
||||
} from './api/export';
|
||||
import { selectRootDirectory, logToDisk, openLogDirectory } from './api/common';
|
||||
import {
|
||||
selectRootDirectory,
|
||||
logToDisk,
|
||||
openLogDirectory,
|
||||
getSentryUserID,
|
||||
} from './api/common';
|
||||
import { fixHotReloadNext12 } from './utils/preload';
|
||||
import { isFolder, getDirFiles } from './api/fs';
|
||||
import { convertHEIC } from './api/heicConvert';
|
||||
|
@ -92,4 +97,5 @@ windowObject['ElectronAPIs'] = {
|
|||
registerUpdateEventListener,
|
||||
updateAndRestart,
|
||||
skipAppVersion,
|
||||
getSentryUserID,
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as Sentry from '@sentry/electron/dist/main';
|
||||
import { makeID } from '../utils/logging';
|
||||
import { keysStore } from '../stores/keys.store';
|
||||
|
||||
import { isDev } from '../utils/common';
|
||||
|
@ -38,7 +39,7 @@ export function logErrorSentry(
|
|||
}
|
||||
Sentry.captureException(err, {
|
||||
level: Sentry.Severity.Info,
|
||||
user: { id: getUserAnonymizedID() },
|
||||
user: { id: getSentryUserID() },
|
||||
contexts: {
|
||||
...(info && {
|
||||
info: info,
|
||||
|
@ -57,7 +58,7 @@ function errorWithContext(originalError: Error, context: string) {
|
|||
return errorWithContext;
|
||||
}
|
||||
|
||||
function getUserAnonymizedID() {
|
||||
export function getSentryUserID() {
|
||||
let anonymizeUserID = keysStore.get('AnonymizeUserID')?.id;
|
||||
if (!anonymizeUserID) {
|
||||
anonymizeUserID = makeID(6);
|
||||
|
@ -65,16 +66,3 @@ function getUserAnonymizedID() {
|
|||
}
|
||||
return anonymizeUserID;
|
||||
}
|
||||
|
||||
function makeID(length: number) {
|
||||
let result = '';
|
||||
const characters =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(
|
||||
Math.floor(Math.random() * charactersLength)
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -6,3 +6,16 @@ export function setupLogging() {
|
|||
log.transports.file.maxSize = MAX_LOG_SIZE;
|
||||
log.transports.console.level = false;
|
||||
}
|
||||
|
||||
export function makeID(length: number) {
|
||||
let result = '';
|
||||
const characters =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(
|
||||
Math.floor(Math.random() * charactersLength)
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue