diff --git a/docusaurus.config.js b/docusaurus.config.js index c8e28ed999..debfbfb4da 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -27,6 +27,12 @@ module.exports = { stylesheets: [ 'https://fonts.googleapis.com/css?family=Material+Icons', ], + scripts: [ + { + src: 'https://cdn.jsdelivr.net/npm/search-insights@2.17.3', + async: true, + }, + ], future: { v4: true, experimental_faster: true, diff --git a/package.json b/package.json index 3917527ebd..d404ba9267 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@algolia/autocomplete-preset-algolia": "1.17.9", "@algolia/client-abtesting": "5.18.0", "@algolia/client-analytics": "5.18.0", - "@algolia/client-insights": "5.18.0", + "@algolia/client-insights": "^5.30.0", "@algolia/client-personalization": "5.18.0", "@algolia/client-query-suggestions": "5.18.0", "@algolia/client-search": "5.18.0", @@ -151,6 +151,7 @@ "repeat-string": "1.6.1", "sass": "^1.44.0", "sass-loader": "^12.4.0", + "search-insights": "^2.17.3", "serve-handler": "6.1.6", "shelljs": "^0.9.0", "snake-case": "3.0.4", diff --git a/src/components/SearchConversionTracker.js b/src/components/SearchConversionTracker.js new file mode 100644 index 0000000000..65d877a644 --- /dev/null +++ b/src/components/SearchConversionTracker.js @@ -0,0 +1,43 @@ +'use client'; + +import { useEffect } from 'react'; +import aa from 'search-insights'; + +export default function SearchConversionTracker() { + useEffect(() => { + aa('init', { + appId: '2SJPGMLW1Q', + apiKey: 'fb2f4e1fb40f962900631121cb365549', + useCookie: true, + }); + + const handleClick = (event) => { + const target = event.target.closest('a[data-algolia-objectid][data-algolia-queryid][data-algolia-index]'); + if (target) { + const objectID = target.getAttribute('data-algolia-objectid'); + const queryID = target.getAttribute('data-algolia-queryid'); + const indexName = target.getAttribute('data-algolia-index'); + + if (objectID && queryID && indexName) { + console.log('Sending conversion:', { + objectID, + queryID, + indexName, + }); + + aa('convertedObjectIDsAfterSearch', { + index: indexName, + eventName: 'Search result clicked', + queryID, + objectIDs: [objectID], + }); + } + } + }; + + document.addEventListener('click', handleClick); + return () => document.removeEventListener('click', handleClick); + }, []); + + return null; +} diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 220fc4327d..9c2259d32f 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -9,6 +9,7 @@ import SumoLogicDocsLogo from '../../static/img/sumo-logic-docs.svg'; import { Feature } from '../components/Feature'; import { features } from '../helper/features'; import ErrorBoundary from '../components/ErrorBoundary'; +import SearchConversionTracker from '../components/SearchConversionTracker'; export const Home = () => { const [tab, setTab] = useState('0'); @@ -19,6 +20,7 @@ export const Home = () => { description='Sumo Logic docs - real-time alerting, security, dashboards, and machine-learning-powered analytics for all three types of telemetry — logs, metrics, and traces.' title='Home' > + {/* Header */} + {children} + + ); +} diff --git a/yarn.lock b/yarn.lock index 7a1f6fc3cc..60fd3d52ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -79,15 +79,10 @@ resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-5.27.0.tgz#290b9d0922c5a7162f6e322357a0d0a8565b939a" integrity sha512-tnFOzdNuMzsz93kOClj3fKfuYoF3oYaEB5bggULSj075GJ7HUNedBEm7a6ScrjtnOaOtipbnT7veUpHA4o4wEQ== -"@algolia/client-insights@5.18.0": - version "5.18.0" - resolved "https://registry.yarnpkg.com/@algolia/client-insights/-/client-insights-5.18.0.tgz#2c6f158e57265fd0888f5b84fe7302d6d659c0ff" - integrity sha512-FAJRNANUOSs/FgYOJ/Njqp+YTe4TMz2GkeZtfsw1TMiA5mVNRS/nnMpxas9771aJz7KTEWvK9GwqPs0K6RMYWg== - dependencies: - "@algolia/client-common" "5.18.0" - "@algolia/requester-browser-xhr" "5.18.0" - "@algolia/requester-fetch" "5.18.0" - "@algolia/requester-node-http" "5.18.0" +"@algolia/client-common@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-5.30.0.tgz#fa7b03095e90f7fef2d1786baec278e7125b0740" + integrity sha512-tbUgvkp2d20mHPbM0+NPbLg6SzkUh0lADUUjzNCF+HiPkjFRaIW3NGMlESKw5ia4Oz6ZvFzyREquUX6rdkdJcQ== "@algolia/client-insights@5.27.0": version "5.27.0" @@ -99,6 +94,16 @@ "@algolia/requester-fetch" "5.27.0" "@algolia/requester-node-http" "5.27.0" +"@algolia/client-insights@^5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@algolia/client-insights/-/client-insights-5.30.0.tgz#e2bd9e2e4984f2e68dc6c1f881fcd3834cd9b23f" + integrity sha512-caXuZqJK761m32KoEAEkjkE2WF/zYg1McuGesWXiLSgfxwZZIAf+DljpiSToBUXhoPesvjcLtINyYUzbkwE0iw== + dependencies: + "@algolia/client-common" "5.30.0" + "@algolia/requester-browser-xhr" "5.30.0" + "@algolia/requester-fetch" "5.30.0" + "@algolia/requester-node-http" "5.30.0" + "@algolia/client-personalization@5.18.0": version "5.18.0" resolved "https://registry.yarnpkg.com/@algolia/client-personalization/-/client-personalization-5.18.0.tgz#26128f6a1aef523ae32f29ef9afd18fd2f159b98" @@ -238,6 +243,13 @@ dependencies: "@algolia/client-common" "5.27.0" +"@algolia/requester-browser-xhr@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.30.0.tgz#a006ed06e910b33d750173ad86feb3ca2ede1a4c" + integrity sha512-alo3ly0tdNLjfMSPz9dmNwYUFHx7guaz5dTGlIzVGnOiwLgIoM6NgA+MJLMcH6e1S7OpmE2AxOy78svlhst2tQ== + dependencies: + "@algolia/client-common" "5.30.0" + "@algolia/requester-fetch@5.18.0": version "5.18.0" resolved "https://registry.yarnpkg.com/@algolia/requester-fetch/-/requester-fetch-5.18.0.tgz#fcccc76bd7d16fb54c56d15baa6b5f657b17ca71" @@ -252,6 +264,13 @@ dependencies: "@algolia/client-common" "5.27.0" +"@algolia/requester-fetch@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@algolia/requester-fetch/-/requester-fetch-5.30.0.tgz#a118448b51ce20f703aca706709a1196dada2a28" + integrity sha512-WOnTYUIY2InllHBy6HHMpGIOo7Or4xhYUx/jkoSK/kPIa1BRoFEHqa8v4pbKHtoG7oLvM2UAsylSnjVpIhGZXg== + dependencies: + "@algolia/client-common" "5.30.0" + "@algolia/requester-node-http@5.18.0": version "5.18.0" resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-5.18.0.tgz#c5b16de53d83276067583e7b2f56b09eac938435" @@ -266,6 +285,13 @@ dependencies: "@algolia/client-common" "5.27.0" +"@algolia/requester-node-http@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-5.30.0.tgz#607f827b09da78bc2300d02e137fbbbeed11f1d3" + integrity sha512-uSTUh9fxeHde1c7KhvZKUrivk90sdiDftC+rSKNFKKEU9TiIKAGA7B2oKC+AoMCqMymot1vW9SGbeESQPTZd0w== + dependencies: + "@algolia/client-common" "5.30.0" + "@ampproject/remapping@^2.2.0": version "2.3.0" resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.3.0.tgz#ed441b6fa600072520ce18b43d2c8cc8caecc7f4" @@ -12469,6 +12495,11 @@ schema-utils@^4.0.0, schema-utils@^4.0.1, schema-utils@^4.3.0, schema-utils@^4.3 ajv-formats "^2.1.1" ajv-keywords "^5.1.0" +search-insights@^2.17.3: + version "2.17.3" + resolved "https://registry.yarnpkg.com/search-insights/-/search-insights-2.17.3.tgz#8faea5d20507bf348caba0724e5386862847b661" + integrity sha512-RQPdCYTa8A68uM2jwxoY842xDhvx3E5LFL1LxvxCNMev4o5mLuokczhzjAgGwUZBAmOKZknArSxLKmXtIi2AxQ== + section-matter@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/section-matter/-/section-matter-1.0.0.tgz#e9041953506780ec01d59f292a19c7b850b84167"