Remove sentry and related code (#10153)
Fixes https://github.com/mozilla/addons-frontend/issues/10028
This commit is contained in:
Родитель
9cd0ef0d81
Коммит
732c6e5365
README.mdwebpack-common.jsyarn.lock
config
package.jsonsrc/amo
client
components/Routes
middleware
pages/error-simulation/SimulateClientError
server
utils
tests/unit/amo
client
middleware
pages/error-simulation
utils
|
@ -325,9 +325,6 @@ module.exports = {
|
|||
// Serve static via Node.
|
||||
staticHost: undefined,
|
||||
enableNodeStatics: true,
|
||||
|
||||
// No need for Sentry.
|
||||
publicSentryDsn: null,
|
||||
};
|
||||
```
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import path from 'path';
|
||||
|
||||
import { addonsServerProdCDN, analyticsHost, prodDomain, apiProdHost, baseUrlProd, sentryHost } from './lib/shared';
|
||||
import { addonsServerProdCDN, analyticsHost, prodDomain, apiProdHost, baseUrlProd } from './lib/shared';
|
||||
|
||||
const addonsFrontendCDN = 'https://addons-amo.cdn.mozilla.net';
|
||||
const basePath = path.resolve(__dirname, '../');
|
||||
|
@ -115,7 +115,6 @@ module.exports = {
|
|||
'langs',
|
||||
'loggingLevel',
|
||||
'mozillaUserId',
|
||||
'publicSentryDsn',
|
||||
'restrictSearchResultsToAppVersion',
|
||||
'rtlLangs',
|
||||
'trackingEnabled',
|
||||
|
@ -139,7 +138,7 @@ module.exports = {
|
|||
defaultSrc: ["'none'"],
|
||||
baseUri: ["'self'"],
|
||||
childSrc: ["'none'"],
|
||||
connectSrc: [analyticsHost, apiProdHost, sentryHost],
|
||||
connectSrc: [analyticsHost, apiProdHost],
|
||||
fontSrc: [addonsFrontendCDN],
|
||||
formAction: ["'self'"],
|
||||
frameSrc: ["'none'"],
|
||||
|
@ -395,10 +394,6 @@ module.exports = {
|
|||
// to test our internal error handler.
|
||||
allowErrorSimulation: false,
|
||||
|
||||
sentryDsn: process.env.SENTRY_DSN || null,
|
||||
// https://sentry.prod.mozaws.net/operations/addons-frontend-amo-prod/
|
||||
publicSentryDsn: 'https://dbce4e759d8b4dc6a1731d3301fdaab7@sentry.prod.mozaws.net/183',
|
||||
|
||||
// The amount of time (in seconds) that an auth token lives for.
|
||||
// This needs to match the SESSION_COOKIE_AGE in addons-server:
|
||||
// https://github.com/mozilla/addons-server/blob/master/src/olympia/lib/settings_base.py#L990
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Config for the -dev server.
|
||||
import { addonsServerDevCDN, analyticsHost, apiDevHost, baseUrlDev, sentryHost, devDomain } from './lib/shared';
|
||||
import { addonsServerDevCDN, analyticsHost, apiDevHost, baseUrlDev, devDomain } from './lib/shared';
|
||||
|
||||
const addonsFrontendCDN = 'https://addons-amo-dev-cdn.allizom.org';
|
||||
|
||||
|
@ -19,7 +19,6 @@ module.exports = {
|
|||
connectSrc: [
|
||||
analyticsHost,
|
||||
apiDevHost,
|
||||
sentryHost,
|
||||
],
|
||||
fontSrc: [
|
||||
addonsFrontendCDN,
|
||||
|
@ -42,8 +41,5 @@ module.exports = {
|
|||
|
||||
allowErrorSimulation: true,
|
||||
|
||||
// https://sentry.prod.mozaws.net/operations/addons-frontend-amo-dev/
|
||||
publicSentryDsn: 'https://2c975f188a8b4d728ecbb8179cff9c26@sentry.prod.mozaws.net/181',
|
||||
|
||||
extensionWorkshopUrl: 'https://extensionworkshop-dev.allizom.org',
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Config specific to local development
|
||||
import { addonsServerDevCDN, analyticsHost, apiDevHost, sentryHost } from './lib/shared';
|
||||
import { addonsServerDevCDN, analyticsHost, apiDevHost } from './lib/shared';
|
||||
|
||||
const webpackServerHost = process.env.WEBPACK_SERVER_HOST || '127.0.0.1';
|
||||
const webpackServerPort = 3001;
|
||||
|
@ -50,7 +50,6 @@ module.exports = {
|
|||
addonsServerDevCDN,
|
||||
analyticsHost,
|
||||
apiDevHost,
|
||||
sentryHost,
|
||||
webpackHost,
|
||||
// This is needed for pino-devtools.
|
||||
`${webpackServerHost}:3010`,
|
||||
|
@ -81,9 +80,5 @@ module.exports = {
|
|||
reportOnly: true,
|
||||
},
|
||||
|
||||
// By default, client side errors are not reported to Sentry during
|
||||
// development. Override this in a local-*.js config to report errors.
|
||||
publicSentryDsn: null,
|
||||
|
||||
extensionWorkshopUrl: 'https://extensionworkshop-dev.allizom.org',
|
||||
};
|
||||
|
|
|
@ -14,5 +14,4 @@ export const baseUrlDev = apiDevHost;
|
|||
export const baseUrlProd = apiProdHost;
|
||||
export const baseUrlStage = apiStageHost;
|
||||
|
||||
export const sentryHost = 'https://sentry.prod.mozaws.net';
|
||||
export const analyticsHost = 'https://www.google-analytics.com';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Config for the stage server.
|
||||
import { addonsServerStageCDN, analyticsHost, apiStageHost, baseUrlStage, sentryHost, stageDomain } from './lib/shared';
|
||||
import { addonsServerStageCDN, analyticsHost, apiStageHost, baseUrlStage, stageDomain } from './lib/shared';
|
||||
|
||||
const addonsFrontendCDN = 'https://addons-amo-cdn.allizom.org';
|
||||
|
||||
|
@ -17,7 +17,6 @@ module.exports = {
|
|||
connectSrc: [
|
||||
analyticsHost,
|
||||
apiStageHost,
|
||||
sentryHost,
|
||||
],
|
||||
fontSrc: [
|
||||
addonsFrontendCDN,
|
||||
|
@ -40,8 +39,5 @@ module.exports = {
|
|||
|
||||
allowErrorSimulation: true,
|
||||
|
||||
// https://sentry.prod.mozaws.net/operations/addons-frontend-amo-stage/
|
||||
publicSentryDsn: 'https://8f0a256ee2c345608510155edafb71f7@sentry.prod.mozaws.net/182',
|
||||
|
||||
extensionWorkshopUrl: 'https://extensionworkshop.allizom.org',
|
||||
};
|
||||
|
|
|
@ -9,8 +9,5 @@ module.exports = {
|
|||
// memory we have (and more...).
|
||||
enableRequestID: false,
|
||||
|
||||
// Force-disable Sentry
|
||||
publicSentryDsn: null,
|
||||
|
||||
mozillaUserId: 1337,
|
||||
};
|
||||
|
|
|
@ -193,8 +193,6 @@
|
|||
"qhistory": "1.1.0",
|
||||
"qs": "6.9.6",
|
||||
"raf": "3.4.1",
|
||||
"raven": "2.6.4",
|
||||
"raven-js": "3.27.2",
|
||||
"rc-tooltip": "5.1.0",
|
||||
"react": "16.14.0",
|
||||
"react-autosuggest": "10.1.0",
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/* global DEPLOYMENT_VERSION */
|
||||
import 'amo/polyfill';
|
||||
import { oneLine } from 'common-tags';
|
||||
import config from 'config';
|
||||
import FastClick from 'fastclick';
|
||||
import { createBrowserHistory } from 'history';
|
||||
import RavenJs from 'raven-js';
|
||||
import * as React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
|
||||
|
@ -12,14 +10,12 @@ import Root from 'amo/components/Root';
|
|||
import { langToLocale, makeI18n, sanitizeLanguage } from 'amo/i18n/utils';
|
||||
import log from 'amo/logger';
|
||||
import { addQueryParamsToHistory } from 'amo/utils';
|
||||
import { getSentryRelease } from 'amo/utils/sentry';
|
||||
import tracking from 'amo/tracking';
|
||||
|
||||
export default async function createClient(
|
||||
createStore,
|
||||
{
|
||||
_FastClick = FastClick,
|
||||
_RavenJs = RavenJs,
|
||||
_config = config,
|
||||
_createBrowserHistory = createBrowserHistory,
|
||||
_tracking = tracking,
|
||||
|
@ -32,25 +28,6 @@ export default async function createClient(
|
|||
await fetchBufferedLogs();
|
||||
}
|
||||
|
||||
// This code needs to come before anything else so we get logs/errors if
|
||||
// anything else in this function goes wrong.
|
||||
const publicSentryDsn = _config.get('publicSentryDsn');
|
||||
const sentryIsEnabled = Boolean(publicSentryDsn);
|
||||
if (sentryIsEnabled) {
|
||||
log.info(`Configured client-side Sentry with DSN ${publicSentryDsn}`);
|
||||
_RavenJs
|
||||
.config(publicSentryDsn, {
|
||||
logger: 'client-js',
|
||||
// `DEPLOYMENT_VERSION` is injected by webpack at build time (thanks to
|
||||
// the `DefinePlugin`).
|
||||
// See: https://github.com/mozilla/addons-frontend/issues/8270
|
||||
release: getSentryRelease({ version: DEPLOYMENT_VERSION }),
|
||||
})
|
||||
.install();
|
||||
} else {
|
||||
log.warn('Client-side Sentry reporting was disabled by the config');
|
||||
}
|
||||
|
||||
if (config.get('enableStrictMode')) {
|
||||
log.info(oneLine`StrictMode is enabled, which causes double redux action
|
||||
dispatching. See: https://github.com/mozilla/addons-frontend/issues/6424`);
|
||||
|
@ -95,10 +72,6 @@ export default async function createClient(
|
|||
|
||||
const { sagaMiddleware, store } = createStore({ history, initialState });
|
||||
|
||||
if (sentryIsEnabled) {
|
||||
_RavenJs.setTagsContext({ amo_request_id: store.getState().api.requestId });
|
||||
}
|
||||
|
||||
if (sagas && sagaMiddleware) {
|
||||
sagaMiddleware.run(sagas);
|
||||
} else {
|
||||
|
|
|
@ -30,7 +30,6 @@ import UserProfile from 'amo/pages/UserProfile';
|
|||
import UserProfileEdit from 'amo/pages/UserProfileEdit';
|
||||
import UsersUnsubscribe from 'amo/pages/UsersUnsubscribe';
|
||||
import SimulateAsyncError from 'amo/pages/error-simulation/SimulateAsyncError';
|
||||
import SimulateClientError from 'amo/pages/error-simulation/SimulateClientError';
|
||||
import SimulateSyncError from 'amo/pages/error-simulation/SimulateSyncError';
|
||||
import About from 'amo/pages/StaticPages/About';
|
||||
import ReviewGuide from 'amo/pages/StaticPages/ReviewGuide';
|
||||
|
@ -202,15 +201,6 @@ const Routes = ({ _config = config }: Props = {}) => (
|
|||
</Page>
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/:lang/:application/simulate-client-error/"
|
||||
component={() => (
|
||||
<Page showWrongPlatformWarning={false}>
|
||||
<SimulateClientError />
|
||||
</Page>
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/:lang/:application/:visibleAddonType(extensions|themes)/"
|
||||
|
|
|
@ -19,11 +19,7 @@ export const datadogTiming = ({
|
|||
});
|
||||
|
||||
client.socket.on('error', (error) => {
|
||||
// Log an error to Sentry.
|
||||
_log.error(`DataDog client socket error: ${error}`);
|
||||
// Log the full stack trace too:
|
||||
// eslint-disable-next-line amo/only-log-strings
|
||||
_log.error('%o', { err: error });
|
||||
});
|
||||
|
||||
return responseTime((req, res, time) => {
|
||||
|
|
|
@ -6,6 +6,11 @@ import { $Request, $Response, NextFunction, Middleware } from 'express';
|
|||
import { AMO_REQUEST_ID_HEADER } from 'amo/constants';
|
||||
|
||||
// This middleware adds a correlation ID to the HTTP context and response.
|
||||
//
|
||||
// Important: we don't pass this ID to the API requests (yet). When we'll do
|
||||
// that, we'll have to double check that caching won't be a problem given that
|
||||
// (1) we store the ID in the Redux state and (2) we serialize the entire Redux
|
||||
// state in the HTML returned by the node server (and that's what gets cached).
|
||||
const requestId = (
|
||||
req: typeof $Request,
|
||||
res: typeof $Response,
|
||||
|
@ -13,7 +18,7 @@ const requestId = (
|
|||
{ _httpContext = httpContext }: {| _httpContext: typeof httpContext |} = {},
|
||||
): typeof Middleware => {
|
||||
const amoRequestId = req.headers[AMO_REQUEST_ID_HEADER] || uuidv4();
|
||||
// Make sure a request header is always set. This is mainly for Sentry errors.
|
||||
// Make sure a request header is always set.
|
||||
req.headers[AMO_REQUEST_ID_HEADER] = amoRequestId;
|
||||
|
||||
_httpContext.set(AMO_REQUEST_ID_HEADER, amoRequestId);
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
import { compose } from 'redux';
|
||||
import * as React from 'react';
|
||||
|
||||
import { render404IfConfigKeyIsFalse } from 'amo/utils/errors';
|
||||
import Button from 'amo/components/Button';
|
||||
|
||||
import './styles.scss';
|
||||
|
||||
export class SimulateClientErrorBase extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
buttonClicked: false,
|
||||
throwRenderError: false,
|
||||
};
|
||||
}
|
||||
|
||||
onClick = () => {
|
||||
this.setState({ buttonClicked: true });
|
||||
setTimeout(() => this.setState({ buttonClicked: false }), 3000);
|
||||
|
||||
throw new Error('This is a simulated client error');
|
||||
};
|
||||
|
||||
throwRenderError = () => {
|
||||
this.setState({ throwRenderError: true });
|
||||
};
|
||||
|
||||
render() {
|
||||
const prompt = this.state.buttonClicked
|
||||
? 'Nice! Check Sentry'
|
||||
: '💣 Go ahead, trigger an error';
|
||||
|
||||
if (this.state.throwRenderError) {
|
||||
throw new Error('This is a simulated client render error');
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="SimulateClientError">
|
||||
<div>
|
||||
<p>
|
||||
This page allows you to simulate client errors, mainly to test our
|
||||
integration with Sentry. If Sentry is enabled (by configuring a
|
||||
DSN), the errors produced by clicking the buttons should appear in
|
||||
the interface.
|
||||
</p>
|
||||
<p>There are two available behaviors:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
The grey button allows to throw an error in the button handler (
|
||||
<code>onClick()</code>) and can be used multiple times. It throws
|
||||
unhandled errors, which should be automatically logged by Sentry.
|
||||
</li>
|
||||
<li>
|
||||
The red button allows to throw an error in the{' '}
|
||||
<code>render()</code> method and is not recoverable because the
|
||||
error will be handled in the <code>ErrorPage</code> component,
|
||||
which should log the error with <code>log.error()</code>. On the
|
||||
client, <code>log.error</code> is bound to{' '}
|
||||
<code>console.error</code>, which should automatically send errors
|
||||
to Sentry.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Button
|
||||
buttonType="neutral"
|
||||
className="SimulateClientError-error"
|
||||
onClick={this.onClick}
|
||||
>
|
||||
{prompt}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
buttonType="alert"
|
||||
className="SimulateClientError-render-error"
|
||||
onClick={this.throwRenderError}
|
||||
>
|
||||
Trigger a render error
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default compose(render404IfConfigKeyIsFalse('allowErrorSimulation'))(
|
||||
SimulateClientErrorBase,
|
||||
);
|
|
@ -9,7 +9,6 @@ import Express from 'express';
|
|||
import httpContext from 'express-http-context';
|
||||
import helmet from 'helmet';
|
||||
import { createMemoryHistory } from 'history';
|
||||
import Raven from 'raven';
|
||||
import * as React from 'react';
|
||||
import ReactDOM from 'react-dom/server';
|
||||
import NestedStatus from 'react-nested-status';
|
||||
|
@ -42,8 +41,6 @@ import {
|
|||
langToLocale,
|
||||
makeI18n,
|
||||
} from 'amo/i18n/utils';
|
||||
import { getDeploymentVersion } from 'amo/utils/build';
|
||||
import { getSentryRelease } from 'amo/utils/sentry';
|
||||
import { fetchSiteStatus, loadedPageIsAnonymous } from 'amo/reducers/site';
|
||||
|
||||
import WebpackIsomorphicToolsConfig from './webpack-isomorphic-tools-config';
|
||||
|
@ -175,27 +172,6 @@ function baseServer(
|
|||
app.use(requestId);
|
||||
}
|
||||
|
||||
const versionJson = JSON.parse(
|
||||
fs.readFileSync(path.join(config.get('basePath'), 'version.json')),
|
||||
);
|
||||
|
||||
const sentryDsn = config.get('sentryDsn');
|
||||
if (sentryDsn) {
|
||||
Raven.config(sentryDsn, {
|
||||
logger: 'server-js',
|
||||
release: getSentryRelease({
|
||||
version: getDeploymentVersion({ versionJson }),
|
||||
}),
|
||||
}).install();
|
||||
app.use(Raven.requestHandler());
|
||||
_log.info(`Sentry reporting configured with DSN ${sentryDsn}`);
|
||||
// The error handler is defined below.
|
||||
} else {
|
||||
_log.warn(
|
||||
'Sentry reporting is disabled; Set config.sentryDsn to enable it.',
|
||||
);
|
||||
}
|
||||
|
||||
if (config.get('useDatadog') && config.get('datadogHost')) {
|
||||
_log.info('Recording DataDog timing stats for all responses');
|
||||
app.use(middleware.datadogTiming({ _HotShots }));
|
||||
|
@ -426,10 +402,6 @@ function baseServer(
|
|||
|
||||
// Error handlers:
|
||||
|
||||
if (sentryDsn) {
|
||||
app.use(Raven.errorHandler());
|
||||
}
|
||||
|
||||
app.use((error, req, res, next) => {
|
||||
try {
|
||||
if (res.headersSent) {
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/* @flow */
|
||||
|
||||
type GetDeploymentVersionParams = {|
|
||||
versionJson: {
|
||||
commit: string,
|
||||
version?: string,
|
||||
},
|
||||
|};
|
||||
|
||||
export const getDeploymentVersion = ({
|
||||
versionJson,
|
||||
}: GetDeploymentVersionParams): string => {
|
||||
const deploymentVersion =
|
||||
versionJson.version && versionJson.version.length
|
||||
? versionJson.version
|
||||
: versionJson.commit;
|
||||
|
||||
return deploymentVersion;
|
||||
};
|
|
@ -1,9 +0,0 @@
|
|||
/* @flow */
|
||||
|
||||
type GetSentryReleaseParams = {|
|
||||
version: string,
|
||||
|};
|
||||
|
||||
export const getSentryRelease = ({ version }: GetSentryReleaseParams) => {
|
||||
return `addons-frontend@${version}`;
|
||||
};
|
|
@ -2,32 +2,15 @@ import { createBrowserHistory } from 'history';
|
|||
import serialize from 'serialize-javascript';
|
||||
|
||||
import createAmoStore from 'amo/store';
|
||||
import { setRequestId } from 'amo/reducers/api';
|
||||
import createClient from 'amo/client/base';
|
||||
import { getSentryRelease } from 'amo/utils/sentry';
|
||||
import { loadedPageIsAnonymous } from 'amo/reducers/site';
|
||||
import { getFakeConfig, createFakeTracking } from 'tests/unit/helpers';
|
||||
import { createFakeTracking } from 'tests/unit/helpers';
|
||||
|
||||
describe(__filename, () => {
|
||||
describe('createClient()', () => {
|
||||
const deploymentVersion = '1.2.3';
|
||||
|
||||
let fakeFastClick;
|
||||
|
||||
function createFakeRavenJs({
|
||||
ravenInstall = sinon.stub(),
|
||||
...methods
|
||||
} = {}) {
|
||||
return {
|
||||
config: sinon.stub().returns({ install: ravenInstall }),
|
||||
setTagsContext: sinon.stub(),
|
||||
...methods,
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
global.DEPLOYMENT_VERSION = deploymentVersion;
|
||||
|
||||
fakeFastClick = {
|
||||
attach: sinon.stub(),
|
||||
};
|
||||
|
@ -63,52 +46,6 @@ describe(__filename, () => {
|
|||
expect(props).toHaveProperty('store', storeResult.store);
|
||||
});
|
||||
|
||||
it('configures RavenJs for Sentry', async () => {
|
||||
const publicSentryDsn = 'example-dsn';
|
||||
const _config = getFakeConfig({ publicSentryDsn });
|
||||
const ravenInstall = sinon.stub();
|
||||
const _RavenJs = createFakeRavenJs({ ravenInstall });
|
||||
|
||||
await _createClient({ createStore: createAmoStore, _config, _RavenJs });
|
||||
|
||||
sinon.assert.calledWith(_RavenJs.config, publicSentryDsn, {
|
||||
logger: 'client-js',
|
||||
release: getSentryRelease({
|
||||
version: deploymentVersion,
|
||||
}),
|
||||
});
|
||||
sinon.assert.called(ravenInstall);
|
||||
});
|
||||
|
||||
it('adds amo_request_id to RavenJs', async () => {
|
||||
const _config = getFakeConfig({ publicSentryDsn: 'example-dsn' });
|
||||
const _RavenJs = createFakeRavenJs();
|
||||
|
||||
const storeResult = createAmoStore();
|
||||
const requestId = 'example-request-id';
|
||||
storeResult.store.dispatch(setRequestId(requestId));
|
||||
|
||||
await _createClient({
|
||||
createStore: () => storeResult,
|
||||
_config,
|
||||
_RavenJs,
|
||||
});
|
||||
|
||||
sinon.assert.calledWith(_RavenJs.setTagsContext, {
|
||||
amo_request_id: requestId,
|
||||
});
|
||||
});
|
||||
|
||||
it('does not configure RavenJs without publicSentryDsn', async () => {
|
||||
const _config = getFakeConfig({ publicSentryDsn: null });
|
||||
const _RavenJs = createFakeRavenJs();
|
||||
|
||||
await _createClient({ _config, _RavenJs });
|
||||
|
||||
sinon.assert.notCalled(_RavenJs.config);
|
||||
sinon.assert.notCalled(_RavenJs.setTagsContext);
|
||||
});
|
||||
|
||||
it('updates the tracking page on location change', async () => {
|
||||
const _tracking = createFakeTracking();
|
||||
const { history } = await _createClient({ _tracking });
|
||||
|
|
|
@ -145,7 +145,6 @@ describe(__filename, () => {
|
|||
hotShotsClient.socket.emit('error', error);
|
||||
|
||||
sinon.assert.calledWith(_log.error, sinon.match(error.message));
|
||||
sinon.assert.calledWithMatch(_log.error, '%o', { err: error });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import SimulateClientError, {
|
||||
SimulateClientErrorBase,
|
||||
} from 'amo/pages/error-simulation/SimulateClientError';
|
||||
import { shallowUntilTarget } from 'tests/unit/helpers';
|
||||
|
||||
describe(__filename, () => {
|
||||
let clock;
|
||||
|
||||
beforeEach(() => {
|
||||
clock = sinon.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
clock.restore();
|
||||
});
|
||||
|
||||
function render(props = {}) {
|
||||
return shallowUntilTarget(
|
||||
<SimulateClientError {...props} />,
|
||||
SimulateClientErrorBase,
|
||||
);
|
||||
}
|
||||
|
||||
it('lets you trigger an error', () => {
|
||||
const root = render();
|
||||
|
||||
expect(() => {
|
||||
root.find('.SimulateClientError-error').simulate('click');
|
||||
}).toThrowError(/simulated client error/);
|
||||
});
|
||||
|
||||
it('toggles the trigger prompt', () => {
|
||||
const root = render();
|
||||
|
||||
const triggerPrompt = '💣 Go ahead, trigger an error';
|
||||
expect(root.find('.SimulateClientError-error').children()).toHaveText(
|
||||
triggerPrompt,
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
root.find('.SimulateClientError-error').simulate('click');
|
||||
}).toThrow();
|
||||
|
||||
root.update();
|
||||
expect(root.find('.SimulateClientError-error').children()).toHaveText(
|
||||
'Nice! Check Sentry',
|
||||
);
|
||||
|
||||
// Trigger the setTimeout() callback:
|
||||
clock.tick(3000);
|
||||
root.update();
|
||||
|
||||
expect(root.find('.SimulateClientError-error').children()).toHaveText(
|
||||
triggerPrompt,
|
||||
);
|
||||
});
|
||||
|
||||
it('can throw a render error', () => {
|
||||
const root = render();
|
||||
|
||||
expect(root).toHaveState('throwRenderError', false);
|
||||
|
||||
expect(() => {
|
||||
root.find('.SimulateClientError-render-error').simulate('click');
|
||||
}).toThrowError(/simulated client render error/);
|
||||
|
||||
expect(root).toHaveState('throwRenderError', true);
|
||||
});
|
||||
});
|
|
@ -1,42 +0,0 @@
|
|||
import { getDeploymentVersion } from 'amo/utils/build';
|
||||
|
||||
describe(__filename, () => {
|
||||
describe('getDeploymentVersion', () => {
|
||||
const getVersionJson = ({
|
||||
commit = '81728b8478c73d47bbe3688b2a40b25355b36939',
|
||||
version = '1.2.3',
|
||||
} = {}) => {
|
||||
return {
|
||||
commit,
|
||||
version,
|
||||
};
|
||||
};
|
||||
|
||||
it('returns the version found in the version.json file', () => {
|
||||
const versionJson = getVersionJson();
|
||||
|
||||
expect(getDeploymentVersion({ versionJson })).toEqual(
|
||||
versionJson.version,
|
||||
);
|
||||
});
|
||||
|
||||
it('returns the commit if version is undefined', () => {
|
||||
const versionJson = getVersionJson();
|
||||
delete versionJson.version;
|
||||
|
||||
expect(getDeploymentVersion({ versionJson })).toEqual(versionJson.commit);
|
||||
});
|
||||
|
||||
it('returns the commit if version is null', () => {
|
||||
const versionJson = getVersionJson({ version: null });
|
||||
|
||||
expect(getDeploymentVersion({ versionJson })).toEqual(versionJson.commit);
|
||||
});
|
||||
|
||||
it('returns the commit if version is an empty string', () => {
|
||||
const versionJson = getVersionJson({ version: '' });
|
||||
|
||||
expect(getDeploymentVersion({ versionJson })).toEqual(versionJson.commit);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
import { getSentryRelease } from 'amo/utils/sentry';
|
||||
|
||||
describe(__filename, () => {
|
||||
describe('getSentryRelease', () => {
|
||||
it('creates a release ID', () => {
|
||||
const version = '1.2.3';
|
||||
|
||||
expect(getSentryRelease({ version })).toEqual(
|
||||
`addons-frontend@${version}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -7,9 +7,6 @@ import webpack from 'webpack';
|
|||
|
||||
import 'amo/polyfill';
|
||||
import { getClientConfig } from 'amo/utils';
|
||||
import { getDeploymentVersion } from 'amo/utils/build';
|
||||
|
||||
import versionJson from './version';
|
||||
|
||||
export function getStyleRules({
|
||||
bundleStylesWithJs = false,
|
||||
|
@ -135,7 +132,6 @@ export function getPlugins({ excludeOtherAppLocales = true } = {}) {
|
|||
new webpack.DefinePlugin({
|
||||
CLIENT_CONFIG: JSON.stringify(clientConfig),
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
DEPLOYMENT_VERSION: JSON.stringify(getDeploymentVersion({ versionJson })),
|
||||
}),
|
||||
// Since the NodeJS code does not run from a webpack bundle, here
|
||||
// are a few replacements that affect only the client side bundle.
|
||||
|
|
62
yarn.lock
62
yarn.lock
|
@ -3206,11 +3206,6 @@ character-reference-invalid@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz#083329cda0eae272ab3dbbf37e9a382c13af1560"
|
||||
integrity sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==
|
||||
|
||||
charenc@0.0.2:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
|
||||
integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=
|
||||
|
||||
cheerio-select-tmp@^0.1.0:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/cheerio-select-tmp/-/cheerio-select-tmp-0.1.1.tgz#55bbef02a4771710195ad736d5e346763ca4e646"
|
||||
|
@ -3710,16 +3705,16 @@ cookie-signature@^1.0.6:
|
|||
resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.1.0.tgz#cc94974f91fb9a9c1bb485e95fc2b7f4b120aff2"
|
||||
integrity sha512-Alvs19Vgq07eunykd3Xy2jF0/qSNv2u7KDbAek9H5liV1UMijbqFs5cycZvv5dVsvseT/U4H8/7/w8Koh35C4A==
|
||||
|
||||
cookie@0.3.1, cookie@^0.3.1:
|
||||
version "0.3.1"
|
||||
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
|
||||
integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=
|
||||
|
||||
cookie@0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
|
||||
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==
|
||||
|
||||
cookie@^0.3.1:
|
||||
version "0.3.1"
|
||||
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
|
||||
integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=
|
||||
|
||||
cookie@^0.4.0:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1"
|
||||
|
@ -3847,11 +3842,6 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
|
|||
shebang-command "^2.0.0"
|
||||
which "^2.0.1"
|
||||
|
||||
crypt@0.0.2:
|
||||
version "0.0.2"
|
||||
resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b"
|
||||
integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=
|
||||
|
||||
crypto-browserify@^3.11.0:
|
||||
version "3.12.0"
|
||||
resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec"
|
||||
|
@ -6693,7 +6683,7 @@ is-boolean-object@^1.0.1:
|
|||
dependencies:
|
||||
call-bind "^1.0.0"
|
||||
|
||||
is-buffer@^1.1.5, is-buffer@~1.1.6:
|
||||
is-buffer@^1.1.5:
|
||||
version "1.1.6"
|
||||
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
|
||||
integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==
|
||||
|
@ -8367,15 +8357,6 @@ md5.js@^1.3.4:
|
|||
inherits "^2.0.1"
|
||||
safe-buffer "^5.1.2"
|
||||
|
||||
md5@^2.2.1:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/md5/-/md5-2.3.0.tgz#c3da9a6aae3a30b46b7b0c349b87b110dc3bda4f"
|
||||
integrity sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==
|
||||
dependencies:
|
||||
charenc "0.0.2"
|
||||
crypt "0.0.2"
|
||||
is-buffer "~1.1.6"
|
||||
|
||||
mdast-util-compact@^1.0.0:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/mdast-util-compact/-/mdast-util-compact-1.0.4.tgz#d531bb7667b5123abf20859be086c4d06c894593"
|
||||
|
@ -10706,22 +10687,6 @@ range-parser@^1.2.0, range-parser@^1.2.1, range-parser@~1.2.0, range-parser@~1.2
|
|||
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
|
||||
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
|
||||
|
||||
raven-js@3.27.2:
|
||||
version "3.27.2"
|
||||
resolved "https://registry.yarnpkg.com/raven-js/-/raven-js-3.27.2.tgz#6c33df952026cd73820aa999122b7b7737a66775"
|
||||
integrity sha512-mFWQcXnhRFEQe5HeFroPaEghlnqy7F5E2J3Fsab189ondqUzcjwSVi7el7F36cr6PvQYXoZ1P2F5CSF2/azeMQ==
|
||||
|
||||
raven@2.6.4:
|
||||
version "2.6.4"
|
||||
resolved "https://registry.yarnpkg.com/raven/-/raven-2.6.4.tgz#458d4a380c8fbb59e0150c655625aaf60c167ea3"
|
||||
integrity sha512-6PQdfC4+DQSFncowthLf+B6Hr0JpPsFBgTVYTAOq7tCmx/kR4SXbeawtPch20+3QfUcQDoJBLjWW1ybvZ4kXTw==
|
||||
dependencies:
|
||||
cookie "0.3.1"
|
||||
md5 "^2.2.1"
|
||||
stack-trace "0.0.10"
|
||||
timed-out "4.0.1"
|
||||
uuid "3.3.2"
|
||||
|
||||
raw-body@2.4.0:
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332"
|
||||
|
@ -12203,11 +12168,6 @@ stack-chain@^1.3.7:
|
|||
resolved "https://registry.yarnpkg.com/stack-chain/-/stack-chain-1.3.7.tgz#d192c9ff4ea6a22c94c4dd459171e3f00cea1285"
|
||||
integrity sha1-0ZLJ/06moiyUxN1FkXHj8AzqEoU=
|
||||
|
||||
stack-trace@0.0.10:
|
||||
version "0.0.10"
|
||||
resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0"
|
||||
integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=
|
||||
|
||||
stack-utils@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.4.tgz#4b600971dcfc6aed0cbdf2a8268177cc916c87c8"
|
||||
|
@ -12991,11 +12951,6 @@ through@^2.3.8:
|
|||
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
|
||||
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
|
||||
|
||||
timed-out@4.0.1:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f"
|
||||
integrity sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=
|
||||
|
||||
timers-browserify@^2.0.4:
|
||||
version "2.0.12"
|
||||
resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.12.tgz#44a45c11fbf407f34f97bccd1577c652361b00ee"
|
||||
|
@ -13620,11 +13575,6 @@ utils-merge@1.0.1, utils-merge@^1.0.1:
|
|||
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
|
||||
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
|
||||
|
||||
uuid@3.3.2:
|
||||
version "3.3.2"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
|
||||
integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==
|
||||
|
||||
uuid@8.3.2, uuid@^8.3.0:
|
||||
version "8.3.2"
|
||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
|
|
Загрузка…
Ссылка в новой задаче