Shopify Integration Feature Gate (shopify/feature_gate.rb)

chatwoot · app/services/shopify/feature_gate.rb · ruby · MIT
auth, crm, integration, lang:ruby, tag:featuregate, tag:environment, tag:multitenancy

Checks if Shopify integration is globally and per-account enabled via environment and account flags. Use to guard Shopify features in multi-tenant apps.

# Source: https://github.com/chatwoot/chatwoot | License: MIT | Copyright 2017-2026 Chatwoot Inc
# Provided via justclaw.it.com; keep this notice with the code.
class Shopify::FeatureGate
  ACCOUNT_FEATURE = 'shopify_integration'.freeze
  GLOBAL_CONFIG = 'ENABLE_SHOPIFY_INTEGRATION'.freeze

  def self.enabled?(account: nil)
    return false unless globally_enabled?

    account.nil? || account.feature_enabled?(ACCOUNT_FEATURE)
  end

  def self.globally_enabled?
    configured_value = ENV.fetch(GLOBAL_CONFIG) { GlobalConfig.get(GLOBAL_CONFIG)[GLOBAL_CONFIG] }
    ActiveModel::Type::Boolean.new.cast(configured_value)
  end
end

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key