Skip to content

Commit

Permalink
feat: Added analytics for pulse failure (appsmithorg#37781)
Browse files Browse the repository at this point in the history
## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes appsmithorg/appsmith-ee#5606

## 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/12049087739>
> Commit: 18929d4
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12049087739&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Wed, 27 Nov 2024 11:51:54 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

- **New Features**
- Enhanced analytics tracking with new event types: "CANVAS_HOVER" and
"MALFORMED_USAGE_PULSE".
- Improved error reporting in the `fetchWithRetry` function, capturing
additional context during failures.

- **Bug Fixes**
	- Added logging for better monitoring of malformed usage scenarios.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
albinAppsmith authored Nov 28, 2024
1 parent bfe2f6e commit ecd421d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 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 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

0 comments on commit ecd421d

Please sign in to comment.