Skip to content

Commit

Permalink
feat: add Clarity to the WFE (#1305)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrasEszes authored Nov 15, 2024
1 parent ade8bf3 commit f4dcbf2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"lint": "eslint source/javascripts --cache",
"lint:fix": "eslint source/javascripts --cache --quiet --fix",
"build": "webpack --bail",
"build:website": "MODE=WEBSITE ANALYTICS=true HOTJAR=true DATADOG_RUM=true npm run build",
"build:website": "MODE=WEBSITE ANALYTICS=true CLARITY=true DATADOG_RUM=true npm run build",
"build:plugin": "MODE=CLI ANALYTICS=true npm run build && ./_scripts/compile_api.sh",
"start:dev": "webpack-dev-server",
"start:base": "concurrently \"npm:start:dev\" \"DEV=true ./_scripts/run_api.sh 4000\"",
Expand Down
4 changes: 2 additions & 2 deletions rails/transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def analytics?
ENV['ANALYTICS'] == 'true'
end

def hotjar?
ENV['HOTJAR'] == 'true'
def clarity?
ENV['CLARITY'] == 'true'
end

def freshpaint?
Expand Down
4 changes: 2 additions & 2 deletions source/index.slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ html
script[src="#{ mode_dependant_asset_path 'javascripts/vendor.js' }"]
script[src="#{ mode_dependant_asset_path 'javascripts/strings.js' }"]
script[src="#{ mode_dependant_asset_path 'javascripts/routes.js' }"]
- if hotjar?
script[src="#{ mode_dependant_asset_path 'javascripts/hotjar.js' }"]
- if clarity?
script[src="#{ mode_dependant_asset_path 'javascripts/clarity.js' }"]
- if datadog_rum?
script[src="#{ mode_dependant_asset_path 'javascripts/datadogrum.js' }"]
script[src="#{ mode_dependant_asset_path 'javascripts/main.js' }"]
Expand Down
5 changes: 5 additions & 0 deletions source/javascripts/clarity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function (c, l, a, r, i, t, y) {
c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments) };
t = l.createElement(r); t.async = 1; t.src = "https://www.clarity.ms/tag/" + i;
y = l.getElementsByTagName(r)[0]; y.parentNode.insertBefore(t, y);
})(window, document, "clarity", "script", "mxdzahxph2");
14 changes: 0 additions & 14 deletions source/javascripts/hotjar.js

This file was deleted.

8 changes: 4 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ const MonacoPluginOptions = {
],
};

const { NODE_ENV, MODE, PUBLIC_URL_ROOT, HOTJAR, DEV_SERVER_PORT, DATADOG_RUM } = process.env;
const { NODE_ENV, MODE, PUBLIC_URL_ROOT, CLARITY, DEV_SERVER_PORT, DATADOG_RUM } = process.env;
const isProd = NODE_ENV === 'prod';
const isWebsiteMode = MODE === 'WEBSITE';
const urlPrefix = isWebsiteMode ? PUBLIC_URL_ROOT : '';
const isHotjarEnabled = HOTJAR === 'true';
const isClarityEnabled = CLARITY === 'true';
const isDataDogRumEnabled = DATADOG_RUM === 'true';
const publicPath = `${urlPrefix}/${version}/`;

Expand All @@ -93,8 +93,8 @@ const entry = {
routes: './javascripts/routes.js.erb',
main: './javascripts/index.js',
};
if (isHotjarEnabled) {
entry.hotjar = './javascripts/hotjar.js';
if (isClarityEnabled) {
entry.clarity = './javascripts/clarity.js';
}
if (isDataDogRumEnabled) {
entry.datadogrum = './javascripts/datadog-rum.js.erb';
Expand Down

0 comments on commit f4dcbf2

Please sign in to comment.