mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Add basic event actions to analytics (#2375)
Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
014097a97e
commit
abde1daba4
20 changed files with 183 additions and 61 deletions
|
@ -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"));
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -42,7 +42,6 @@ export const saveAsJSON = async (
|
|||
},
|
||||
appState.fileHandle,
|
||||
);
|
||||
|
||||
return { fileHandle };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue