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

ref: Use @sentry/react #19366

Merged
merged 8 commits into from Jun 25, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -21,8 +21,8 @@
"@emotion/core": "^10.0.27",
"@emotion/styled": "^10.0.27",
"@sentry/apm": "5.18.0",
"@sentry/browser": "5.18.0",
"@sentry/integrations": "5.18.0",
"@sentry/react": "5.18.0",
"@sentry/release-parser": "^0.6.0",
"@sentry/rrweb": "^0.1.1",
"@sentry/utils": "5.18.0",
Expand Down
@@ -1,9 +1,9 @@
import * as ReactRouter from 'react-router';
import * as Sentry from '@sentry/browser';
import isInteger from 'lodash/isInteger';
import omit from 'lodash/omit';
import pick from 'lodash/pick';
import qs from 'query-string';
import * as Sentry from '@sentry/react';

import {
DATE_TIME,
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/actionCreators/group.jsx
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {Client} from 'app/api';
import {buildUserId, buildTeamId} from 'app/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/actionCreators/members.tsx
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {Client} from 'app/api';
import {Member} from 'app/types';
Expand Down
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {Client} from 'app/api';
import {addErrorMessage} from 'app/actionCreators/indicator';
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/actionCreators/release.tsx
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import ReleaseActions from 'app/actions/releaseActions';
import {Client} from 'app/api';
Expand Down
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import RepositoryActions from 'app/actions/repositoryActions';
import {Client} from 'app/api';
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/api.tsx
@@ -1,7 +1,7 @@
import isUndefined from 'lodash/isUndefined';
import isNil from 'lodash/isNil';
import $ from 'jquery';
import {Severity} from '@sentry/browser';
import {Severity} from '@sentry/react';

import {
PROJECT_MOVED,
Expand Down
6 changes: 3 additions & 3 deletions src/sentry/static/sentry/app/bootstrap.tsx
Expand Up @@ -12,13 +12,13 @@ import React from 'react';
import ReactDOM from 'react-dom';
import Reflux from 'reflux';
import * as Router from 'react-router';
import * as Sentry from '@sentry/browser';
import {ExtraErrorData} from '@sentry/integrations';
import {Integrations} from '@sentry/apm';
import SentryRRWeb from '@sentry/rrweb';
import createReactClass from 'create-react-class';
import jQuery from 'jquery';
import moment from 'moment';
import {Integrations} from '@sentry/apm';
import {ExtraErrorData} from '@sentry/integrations';
import * as Sentry from '@sentry/react';

import {metric} from 'app/utils/analytics';
import {init as initApiSentryClient} from 'app/utils/apiSentryClient';
Expand Down
@@ -1,7 +1,7 @@
import debounce from 'lodash/debounce';
import PropTypes from 'prop-types';
import React from 'react';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import NoteInput from 'app/components/activity/note/input';
import localStorage from 'app/utils/localStorage';
Expand Down
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import Reflux from 'reflux';
import styled from '@emotion/styled';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {
closeGuide,
Expand Down
17 changes: 2 additions & 15 deletions src/sentry/static/sentry/app/components/asyncComponent.tsx
@@ -1,9 +1,9 @@
import isEqual from 'lodash/isEqual';
import PropTypes from 'prop-types';
import React from 'react';
import * as Sentry from '@sentry/browser';
import {RouteComponentProps} from 'react-router/lib/Router';
import {WithRouterProps} from 'react-router/lib/withRouter';
import * as Sentry from '@sentry/react';

import {Client} from 'app/api';
import {t} from 'app/locale';
Expand All @@ -15,15 +15,7 @@ import RouteError from 'app/views/routeError';
import {metric} from 'app/utils/analytics';
import getRouteStringFromRoutes from 'app/utils/getRouteStringFromRoutes';

type AsyncComponentProps = {
/**
* Optional sentry APM profiling.
*
* NOTE: we don't decorate `AsyncComponent` but rather the subclass so we can
* get its component name
*/
finishProfile?: () => void;
} & Partial<RouteComponentProps<{}, {}>>;
type AsyncComponentProps = Partial<RouteComponentProps<{}, {}>>;

type AsyncComponentState = {
loading: boolean;
Expand Down Expand Up @@ -167,11 +159,6 @@ export default class AsyncComponent<
},
});
this._measurement.hasMeasured = true;

// sentry apm profiling
if (typeof this.props.finishProfile === 'function') {
this.props.finishProfile();
}
}

// Re-fetch data when router params change.
Expand Down
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import SentryTypes from 'app/sentryTypes';
import UserAvatar from 'app/components/avatar/userAvatar';
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/dropdownMenu.tsx
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {MENU_CLOSE_DELAY} from 'app/constants';

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/errorBoundary.tsx
Expand Up @@ -2,7 +2,7 @@ import {browserHistory} from 'react-router';
import PropTypes from 'prop-types';
import React from 'react';
import styled from '@emotion/styled';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {t} from 'app/locale';
import Alert from 'app/components/alert';
Expand Down
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {t} from 'app/locale';
import InlineSvg from 'app/components/inlineSvg';
Expand Down
Expand Up @@ -159,7 +159,7 @@ class SpanTree extends React.Component<PropType> {

// hide gap spans (i.e. "missing instrumentation" spans) for browser js transactions,
// since they're not useful to indicate
const shouldIncludeGap = !isJavaScriptSDK(event.sdk?.name);
const shouldIncludeGap = !isBrowserJavaScriptSDK(event.sdk?.name);

const isValidGap =
typeof previousSiblingEndTimestamp === 'number' &&
Expand Down Expand Up @@ -356,12 +356,14 @@ const TraceViewContainer = styled('div')`
border-bottom-right-radius: 3px;
`;

function isJavaScriptSDK(sdkName?: string): boolean {
function isBrowserJavaScriptSDK(sdkName?: string): boolean {
if (!sdkName) {
return false;
}
// based on https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/version.ts
return sdkName.toLowerCase() === 'sentry.javascript.browser';
return ['sentry.javascript.browser', 'sentry.javascript.react'].includes(
sdkName.toLowerCase()
);
}

export default SpanTree;
@@ -1,7 +1,7 @@
import isEmpty from 'lodash/isEmpty';
import isString from 'lodash/isString';
import * as Sentry from '@sentry/browser';
import queryString from 'query-string';
import * as Sentry from '@sentry/react';

import {FILTER_MASK} from 'app/constants';
import {defined} from 'app/utils';
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/lazyLoad.jsx
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import styled from '@emotion/styled';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {isWebpackChunkLoadingError} from 'app/utils';
import {t} from 'app/locale';
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/components/links/link.tsx
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import PropTypes from 'prop-types';
import {Link as RouterLink} from 'react-router';
import {Location, LocationDescriptor} from 'history';
import * as Sentry from '@sentry/browser';
import styled from '@emotion/styled';
import isPropValid from '@emotion/is-prop-valid';
import * as Sentry from '@sentry/react';

type AnchorProps = React.HTMLProps<HTMLAnchorElement>;

Expand Down
8 changes: 4 additions & 4 deletions src/sentry/static/sentry/app/components/loadingIndicator.tsx
@@ -1,8 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';

import withProfiler from 'app/utils/withProfiler';
import {withProfiler} from '@sentry/react';

type Props = {
overlay?: boolean;
Expand All @@ -17,7 +16,6 @@ type Props = {
className?: string;
style?: React.CSSProperties;
children?: React.ReactNode;
finishProfile: () => void;
};

function LoadingIndicator(props: Props) {
Expand Down Expand Up @@ -82,4 +80,6 @@ LoadingIndicator.propTypes = {
hideSpinner: PropTypes.bool,
};

export default withProfiler(LoadingIndicator);
export default withProfiler(LoadingIndicator, {
hasUpdateSpan: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm I can't form words atm, but has doesn't read to me that this is an option for withProfiler... maybe something like includeUpdateSpan?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just updateSpan

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateSpan makes it sound like the profiler will perform an update of a span -- maybe includeUpdates?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So somethin alongs the lines of:

// If time component is on page should be displayed as a span. True by default.
includeRender?: boolean;
// If component updates should be displayed as spans. True by default.
includeUpdates?: boolean;

I like this naming.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I am going to merge this in, but I will make the API changes and come back and update.

});
Expand Up @@ -4,9 +4,9 @@ import 'react-date-range/dist/theme/default.css';
import {DateRangePicker} from 'react-date-range';
import PropTypes from 'prop-types';
import React from 'react';
import * as Sentry from '@sentry/browser';
import moment from 'moment';
import styled from '@emotion/styled';
import * as Sentry from '@sentry/react';

import {addErrorMessage} from 'app/actionCreators/indicator';
import {analytics} from 'app/utils/analytics';
Expand Down
Expand Up @@ -3,7 +3,7 @@ import debounce from 'lodash/debounce';
import {withRouter} from 'react-router';
import PropTypes from 'prop-types';
import React from 'react';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {Client} from 'app/api';
import {createFuzzySearch} from 'app/utils/createFuzzySearch';
Expand Down
Expand Up @@ -3,10 +3,10 @@ import {browserHistory} from 'react-router';
import PropTypes from 'prop-types';
import React from 'react';
import Reflux from 'reflux';
import * as Sentry from '@sentry/browser';
import createReactClass from 'create-react-class';
import debounce from 'lodash/debounce';
import styled from '@emotion/styled';
import * as Sentry from '@sentry/react';

import {addErrorMessage} from 'app/actionCreators/indicator';
import {trackAnalyticsEvent} from 'app/utils/analytics';
Expand Down
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import u2f from 'u2f-api';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import ConfigStore from 'app/stores/configStore';
import {t, tct} from 'app/locale';
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/stores/hookStore.tsx
@@ -1,6 +1,6 @@
import Reflux from 'reflux';
import isUndefined from 'lodash/isUndefined';
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

import {Hooks, HookName} from 'app/types/hooks';

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/translations.tsx
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

// zh-cn => zh_CN
function convertToDjangoLocaleFormat(language: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/utils/apiSentryClient.tsx
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

let hub;

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/utils/apm.tsx
@@ -1,6 +1,6 @@
import * as Sentry from '@sentry/browser';
import * as Router from 'react-router';
import {createMemoryHistory} from 'history';
import * as Sentry from '@sentry/react';

import getRouteStringFromRoutes from 'app/utils/getRouteStringFromRoutes';

Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/utils/eventWaiter.tsx
@@ -1,5 +1,5 @@
import * as Sentry from '@sentry/browser';
import React from 'react';
import * as Sentry from '@sentry/react';

import {analytics} from 'app/utils/analytics';
import {Client} from 'app/api';
Expand Down
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

export default function handleXhrErrorResponse(message: string) {
return (resp: JQueryXHR) => {
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/static/sentry/app/utils/logging.tsx
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';

export function logException(ex: Error, context: any): void {
Sentry.withScope(scope => {
Expand Down
54 changes: 0 additions & 54 deletions src/sentry/static/sentry/app/utils/withProfiler.tsx

This file was deleted.