UNPKG

1.22 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.telemetryReducer = void 0;
5const initialState = {
6 gatsbyImageSourceUrls: new Set()
7};
8const telemetryReducer = (state = initialState, action) => {
9 switch (action.type) {
10 case `PROCESS_GATSBY_IMAGE_SOURCE_URL`:
11 {
12 const {
13 sourceUrl
14 } = action.payload;
15 state.gatsbyImageSourceUrls.add(sourceUrl);
16 return state;
17 }
18 case `CLEAR_GATSBY_IMAGE_SOURCE_URL`:
19 {
20 state.gatsbyImageSourceUrls = new Set();
21 return state;
22 }
23 case `MERGE_WORKER_QUERY_STATE`:
24 {
25 const {
26 queryStateTelemetryChunk
27 } = action.payload;
28
29 // This action may be dispatched in cases where queries might not be included in the merge data
30 if (!queryStateTelemetryChunk) {
31 return state;
32 }
33 const urlsFromWorker = queryStateTelemetryChunk.gatsbyImageSourceUrls || new Set();
34 urlsFromWorker.forEach(url => {
35 state.gatsbyImageSourceUrls.add(url);
36 });
37 return state;
38 }
39 default:
40 {
41 return state;
42 }
43 }
44};
45exports.telemetryReducer = telemetryReducer;
46//# sourceMappingURL=telemetry.js.map
\No newline at end of file