Skip to content

chore: refactor faro (CE) #40350

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

Merged
merged 7 commits into from
Apr 29, 2025
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
6 changes: 4 additions & 2 deletions app/client/src/AppErrorBoundry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AppCrashImage from "assets/images/404-image.png";
import log from "loglevel";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import { Button } from "@appsmith/ads";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";

const Wrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -32,7 +32,9 @@ class AppErrorBoundary extends Component {

componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
log.error({ error, errorInfo });
captureException(error, { errorName: "AppErrorBoundary" });
appsmithTelemetry.captureException(error, {
errorName: "AppErrorBoundary",
});
AnalyticsUtil.logEvent("APP_CRASH", { error, errorInfo });
this.setState({
hasError: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Tag } from "@blueprintjs/core";
import styled from "styled-components";
import { UIComponentTypes } from "entities/Plugin";
import log from "loglevel";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";
import type { FormEvalOutput } from "reducers/evaluationReducers/formEvaluationReducer";
import {
checkIfSectionCanRender,
Expand Down Expand Up @@ -103,7 +103,7 @@ const FormRender = (props: Props) => {
}
} catch (e) {
log.error(e);
captureException(e, { errorName: "FormRenderError" });
appsmithTelemetry.captureException(e, { errorName: "FormRenderError" });

return (
<ErrorComponent
Expand Down
11 changes: 7 additions & 4 deletions app/client/src/actions/pageActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ReplayOperation } from "entities/Replay/ReplayEntity/ReplayOperations";
import type { PACKAGE_PULL_STATUS } from "ee/constants/ModuleConstants";
import type { ApiResponse } from "api/ApiResponses";
import type { EvaluationReduxAction } from "./EvaluationReduxActionTypes";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";

export interface FetchPageListPayload {
applicationId: string;
Expand Down Expand Up @@ -323,9 +323,12 @@ export const updatePageAction = (
payload: UpdatePageActionPayload,
): ReduxAction<UpdatePageActionPayload> => {
if (!payload.id) {
captureException(new Error("Attempting to update page without page id"), {
errorName: "PageActions_UpdatePage",
});
appsmithTelemetry.captureException(
new Error("Attempting to update page without page id"),
{
errorName: "PageActions_UpdatePage",
},
);
}

return {
Expand Down
13 changes: 8 additions & 5 deletions app/client/src/api/helpers/validateJsonResponseMeta.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";
import type { AxiosResponse } from "axios";
import { CONTENT_TYPE_HEADER_KEY } from "PluginActionEditor/constants/CommonApiConstants";

Expand All @@ -7,9 +7,12 @@ export const validateJsonResponseMeta = (response: AxiosResponse) => {
response.headers[CONTENT_TYPE_HEADER_KEY] === "application/json" &&
!response.data.responseMeta
) {
captureException(new Error("Api responded without response meta"), {
errorName: "ValidateJsonResponseMeta",
contexts: { response: response.data },
});
appsmithTelemetry.captureException(
new Error("Api responded without response meta"),
{
errorName: "ValidateJsonResponseMeta",
contexts: { response: response.data },
},
);
}
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import type { AxiosError } from "axios";
import type { ApiResponse } from "api/types";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";

export const handleMissingResponseMeta = async (
error: AxiosError<ApiResponse>,
) => {
if (error.response?.data && !error.response.data.responseMeta) {
captureException(new Error("Api responded without response meta"), {
errorName: "MissingResponseMeta",
contexts: { response: { ...error.response.data } },
});
appsmithTelemetry.captureException(
new Error("Api responded without response meta"),
{
errorName: "MissingResponseMeta",
contexts: { response: { ...error.response.data } },
},
);

return Promise.reject(error.response.data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import type { AxiosError } from "axios";
import type { ApiResponse } from "api/types";
import { is404orAuthPath } from "api/helpers";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";

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

return Promise.reject({
...error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { is404orAuthPath } from "api/helpers";
import { logoutUser } from "actions/userActions";
import { AUTH_LOGIN_URL } from "constants/routes";
import { API_STATUS_CODES, ERROR_CODES } from "ee/constants/ApiConstants";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";

export const handleUnauthorizedError = async (error: AxiosError) => {
if (is404orAuthPath()) return null;
Expand All @@ -20,7 +20,9 @@ export const handleUnauthorizedError = async (error: AxiosError) => {
}),
);

captureException(error, { errorName: "UnauthorizedError" });
appsmithTelemetry.captureException(error, {
errorName: "UnauthorizedError",
});

return Promise.reject({
...error,
Expand Down
11 changes: 7 additions & 4 deletions app/client/src/ce/sagas/PageSagas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ import {
selectCombinedPreviewMode,
selectGitApplicationCurrentBranch,
} from "selectors/gitModSelectors";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";

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

if (isRetry) {
captureException(new Error("Failed to correct binding paths"), {
errorName: "PageSagas_BindingPathCorrection",
});
appsmithTelemetry.captureException(
new Error("Failed to correct binding paths"),
{
errorName: "PageSagas_BindingPathCorrection",
},
);
yield put({
type: ReduxActionErrorTypes.FAILED_CORRECTING_BINDING_PATHS,
payload: {
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/ce/utils/AnalyticsUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SegmentSingleton from "utils/Analytics/segment";
import MixpanelSingleton, {
type SessionRecordingConfig,
} from "utils/Analytics/mixpanel";
import FaroUtil from "utils/Analytics/sentry";
import { appsmithTelemetry } from "instrumentation";
import SmartlookUtil from "utils/Analytics/smartlook";
import TrackedUser from "ee/utils/Analytics/trackedUser";

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

FaroUtil.identifyUser(trackedUser.userId, userData);
appsmithTelemetry.identifyUser(trackedUser.userId, userData);

if (trackedUser.email) {
SmartlookUtil.identify(trackedUser.userId, trackedUser.email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { getPathNavigationUrl } from "selectors/navigationSelectors";
import { Button, Icon, Link, toast, Tooltip } from "@appsmith/ads";
import type { EvaluationError } from "utils/DynamicBindingUtils";
import { DEBUGGER_TAB_KEYS } from "../Debugger/constants";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";

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

if (!value) {
captureException(new Error("Prepared statement got no value"), {
errorName: "PreparedStatementError",
extra: { props },
});
appsmithTelemetry.captureException(
new Error("Prepared statement got no value"),
{
errorName: "PreparedStatementError",
extra: { props },
},
);

return <div />;
}
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/components/editorComponents/ErrorBoundry.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import styled from "styled-components";
import * as log from "loglevel";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";

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

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

render() {
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/components/propertyControls/TabControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import isString from "lodash/isString";
import isUndefined from "lodash/isUndefined";
import includes from "lodash/includes";
import map from "lodash/map";
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";
import { useDispatch } from "react-redux";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import { DraggableListControl } from "pages/Editor/PropertyPane/DraggableListControl";
Expand Down Expand Up @@ -131,7 +131,7 @@ class TabControl extends BaseControl<ControlProps, State> {

return parsedData;
} catch (error) {
captureException(
appsmithTelemetry.captureException(
{
message: "Tab Migration Failed",
oldData: this.props.propertyValue,
Expand Down
6 changes: 4 additions & 2 deletions app/client/src/ee/sagas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export * from "ce/sagas";
import { sagas as CE_Sagas } from "ce/sagas";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";
import { call, all, spawn, race, take } from "redux-saga/effects";
import { appsmithTelemetry } from "instrumentation";
import log from "loglevel";
import captureException from "instrumentation/sendFaroErrors";

const sagasArr = [...CE_Sagas];

Expand All @@ -22,7 +22,9 @@ export function* rootSaga(sagasToRun = sagasArr): any {
break;
} catch (e) {
log.error(e);
captureException(e, { errorName: "RootSagaError" });
appsmithTelemetry.captureException(e, {
errorName: "RootSagaError",
});
}
}
}),
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/git/sagas/helpers/handleApiErrors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import captureException from "instrumentation/sendFaroErrors";
import { appsmithTelemetry } from "instrumentation";
import type { ApiResponse } from "api/types";
import log from "loglevel";

Expand All @@ -22,7 +22,7 @@ export default function handleApiErrors(error?: Error, response?: ApiResponse) {
}
} else {
log.error(error);
captureException(error, { errorName: "GitApiError" });
appsmithTelemetry.captureException(error, { errorName: "GitApiError" });
}

return apiError;
Expand Down
18 changes: 7 additions & 11 deletions app/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,18 @@ import GlobalStyles from "globalStyles";
import AppErrorBoundary from "./AppErrorBoundry";
import log from "loglevel";
import { FaroErrorBoundary } from "@grafana/faro-react";
import { isTracingEnabled } from "instrumentation/utils";

runSagaMiddleware();

appInitializer();

isTracingEnabled() &&
(async () => {
try {
await import(
/* webpackChunkName: "instrumentation" */ "./instrumentation"
);
} catch (e) {
log.error("Error loading telemetry script", e);
}
})();
(async () => {
try {
await import(/* webpackChunkName: "instrumentation" */ "./instrumentation");
} catch (e) {
log.error("Error loading telemetry script", e);
}
})();

function App() {
return (
Expand Down
Loading
Loading