From 525cd2b04e2e606a8a7731152c79e0cc1596ea68 Mon Sep 17 00:00:00 2001 From: Jonas Alfredsson Date: Mon, 29 May 2023 15:49:12 +0200 Subject: [PATCH] Track all feature flag calls If an analytics processor exists we previouly only tracked feature flag names that were present either from the environment or from the API. However, this gave us no information about calls to flags that either were wrong, or were handled by the default handler. With this change we now track all calls for more extensive coverage. --- models.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/models.go b/models.go index 00449d7..da62f75 100644 --- a/models.go +++ b/models.go @@ -142,6 +142,10 @@ func (f *Flags) IsFeatureEnabled(featureName string) (bool, error) { // Returns a specific flag given the name of the feature. func (f *Flags) GetFlag(featureName string) (Flag, error) { + if f.analyticsProcessor != nil { + f.analyticsProcessor.TrackFeature(featureName) + } + var resultFlag Flag for _, flag := range f.flags { if flag.FeatureName == featureName { @@ -154,8 +158,5 @@ func (f *Flags) GetFlag(featureName string) (Flag, error) { } return resultFlag, &FlagsmithClientError{fmt.Sprintf("flagsmith: No feature found with name %q", featureName)} } - if f.analyticsProcessor != nil { - f.analyticsProcessor.TrackFeature(resultFlag.FeatureName) - } return resultFlag, nil }