2023-04-26 07:18:16 +00:00
|
|
|
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
|
2023-01-06 14:09:38 +00:00
|
|
|
import { createReducer } from "utils/ReducerUtils";
|
|
|
|
|
|
|
|
|
|
export type SegmentState = "INIT_SUCCESS" | "INIT_UNCERTAIN";
|
|
|
|
|
|
|
|
|
|
export const initialState: AnalyticsReduxState = {
|
|
|
|
|
telemetry: {},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export interface AnalyticsReduxState {
|
|
|
|
|
telemetry: {
|
|
|
|
|
segmentState?: SegmentState;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const handlers = {
|
|
|
|
|
[ReduxActionTypes.SEGMENT_INITIALIZED]: (
|
|
|
|
|
state: AnalyticsReduxState,
|
|
|
|
|
): AnalyticsReduxState => ({
|
|
|
|
|
...state,
|
|
|
|
|
telemetry: {
|
|
|
|
|
...state.telemetry,
|
|
|
|
|
segmentState: "INIT_SUCCESS",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
[ReduxActionTypes.SEGMENT_INIT_UNCERTAIN]: (
|
|
|
|
|
state: AnalyticsReduxState,
|
|
|
|
|
): AnalyticsReduxState => ({
|
|
|
|
|
...state,
|
|
|
|
|
telemetry: {
|
|
|
|
|
...state.telemetry,
|
|
|
|
|
segmentState: "INIT_UNCERTAIN",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default createReducer(initialState, handlers);
|