Skip to content

Commit 467f93e

Browse files
authored
Merge pull request #820 from devtron-labs/chore/action-menu
feat: added utm to action menu href
2 parents 3564a41 + 0ee7687 commit 467f93e

5 files changed

Lines changed: 18 additions & 8 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.17.0-pre-12",
3+
"version": "1.17.0-pre-13",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/ActionMenu/ActionMenuItem.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { LegacyRef, MouseEvent, Ref } from 'react'
22
import { Link } from 'react-router-dom'
33

44
import { Tooltip } from '@Common/Tooltip'
5+
import { useMainContext } from '@Shared/Providers'
56

7+
import { getUTMPathAppended } from '../DocLink/utils'
68
import { Icon } from '../Icon'
79
import { getTooltipProps } from '../SelectPicker/common'
810
import { TrailingItem } from '../TrailingItem'
@@ -30,6 +32,8 @@ export const ActionMenuItem = <T extends string | number>({
3032
componentType = 'button',
3133
} = item
3234

35+
const { isEnterprise } = useMainContext()
36+
3337
// REFS
3438
const ref: LegacyRef<HTMLLIElement> = (el) => {
3539
if (isFocused && el) {
@@ -92,7 +96,7 @@ export const ActionMenuItem = <T extends string | number>({
9296
<a
9397
ref={itemRef as LegacyRef<HTMLAnchorElement>}
9498
className={COMMON_ACTION_MENU_ITEM_CLASS}
95-
href={item.href}
99+
href={getUTMPathAppended({ isEnterprise, link: item.href })}
96100
target="_blank"
97101
rel="noreferrer"
98102
onClick={handleClick}

src/Shared/Components/DocLink/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ export type DocLinkProps<T extends boolean = false> = Pick<
2525
*/
2626
openInNewTab?: boolean
2727
}
28+
29+
export interface URLWithUTMSource {
30+
isEnterprise: BaseDocLink<false>['isEnterprise']
31+
link?: string
32+
}

src/Shared/Components/DocLink/utils.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { DOCUMENTATION_HOME_PAGE, DOCUMENTATION_VERSION } from '@Common/Constants'
22

33
import { DOCUMENTATION } from './constants'
4-
import { BaseDocLink } from './types'
4+
import { BaseDocLink, URLWithUTMSource } from './types'
5+
6+
export const getUTMPathAppended = ({ isEnterprise, link = '' }: URLWithUTMSource) =>
7+
`${link}?utm_source=product_${isEnterprise ? 'ent' : 'oss'}&utm_medium=product_app&utm_campaign=docs_navigation`
58

69
export const getDocumentationUrl = <T extends boolean = false>({
710
docLinkKey,
@@ -19,9 +22,7 @@ export const getDocumentationUrl = <T extends boolean = false>({
1922
return docPath
2023
}
2124

22-
const utmPath = !isLicenseDashboard
23-
? `?utm_source=product_${isEnterprise ? 'ent' : 'oss'}&utm_medium=product_app&utm_campaign=docs_navigation`
24-
: ''
25+
const utmPath = !isLicenseDashboard ? getUTMPathAppended({ isEnterprise }) : ''
2526

2627
return `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/${docPath || ''}${utmPath}`
2728
}

0 commit comments

Comments
 (0)