@@ -10,7 +10,7 @@ define(['underscore'], function (_underscore) {
10
10
var originalTarget = target . trigger ,
11
11
action = '' ,
12
12
event ,
13
- eventData ,
13
+ eventAttributes ,
14
14
hasVisibilityChanged ,
15
15
isAdminAnalyticsEnabled ,
16
16
setupEventAttributes ;
@@ -38,14 +38,14 @@ define(['underscore'], function (_underscore) {
38
38
39
39
setupEventAttributes ( name , args ) ;
40
40
41
- if ( action !== '' && ! _underscore . isEmpty ( eventData ) ) {
41
+ if ( action !== '' && ! _underscore . isEmpty ( eventAttributes ) ) {
42
42
event = {
43
- element : eventData . label ,
44
- type : eventData . name ,
43
+ element : eventAttributes . label ,
44
+ type : eventAttributes . name ,
45
45
action : action ,
46
46
widget : {
47
- name : eventData . form ,
48
- type : eventData . menu_section
47
+ name : eventAttributes . form ,
48
+ type : eventAttributes . menu_section
49
49
} ,
50
50
feature : 'page-builder-tracker'
51
51
} ;
@@ -57,12 +57,18 @@ define(['underscore'], function (_underscore) {
57
57
}
58
58
} ;
59
59
60
+ /**
61
+ * Sets up event attributes depending on name and args
62
+ *
63
+ * @param name
64
+ * @param args
65
+ */
60
66
setupEventAttributes = function ( name , args ) {
61
67
var arrayName = name . split ( ':' ) ,
62
68
arrayNameObject ;
63
69
64
70
action = '' ;
65
- eventData = { } ;
71
+ eventAttributes = { } ;
66
72
67
73
if ( _underscore . isUndefined ( args ) ) {
68
74
return ;
@@ -71,14 +77,14 @@ define(['underscore'], function (_underscore) {
71
77
if ( arrayName . length === 3 ) {
72
78
arrayNameObject = arrayName [ 1 ] ;
73
79
action = hasVisibilityChanged ( args [ arrayNameObject ] ) ? 'hide/show' : '' ;
74
- eventData =
80
+ eventAttributes =
75
81
! _underscore . isUndefined ( args [ arrayNameObject ] ) &&
76
82
! _underscore . isUndefined ( args [ arrayNameObject ] . config ) ?
77
83
args [ arrayNameObject ] . config : { } ;
78
84
} else if ( arrayName . length === 2 ) {
79
85
if ( name . indexOf ( 'duplicateAfter' ) !== - 1 ) {
80
86
action = 'duplicate' ;
81
- eventData =
87
+ eventAttributes =
82
88
! _underscore . isUndefined ( args . originalContentType ) &&
83
89
! _underscore . isUndefined ( args . originalContentType . config ) ?
84
90
args . originalContentType . config : { } ;
@@ -90,13 +96,19 @@ define(['underscore'], function (_underscore) {
90
96
91
97
if ( name . indexOf ( 'renderAfter' ) !== - 1 ) action = 'edit' ;
92
98
93
- eventData =
99
+ eventAttributes =
94
100
! _underscore . isUndefined ( args . contentType ) &&
95
101
! _underscore . isUndefined ( args . contentType . config ) ?
96
102
args . contentType . config : { } ;
97
103
}
98
104
} ;
99
105
106
+ /**
107
+ * Checks if visibility has changed from previousState to state
108
+ *
109
+ * @param objectWrapper
110
+ * @return {boolean } Returns true when the display attribute on previousState is different from state
111
+ */
100
112
hasVisibilityChanged = function ( objectWrapper ) {
101
113
var state ,
102
114
previousState ;
0 commit comments