Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added analytics for pulse failure #37781

Merged
merged 1 commit into from
Nov 28, 2024
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
3 changes: 2 additions & 1 deletion app/client/src/ce/utils/analyticsUtilTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ export type EventName =
| "EDITOR_MODE_CHANGE"
| BUILDING_BLOCKS_EVENTS
| "VISIT_SELF_HOST_DOCS"
| "CANVAS_HOVER";
| "CANVAS_HOVER"
| "MALFORMED_USAGE_PULSE";

type HOMEPAGE_CREATE_APP_FROM_TEMPLATE_EVENTS =
| "TEMPLATE_DROPDOWN_CLICK"
Expand Down
10 changes: 10 additions & 0 deletions app/client/src/usagePulse/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getAppMode } from "ee/selectors/entitiesSelector";
import store from "store";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import { FALLBACK_KEY } from "ee/constants/UsagePulse";
import { getInstanceId } from "ee/selectors/tenantSelectors";

//TODO (Dipyaman): We should return a promise that will get resolved only on success or rejected after the retries
export const fetchWithRetry = (config: {
Expand All @@ -16,6 +17,9 @@ export const fetchWithRetry = (config: {
retries: number;
retryTimeout: number;
}) => {
const instanceId = getInstanceId(store.getState());
const anonymousUserId = AnalyticsUtil.getAnonymousId();

fetch(config.url, {
method: "POST",
credentials: "same-origin",
Expand All @@ -36,6 +40,12 @@ export const fetchWithRetry = (config: {
retries: config.retries - 1,
retryTimeout: config.retryTimeout,
});
} else {
// add analytics for failed usage pulse
AnalyticsUtil.logEvent("MALFORMED_USAGE_PULSE", {
anonymousUserId,
instanceId,
});
}
});
};
Expand Down
Loading