mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
Plausible for hidden environments (#2837)
Plausible for hidden environments
This commit is contained in:
parent
74410d292b
commit
d13401b6ed
@ -1,13 +1,9 @@
|
||||
import { createLocalStorage } from 'utils/createLocalStorage';
|
||||
import { useGlobalLocalStorage } from './useGlobalLocalStorage';
|
||||
import { useState } from 'react';
|
||||
|
||||
interface IGlobalStore {
|
||||
favorites?: boolean;
|
||||
hiddenEnvironments?: Set<string>;
|
||||
}
|
||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||
|
||||
export const useHiddenEnvironments = () => {
|
||||
const { trackEvent } = usePlausibleTracker();
|
||||
const { value: globalStore, setValue: setGlobalStore } =
|
||||
useGlobalLocalStorage();
|
||||
const [hiddenEnvironments, setStoredHiddenEnvironments] = useState<
|
||||
@ -19,8 +15,18 @@ export const useHiddenEnvironments = () => {
|
||||
const hiddenEnvironments = new Set(params.hiddenEnvironments);
|
||||
if (hiddenEnvironments.has(environment)) {
|
||||
hiddenEnvironments.delete(environment);
|
||||
trackEvent('hidden_environment', {
|
||||
props: {
|
||||
eventType: `environment unhidden`,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
hiddenEnvironments.add(environment);
|
||||
trackEvent('hidden_environment', {
|
||||
props: {
|
||||
eventType: `environment hidden`,
|
||||
},
|
||||
});
|
||||
}
|
||||
setStoredHiddenEnvironments(hiddenEnvironments);
|
||||
return {
|
||||
|
@ -14,7 +14,8 @@ type CustomEvents =
|
||||
| 'change_request'
|
||||
| 'favorite'
|
||||
| 'maintenance'
|
||||
| 'message_banner';
|
||||
| 'message_banner'
|
||||
| 'hidden_environment';
|
||||
|
||||
export const usePlausibleTracker = () => {
|
||||
const plausible = useContext(PlausibleContext);
|
||||
|
Loading…
Reference in New Issue
Block a user