chore: telemetery fields in new instance type defination

This commit is contained in:
LAKHAN BAHETI 2024-04-29 18:45:50 +05:30
parent 0d7f4761c7
commit a28cca29d5
4 changed files with 26 additions and 13 deletions

View File

@ -20,6 +20,7 @@ export interface IInstance {
last_checked_at: string | undefined;
namespace: string | undefined;
is_telemetry_enabled: boolean;
is_telemetry_anonymous: boolean;
is_support_required: boolean;
is_activated: boolean;
is_setup_done: boolean;

View File

@ -25,7 +25,7 @@ import { EUserWorkspaceRoles, ROLE } from "@/constants/workspace";
// helpers
import { getUserRole } from "@/helpers/user.helper";
// hooks
import { useEventTracker, useApplication } from "@/hooks/store";
import { useEventTracker, useInstance } from "@/hooks/store";
import useDynamicDropdownPosition from "@/hooks/use-dynamic-dropdown";
// services
import { WorkspaceService } from "@/services/workspace.service";
@ -273,9 +273,7 @@ export const InviteMembers: React.FC<Props> = (props) => {
const { resolvedTheme } = useTheme();
// store hooks
const { captureEvent } = useEventTracker();
const {
instance: { instance },
} = useApplication();
const { instance } = useInstance();
const {
control,
@ -315,7 +313,7 @@ export const InviteMembers: React.FC<Props> = (props) => {
})
.then(async () => {
captureEvent(MEMBER_INVITED, {
emails: !instance?.is_telemetry_anonymous
emails: !instance?.instance?.is_telemetry_anonymous
? [
...payload.emails.map((email) => ({
email: email.email,

View File

@ -33,7 +33,10 @@ export const AppProvider: FC<IAppProvider> = observer((props) => {
const { children } = props;
// store hooks
const { instance } = useInstance();
const { data: currentUser } = useUser();
const {
data: currentUser,
profile: { data: profile },
} = useUser();
const { currentWorkspace, workspaces } = useWorkspace();
// themes
const { resolvedTheme } = useTheme();
@ -47,10 +50,11 @@ export const AppProvider: FC<IAppProvider> = observer((props) => {
<CrispWrapper user={currentUser}>
<PostHogProvider
user={currentUser}
profile={profile}
currentWorkspaceId={currentWorkspace?.id}
workspaceIds={Object.keys(workspaces)}
isCloud={!instance?.is_telemetry_anonymous || false}
telemetryEnabled={instance?.is_telemetry_enabled || false}
isCloud={!instance?.instance?.is_telemetry_anonymous || false}
telemetryEnabled={instance?.instance?.is_telemetry_enabled || false}
posthogAPIKey={instance?.config?.posthog_api_key || undefined}
posthogHost={instance?.config.posthog_host || undefined}
>

View File

@ -2,7 +2,7 @@ import { FC, ReactNode, useEffect, useState } from "react";
import { useRouter } from "next/router";
import posthog from "posthog-js";
import { PostHogProvider as PHProvider } from "posthog-js/react";
import { IUser } from "@plane/types";
import { IUser, TUserProfile } from "@plane/types";
// constants
import { GROUP_WORKSPACE } from "@/constants/event-tracker";
// types
@ -10,6 +10,7 @@ import { GROUP_WORKSPACE } from "@/constants/event-tracker";
export interface IPosthogWrapper {
children: ReactNode;
user: IUser | undefined;
profile: TUserProfile | undefined;
workspaceIds: string[];
currentWorkspaceId: string | undefined;
posthogAPIKey: string | undefined;
@ -19,8 +20,17 @@ export interface IPosthogWrapper {
}
const PostHogProvider: FC<IPosthogWrapper> = (props) => {
const { children, user, workspaceIds, currentWorkspaceId, posthogAPIKey, posthogHost, isCloud, telemetryEnabled } =
props;
const {
children,
user,
profile,
workspaceIds,
currentWorkspaceId,
posthogAPIKey,
posthogHost,
isCloud,
telemetryEnabled,
} = props;
// states
const [lastWorkspaceId, setLastWorkspaceId] = useState(currentWorkspaceId);
// router
@ -34,11 +44,11 @@ const PostHogProvider: FC<IPosthogWrapper> = (props) => {
first_name: isCloud ? user.first_name : undefined,
last_name: isCloud ? user.last_name : undefined,
email: isCloud ? user.email : undefined,
use_case: user?.use_case,
use_case: profile?.use_case,
workspaces: workspaceIds,
});
}
}, [user, workspaceIds, isCloud]);
}, [user, workspaceIds, isCloud, profile]);
useEffect(() => {
if (