Switched to plausible-tracker and removed node-fetch

This commit is contained in:
Mawoka
2022-06-24 14:02:23 +02:00
parent cc33f16d6f
commit c19e362aaf
10 changed files with 59 additions and 100 deletions
+5 -13
View File
@@ -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}`;
};