Class: ApplicationExperiment

Inherits:
Gitlab::Experiment
  • Object
show all
Defined in:
app/experiments/application_experiment.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available?Boolean

We have experiments in ce/foss code even though they will never be available for ce/foss instances. We do that since we currently only experiment on the ee with SaaS instance. However, if the experiment is successful, we may commit the final code to ce/foss if the feature we are experimenting on is not a licensed or SaaS feature.

This follows the docs.gitlab.com/ee/development/ee_features.html guidelines and therefore we have hardcoded ‘false` here.

Returns:

  • (Boolean)


14
15
16
# File 'app/experiments/application_experiment.rb', line 14

def self.available?
  false
end

Instance Method Details

#control_behaviorObject



18
19
20
# File 'app/experiments/application_experiment.rb', line 18

def control_behavior
  # define a default nil control behavior so we can omit it when not needed
end

#key_for(source, seed = name) ⇒ Object

Deprecated.

This is deprecated logic as of v0.6.0 and should eventually be removed, but needs to stay intact for actively running experiments. The new strategy utilizes Digest::SHA2, a secret seed, and generates a 64-byte string.

gitlab.com/gitlab-org/gitlab/-/issues/334590



29
30
31
32
33
34
35
36
37
38
# File 'app/experiments/application_experiment.rb', line 29

def key_for(source, seed = name)
  # If FIPS is enabled, we simply call the method available in the gem, which
  # uses SHA2.
  return super if Gitlab::FIPS.enabled?

  # If FIPS isn't enabled, we use the legacy MD5 logic to keep existing
  # experiment events working.
  source = source.keys + source.values if source.is_a?(Hash)
  Digest::MD5.hexdigest(Array(source).map { |v| identify(v) }.unshift(seed).join('|'))
end

#nest_experiment(other) ⇒ Object



40
41
42
# File 'app/experiments/application_experiment.rb', line 40

def nest_experiment(other)
  instance_exec(:nested, { label: other.name }, &Configuration.tracking_behavior)
end