@@ -35,14 +35,6 @@ export const trackPageVisit = (): void => {
35
35
}
36
36
} ;
37
37
38
- export const trackPageFetchException = ( ) : void => {
39
- if ( typeof window !== 'undefined' && typeof s != 'undefined' ) {
40
- s . linkTrackVars =
41
- 'prop39,prop41,prop50,prop61,prop62,eVar39,eVar41,eVar50,eVar61,eVar62,eVar69' ;
42
- s . tl ( true , 'o' , 'page fetch exception' ) ;
43
- }
44
- } ;
45
-
46
38
export const trackExternalLink = ( hrefTo : string ) : void => {
47
39
if ( typeof window !== 'undefined' && typeof s != 'undefined' ) {
48
40
s . linkTrackVars =
@@ -51,57 +43,6 @@ export const trackExternalLink = (hrefTo: string): void => {
51
43
}
52
44
} ;
53
45
54
- export const setSearchQuery = ( query : string ) : void => {
55
- if ( typeof window !== 'undefined' && typeof s != 'undefined' ) {
56
- s . eVar26 = query ;
57
- }
58
- } ;
59
-
60
- const triggerNoSearchResults = ( query : string ) : void => {
61
- const queryBackup : string = s . eVar26 ;
62
- const resultCountBackup : number = parseInt ( s . eVar27 , 10 ) ;
63
-
64
- s . eVar26 = query ;
65
- s . eVar27 = '0' ; // If it's the number 0, the variable won't be sent
66
- s . linkTrackVars =
67
- 'prop39,prop41,prop50,prop61,prop62,eVar26,eVar27,eVar39,eVar41,eVar50,eVar61,eVar62,eVar69,events' ;
68
- s . linkTrackEvents = 'event2' ;
69
- s . events = 'event2' ;
70
- s . tl ( true , 'o' , 'internal search' ) ;
71
-
72
- s . eVar26 = queryBackup ;
73
- s . eVar27 = resultCountBackup . toString ( ) ;
74
- } ;
75
-
76
- let noResultsTimeout : NodeJS . Timeout ;
77
- export const setSearchResultCount = ( resultCount : number ) : void => {
78
- if ( typeof window !== 'undefined' && typeof s != 'undefined' ) {
79
- s . eVar27 = resultCount . toString ( ) ;
80
- s . events = resultCount === 0 ? 'event1' : 'event2' ;
81
-
82
- if ( resultCount === 0 ) {
83
- if ( noResultsTimeout ) {
84
- clearTimeout ( noResultsTimeout ) ;
85
- }
86
- noResultsTimeout = setTimeout (
87
- triggerNoSearchResults . bind ( null , s . eVar26 ) ,
88
- 1000
89
- ) ;
90
- }
91
- }
92
- } ;
93
-
94
- export const trackSearchQuery = ( _input , _event , suggestion ) : void => {
95
- if ( typeof window !== 'undefined' && typeof s != 'undefined' ) {
96
- s . linkTrackVars =
97
- 'prop39,prop41,prop50,prop61,prop62,eVar26,eVar27,eVar39,eVar41,eVar50,eVar61,eVar62,eVar69,events' ;
98
- s . linkTrackEvents = 'event1' ;
99
- s . events = 'event1' ;
100
- s . tl ( true , 'o' , 'internal search' ) ;
101
- }
102
- window . location . assign ( suggestion . url ) ;
103
- } ;
104
-
105
46
export const trackFeedbackSubmission = ( feedback : boolean ) => {
106
47
const opt = {
107
48
event : {
@@ -110,11 +51,13 @@ export const trackFeedbackSubmission = (feedback: boolean) => {
110
51
}
111
52
} ;
112
53
113
- AWSMA . ready ( ( ) => {
114
- document . dispatchEvent (
115
- new CustomEvent ( AWSMA . TRIGGER_EVENT , { detail : opt } )
116
- ) ;
117
- } ) ;
54
+ if ( AWSMA ) {
55
+ AWSMA . ready ( ( ) => {
56
+ document . dispatchEvent (
57
+ new CustomEvent ( AWSMA . TRIGGER_EVENT , { detail : opt } )
58
+ ) ;
59
+ } ) ;
60
+ }
118
61
} ;
119
62
120
63
export const trackExpanderOpen = ( expanderId ) => {
@@ -125,11 +68,13 @@ export const trackExpanderOpen = (expanderId) => {
125
68
}
126
69
} ;
127
70
128
- AWSMA . ready ( ( ) => {
129
- document . dispatchEvent (
130
- new CustomEvent ( AWSMA . TRIGGER_EVENT , { detail : opt } )
131
- ) ;
132
- } ) ;
71
+ if ( AWSMA ) {
72
+ AWSMA . ready ( ( ) => {
73
+ document . dispatchEvent (
74
+ new CustomEvent ( AWSMA . TRIGGER_EVENT , { detail : opt } )
75
+ ) ;
76
+ } ) ;
77
+ }
133
78
} ;
134
79
135
80
export const trackCopyClicks = ( data ) => {
@@ -141,27 +86,13 @@ export const trackCopyClicks = (data) => {
141
86
data : data
142
87
} ;
143
88
144
- AWSMA . ready ( ( ) => {
145
- document . dispatchEvent (
146
- new CustomEvent ( AWSMA . TRIGGER_EVENT , { detail : opt } )
147
- ) ;
148
- } ) ;
149
- } ;
150
-
151
- // Track the click on the "Whats new" banner component
152
- export const trackWhatsNewBanner = ( ) => {
153
- const opt = {
154
- event : {
155
- type : 'click' ,
156
- name : 'WhatsNewBanner'
157
- }
158
- } ;
159
-
160
- AWSMA . ready ( ( ) => {
161
- document . dispatchEvent (
162
- new CustomEvent ( AWSMA . TRIGGER_EVENT , { detail : opt } )
163
- ) ;
164
- } ) ;
89
+ if ( AWSMA ) {
90
+ AWSMA . ready ( ( ) => {
91
+ document . dispatchEvent (
92
+ new CustomEvent ( AWSMA . TRIGGER_EVENT , { detail : opt } )
93
+ ) ;
94
+ } ) ;
95
+ }
165
96
} ;
166
97
167
98
// Track the click on the Version Switcher component
@@ -173,9 +104,11 @@ export const trackVersionChange = (viewOld: boolean) => {
173
104
}
174
105
} ;
175
106
176
- AWSMA . ready ( ( ) => {
177
- document . dispatchEvent (
178
- new CustomEvent ( AWSMA . TRIGGER_EVENT , { detail : opt } )
179
- ) ;
180
- } ) ;
107
+ if ( AWSMA ) {
108
+ AWSMA . ready ( ( ) => {
109
+ document . dispatchEvent (
110
+ new CustomEvent ( AWSMA . TRIGGER_EVENT , { detail : opt } )
111
+ ) ;
112
+ } ) ;
113
+ }
181
114
} ;
0 commit comments