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 { useGlobalLocalStorage } from './useGlobalLocalStorage';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
interface IGlobalStore {
|
|
||||||
favorites?: boolean;
|
|
||||||
hiddenEnvironments?: Set<string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useHiddenEnvironments = () => {
|
export const useHiddenEnvironments = () => {
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
const { value: globalStore, setValue: setGlobalStore } =
|
const { value: globalStore, setValue: setGlobalStore } =
|
||||||
useGlobalLocalStorage();
|
useGlobalLocalStorage();
|
||||||
const [hiddenEnvironments, setStoredHiddenEnvironments] = useState<
|
const [hiddenEnvironments, setStoredHiddenEnvironments] = useState<
|
||||||
@ -19,8 +15,18 @@ export const useHiddenEnvironments = () => {
|
|||||||
const hiddenEnvironments = new Set(params.hiddenEnvironments);
|
const hiddenEnvironments = new Set(params.hiddenEnvironments);
|
||||||
if (hiddenEnvironments.has(environment)) {
|
if (hiddenEnvironments.has(environment)) {
|
||||||
hiddenEnvironments.delete(environment);
|
hiddenEnvironments.delete(environment);
|
||||||
|
trackEvent('hidden_environment', {
|
||||||
|
props: {
|
||||||
|
eventType: `environment unhidden`,
|
||||||
|
},
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
hiddenEnvironments.add(environment);
|
hiddenEnvironments.add(environment);
|
||||||
|
trackEvent('hidden_environment', {
|
||||||
|
props: {
|
||||||
|
eventType: `environment hidden`,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
setStoredHiddenEnvironments(hiddenEnvironments);
|
setStoredHiddenEnvironments(hiddenEnvironments);
|
||||||
return {
|
return {
|
||||||
|
@ -14,7 +14,8 @@ type CustomEvents =
|
|||||||
| 'change_request'
|
| 'change_request'
|
||||||
| 'favorite'
|
| 'favorite'
|
||||||
| 'maintenance'
|
| 'maintenance'
|
||||||
| 'message_banner';
|
| 'message_banner'
|
||||||
|
| 'hidden_environment';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
const plausible = useContext(PlausibleContext);
|
const plausible = useContext(PlausibleContext);
|
||||||
|
Loading…
Reference in New Issue
Block a user