diff --git a/protocol-designer/src/analytics/reducers.ts b/protocol-designer/src/analytics/reducers.ts index c894c6be3ce..6aff3b00a84 100644 --- a/protocol-designer/src/analytics/reducers.ts +++ b/protocol-designer/src/analytics/reducers.ts @@ -8,7 +8,7 @@ export interface OptInState { hasOptedIn: boolean appVersion?: string } -const optInInitialState = { +const optInInitialState: OptInState = { hasOptedIn: true, } @@ -23,7 +23,11 @@ const hasOptedIn: Reducer = handleActions( action: RehydratePersistedAction ) => { const persistedState = action.payload?.['analytics.hasOptedIn'] - return persistedState !== undefined ? persistedState : optInInitialState + if (persistedState == null || persistedState?.hasOptedIn == null) { + return optInInitialState + } else { + return persistedState + } }, }, optInInitialState