Class AnalyticsAwareFeatureFlag

java.lang.Object
com.atlassian.jira.config.FeatureFlag
com.atlassian.jira.config.AnalyticsAwareFeatureFlag
All Implemented Interfaces:
Feature

@Internal public class AnalyticsAwareFeatureFlag extends FeatureFlag
A AnalyticsAwareFeatureFlag is extended version of FeatureFlag that makes Feature Flag analytics compatible. It means that with safeFeatureKey property it is possible to declare that feature key should be hashed or can be passed as it is. Default behaviour is to hash all feature keys.

If you don't know what analytics are or if you are not sure if your feature key is safe, then you don't want to use this class.

This class is useful only when used together with FeatureFlagProvider. If you use this class outside of implementation of FeatureFlagProvider it will have no effect = class will be working as normal implementation of FeatureFlag.

  • Method Details

    • isSafeFlagForAnalytics

      public boolean isSafeFlagForAnalytics()
      Returns:
      true if feature flag key doesn't contain UGC and false otherwise
    • getSafeFeatureKey

      public String getSafeFeatureKey()
      Returns:
      feature key if flag is analytics friendly of SHA256 of feature key if flag is not analytics friendly
    • safeKey

      public AnalyticsAwareFeatureFlag safeKey()
      Creates a new FeatureFlag that is set as safe for analytics
      Returns:
      a new feature flag
    • unsafeKey

      public AnalyticsAwareFeatureFlag unsafeKey()
      Creates a new FeatureFlag that is set as unsafe for analytics
      Returns:
      a new feature flag
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class FeatureFlag
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class FeatureFlag
    • featureFlag

      public static AnalyticsAwareFeatureFlag featureFlag(String featureKey)
      Creates a new FeatureFlag with the specified key and off by default and set as unsafe for analytics
      Parameters:
      featureKey - the key in play
      Returns:
      a new feature flag
    • safeFeatureFlag

      public static AnalyticsAwareFeatureFlag safeFeatureFlag(String featureKey)
      Creates a new FeatureFlag with the specified key and off by default and set as safe for analytics
      Parameters:
      featureKey - the key in play
      Returns:
      a new feature flag
    • convertToSafeFeatureFlag

      public static AnalyticsAwareFeatureFlag convertToSafeFeatureFlag(FeatureFlag featureFlag)
      Creates a new FeatureFlag with the data from original feature key and set as safe for analytics
      Parameters:
      featureFlag - the flag in play
      Returns:
      a new feature flag
    • convertToUnsafeFeatureFlag

      public static FeatureFlag convertToUnsafeFeatureFlag(FeatureFlag featureFlag)
      Creates a new FeatureFlag with the data from original feature key and set as unsafe for analytics
      Parameters:
      featureFlag - the flag in play
      Returns:
      a new feature flag
    • convertToAnalyticsAware

      public static AnalyticsAwareFeatureFlag convertToAnalyticsAware(FeatureFlag featureFlag)
      Creates a new FeatureFlag with the data from original feature key if FeatureFlag is not instance of AnalyticsAwareFeatureFlag or returns flag itself otherwise
      Parameters:
      featureFlag - feature flag to convert
      Returns:
      instance of AnalyticsAwareFeatureFlag if the same settings as provided feature flag