File tree 7 files changed +73
-8
lines changed
components/data/purchases/edit-card-details
cancel-private-registration
payment/edit-payment-method
7 files changed +73
-8
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ const EditCardDetailsData = React.createClass( {
35
35
sites : React . PropTypes . object . isRequired
36
36
} ,
37
37
38
+ getDefaultProps ( ) {
39
+ return {
40
+ trackingSlug : 'edit_card_details'
41
+ } ;
42
+ } ,
43
+
38
44
mixins : [ observe ( 'sites' ) ] ,
39
45
40
46
componentWillMount ( ) {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import Card from 'components/card';
13
13
import Main from 'components/main' ;
14
14
import HeaderCake from 'components/header-cake' ;
15
15
import paths from '../paths' ;
16
+ import purchasesMixin from '../purchases-mixin' ;
16
17
import { isRefundable } from 'lib/purchases' ;
17
18
import { cancelPrivateRegistration } from 'lib/upgrades/actions' ;
18
19
import SimpleNotice from 'notices/simple-notice' ;
@@ -24,12 +25,14 @@ const CancelPrivateRegistration = React.createClass( {
24
25
} ;
25
26
} ,
26
27
27
- goToManagePurchase ( ) {
28
- const { domain , id } = this . props . selectedPurchase . data ;
29
-
30
- page ( paths . managePurchase ( domain , id ) ) ;
28
+ getDefaultProps ( ) {
29
+ return {
30
+ trackingSlug : 'cancel_private_registration'
31
+ } ;
31
32
} ,
32
33
34
+ mixins : [ purchasesMixin ] ,
35
+
33
36
cancel ( ) {
34
37
const { domain, id } = this . props . selectedPurchase . data ;
35
38
@@ -44,10 +47,6 @@ const CancelPrivateRegistration = React.createClass( {
44
47
} ) ;
45
48
} ,
46
49
47
- isDataLoading ( ) {
48
- return ( ! this . props . selectedSite || ! this . props . selectedPurchase . hasLoadedFromServer ) ;
49
- } ,
50
-
51
50
renderDescriptionText ( ) {
52
51
const purchase = this . props . selectedPurchase . data ;
53
52
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ const CancelPurchase = React.createClass( {
25
25
selectedSite : React . PropTypes . object
26
26
} ,
27
27
28
+ getDefaultProps ( ) {
29
+ return {
30
+ trackingSlug : 'cancel'
31
+ } ;
32
+ } ,
33
+
28
34
mixins : [ purchasesMixin ] ,
29
35
30
36
componentDidMount ( ) {
Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ const ConfirmCancelPurchase = React.createClass( {
22
22
selectedSite : React . PropTypes . object
23
23
} ,
24
24
25
+ getDefaultProps ( ) {
26
+ return {
27
+ trackingSlug : 'confirm_cancel'
28
+ } ;
29
+ } ,
30
+
25
31
mixins : [ purchasesMixin ] ,
26
32
27
33
componentDidMount ( ) {
Original file line number Diff line number Diff line change @@ -54,6 +54,12 @@ const ManagePurchase = React.createClass( {
54
54
destinationType : React . PropTypes . string
55
55
} ,
56
56
57
+ getDefaultProps ( ) {
58
+ return {
59
+ trackingSlug : 'manage'
60
+ } ;
61
+ } ,
62
+
57
63
mixins : [ purchasesMixin ] ,
58
64
59
65
isDataFetchingAfterRenewal ( ) {
Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ const EditPaymentMethod = React.createClass( {
19
19
selectedSite : React . PropTypes . object . isRequired
20
20
} ,
21
21
22
+ getDefaultProps ( ) {
23
+ return {
24
+ trackingSlug : 'edit_payment_method'
25
+ } ;
26
+ } ,
27
+
22
28
mixins : [ purchasesMixin ] ,
23
29
24
30
render ( ) {
Original file line number Diff line number Diff line change @@ -6,9 +6,45 @@ import page from 'page';
6
6
/**
7
7
* Internal Dependencies
8
8
*/
9
+ import analytics from 'analytics' ;
9
10
import paths from './paths' ;
10
11
11
12
export default {
13
+ componentWillMount ( ) {
14
+ if ( this . isDataLoading ( ) ) {
15
+ return ;
16
+ }
17
+
18
+ const purchase = this . getPurchase ( ) ;
19
+ this . recordPageView ( purchase ) ;
20
+ } ,
21
+
22
+ componentWillReceiveProps ( nextProps ) {
23
+ // Return if the purchases haven't loaded yet
24
+ if ( ! nextProps . selectedPurchase . hasLoadedFromServer ) {
25
+ return ;
26
+ }
27
+
28
+ // Return if the purchases have already been loaded into the props
29
+ if ( this . props . selectedPurchase . data && nextProps . selectedPurchase . data . id === this . props . selectedPurchase . data . id ) {
30
+ return ;
31
+ }
32
+
33
+ // We should only reach this part of the code whenever list of purchases changes
34
+ // which will only be once per session
35
+ const purchase = nextProps . selectedPurchase . data ;
36
+ this . recordPageView ( purchase ) ;
37
+ } ,
38
+
39
+ recordPageView ( purchase ) {
40
+ if ( this . props . trackingSlug ) {
41
+ analytics . tracks . recordEvent (
42
+ `calypso_${ this . props . trackingSlug } _purchase_view` ,
43
+ { product_slug : purchase . productSlug }
44
+ ) ;
45
+ }
46
+ } ,
47
+
12
48
getPurchase ( ) {
13
49
return this . props . selectedPurchase . data ;
14
50
} ,
You can’t perform that action at this time.
0 commit comments