Skip to content

Commit

Permalink
[MM-28062] Add telemetry for in-app purchase flow (mattermost#6760)
Browse files Browse the repository at this point in the history
* Add telemetry for in-app purchase flow

* Fix spelling mistake in telemetry doc

* Fixes

* Fix linter
  • Loading branch information
nickmisasi committed Oct 13, 2020
1 parent 2d69be5 commit 8618aeb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
10 changes: 10 additions & 0 deletions components/purchase_modal/process_payment_setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import React from 'react';
import {Stripe} from '@stripe/stripe-js';

import {BillingDetails} from 'types/cloud/sku';
import {pageVisited} from 'actions/telemetry_actions';
import {TELEMETRY_CATEGORIES} from 'utils/constants';

import successSvg from 'images/cloud/payment_success.svg';
import failedSvg from 'images/cloud/payment_fail.svg';
Expand Down Expand Up @@ -138,6 +140,10 @@ export default class ProcessPaymentSetup extends React.PureComponent<Props, Stat
/>
);
case ProcessState.SUCCESS:
pageVisited(
TELEMETRY_CATEGORIES.CLOUD_PURCHASING,
'pageview_payment_success',
);
return (
<IconMessage
title={t('admin.billing.subscription.upgradedSuccess')}
Expand All @@ -151,6 +157,10 @@ export default class ProcessPaymentSetup extends React.PureComponent<Props, Stat
/>
);
case ProcessState.FAILED:
pageVisited(
TELEMETRY_CATEGORIES.CLOUD_PURCHASING,
'pageview_payment_failed',
);
return (
<IconMessage
title={t('admin.billing.subscription.paymentVerificationFailed')}
Expand Down
24 changes: 22 additions & 2 deletions components/purchase_modal/purchase_modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import wavesBackground from 'images/cloud/waves.svg';
import blueDotes from 'images/cloud/blue.svg';
import LowerBlueDots from 'images/cloud/blue-lower.svg';
import cloudLogo from 'images/cloud/mattermost-cloud.svg';
import {trackEvent, pageVisited} from 'actions/telemetry_actions';
import {TELEMETRY_CATEGORIES, CloudLinks} from 'utils/constants';

import {STRIPE_CSS_SRC, STRIPE_PUBLIC_KEY} from 'components/payment_form/stripe';
import RootPortal from 'components/root_portal';
import FullScreenModal from 'components/widgets/modals/full_screen_modal';
import {areBillingDetailsValid, BillingDetails} from 'types/cloud/sku';
import {getNextBillingDate} from 'utils/utils';
import {CloudLinks} from 'utils/constants';

import PaymentForm from '../payment_form/payment_form';

Expand Down Expand Up @@ -79,6 +80,7 @@ export default class PurchaseModal extends React.PureComponent<Props, State> {
}

componentDidMount() {
pageVisited(TELEMETRY_CATEGORIES.CLOUD_PURCHASING, 'pageview_purchase');
this.props.actions.getCloudProducts();

// this.fetchProductPrice();
Expand Down Expand Up @@ -117,6 +119,12 @@ export default class PurchaseModal extends React.PureComponent<Props, State> {
</div>
<a
className='footer-text'
onClick={() =>
trackEvent(
TELEMETRY_CATEGORIES.CLOUD_PURCHASING,
'click_contact_support',
)
}
href={this.props.contactSupportLink}
rel='noopener noreferrer'
target='_new'
Expand Down Expand Up @@ -187,6 +195,12 @@ export default class PurchaseModal extends React.PureComponent<Props, State> {
<div className='footer-text'>{'Need other billing options?'}</div>
<a
className='footer-text'
onClick={() => {
trackEvent(
TELEMETRY_CATEGORIES.CLOUD_PURCHASING,
'click_contact_sales',
);
}}
href={this.props.contactSalesLink}
target='_new'
rel='noopener noreferrer'
Expand Down Expand Up @@ -216,7 +230,13 @@ export default class PurchaseModal extends React.PureComponent<Props, State> {
<RootPortal>
<FullScreenModal
show={Boolean(this.props.show)}
onClose={this.props.actions.closeModal}
onClose={() => {
trackEvent(
TELEMETRY_CATEGORIES.CLOUD_PURCHASING,
'click_close_purchasing_screen',
);
this.props.actions.closeModal();
}}
ref={this.modal}
ariaLabelledBy='purchase_modal_title'
>
Expand Down
21 changes: 19 additions & 2 deletions components/user_limit_modal/user_limit_modal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import React from 'react';
import React, {useEffect} from 'react';
import {Modal, Button} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';

import {ModalIdentifiers} from 'utils/constants';
import {trackEvent, pageVisited} from 'actions/telemetry_actions';

import {ModalIdentifiers, TELEMETRY_CATEGORIES} from 'utils/constants';
import PurchaseModal from 'components/purchase_modal';

import UpgradeUserLimitModalSvg from './user_limit_upgrade_svg';
Expand All @@ -20,7 +22,18 @@ type Props = {
};

export default function UserLimitModal(props: Props) {
useEffect(() => {
pageVisited(
TELEMETRY_CATEGORIES.CLOUD_PURCHASING,
'pageview_modal_user_limit_reached',
);
}, []);

const onSubmit = () => {
trackEvent(
TELEMETRY_CATEGORIES.CLOUD_PURCHASING,
'click_modal_user_limit_upgrade',
);
props.actions.closeModal();
props.actions.openModal({
modalId: ModalIdentifiers.CLOUD_PURCHASE,
Expand All @@ -29,6 +42,10 @@ export default function UserLimitModal(props: Props) {
};

const close = () => {
trackEvent(
TELEMETRY_CATEGORIES.CLOUD_PURCHASING,
'click_modal_user_limit_not_now',
);
props.actions.closeModal();
};

Expand Down
4 changes: 4 additions & 0 deletions utils/constants.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ export const CloudBanners = {
HIDE: 'hide',
};

export const TELEMETRY_CATEGORIES = {
CLOUD_PURCHASING: 'cloud_purchasing',
};

export const PostTypes = {
JOIN_LEAVE: 'system_join_leave',
JOIN_CHANNEL: 'system_join_channel',
Expand Down

0 comments on commit 8618aeb

Please sign in to comment.