Skip to content

Commit 09ff413

Browse files
authored
feat: add eventing for helpbar (#4682)
* feat: add eventing for helpbar * chore: clean up * chore: add eventing for three helpbar links * chore: clean up
1 parent d490f91 commit 09ff413

File tree

3 files changed

+44
-35
lines changed

3 files changed

+44
-35
lines changed

src/pageLayout/containers/TreeNav.tsx

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Libraries
22
import React, {FC, useContext, useEffect} from 'react'
3-
import {Link} from 'react-router-dom'
3+
import {Link, useLocation} from 'react-router-dom'
44
import {useSelector} from 'react-redux'
55
import {connect, ConnectedProps} from 'react-redux'
66
import {withRouter, RouteComponentProps} from 'react-router-dom'
@@ -42,7 +42,7 @@ const TreeSidebar: FC<ReduxProps & RouteComponentProps> = () =>
4242
AppSettingContext
4343
)
4444
const org = useSelector(getOrg)
45-
45+
const location = useLocation()
4646
useEffect(() => {
4747
if (isFlagEnabled('helpBar')) {
4848
const helpBarMenu = document.querySelectorAll<HTMLElement>(
@@ -72,23 +72,10 @@ const TreeSidebar: FC<ReduxProps & RouteComponentProps> = () =>
7272
}
7373
}
7474

75-
// Hiding Contact Support and Feedback code for Help Bar phase 1 release
76-
// https://github.com/influxdata/ui/issues/3457
77-
// https://github.com/influxdata/ui/issues/3454
78-
// const handleSelect = (): void => {
79-
// const accountType = quartzMe?.accountType ?? 'free'
80-
// const isPayGCustomer = accountType !== 'free'
81-
82-
// if (isPayGCustomer) {
83-
// showOverlay('payg-support', null, dismissOverlay)
84-
// } else {
85-
// showOverlay('free-account-support', null, dismissOverlay)
86-
// }
87-
// }
88-
89-
// const openFeedbackOverlay = (): void => {
90-
// showOverlay('feedback-questions', null, dismissOverlay)
91-
// }
75+
const handleEventing = (link: string): void => {
76+
const currentPage = location.pathname
77+
event(`helpBar.${link}.opened`, {}, {from: currentPage})
78+
}
9279

9380
return (
9481
<OrgSettings>
@@ -173,30 +160,33 @@ const TreeSidebar: FC<ReduxProps & RouteComponentProps> = () =>
173160
label="Documentation"
174161
testID="nav-subitem-documentation"
175162
linkElement={() => (
176-
<SafeBlankLink href="https://docs.influxdata.com/" />
163+
<SafeBlankLink
164+
href="https://docs.influxdata.com/"
165+
onClick={() => handleEventing('documentation')}
166+
/>
177167
)}
178168
/>
179169
<TreeNav.SubItem
180170
id="faqs"
181171
label="FAQs"
182172
testID="nav-subitem-faqs"
183173
linkElement={() => (
184-
<SafeBlankLink href="https://docs.influxdata.com/influxdb/cloud/reference/faq/" />
174+
<SafeBlankLink
175+
href="https://docs.influxdata.com/influxdb/cloud/reference/faq/"
176+
onClick={() => handleEventing('faq')}
177+
/>
185178
)}
186179
/>
187-
{/* <TreeNav.SubItem
188-
id="contactSupport"
189-
label="Contact Support"
190-
testID="nav-subitem-contact-support"
191-
onClick={handleSelect}
192-
/> */}
193180
<TreeNav.SubHeading label="Community" />
194181
<TreeNav.SubItem
195182
id="offcialForum"
196183
label="Official Forum"
197184
testID="nav-subitem-forum"
198185
linkElement={() => (
199-
<SafeBlankLink href="https://community.influxdata.com" />
186+
<SafeBlankLink
187+
href="https://community.influxdata.com"
188+
onClick={() => handleEventing('officialForum')}
189+
/>
200190
)}
201191
/>
202192
<TreeNav.SubItem
@@ -207,13 +197,6 @@ const TreeSidebar: FC<ReduxProps & RouteComponentProps> = () =>
207197
<SafeBlankLink href="https://influxcommunity.slack.com/join/shared_invite/zt-156zm7ult-LcIW2T4TwLYeS8rZbCP1mw#/shared-invite/email" />
208198
)}
209199
/>
210-
{/* <TreeNav.SubHeading label="Feedback" />
211-
<TreeNav.SubItem
212-
id="feedback"
213-
label="Feedback & Questions"
214-
testID="nav-subitem-feedback-questions"
215-
onClick={openFeedbackOverlay}
216-
/> */}
217200
</TreeNav.SubMenu>
218201
</TreeNav.Item>
219202
) : null}

src/support/components/FeedbackQuestionsOverlay.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {FC, ChangeEvent, useContext, useState} from 'react'
2+
import {useSelector} from 'react-redux'
23

34
// Components
45
import {
@@ -17,16 +18,30 @@ import {OverlayContext} from 'src/overlays/components/OverlayController'
1718
// Types
1819
import ErrorBoundary from 'src/shared/components/ErrorBoundary'
1920

21+
// Selectors
22+
import {getOrg} from 'src/organizations/selectors'
23+
import {getMe} from 'src/me/selectors'
24+
25+
// Utils
26+
import {event} from 'src/cloud/utils/reporting'
27+
2028
interface OwnProps {
2129
onClose: () => void
2230
}
2331

2432
const FeedbackQuestionsOverlay: FC<OwnProps> = () => {
2533
const {onClose} = useContext(OverlayContext)
34+
const {id: orgID} = useSelector(getOrg)
35+
const {id: meID} = useSelector(getMe)
2636
const [feedbackText, setFeedbackText] = useState('')
2737

2838
const handleSubmit = () => {
2939
// handle form submit
40+
event(
41+
'helpBar.feedbackAndQuestions.submitted',
42+
{},
43+
{userID: meID, orgID: orgID}
44+
)
3045
}
3146

3247
const handleInputChange = (e: ChangeEvent<HTMLTextAreaElement>) => {

src/support/components/PayGSupportOverlay.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {FC, ChangeEvent, useContext, useState} from 'react'
2+
import {useSelector} from 'react-redux'
23

34
// Components
45
import {
@@ -25,12 +26,21 @@ import {OverlayContext} from 'src/overlays/components/OverlayController'
2526
// Types
2627
import ErrorBoundary from 'src/shared/components/ErrorBoundary'
2728

29+
// Selectors
30+
import {getOrg} from 'src/organizations/selectors'
31+
import {getMe} from 'src/me/selectors'
32+
33+
// Utils
34+
import {event} from 'src/cloud/utils/reporting'
35+
2836
import './ContactSupport.scss'
2937
interface OwnProps {
3038
onClose: () => void
3139
}
3240

3341
const PayGSupportOverlay: FC<OwnProps> = () => {
42+
const {id: orgID} = useSelector(getOrg)
43+
const {id: meID} = useSelector(getMe)
3444
const [subject, setSubject] = useState('')
3545
const [severity, setSeverity] = useState('')
3646
const [textInput, setTextInput] = useState('')
@@ -53,6 +63,7 @@ const PayGSupportOverlay: FC<OwnProps> = () => {
5363
}
5464
const handleSubmit = (): void => {
5565
// submit support form
66+
event('helpBar.supportRequest.submitted', {}, {userID: meID, orgID: orgID})
5667
}
5768

5869
const handleSubjectChange = (event: ChangeEvent<HTMLInputElement>) => {

0 commit comments

Comments
 (0)