Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Helpscout beacon #6

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SECRET_KEY_BASE=
HELP_SCOUT_BEACON_ID_MAIN=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
public/uploads
# Ignore application configuration
/config/application.yml

# Ignore .env file
.env
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ gem "decidim", "0.23.6"

gem "bootsnap", "~> 1.4"

gem "dotenv-rails"

gem "puma", "~> 4.3.5"
gem "uglifier", "~> 4.1"

Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ GEM
doorkeeper (5.5.2)
railties (>= 5)
doorkeeper-i18n (4.0.1)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
equalizer (0.0.11)
erb_lint (0.0.37)
activesupport
Expand Down Expand Up @@ -851,6 +855,7 @@ DEPENDENCIES
decidim-navbar_links!
decidim-term_customizer!
delayed_job_active_record
dotenv-rails
faker (~> 1.9)
figaro
jquery-ui-rails
Expand Down
4 changes: 4 additions & 0 deletions app/views/layouts/decidim/admin/_template_bottom.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
</div><!--/.layout-wrapper-->
</main>

<%= render "support/helpscout" %>
22 changes: 22 additions & 0 deletions app/views/support/_beacon.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script type="text/javascript">!function (e, t, n) {
function a() {
var e = t.getElementsByTagName("script")[0], n = t.createElement("script");
n.type = "text/javascript", n.async = !0, n.src = "https://beacon-v2.helpscout.net", e.parentNode.insertBefore(n, e)
}

if (e.Beacon = n = function (t, n, a) {
e.Beacon.readyQueue.push({method: t, options: n, data: a})
}, n.readyQueue = [], "complete" === t.readyState) return a();
e.attachEvent ? e.attachEvent("onload", a) : e.addEventListener("load", a, !1)
}(window, document, window.Beacon || function () {
});</script>
<script type="text/javascript">window.Beacon('init', '<%= beacon_id %>')</script>
<% if current_user %>
<script type="text/javascript">
Beacon("identify", {
name: "<%= current_user.name %>",
email: "<%= current_user.email %>",
company: "<%= current_user.organization.name %>"
});
</script>
<% end %>
11 changes: 11 additions & 0 deletions app/views/support/_helpscout.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% if Rails.application.secrets.dig(:helpscout).present? && Rails.application.secrets.dig(:helpscout, :enabled) %>
<% if Rails.application.secrets.dig(:helpscout, :fallback) %>
<% if current_locale == "fr" %>
<%= render partial: "support/beacon", locals: { beacon_id: Rails.application.secrets.dig(:helpscout, :main) } %>
<% else %>
<%= render partial: "support/beacon", locals: { beacon_id: Rails.application.secrets.dig(:helpscout, :fallback) } %>
<% end %>
<% else %>
<%= render partial: "support/beacon", locals: { beacon_id: Rails.application.secrets.dig(:helpscout, :main) } %>
<% end %>
<% end %>
4 changes: 4 additions & 0 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
# if you're sharing your code publicly.

default: &default
helpscout:
enabled: true
main: <%= ENV["HELP_SCOUT_BEACON_ID_MAIN"] %>
fallback: <%= ENV["HELP_SCOUT_BEACON_ID_FALLBACK"] %>
omniauth:
# facebook:
# # It must be a boolean. Remember ENV variables doesn't support booleans.
Expand Down