Skip to content

Commit ce7e652

Browse files
authored
Merge pull request #4166 from paulkaplan/reduce-analytics-events
Reduce analytics events
2 parents 77fb9b6 + 6fe27f7 commit ce7e652

File tree

6 files changed

+11
-61
lines changed

6 files changed

+11
-61
lines changed

src/containers/blocks.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import React from 'react';
77
import VMScratchBlocks from '../lib/blocks';
88
import VM from 'scratch-vm';
99

10-
import analytics from '../lib/analytics';
1110
import log from '../lib/log.js';
1211
import Prompt from './prompt.jsx';
1312
import BlocksComponent from '../components/blocks/blocks.jsx';
@@ -113,8 +112,6 @@ class Blocks extends React.Component {
113112
if (this.props.isVisible) {
114113
this.setLocale();
115114
}
116-
117-
analytics.pageview('/editors/blocks');
118115
}
119116
shouldComponentUpdate (nextProps, nextState) {
120117
return (

src/containers/error-boundary.jsx

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import {connect} from 'react-redux';
4-
import bowser from 'bowser';
54
import BrowserModalComponent from '../components/browser-modal/browser-modal.jsx';
65
import CrashMessageComponent from '../components/crash-message/crash-message.jsx';
76
import log from '../lib/log.js';
87
import supportedBrowser from '../lib/supported-browser';
9-
import analytics from '../lib/analytics';
108

119
class ErrorBoundary extends React.Component {
1210
constructor (props) {
@@ -24,35 +22,23 @@ class ErrorBoundary extends React.Component {
2422
message: 'Unknown error'
2523
};
2624

25+
// Log errors to analytics, leaving out supported browsers from unsupported.
26+
if (supportedBrowser() && window.Sentry) {
27+
window.Sentry.withScope(scope => {
28+
Object.keys(info).forEach(key => {
29+
scope.setExtra(key, info[key]);
30+
});
31+
scope.setExtra('action', this.props.action);
32+
window.Sentry.captureException(error);
33+
});
34+
}
35+
2736
// Display fallback UI
2837
this.setState({
2938
hasError: true,
3039
errorId: window.Sentry ? window.Sentry.lastEventId() : null
3140
});
3241

33-
// Log errors to analytics, separating supported browsers from unsupported.
34-
if (supportedBrowser()) {
35-
analytics.event({
36-
category: 'error',
37-
action: this.props.action,
38-
label: error.message
39-
});
40-
if (window.Sentry) {
41-
window.Sentry.withScope(scope => {
42-
Object.keys(info).forEach(key => {
43-
scope.setExtra(key, info[key]);
44-
});
45-
window.Sentry.captureException(error);
46-
});
47-
}
48-
} else {
49-
analytics.event({
50-
category: 'Unsupported Browser Error',
51-
action: `(Unsupported Browser) ${this.props.action}`,
52-
label: `${bowser.name} ${error.message}`
53-
});
54-
}
55-
5642
// Log error locally for debugging as well.
5743
log.error(`Unhandled Error: ${error.stack}\nComponent stack: ${info.componentStack}`);
5844
}

src/containers/paint-editor-wrapper.jsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import bindAll from 'lodash.bindall';
44
import VM from 'scratch-vm';
55
import PaintEditor from 'scratch-paint';
66

7-
import analytics from '../lib/analytics';
8-
97
import {connect} from 'react-redux';
108

119
class PaintEditorWrapper extends React.Component {
@@ -16,9 +14,6 @@ class PaintEditorWrapper extends React.Component {
1614
'handleUpdateName'
1715
]);
1816
}
19-
componentDidMount () {
20-
analytics.pageview('/editors/paint');
21-
}
2217
shouldComponentUpdate (nextProps) {
2318
return this.props.imageId !== nextProps.imageId ||
2419
this.props.rtl !== nextProps.rtl ||

src/containers/sound-editor.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class SoundEditor extends React.Component {
4444
}
4545
componentDidMount () {
4646
this.audioBufferPlayer = new AudioBufferPlayer(this.props.samples, this.props.sampleRate);
47-
analytics.pageview('/editors/sound');
4847
}
4948
componentWillReceiveProps (newProps) {
5049
if (newProps.soundId !== this.props.soundId) { // A different sound has been selected

src/lib/project-fetcher-hoc.jsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {connect} from 'react-redux';
77
import {setProjectUnchanged} from '../reducers/project-changed';
88
import {
99
LoadingStates,
10-
defaultProjectId,
1110
getIsCreatingNew,
1211
getIsFetchingWithId,
1312
getIsLoading,
@@ -21,7 +20,6 @@ import {
2120
BLOCKS_TAB_INDEX
2221
} from '../reducers/editor-tab';
2322

24-
import analytics from './analytics';
2523
import log from './log';
2624
import storage from './storage';
2725

@@ -81,17 +79,6 @@ const ProjectFetcherHOC = function (WrappedComponent) {
8179
throw new Error('Could not find project');
8280
}
8381
})
84-
.then(() => {
85-
if (projectId !== defaultProjectId) {
86-
// if not default project, register a project load event
87-
analytics.event({
88-
category: 'project',
89-
action: 'Load Project',
90-
label: projectId,
91-
nonInteraction: true
92-
});
93-
}
94-
})
9582
.catch(err => {
9683
this.props.onError(err);
9784
log.error(err);

src/reducers/modals.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import analytics from '../lib/analytics';
2-
31
const OPEN_MODAL = 'scratch-gui/modals/OPEN_MODAL';
42
const CLOSE_MODAL = 'scratch-gui/modals/CLOSE_MODAL';
53

@@ -59,51 +57,39 @@ const closeModal = function (modal) {
5957
};
6058
};
6159
const openBackdropLibrary = function () {
62-
analytics.pageview('/libraries/backdrops');
6360
return openModal(MODAL_BACKDROP_LIBRARY);
6461
};
6562
const openCameraCapture = function () {
66-
analytics.pageview('/modals/camera');
6763
return openModal(MODAL_CAMERA_CAPTURE);
6864
};
6965
const openCostumeLibrary = function () {
70-
analytics.pageview('/libraries/costumes');
7166
return openModal(MODAL_COSTUME_LIBRARY);
7267
};
7368
const openExtensionLibrary = function () {
74-
analytics.pageview('/libraries/extensions');
7569
return openModal(MODAL_EXTENSION_LIBRARY);
7670
};
7771
const openImportInfo = function () {
78-
analytics.pageview('modals/import');
7972
return openModal(MODAL_IMPORT_INFO);
8073
};
8174
const openLoadingProject = function () {
82-
analytics.pageview('modals/loading');
8375
return openModal(MODAL_LOADING_PROJECT);
8476
};
8577
const openPreviewInfo = function () {
86-
analytics.pageview('/modals/preview');
8778
return openModal(MODAL_PREVIEW_INFO);
8879
};
8980
const openSoundLibrary = function () {
90-
analytics.pageview('/libraries/sounds');
9181
return openModal(MODAL_SOUND_LIBRARY);
9282
};
9383
const openSpriteLibrary = function () {
94-
analytics.pageview('/libraries/sprites');
9584
return openModal(MODAL_SPRITE_LIBRARY);
9685
};
9786
const openSoundRecorder = function () {
98-
analytics.pageview('/modals/microphone');
9987
return openModal(MODAL_SOUND_RECORDER);
10088
};
10189
const openConnectionModal = function () {
102-
analytics.pageview('/modals/connection');
10390
return openModal(MODAL_CONNECTION);
10491
};
10592
const openTipsLibrary = function () {
106-
analytics.pageview('/modals/tips');
10793
return openModal(MODAL_TIPS_LIBRARY);
10894
};
10995
const closeBackdropLibrary = function () {

0 commit comments

Comments
 (0)