1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

[Gitar] Cleaning up stale flag: onboardingMetrics with value true (#8550)

This commit is contained in:
gitar-bot[bot] 2024-10-28 11:47:58 +01:00 committed by GitHub
parent cb6b776154
commit 0ff0b2dbd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 21 additions and 42 deletions

View File

@ -240,23 +240,21 @@ class UserStore implements IUserStore {
let firstLoginOrder = 0;
if (this.flagResolver.isEnabled('onboardingMetrics')) {
const existingUser =
await this.buildSelectUser(user).first('first_seen_at');
const existingUser =
await this.buildSelectUser(user).first('first_seen_at');
if (!existingUser.first_seen_at) {
const countEarlierUsers = await this.db(TABLE)
.whereNotNull('first_seen_at')
.andWhere('first_seen_at', '<', currentDate)
.count('*')
.then((res) => Number(res[0].count));
if (!existingUser.first_seen_at) {
const countEarlierUsers = await this.db(TABLE)
.whereNotNull('first_seen_at')
.andWhere('first_seen_at', '<', currentDate)
.count('*')
.then((res) => Number(res[0].count));
firstLoginOrder = countEarlierUsers;
firstLoginOrder = countEarlierUsers;
await updateQuery.update({
first_seen_at: currentDate,
});
}
await updateQuery.update({
first_seen_at: currentDate,
});
}
await updateQuery;

View File

@ -24,7 +24,7 @@ let app: IUnleashTest;
beforeAll(async () => {
db = await dbInit('onboarding_read_model', getLogger, {
experimental: { flags: { onboardingMetrics: true } },
experimental: { flags: {} },
});
app = await setupAppWithCustomConfig(

View File

@ -17,7 +17,7 @@ let onboardingReadModel: IOnboardingReadModel;
beforeAll(async () => {
db = await dbInit('onboarding_store', getLogger);
const config = createTestConfig({
experimental: { flags: { onboardingMetrics: true } },
experimental: { flags: {} },
});
stores = db.stores;
eventBus = config.eventBus;
@ -41,8 +41,7 @@ beforeEach(async () => {
test('Default project should take first user created instead of project created as start time', async () => {
jest.useFakeTimers();
jest.setSystemTime(new Date());
const { userStore, featureToggleStore, projectStore, projectReadModel } =
stores;
const { userStore, featureToggleStore, projectStore } = stores;
// default projects are created in advance and should be ignored
await projectStore.create({ id: 'default', name: 'irrelevant' });
@ -106,8 +105,7 @@ test('Ignore system user in onboarding events', async () => {
test('Storing onboarding events', async () => {
jest.useFakeTimers();
jest.setSystemTime(new Date());
const { userStore, featureToggleStore, projectStore, projectReadModel } =
stores;
const { userStore, featureToggleStore, projectStore } = stores;
const user = await userStore.insert({});
await projectStore.create({ id: 'test_project', name: 'irrelevant' });
await featureToggleStore.create('test_project', {
@ -172,8 +170,7 @@ const reachedOnboardingEvents = (count: number) => {
test('Reacting to events', async () => {
jest.useFakeTimers();
jest.setSystemTime(new Date());
const { userStore, featureToggleStore, projectStore, projectReadModel } =
stores;
const { userStore, featureToggleStore, projectStore } = stores;
const user = await userStore.insert({});
await projectStore.create({ id: 'test_project', name: 'irrelevant' });
await featureToggleStore.create('test_project', {

View File

@ -56,8 +56,6 @@ export class OnboardingService {
listen() {
this.eventBus.on(USER_LOGIN, async (event: { loginOrder: number }) => {
if (!this.flagResolver.isEnabled('onboardingMetrics')) return;
if (event.loginOrder === 0) {
await this.insert({ type: 'first-user-login' });
}
@ -68,8 +66,6 @@ export class OnboardingService {
}
});
this.eventBus.on(STAGE_ENTERED, async (stage: NewStage) => {
if (!this.flagResolver.isEnabled('onboardingMetrics')) return;
if (stage.stage === 'initial') {
await this.insert({
type: 'flag-created',

View File

@ -110,7 +110,7 @@ export function registerPrometheusMetrics(
};
const { eventStore, environmentStore } = stores;
const { flagResolver, db } = config;
const { flagResolver } = config;
const dbMetrics = new DbMetricsMonitor(config);
const cachedEnvironments: () => Promise<IEnvironment[]> = memoizee(
@ -530,10 +530,7 @@ export function registerPrometheusMetrics(
name: 'onboarding_duration',
labelNames: ['event'],
help: 'firstLogin, secondLogin, firstFeatureFlag, firstPreLive, firstLive from first user creation',
query: () =>
flagResolver.isEnabled('onboardingMetrics')
? stores.onboardingReadModel.getInstanceOnboardingMetrics()
: Promise.resolve({}),
query: () => stores.onboardingReadModel.getInstanceOnboardingMetrics(),
map: (result) =>
Object.keys(result)
.filter((key) => Number.isInteger(result[key]))
@ -549,10 +546,7 @@ export function registerPrometheusMetrics(
name: 'project_onboarding_duration',
labelNames: ['event', 'project'],
help: 'firstFeatureFlag, firstPreLive, firstLive from project creation',
query: () =>
flagResolver.isEnabled('onboardingMetrics')
? stores.onboardingReadModel.getProjectsOnboardingMetrics()
: Promise.resolve([]),
query: () => stores.onboardingReadModel.getProjectsOnboardingMetrics(),
map: (projectsOnboardingMetrics) =>
projectsOnboardingMetrics.flatMap(
({ project, ...projectMetrics }) =>

View File

@ -49,7 +49,6 @@ export type IFlagKey =
| 'enableLegacyVariants'
| 'extendedMetrics'
| 'removeUnsafeInlineStyleSrc'
| 'onboardingMetrics'
| 'onboardingUI'
| 'projectRoleAssignment'
| 'eventTimeline'
@ -255,10 +254,6 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_REMOVE_UNSAFE_INLINE_STYLE_SRC,
false,
),
onboardingMetrics: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_ONBOARDING_METRICS,
false,
),
onboardingUI: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_ONBOARDING_UI,
false,

View File

@ -49,7 +49,6 @@ process.nextTick(async () => {
manyStrategiesPagination: true,
enableLegacyVariants: false,
extendedMetrics: true,
onboardingMetrics: true,
onboardingUI: true,
personalDashboardUI: true,
purchaseAdditionalEnvironments: true,

View File

@ -8,7 +8,7 @@ let db: ITestDb;
beforeAll(async () => {
db = await dbInit('user_store_serial', getLogger, {
experimental: { flags: { onboardingMetrics: true } },
experimental: { flags: {} },
});
stores = db.stores;
});