Просмотр исходного кода

Merge pull request #26901 from overleaf/rh-hotjar-marketing

Add hotjar tracking to marketing pages

GitOrigin-RevId: 5490392b44a287e4853778416323b3aa5fbfc1ef
roo hutton 1 год назад
Родитель
Сommit
6bdcd1f803

+ 10 - 1
services/web/app/src/Features/StaticPages/HomeController.mjs

@@ -6,6 +6,7 @@ import ErrorController from '../Errors/ErrorController.js'
 import SessionManager from '../Authentication/SessionManager.js'
 import SessionManager from '../Authentication/SessionManager.js'
 import { expressify } from '@overleaf/promise-utils'
 import { expressify } from '@overleaf/promise-utils'
 import logger from '@overleaf/logger'
 import logger from '@overleaf/logger'
+import SplitTestHandler from '../SplitTests/SplitTestHandler.js'
 
 
 const __dirname = new URL('.', import.meta.url).pathname
 const __dirname = new URL('.', import.meta.url).pathname
 
 
@@ -31,7 +32,15 @@ async function home(req, res) {
       page: req.path,
       page: req.path,
     })
     })
 
 
-    res.render('external/home/index')
+    const hotjarAssignment = await SplitTestHandler.promises.getAssignment(
+      req,
+      res,
+      'hotjar-marketing'
+    )
+
+    res.render('external/home/index', {
+      shouldLoadHotjar: hotjarAssignment?.variant === 'enabled',
+    })
   } else {
   } else {
     res.redirect('/login')
     res.redirect('/login')
   }
   }

+ 3 - 0
services/web/app/views/layout-website-redesign.pug

@@ -6,6 +6,9 @@ include ./_mixins/bootstrap_js
 block entrypointVar
 block entrypointVar
 	- entrypoint = 'marketing'
 	- entrypoint = 'marketing'
 
 
+block append meta
+	meta(name='ol-shouldLoadHotjar' data-type='boolean' content=shouldLoadHotjar)
+
 block body
 block body
 	if typeof suppressNavbar == 'undefined'
 	if typeof suppressNavbar == 'undefined'
 		if bootstrapVersion === 5
 		if bootstrapVersion === 5

+ 2 - 1
services/web/frontend/js/features/cookie-banner/index.js

@@ -30,7 +30,8 @@ function setConsent(value) {
 if (
 if (
   getMeta('ol-ExposedSettings').gaToken ||
   getMeta('ol-ExposedSettings').gaToken ||
   getMeta('ol-ExposedSettings').gaTokenV4 ||
   getMeta('ol-ExposedSettings').gaTokenV4 ||
-  getMeta('ol-ExposedSettings').propensityId
+  getMeta('ol-ExposedSettings').propensityId ||
+  getMeta('ol-ExposedSettings').hotjarId
 ) {
 ) {
   document
   document
     .querySelectorAll('[data-ol-cookie-banner-set-consent]')
     .querySelectorAll('[data-ol-cookie-banner-set-consent]')

+ 1 - 0
services/web/frontend/js/marketing.ts

@@ -1,5 +1,6 @@
 import './utils/webpack-public-path'
 import './utils/webpack-public-path'
 import './infrastructure/error-reporter'
 import './infrastructure/error-reporter'
+import './infrastructure/hotjar'
 import './features/form-helpers/hydrate-form'
 import './features/form-helpers/hydrate-form'
 import './features/form-helpers/password-visibility'
 import './features/form-helpers/password-visibility'
 import './features/link-helpers/slow-link'
 import './features/link-helpers/slow-link'

+ 1 - 0
services/web/frontend/js/pages/marketing/homepage.js

@@ -1,4 +1,5 @@
 import '../../marketing'
 import '../../marketing'
+import '@/infrastructure/hotjar'
 
 
 function homepageAnimation(homepageAnimationEl) {
 function homepageAnimation(homepageAnimationEl) {
   function createFrames(word, { buildTime, holdTime, breakTime }) {
   function createFrames(word, { buildTime, holdTime, breakTime }) {