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