@ossy/analytics 3.7.0 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/analytics",
|
|
3
3
|
"description": "Analytics module — workspace insight KPIs",
|
|
4
|
-
"version": "3.7.
|
|
4
|
+
"version": "3.7.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"module": "./src/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@ossy/event-store": "^3.7.0",
|
|
29
|
-
"@ossy/workspaces": "^3.
|
|
29
|
+
"@ossy/workspaces": "^3.7.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@ossy/app": "*",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@jest/globals": "^30.2.0",
|
|
43
43
|
"jest": "^30.2.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "1ee220424da6b065034a7f52f52aa4a6ce7c88d5"
|
|
46
46
|
}
|
|
@@ -2,8 +2,6 @@ import React, { useMemo } from 'react'
|
|
|
2
2
|
import { Text, View, Page, useLocale } from '@ossy/design-system'
|
|
3
3
|
import { usePageViewStats } from './usePageViewStats.js'
|
|
4
4
|
import { useWorkspaceKpis } from './useWorkspaceKpis.js'
|
|
5
|
-
import { useSdk } from '@ossy/sdk-react'
|
|
6
|
-
import { GetWorkspace } from '@ossy/workspaces'
|
|
7
5
|
|
|
8
6
|
function SummaryCard ({ label, value }) {
|
|
9
7
|
return (
|
|
@@ -22,11 +20,10 @@ function SummaryCard ({ label, value }) {
|
|
|
22
20
|
/**
|
|
23
21
|
* Workspace analytics product UI. Only mount when the caller is authenticated
|
|
24
22
|
* so KPI / page-view actions do not run for anonymous sessions.
|
|
23
|
+
* Workspace comes from the page (shell snapshot) — do not re-read GetWorkspace.
|
|
25
24
|
*/
|
|
26
|
-
export default function AnalyticsProductHome () {
|
|
25
|
+
export default function AnalyticsProductHome ({ workspace }) {
|
|
27
26
|
const { t } = useLocale()
|
|
28
|
-
const sdk = useSdk()
|
|
29
|
-
const { data: workspace } = sdk.read(GetWorkspace)
|
|
30
27
|
const { from, to } = useMemo(() => {
|
|
31
28
|
const now = Date.now()
|
|
32
29
|
return { from: now - 30 * 24 * 60 * 60 * 1000, to: now }
|
package/src/analytics.page.jsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { useApp } from '@ossy/app/shell'
|
|
3
|
-
import { GetWorkspace } from '@ossy/workspaces'
|
|
2
|
+
import { useApp, useShellWorkspace } from '@ossy/app/shell'
|
|
4
3
|
import { isServiceEntitled } from '@ossy/workspaces/entitlements'
|
|
5
|
-
import { useSdk } from '@ossy/sdk-react'
|
|
6
4
|
import AnalyticsSalesPage from './AnalyticsSalesPage.jsx'
|
|
7
5
|
import AnalyticsProductHome from './AnalyticsProductHome.jsx'
|
|
8
6
|
|
|
@@ -14,19 +12,21 @@ export const metadata = {
|
|
|
14
12
|
},
|
|
15
13
|
}
|
|
16
14
|
|
|
15
|
+
const ANALYTICS_SERVICE = '@ossy/analytics'
|
|
16
|
+
|
|
17
17
|
/**
|
|
18
|
-
* Analytics home — product KPIs
|
|
19
|
-
*
|
|
18
|
+
* Analytics home — product KPIs when signed in and entitled, otherwise sales.
|
|
19
|
+
* Entitlement comes from the shell workspace snapshot (SSR bootstrap / cookie)
|
|
20
|
+
* so the dashboard does not flash the sales page on navigation.
|
|
20
21
|
*/
|
|
21
22
|
export default function AnalyticsPage () {
|
|
22
23
|
const app = useApp()
|
|
23
|
-
const
|
|
24
|
+
const { workspace } = useShellWorkspace()
|
|
24
25
|
const isAuthenticated = !!app?.isAuthenticated
|
|
25
|
-
const
|
|
26
|
-
const entitled = isServiceEntitled(workspace?.services, '@ossy/analytics')
|
|
26
|
+
const entitled = isServiceEntitled(workspace?.services, ANALYTICS_SERVICE)
|
|
27
27
|
|
|
28
28
|
if (isAuthenticated && entitled) {
|
|
29
|
-
return <AnalyticsProductHome />
|
|
29
|
+
return <AnalyticsProductHome workspace={workspace} />
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
return <AnalyticsSalesPage isAuthenticated={isAuthenticated} />
|