Skip to content

Commit

Permalink
chore: add instrumentation to video homepage search
Browse files Browse the repository at this point in the history
  • Loading branch information
tabathadelane committed Apr 4, 2023
1 parent 349c023 commit 5567df4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/components/HomepageVideo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React, { useEffect, useState } from 'react';
import { css } from '@emotion/react';
import { SearchInput, useTranslation } from '@newrelic/gatsby-theme-newrelic';
import {
SearchInput,
useTessen,
useTranslation,
} from '@newrelic/gatsby-theme-newrelic';
import { navigate } from '@reach/router';
import curlyAndDotsBackground from './curlyAndDots.png';
import curlyAndDotsBackgroundDarkmode from './curlyAndDotsDM.png';
Expand All @@ -10,6 +14,7 @@ import { useMainLayoutContext } from './MainLayoutContext';
const HomepageVideo = () => {
const [searchTerm, setSearchTerm] = useState('');
const { t } = useTranslation();
const tessen = useTessen();
const [sidebar] = useMainLayoutContext();
const [mobileBreakpoint, setMobileBreakpoint] = useState('1050px');

Expand Down Expand Up @@ -80,7 +85,14 @@ const HomepageVideo = () => {
onChange={(e) => {
setSearchTerm(e.target.value);
}}
onSubmit={() => navigate(`?q=${searchTerm || ''}`)}
onSubmit={() => {
tessen.track({
eventName: 'videoViewSearch',
category: 'SearchInput',
searchTerm,
});
navigate(`?q=${searchTerm || ''}`);
}}
css={css`
@media screen and (max-width: ${mobileBreakpoint}) {
margin-bottom: 1rem;
Expand Down

0 comments on commit 5567df4

Please sign in to comment.