diff --git a/.env.example b/.env.example index 26b1487ae..21a72526d 100644 --- a/.env.example +++ b/.env.example @@ -184,12 +184,6 @@ ANDROID_SHA256_CERT_FINGERPRINT=AC:73:8E:DE:EB:56:EA:CC:10:87:02:A7:65:37:7B:38: # SENTRY_DSN= -# MICROSOFT CLARITY -# MS_CLARITY_TOKEN=xxxxxxxxx - -# GOOGLE_TAG_MANAGER -# GOOGLE_TAG = GTM-XXXXXXX - ## Scout ## https://scoutapm.com/docs/ruby/configuration # SCOUT_KEY=YOURKEY diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 521d027cc..e656c2550 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -3,6 +3,7 @@ class DashboardController < ActionController::Base before_action :set_application_pack before_action :set_global_config + before_action :set_dashboard_scripts around_action :switch_locale before_action :ensure_installation_onboarding, only: [:index] before_action :render_hc_if_custom_domain, only: [:index] @@ -35,6 +36,10 @@ class DashboardController < ActionController::Base ).merge(app_config) end + def set_dashboard_scripts + @dashboard_scripts = GlobalConfig.get_value('DASHBOARD_SCRIPTS') + end + def ensure_installation_onboarding redirect_to '/installation/onboarding' if ::Redis::Alfred.get(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING) end diff --git a/app/views/layouts/vueapp.html.erb b/app/views/layouts/vueapp.html.erb index eb129867c..cf800cda2 100644 --- a/app/views/layouts/vueapp.html.erb +++ b/app/views/layouts/vueapp.html.erb @@ -70,40 +70,8 @@
<%= yield %> - <% if @global_config['CHATWOOT_INBOX_TOKEN'].present? %> - - <% end %> - <% if ENV.fetch('MS_CLARITY_TOKEN', nil).present? %> - - <% end %> - <% if ENV.fetch('GOOGLE_TAG', nil).present? %> - + <% if @dashboard_scripts.present? %> + <%= @dashboard_scripts.html_safe %> <% end %> diff --git a/app/views/super_admin/app_configs/show.html.erb b/app/views/super_admin/app_configs/show.html.erb index 83f99f6bd..1754808e5 100644 --- a/app/views/super_admin/app_configs/show.html.erb +++ b/app/views/super_admin/app_configs/show.html.erb @@ -13,18 +13,25 @@
<%= form.label "app_config[#{key}]", @installation_configs[key]&.dig('display_title') || key %>
-
+
<% if @installation_configs[key]&.dig('type') == 'boolean' %> <%= form.select "app_config[#{key}]", [["True", true], ["False", false]], { selected: ActiveModel::Type::Boolean.new.cast(@app_config[key]) }, class: "mt-2 border border-slate-100 p-1 rounded-md" %> + <% elsif @installation_configs[key]&.dig('type') == 'code' %> + <%= form.text_area "app_config[#{key}]", + value: @app_config[key], + rows: 12, + wrap: 'off', + class: "mt-2 border font-mono text-xs border-slate-100 p-1 rounded-md overflow-scroll" + %> <% else %> <%= form.text_field "app_config[#{key}]", value: @app_config[key] %> <% end %> <%if @installation_configs[key]&.dig('description').present? %> -

+

<%= @installation_configs[key]&.dig('description') %>

<% end %> diff --git a/config/installation_config.yml b/config/installation_config.yml index b0f4549aa..419a63352 100644 --- a/config/installation_config.yml +++ b/config/installation_config.yml @@ -163,6 +163,11 @@ value: display_title: 'Clearbit API Key' description: 'This API key is used for onboarding the users, to pre-fill account data.' +- name: DASHBOARD_SCRIPTS + value: + display_title: 'Dashboard Scripts' + description: 'Scripts are loaded as the last item in the tag' + type: code # ------- End of Chatwoot Internal Config for Cloud ----# # ------- Chatwoot Internal Config for Self Hosted ----# diff --git a/enterprise/app/controllers/enterprise/super_admin/app_configs_controller.rb b/enterprise/app/controllers/enterprise/super_admin/app_configs_controller.rb index ae1394a24..39a131ba2 100644 --- a/enterprise/app/controllers/enterprise/super_admin/app_configs_controller.rb +++ b/enterprise/app/controllers/enterprise/super_admin/app_configs_controller.rb @@ -30,6 +30,6 @@ module Enterprise::SuperAdmin::AppConfigsController end def internal_config_options - %w[CHATWOOT_INBOX_TOKEN CHATWOOT_INBOX_HMAC_KEY ANALYTICS_TOKEN CLEARBIT_API_KEY] + %w[CHATWOOT_INBOX_TOKEN CHATWOOT_INBOX_HMAC_KEY ANALYTICS_TOKEN CLEARBIT_API_KEY DASHBOARD_SCRIPTS] end end