chore: expand the tracking to all pages
it is ensured that the encryption key is not tracked as it is a fragment/hash
This commit is contained in:
parent
fc40ba8666
commit
4233b908e5
@ -1,7 +1,9 @@
|
||||
import { lazy } from 'react';
|
||||
import { lazy, useEffect } from 'react';
|
||||
import { Route, createBrowserRouter, createRoutesFromElements } from 'react-router-dom';
|
||||
import AdminShell from './admin-shell.jsx';
|
||||
import { trackPageView } from './api/analytics';
|
||||
import ApplicationShell from './app-shell.jsx';
|
||||
import config from './config';
|
||||
import ApiDocs from './routes/api-docs/index.jsx';
|
||||
|
||||
const Home = lazy(() => import('./routes/home'));
|
||||
@ -21,6 +23,13 @@ const Analytics = lazy(() => import('./routes/account/analytics'));
|
||||
const NotFound = lazy(() => import('./routes/not-found'));
|
||||
|
||||
const createAppRouter = () => {
|
||||
useEffect(() => {
|
||||
if (config.get('settings.analytics.enabled')) {
|
||||
console.log('tracking page view', location.pathname);
|
||||
trackPageView(location.pathname);
|
||||
}
|
||||
}, [location.pathname]);
|
||||
|
||||
return createBrowserRouter(
|
||||
createRoutesFromElements(
|
||||
<>
|
||||
|
@ -16,10 +16,9 @@ import {
|
||||
IconTrash,
|
||||
IconX,
|
||||
} from '@tabler/icons';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { trackPageView } from '../../api/analytics';
|
||||
import { burnSecret } from '../../api/secret';
|
||||
import CopyButton from '../../components/CopyButton';
|
||||
import QRLink from '../../components/qrlink';
|
||||
@ -54,12 +53,6 @@ const Home = () => {
|
||||
|
||||
const [enableIpRange, setEnableIpRange] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (config.get('settings.analytics.enabled')) {
|
||||
trackPageView(location.pathname);
|
||||
}
|
||||
}, [location.pathname]);
|
||||
|
||||
const onSubmit = (event) => {
|
||||
handleSubmit(event, t);
|
||||
|
||||
|
@ -18,8 +18,8 @@ function createUniqueId(ip, userAgent) {
|
||||
// Validate path to prevent malicious inputs
|
||||
function isValidPath(path) {
|
||||
// Only allow paths that start with / and contain safe characters
|
||||
const pathRegex = /^\/[a-zA-Z0-9\-_/]*$/;
|
||||
return pathRegex.test(path) && path.length <= 255 && !path.includes('/secret');
|
||||
const pathRegex = /^\/[a-zA-Z0-9\-?=&/]*$/;
|
||||
return pathRegex.test(path) && path.length <= 255;
|
||||
}
|
||||
|
||||
async function analytics(fastify) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user