mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
taking is_telemetry_enabled field only into consideration
This commit is contained in:
parent
12aaef2419
commit
ae75271094
@ -53,8 +53,7 @@ export const AppProvider: FC<IAppProvider> = observer((props) => {
|
|||||||
userProfile={userProfile}
|
userProfile={userProfile}
|
||||||
currentWorkspaceId={currentWorkspace?.id}
|
currentWorkspaceId={currentWorkspace?.id}
|
||||||
joinedWorkspaceIds={Object.keys(workspaces)}
|
joinedWorkspaceIds={Object.keys(workspaces)}
|
||||||
isCloud={!instance?.is_telemetry_anonymous || false}
|
isTelemetryEnabled={instance?.is_telemetry_enabled ?? false}
|
||||||
telemetryEnabled={instance?.is_telemetry_enabled || false}
|
|
||||||
posthogAPIKey={config?.posthog_api_key || undefined}
|
posthogAPIKey={config?.posthog_api_key || undefined}
|
||||||
posthogHost={config?.posthog_host || undefined}
|
posthogHost={config?.posthog_host || undefined}
|
||||||
>
|
>
|
||||||
|
@ -14,8 +14,7 @@ export interface IPosthogWrapper {
|
|||||||
currentWorkspaceId: string | undefined;
|
currentWorkspaceId: string | undefined;
|
||||||
posthogAPIKey: string | undefined;
|
posthogAPIKey: string | undefined;
|
||||||
posthogHost: string | undefined;
|
posthogHost: string | undefined;
|
||||||
isCloud: boolean;
|
isTelemetryEnabled: boolean;
|
||||||
telemetryEnabled: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
||||||
@ -27,8 +26,7 @@ const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
|||||||
currentWorkspaceId,
|
currentWorkspaceId,
|
||||||
posthogAPIKey,
|
posthogAPIKey,
|
||||||
posthogHost,
|
posthogHost,
|
||||||
isCloud,
|
isTelemetryEnabled,
|
||||||
telemetryEnabled,
|
|
||||||
} = props;
|
} = props;
|
||||||
// states
|
// states
|
||||||
const [lastWorkspaceId, setLastWorkspaceId] = useState(currentWorkspaceId);
|
const [lastWorkspaceId, setLastWorkspaceId] = useState(currentWorkspaceId);
|
||||||
@ -36,26 +34,22 @@ const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user) {
|
if (user && isTelemetryEnabled) {
|
||||||
// Identify sends an event, so you want may want to limit how often you call it
|
// Identify sends an event, so you want may want to limit how often you call it
|
||||||
posthog?.identify(isCloud ? user.email : user.id, {
|
posthog?.identify(user.email, {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
first_name: isCloud ? user.first_name : undefined,
|
first_name: user.first_name,
|
||||||
last_name: isCloud ? user.last_name : undefined,
|
last_name: user.last_name,
|
||||||
email: isCloud ? user.email : undefined,
|
email: user.email,
|
||||||
use_case: userProfile?.use_case,
|
use_case: userProfile?.use_case,
|
||||||
role: userProfile?.role,
|
role: userProfile?.role,
|
||||||
workspaces: joinedWorkspaceIds,
|
workspaces: joinedWorkspaceIds,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [user, joinedWorkspaceIds, isCloud, userProfile]);
|
}, [user, joinedWorkspaceIds, isTelemetryEnabled, userProfile]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (posthogAPIKey && (process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost) && isTelemetryEnabled) {
|
||||||
posthogAPIKey &&
|
|
||||||
(process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost) &&
|
|
||||||
(isCloud || (!isCloud && telemetryEnabled))
|
|
||||||
) {
|
|
||||||
posthog.init(posthogAPIKey, {
|
posthog.init(posthogAPIKey, {
|
||||||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost || "https://app.posthog.com",
|
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost || "https://app.posthog.com",
|
||||||
debug: process.env.NEXT_PUBLIC_POSTHOG_DEBUG === "1", // Debug mode based on the environment variable
|
debug: process.env.NEXT_PUBLIC_POSTHOG_DEBUG === "1", // Debug mode based on the environment variable
|
||||||
@ -64,16 +58,16 @@ const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
|||||||
});
|
});
|
||||||
posthog?.opt_in_capturing();
|
posthog?.opt_in_capturing();
|
||||||
}
|
}
|
||||||
}, [posthogAPIKey, posthogHost, isCloud, telemetryEnabled]);
|
}, [posthogAPIKey, posthogHost, isTelemetryEnabled]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Join workspace group on workspace change
|
// Join workspace group on workspace change
|
||||||
if (lastWorkspaceId !== currentWorkspaceId && currentWorkspaceId && user) {
|
if (lastWorkspaceId !== currentWorkspaceId && currentWorkspaceId && user && isTelemetryEnabled) {
|
||||||
setLastWorkspaceId(currentWorkspaceId);
|
setLastWorkspaceId(currentWorkspaceId);
|
||||||
posthog?.identify(isCloud ? user.email : user.id);
|
posthog?.identify(user.email);
|
||||||
posthog?.group(GROUP_WORKSPACE, currentWorkspaceId);
|
posthog?.group(GROUP_WORKSPACE, currentWorkspaceId);
|
||||||
}
|
}
|
||||||
}, [currentWorkspaceId, lastWorkspaceId, user, isCloud]);
|
}, [currentWorkspaceId, lastWorkspaceId, user, isTelemetryEnabled]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Track page views
|
// Track page views
|
||||||
@ -88,7 +82,7 @@ const PostHogProvider: FC<IPosthogWrapper> = (props) => {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (!isCloud && !telemetryEnabled) {
|
if (!isTelemetryEnabled) {
|
||||||
posthog?.opt_out_capturing();
|
posthog?.opt_out_capturing();
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user