import 'focus-visible/dist/focus-visible.js' ; import * as React from 'react' ; import * as ReactDOM from 'react-dom' ; import { App } from '@client/App' ; import registerServiceWorker from '@client/registerServiceWorker' ; import { createStore } from '@client/store' ; import * as actions from '@client/notification/actions' ; import { storage } from '@client/storage' ; import * as Sentry from '@sentry/browser' ; import * as LogRocket from 'logrocket' ; import { SubmissionController } from '@client/SubmissionController' ; import * as pdfjs from 'pdfjs-dist/build/pdf' ; import * as pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry' ; pdfjs . GlobalWorkerOptions . workerSrc = pdfjsWorker ; storage . configStorage ( 'OpenCRVS' ) ; const { store , history } = createStore ( ) ; if ( window . location . hostname !== 'localhost' && window . location . hostname !== '127.0.0.1' ) { Sentry . init ( { release : process . env . REACT_APP_VERSION , environment : process . env . NODE_ENV , dsn : window . config . SENTRY } ) ; LogRocket . init ( window . config . LOGROCKET , { release : process . env . REACT_APP_VERSION } ) ; Sentry . configureScope ( ( scope ) => { scope . addEventProcessor ( async ( event ) => { if ( ! event . extra ) { event . extra = { } ; } const sessionUrl = await new Promise ( ( resolve ) => { LogRocket . getSessionURL ( ( url ) => { resolve ( url ) ; } ) ; } ) ; event . extra . sessionURL = sessionUrl ; return event ; } ) ; } ) ; } function onNewContentAvailable ( waitingSW ) { if ( waitingSW ) { waitingSW . postMessage ( 'skipWaiting' ) ; window . location . reload ( ) ; } } function onBackGroundSync ( ) { if ( typeof BroadcastChannel === 'undefined' ) { return ; } const channel = new BroadcastChannel ( window . config . BACKGROUND_SYNC_BROADCAST_CHANNEL ) ; channel . onmessage = ( e ) => { const action = actions . showBackgroundSyncedNotification ( ) ; store . dispatch ( action ) ; } ; } onBackGroundSync ( ) ; ReactDOM . render ( < App store = { store } history = { history } / > , document . getElementById ( 'root' ) ) ; registerServiceWorker ( onNewContentAvailable ) ; new SubmissionController ( store ) . start ( ) ;