Class: ShopifyCLI::Migrator::Migrations::MergeReportingConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_cli/migrator/migrations/1633691650_merge_reporting_configuration.rb

Overview

Before this migration, users configured automatic usage and error reporting independenty. We changed it to be a single configuration in the environment's configuration and therefore we need a migration to merge the configurations.

Class Method Summary collapse

Class Method Details

.run ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/shopify_cli/migrator/migrations/1633691650_merge_reporting_configuration.rb', line 11

def self.run
  analytics_enabled = ShopifyCLI::Config.get_bool(
    Constants::Config::Sections::Analytics::NAME,
    Constants::Config::Sections::Analytics::Fields::ENABLED,
    default: false
  )
  error_reporting_enabled = ShopifyCLI::Config.get_bool(
    "error-tracking",
    "automatic-reporting",
    default: false
  )
  # Because we are merging configuration options, both need
  # to be true to for the new flag to be true. Otherwise,
  # we delete them and let the CLI prompt the user again.
  should_merge_be_true = analytics_enabled && error_reporting_enabled

  unless should_merge_be_true
    ShopifyCLI::Config.unset(
      Constants::Config::Sections::Analytics::NAME,
      Constants::Config::Sections::Analytics::Fields::ENABLED
    )
    ShopifyCLI::Config.unset(
      "error-tracking",
      "automatic-reporting"
    )
  end
end