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

APPEALS-23487: Add additional metrics for Browser captured error #18725

Merged
merged 4 commits into from
Jun 16, 2023
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/views/reader/appeal/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
windowSlider: FeatureToggle.enabled?(:window_slider, user: current_user),
readerSelectorsMemoized: FeatureToggle.enabled?(:bulk_upload_documents, user: current_user),
metricsLogRestError: FeatureToggle.enabled?(:metrics_log_rest_error, user: current_user),
metricsBrowserError: FeatureToggle.enabled?(:metrics_browser_error, user: current_user),
metricsLoadScreen: FeatureToggle.enabled?(:metrics_load_screen, user: current_user),
metricsReaderRenderText: FeatureToggle.enabled?(:metrics_reader_render_text, user: current_user),
metricsReaderRenderText: FeatureToggle.enabled?(:metrics_reader_render_text, user: current_user)
},
buildDate: build_date
}) %>
Expand Down
32 changes: 32 additions & 0 deletions client/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import { render } from 'react-dom';
import { forOwn } from 'lodash';
import { BrowserRouter, Switch } from 'react-router-dom';

// Internal Dependencies
import { storeMetrics } from './util/Metrics';

// Redux Store Dependencies
import ReduxBase from 'app/components/ReduxBase';
import rootReducer from 'store/root';
Expand Down Expand Up @@ -55,6 +58,7 @@ import Inbox from 'app/inbox';
import Explain from 'app/explain';
import MPISearch from 'app/mpi/MPISearch';
import Admin from 'app/admin';
import uuid from 'uuid';

const COMPONENTS = {
// New Version 2.0 Root Component
Expand Down Expand Up @@ -93,6 +97,34 @@ const COMPONENTS = {
};

const componentWrapper = (component) => (props, railsContext, domNodeId) => {
window.onerror = (event, source, lineno, colno, error) => {
if (props.featureToggles?.metricsBrowserError) {
const id = uuid.v4();
const data = {
event,
source,
lineno,
colno,
error
};
const t0 = performance.now();
const start = Date.now();
const t1 = performance.now();
const end = Date.now();
const duration = t1 - t0;
storeMetrics(
id,
data,
{ type: 'error',
product: 'browser',
start: start,
end: end,
duration: duration }
);
}
return true;
};

/* eslint-disable */
const wrapComponent = (Component) => (
<ErrorBoundary>
Expand Down