Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions app/client/src/ce/sagas/NavigationSagas.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { fork, put, select, call } from "redux-saga/effects";
import { fork, put, select, call, take } from "redux-saga/effects";
import type { RouteChangeActionPayload } from "actions/focusHistoryActions";
import { FocusEntity, identifyEntityFromPath } from "navigation/FocusEntity";
import log from "loglevel";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import { getRecentEntityIds } from "selectors/globalSearchSelectors";
import type { ReduxAction } from "ee/constants/ReduxActionConstants";
import {
ReduxActionTypes,
type ReduxAction,
} from "ee/constants/ReduxActionConstants";
import { getCurrentThemeDetails } from "selectors/themeSelectors";
import type { BackgroundTheme } from "sagas/ThemeSaga";
import { changeAppBackground } from "sagas/ThemeSaga";
Expand Down Expand Up @@ -86,6 +89,10 @@ function* clearErrors() {
}

function* watchForTrackableUrl(payload: RouteChangeActionPayload) {
yield take([
ReduxActionTypes.INITIALIZE_EDITOR_SUCCESS,
ReduxActionTypes.INITIALIZE_PAGE_VIEWER_SUCCESS,
]);
const oldPathname = payload.prevLocation.pathname;
const newPathname = payload.location.pathname;
const isOldPathTrackable: boolean = yield call(
Expand Down
30 changes: 23 additions & 7 deletions app/client/src/ce/sagas/userSagas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,11 @@ function* initTrackers(currentUser: User) {
}
}

export function* runUserSideEffectsSaga() {
function* restartUserTracking() {
const currentUser: User = yield select(getCurrentUser);
const { enableTelemetry } = currentUser;
const isAirgappedInstance = isAirgapped();

if (enableTelemetry) {
yield fork(initTrackers, currentUser);
}

const isFFFetched: boolean = yield select(getFeatureFlagsFetched);

if (!isFFFetched) {
Expand All @@ -169,13 +165,33 @@ export function* runUserSideEffectsSaga() {

if (!isAirgappedInstance) {
// We need to stop and start tracking activity to ensure that the tracking from previous session is not carried forward
UsagePulse.stopTrackingActivity();
UsagePulse.startTrackingActivity(
yield call(UsagePulse.stopTrackingActivity);

if (currentUser?.isAnonymous) {
yield take([
ReduxActionTypes.INITIALIZE_EDITOR_SUCCESS,
ReduxActionTypes.INITIALIZE_PAGE_VIEWER_SUCCESS,
]);
}

yield call(
UsagePulse.startTrackingActivity,
enableTelemetry && getAppsmithConfigs().segment.enabled,
currentUser?.isAnonymous ?? false,
isFreeLicense,
);
}
}

export function* runUserSideEffectsSaga() {
const currentUser: User = yield select(getCurrentUser);
const { enableTelemetry } = currentUser;

if (enableTelemetry) {
yield fork(initTrackers, currentUser);
}

yield fork(restartUserTracking);

if (currentUser.emptyInstance) {
history.replace(SETUP);
Expand Down