console: hide onboarding for users who onboarded before onboarding was launched

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7168
GitOrigin-RevId: 8e119129b2a910fefd692e93a19007cdfd564bf5
This commit is contained in:
Rishichandra Wawhal 2022-12-06 11:38:51 +05:30 committed by hasura-bot
parent adf565fe3d
commit 7f0e4b2092
4 changed files with 28 additions and 1 deletions

View File

@ -19,6 +19,10 @@ export const fetchAllOnboardingDataQuery = `
activity
target
}
users {
id
created_at
}
}
`;

View File

@ -8,6 +8,11 @@ import {
} from '../constants';
import { OnboardingResponseData } from '../types';
const userMock = {
id: '59300b64-fb3a-4f17-8a0f-6f698569eade',
created_at: '2022-11-02T13:31:32.526653286Z',
};
export const mockOnboardingData: Record<
string,
OnboardingResponseData['data']
@ -22,6 +27,7 @@ export const mockOnboardingData: Record<
target: 'cloud_console',
},
],
users: [userMock],
},
/**
* config to hide wizard as hasura data source created
@ -59,6 +65,7 @@ export const mockOnboardingData: Record<
target: 'cloud_console',
},
],
users: [userMock],
},
/**
* config to hide wizard as run query clicked
@ -100,6 +107,7 @@ export const mockOnboardingData: Record<
target: 'cloud_console',
},
],
users: [userMock],
},
/**
* config to hide wizard as user skipped onboarding
@ -129,6 +137,7 @@ export const mockOnboardingData: Record<
target: 'cloud_console',
},
],
users: [userMock],
},
/**
* config to hide wizard as user completed onboarding
@ -158,6 +167,7 @@ export const mockOnboardingData: Record<
target: 'cloud_console',
},
],
users: [userMock],
},
};

View File

@ -3,8 +3,14 @@ export type UserOnboarding = {
target: string;
};
export type User = {
id: string;
created_at: string;
};
export type OnboardingResponseData = {
data: {
user_onboarding: UserOnboarding[];
users: User[];
};
};

View File

@ -65,7 +65,14 @@ export function getWizardState(
// if onbarding data is not present due to api error, or data loading state, then hide the wizard
// this early return is required to distinguish between server errors vs data not being present for user
// if the request is successful and data is not present for the given user, then we should show the onboarding wizard
if (!onboardingData) return 'hidden';
if (!onboardingData?.data) return 'hidden';
// if user created account before the launch of onboarding wizard (Oct 17, 2022),
// hide the wizard and survey
const userCreatedAt = new Date(onboardingData.data.users[0].created_at);
if (userCreatedAt.getTime() < 1666008600000) {
return 'hidden';
}
// transform the onboarding data if present, to a consumable format
const transformedOnboardingData = onboardingDataTransformFn(onboardingData);