diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index e94002a580..51e1c18fae 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -807,6 +807,7 @@ const _ProjectController = { ? usedLatex : null, isSaas: Features.hasFeature('saas'), + shouldLoadHotjar: splitTestAssignments.hotjar?.variant === 'enabled', }) timer.done() } catch (err) { diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index 598b1a9582..5d4232623b 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -130,6 +130,8 @@ async function plansPage(req, res) { ? formatCurrencyLocalized : SubscriptionHelper.formatCurrencyDefault + const shouldLoadHotjar = await getShouldLoadHotjar(req, res) + res.render('subscriptions/plans', { title: 'plans_and_pricing', currentView, @@ -156,6 +158,7 @@ async function plansPage(req, res) { latamCountryBannerDetails, countryCode, websiteRedesignPlansVariant: 'default', + shouldLoadHotjar, }) } @@ -194,6 +197,8 @@ async function plansPageLightDesign(req, res) { const latamCountryBannerDetails = await getLatamCountryBannerDetails(req, res) + const shouldLoadHotjar = await getShouldLoadHotjar(req, res) + res.render('subscriptions/plans-light-design', { title: 'plans_and_pricing', currentView, @@ -220,6 +225,7 @@ async function plansPageLightDesign(req, res) { latamCountryBannerDetails, countryCode, websiteRedesignPlansVariant: 'light-design', + shouldLoadHotjar, }) } @@ -383,6 +389,8 @@ async function interstitialPaymentPage(req, res) { 'local-ccy-format-v2' ) + const shouldLoadHotjar = await getShouldLoadHotjar(req, res) + res.render(template, { title: 'subscribe', itm_content: req.query?.itm_content, @@ -403,6 +411,7 @@ async function interstitialPaymentPage(req, res) { skipLinkTarget: req.session?.postCheckoutRedirect || '/project', websiteRedesignPlansVariant: websiteRedesignPlansAssignment.variant, countryCode, + shouldLoadHotjar, }) } } @@ -899,6 +908,15 @@ async function getLatamCountryBannerDetails(req, res) { return latamCountryBannerDetails } +async function getShouldLoadHotjar(req, res) { + const assignment = await SplitTestHandler.promises.getAssignment( + req, + res, + 'hotjar-plans' + ) + return assignment?.variant === 'enabled' +} + /** * Build a subscription change preview for display purposes * diff --git a/services/web/app/views/project/editor/_meta.pug b/services/web/app/views/project/editor/_meta.pug index 712deffc61..47aaea0ca5 100644 --- a/services/web/app/views/project/editor/_meta.pug +++ b/services/web/app/views/project/editor/_meta.pug @@ -39,6 +39,7 @@ meta(name="ol-linkSharingEnforcement" data-type="boolean" content=linkSharingEnf meta(name="ol-usedLatex" data-type="string" content=usedLatex) meta(name="ol-ro-mirror-on-client-no-local-storage" data-type="boolean" content=roMirrorOnClientNoLocalStorage) meta(name="ol-isSaas" data-type="boolean" content=isSaas) +meta(name="ol-shouldLoadHotjar" data-type="boolean" content=shouldLoadHotjar) // translations for the loading page, before i18n has loaded in the client meta(name="ol-loadingText", data-type="string" content=translate("loading")) diff --git a/services/web/app/views/subscriptions/interstitial-payment-light-design.pug b/services/web/app/views/subscriptions/interstitial-payment-light-design.pug index 9fb878cd50..bb8ded05b4 100644 --- a/services/web/app/views/subscriptions/interstitial-payment-light-design.pug +++ b/services/web/app/views/subscriptions/interstitial-payment-light-design.pug @@ -17,6 +17,7 @@ block append meta meta(name="ol-itm_content" content=itm_content) meta(name="ol-countryCode" content=countryCode) meta(name="ol-websiteRedesignPlansVariant" content=websiteRedesignPlansVariant) + meta(name="ol-shouldLoadHotjar" data-type="boolean" content=shouldLoadHotjar) block content main.website-redesign#main-content diff --git a/services/web/app/views/subscriptions/interstitial-payment.pug b/services/web/app/views/subscriptions/interstitial-payment.pug index a771af7dfc..f112805520 100644 --- a/services/web/app/views/subscriptions/interstitial-payment.pug +++ b/services/web/app/views/subscriptions/interstitial-payment.pug @@ -15,6 +15,7 @@ block append meta meta(name="ol-itm_content" content=itm_content) meta(name="ol-countryCode" content=countryCode) meta(name="ol-websiteRedesignPlansVariant" content=websiteRedesignPlansVariant) + meta(name="ol-shouldLoadHotjar" data-type="boolean" content=shouldLoadHotjar) block content main.content.content-alt#main-content diff --git a/services/web/app/views/subscriptions/plans-light-design.pug b/services/web/app/views/subscriptions/plans-light-design.pug index f9e2ba0423..ef569a1062 100644 --- a/services/web/app/views/subscriptions/plans-light-design.pug +++ b/services/web/app/views/subscriptions/plans-light-design.pug @@ -15,6 +15,7 @@ block append meta meta(name="ol-currentView" content=currentView) meta(name="ol-countryCode" content=countryCode) meta(name="ol-websiteRedesignPlansVariant" content=websiteRedesignPlansVariant) + meta(name="ol-shouldLoadHotjar" data-type="boolean" content=shouldLoadHotjar) block content main.website-redesign#main-content diff --git a/services/web/app/views/subscriptions/plans.pug b/services/web/app/views/subscriptions/plans.pug index 50e17b09c1..4c8c59961d 100644 --- a/services/web/app/views/subscriptions/plans.pug +++ b/services/web/app/views/subscriptions/plans.pug @@ -11,6 +11,7 @@ block append meta meta(name="ol-currentView" content=currentView) meta(name="ol-countryCode" content=countryCode) meta(name="ol-websiteRedesignPlansVariant" content=websiteRedesignPlansVariant) + meta(name="ol-shouldLoadHotjar" data-type="boolean" content=shouldLoadHotjar) block content main.content.content-alt#main-content diff --git a/services/web/frontend/js/infrastructure/hotjar.ts b/services/web/frontend/js/infrastructure/hotjar.ts index c72b8fd1eb..67051d088f 100644 --- a/services/web/frontend/js/infrastructure/hotjar.ts +++ b/services/web/frontend/js/infrastructure/hotjar.ts @@ -1,13 +1,13 @@ import getMeta from '@/utils/meta' -import { isSplitTestEnabled } from '@/utils/splitTestUtils' import { debugConsole } from '@/utils/debugging' import { initializeHotjar } from '@/infrastructure/hotjar-snippet' const { hotjarId, hotjarVersion } = getMeta('ol-ExposedSettings') +const shouldLoadHotjar = getMeta('ol-shouldLoadHotjar') let hotjarInitialized = false -if (hotjarId && hotjarVersion && isSplitTestEnabled('hotjar')) { +if (hotjarId && hotjarVersion && shouldLoadHotjar) { const loadHotjar = () => { // consent needed if (!document.cookie.split('; ').some(item => item === 'oa=1')) { diff --git a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js index 503b64e603..d3465bee1d 100644 --- a/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js +++ b/services/web/frontend/js/pages/user/subscription/plans-v2/plans-v2-main.js @@ -1,4 +1,5 @@ import '../../../../marketing' +import '../../../../infrastructure/hotjar' import * as eventTracking from '../../../../infrastructure/event-tracking' import { setUpStickyHeaderObserver } from './plans-v2-sticky-header' diff --git a/services/web/frontend/js/utils/meta.ts b/services/web/frontend/js/utils/meta.ts index 8a9d11778b..03b3b2bf7c 100644 --- a/services/web/frontend/js/utils/meta.ts +++ b/services/web/frontend/js/utils/meta.ts @@ -175,6 +175,7 @@ export interface Meta { 'ol-settingsGroupSSO': { enabled: boolean } | undefined 'ol-settingsPlans': Plan[] 'ol-shouldAllowEditingDetails': boolean + 'ol-shouldLoadHotjar': boolean 'ol-showAiErrorAssistant': boolean 'ol-showBrlGeoBanner': boolean 'ol-showCouponField': boolean