diff --git a/package.json b/package.json index c685d1ec238a16a6a132dbefb6f6e460be3a941d..27fba878256337626164454753d61354ddb8fa51 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,7 @@ "@material-ui/core": "~4.12.0", "@material-ui/styles": "^4.11.3", "@reduxjs/toolkit": "^1.9.5", - "@sentry/react": "^7.21.1", - "@sentry/tracing": "^7.21.1", + "@sentry/react": "^8.26.0", "classnames": "^2.5.1", "cozy-bar": "8.15.0", "cozy-client": "40.6.0", diff --git a/src/components/Options/ExportData/Modals/exportLoadingModal.tsx b/src/components/Options/ExportData/Modals/exportLoadingModal.tsx index e8caa16c8cf0632deb8e639c4ce53d461777a5bb..b9d6f207ab1da05e62fb25c2f3eb05e35f1aea3f 100644 --- a/src/components/Options/ExportData/Modals/exportLoadingModal.tsx +++ b/src/components/Options/ExportData/Modals/exportLoadingModal.tsx @@ -1,220 +1,220 @@ -import { Button } from '@material-ui/core' -import Dialog from '@material-ui/core/Dialog' -import * as Sentry from '@sentry/react' -import CloseIcon from 'assets/icons/ico/close.svg' -import StyledIconButton from 'components/CommonKit/IconButton/StyledIconButton' -import Loader from 'components/Loader/Loader' -import { useClient } from 'cozy-client' -import { useI18n } from 'cozy-ui/transpiled/react/I18n' -import { FluidType, TimeStep } from 'enums' -import FileSaver from 'file-saver' -import { Dataload, TimePeriod } from 'models' -import React, { useCallback, useEffect } from 'react' -import ConsumptionDataManager from 'services/consumption.service' -import EnedisMonthlyAnalysisDataService from 'services/enedisMonthlyAnalysisData.service' -import { formatTwoDigits, getFluidName } from 'utils/utils' -import * as XLSX from 'xlsx' -import './exportLoadingModal.scss' - -interface ExportDataRow { - [key: string]: string | number -} - -interface ExportDataSheet { - fluidName: string - data: ExportDataRow[] -} - -interface ExportLoadingModalProps { - open: boolean - handleCloseClick: () => void - handleDone: (e?: unknown) => void - selectedFluids: FluidType[] -} - -const ExportLoadingModal = ({ - open, - handleCloseClick, - handleDone, - selectedFluids, -}: ExportLoadingModalProps) => { - const { t } = useI18n() - const client = useClient() - - const fileType = - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8' - const fileExtension = '.xlsx' - - const exportToXlsx = ( - exportDataSheets: ExportDataSheet[], - fileName: string - ) => { - const wb = XLSX.utils.book_new() - for (const dataSheet of exportDataSheets) { - const ws = XLSX.utils.json_to_sheet(dataSheet.data) - XLSX.utils.book_append_sheet(wb, ws, dataSheet.fluidName) - } - const excelBuffer = XLSX.write(wb, { bookType: 'xlsx', type: 'array' }) - const data = new Blob([excelBuffer], { type: fileType }) - FileSaver.saveAs(data, fileName + fileExtension) - } - - const buildDataRow = useCallback( - async ( - dataload: Dataload, - fluidType: FluidType - ): Promise<ExportDataRow> => { - const dataRow: ExportDataRow = {} - const fluidName = getFluidName(fluidType) - dataRow[t('export.month')] = formatTwoDigits(dataload.date.month) - dataRow[t('export.year')] = dataload.date.year - dataRow[ - `${t('export.consumption')} (${t('FLUID.' + fluidName + '.UNIT')})` - ] = dataload.value - if (fluidType === FluidType.ELECTRICITY) { - const emas = new EnedisMonthlyAnalysisDataService(client) - const maxPowerEntities = await emas.getMaxPowerByDate( - dataload.date.year, - dataload.date.month - ) - if (maxPowerEntities) { - const maxLoad = maxPowerEntities.reduce((max, entity) => { - if (entity.load > max) { - return entity.load - } - return max - }, 0) - dataRow[t('export.maxpower')] = maxLoad - } - } - return dataRow - }, - [client, t] - ) - - const getExportDataSheet = useCallback( - async (fluidType: FluidType): Promise<ExportDataSheet | null> => { - const consumptionService = new ConsumptionDataManager(client) - const firstDataDate = await consumptionService.fetchAllFirstDateData( - [fluidType], - TimeStep.MONTH - ) - const lastDataDate = await consumptionService.fetchAllLastDateData( - [fluidType], - TimeStep.MONTH - ) - if (!firstDataDate[0] || !lastDataDate[0]) return null - - const timePeriod: TimePeriod = { - startDate: firstDataDate[0], - endDate: lastDataDate[0], - } - - const dataLoad = await consumptionService.getGraphData({ - timePeriod, - timeStep: TimeStep.MONTH, - fluidTypes: [fluidType], - isHome: false, - isExport: true, - }) - - if (!dataLoad?.actualData) return null - - const exportDataSheet: ExportDataSheet = { - fluidName: t(`FLUID.${FluidType[fluidType]}.LABEL`), - data: [], - } - - for (const data of dataLoad.actualData) { - if (data.value === -1) continue - const dataRow = await buildDataRow(data, fluidType) - exportDataSheet.data.push(dataRow) - } - return exportDataSheet - }, - [buildDataRow, client, t] - ) - - useEffect(() => { - let subscribed = true - const date = new Date() - - const exportData = async (): Promise<void> => { - try { - const exportDataSheets: ExportDataSheet[] = [] - for (const fluidType of selectedFluids) { - const exportDataFluid = await getExportDataSheet(fluidType) - if (exportDataFluid) { - exportDataSheets.push(exportDataFluid) - } - } - await new Promise(r => setTimeout(r, 2000)) - if (subscribed) { - exportToXlsx( - exportDataSheets, - 'ecolyo_data_' + date.toLocaleDateString() - ) - handleDone() - } - } catch (e) { - Sentry.captureException(e) - handleDone(e) - } - } - - if (subscribed && open) { - exportData() - } - return () => { - subscribed = false - } - }, [getExportDataSheet, handleDone, open, selectedFluids]) - - return ( - <Dialog - open={open} - onClose={(_event, reason) => { - if (reason !== 'backdropClick' && reason !== 'escapeKeyDown') { - handleCloseClick() - } - }} - aria-labelledby="accessibility-title" - classes={{ - root: 'modal-root', - paper: 'modal-paper', - }} - > - <div id="accessibility-title"> - {t('export.modal_loading.accessibility_title')} - </div> - - <div className="modal-loading-root"> - <StyledIconButton - icon={CloseIcon} - sized={18} - onClick={handleCloseClick} - aria-label={t('export.button_close')} - className="modal-paper-close-button" - /> - <div className="content"> - <div className="icon-main"> - <Loader color="gold" /> - </div> - <div className="text-16-bold subtitle"> - {t('export.modal_loading.text1')} - </div> - <div>{t('export.modal_loading.text2')}</div> - <Button - aria-label={t('export.modal_loading.button_cancel')} - onClick={handleCloseClick} - className="btnSecondary" - > - {t('export.modal_loading.button_cancel')} - </Button> - </div> - </div> - </Dialog> - ) -} - -export default ExportLoadingModal +import { Button } from '@material-ui/core' +import Dialog from '@material-ui/core/Dialog' +import * as Sentry from '@sentry/react' +import CloseIcon from 'assets/icons/ico/close.svg' +import StyledIconButton from 'components/CommonKit/IconButton/StyledIconButton' +import Loader from 'components/Loader/Loader' +import { useClient } from 'cozy-client' +import { useI18n } from 'cozy-ui/transpiled/react/I18n' +import { FluidType, TimeStep } from 'enums' +import FileSaver from 'file-saver' +import { Dataload, TimePeriod } from 'models' +import React, { useCallback, useEffect } from 'react' +import ConsumptionDataManager from 'services/consumption.service' +import EnedisMonthlyAnalysisDataService from 'services/enedisMonthlyAnalysisData.service' +import { formatTwoDigits, getFluidName } from 'utils/utils' +import * as XLSX from 'xlsx' +import './exportLoadingModal.scss' + +interface ExportDataRow { + [key: string]: string | number +} + +interface ExportDataSheet { + fluidName: string + data: ExportDataRow[] +} + +interface ExportLoadingModalProps { + open: boolean + handleCloseClick: () => void + handleDone: (e?: unknown) => void + selectedFluids: FluidType[] +} + +const ExportLoadingModal = ({ + open, + handleCloseClick, + handleDone, + selectedFluids, +}: ExportLoadingModalProps) => { + const { t } = useI18n() + const client = useClient() + + const fileType = + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8' + const fileExtension = '.xlsx' + + const exportToXlsx = ( + exportDataSheets: ExportDataSheet[], + fileName: string + ) => { + const wb = XLSX.utils.book_new() + for (const dataSheet of exportDataSheets) { + const ws = XLSX.utils.json_to_sheet(dataSheet.data) + XLSX.utils.book_append_sheet(wb, ws, dataSheet.fluidName) + } + const excelBuffer = XLSX.write(wb, { bookType: 'xlsx', type: 'array' }) + const data = new Blob([excelBuffer], { type: fileType }) + FileSaver.saveAs(data, fileName + fileExtension) + } + + const buildDataRow = useCallback( + async ( + dataload: Dataload, + fluidType: FluidType + ): Promise<ExportDataRow> => { + const dataRow: ExportDataRow = {} + const fluidName = getFluidName(fluidType) + dataRow[t('export.month')] = formatTwoDigits(dataload.date.month) + dataRow[t('export.year')] = dataload.date.year + dataRow[ + `${t('export.consumption')} (${t('FLUID.' + fluidName + '.UNIT')})` + ] = dataload.value + if (fluidType === FluidType.ELECTRICITY) { + const emas = new EnedisMonthlyAnalysisDataService(client) + const maxPowerEntities = await emas.getMaxPowerByDate( + dataload.date.year, + dataload.date.month + ) + if (maxPowerEntities) { + const maxLoad = maxPowerEntities.reduce((max, entity) => { + if (entity.load > max) { + return entity.load + } + return max + }, 0) + dataRow[t('export.maxpower')] = maxLoad + } + } + return dataRow + }, + [client, t] + ) + + const getExportDataSheet = useCallback( + async (fluidType: FluidType): Promise<ExportDataSheet | null> => { + const consumptionService = new ConsumptionDataManager(client) + const firstDataDate = await consumptionService.fetchAllFirstDateData( + [fluidType], + TimeStep.MONTH + ) + const lastDataDate = await consumptionService.fetchAllLastDateData( + [fluidType], + TimeStep.MONTH + ) + if (!firstDataDate[0] || !lastDataDate[0]) return null + + const timePeriod: TimePeriod = { + startDate: firstDataDate[0], + endDate: lastDataDate[0], + } + + const dataLoad = await consumptionService.getGraphData({ + timePeriod, + timeStep: TimeStep.MONTH, + fluidTypes: [fluidType], + isHome: false, + isExport: true, + }) + + if (!dataLoad?.actualData) return null + + const exportDataSheet: ExportDataSheet = { + fluidName: t(`FLUID.${FluidType[fluidType]}.LABEL`), + data: [], + } + + for (const data of dataLoad.actualData) { + if (data.value === -1) continue + const dataRow = await buildDataRow(data, fluidType) + exportDataSheet.data.push(dataRow) + } + return exportDataSheet + }, + [buildDataRow, client, t] + ) + + useEffect(() => { + let subscribed = true + const date = new Date() + + const exportData = async (): Promise<void> => { + try { + const exportDataSheets: ExportDataSheet[] = [] + for (const fluidType of selectedFluids) { + const exportDataFluid = await getExportDataSheet(fluidType) + if (exportDataFluid) { + exportDataSheets.push(exportDataFluid) + } + } + await new Promise(r => setTimeout(r, 2000)) + if (subscribed) { + exportToXlsx( + exportDataSheets, + 'ecolyo_data_' + date.toLocaleDateString() + ) + handleDone() + } + } catch (e) { + Sentry.captureException(e) + handleDone(e) + } + } + + if (subscribed && open) { + exportData() + } + return () => { + subscribed = false + } + }, [getExportDataSheet, handleDone, open, selectedFluids]) + + return ( + <Dialog + open={open} + onClose={(_event, reason) => { + if (reason !== 'backdropClick' && reason !== 'escapeKeyDown') { + handleCloseClick() + } + }} + aria-labelledby="accessibility-title" + classes={{ + root: 'modal-root', + paper: 'modal-paper', + }} + > + <div id="accessibility-title"> + {t('export.modal_loading.accessibility_title')} + </div> + + <div className="modal-loading-root"> + <StyledIconButton + icon={CloseIcon} + sized={18} + onClick={handleCloseClick} + aria-label={t('export.button_close')} + className="modal-paper-close-button" + /> + <div className="content"> + <div className="icon-main"> + <Loader color="gold" /> + </div> + <div className="text-16-bold subtitle"> + {t('export.modal_loading.text1')} + </div> + <div>{t('export.modal_loading.text2')}</div> + <Button + aria-label={t('export.modal_loading.button_cancel')} + onClick={handleCloseClick} + className="btnSecondary" + > + {t('export.modal_loading.button_cancel')} + </Button> + </div> + </div> + </Dialog> + ) +} + +export default ExportLoadingModal diff --git a/src/components/Splash/SplashRoot.tsx b/src/components/Splash/SplashRoot.tsx index 61e2d7af4ba085a00813f57c29f32cd5ef6adf7e..b95191a5aeaad64a7cd28a7c5b562105d49bb4fd 100644 --- a/src/components/Splash/SplashRoot.tsx +++ b/src/components/Splash/SplashRoot.tsx @@ -182,187 +182,191 @@ const SplashRoot = ({ fadeTimer = 1000, children }: SplashRootProps) => { useEffect(() => { let subscribed = true async function loadData() { - const initializationService = new InitializationService( - client, - setInitStepErrors - ) - const customPopupService = new CustomPopupService(client) - const partnersInfoService = new PartnersInfoService(client) - const ms = new MigrationService(client, setInitStepErrors) const startTime = performance.now() - const transaction = Sentry.startTransaction({ name: 'Initialize app' }) - try { - console.group('Initialization logs') - // Run init steps in parallel - setInitStep(InitSteps.PROFILE) - const [ - termsStatus, - , - profile, - profileType, - profileEcogesture, - fluidStatus, - ] = await Promise.all([ - initializationService.initConsent(), - initializationService.initFluidPrices(), - initializationService.initProfile(), - initializationService.initProfileType(), - initializationService.initProfileEcogesture(), - initializationService.initFluidStatus(), - ]) - if (subscribed) dispatch(updateTermsStatus(termsStatus)) - - setInitStep(InitSteps.MIGRATION) - const migrationsResult = await ms.runMigrations(migrations) - // Init last release notes when they exist - dispatch( - showReleaseNotes({ - notes: migrationsResult.notes, - redirectLink: migrationsResult.redirectLink, - show: migrationsResult.show, - }) + Sentry.startSpan({ name: 'Initialize app' }, async () => { + const initializationService = new InitializationService( + client, + setInitStepErrors ) - if (subscribed && profile) { - setValidExploration(UserExplorationID.EXPLORATION007) - setInitStep(InitSteps.CHALLENGES) + const customPopupService = new CustomPopupService(client) + const partnersInfoService = new PartnersInfoService(client) + const ms = new MigrationService(client, setInitStepErrors) + try { + console.group('Initialization logs') + // Run init steps in parallel + setInitStep(InitSteps.PROFILE) const [ - duelHash, - quizHash, - challengeHash, - explorationHash, - analysisResult, + termsStatus, + , + profile, + profileType, + profileEcogesture, + fluidStatus, ] = await Promise.all([ - initializationService.initDuelEntity(profile.duelHash), - initializationService.initQuizEntity(profile.quizHash), - initializationService.initExplorationEntity(profile.challengeHash), - initializationService.initChallengeEntity(profile.explorationHash), - initializationService.initAnalysis(profile), + initializationService.initConsent(), + initializationService.initFluidPrices(), + initializationService.initProfile(), + initializationService.initProfileType(), + initializationService.initProfileEcogesture(), + initializationService.initFluidStatus(), ]) - const updatedProfile: Partial<Profile> = { - duelHash, - quizHash, - challengeHash, - explorationHash, - monthlyAnalysisDate: analysisResult.monthlyAnalysisDate, - haveSeenLastAnalysis: analysisResult.haveSeenLastAnalysis, - } - dispatch(updateProfile(updatedProfile)) - dispatch(setAnalysisMonth(analysisResult.monthlyAnalysisDate)) - if (profileType) { - await loadProfileType(profileType) - } - if (profileEcogesture) { - dispatch(setProfileEcogesture(profileEcogesture)) - } - dispatch(toggleAnalysisNotification(!profile.haveSeenLastAnalysis)) - } + if (subscribed) dispatch(updateTermsStatus(termsStatus)) - // Process fluids status - if (subscribed) { - dispatch(setFluidStatus(fluidStatus)) - let lastDataDate = DateTime.fromISO('0001-01-01') - for (const fluid of fluidStatus) { - if (fluid.lastDataDate && fluid.lastDataDate > lastDataDate) { - lastDataDate = fluid.lastDataDate + setInitStep(InitSteps.MIGRATION) + const migrationsResult = await ms.runMigrations(migrations) + // Init last release notes when they exist + dispatch( + showReleaseNotes({ + notes: migrationsResult.notes, + redirectLink: migrationsResult.redirectLink, + show: migrationsResult.show, + }) + ) + if (subscribed && profile) { + setValidExploration(UserExplorationID.EXPLORATION007) + setInitStep(InitSteps.CHALLENGES) + const [ + duelHash, + quizHash, + challengeHash, + explorationHash, + analysisResult, + ] = await Promise.all([ + initializationService.initDuelEntity(profile.duelHash), + initializationService.initQuizEntity(profile.quizHash), + initializationService.initExplorationEntity( + profile.challengeHash + ), + initializationService.initChallengeEntity( + profile.explorationHash + ), + initializationService.initAnalysis(profile), + ]) + const updatedProfile: Partial<Profile> = { + duelHash, + quizHash, + challengeHash, + explorationHash, + monthlyAnalysisDate: analysisResult.monthlyAnalysisDate, + haveSeenLastAnalysis: analysisResult.haveSeenLastAnalysis, } + dispatch(updateProfile(updatedProfile)) + dispatch(setAnalysisMonth(analysisResult.monthlyAnalysisDate)) + if (profileType) { + await loadProfileType(profileType) + } + if (profileEcogesture) { + dispatch(setProfileEcogesture(profileEcogesture)) + } + dispatch(toggleAnalysisNotification(!profile.haveSeenLastAnalysis)) } - } - // Init Challenge - const userChallengeList = - await initializationService.initUserChallenges(fluidStatus) - if (subscribed) { - dispatch(setUserChallengeList(userChallengeList)) - const filteredCurrentOngoingChallenge = userChallengeList.filter( - challenge => challenge.state === UserChallengeState.ONGOING - ) - // Set Notification if exploration state is notification - if ( - filteredCurrentOngoingChallenge[0]?.exploration.state === - UserExplorationState.NOTIFICATION - ) { - dispatch(toggleChallengeExplorationNotification(true)) + + // Process fluids status + if (subscribed) { + dispatch(setFluidStatus(fluidStatus)) + let lastDataDate = DateTime.fromISO('0001-01-01') + for (const fluid of fluidStatus) { + if (fluid.lastDataDate && fluid.lastDataDate > lastDataDate) { + lastDataDate = fluid.lastDataDate + } + } } - // Set action to notification if action is accomplished - if ( - filteredCurrentOngoingChallenge[0]?.action.state === - UserActionState.ONGOING - ) { - const actionService = new ActionService(client) - const updatedUserChallenge = await actionService.isActionDone( - filteredCurrentOngoingChallenge[0] + // Init Challenge + const userChallengeList = + await initializationService.initUserChallenges(fluidStatus) + if (subscribed) { + dispatch(setUserChallengeList(userChallengeList)) + const filteredCurrentOngoingChallenge = userChallengeList.filter( + challenge => challenge.state === UserChallengeState.ONGOING ) - if (updatedUserChallenge) { - dispatch(updateUserChallengeList(updatedUserChallenge)) + // Set Notification if exploration state is notification + if ( + filteredCurrentOngoingChallenge[0]?.exploration.state === + UserExplorationState.NOTIFICATION + ) { + dispatch(toggleChallengeExplorationNotification(true)) } - } - // Set Notification if action state is notification - if ( - filteredCurrentOngoingChallenge[0]?.action.state === - UserActionState.NOTIFICATION - ) { - dispatch(toggleChallengeActionNotification(true)) - } - const filteredCurrentDuelChallenge = userChallengeList.filter( - challenge => challenge.state === UserChallengeState.DUEL - ) - if ( - filteredCurrentDuelChallenge[0]?.duel.state === - UserDuelState.ONGOING - ) { - const { updatedUserChallenge, dataloads } = - await initializationService.initDuelProgress( - filteredCurrentDuelChallenge[0] - ) - if (subscribed) { - dispatch( - setChallengeConsumption({ - userChallenge: updatedUserChallenge, - currentDataload: dataloads, - }) + // Set action to notification if action is accomplished + if ( + filteredCurrentOngoingChallenge[0]?.action.state === + UserActionState.ONGOING + ) { + const actionService = new ActionService(client) + const updatedUserChallenge = await actionService.isActionDone( + filteredCurrentOngoingChallenge[0] ) - // Check is duel is done and display notification - const challengeService = new ChallengeService(client) - const { isDone } = await challengeService.isChallengeDone( - updatedUserChallenge, - dataloads - ) - dispatch(toggleChallengeDuelNotification(isDone)) + if (updatedUserChallenge) { + dispatch(updateUserChallengeList(updatedUserChallenge)) + } + } + // Set Notification if action state is notification + if ( + filteredCurrentOngoingChallenge[0]?.action.state === + UserActionState.NOTIFICATION + ) { + dispatch(toggleChallengeActionNotification(true)) + } + const filteredCurrentDuelChallenge = userChallengeList.filter( + challenge => challenge.state === UserChallengeState.DUEL + ) + if ( + filteredCurrentDuelChallenge[0]?.duel.state === + UserDuelState.ONGOING + ) { + const { updatedUserChallenge, dataloads } = + await initializationService.initDuelProgress( + filteredCurrentDuelChallenge[0] + ) + if (subscribed) { + dispatch( + setChallengeConsumption({ + userChallenge: updatedUserChallenge, + currentDataload: dataloads, + }) + ) + // Check is duel is done and display notification + const challengeService = new ChallengeService(client) + const { isDone } = await challengeService.isChallengeDone( + updatedUserChallenge, + dataloads + ) + dispatch(toggleChallengeDuelNotification(isDone)) + } } } - } - /** - * Load custom popup and partners info synchronously so these treatments don't block the loading - */ - customPopupService.getCustomPopup().then(async customPopup => { - if (profile && customPopup) { - await processCustomPopup(profile, customPopup) + /** + * Load custom popup and partners info synchronously so these treatments don't block the loading + */ + customPopupService.getCustomPopup().then(async customPopup => { + if (profile && customPopup) { + await processCustomPopup(profile, customPopup) + } + }) + partnersInfoService.getPartnersInfo().then(async partnersInfo => { + if (profile && partnersInfo) { + await processFluidsStatus(profile, partnersInfo) + await processPartnersStatus(profile, partnersInfo) + } + }) + + if (subscribed) { + logDuration('[Initialization] Finished successfully !', startTime) + setState(prev => ({ + ...prev, + splashStart: true, + })) } - }) - partnersInfoService.getPartnersInfo().then(async partnersInfo => { - if (profile && partnersInfo) { - await processFluidsStatus(profile, partnersInfo) - await processPartnersStatus(profile, partnersInfo) + } catch (error: any) { + if (error.message === 'Failed to fetch' && !initStepErrors) { + setInitStepErrors(InitStepsErrors.UNKNOWN_ERROR) } - }) - - if (subscribed) { - logDuration('[Initialization] Finished successfully !', startTime) - setState(prev => ({ - ...prev, - splashStart: true, - })) - } - } catch (error: any) { - if (error.message === 'Failed to fetch' && !initStepErrors) { - setInitStepErrors(InitStepsErrors.UNKNOWN_ERROR) + logApp.error(`[Initialization] Error : ${error}`) + Sentry.captureException(error) + } finally { + console.groupEnd() } - logApp.error(`[Initialization] Error : ${error}`) - Sentry.captureException(error) - } finally { - console.groupEnd() - transaction.finish() - } + }) } if (!initStepErrors) loadData() return () => { diff --git a/src/targets/browser/index.tsx b/src/targets/browser/index.tsx index 5ebc9a37ad05dbe2da2a668c4c961792463f9038..bc96684b433b78e645df943ec3fef607ef434a03 100644 --- a/src/targets/browser/index.tsx +++ b/src/targets/browser/index.tsx @@ -7,7 +7,6 @@ declare let Piwik: any import { ThemeProvider } from '@material-ui/core' import * as Sentry from '@sentry/react' -import { BrowserTracing } from '@sentry/tracing' import { theme } from 'components/theme' import CozyClient, { Client, CozyProvider } from 'cozy-client' import { isFlagshipApp } from 'cozy-device-helper' @@ -81,7 +80,7 @@ const setupApp = memoize(() => { !isLocal && Sentry.init({ dsn: __SENTRY_DSN__, - integrations: [new BrowserTracing()], + integrations: [Sentry.browserTracingIntegration()], // Set tracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production diff --git a/src/targets/public/index.tsx b/src/targets/public/index.tsx index 294a37fb174f66b2c2747e92b9ef5c22ec51a1f2..f36b93ae4cf144aeb931375d988f0b965df47688 100644 --- a/src/targets/public/index.tsx +++ b/src/targets/public/index.tsx @@ -3,7 +3,6 @@ declare let __SENTRY_DSN__: string import * as Sentry from '@sentry/react' -import { BrowserTracing } from '@sentry/tracing' import Unsubscribe from 'components/Options/Unsubscribe/Unsubscribe' import CozyClient, { Client, CozyProvider } from 'cozy-client' import { isFlagshipApp } from 'cozy-device-helper' @@ -63,7 +62,7 @@ const setupApp = memoize(() => { !isLocal && Sentry.init({ dsn: __SENTRY_DSN__, - integrations: [new BrowserTracing()], + integrations: [Sentry.browserTracingIntegration()], // Set tracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production diff --git a/yarn.lock b/yarn.lock index 13c8840005c17d7744dfc55723d5782fc3fc57fe..91f8615bc14105a123a8e18012d45cdf861c5e5a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2556,15 +2556,56 @@ resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.2.1.tgz#812edd4104a15a493dda1ccac0b352270d7a188c" integrity sha512-XiY0IsyHR+DXYS5vBxpoBe/8veTeoRpMHP+vDosLZxL5bnpetzI0igkxkLZS235ldLzyfkxF+2divEwWHP3vMQ== -"@sentry/browser@7.21.1": - version "7.21.1" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.21.1.tgz#bffa3ea19050c06400107d2297b9802f9719f98b" - integrity sha512-cS2Jz2+fs9+4pJqLJPtYqGyY97ywJDWAWIR1Yla3hs1QQuH6m0Nz3ojZD1gE2eKH9mHwkGbnNAh+hHcrYrfGzw== - dependencies: - "@sentry/core" "7.21.1" - "@sentry/types" "7.21.1" - "@sentry/utils" "7.21.1" - tslib "^1.9.3" +"@sentry-internal/browser-utils@8.26.0": + version "8.26.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/browser-utils/-/browser-utils-8.26.0.tgz#3c76015e1bddde6775e6a7e115fbb494f247fed1" + integrity sha512-O2Tj+WK33/ZVp5STnz6ZL0OO+/Idk2KqsH0ITQkQmyZ2z0kdzWOeqK7s7q3/My6rB1GfPcyqPcBBv4dVv92FYQ== + dependencies: + "@sentry/core" "8.26.0" + "@sentry/types" "8.26.0" + "@sentry/utils" "8.26.0" + +"@sentry-internal/feedback@8.26.0": + version "8.26.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-8.26.0.tgz#c29a2a4d97d9a9b56344521f3dbb16e2c40d799e" + integrity sha512-hQtw1gg8n6ERK1UH47F7ZI1zOsbhu0J2VX+TrnkpaQR2FgxDW1oe9Ja6oCV4CQKuR4w+1ZI/Kj4imSt0K33kEw== + dependencies: + "@sentry/core" "8.26.0" + "@sentry/types" "8.26.0" + "@sentry/utils" "8.26.0" + +"@sentry-internal/replay-canvas@8.26.0": + version "8.26.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-8.26.0.tgz#005e4ebed631d0e505e117d42ae8bc64748628d1" + integrity sha512-2CFQW6f9aJHIo/DqmqYa9PaYoLn1o36ywc0h8oyGrD4oPCbrnE5F++PmTdc71GBODu41HBn/yoCTLmxOD+UjpA== + dependencies: + "@sentry-internal/replay" "8.26.0" + "@sentry/core" "8.26.0" + "@sentry/types" "8.26.0" + "@sentry/utils" "8.26.0" + +"@sentry-internal/replay@8.26.0": + version "8.26.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/replay/-/replay-8.26.0.tgz#7d01b1915343bf8ca3d9ef7500994d4a45f3785e" + integrity sha512-JDY7W2bswlp5c3483lKP4kcb75fHNwGNfwD8x8FsY9xMjv7nxeXjLpR5cCEk1XqPq2+n6w4j7mJOXhEXGiUIKg== + dependencies: + "@sentry-internal/browser-utils" "8.26.0" + "@sentry/core" "8.26.0" + "@sentry/types" "8.26.0" + "@sentry/utils" "8.26.0" + +"@sentry/browser@8.26.0": + version "8.26.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.26.0.tgz#749508ca8d1da857930f41430eb3a77102712f46" + integrity sha512-e5s6eKlwLZWzTwQcBwqyAGZMMuQROW9Z677VzwkSyREWAIkKjfH2VBxHATnNGc0IVkNHjD7iH3ixo3C0rLKM3w== + dependencies: + "@sentry-internal/browser-utils" "8.26.0" + "@sentry-internal/feedback" "8.26.0" + "@sentry-internal/replay" "8.26.0" + "@sentry-internal/replay-canvas" "8.26.0" + "@sentry/core" "8.26.0" + "@sentry/types" "8.26.0" + "@sentry/utils" "8.26.0" "@sentry/browser@^6.0.1": version "6.19.7" @@ -2587,14 +2628,13 @@ "@sentry/utils" "6.19.7" tslib "^1.9.3" -"@sentry/core@7.21.1": - version "7.21.1" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.21.1.tgz#d0423282d90875625802dfe380f9657e9242b72b" - integrity sha512-Og5wEEsy24fNvT/T7IKjcV4EvVK5ryY2kxbJzKY6GU2eX+i+aBl+n/vp7U0Es351C/AlTkS+0NOUsp2TQQFxZA== +"@sentry/core@8.26.0": + version "8.26.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.26.0.tgz#0673a9e2c5b699cf1bde1ed073a345cc393577da" + integrity sha512-g/tVmTZD4GNbLFf++hKJfBpcCAtduFEMLnbfa9iT/QEZjlmP+EzY+GsH9bafM5VsNe8DiOUp+kJKWtShzlVdBA== dependencies: - "@sentry/types" "7.21.1" - "@sentry/utils" "7.21.1" - tslib "^1.9.3" + "@sentry/types" "8.26.0" + "@sentry/utils" "8.26.0" "@sentry/hub@6.19.7": version "6.19.7" @@ -2614,36 +2654,26 @@ "@sentry/types" "6.19.7" tslib "^1.9.3" -"@sentry/react@^7.21.1": - version "7.21.1" - resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.21.1.tgz#275e6fd46212f608f382c7dde46d21e748f93491" - integrity sha512-w91PIUyX07mErKgrBQA+7ID8zFKrYDUYSOrFSHufg5DdPq4EpHiNDe/Yngg3e9ELhtr1AbCnEvx9wlvqLi3nZQ== +"@sentry/react@^8.26.0": + version "8.26.0" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-8.26.0.tgz#b4e72b9759fbf7d3c5ed37bb5ceb2e94b0d10fd1" + integrity sha512-dYoC0xzcqq8zmNMFoTWidhA7mVd3RDz/nAUn6C8yK/hkKA7bUknYCkhpESGLZfHaGwSKzeXRXKd/o/cgUVM9eA== dependencies: - "@sentry/browser" "7.21.1" - "@sentry/types" "7.21.1" - "@sentry/utils" "7.21.1" + "@sentry/browser" "8.26.0" + "@sentry/core" "8.26.0" + "@sentry/types" "8.26.0" + "@sentry/utils" "8.26.0" hoist-non-react-statics "^3.3.2" - tslib "^1.9.3" - -"@sentry/tracing@^7.21.1": - version "7.21.1" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.21.1.tgz#db02643e84960f1ea14b35fe75a93fc0bbca1fcb" - integrity sha512-b1BTPsRaNQpohzegoz59KGuBl+To651vEq0vMS4tCzSyIdxkYso3JCrjDdEqW/2MliQYANNVrUai2bmwmU9h1g== - dependencies: - "@sentry/core" "7.21.1" - "@sentry/types" "7.21.1" - "@sentry/utils" "7.21.1" - tslib "^1.9.3" "@sentry/types@6.19.7": version "6.19.7" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.19.7.tgz#c6b337912e588083fc2896eb012526cf7cfec7c7" integrity sha512-jH84pDYE+hHIbVnab3Hr+ZXr1v8QABfhx39KknxqKWr2l0oEItzepV0URvbEhB446lk/S/59230dlUUIBGsXbg== -"@sentry/types@7.21.1": - version "7.21.1" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.21.1.tgz#408a7b95a66ddc30c4359979594e03bee8f9fbdc" - integrity sha512-3/IKnd52Ol21amQvI+kz+WB76s8/LR5YvFJzMgIoI2S8d82smIr253zGijRXxHPEif8kMLX4Yt+36VzrLxg6+A== +"@sentry/types@8.26.0": + version "8.26.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-8.26.0.tgz#c999fdd9e52587570f723d2370244bad8f79b571" + integrity sha512-zKmh6SWsJh630rpt7a9vP4Cm4m1C2gDTUqUiH565CajCL/4cePpNWYrNwalSqsOSL7B9OrczA1+n6a6XvND+ng== "@sentry/utils@6.19.7": version "6.19.7" @@ -2653,13 +2683,12 @@ "@sentry/types" "6.19.7" tslib "^1.9.3" -"@sentry/utils@7.21.1": - version "7.21.1" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.21.1.tgz#96582345178015fd32fe9159c25c44ccf2f99d2a" - integrity sha512-F0W0AAi8tgtTx6ApZRI2S9HbXEA9ENX1phTZgdNNWcMFm1BNbc21XEwLqwXBNjub5nlA6CE8xnjXRgdZKx4kzQ== +"@sentry/utils@8.26.0": + version "8.26.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-8.26.0.tgz#c6629f0f2bc8cbc4fddd124770e9063b4e2d1c65" + integrity sha512-xvlPU9Hd2BlyT+FhWHGNwnxWqdVRk2AHnDtVcW4Ma0Ri5EwS+uy4Jeik5UkSv8C5RVb9VlxFmS8LN3I1MPJsLw== dependencies: - "@sentry/types" "7.21.1" - tslib "^1.9.3" + "@sentry/types" "8.26.0" "@sinclair/typebox@^0.24.1": version "0.24.43"