mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-10-26 11:08:40 +03:00
remove metrics code from welcome package
This commit is contained in:
parent
fd476842cc
commit
598222a4cf
@ -7,15 +7,6 @@ export default class ChangeLogView {
|
||||
constructor(props) {
|
||||
this.props = props;
|
||||
etch.initialize(this);
|
||||
|
||||
this.element.addEventListener('click', event => {
|
||||
const link = event.target.closest('a');
|
||||
if (link && link.dataset.event) {
|
||||
this.props.reporterProxy.sendEvent(
|
||||
`clicked-welcome-${link.dataset.event}-link`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
didChangeShowChangeLog() {
|
||||
|
@ -16,9 +16,6 @@ export default class GuideView {
|
||||
this.didClickStylingButton = this.didClickStylingButton.bind(this);
|
||||
this.didClickInitScriptButton = this.didClickInitScriptButton.bind(this);
|
||||
this.didClickSnippetsButton = this.didClickSnippetsButton.bind(this);
|
||||
this.didExpandOrCollapseSection = this.didExpandOrCollapseSection.bind(
|
||||
this
|
||||
);
|
||||
etch.initialize(this);
|
||||
}
|
||||
|
||||
@ -358,8 +355,7 @@ export default class GuideView {
|
||||
|
||||
getSectionProps(sectionName) {
|
||||
const props = {
|
||||
dataset: { section: sectionName },
|
||||
onclick: this.didExpandOrCollapseSection
|
||||
dataset: { section: sectionName }
|
||||
};
|
||||
if (
|
||||
this.props.openSections &&
|
||||
@ -415,7 +411,6 @@ export default class GuideView {
|
||||
}
|
||||
|
||||
didClickProjectButton() {
|
||||
this.props.reporterProxy.sendEvent('clicked-project-cta');
|
||||
atom.commands.dispatch(
|
||||
atom.views.getView(atom.workspace),
|
||||
'application:open'
|
||||
@ -423,7 +418,6 @@ export default class GuideView {
|
||||
}
|
||||
|
||||
didClickGitButton() {
|
||||
this.props.reporterProxy.sendEvent('clicked-git-cta');
|
||||
atom.commands.dispatch(
|
||||
atom.views.getView(atom.workspace),
|
||||
'github:toggle-git-tab'
|
||||
@ -431,7 +425,6 @@ export default class GuideView {
|
||||
}
|
||||
|
||||
didClickGitHubButton() {
|
||||
this.props.reporterProxy.sendEvent('clicked-github-cta');
|
||||
atom.commands.dispatch(
|
||||
atom.views.getView(atom.workspace),
|
||||
'github:toggle-github-tab'
|
||||
@ -439,40 +432,26 @@ export default class GuideView {
|
||||
}
|
||||
|
||||
didClickPackagesButton() {
|
||||
this.props.reporterProxy.sendEvent('clicked-packages-cta');
|
||||
atom.workspace.open('atom://config/install', { split: 'left' });
|
||||
}
|
||||
|
||||
didClickThemesButton() {
|
||||
this.props.reporterProxy.sendEvent('clicked-themes-cta');
|
||||
atom.workspace.open('atom://config/themes', { split: 'left' });
|
||||
}
|
||||
|
||||
didClickStylingButton() {
|
||||
this.props.reporterProxy.sendEvent('clicked-styling-cta');
|
||||
atom.workspace.open('atom://.pulsar/stylesheet', { split: 'left' });
|
||||
}
|
||||
|
||||
didClickInitScriptButton() {
|
||||
this.props.reporterProxy.sendEvent('clicked-init-script-cta');
|
||||
atom.workspace.open('atom://.pulsar/init-script', { split: 'left' });
|
||||
}
|
||||
|
||||
didClickSnippetsButton() {
|
||||
this.props.reporterProxy.sendEvent('clicked-snippets-cta');
|
||||
atom.workspace.open('atom://.pulsar/snippets', { split: 'left' });
|
||||
}
|
||||
|
||||
didClickTeletypeButton() {
|
||||
this.props.reporterProxy.sendEvent('clicked-teletype-cta');
|
||||
atom.workspace.open('atom://config/packages/teletype', { split: 'left' });
|
||||
}
|
||||
|
||||
didExpandOrCollapseSection(event) {
|
||||
const sectionName = event.currentTarget.closest('details').dataset.section;
|
||||
const action = event.currentTarget.hasAttribute('open')
|
||||
? 'collapse'
|
||||
: 'expand';
|
||||
this.props.reporterProxy.sendEvent(`${action}-${sectionName}-section`);
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
/** @babel */
|
||||
|
||||
export default class ReporterProxy {
|
||||
constructor() {
|
||||
this.reporter = null;
|
||||
this.queue = [];
|
||||
this.eventType = 'welcome-v1';
|
||||
}
|
||||
|
||||
setReporter(reporter) {
|
||||
this.reporter = reporter;
|
||||
let customEvent;
|
||||
|
||||
while ((customEvent = this.queue.shift())) {
|
||||
this.reporter.addCustomEvent(this.eventType, customEvent);
|
||||
}
|
||||
}
|
||||
|
||||
sendEvent(action, label, value) {
|
||||
const event = { ea: action, el: label, ev: value };
|
||||
if (this.reporter) {
|
||||
this.reporter.addCustomEvent(this.eventType, event);
|
||||
} else {
|
||||
this.queue.push(event);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
/** @babel */
|
||||
|
||||
import { CompositeDisposable } from 'atom';
|
||||
import ReporterProxy from './reporter-proxy';
|
||||
|
||||
let WelcomeView, GuideView, ChangeLogView;
|
||||
|
||||
@ -10,10 +9,6 @@ const GUIDE_URI = 'atom://welcome/guide';
|
||||
const CHANGELOG_URI = 'atom://welcome/changelog';
|
||||
|
||||
export default class WelcomePackage {
|
||||
constructor() {
|
||||
this.reporterProxy = new ReporterProxy();
|
||||
}
|
||||
|
||||
async activate() {
|
||||
this.subscriptions = new CompositeDisposable();
|
||||
|
||||
@ -51,7 +46,6 @@ export default class WelcomePackage {
|
||||
|
||||
if (atom.config.get('welcome.showOnStartup')) {
|
||||
await this.show();
|
||||
this.reporterProxy.sendEvent('show-on-initial-load');
|
||||
}
|
||||
|
||||
if (atom.config.get('welcome.showChangeLog')) {
|
||||
@ -86,26 +80,22 @@ export default class WelcomePackage {
|
||||
}
|
||||
}
|
||||
|
||||
consumeReporter(reporter) {
|
||||
return this.reporterProxy.setReporter(reporter);
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this.subscriptions.dispose();
|
||||
}
|
||||
|
||||
createWelcomeView(state) {
|
||||
if (WelcomeView == null) WelcomeView = require('./welcome-view');
|
||||
return new WelcomeView({ reporterProxy: this.reporterProxy, ...state });
|
||||
return new WelcomeView(state);
|
||||
}
|
||||
|
||||
createGuideView(state) {
|
||||
if (GuideView == null) GuideView = require('./guide-view');
|
||||
return new GuideView({ reporterProxy: this.reporterProxy, ...state });
|
||||
return new GuideView(state);
|
||||
}
|
||||
|
||||
createChangeLogView(state) {
|
||||
if (ChangeLogView == null) ChangeLogView = require("./changelog-view");
|
||||
return new ChangeLogView({ reporterProxy: this.reporterProxy, ...state });
|
||||
return new ChangeLogView(state);
|
||||
}
|
||||
}
|
||||
|
@ -9,15 +9,6 @@ export default class WelcomeView {
|
||||
this.props = props;
|
||||
this.brand = atom.branding.name;
|
||||
etch.initialize(this);
|
||||
|
||||
this.element.addEventListener('click', event => {
|
||||
const link = event.target.closest('a');
|
||||
if (link && link.dataset.event) {
|
||||
this.props.reporterProxy.sendEvent(
|
||||
`clicked-welcome-${link.dataset.event}-link`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
didChangeShowOnStartup() {
|
||||
|
@ -98,84 +98,5 @@ describe('Welcome', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('reporting events', () => {
|
||||
let panes, guideView, reportedEvents;
|
||||
beforeEach(() => {
|
||||
panes = atom.workspace.getCenter().getPanes();
|
||||
guideView = panes[1].getItems()[0];
|
||||
reportedEvents = [];
|
||||
|
||||
welcomePackage.reporterProxy.sendEvent = (...event) => {
|
||||
reportedEvents.push(event);
|
||||
};
|
||||
});
|
||||
|
||||
describe('GuideView events', () => {
|
||||
it('captures expand and collapse events', () => {
|
||||
guideView.element
|
||||
.querySelector('details[data-section="packages"] summary')
|
||||
.click();
|
||||
assert.deepEqual(reportedEvents, [['expand-packages-section']]);
|
||||
|
||||
guideView.element
|
||||
.querySelector('details[data-section="packages"]')
|
||||
.setAttribute('open', 'open');
|
||||
guideView.element
|
||||
.querySelector('details[data-section="packages"] summary')
|
||||
.click();
|
||||
assert.deepEqual(reportedEvents, [
|
||||
['expand-packages-section'],
|
||||
['collapse-packages-section']
|
||||
]);
|
||||
});
|
||||
|
||||
it('captures button events', () => {
|
||||
for (const detailElement of Array.from(
|
||||
guideView.element.querySelector('details')
|
||||
)) {
|
||||
reportedEvents.length = 0;
|
||||
|
||||
const sectionName = detailElement.dataset.section;
|
||||
const eventName = `clicked-${sectionName}-cta`;
|
||||
const primaryButton = detailElement.querySelector('.btn-primary');
|
||||
if (primaryButton) {
|
||||
primaryButton.click();
|
||||
assert.deepEqual(reportedEvents, [[eventName]]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the reporter changes', () =>
|
||||
it('sends all queued events', () => {
|
||||
welcomePackage.reporterProxy.queue.length = 0;
|
||||
|
||||
const reporter1 = {
|
||||
addCustomEvent(category, event) {
|
||||
this.reportedEvents.push({ category, ...event });
|
||||
},
|
||||
reportedEvents: []
|
||||
};
|
||||
const reporter2 = {
|
||||
addCustomEvent(category, event) {
|
||||
this.reportedEvents.push({ category, ...event });
|
||||
},
|
||||
reportedEvents: []
|
||||
};
|
||||
|
||||
welcomePackage.reporterProxy.sendEvent('foo', 'bar', 10);
|
||||
welcomePackage.reporterProxy.sendEvent('foo2', 'bar2', 60);
|
||||
welcomePackage.reporterProxy.setReporter(reporter1);
|
||||
|
||||
assert.deepEqual(reporter1.reportedEvents, [
|
||||
{ category: 'welcome-v1', ea: 'foo', el: 'bar', ev: 10 },
|
||||
{ category: 'welcome-v1', ea: 'foo2', el: 'bar2', ev: 60 }
|
||||
]);
|
||||
|
||||
welcomePackage.consumeReporter(reporter2);
|
||||
assert.deepEqual(reporter2.reportedEvents, []);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user