feat: add analytics

This commit is contained in:
Kentai Radiquum 2024-08-18 20:21:36 +05:00
parent 33d34938c6
commit 6d4d320da8
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
9 changed files with 67 additions and 15 deletions

View file

@ -7,6 +7,7 @@ import { useEffect, useState } from "react";
import { Button, Modal } from "flowbite-react";
import { Spinner } from "./components/Spinner/Spinner";
import { ChangelogModal } from "#/components/ChangelogModal/ChangelogModal";
import PlausibleProvider from "next-plausible";
const inter = Inter({ subsets: ["latin"] });
@ -97,6 +98,14 @@ export const App = (props) => {
</Button>
</Modal.Footer>
</Modal>
{preferencesStore.flags.enableAnalytics && (
<PlausibleProvider
domain="anix.wah.su"
trackLocalhost={true}
selfHosted={true}
enabled={true}
/>
)}
</body>
);
};

View file

@ -310,6 +310,34 @@ const SettingsModal = (props: { isOpen: boolean; setIsOpen: any }) => {
checked={preferenceStore.flags.showChangelog}
/>
</div>
<div className="flex items-center justify-between">
<div>
<p className="font-bold dark:text-white">
Отправка аналитики
</p>
<p className="text-gray-500 dark:text-gray-400">
Требуется перезагрузка для применения
</p>
</div>
<ToggleSwitch
color="blue"
theme={{
toggle: {
checked: {
color: {
blue: "border-blue-700 bg-blue-700",
},
},
},
}}
onChange={() =>
preferenceStore.setFlags({
enableAnalytics: !preferenceStore.flags.enableAnalytics,
})
}
checked={preferenceStore.flags.enableAnalytics}
/>
</div>
</div>
</Modal.Body>
</Modal>

View file

@ -9,6 +9,7 @@ interface preferencesState {
// saveSearchHistory: boolean;
saveWatchHistory?: boolean;
showChangelog?: boolean;
enableAnalytics?: boolean;
};
params: {
isFirstLaunch?: boolean;
@ -32,6 +33,7 @@ export const usePreferencesStore = create<preferencesState>()(
// saveSearchHistory: true,
saveWatchHistory: true,
showChangelog: true,
enableAnalytics: true,
},
params: {
isFirstLaunch: true,

5
next.config.js Normal file
View file

@ -0,0 +1,5 @@
const { withPlausibleProxy } = require("next-plausible");
module.exports = withPlausibleProxy({
customDomain: "https://analytics.wah.su",
})({});

View file

@ -1,4 +0,0 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
export default nextConfig;

14
package-lock.json generated
View file

@ -13,6 +13,7 @@
"flowbite-react": "^0.10.1",
"markdown-to-jsx": "^7.4.7",
"next": "14.2.5",
"next-plausible": "^3.12.1",
"react": "^18",
"react-cropper": "^2.3.3",
"react-dom": "^18",
@ -4003,6 +4004,19 @@
}
}
},
"node_modules/next-plausible": {
"version": "3.12.1",
"resolved": "https://registry.npmjs.org/next-plausible/-/next-plausible-3.12.1.tgz",
"integrity": "sha512-DcQxB/oE8gOLuIU0SBbzN0dYYNibOXgKfnzPkO9SXug6B4Y95eT41JgbN3gjlcsqHWaDWJu/s3928O7ilo2sTg==",
"funding": {
"url": "https://github.com/4lejandrito/next-plausible?sponsor=1"
},
"peerDependencies": {
"next": "^11.1.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/next/node_modules/postcss": {
"version": "8.4.31",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",

View file

@ -14,6 +14,7 @@
"flowbite-react": "^0.10.1",
"markdown-to-jsx": "^7.4.7",
"next": "14.2.5",
"next-plausible": "^3.12.1",
"react": "^18",
"react-cropper": "^2.3.3",
"react-dom": "^18",

View file

@ -10,6 +10,8 @@
- Добавление коллекции в избранное
- Управление своими коллекциями
- Описание релиза на карточках при наведении и постоянно если мобильное устройство
- Просмотр коллекций в которых находится релиз
- Аналитика с возможностью отключения
## Изменено

View file

@ -1,10 +1,6 @@
{
"compilerOptions": {
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
@ -27,16 +23,15 @@
"#/api/*": ["api/*"],
"#/store/*": ["store/*"],
"#/hooks/*": ["hooks/*"],
"#/pages/*": ["pages/*"],
},
"#/pages/*": ["pages/*"]
}
},
"include": [
"next-env.d.ts",
".next/types/**/*.ts",
"**/*.ts",
"**/*.tsx"
"**/*.tsx",
"next.config.js"
],
"exclude": [
"node_modules"
]
"exclude": ["node_modules"]
}