Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Dec 11, 2023
1 parent b58abe0 commit 4c3ed07
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 719 deletions.
3 changes: 2 additions & 1 deletion databox/client/src/components/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import {ModalStack} from '@alchemy/navigation';
import UserPreferencesProvider from './User/Preferences/UserPreferencesProvider';
import {keycloakClient, oauthClient} from '../api/api-client';
import {AuthenticationProvider} from '@alchemy/react-auth';
import {AuthenticationProvider, MatomoUser} from '@alchemy/react-auth';
import {RouterProvider} from '@alchemy/navigation';
import {routes} from '../routes.ts';
import RouteProxy from "./Routing/RouteProxy.tsx";
Expand All @@ -19,6 +19,7 @@ export default function Root({}: Props) {
oauthClient={oauthClient}
onLogout={onLogout}
>
<MatomoUser/>
<ModalStack>
<UserPreferencesProvider>
<RouterProvider
Expand Down
3 changes: 2 additions & 1 deletion expose/client/src/component/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {ModalStack} from '@alchemy/navigation';
import {keycloakClient, oauthClient} from '../lib/api-client';
import {AuthenticationProvider} from '@alchemy/react-auth';
import {AuthenticationProvider, MatomoUser} from '@alchemy/react-auth';
import App from './App.tsx';

type Props = {};
Expand All @@ -12,6 +12,7 @@ export default function Root({}: Props) {
}, []);

return <AuthenticationProvider oauthClient={oauthClient} onLogout={onLogout}>
<MatomoUser/>
<ModalStack>
<App/>
</ModalStack>
Expand Down
2 changes: 2 additions & 0 deletions lib/js/react-auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {useAuth} from "./src/hooks/useAuth";
import {useKeycloakUser, useUser, UseUserReturn} from "./src/hooks/useUser";
import {useKeycloakUrls} from "./src/hooks/useKeycloakUrls";
import AuthorizationCodePage from "./src/components/AuthorizationCodePage";
import MatomoUser from "./src/components/MatomoUser";

export {
AuthenticationContext,
Expand All @@ -13,6 +14,7 @@ export {
useUser,
useKeycloakUser,
useKeycloakUrls,
MatomoUser,
};
export type {
TAuthContext,
Expand Down
3 changes: 2 additions & 1 deletion lib/js/react-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"typescript": "^5.3.2",
"react-i18next": "^13.5.0",
"react-router-dom": "^6.20.0",
"@mui/material": "^5.14.19"
"@mui/material": "^5.14.19",
"@jonkoops/matomo-tracker-react": "^0.7.0"
}
}
20 changes: 20 additions & 0 deletions lib/js/react-auth/src/components/MatomoUser.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import {useUser} from "../hooks/useUser";
import {useMatomo} from "@jonkoops/matomo-tracker-react";

type Props = {
idProp?: string;
};

export default function MatomoUser({
idProp = 'sub'
}: Props) {
const {user} = useUser<Record<string, string>>();
const {pushInstruction} = useMatomo();

React.useEffect(() => {
pushInstruction('setUserId', user ? (user[idProp] as string) : null);
}, []);

return null
}
Loading

0 comments on commit 4c3ed07

Please sign in to comment.