@@ -7,6 +7,7 @@ import { FeatureFlagProvider } from 'src/modules/feature/providers/feature-flag/
7
7
import { EventEmitter2 , OnEvent } from '@nestjs/event-emitter' ;
8
8
import { FeatureAnalytics } from 'src/modules/feature/feature.analytics' ;
9
9
import { knownFeatures } from 'src/modules/feature/constants/known-features' ;
10
+ import { Feature } from 'src/modules/feature/model/feature' ;
10
11
11
12
@Injectable ( )
12
13
export class FeatureService {
@@ -38,7 +39,7 @@ export class FeatureService {
38
39
/**
39
40
* Returns list of features flags
40
41
*/
41
- async list ( ) {
42
+ async list ( ) : Promise < { features : Record < string , Feature > } > {
42
43
this . logger . log ( 'Getting features list' ) ;
43
44
44
45
const features = { } ;
@@ -68,14 +69,6 @@ export class FeatureService {
68
69
}
69
70
} ) ;
70
71
71
- try {
72
- this . analytics . sendFeatureFlagRecalculated ( {
73
- configVersion : ( await this . featuresConfigRepository . getOrCreate ( ) ) ?. data ?. version ,
74
- features,
75
- } ) ;
76
- } catch ( e ) {
77
- // ignore telemetry error
78
- }
79
72
return { features } ;
80
73
}
81
74
@@ -118,7 +111,17 @@ export class FeatureService {
118
111
`Features flags recalculated. Updated: ${ actions . toUpsert . length } deleted: ${ actions . toDelete . length } ` ,
119
112
) ;
120
113
121
- this . eventEmitter . emit ( FeatureServerEvents . FeaturesRecalculated , await this . list ( ) ) ;
114
+ const list = await this . list ( ) ;
115
+ this . eventEmitter . emit ( FeatureServerEvents . FeaturesRecalculated , list ) ;
116
+
117
+ try {
118
+ this . analytics . sendFeatureFlagRecalculated ( {
119
+ configVersion : ( await this . featuresConfigRepository . getOrCreate ( ) ) ?. data ?. version ,
120
+ features : list . features ,
121
+ } ) ;
122
+ } catch ( e ) {
123
+ // ignore telemetry error
124
+ }
122
125
} catch ( e ) {
123
126
this . logger . error ( 'Unable to recalculate features flags' , e ) ;
124
127
}
0 commit comments