Skip to content

Commit 7239cdd

Browse files
chore: refactor faro (CE) (#40350)
## 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 #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### 🔍 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/14664226456> > Commit: caaee4b > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14664226456&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Fri, 25 Apr 2025 13:20:56 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Unified all error and telemetry reporting to use a centralized telemetry utility for improved consistency. - Replaced legacy error reporting imports and methods with a new singleton telemetry interface across the application. - Removed obsolete telemetry and error reporting files and classes. - Simplified telemetry initialization by removing conditional tracing checks. - No changes to user-facing functionality or workflows. - **Tests** - Updated test mocks to use the new telemetry interface. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Apeksha Bhosale <7846888+ApekshaBhosale@users.noreply.github.com>
1 parent 82cf730 commit 7239cdd

File tree

50 files changed

+348
-637
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+348
-637
lines changed

app/client/src/AppErrorBoundry.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import AppCrashImage from "assets/images/404-image.png";
44
import log from "loglevel";
55
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
66
import { Button } from "@appsmith/ads";
7-
import captureException from "instrumentation/sendFaroErrors";
7+
import { appsmithTelemetry } from "instrumentation";
88

99
const Wrapper = styled.div`
1010
display: flex;
@@ -32,7 +32,9 @@ class AppErrorBoundary extends Component {
3232

3333
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
3434
log.error({ error, errorInfo });
35-
captureException(error, { errorName: "AppErrorBoundary" });
35+
appsmithTelemetry.captureException(error, {
36+
errorName: "AppErrorBoundary",
37+
});
3638
AnalyticsUtil.logEvent("APP_CRASH", { error, errorInfo });
3739
this.setState({
3840
hasError: true,

app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/FormRender.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Tag } from "@blueprintjs/core";
99
import styled from "styled-components";
1010
import { UIComponentTypes } from "entities/Plugin";
1111
import log from "loglevel";
12-
import captureException from "instrumentation/sendFaroErrors";
12+
import { appsmithTelemetry } from "instrumentation";
1313
import type { FormEvalOutput } from "reducers/evaluationReducers/formEvaluationReducer";
1414
import {
1515
checkIfSectionCanRender,
@@ -103,7 +103,7 @@ const FormRender = (props: Props) => {
103103
}
104104
} catch (e) {
105105
log.error(e);
106-
captureException(e, { errorName: "FormRenderError" });
106+
appsmithTelemetry.captureException(e, { errorName: "FormRenderError" });
107107

108108
return (
109109
<ErrorComponent

app/client/src/actions/pageActions.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { ReplayOperation } from "entities/Replay/ReplayEntity/ReplayOperations";
2929
import type { PACKAGE_PULL_STATUS } from "ee/constants/ModuleConstants";
3030
import type { ApiResponse } from "api/ApiResponses";
3131
import type { EvaluationReduxAction } from "./EvaluationReduxActionTypes";
32-
import captureException from "instrumentation/sendFaroErrors";
32+
import { appsmithTelemetry } from "instrumentation";
3333

3434
export interface FetchPageListPayload {
3535
applicationId: string;
@@ -323,9 +323,12 @@ export const updatePageAction = (
323323
payload: UpdatePageActionPayload,
324324
): ReduxAction<UpdatePageActionPayload> => {
325325
if (!payload.id) {
326-
captureException(new Error("Attempting to update page without page id"), {
327-
errorName: "PageActions_UpdatePage",
328-
});
326+
appsmithTelemetry.captureException(
327+
new Error("Attempting to update page without page id"),
328+
{
329+
errorName: "PageActions_UpdatePage",
330+
},
331+
);
329332
}
330333

331334
return {
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import captureException from "instrumentation/sendFaroErrors";
1+
import { appsmithTelemetry } from "instrumentation";
22
import type { AxiosResponse } from "axios";
33
import { CONTENT_TYPE_HEADER_KEY } from "PluginActionEditor/constants/CommonApiConstants";
44

@@ -7,9 +7,12 @@ export const validateJsonResponseMeta = (response: AxiosResponse) => {
77
response.headers[CONTENT_TYPE_HEADER_KEY] === "application/json" &&
88
!response.data.responseMeta
99
) {
10-
captureException(new Error("Api responded without response meta"), {
11-
errorName: "ValidateJsonResponseMeta",
12-
contexts: { response: response.data },
13-
});
10+
appsmithTelemetry.captureException(
11+
new Error("Api responded without response meta"),
12+
{
13+
errorName: "ValidateJsonResponseMeta",
14+
contexts: { response: response.data },
15+
},
16+
);
1417
}
1518
};

app/client/src/api/interceptors/response/failureHandlers/handleMissingResponseMeta.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import type { AxiosError } from "axios";
22
import type { ApiResponse } from "api/types";
3-
import captureException from "instrumentation/sendFaroErrors";
3+
import { appsmithTelemetry } from "instrumentation";
44

55
export const handleMissingResponseMeta = async (
66
error: AxiosError<ApiResponse>,
77
) => {
88
if (error.response?.data && !error.response.data.responseMeta) {
9-
captureException(new Error("Api responded without response meta"), {
10-
errorName: "MissingResponseMeta",
11-
contexts: { response: { ...error.response.data } },
12-
});
9+
appsmithTelemetry.captureException(
10+
new Error("Api responded without response meta"),
11+
{
12+
errorName: "MissingResponseMeta",
13+
contexts: { response: { ...error.response.data } },
14+
},
15+
);
1316

1417
return Promise.reject(error.response.data);
1518
}

app/client/src/api/interceptors/response/failureHandlers/handleNotFoundError.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import type { AxiosError } from "axios";
77
import type { ApiResponse } from "api/types";
88
import { is404orAuthPath } from "api/helpers";
9-
import captureException from "instrumentation/sendFaroErrors";
9+
import { appsmithTelemetry } from "instrumentation";
1010

1111
export async function handleNotFoundError(error: AxiosError<ApiResponse>) {
1212
if (is404orAuthPath()) return null;
@@ -20,7 +20,7 @@ export async function handleNotFoundError(error: AxiosError<ApiResponse>) {
2020
(SERVER_ERROR_CODES.RESOURCE_NOT_FOUND.includes(errorData.error?.code) ||
2121
SERVER_ERROR_CODES.UNABLE_TO_FIND_PAGE.includes(errorData?.error?.code))
2222
) {
23-
captureException(error, { errorName: "NotFoundError" });
23+
appsmithTelemetry.captureException(error, { errorName: "NotFoundError" });
2424

2525
return Promise.reject({
2626
...error,

app/client/src/api/interceptors/response/failureHandlers/handleUnauthorizedError.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { is404orAuthPath } from "api/helpers";
44
import { logoutUser } from "actions/userActions";
55
import { AUTH_LOGIN_URL } from "constants/routes";
66
import { API_STATUS_CODES, ERROR_CODES } from "ee/constants/ApiConstants";
7-
import captureException from "instrumentation/sendFaroErrors";
7+
import { appsmithTelemetry } from "instrumentation";
88

99
export const handleUnauthorizedError = async (error: AxiosError) => {
1010
if (is404orAuthPath()) return null;
@@ -20,7 +20,9 @@ export const handleUnauthorizedError = async (error: AxiosError) => {
2020
}),
2121
);
2222

23-
captureException(error, { errorName: "UnauthorizedError" });
23+
appsmithTelemetry.captureException(error, {
24+
errorName: "UnauthorizedError",
25+
});
2426

2527
return Promise.reject({
2628
...error,

app/client/src/ce/sagas/PageSagas.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ import {
151151
selectCombinedPreviewMode,
152152
selectGitApplicationCurrentBranch,
153153
} from "selectors/gitModSelectors";
154-
import captureException from "instrumentation/sendFaroErrors";
154+
import { appsmithTelemetry } from "instrumentation";
155155

156156
export interface HandleWidgetNameUpdatePayload {
157157
newName: string;
@@ -575,9 +575,12 @@ export function* savePageSaga(action: ReduxAction<{ isRetry?: boolean }>) {
575575
const { message } = incorrectBindingError;
576576

577577
if (isRetry) {
578-
captureException(new Error("Failed to correct binding paths"), {
579-
errorName: "PageSagas_BindingPathCorrection",
580-
});
578+
appsmithTelemetry.captureException(
579+
new Error("Failed to correct binding paths"),
580+
{
581+
errorName: "PageSagas_BindingPathCorrection",
582+
},
583+
);
581584
yield put({
582585
type: ReduxActionErrorTypes.FAILED_CORRECTING_BINDING_PATHS,
583586
payload: {

app/client/src/ce/utils/AnalyticsUtil.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SegmentSingleton from "utils/Analytics/segment";
99
import MixpanelSingleton, {
1010
type SessionRecordingConfig,
1111
} from "utils/Analytics/mixpanel";
12-
import FaroUtil from "utils/Analytics/sentry";
12+
import { appsmithTelemetry } from "instrumentation";
1313
import SmartlookUtil from "utils/Analytics/smartlook";
1414
import TrackedUser from "ee/utils/Analytics/trackedUser";
1515

@@ -94,7 +94,7 @@ async function identifyUser(userData: User, sendAdditionalData?: boolean) {
9494
await segmentAnalytics.identify(trackedUser.userId, userProperties);
9595
}
9696

97-
FaroUtil.identifyUser(trackedUser.userId, userData);
97+
appsmithTelemetry.identifyUser(trackedUser.userId, userData);
9898

9999
if (trackedUser.email) {
100100
SmartlookUtil.identify(trackedUser.userId, trackedUser.email);

app/client/src/components/editorComponents/CodeEditor/EvaluatedValuePopup.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { getPathNavigationUrl } from "selectors/navigationSelectors";
2828
import { Button, Icon, Link, toast, Tooltip } from "@appsmith/ads";
2929
import type { EvaluationError } from "utils/DynamicBindingUtils";
3030
import { DEBUGGER_TAB_KEYS } from "../Debugger/constants";
31-
import captureException from "instrumentation/sendFaroErrors";
31+
import { appsmithTelemetry } from "instrumentation";
3232

3333
const modifiers: IPopoverSharedProps["modifiers"] = {
3434
offset: {
@@ -290,10 +290,13 @@ export function PreparedStatementViewer(props: {
290290
const { parameters, value } = props.evaluatedValue;
291291

292292
if (!value) {
293-
captureException(new Error("Prepared statement got no value"), {
294-
errorName: "PreparedStatementError",
295-
extra: { props },
296-
});
293+
appsmithTelemetry.captureException(
294+
new Error("Prepared statement got no value"),
295+
{
296+
errorName: "PreparedStatementError",
297+
extra: { props },
298+
},
299+
);
297300

298301
return <div />;
299302
}

app/client/src/components/editorComponents/ErrorBoundry.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import styled from "styled-components";
33
import * as log from "loglevel";
4-
import captureException from "instrumentation/sendFaroErrors";
4+
import { appsmithTelemetry } from "instrumentation";
55

66
import type { ReactNode, CSSProperties } from "react";
77

@@ -39,7 +39,7 @@ class ErrorBoundary extends React.Component<Props, State> {
3939
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4040
componentDidCatch(error: any, errorInfo: any) {
4141
log.error({ error, errorInfo });
42-
captureException(error, { errorName: "ErrorBoundary" });
42+
appsmithTelemetry.captureException(error, { errorName: "ErrorBoundary" });
4343
}
4444

4545
render() {

app/client/src/components/propertyControls/TabControl.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import isString from "lodash/isString";
1010
import isUndefined from "lodash/isUndefined";
1111
import includes from "lodash/includes";
1212
import map from "lodash/map";
13-
import captureException from "instrumentation/sendFaroErrors";
13+
import { appsmithTelemetry } from "instrumentation";
1414
import { useDispatch } from "react-redux";
1515
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
1616
import { DraggableListControl } from "pages/Editor/PropertyPane/DraggableListControl";
@@ -131,7 +131,7 @@ class TabControl extends BaseControl<ControlProps, State> {
131131

132132
return parsedData;
133133
} catch (error) {
134-
captureException(
134+
appsmithTelemetry.captureException(
135135
{
136136
message: "Tab Migration Failed",
137137
oldData: this.props.propertyValue,

app/client/src/ee/sagas/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ export * from "ce/sagas";
22
import { sagas as CE_Sagas } from "ce/sagas";
33
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
44
import { call, all, spawn, race, take } from "redux-saga/effects";
5+
import { appsmithTelemetry } from "instrumentation";
56
import log from "loglevel";
6-
import captureException from "instrumentation/sendFaroErrors";
77

88
const sagasArr = [...CE_Sagas];
99

@@ -22,7 +22,9 @@ export function* rootSaga(sagasToRun = sagasArr): any {
2222
break;
2323
} catch (e) {
2424
log.error(e);
25-
captureException(e, { errorName: "RootSagaError" });
25+
appsmithTelemetry.captureException(e, {
26+
errorName: "RootSagaError",
27+
});
2628
}
2729
}
2830
}),

app/client/src/git/sagas/helpers/handleApiErrors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import captureException from "instrumentation/sendFaroErrors";
1+
import { appsmithTelemetry } from "instrumentation";
22
import type { ApiResponse } from "api/types";
33
import log from "loglevel";
44

@@ -22,7 +22,7 @@ export default function handleApiErrors(error?: Error, response?: ApiResponse) {
2222
}
2323
} else {
2424
log.error(error);
25-
captureException(error, { errorName: "GitApiError" });
25+
appsmithTelemetry.captureException(error, { errorName: "GitApiError" });
2626
}
2727

2828
return apiError;

app/client/src/index.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,18 @@ import GlobalStyles from "globalStyles";
2727
import AppErrorBoundary from "./AppErrorBoundry";
2828
import log from "loglevel";
2929
import { FaroErrorBoundary } from "@grafana/faro-react";
30-
import { isTracingEnabled } from "instrumentation/utils";
3130

3231
runSagaMiddleware();
3332

3433
appInitializer();
3534

36-
isTracingEnabled() &&
37-
(async () => {
38-
try {
39-
await import(
40-
/* webpackChunkName: "instrumentation" */ "./instrumentation"
41-
);
42-
} catch (e) {
43-
log.error("Error loading telemetry script", e);
44-
}
45-
})();
35+
(async () => {
36+
try {
37+
await import(/* webpackChunkName: "instrumentation" */ "./instrumentation");
38+
} catch (e) {
39+
log.error("Error loading telemetry script", e);
40+
}
41+
})();
4642

4743
function App() {
4844
return (

0 commit comments

Comments
 (0)