Skip to content

Commit fd8fccb

Browse files
authored
fix: adding navigation events (#4182)
1 parent b15754a commit fd8fccb

File tree

32 files changed

+160
-177
lines changed

32 files changed

+160
-177
lines changed

src/accounts/AccountHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const AccountHeader: FC<Props> = ({testID = 'member-page--header'}) => (
1313
<Page.Header fullWidth={false} testID={testID}>
1414
<Page.Title title="Account" />
1515
<LimitChecker>
16-
<RateLimitAlert />
16+
<RateLimitAlert location="account" />
1717
</LimitChecker>
1818
</Page.Header>
1919
)

src/alerting/components/AlertingIndex.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const AlertingIndex: FunctionComponent = () => {
6565
<Page.Header fullWidth={true} testID="alerts-page--header">
6666
<Page.Title title="Alerts" />
6767
<ErrorBoundary>
68-
<RateLimitAlert />
68+
<RateLimitAlert location="alerting" />
6969
</ErrorBoundary>
7070
</Page.Header>
7171
<Page.Contents

src/annotations/containers/AnnotationsIndex.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
// Libraries
22
import React, {FC} from 'react'
3-
import {useSelector} from 'react-redux'
43

54
// Components
65
import SettingsTabbedPage from 'src/settings/components/SettingsTabbedPage'
76
import SettingsHeader from 'src/settings/components/SettingsHeader'
87
import {Page} from '@influxdata/clockface'
98
import {AnnotationsTab} from 'src/annotations/components/AnnotationsTab'
109

11-
// Selectors
12-
import {getOrg} from 'src/organizations/selectors'
13-
1410
// Utils
1511
import {pageTitleSuffixer} from 'src/shared/utils/pageTitles'
1612

1713
export const AnnotationsIndex: FC = () => {
18-
const org = useSelector(getOrg)
19-
2014
return (
2115
<>
2216
<Page titleTag={pageTitleSuffixer(['Annotations', 'Settings'])}>
2317
<SettingsHeader />
24-
<SettingsTabbedPage activeTab="annotations" orgID={org.id}>
18+
<SettingsTabbedPage activeTab="annotations">
2519
{/*
2620
TODO: GetResources with ResourceType.AnnotationStreams
2721
*/}

src/billing/components/BillingPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const BillingPage: FC = () => {
1919
<Page.Header fullWidth={false} testID="billing-page--header">
2020
<Page.Title title="Account" />
2121
<LimitChecker>
22-
<RateLimitAlert />
22+
<RateLimitAlert location="billing" />
2323
</LimitChecker>
2424
</Page.Header>
2525
<AccountTabContainer activeTab="billing">

src/checks/components/CheckHistory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const CheckHistory: FC = () => {
5757
title="Check Statuses"
5858
testID="alert-history-title"
5959
/>
60-
<RateLimitAlert />
60+
<RateLimitAlert location="check history" />
6161
</Page.Header>
6262
<Page.ControlBar fullWidth={true}>
6363
<Page.ControlBarLeft>

src/cloud/components/AssetLimitOverlay.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import CloudUpgradeButton from 'src/shared/components/CloudUpgradeButton'
1616

1717
// Types
1818
import {AppState} from 'src/types'
19+
import {event} from 'src/cloud/utils/reporting'
1920

2021
interface OwnProps {
2122
onClose: () => void
@@ -57,6 +58,9 @@ const AssetLimitOverlay: FC<OwnProps & StateProps> = ({assetName, onClose}) => {
5758
<CloudUpgradeButton
5859
size={ComponentSize.Large}
5960
className="upgrade-payg--button__asset-create"
61+
metric={() => {
62+
event('asset limit upgrade', {asset: assetName})
63+
}}
6064
/>
6165
</Overlay.Footer>
6266
</div>
Lines changed: 42 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Libraries
22
import React, {FC, useEffect} from 'react'
3-
import {connect} from 'react-redux'
3+
import {useSelector, useDispatch} from 'react-redux'
44
import classnames from 'classnames'
55

66
// Components
@@ -23,13 +23,12 @@ import {
2323
extractRateLimitResources,
2424
extractRateLimitStatus,
2525
} from 'src/cloud/utils/limits'
26+
import {event} from 'src/cloud/utils/reporting'
2627

2728
// Constants
2829
import {CLOUD} from 'src/shared/constants'
2930

3031
// Types
31-
import {AppState} from 'src/types'
32-
import {LimitStatus} from 'src/cloud/actions/limits'
3332
import RateLimitAlertContent from 'src/cloud/components/RateLimitAlertContent'
3433

3534
import {notify} from 'src/shared/actions/notifications'
@@ -42,59 +41,50 @@ import {UpgradeContent} from 'src/cloud/components/RateLimitAlertContent'
4241

4342
import './RateLimitAlert.scss'
4443

45-
interface StateProps {
46-
resources: string[]
47-
status: LimitStatus['status']
48-
showUpgrade: boolean
49-
}
50-
51-
interface OwnProps {
44+
interface Props {
5245
alertOnly?: boolean
5346
className?: string
54-
sendNotify: (_: any) => void
55-
handleShowOverlay: any
56-
handleDismissOverlay: any
47+
location?: string
5748
}
58-
type Props = StateProps & OwnProps
5949

60-
const RateLimitAlert: FC<Props> = ({
61-
status,
62-
alertOnly,
63-
className,
64-
resources,
65-
showUpgrade,
66-
sendNotify,
67-
handleShowOverlay,
68-
handleDismissOverlay,
69-
}) => {
50+
const RateLimitAlert: FC<Props> = ({alertOnly, className, location}) => {
51+
const resources = useSelector(extractRateLimitResources)
52+
const status = useSelector(extractRateLimitStatus)
53+
const showUpgrade = useSelector(shouldShowUpgradeButton)
54+
const dispatch = useDispatch()
55+
7056
const appearOverlay = () => {
71-
handleShowOverlay('write-limit', null, handleDismissOverlay)
57+
dispatch(showOverlay('write-limit', null, () => dispatch(dismissOverlay)))
7258
}
7359

7460
useEffect(() => {
7561
if (CLOUD && status === 'exceeded' && resources.includes('write')) {
7662
if (showUpgrade) {
77-
sendNotify(
78-
writeLimitReached(
79-
'',
80-
<UpgradeContent
81-
type="write"
82-
link="https://docs.influxdata.com/influxdb/v2.0/write-data/best-practices/optimize-writes/"
83-
className="flex-upgrade-content"
84-
/>
63+
dispatch(
64+
notify(
65+
writeLimitReached(
66+
'',
67+
<UpgradeContent
68+
type="write"
69+
link="https://docs.influxdata.com/influxdb/v2.0/write-data/best-practices/optimize-writes/"
70+
className="flex-upgrade-content"
71+
/>
72+
)
8573
)
8674
)
8775
} else {
88-
sendNotify(
89-
writeLimitReached(
90-
"Data in has stopped because you've hit the query write limit. Let's get it flowing again: ",
91-
<Button
92-
className="rate-alert-overlay-button"
93-
color={ComponentColor.Primary}
94-
size={ComponentSize.Small}
95-
onClick={appearOverlay}
96-
text="Request Write Limit Increase"
97-
/>
76+
dispatch(
77+
notify(
78+
writeLimitReached(
79+
"Data in has stopped because you've hit the query write limit. Let's get it flowing again: ",
80+
<Button
81+
className="rate-alert-overlay-button"
82+
color={ComponentColor.Primary}
83+
size={ComponentSize.Small}
84+
onClick={appearOverlay}
85+
text="Request Write Limit Increase"
86+
/>
87+
)
9888
)
9989
)
10090
}
@@ -126,27 +116,17 @@ const RateLimitAlert: FC<Props> = ({
126116
}
127117

128118
if (CLOUD && !alertOnly) {
129-
return <CloudUpgradeButton className="upgrade-payg--button__header" />
119+
return (
120+
<CloudUpgradeButton
121+
className="upgrade-payg--button__header"
122+
metric={() => {
123+
event('rate limit upgrade', {location})
124+
}}
125+
/>
126+
)
130127
}
131128

132129
return null
133130
}
134131

135-
const mstp = (state: AppState) => {
136-
const resources = extractRateLimitResources(state)
137-
const status = extractRateLimitStatus(state)
138-
const showUpgrade = shouldShowUpgradeButton(state)
139-
return {
140-
status,
141-
resources,
142-
showUpgrade,
143-
}
144-
}
145-
146-
const mdtp = {
147-
sendNotify: notify,
148-
handleShowOverlay: showOverlay,
149-
handleDismissOverlay: dismissOverlay,
150-
}
151-
152-
export default connect(mstp, mdtp)(RateLimitAlert)
132+
export default RateLimitAlert

src/cloud/components/RateLimitAlertContent.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,23 @@ import {event} from 'src/cloud/utils/reporting'
2222

2323
interface Props {
2424
className?: string
25+
location?: string
2526
}
2627

2728
interface UpgradeProps {
2829
type: string
2930
link: string
3031
className?: string
3132
limitText?: string
33+
location?: string
3234
}
3335

3436
export const UpgradeContent: FC<UpgradeProps> = ({
3537
type,
3638
link,
3739
className,
3840
limitText,
41+
location,
3942
}) => {
4043
return (
4144
<div className={`${className} rate-alert--content__free`}>
@@ -58,14 +61,14 @@ export const UpgradeContent: FC<UpgradeProps> = ({
5861
>
5962
<CloudUpgradeButton
6063
className="upgrade-payg--button__rate-alert"
61-
metric={() => event(`user.limits.${type}.upgrade`)}
64+
metric={() => event(`user.limits.${type}.upgrade`, {location})}
6265
/>
6366
</FlexBox>
6467
</div>
6568
)
6669
}
6770

68-
const RateLimitAlertContent: FC<Props> = ({className}) => {
71+
const RateLimitAlertContent: FC<Props> = ({className, location}) => {
6972
const dispatch = useDispatch()
7073
const showUpgradeButton = useSelector(shouldShowUpgradeButton)
7174
const rateLimitAlertContentClass = classnames('rate-alert--content', {
@@ -82,6 +85,7 @@ const RateLimitAlertContent: FC<Props> = ({className}) => {
8285
type="series cardinality"
8386
link="https://docs.influxdata.com/influxdb/v2.0/write-data/best-practices/resolve-high-cardinality/"
8487
className={rateLimitAlertContentClass}
88+
location={location}
8589
/>
8690
)
8791
}

src/dashboards/components/DashboardPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class DashboardPage extends Component<Props> {
7373
<LimitChecker>
7474
<HoverTimeProvider>
7575
<DashboardHeader onManualRefresh={onManualRefresh} />
76-
<RateLimitAlert alertOnly={true} />
76+
<RateLimitAlert alertOnly={true} location="dashboard page" />
7777
<VariablesControlBar />
7878
<ErrorBoundary>
7979
<DashboardComponent manualRefresh={manualRefresh} />

src/dashboards/components/dashboard_index/DashboardsIndex.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class DashboardIndex extends PureComponent<Props, State> {
6464
>
6565
<Page.Header fullWidth={false}>
6666
<Page.Title title="Dashboards" />
67-
<RateLimitAlert />
67+
<RateLimitAlert location="dashboards" />
6868
</Page.Header>
6969
<Page.ControlBar fullWidth={false}>
7070
<ErrorBoundary>

0 commit comments

Comments
 (0)