{t("encrypted.tooltip")}
diff --git a/src/components/ShortcutsDialog.tsx b/src/components/ShortcutsDialog.tsx
index c9b2e1ca6..9a7ffa2db 100644
--- a/src/components/ShortcutsDialog.tsx
+++ b/src/components/ShortcutsDialog.tsx
@@ -4,6 +4,7 @@ import { isDarwin } from "../keys";
import { Dialog } from "./Dialog";
import { getShortcutKey } from "../utils";
import "./ShortcutsDialog.scss";
+import { EVENT_EXIT, trackEvent } from "../analytics";
const Columns = (props: { children: React.ReactNode }) => (
(
href="https://blog.excalidraw.com"
target="_blank"
rel="noopener noreferrer"
+ onClick={() => {
+ trackEvent(EVENT_EXIT, "blog");
+ }}
>
{t("shortcutsDialog.blog")}
@@ -98,6 +102,9 @@ const Footer = () => (
href="https://howto.excalidraw.com"
target="_blank"
rel="noopener noreferrer"
+ onClick={() => {
+ trackEvent(EVENT_EXIT, "guides");
+ }}
>
{t("shortcutsDialog.howto")}
@@ -105,6 +112,9 @@ const Footer = () => (
href="https://github.com/excalidraw/excalidraw/issues"
target="_blank"
rel="noopener noreferrer"
+ onClick={() => {
+ trackEvent(EVENT_EXIT, "issues");
+ }}
>
{t("shortcutsDialog.github")}
diff --git a/src/data/blob.ts b/src/data/blob.ts
index 012090940..224dc216d 100644
--- a/src/data/blob.ts
+++ b/src/data/blob.ts
@@ -7,6 +7,7 @@ import { calculateScrollCenter } from "../scene";
import { MIME_TYPES } from "../constants";
import { CanvasError } from "../errors";
import { clearElementsForExport } from "../element";
+import { EVENT_ACTION, trackEvent } from "../analytics";
export const parseFileContents = async (blob: Blob | File) => {
let contents: string;
@@ -89,7 +90,7 @@ export const loadFromBlob = async (
if (data.type !== "excalidraw") {
throw new Error(t("alerts.couldNotLoadInvalidFile"));
}
- return restore(
+ const result = restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
@@ -109,6 +110,9 @@ export const loadFromBlob = async (
},
localAppState,
);
+
+ trackEvent(EVENT_ACTION, "load", getMimeType(blob));
+ return result;
} catch (error) {
console.error(error.message);
throw new Error(t("alerts.couldNotLoadInvalidFile"));
diff --git a/src/data/index.ts b/src/data/index.ts
index 171df12c7..a89579368 100644
--- a/src/data/index.ts
+++ b/src/data/index.ts
@@ -20,6 +20,7 @@ import { ExportType } from "../scene/types";
import { restore } from "./restore";
import { ImportedDataState } from "./types";
import { canvasToBlob } from "./blob";
+import { EVENT_ACTION, trackEvent } from "../analytics";
export { loadFromBlob } from "./blob";
export { saveAsJSON, loadFromJSON } from "./json";
@@ -263,6 +264,7 @@ const importFromBackend = async (
data = await response.json();
}
+ trackEvent(EVENT_ACTION, "import");
return {
elements: data.elements || null,
appState: data.appState || null,
diff --git a/src/data/json.ts b/src/data/json.ts
index 37aec4133..2eb4f9502 100644
--- a/src/data/json.ts
+++ b/src/data/json.ts
@@ -42,7 +42,6 @@ export const saveAsJSON = async (
},
appState.fileHandle,
);
-
return { fileHandle };
};
diff --git a/src/global.d.ts b/src/global.d.ts
index c72b46e46..25a7d1fc8 100644
--- a/src/global.d.ts
+++ b/src/global.d.ts
@@ -12,6 +12,7 @@ interface Document {
interface Window {
ClipboardItem: any;
__EXCALIDRAW_SHA__: string | undefined;
+ gtag: Function;
}
// https://github.com/facebook/create-react-app/blob/ddcb7d5/packages/react-scripts/lib/react-app.d.ts
diff --git a/src/i18n.ts b/src/i18n.ts
index 9742e4f8b..279a08ccb 100644
--- a/src/i18n.ts
+++ b/src/i18n.ts
@@ -1,4 +1,5 @@
import LanguageDetector from "i18next-browser-languagedetector";
+import { EVENT_CHANGE, trackEvent } from "./analytics";
import fallbackLanguageData from "./locales/en.json";
import percentages from "./locales/percentages.json";
@@ -67,8 +68,8 @@ export const setLanguage = async (newLng: string | undefined) => {
currentLanguageData = await import(
/* webpackChunkName: "i18n-[request]" */ `./locales/${currentLanguage.lng}.json`
);
-
languageDetector.cacheUserLanguage(currentLanguage.lng);
+ trackEvent(EVENT_CHANGE, "language", currentLanguage.lng);
};
export const setLanguageFirstTime = async () => {
@@ -84,6 +85,7 @@ export const setLanguageFirstTime = async () => {
);
languageDetector.cacheUserLanguage(currentLanguage.lng);
+ trackEvent(EVENT_CHANGE, "language on load", currentLanguage.lng);
};
export const getLanguage = () => currentLanguage;