File tree Expand file tree Collapse file tree 2 files changed +29
-15
lines changed
packages/gatsby/src/redux Expand file tree Collapse file tree 2 files changed +29
-15
lines changed Original file line number Diff line number Diff line change 1
1
const _ = require ( `lodash` )
2
2
const path = require ( `path` )
3
3
const v8 = require ( `v8` )
4
+ const telemetry = require ( `gatsby-telemetry` )
4
5
const reporter = require ( `gatsby-cli/lib/reporter` )
5
-
6
6
const writeToCache = jest . spyOn ( require ( `../persist` ) , `writeToCache` )
7
7
const v8Serialize = jest . spyOn ( v8 , `serialize` )
8
8
const v8Deserialize = jest . spyOn ( v8 , `deserialize` )
@@ -150,6 +150,26 @@ describe(`redux db`, () => {
150
150
reporterInfo . mockClear ( )
151
151
} )
152
152
153
+ it ( `should have cache status telemetry event` , async ( ) => {
154
+ jest . spyOn ( telemetry , `trackCli` )
155
+
156
+ readState ( )
157
+
158
+ expect ( telemetry . trackCli ) . toHaveBeenCalledWith ( `CACHE_STATUS` , {
159
+ cacheStatus : `COLD` ,
160
+ } )
161
+
162
+ store . getState ( ) . nodes = getFakeNodes ( )
163
+
164
+ await saveState ( )
165
+
166
+ readState ( )
167
+
168
+ expect ( telemetry . trackCli ) . toHaveBeenCalledWith ( `CACHE_STATUS` , {
169
+ cacheStatus : `WARM` ,
170
+ } )
171
+ } )
172
+
153
173
it ( `should write redux cache to disk` , async ( ) => {
154
174
createPages ( defaultPage )
155
175
Original file line number Diff line number Diff line change @@ -41,25 +41,19 @@ export const readState = (): IGatsbyState => {
41
41
// changes. Explicitly delete it here to cover case where user
42
42
// runs gatsby the first time after upgrading.
43
43
delete state [ `jsonDataPaths` ]
44
- telemetry . decorateEvent ( `BUILD_END` , {
45
- cacheStatus : `WARM` ,
46
- } )
47
- telemetry . decorateEvent ( `DEVELOP_STOP` , {
44
+
45
+ telemetry . trackCli ( `CACHE_STATUS` , {
48
46
cacheStatus : `WARM` ,
49
47
} )
48
+
50
49
return state
51
50
} catch ( e ) {
52
- // ignore errors.
51
+ telemetry . trackCli ( `CACHE_STATUS` , {
52
+ cacheStatus : `COLD` ,
53
+ } )
54
+
55
+ return { } as IGatsbyState
53
56
}
54
- // BUG: Would this not cause downstream bugs? seems likely. Why wouldn't we just
55
- // throw and kill the program?
56
- telemetry . decorateEvent ( `BUILD_END` , {
57
- cacheStatus : `COLD` ,
58
- } )
59
- telemetry . decorateEvent ( `DEVELOP_STOP` , {
60
- cacheStatus : `COLD` ,
61
- } )
62
- return { } as IGatsbyState
63
57
}
64
58
65
59
export interface IMultiDispatch {
You can’t perform that action at this time.
0 commit comments