1
1
import React , { FunctionComponent , useEffect , useCallback } from 'react'
2
2
import { ServerError } from 'apollo-link-http-common'
3
3
import dynamic from 'next/dynamic'
4
- import { version } from '~/package.json'
5
- import ReactGA from 'react-ga'
6
- import Router , { useRouter } from 'next/router'
4
+
5
+ import { useRouter } from 'next/router'
7
6
import { ThemeProvider } from 'styled-components'
8
7
import { baseTheme , UIBase } from '@storystore/ui/dist/theme'
9
8
import { Root , HeaderContainer , Main , FooterContainer , Copyright , TabBarContainer , OfflineToast } from './App.styled'
10
9
11
10
import { useApp } from './useApp'
12
11
import { resolveImage } from '~/lib/resolveImage'
13
12
import { useStoryStore } from '~/hooks/useStoryStore/useStoryStore'
14
- import { useServiceWorker } from '~/hooks/useServiceWorker'
15
13
import useNetworkStatus from '~/hooks/useNetworkStatus'
16
14
17
15
import NextNprogress from 'nextjs-progressbar'
@@ -28,7 +26,6 @@ import IconBagActiveSvg from 'remixicon/icons/Finance/shopping-bag-fill.svg'
28
26
import IconHomeSvg from 'remixicon/icons/Buildings/store-2-line.svg'
29
27
import IconHomeActiveSvg from 'remixicon/icons/Buildings/store-2-fill.svg'
30
28
import CloudOff from 'remixicon/icons/Business/cloud-off-line.svg'
31
- import { FontStyles } from './FontStyles'
32
29
import { ToastsStyles } from './ToastsStyles'
33
30
import useValueUpdated from '~/hooks/useValueUpdated'
34
31
@@ -49,8 +46,6 @@ if (process.browser) {
49
46
}
50
47
51
48
export const App : FunctionComponent < AppProps > = ( { children } ) => {
52
- const workbox = useServiceWorker ( )
53
-
54
49
const { cartId, settings, setCartId } = useStoryStore ( )
55
50
56
51
const { queries, api } = useApp ( { cartId, footerBlockId : settings . footerBlockId } )
@@ -79,42 +74,6 @@ export const App: FunctionComponent<AppProps> = ({ children }) => {
79
74
}
80
75
} , [ setCartId , queries , api , cartId ] )
81
76
82
- /**
83
- * Update SW Cache on Route change
84
- */
85
- const handleRouteChange = useCallback (
86
- ( url , error ?: any ) => {
87
- if ( error || ! workbox ) return
88
-
89
- workbox . messageSW ( {
90
- type : 'CACHE_URLS' ,
91
- payload : {
92
- urlsToCache : [ url ] ,
93
- } ,
94
- } )
95
-
96
- ReactGA . pageview ( url )
97
- } ,
98
- [ workbox ]
99
- )
100
-
101
- useEffect ( ( ) => {
102
- Router . events . on ( 'routeChangeComplete' , handleRouteChange )
103
-
104
- return ( ) => {
105
- Router . events . off ( 'routeChangeComplete' , handleRouteChange )
106
- }
107
- } , [ handleRouteChange ] )
108
-
109
- useEffect ( ( ) => {
110
- if ( process . env . GOOGLE_ANALYTICS ) {
111
- /**
112
- * Google Analytics
113
- */
114
- ReactGA . initialize ( process . env . GOOGLE_ANALYTICS )
115
- }
116
- } , [ ] )
117
-
118
77
/**
119
78
* Offline Message
120
79
*/
@@ -135,22 +94,6 @@ export const App: FunctionComponent<AppProps> = ({ children }) => {
135
94
}
136
95
} , online )
137
96
138
- /**
139
- * Google Analytics
140
- */
141
- useEffect ( ( ) => {
142
- if ( ! process . env . GOOGLE_ANALYTICS ) return
143
- ReactGA . set ( { dimension1 : version } ) // version
144
-
145
- ReactGA . set ( { dimension2 : window . location . host } ) // release
146
-
147
- if ( settings . magentoUrl ) {
148
- ReactGA . set ( { dimension3 : new URL ( settings . magentoUrl ) . host } ) // endpoint
149
- }
150
-
151
- ReactGA . pageview ( window . location . pathname )
152
- } , [ settings ] )
153
-
154
97
if ( online && queries . app . error ) {
155
98
const networkError = queries . app . error ?. networkError as ServerError
156
99
@@ -196,7 +139,6 @@ export const App: FunctionComponent<AppProps> = ({ children }) => {
196
139
>
197
140
< NextNprogress color = { settings . colorAccent || baseTheme . colors . accent } startPosition = { 0.4 } stopDelayMs = { 200 } height = { 3 } options = { { showSpinner : false , easing : 'ease' } } />
198
141
< UIBase />
199
- < FontStyles />
200
142
< ToastsStyles />
201
143
202
144
{ /* Head Metadata */ }
0 commit comments