Skip to content

Commit

Permalink
Fixes fathom dependency on networks store
Browse files Browse the repository at this point in the history
  • Loading branch information
karynemayer committed May 15, 2024
1 parent bb81f7e commit 9f860c8
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/boot/fathom.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { boot } from 'quasar/wrappers';
import { getChain } from 'src/config/ConfigManager';

import { useNetworksStore } from 'src/stores/networks';
declare const fathom: { trackEvent: (eventName: string) => void };

export default boot(({ app }) => {
const siteID = getChain().getFathomSiteId();
if (siteID) {
const script = document.createElement('script');
script.src = 'https://cdn.usefathom.com/script.js';
script.dataset.site = siteID;
script.dataset.spa = 'auto';
script.defer = true;
script.onload = () => {
app.config.globalProperties.$fathom = fathom;
};
document.body.appendChild(script);
const networksStore = useNetworksStore();
if (networksStore.currentNetworkName !== '') {
const siteID = networksStore.getCurrentNetwork.getFathomSiteId();
if (siteID) {
const script = document.createElement('script');
script.src = 'https://cdn.usefathom.com/script.js';
script.dataset.site = siteID;
script.dataset.spa = 'auto';
script.defer = true;
script.onload = () => {
app.config.globalProperties.$fathom = fathom;
};
document.body.appendChild(script);
}
}
});

0 comments on commit 9f860c8

Please sign in to comment.