Skip to content

Commit

Permalink
refactor: moving speedcurve utils up to the top
Browse files Browse the repository at this point in the history
Using them in index.jsx instead of the old “App” file since that’s the first moment we’re about to start painting.  Also updating references in OrderSummary and PaymentForm.
  • Loading branch information
davidjoy committed Oct 11, 2019
1 parent 368f785 commit 236637f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import Footer, { messages as footerMessages } from '@edx/frontend-component-foot
import appMessages from './i18n';
import { PaymentPage, EcommerceRedirect, responseInterceptor } from './payment';
import configureStore from './store';
import markPerformanceIfAble from './speedcurve';
import './index.scss';

App.subscribe(APP_READY, () => {
markPerformanceIfAble('Payment app began painting');
ReactDOM.render(
<AppProvider store={configureStore()}>
<Header />
Expand Down
4 changes: 2 additions & 2 deletions src/payment/cart/OrderSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@edx/frontend-i18n';

import { utils } from '../../common';
import markPerformanceIfAble from '../../speedcurve';

class OrderSummary extends React.Component {
componentDidMount() {
utils.markPerformanceIfAble('Order Summary component rendered');
markPerformanceIfAble('Order Summary component rendered');
}

render() {
Expand Down
4 changes: 2 additions & 2 deletions src/payment/checkout/payment-form/PaymentForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CardDetails from './CardDetails';
import CardHolderInformation from './CardHolderInformation';
import getStates from './utils/countryStatesMap';
import messages from './PaymentForm.messages';
import { utils } from '../../../common';
import markPerformanceIfAble from '../../../speedcurve';

const CardValidator = require('../card-validator');

Expand All @@ -25,7 +25,7 @@ export class PaymentFormComponent extends React.Component {
&& !this.props.loading
) {
// Send a SpeedCurve event when we stop loading for the first time
utils.markPerformanceIfAble('Payment form finished loading');
markPerformanceIfAble('Payment form finished loading');
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/payment/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,3 @@ export function generateAndSubmitForm(url, params = {}) {
form.submit();
}

// Used for SpeedCurve performance tracking
export function markPerformanceIfAble(markName) {
if (performance.mark) {
performance.mark(markName);
}
}
6 changes: 6 additions & 0 deletions src/speedcurve.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Used for SpeedCurve performance tracking
export default function markPerformanceIfAble(markName) {
if (performance.mark) {
performance.mark(markName);
}
}

0 comments on commit 236637f

Please sign in to comment.