chore: add ga for most actions (#4829)

This commit is contained in:
David Luzar 2022-03-28 14:46:40 +02:00 committed by GitHub
parent e940aeb1a3
commit f242721f3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 221 additions and 93 deletions

View file

@ -38,7 +38,6 @@ import { ActionResult } from "../actions/types";
import { trackEvent } from "../analytics";
import { getDefaultAppState, isEraserActive } from "../appState";
import {
copyToClipboard,
parseClipboard,
probablySupportsClipboardBlob,
probablySupportsClipboardWriteText,
@ -1291,12 +1290,11 @@ class App extends React.Component<AppProps, AppState> {
});
private cutAll = () => {
this.copyAll();
this.actionManager.executeAction(actionDeleteSelected);
this.actionManager.executeAction(actionCut, "keyboard");
};
private copyAll = () => {
copyToClipboard(this.scene.getElements(), this.state, this.files);
this.actionManager.executeAction(actionCopy, "keyboard");
};
private static resetTapTwice() {
@ -1570,7 +1568,14 @@ class App extends React.Component<AppProps, AppState> {
gesture.pointers.delete(event.pointerId);
};
toggleLock = () => {
toggleLock = (source: "keyboard" | "ui" = "ui") => {
if (!this.state.elementLocked) {
trackEvent(
"toolbar",
"toggleLock",
`${source} (${this.deviceType.isMobile ? "mobile" : "desktop"})`,
);
}
this.setState((prevState) => {
return {
elementLocked: !prevState.elementLocked,
@ -1594,9 +1599,6 @@ class App extends React.Component<AppProps, AppState> {
};
toggleStats = () => {
if (!this.state.showStats) {
trackEvent("dialog", "stats");
}
this.actionManager.executeAction(actionToggleStats);
};
@ -1851,9 +1853,16 @@ class App extends React.Component<AppProps, AppState> {
) {
const shape = findShapeByKey(event.key);
if (shape) {
if (this.state.activeTool.type !== shape) {
trackEvent(
"toolbar",
shape,
`keyboard (${this.deviceType.isMobile ? "mobile" : "desktop"})`,
);
}
this.setActiveTool({ type: shape });
} else if (event.key === KEYS.Q) {
this.toggleLock();
this.toggleLock("keyboard");
}
}
if (event.key === KEYS.SPACE && gesture.pointers.size === 0) {
@ -5493,6 +5502,7 @@ class App extends React.Component<AppProps, AppState> {
options: [
this.deviceType.isMobile &&
navigator.clipboard && {
trackEvent: false,
name: "paste",
perform: (elements, appStates) => {
this.pasteFromClipboard(null);
@ -5549,6 +5559,7 @@ class App extends React.Component<AppProps, AppState> {
this.deviceType.isMobile &&
navigator.clipboard && {
name: "paste",
trackEvent: false,
perform: (elements, appStates) => {
this.pasteFromClipboard(null);
return {