mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Add more events for sharing and refactor I/O, dialogs (#2443)
This commit is contained in:
parent
c43109a230
commit
66e5b18e4e
10 changed files with 87 additions and 75 deletions
|
@ -181,7 +181,7 @@ import {
|
|||
isSavedToFirebase,
|
||||
} from "../data/firebase";
|
||||
import { getNewZoom } from "../scene/zoom";
|
||||
import { EVENT_SHAPE, trackEvent } from "../analytics";
|
||||
import { EVENT_SHAPE, EVENT_SHARE, trackEvent } from "../analytics";
|
||||
|
||||
/**
|
||||
* @param func handler taking at most single parameter (event).
|
||||
|
@ -657,8 +657,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
// when joining a room we don't want user's local scene data to be merged
|
||||
// into the remote scene
|
||||
this.resetScene();
|
||||
|
||||
this.initializeSocketClient({ showLoadingState: true });
|
||||
trackEvent(EVENT_SHARE, "session join");
|
||||
} else if (scene) {
|
||||
if (scene.appState) {
|
||||
scene.appState = {
|
||||
|
@ -1262,12 +1262,14 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
this.scene.replaceAllElements(this.scene.getElements());
|
||||
|
||||
await this.initializeSocketClient({ showLoadingState: false });
|
||||
trackEvent(EVENT_SHARE, "session start");
|
||||
};
|
||||
|
||||
closePortal = () => {
|
||||
this.saveCollabRoomToFirebase();
|
||||
window.history.pushState({}, "Excalidraw", window.location.origin);
|
||||
this.destroySocketClient();
|
||||
trackEvent(EVENT_SHARE, "session end");
|
||||
};
|
||||
|
||||
toggleLock = () => {
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
import "./ExportDialog.scss";
|
||||
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { render, unmountComponentAtNode } from "react-dom";
|
||||
|
||||
import { ToolButton } from "./ToolButton";
|
||||
import { clipboard, exportFile, link } from "./icons";
|
||||
import { NonDeletedExcalidrawElement } from "../element/types";
|
||||
import { AppState } from "../types";
|
||||
import { exportToCanvas, getExportSize } from "../scene/export";
|
||||
import { ActionsManagerInterface } from "../actions/types";
|
||||
import Stack from "./Stack";
|
||||
import { t } from "../i18n";
|
||||
|
||||
import { EVENT_DIALOG, trackEvent } from "../analytics";
|
||||
import { probablySupportsClipboardBlob } from "../clipboard";
|
||||
import { getSelectedElements, isSomeElementSelected } from "../scene";
|
||||
import useIsMobile from "../is-mobile";
|
||||
import { Dialog } from "./Dialog";
|
||||
import { canvasToBlob } from "../data/blob";
|
||||
import { NonDeletedExcalidrawElement } from "../element/types";
|
||||
import { CanvasError } from "../errors";
|
||||
import { EVENT_ACTION, trackEvent } from "../analytics";
|
||||
import { t } from "../i18n";
|
||||
import useIsMobile from "../is-mobile";
|
||||
import { getSelectedElements, isSomeElementSelected } from "../scene";
|
||||
import { exportToCanvas, getExportSize } from "../scene/export";
|
||||
import { AppState } from "../types";
|
||||
import { Dialog } from "./Dialog";
|
||||
import "./ExportDialog.scss";
|
||||
import { clipboard, exportFile, link } from "./icons";
|
||||
import Stack from "./Stack";
|
||||
import { ToolButton } from "./ToolButton";
|
||||
|
||||
const scales = [1, 2, 3];
|
||||
const defaultScale = scales.includes(devicePixelRatio) ? devicePixelRatio : 1;
|
||||
|
@ -252,7 +249,7 @@ export const ExportDialog = ({
|
|||
<>
|
||||
<ToolButton
|
||||
onClick={() => {
|
||||
trackEvent(EVENT_ACTION, "export", "dialog");
|
||||
trackEvent(EVENT_DIALOG, "export");
|
||||
setModalIsShown(true);
|
||||
}}
|
||||
icon={exportFile}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import React, { useState, useEffect, useRef } from "react";
|
||||
import clsx from "clsx";
|
||||
import { ToolButton } from "./ToolButton";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { EVENT_DIALOG, EVENT_SHARE, trackEvent } from "../analytics";
|
||||
import { copyTextToSystemClipboard } from "../clipboard";
|
||||
import { t } from "../i18n";
|
||||
import useIsMobile from "../is-mobile";
|
||||
import { users, clipboard, start, stop } from "./icons";
|
||||
|
||||
import "./RoomDialog.scss";
|
||||
import { copyTextToSystemClipboard } from "../clipboard";
|
||||
import { Dialog } from "./Dialog";
|
||||
import { AppState } from "../types";
|
||||
import { KEYS } from "../keys";
|
||||
import { AppState } from "../types";
|
||||
import { Dialog } from "./Dialog";
|
||||
import { clipboard, start, stop, users } from "./icons";
|
||||
import "./RoomDialog.scss";
|
||||
import { ToolButton } from "./ToolButton";
|
||||
|
||||
const RoomModal = ({
|
||||
activeRoomLink,
|
||||
|
@ -33,6 +33,7 @@ const RoomModal = ({
|
|||
const copyRoomLink = async () => {
|
||||
try {
|
||||
await copyTextToSystemClipboard(activeRoomLink);
|
||||
trackEvent(EVENT_SHARE, "copy link");
|
||||
} catch (error) {
|
||||
setErrorMessage(error.message);
|
||||
}
|
||||
|
@ -95,6 +96,7 @@ const RoomModal = ({
|
|||
value={username || ""}
|
||||
className="RoomDialog-username TextInput"
|
||||
onChange={(event) => onUsernameChange(event.target.value)}
|
||||
onBlur={() => trackEvent(EVENT_SHARE, "name")}
|
||||
onKeyPress={(event) =>
|
||||
event.key === KEYS.ENTER && onPressingEnter()
|
||||
}
|
||||
|
@ -161,7 +163,10 @@ export const RoomDialog = ({
|
|||
className={clsx("RoomDialog-modalButton", {
|
||||
"is-collaborating": isCollaborating,
|
||||
})}
|
||||
onClick={() => setModalIsShown(true)}
|
||||
onClick={() => {
|
||||
trackEvent(EVENT_DIALOG, "collaboration");
|
||||
setModalIsShown(true);
|
||||
}}
|
||||
icon={users}
|
||||
type="button"
|
||||
title={t("buttons.roomDialog")}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue