✨ Switched to plausible-tracker and removed node-fetch
This commit is contained in:
@@ -5,12 +5,6 @@
|
||||
<meta name="description" content="" />
|
||||
<!-- <link rel="icon" href="%sveltekit.assets%/favicon.png" />-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<script
|
||||
async=""
|
||||
defer=""
|
||||
data-domain="classquiz.mawoka.eu"
|
||||
src="https://sugar.mawoka.eu.org/js/plausible.hash.outbound-links.js"
|
||||
></script>
|
||||
<link rel="prefetch" href="https://sugar.mawoka.eu.org/" />
|
||||
<script>
|
||||
window.plausible =
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as cookie from 'cookie';
|
||||
import fetch from 'node-fetch';
|
||||
import Redis from 'ioredis';
|
||||
|
||||
const redis = new Redis(process.env.REDIS_URL);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import * as Sentry from '@sentry/browser';
|
||||
import { plausible } from '$lib/stores';
|
||||
|
||||
const gen_salt = (l: number): string => {
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
@@ -32,7 +32,8 @@ export const mint = async (
|
||||
const challenge = `${ver}:${bits}:${ts}:${resource}:${ext}:${salt}`;
|
||||
let counter = 0;
|
||||
let result: string;
|
||||
const t0 = performance.now();
|
||||
const t1 = performance.now();
|
||||
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
const data = new TextEncoder().encode(`${challenge}:${counter.toString(16)}`);
|
||||
@@ -45,16 +46,7 @@ export const mint = async (
|
||||
}
|
||||
counter += 1;
|
||||
}
|
||||
const t1 = performance.now();
|
||||
const transaction = Sentry.startTransaction({ name: 'calculatedHasCash' });
|
||||
const span = transaction.startChild({
|
||||
op: 'hashcash',
|
||||
data: {
|
||||
milliseconds_taken: t0 - t1,
|
||||
bits: bits
|
||||
}
|
||||
});
|
||||
span.finish();
|
||||
transaction.finish();
|
||||
const t2 = performance.now();
|
||||
plausible.trackEvent('Hashcash', { props: { ms_taken: t2 - t1 } });
|
||||
return `${challenge}:${result}`;
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ export const alertModal = writable({ open: false, title: '', body: '' });
|
||||
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import Plausible from 'plausible-tracker';
|
||||
|
||||
const URLSearchParamsToObject = (params: URLSearchParams) => {
|
||||
const obj = {};
|
||||
@@ -41,3 +42,9 @@ export const createQueryParamsStore = (key: string) => {
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const plausible = Plausible({
|
||||
domain: 'classquiz.mawoka.eu',
|
||||
apiHost: 'https://sugar.mawoka.eu.org',
|
||||
trackLocalhost: true
|
||||
});
|
||||
|
||||
@@ -18,8 +18,23 @@
|
||||
import { initLocalizationContext } from '$lib/i18n';
|
||||
import { browser } from '$app/env';
|
||||
import Alert from '$lib/modals/alert.svelte';
|
||||
import { plausible } from '$lib/stores';
|
||||
|
||||
/* afterNavigate(() => {
|
||||
if (browser) {
|
||||
if (latestPageVisitURl === window.location.href) {
|
||||
return;
|
||||
} else {
|
||||
latestPageVisitURl = window.location.href;
|
||||
plausible.trackPageview();
|
||||
}
|
||||
console.log('After nav');
|
||||
}
|
||||
});*/
|
||||
|
||||
if (browser) {
|
||||
plausible.enableAutoPageviews();
|
||||
plausible.enableAutoOutboundTracking();
|
||||
pathname.set(window.location.pathname);
|
||||
if (
|
||||
localStorage.theme === 'dark' ||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import { getLocalization } from '$lib/i18n';
|
||||
import Footer from '$lib/footer.svelte';
|
||||
import { alertModal, navbarVisible, signedIn } from '$lib/stores';
|
||||
import { alertModal, navbarVisible, signedIn, plausible } from '$lib/stores';
|
||||
|
||||
interface QuizData {
|
||||
id: string;
|
||||
@@ -71,7 +71,7 @@
|
||||
}
|
||||
const data = await res.json();
|
||||
// eslint-disable-next-line no-undef
|
||||
plausible('Started Game', { props: { quiz_id: id } });
|
||||
plausible.trackEvent('Started Game', { props: { quiz_id: id } });
|
||||
window.location.replace(`/admin?token=${data.game_id}&pin=${data.game_pin}&connect=1`);
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
import ShowTitle from '$lib/play/title.svelte';
|
||||
import Question from '$lib/play/question.svelte';
|
||||
import ShowResults from '$lib/play/show_results.svelte';
|
||||
import { navbarVisible } from '$lib/stores';
|
||||
import { navbarVisible, plausible } from '$lib/stores';
|
||||
import ShowEndScreen from '$lib/play/end.svelte';
|
||||
|
||||
// Exports
|
||||
@@ -66,7 +66,7 @@
|
||||
console.log('joined_game', data);
|
||||
gameData = JSON.parse(data);
|
||||
// eslint-disable-next-line no-undef
|
||||
plausible('Joined Game', { props: { quiz_id: gameData.quiz_id } });
|
||||
plausible.trackEvent('Joined Game', { props: { quiz_id: gameData.quiz_id } });
|
||||
});
|
||||
|
||||
socket.on('game_not_found', () => {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
import { createTippy } from 'svelte-tippy';
|
||||
import 'tippy.js/animations/perspective-subtle.css';
|
||||
import 'tippy.js/dist/tippy.css';
|
||||
import { plausible } from '$lib/stores';
|
||||
|
||||
const tippy = createTippy({
|
||||
arrow: true,
|
||||
@@ -79,7 +80,7 @@
|
||||
}
|
||||
const data = await res.json();
|
||||
// eslint-disable-next-line no-undef
|
||||
plausible('Started Game', { props: { quiz_id: id } });
|
||||
plausible.trackEvent('Started Game', { props: { quiz_id: id } });
|
||||
window.location.replace(`/admin?token=${data.game_id}&pin=${data.game_pin}&connect=1`);
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user