mirror of
https://github.com/chinchang/web-maker.git
synced 2025-05-05 18:15:58 +02:00
add ui events
This commit is contained in:
parent
698de288e0
commit
e39e284705
@ -1,3 +1,5 @@
|
|||||||
|
import { trackEvent } from './analytics';
|
||||||
|
|
||||||
export const commandPaletteService = {
|
export const commandPaletteService = {
|
||||||
subscriptions: {},
|
subscriptions: {},
|
||||||
subscribe(eventName, callback) {
|
subscribe(eventName, callback) {
|
||||||
@ -11,6 +13,7 @@ export const commandPaletteService = {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
publish(eventName, ...args) {
|
publish(eventName, ...args) {
|
||||||
|
trackEvent('ui', 'commandPaletteCommandSelected', eventName);
|
||||||
const callbacks = this.subscriptions[eventName] || [];
|
const callbacks = this.subscriptions[eventName] || [];
|
||||||
callbacks.forEach(callback => {
|
callbacks.forEach(callback => {
|
||||||
callback(...args);
|
callback(...args);
|
||||||
|
@ -35,6 +35,7 @@ import emmet from '@emmetio/codemirror-plugin';
|
|||||||
import { prettify, loadCss } from '../utils';
|
import { prettify, loadCss } from '../utils';
|
||||||
import { modes } from '../codeModes';
|
import { modes } from '../codeModes';
|
||||||
import { deferred } from '../deferred';
|
import { deferred } from '../deferred';
|
||||||
|
import { trackEvent } from '../analytics';
|
||||||
|
|
||||||
emmet(CodeMirror);
|
emmet(CodeMirror);
|
||||||
let monacoDepsDeferred;
|
let monacoDepsDeferred;
|
||||||
@ -281,6 +282,7 @@ export default class CodeEditor extends Component {
|
|||||||
content: this.instance.getValue(),
|
content: this.instance.getValue(),
|
||||||
type: options.prettierParser
|
type: options.prettierParser
|
||||||
}).then(formattedCode => this.instance.setValue(formattedCode));
|
}).then(formattedCode => this.instance.setValue(formattedCode));
|
||||||
|
trackEvent('ui', 'prettifyKeyboardShortcut');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -332,6 +334,7 @@ export default class CodeEditor extends Component {
|
|||||||
type: options.prettierParser
|
type: options.prettierParser
|
||||||
}).then(formattedCode => editor.setValue(formattedCode));
|
}).then(formattedCode => editor.setValue(formattedCode));
|
||||||
}
|
}
|
||||||
|
trackEvent('ui', 'prettifyKeyboardShortcut');
|
||||||
},
|
},
|
||||||
Tab: function(editor) {
|
Tab: function(editor) {
|
||||||
if (options.emmet) {
|
if (options.emmet) {
|
||||||
|
@ -625,7 +625,7 @@ export default class ContentWrap extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
log('contentwrap update');
|
// log('contentwrap update');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SplitPane
|
<SplitPane
|
||||||
|
@ -638,6 +638,7 @@ export default class ContentWrapFiles extends Component {
|
|||||||
|
|
||||||
prettifyBtnClickHandler() {
|
prettifyBtnClickHandler() {
|
||||||
this.props.onPrettifyBtnClick(this.state.selectedFile);
|
this.props.onPrettifyBtnClick(this.state.selectedFile);
|
||||||
|
trackEvent('ui', 'prettifyBtnClick');
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
@ -4,6 +4,7 @@ import { ItemTile } from './ItemTile';
|
|||||||
import templates from '../templateList';
|
import templates from '../templateList';
|
||||||
import { Divider } from './common';
|
import { Divider } from './common';
|
||||||
import Switch from './Switch';
|
import Switch from './Switch';
|
||||||
|
import { trackEvent } from '../analytics';
|
||||||
|
|
||||||
export class CreateNewModal extends Component {
|
export class CreateNewModal extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -14,6 +15,11 @@ export class CreateNewModal extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
isFileModeSelected: e.target.checked
|
isFileModeSelected: e.target.checked
|
||||||
});
|
});
|
||||||
|
trackEvent(
|
||||||
|
'ui',
|
||||||
|
'newCreationModeChange',
|
||||||
|
e.target.checked ? 'files' : '3panes'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
@ -181,6 +187,7 @@ export class CreateNewModal extends Component {
|
|||||||
type="button"
|
type="button"
|
||||||
class="btn btn--primary"
|
class="btn btn--primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
trackEvent('ui', 'startBlankBtnClick');
|
||||||
this.state.isFileModeSelected
|
this.state.isFileModeSelected
|
||||||
? onBlankFileTemplateSelect()
|
? onBlankFileTemplateSelect()
|
||||||
: onBlankTemplateSelect();
|
: onBlankTemplateSelect();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
import { FileIcon } from './FileIcon';
|
import { FileIcon } from './FileIcon';
|
||||||
import { getParentPath, getFileFromPath } from '../fileUtils';
|
import { getParentPath, getFileFromPath } from '../fileUtils';
|
||||||
|
import { trackEvent } from '../analytics';
|
||||||
|
|
||||||
const ENTER_KEY = 13;
|
const ENTER_KEY = 13;
|
||||||
const ESCAPE_KEY = 27;
|
const ESCAPE_KEY = 27;
|
||||||
@ -119,9 +120,11 @@ function Folder(props) {
|
|||||||
export class SidePane extends Component {
|
export class SidePane extends Component {
|
||||||
addFileButtonClickHandler() {
|
addFileButtonClickHandler() {
|
||||||
this.setState({ isAddingFile: true });
|
this.setState({ isAddingFile: true });
|
||||||
|
trackEvent('ui', 'fileAddBtnClick');
|
||||||
}
|
}
|
||||||
addFolderButtonClickHandler() {
|
addFolderButtonClickHandler() {
|
||||||
this.setState({ isAddingFolder: true });
|
this.setState({ isAddingFolder: true });
|
||||||
|
trackEvent('ui', 'folderAddBtnClick');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Checks if the passed filename already exists and if so, warns the user.
|
* Checks if the passed filename already exists and if so, warns the user.
|
||||||
@ -173,6 +176,7 @@ export class SidePane extends Component {
|
|||||||
if (answer) {
|
if (answer) {
|
||||||
this.props.onRemoveFile(file.path);
|
this.props.onRemoveFile(file.path);
|
||||||
}
|
}
|
||||||
|
trackEvent('ui', 'fileRemoveBtnClick');
|
||||||
}
|
}
|
||||||
renameFile(e) {
|
renameFile(e) {
|
||||||
// This gets called twice when enter is pressed, because blur also fires.
|
// This gets called twice when enter is pressed, because blur also fires.
|
||||||
@ -200,6 +204,7 @@ export class SidePane extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
fileBeingRenamed: file
|
fileBeingRenamed: file
|
||||||
});
|
});
|
||||||
|
trackEvent('ui', 'fileRenameBtnClick');
|
||||||
}
|
}
|
||||||
|
|
||||||
dragOverHandler(e) {
|
dragOverHandler(e) {
|
||||||
|
@ -565,6 +565,11 @@ export default class App extends Component {
|
|||||||
isCommandPaletteOpen: true,
|
isCommandPaletteOpen: true,
|
||||||
isCommandPaletteInCommandMode: !!event.shiftKey
|
isCommandPaletteInCommandMode: !!event.shiftKey
|
||||||
});
|
});
|
||||||
|
trackEvent(
|
||||||
|
'ui',
|
||||||
|
'openCommandPaletteKeyboardShortcut',
|
||||||
|
!!event.shiftKey ? 'command' : 'files'
|
||||||
|
);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1355,6 +1360,7 @@ export default class App extends Component {
|
|||||||
this.createNewItem(true);
|
this.createNewItem(true);
|
||||||
this.setState({ isCreateNewModalOpen: false });
|
this.setState({ isCreateNewModalOpen: false });
|
||||||
} else {
|
} else {
|
||||||
|
trackEvent('ui', 'FileModeCreationLimitMessageSeen');
|
||||||
return alert(
|
return alert(
|
||||||
'"Files mode" is currently in beta and is limited to only 2 creations per user. You have already made 2 creations in Files mode.\n\nNote: You can choose to delete old ones to create new.'
|
'"Files mode" is currently in beta and is limited to only 2 creations per user. You have already made 2 creations in Files mode.\n\nNote: You can choose to delete old ones to create new.'
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user