Skip to content

Commit

Permalink
Merge branch 'release' of https://github.com/appsmithorg/appsmith int…
Browse files Browse the repository at this point in the history
…o chore/replace-entities-in-entity-explorer
  • Loading branch information
ankitakinger committed Jan 20, 2025
2 parents d346aa9 + 2ca5993 commit dad304b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/client/src/usagePulse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { PULSE_INTERVAL as PULSE_INTERVAL_CE } from "ce/constants/UsagePulse";
import { PULSE_INTERVAL as PULSE_INTERVAL_EE } from "ee/constants/UsagePulse";
import store from "store";
import type { PageListReduxState } from "reducers/entityReducers/pageListReducer";
import { isAirgapped } from "ee/utils/airgapHelpers";

class UsagePulse {
static userAnonymousId: string | undefined;
Expand All @@ -26,6 +27,7 @@ class UsagePulse {
static isTelemetryEnabled: boolean;
static isAnonymousUser: boolean;
static isFreePlan: boolean;
static isAirgapped = isAirgapped();

/*
* Function to check if the given URL is trakable or not.
Expand Down Expand Up @@ -143,6 +145,10 @@ class UsagePulse {
* registers listeners to wait for the user to go to a trackable url
*/
static async sendPulseAndScheduleNext() {
if (UsagePulse.isAirgapped) {
return;
}

UsagePulse.sendPulse();
UsagePulse.scheduleNextActivityListeners();
}
Expand Down
30 changes: 30 additions & 0 deletions app/client/src/usagePulse/usagePulse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,34 @@ describe("Usage pulse", () => {
});
});
});

describe("sendPulseAndScheduleNext", () => {
let sendPulseSpy: jest.SpyInstance;
let scheduleNextActivityListenersSpy: jest.SpyInstance;

beforeEach(() => {
sendPulseSpy = jest
.spyOn(UsagePulse, "sendPulse")
.mockImplementation(() => {});
scheduleNextActivityListenersSpy = jest
.spyOn(UsagePulse, "scheduleNextActivityListeners")
.mockImplementation(() => {});
UsagePulse.isAirgapped = false;
});

it("should not send pulse or schedule next when airgapped", () => {
UsagePulse.isAirgapped = true;
UsagePulse.sendPulseAndScheduleNext();

expect(sendPulseSpy).not.toHaveBeenCalled();
expect(scheduleNextActivityListenersSpy).not.toHaveBeenCalled();
});

it("should send pulse and schedule next activity listeners when not airgapped", () => {
UsagePulse.sendPulseAndScheduleNext();

expect(sendPulseSpy).toHaveBeenCalledTimes(1);
expect(scheduleNextActivityListenersSpy).toHaveBeenCalledTimes(1);
});
});
});

0 comments on commit dad304b

Please sign in to comment.