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