mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-22 01:16:07 +02:00
parent
d7d9929e33
commit
6fb262986d
24
package.json
24
package.json
@ -82,9 +82,7 @@
|
||||
"testTimeout": 10000,
|
||||
"globalSetup": "./scripts/jest-setup.js",
|
||||
"transform": {
|
||||
"^.+\\.tsx?$": [
|
||||
"@swc/jest"
|
||||
]
|
||||
"^.+\\.tsx?$": ["@swc/jest"]
|
||||
},
|
||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
||||
"testPathIgnorePatterns": [
|
||||
@ -93,13 +91,7 @@
|
||||
"/frontend/",
|
||||
"/website/"
|
||||
],
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"tsx",
|
||||
"js",
|
||||
"jsx",
|
||||
"json"
|
||||
],
|
||||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json"],
|
||||
"coveragePathIgnorePatterns": [
|
||||
"/node_modules/",
|
||||
"/dist/",
|
||||
@ -240,14 +232,8 @@
|
||||
"tough-cookie": "4.1.4"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,ts}": [
|
||||
"biome check --write --no-errors-on-unmatched"
|
||||
],
|
||||
"*.{jsx,tsx}": [
|
||||
"biome check --write --no-errors-on-unmatched"
|
||||
],
|
||||
"*.json": [
|
||||
"biome format --write --no-errors-on-unmatched"
|
||||
]
|
||||
"*.{js,ts}": ["biome check --write --no-errors-on-unmatched"],
|
||||
"*.{jsx,tsx}": ["biome check --write --no-errors-on-unmatched"],
|
||||
"*.json": ["biome format --write --no-errors-on-unmatched"]
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {
|
||||
CLIENT_METRICS,
|
||||
CLIENT_METRICS_ADDED,
|
||||
FEATURE_ARCHIVED,
|
||||
FEATURE_COMPLETED,
|
||||
FEATURE_CREATED,
|
||||
@ -33,7 +33,7 @@ test('can insert and read lifecycle stages', async () => {
|
||||
);
|
||||
|
||||
function emitMetricsEvent(environment: string) {
|
||||
eventBus.emit(CLIENT_METRICS, [
|
||||
eventBus.emit(CLIENT_METRICS_ADDED, [
|
||||
{
|
||||
featureName,
|
||||
environment,
|
||||
@ -120,7 +120,7 @@ test('ignores lifecycle state updates when flag disabled', async () => {
|
||||
|
||||
await eventStore.emit(FEATURE_CREATED, { featureName });
|
||||
await eventStore.emit(FEATURE_COMPLETED, { featureName });
|
||||
await eventBus.emit(CLIENT_METRICS, {
|
||||
await eventBus.emit(CLIENT_METRICS_ADDED, {
|
||||
bucket: { toggles: { [featureName]: 'irrelevant' } },
|
||||
environment: 'development',
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {
|
||||
CLIENT_METRICS,
|
||||
CLIENT_METRICS_ADDED,
|
||||
FEATURE_ARCHIVED,
|
||||
FEATURE_CREATED,
|
||||
FEATURE_REVIVED,
|
||||
@ -9,8 +9,8 @@ import {
|
||||
type IEnvironmentStore,
|
||||
type IEventStore,
|
||||
type IFeatureEnvironmentStore,
|
||||
type IProjectLifecycleStageDuration,
|
||||
type IFlagResolver,
|
||||
type IProjectLifecycleStageDuration,
|
||||
type IUnleashConfig,
|
||||
} from '../../types';
|
||||
import type {
|
||||
@ -95,7 +95,7 @@ export class FeatureLifecycleService extends EventEmitter {
|
||||
);
|
||||
});
|
||||
this.eventBus.on(
|
||||
CLIENT_METRICS,
|
||||
CLIENT_METRICS_ADDED,
|
||||
async (events: IClientMetricsEnv[]) => {
|
||||
if (events.length > 0) {
|
||||
const groupedByEnvironment = groupBy(events, 'environment');
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
} from '../../../test/e2e/helpers/test-helper';
|
||||
import getLogger from '../../../test/fixtures/no-logger';
|
||||
import {
|
||||
CLIENT_METRICS,
|
||||
CLIENT_METRICS_ADDED,
|
||||
FEATURE_ARCHIVED,
|
||||
FEATURE_CREATED,
|
||||
FEATURE_REVIVED,
|
||||
@ -121,7 +121,7 @@ test('should return lifecycle stages', async () => {
|
||||
eventStore.emit(FEATURE_CREATED, { featureName: 'my_feature_a' });
|
||||
await reachedStage('my_feature_a', 'initial');
|
||||
await expectFeatureStage('my_feature_a', 'initial');
|
||||
eventBus.emit(CLIENT_METRICS, [
|
||||
eventBus.emit(CLIENT_METRICS_ADDED, [
|
||||
{
|
||||
featureName: 'my_feature_a',
|
||||
environment: 'default',
|
||||
@ -133,7 +133,7 @@ test('should return lifecycle stages', async () => {
|
||||
]);
|
||||
|
||||
// missing feature
|
||||
eventBus.emit(CLIENT_METRICS, [
|
||||
eventBus.emit(CLIENT_METRICS_ADDED, [
|
||||
{
|
||||
environment: 'default',
|
||||
yes: 0,
|
||||
@ -141,7 +141,7 @@ test('should return lifecycle stages', async () => {
|
||||
},
|
||||
]);
|
||||
// non existent env
|
||||
eventBus.emit(CLIENT_METRICS, [
|
||||
eventBus.emit(CLIENT_METRICS_ADDED, [
|
||||
{
|
||||
featureName: 'my_feature_a',
|
||||
environment: 'non-existent',
|
||||
|
@ -1,5 +1,9 @@
|
||||
import type { Logger } from '../../../logger';
|
||||
import type { IFlagResolver, IUnleashConfig } from '../../../types';
|
||||
import {
|
||||
CLIENT_METRICS_ADDED,
|
||||
type IFlagResolver,
|
||||
type IUnleashConfig,
|
||||
} from '../../../types';
|
||||
import type { IUnleashStores } from '../../../types';
|
||||
import type { ToggleMetricsSummary } from '../../../types/models/metrics';
|
||||
import type {
|
||||
@ -182,6 +186,7 @@ export default class ClientMetricsServiceV2 {
|
||||
const copy = [...this.unsavedMetrics];
|
||||
this.unsavedMetrics = [];
|
||||
await this.clientMetricsStoreV2.batchInsertMetrics(copy);
|
||||
this.config.eventBus.emit(CLIENT_METRICS_ADDED, copy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,7 @@ export const PROJECT_ENVIRONMENT_REMOVED =
|
||||
export const DEFAULT_STRATEGY_UPDATED = 'default-strategy-updated' as const;
|
||||
|
||||
export const CLIENT_METRICS = 'client-metrics' as const;
|
||||
export const CLIENT_METRICS_ADDED = 'client-metrics-added' as const;
|
||||
export const CLIENT_REGISTER = 'client-register' as const;
|
||||
|
||||
export const PAT_CREATED = 'pat-created' as const;
|
||||
|
Loading…
Reference in New Issue
Block a user