fix: Stopped calling usage pulse in air-gapped instance (#38749)
## Description This PR added fix for not triggering usage pulse for air gapped instances Fixes https://github.com/appsmithorg/cloud-services/issues/1883 ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12867501950> > Commit: 2300d200cf4213edfc734c1a8b89b4ad797cdb64 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12867501950&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Mon, 20 Jan 2025 12:38:11 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Enhanced user activity tracking by introducing airgapped environment detection, preventing unnecessary tracking in restricted network settings. - **Tests** - Added a new test suite to verify the behavior of the user activity tracking method in airgapped conditions, ensuring correct functionality based on the airgapped status. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
0b830a58b4
commit
2ca5993b18
|
|
@ -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;
|
||||
|
|
@ -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.
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user