{"version":3,"file":"main_menu_tracker-2f77cb46.js","sources":["../../../app/javascript/packs/analytics/main_menu_tracker.js"],"sourcesContent":["import $ from 'jquery'\nimport CalendarTracker from 'components_sites_calendar/helpers/CalendarTracker'\nimport ReportingTracker from 'components_reporting/helpers/ReportingTracker'\nimport SettingsTracker from 'components_shared/helpers/SettingsTracker'\nimport CompanyUserManagementTracker\n from '../../components_company_user_roles/helpers/CompanyUserManagementTracker'\n\n// Reporting\nconst reportingComponentName = 'Reporting'\nconst reportingTracker = ReportingTracker.forComponent(reportingComponentName)\n\n// User Management\nconst userManagementComponentName = 'UserManagement'\nconst userManagementTracker = CompanyUserManagementTracker.forComponent(userManagementComponentName)\n\n// Advice List\nconst adviceListComponentName = 'AdviceList'\nconst adviceListTracker = CalendarTracker.forComponent(adviceListComponentName)\n\n// Locale Select\nconst localeSelectComponentName = 'UserLocaleInput'\nconst localeSelectTracker = SettingsTracker.forComponent(localeSelectComponentName)\n\n$(document).ready(() => {\n // Reporting\n memoizedExposureTracker('reportingExposed', 'nav-reporting-icon', () => {\n reportingTracker.track(reportingComponentName, 'exposed')\n })\n\n // User Management\n memoizedExposureTracker('userManagementExposed', 'operatorUserManagement', () => {\n userManagementTracker.track(userManagementComponentName, 'exposed')\n })\n memoizedExposureTracker('contributorUserManagementExposed', 'contributorUserManagement', () => {\n userManagementTracker.track(userManagementComponentName, 'exposed')\n })\n memoizedExposureTracker('prospectsCountExposed', 'prospects-count', () => {\n userManagementTracker.track(userManagementComponentName, 'prospects count exposed')\n }, true)\n\n // Advice List\n memoizedExposureTracker('adviceListExposed', 'nav-advice-list-icon', () => {\n adviceListTracker.track(adviceListComponentName, 'exposed')\n })\n\n // Locale Select\n memoizedExposureTracker('localeSelectExposed', 'localeDropdownMenuButton', () => {\n localeSelectTracker.track(localeSelectComponentName, 'exposed')\n })\n})\n\n/**\n * Uses the localStorage to memoize whether an element has been previously exposed or not. If not previously\n * exposed, run the callback function\n * @param cacheKey {string} the key used to check the localStorage for existence\n * @param elementId {string} the id of element to check if exists\n * @param callback {()=>void} the callback function - used once if the element has never been\n * @param forceWrite {boolean} skip cache check and force writes to storage\n */\nconst memoizedExposureTracker = (cacheKey, elementId, callback, forceWrite = false) => {\n const element = document.getElementById(elementId)\n if (element) {\n const elementExposed = localStorage.getItem(cacheKey)\n if (elementExposed !== 'true' || forceWrite) {\n setTimeout(() => callback(), 0)\n localStorage.setItem(cacheKey, 'true')\n }\n }\n}\n"],"names":["reportingComponentName","reportingTracker","ReportingTracker","userManagementComponentName","userManagementTracker","CompanyUserManagementTracker","adviceListComponentName","adviceListTracker","CalendarTracker","localeSelectComponentName","localeSelectTracker","SettingsTracker","$","memoizedExposureTracker","cacheKey","elementId","callback","forceWrite"],"mappings":"sWAQA,MAAMA,EAAyB,YACzBC,EAAmBC,EAAiB,aAAaF,CAAsB,EAGvEG,EAA8B,iBAC9BC,EAAwBC,EAA6B,aAAaF,CAA2B,EAG7FG,EAA0B,aAC1BC,EAAoBC,EAAgB,aAAaF,CAAuB,EAGxEG,EAA4B,kBAC5BC,EAAsBC,EAAgB,aAAaF,CAAyB,EAElFG,EAAE,QAAQ,EAAE,MAAM,IAAM,CAEtBC,EAAwB,mBAAoB,qBAAsB,IAAM,CACtEZ,EAAiB,MAAMD,EAAwB,SAAS,CAC5D,CAAG,EAGDa,EAAwB,wBAAyB,yBAA0B,IAAM,CAC/ET,EAAsB,MAAMD,EAA6B,SAAS,CACtE,CAAG,EACDU,EAAwB,mCAAoC,4BAA6B,IAAM,CAC7FT,EAAsB,MAAMD,EAA6B,SAAS,CACtE,CAAG,EACDU,EAAwB,wBAAyB,kBAAmB,IAAM,CACxET,EAAsB,MAAMD,EAA6B,yBAAyB,CACnF,EAAE,EAAI,EAGPU,EAAwB,oBAAqB,uBAAwB,IAAM,CACzEN,EAAkB,MAAMD,EAAyB,SAAS,CAC9D,CAAG,EAGDO,EAAwB,sBAAuB,2BAA4B,IAAM,CAC/EH,EAAoB,MAAMD,EAA2B,SAAS,CAClE,CAAG,CACH,CAAC,EAUD,MAAMI,EAA0B,CAACC,EAAUC,EAAWC,EAAUC,EAAa,KAAU,CACrE,SAAS,eAAeF,CAAS,IAExB,aAAa,QAAQD,CAAQ,IAC7B,QAAUG,KAC/B,WAAW,IAAMD,EAAU,EAAE,CAAC,EAC9B,aAAa,QAAQF,EAAU,MAAM,EAG3C"}