@@ -5,7 +5,7 @@ import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
5
5
import { connect } from 'react-redux' ;
6
6
import translate from 'core/i18n/translate' ;
7
7
8
- import { sanitizeHTML } from 'core/utils' ;
8
+ import { getAction , sanitizeHTML } from 'core/utils' ;
9
9
import config from 'config' ;
10
10
import themeAction , { getThemeData } from 'disco/themePreview' ;
11
11
import tracking from 'core/tracking' ;
@@ -37,6 +37,7 @@ import {
37
37
validInstallStates ,
38
38
} from 'core/constants' ;
39
39
import {
40
+ CLICK_CATEGORY ,
40
41
CLOSE_INFO ,
41
42
INSTALL_CATEGORY ,
42
43
SET_ENABLE_NOT_AVAILABLE ,
@@ -69,12 +70,14 @@ export class Addon extends React.Component {
69
70
textcolor : PropTypes . string ,
70
71
themeAction : PropTypes . func ,
71
72
type : PropTypes . oneOf ( validAddonTypes ) . isRequired ,
73
+ _tracking : PropTypes . object ,
72
74
}
73
75
74
76
static defaultProps = {
75
77
// Defaults themeAction to the imported func.
76
78
themeAction,
77
79
needsRestart : false ,
80
+ _tracking : tracking ,
78
81
}
79
82
80
83
componentDidMount ( ) {
@@ -90,6 +93,7 @@ export class Addon extends React.Component {
90
93
return JSON . stringify ( getThemeData ( this . props ) ) ;
91
94
}
92
95
96
+
93
97
getError ( ) {
94
98
const { error, i18n, status } = this . props ;
95
99
return status === ERROR ? ( < div className = "notification error" key = "error-overlay" >
@@ -177,6 +181,18 @@ export class Addon extends React.Component {
177
181
this . setCurrentStatus ( ) ;
178
182
}
179
183
184
+ clickHeadingLink = ( e ) => {
185
+ const { type, name, _tracking } = this . props ;
186
+
187
+ if ( e . target . nodeName . toLowerCase ( ) === 'a' ) {
188
+ _tracking . sendEvent ( {
189
+ action : getAction ( type ) ,
190
+ category : CLICK_CATEGORY ,
191
+ label : name ,
192
+ } ) ;
193
+ }
194
+ }
195
+
180
196
clickInstallTheme = ( e ) => {
181
197
const { guid, installTheme, name, status, type } = this . props ;
182
198
e . preventDefault ( ) ;
@@ -220,6 +236,7 @@ export class Addon extends React.Component {
220
236
</ ReactCSSTransitionGroup >
221
237
< div className = "copy" >
222
238
< h2
239
+ onClick = { this . clickHeadingLink }
223
240
ref = "heading"
224
241
className = "heading"
225
242
dangerouslySetInnerHTML = { sanitizeHTML ( heading , [ 'a' , 'span' ] ) } />
@@ -376,11 +393,8 @@ export function mapDispatchToProps(dispatch, { _tracking = tracking,
376
393
} ,
377
394
378
395
uninstall ( { guid, name, type } ) {
379
- const action = {
380
- [ EXTENSION_TYPE ] : 'addon' ,
381
- [ THEME_TYPE ] : 'theme' ,
382
- } [ type ] || 'invalid' ;
383
396
dispatch ( { type : INSTALL_STATE , payload : { guid, status : UNINSTALLING } } ) ;
397
+ const action = getAction ( type ) ;
384
398
return _addonManager . uninstall ( guid )
385
399
. then ( ( ) => {
386
400
_tracking . sendEvent ( {
0 commit comments