mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
[Gitar] Cleaning up stale flag: onboardingMetrics with value true (#8550)
This commit is contained in:
parent
cb6b776154
commit
0ff0b2dbd0
@ -240,7 +240,6 @@ class UserStore implements IUserStore {
|
|||||||
|
|
||||||
let firstLoginOrder = 0;
|
let firstLoginOrder = 0;
|
||||||
|
|
||||||
if (this.flagResolver.isEnabled('onboardingMetrics')) {
|
|
||||||
const existingUser =
|
const existingUser =
|
||||||
await this.buildSelectUser(user).first('first_seen_at');
|
await this.buildSelectUser(user).first('first_seen_at');
|
||||||
|
|
||||||
@ -257,7 +256,6 @@ class UserStore implements IUserStore {
|
|||||||
first_seen_at: currentDate,
|
first_seen_at: currentDate,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
await updateQuery;
|
await updateQuery;
|
||||||
return firstLoginOrder;
|
return firstLoginOrder;
|
||||||
|
@ -24,7 +24,7 @@ let app: IUnleashTest;
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
db = await dbInit('onboarding_read_model', getLogger, {
|
db = await dbInit('onboarding_read_model', getLogger, {
|
||||||
experimental: { flags: { onboardingMetrics: true } },
|
experimental: { flags: {} },
|
||||||
});
|
});
|
||||||
|
|
||||||
app = await setupAppWithCustomConfig(
|
app = await setupAppWithCustomConfig(
|
||||||
|
@ -17,7 +17,7 @@ let onboardingReadModel: IOnboardingReadModel;
|
|||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
db = await dbInit('onboarding_store', getLogger);
|
db = await dbInit('onboarding_store', getLogger);
|
||||||
const config = createTestConfig({
|
const config = createTestConfig({
|
||||||
experimental: { flags: { onboardingMetrics: true } },
|
experimental: { flags: {} },
|
||||||
});
|
});
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
eventBus = config.eventBus;
|
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 () => {
|
test('Default project should take first user created instead of project created as start time', async () => {
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
jest.setSystemTime(new Date());
|
jest.setSystemTime(new Date());
|
||||||
const { userStore, featureToggleStore, projectStore, projectReadModel } =
|
const { userStore, featureToggleStore, projectStore } = stores;
|
||||||
stores;
|
|
||||||
|
|
||||||
// default projects are created in advance and should be ignored
|
// default projects are created in advance and should be ignored
|
||||||
await projectStore.create({ id: 'default', name: 'irrelevant' });
|
await projectStore.create({ id: 'default', name: 'irrelevant' });
|
||||||
@ -106,8 +105,7 @@ test('Ignore system user in onboarding events', async () => {
|
|||||||
test('Storing onboarding events', async () => {
|
test('Storing onboarding events', async () => {
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
jest.setSystemTime(new Date());
|
jest.setSystemTime(new Date());
|
||||||
const { userStore, featureToggleStore, projectStore, projectReadModel } =
|
const { userStore, featureToggleStore, projectStore } = stores;
|
||||||
stores;
|
|
||||||
const user = await userStore.insert({});
|
const user = await userStore.insert({});
|
||||||
await projectStore.create({ id: 'test_project', name: 'irrelevant' });
|
await projectStore.create({ id: 'test_project', name: 'irrelevant' });
|
||||||
await featureToggleStore.create('test_project', {
|
await featureToggleStore.create('test_project', {
|
||||||
@ -172,8 +170,7 @@ const reachedOnboardingEvents = (count: number) => {
|
|||||||
test('Reacting to events', async () => {
|
test('Reacting to events', async () => {
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
jest.setSystemTime(new Date());
|
jest.setSystemTime(new Date());
|
||||||
const { userStore, featureToggleStore, projectStore, projectReadModel } =
|
const { userStore, featureToggleStore, projectStore } = stores;
|
||||||
stores;
|
|
||||||
const user = await userStore.insert({});
|
const user = await userStore.insert({});
|
||||||
await projectStore.create({ id: 'test_project', name: 'irrelevant' });
|
await projectStore.create({ id: 'test_project', name: 'irrelevant' });
|
||||||
await featureToggleStore.create('test_project', {
|
await featureToggleStore.create('test_project', {
|
||||||
|
@ -56,8 +56,6 @@ export class OnboardingService {
|
|||||||
|
|
||||||
listen() {
|
listen() {
|
||||||
this.eventBus.on(USER_LOGIN, async (event: { loginOrder: number }) => {
|
this.eventBus.on(USER_LOGIN, async (event: { loginOrder: number }) => {
|
||||||
if (!this.flagResolver.isEnabled('onboardingMetrics')) return;
|
|
||||||
|
|
||||||
if (event.loginOrder === 0) {
|
if (event.loginOrder === 0) {
|
||||||
await this.insert({ type: 'first-user-login' });
|
await this.insert({ type: 'first-user-login' });
|
||||||
}
|
}
|
||||||
@ -68,8 +66,6 @@ export class OnboardingService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.eventBus.on(STAGE_ENTERED, async (stage: NewStage) => {
|
this.eventBus.on(STAGE_ENTERED, async (stage: NewStage) => {
|
||||||
if (!this.flagResolver.isEnabled('onboardingMetrics')) return;
|
|
||||||
|
|
||||||
if (stage.stage === 'initial') {
|
if (stage.stage === 'initial') {
|
||||||
await this.insert({
|
await this.insert({
|
||||||
type: 'flag-created',
|
type: 'flag-created',
|
||||||
|
@ -110,7 +110,7 @@ export function registerPrometheusMetrics(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const { eventStore, environmentStore } = stores;
|
const { eventStore, environmentStore } = stores;
|
||||||
const { flagResolver, db } = config;
|
const { flagResolver } = config;
|
||||||
const dbMetrics = new DbMetricsMonitor(config);
|
const dbMetrics = new DbMetricsMonitor(config);
|
||||||
|
|
||||||
const cachedEnvironments: () => Promise<IEnvironment[]> = memoizee(
|
const cachedEnvironments: () => Promise<IEnvironment[]> = memoizee(
|
||||||
@ -530,10 +530,7 @@ export function registerPrometheusMetrics(
|
|||||||
name: 'onboarding_duration',
|
name: 'onboarding_duration',
|
||||||
labelNames: ['event'],
|
labelNames: ['event'],
|
||||||
help: 'firstLogin, secondLogin, firstFeatureFlag, firstPreLive, firstLive from first user creation',
|
help: 'firstLogin, secondLogin, firstFeatureFlag, firstPreLive, firstLive from first user creation',
|
||||||
query: () =>
|
query: () => stores.onboardingReadModel.getInstanceOnboardingMetrics(),
|
||||||
flagResolver.isEnabled('onboardingMetrics')
|
|
||||||
? stores.onboardingReadModel.getInstanceOnboardingMetrics()
|
|
||||||
: Promise.resolve({}),
|
|
||||||
map: (result) =>
|
map: (result) =>
|
||||||
Object.keys(result)
|
Object.keys(result)
|
||||||
.filter((key) => Number.isInteger(result[key]))
|
.filter((key) => Number.isInteger(result[key]))
|
||||||
@ -549,10 +546,7 @@ export function registerPrometheusMetrics(
|
|||||||
name: 'project_onboarding_duration',
|
name: 'project_onboarding_duration',
|
||||||
labelNames: ['event', 'project'],
|
labelNames: ['event', 'project'],
|
||||||
help: 'firstFeatureFlag, firstPreLive, firstLive from project creation',
|
help: 'firstFeatureFlag, firstPreLive, firstLive from project creation',
|
||||||
query: () =>
|
query: () => stores.onboardingReadModel.getProjectsOnboardingMetrics(),
|
||||||
flagResolver.isEnabled('onboardingMetrics')
|
|
||||||
? stores.onboardingReadModel.getProjectsOnboardingMetrics()
|
|
||||||
: Promise.resolve([]),
|
|
||||||
map: (projectsOnboardingMetrics) =>
|
map: (projectsOnboardingMetrics) =>
|
||||||
projectsOnboardingMetrics.flatMap(
|
projectsOnboardingMetrics.flatMap(
|
||||||
({ project, ...projectMetrics }) =>
|
({ project, ...projectMetrics }) =>
|
||||||
|
@ -49,7 +49,6 @@ export type IFlagKey =
|
|||||||
| 'enableLegacyVariants'
|
| 'enableLegacyVariants'
|
||||||
| 'extendedMetrics'
|
| 'extendedMetrics'
|
||||||
| 'removeUnsafeInlineStyleSrc'
|
| 'removeUnsafeInlineStyleSrc'
|
||||||
| 'onboardingMetrics'
|
|
||||||
| 'onboardingUI'
|
| 'onboardingUI'
|
||||||
| 'projectRoleAssignment'
|
| 'projectRoleAssignment'
|
||||||
| 'eventTimeline'
|
| 'eventTimeline'
|
||||||
@ -255,10 +254,6 @@ const flags: IFlags = {
|
|||||||
process.env.UNLEASH_EXPERIMENTAL_REMOVE_UNSAFE_INLINE_STYLE_SRC,
|
process.env.UNLEASH_EXPERIMENTAL_REMOVE_UNSAFE_INLINE_STYLE_SRC,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
onboardingMetrics: parseEnvVarBoolean(
|
|
||||||
process.env.UNLEASH_EXPERIMENTAL_ONBOARDING_METRICS,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
onboardingUI: parseEnvVarBoolean(
|
onboardingUI: parseEnvVarBoolean(
|
||||||
process.env.UNLEASH_EXPERIMENTAL_ONBOARDING_UI,
|
process.env.UNLEASH_EXPERIMENTAL_ONBOARDING_UI,
|
||||||
false,
|
false,
|
||||||
|
@ -49,7 +49,6 @@ process.nextTick(async () => {
|
|||||||
manyStrategiesPagination: true,
|
manyStrategiesPagination: true,
|
||||||
enableLegacyVariants: false,
|
enableLegacyVariants: false,
|
||||||
extendedMetrics: true,
|
extendedMetrics: true,
|
||||||
onboardingMetrics: true,
|
|
||||||
onboardingUI: true,
|
onboardingUI: true,
|
||||||
personalDashboardUI: true,
|
personalDashboardUI: true,
|
||||||
purchaseAdditionalEnvironments: true,
|
purchaseAdditionalEnvironments: true,
|
||||||
|
@ -8,7 +8,7 @@ let db: ITestDb;
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
db = await dbInit('user_store_serial', getLogger, {
|
db = await dbInit('user_store_serial', getLogger, {
|
||||||
experimental: { flags: { onboardingMetrics: true } },
|
experimental: { flags: {} },
|
||||||
});
|
});
|
||||||
stores = db.stores;
|
stores = db.stores;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user