33import dev .faststats .internal .Logger ;
44import dev .faststats .internal .LoggerFactory ;
55import org .jetbrains .annotations .Contract ;
6+ import org .jetbrains .annotations .MustBeInvokedByOverriders ;
67import org .jspecify .annotations .Nullable ;
78
89import java .io .IOException ;
@@ -19,9 +20,9 @@ public non-sealed abstract class SimpleContext implements FastStatsContext {
1920 private final @ Token String token ;
2021 private final SdkInfo sdkInfo ;
2122
22- private final @ Nullable Metrics metrics ;
23- private final @ Nullable FeatureFlagService featureFlagService ;
24- private final @ Nullable ErrorTrackerService errorTrackerService ;
23+ private @ Nullable Metrics metrics ;
24+ private @ Nullable FeatureFlagService featureFlagService ;
25+ private @ Nullable ErrorTrackerService errorTrackerService ;
2526
2627 /**
2728 * Creates a new context that stores the shared configuration and token for all FastStats services.
@@ -42,7 +43,10 @@ protected SimpleContext(final Factory<?, ?> factory, final Config config, final
4243 this .sdkInfo = constructSdkInfo (name );
4344 this .config = config ;
4445 this .token = token ;
46+ }
4547
48+ @ MustBeInvokedByOverriders
49+ protected final void initializeServices (final Factory <?, ?> factory ) throws IllegalStateException {
4650 this .metrics = factory .metrics != null ? factory .metrics .apply (metricsFactory ()) : null ;
4751 this .errorTrackerService = factory .errorTracker != null ? new SimpleErrorTrackerService (this , factory .errorTracker ) : null ;
4852 this .featureFlagService = factory .featureFlagService != null ? factory .featureFlagService .apply (new SimpleFeatureFlagService .Factory (config , token )) : null ;
0 commit comments