Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

supplying 'timeupdate' and 'projectinfo' events

Blue Mouse9473f6e6ef18
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index 5f4520771..7b5c58729 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -589,10 +589,14 @@ const ViewProject = ({
}
}, [isLoading, showTotal, chartData, mainChart, t])
+ // Initialising Swetrix SDK instance
useEffect(() => {
const sdk = new SwetrixSDK([{
cdnURL: 'http://localhost:3000/assets/test_extension.js',
id: 'test-extension',
+ }, {
+ cdnURL: 'http://localhost:3000/assets/export_as_json.js',
+ id: 'export-as-json',
}], {
debug: true,
}, {
@@ -630,6 +634,30 @@ const ViewProject = ({
}
}, [])
+ // Supplying 'timeupdate' event to the SDK after loading
+ useEffect(() => {
+ sdkInstance?._emitEvent('timeupdate', {
+ period,
+ timeBucket,
+ dateRange: period === 'custom' ? dateRange : null,
+ })
+ }, [sdkInstance])
+
+ // Supplying 'projectinfo' event to the SDK after loading
+ useEffect(() => {
+ if (_isEmpty(project)) {
+ return
+ }
+
+ const {
+ active: isActive, created, public: isPublic,
+ } = project
+
+ sdkInstance?._emitEvent('projectinfo', {
+ id, name, isActive, created, isPublic,
+ })
+ }, [sdkInstance, name])
+
useEffect(() => {
setPeriodPairs(tbPeriodPairs(t))
}, [t])