Skip to content

Commit

Permalink
Merge pull request #846 from telosnetwork/839-add-fathom-analytics-to…
Browse files Browse the repository at this point in the history
…-explorer

#839 | adding fathom analytics
  • Loading branch information
pmjanus authored Apr 17, 2024
2 parents 61c485c + 94c35fe commit 9b0e499
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 34 deletions.
2 changes: 1 addition & 1 deletion quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = configure(function (ctx) {
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://quasar.dev/quasar-cli/boot-files
boot: ['config', 'axios', 'api', 'ual', 'fuel'],
boot: ['config', 'axios', 'fathom', 'api', 'ual', 'fuel'],

// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
css: ['app.sass'],
Expand Down
19 changes: 19 additions & 0 deletions src/boot/fathom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { boot } from 'quasar/wrappers';
import { getChain } from 'src/config/ConfigManager';

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);
}
});
67 changes: 34 additions & 33 deletions src/config/BaseChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,45 +63,46 @@ export const baseUiConfiguration: UiCustomization = {
};

export default abstract class BaseChain implements Chain {
protected name: string;
protected name: string;

constructor(name: string) {
this.name = name;
}
constructor(name: string) {
this.name = name;
}

getName(): string {
return this.name;
}
getName(): string {
return this.name;
}

getLargeLogoPath(): string {
return `~/assets/${this.name}/logo_lg.svg`;
}
getLargeLogoPath(): string {
return `~/assets/${this.name}/logo_lg.svg`;
}

getSmallLogoPath(): string {
return `~/assets/${this.name}/logo_sm.svg`;
}
getSmallLogoPath(): string {
return `~/assets/${this.name}/logo_sm.svg`;
}

abstract getSystemToken(): Token;
abstract getChainId(): string;
abstract getDisplay(): string;
abstract getHyperionEndpoint(): string;
abstract getRPCEndpoint(): RpcEndpoint;
abstract getFuelRPCEndpoint(): RpcEndpoint | null;
abstract getApiEndpoint(): string;
abstract getS3ProducerBucket(): string;
abstract getPriceData(): Promise<PriceChartData>;
abstract getUsdPrice(): Promise<number>;
abstract getMapDisplay(): boolean;
abstract getTheme(): Theme;
abstract getFooterLinks(): FooterLink[];
abstract getSystemToken(): Token;
abstract getChainId(): string;
abstract getDisplay(): string;
abstract getHyperionEndpoint(): string;
abstract getRPCEndpoint(): RpcEndpoint;
abstract getFuelRPCEndpoint(): RpcEndpoint | null;
abstract getApiEndpoint(): string;
abstract getS3ProducerBucket(): string;
abstract getPriceData(): Promise<PriceChartData>;
abstract getUsdPrice(): Promise<number>;
abstract getMapDisplay(): boolean;
abstract getTheme(): Theme;
abstract getFooterLinks(): FooterLink[];
abstract getFathomSiteId(): string | null;

getUiCustomization(): UiCustomization {
return baseUiConfiguration;
}
getUiCustomization(): UiCustomization {
return baseUiConfiguration;
}

abstract getFiltersSupported(prop: string): boolean;
abstract getFiltersSupported(prop: string): boolean;

isTestnet(): boolean {
return false;
}
isTestnet(): boolean {
return false;
}
}
4 changes: 4 additions & 0 deletions src/config/chains/eos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,8 @@ export default class EOS extends BaseChain {
{ label: 'REPOSITORY', url: 'https://github.com/telosnetwork/open-block-explorer' },
];
}

getFathomSiteId(): string | null {
return null;
}
}
5 changes: 5 additions & 0 deletions src/config/chains/jungle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,9 @@ export default class TelosTestnet extends BaseChain {
{ label: 'REPOSITORY', url: 'https://github.com/telosnetwork/open-block-explorer' },
];
}

getFathomSiteId(): string | null {
return null;
}

}
5 changes: 5 additions & 0 deletions src/config/chains/telos-testnet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,9 @@ export default class TelosTestnet extends BaseChain {
{ label: 'REPOSITORY', url: 'https://github.com/telosnetwork/open-block-explorer' },
];
}

getFathomSiteId(): string | null {
return 'HKAXCRJB';
}

}
5 changes: 5 additions & 0 deletions src/config/chains/telos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,9 @@ export default class Telos extends BaseChain {
{ label: 'REPOSITORY', url: 'https://github.com/telosnetwork/open-block-explorer' },
];
}

getFathomSiteId(): string | null {
return 'VMVLEWFD';
}

}
5 changes: 5 additions & 0 deletions src/config/chains/ux/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,9 @@ export default class UX extends BaseChain {
{ label: 'REPOSITORY', url: 'https://github.com/telosnetwork/open-block-explorer' },
];
}

getFathomSiteId(): string | null {
return null;
}

}
5 changes: 5 additions & 0 deletions src/config/chains/wax/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ export default class EOS extends BaseChain {
{ label: 'REPOSITORY', url: 'https://github.com/telosnetwork/open-block-explorer' },
];
}

getFathomSiteId(): string | null {
return null;
}

}
1 change: 1 addition & 0 deletions src/types/Chain.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export interface Chain {
getFiltersSupported(prop: string): boolean;
isTestnet(): boolean;
getFooterLinks(): FooterLink[];
getFathomSiteId(): string | null;
}

0 comments on commit 9b0e499

Please sign in to comment.