diff --git a/scripts/notarize.js b/scripts/notarize.js index 4c132bfb..64a2b9ae 100644 --- a/scripts/notarize.js +++ b/scripts/notarize.js @@ -6,9 +6,14 @@ exports.default = async function notarizing(context) { return } + if (!process.env.APPLE_ID || !process.env.APPLE_APP_SPECIFIC_PASSWORD || !process.env.APPLE_TEAM_ID) { + console.log('Skipping notarization') + return + } + const appName = context.packager.appInfo.productFilename - const notarized = await notarize({ + await notarize({ appPath: `${context.appOutDir}/${appName}.app`, appBundleId: 'com.kangfenmao.CherryStudio', appleId: process.env.APPLE_ID, @@ -16,7 +21,5 @@ exports.default = async function notarizing(context) { teamId: process.env.APPLE_TEAM_ID }) - console.log('Notarized:', notarized) - - return notarized + console.log('Notarized app:', appName) } diff --git a/src/renderer/src/init.ts b/src/renderer/src/init.ts index 46d07e8a..3562dcbf 100644 --- a/src/renderer/src/init.ts +++ b/src/renderer/src/init.ts @@ -1,26 +1,24 @@ import localforage from 'localforage' import KeyvStorage from '@kangfenmao/keyv-storage' import * as Sentry from '@sentry/electron/renderer' +import { isProduction } from './utils' -function initSentry() { - // Disable sentry in development mode - if (process?.env?.NODE_ENV === 'development') { - return +async function initSentry() { + if (await isProduction()) { + Sentry.init({ + integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()], + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 1.0, + + // Capture Replay for 10% of all sessions, + // plus for 100% of sessions with an error + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0 + }) } - - Sentry.init({ - integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()], - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for performance monitoring. - // We recommend adjusting this value in production - tracesSampleRate: 1.0, - - // Capture Replay for 10% of all sessions, - // plus for 100% of sessions with an error - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0 - }) } function init() { diff --git a/src/renderer/src/utils/index.ts b/src/renderer/src/utils/index.ts index 53c8c7de..f3da50db 100644 --- a/src/renderer/src/utils/index.ts +++ b/src/renderer/src/utils/index.ts @@ -98,3 +98,13 @@ export const firstLetter = (str?: string) => { export function isFreeModel(model: Model) { return (model.id + model.name).toLocaleLowerCase().includes('free') } + +export async function isProduction() { + const { isPackaged } = await window.api.getAppInfo() + return isPackaged +} + +export async function isDev() { + const isProd = await isProduction() + return !isProd +}