fix: delay version logging & prevent duplicates (#2770)
This commit is contained in:
parent
62f1ed74f1
commit
adcd28f348
@ -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,
|
||||
|
@ -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
|
||||
);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user