From 7e66219e044a8821c6386b6255e76c62385674b3 Mon Sep 17 00:00:00 2001 From: AGMETEOR Date: Fri, 12 Aug 2022 16:09:23 +0300 Subject: [PATCH 1/2] [MM-45761] - Telemetry: Track how many users end up in purchase/pricing modal/notify admin --- .../src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx | 2 +- webapp/src/components/cardDetail/cardDetail.tsx | 4 ++-- webapp/src/components/cardLimitNotification.tsx | 2 +- webapp/src/components/viewLImitDialog/viewLimitDialog.tsx | 2 +- webapp/src/types/index.d.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mattermost-plugin/webapp/src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx b/mattermost-plugin/webapp/src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx index 7b01fbcfa..f5cc977a0 100644 --- a/mattermost-plugin/webapp/src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx +++ b/mattermost-plugin/webapp/src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx @@ -8,7 +8,7 @@ const PostTypeCloudUpgradeNudge = (props: {post: Post}): JSX.Element => { const ctaHandler = (e: React.MouseEvent) => { e.preventDefault() const windowAny = (window as any) - windowAny?.openPricingModal()() + windowAny?.openPricingModal()('boards > click_view_upgrade_options_nudge') } // custom post type doesn't support styling via CSS stylesheet. diff --git a/webapp/src/components/cardDetail/cardDetail.tsx b/webapp/src/components/cardDetail/cardDetail.tsx index 8355edb71..6f0e74660 100644 --- a/webapp/src/components/cardDetail/cardDetail.tsx +++ b/webapp/src/components/cardDetail/cardDetail.tsx @@ -165,7 +165,7 @@ const CardDetail = (props: Props): JSX.Element|null => { role='button' onClick={() => { props.onClose(); - (window as any).openPricingModal()() + (window as any).openPricingModal()('boards > learn_more_about_our_plans_click') }} > { className='CardDetail__limited-button' onClick={() => { props.onClose(); - (window as any).openPricingModal()() + (window as any).openPricingModal()('boards > upgrade_click') }} emphasis='primary' size='large' diff --git a/webapp/src/components/cardLimitNotification.tsx b/webapp/src/components/cardLimitNotification.tsx index 041f08c97..0390983e1 100644 --- a/webapp/src/components/cardLimitNotification.tsx +++ b/webapp/src/components/cardLimitNotification.tsx @@ -119,7 +119,7 @@ const CardLimitNotification = (props: Props) => { }, [me?.id]) const onClick = useCallback(() => { - (window as any).openPricingModal()() + (window as any).openPricingModal()('boards > card_limit_notification_upgrade_to_a_paid_plan_click') TelemetryClient.trackEvent(TelemetryCategory, TelemetryActions.LimitCardLimitLinkOpen, {}) }, []) diff --git a/webapp/src/components/viewLImitDialog/viewLimitDialog.tsx b/webapp/src/components/viewLImitDialog/viewLimitDialog.tsx index 08d407978..7a6e6a919 100644 --- a/webapp/src/components/viewLImitDialog/viewLimitDialog.tsx +++ b/webapp/src/components/viewLImitDialog/viewLimitDialog.tsx @@ -80,7 +80,7 @@ export const ViewLimitModal = (props: Props): JSX.Element => { telemetryClient.trackEvent(TelemetryCategory, TelemetryActions.ViewLimitCTAPerformed, {board: board.id}) if (isAdmin) { - (window as any)?.openPricingModal()() + (window as any)?.openPricingModal()('boards > view_limit_dialog') } else { await octoClient.notifyAdminUpgrade() props.showNotifyAdminSuccess() diff --git a/webapp/src/types/index.d.ts b/webapp/src/types/index.d.ts index 019348717..c49d39a1a 100644 --- a/webapp/src/types/index.d.ts +++ b/webapp/src/types/index.d.ts @@ -8,7 +8,7 @@ export interface IAppWindow extends Window { msCrypto: Crypto openInNewBrowser?: ((href: string) => void) | null webkit?: {messageHandlers: {nativeApp?: {postMessage: (message: T) => void}}} - openPricingModal?: () => () => void + openPricingModal?: () => (callerInfo: string) => void } // SuiteWindow documents all custom properties From 65a19de70ad8e7bbe15ff89ea7fe4f084defc8d8 Mon Sep 17 00:00:00 2001 From: AGMETEOR Date: Fri, 12 Aug 2022 17:54:12 +0300 Subject: [PATCH 2/2] fix telemetry args --- .../src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx | 2 +- webapp/src/components/cardDetail/cardDetail.tsx | 4 ++-- webapp/src/components/cardLimitNotification.tsx | 2 +- webapp/src/components/viewLImitDialog/viewLimitDialog.tsx | 2 +- webapp/src/types/index.d.ts | 6 +++++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mattermost-plugin/webapp/src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx b/mattermost-plugin/webapp/src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx index f5cc977a0..15789188b 100644 --- a/mattermost-plugin/webapp/src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx +++ b/mattermost-plugin/webapp/src/components/cloudUpgradeNudge/cloudUpgradeNudge.tsx @@ -8,7 +8,7 @@ const PostTypeCloudUpgradeNudge = (props: {post: Post}): JSX.Element => { const ctaHandler = (e: React.MouseEvent) => { e.preventDefault() const windowAny = (window as any) - windowAny?.openPricingModal()('boards > click_view_upgrade_options_nudge') + windowAny?.openPricingModal()({trackingLocation: 'boards > click_view_upgrade_options_nudge'}) } // custom post type doesn't support styling via CSS stylesheet. diff --git a/webapp/src/components/cardDetail/cardDetail.tsx b/webapp/src/components/cardDetail/cardDetail.tsx index 6f0e74660..0cfaa3bf5 100644 --- a/webapp/src/components/cardDetail/cardDetail.tsx +++ b/webapp/src/components/cardDetail/cardDetail.tsx @@ -165,7 +165,7 @@ const CardDetail = (props: Props): JSX.Element|null => { role='button' onClick={() => { props.onClose(); - (window as any).openPricingModal()('boards > learn_more_about_our_plans_click') + (window as any).openPricingModal()({trackingLocation: 'boards > learn_more_about_our_plans_click'}) }} > { className='CardDetail__limited-button' onClick={() => { props.onClose(); - (window as any).openPricingModal()('boards > upgrade_click') + (window as any).openPricingModal()({trackingLocation: 'boards > upgrade_click'}) }} emphasis='primary' size='large' diff --git a/webapp/src/components/cardLimitNotification.tsx b/webapp/src/components/cardLimitNotification.tsx index 0390983e1..84b6f087b 100644 --- a/webapp/src/components/cardLimitNotification.tsx +++ b/webapp/src/components/cardLimitNotification.tsx @@ -119,7 +119,7 @@ const CardLimitNotification = (props: Props) => { }, [me?.id]) const onClick = useCallback(() => { - (window as any).openPricingModal()('boards > card_limit_notification_upgrade_to_a_paid_plan_click') + (window as any).openPricingModal()({trackingLocation: 'boards > card_limit_notification_upgrade_to_a_paid_plan_click'}) TelemetryClient.trackEvent(TelemetryCategory, TelemetryActions.LimitCardLimitLinkOpen, {}) }, []) diff --git a/webapp/src/components/viewLImitDialog/viewLimitDialog.tsx b/webapp/src/components/viewLImitDialog/viewLimitDialog.tsx index 7a6e6a919..722ede4c4 100644 --- a/webapp/src/components/viewLImitDialog/viewLimitDialog.tsx +++ b/webapp/src/components/viewLImitDialog/viewLimitDialog.tsx @@ -80,7 +80,7 @@ export const ViewLimitModal = (props: Props): JSX.Element => { telemetryClient.trackEvent(TelemetryCategory, TelemetryActions.ViewLimitCTAPerformed, {board: board.id}) if (isAdmin) { - (window as any)?.openPricingModal()('boards > view_limit_dialog') + (window as any)?.openPricingModal()({trackingLocation: 'boards > view_limit_dialog'}) } else { await octoClient.notifyAdminUpgrade() props.showNotifyAdminSuccess() diff --git a/webapp/src/types/index.d.ts b/webapp/src/types/index.d.ts index c49d39a1a..b4c557486 100644 --- a/webapp/src/types/index.d.ts +++ b/webapp/src/types/index.d.ts @@ -1,5 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. + +type TelemetryProps = { + trackingLocation: string; +} export interface IAppWindow extends Window { baseURL?: string frontendBaseURL?: string @@ -8,7 +12,7 @@ export interface IAppWindow extends Window { msCrypto: Crypto openInNewBrowser?: ((href: string) => void) | null webkit?: {messageHandlers: {nativeApp?: {postMessage: (message: T) => void}}} - openPricingModal?: () => (callerInfo: string) => void + openPricingModal?: () => (telemetry: TelemetryProps) => void } // SuiteWindow documents all custom properties