Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

fix: delay version logging & prevent duplicates (#2770)

David Luzaradcd28f348c8
diff --git a/src/excalidraw-app/index.tsx b/src/excalidraw-app/index.tsx
index d63eb71b6a..9dbdf544fa 100644
--- a/src/excalidraw-app/index.tsx
+++ b/src/excalidraw-app/index.tsx
@@ -229,7 +229,19 @@ function ExcalidrawWrapper(props: { collab: CollabAPI }) {
const { collab } = props;
useEffect(() => {
- trackEvent("load", "version", getVersion());
+ // delayed by 15 sec so that the app has a time to load the latest SW
+ setTimeout(() => {
+ const version = getVersion();
+ const loggedVersion = window.localStorage.getItem(
+ "excalidraw-lastLoggedVersion",
+ );
+ // prevent logging on multiple visits
+ if (version && version !== loggedVersion) {
+ window.localStorage.setItem("excalidraw-lastLoggedVersion", version);
+ trackEvent("load", "version", version);
+ }
+ }, 15000);
+
excalidrawRef.current!.readyPromise.then((excalidrawApi) => {
initializeScene({
resetScene: excalidrawApi.resetScene,
diff --git a/src/utils.ts b/src/utils.ts
index 933765c2f6..936b2850c6 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -364,6 +364,8 @@ export const nFormatter = (num: number, digits: number): string => {
};
export const getVersion = () => {
- const version = document.querySelector('meta[name="version"]');
- return version ? (version as any).content : DEFAULT_VERSION;
+ return (
+ document.querySelector<HTMLMetaElement>('meta[name="version"]')?.content ||
+ DEFAULT_VERSION
+ );
};