diff --git a/package-lock.json b/package-lock.json index 1609eb8bf..6b5ce4b95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.17.0-pre-12", + "version": "1.17.0-pre-13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.17.0-pre-12", + "version": "1.17.0-pre-13", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index 5be440157..ea0e278e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.17.0-pre-12", + "version": "1.17.0-pre-13", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Shared/Components/ActionMenu/ActionMenuItem.tsx b/src/Shared/Components/ActionMenu/ActionMenuItem.tsx index 8d9970c03..b4aca7195 100644 --- a/src/Shared/Components/ActionMenu/ActionMenuItem.tsx +++ b/src/Shared/Components/ActionMenu/ActionMenuItem.tsx @@ -2,7 +2,9 @@ import { LegacyRef, MouseEvent, Ref } from 'react' import { Link } from 'react-router-dom' import { Tooltip } from '@Common/Tooltip' +import { useMainContext } from '@Shared/Providers' +import { getUTMPathAppended } from '../DocLink/utils' import { Icon } from '../Icon' import { getTooltipProps } from '../SelectPicker/common' import { TrailingItem } from '../TrailingItem' @@ -30,6 +32,8 @@ export const ActionMenuItem = ({ componentType = 'button', } = item + const { isEnterprise } = useMainContext() + // REFS const ref: LegacyRef = (el) => { if (isFocused && el) { @@ -92,7 +96,7 @@ export const ActionMenuItem = ({ } className={COMMON_ACTION_MENU_ITEM_CLASS} - href={item.href} + href={getUTMPathAppended({ isEnterprise, link: item.href })} target="_blank" rel="noreferrer" onClick={handleClick} diff --git a/src/Shared/Components/DocLink/types.ts b/src/Shared/Components/DocLink/types.ts index 5ced59b00..b018f55a0 100644 --- a/src/Shared/Components/DocLink/types.ts +++ b/src/Shared/Components/DocLink/types.ts @@ -25,3 +25,8 @@ export type DocLinkProps = Pick< */ openInNewTab?: boolean } + +export interface URLWithUTMSource { + isEnterprise: BaseDocLink['isEnterprise'] + link?: string +} diff --git a/src/Shared/Components/DocLink/utils.tsx b/src/Shared/Components/DocLink/utils.tsx index 2124c59f4..6ae039d9e 100644 --- a/src/Shared/Components/DocLink/utils.tsx +++ b/src/Shared/Components/DocLink/utils.tsx @@ -1,7 +1,10 @@ import { DOCUMENTATION_HOME_PAGE, DOCUMENTATION_VERSION } from '@Common/Constants' import { DOCUMENTATION } from './constants' -import { BaseDocLink } from './types' +import { BaseDocLink, URLWithUTMSource } from './types' + +export const getUTMPathAppended = ({ isEnterprise, link = '' }: URLWithUTMSource) => + `${link}?utm_source=product_${isEnterprise ? 'ent' : 'oss'}&utm_medium=product_app&utm_campaign=docs_navigation` export const getDocumentationUrl = ({ docLinkKey, @@ -19,9 +22,7 @@ export const getDocumentationUrl = ({ return docPath } - const utmPath = !isLicenseDashboard - ? `?utm_source=product_${isEnterprise ? 'ent' : 'oss'}&utm_medium=product_app&utm_campaign=docs_navigation` - : '' + const utmPath = !isLicenseDashboard ? getUTMPathAppended({ isEnterprise }) : '' return `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/${docPath || ''}${utmPath}` }