MCPcopy Create free account
hub / github.com/codecombat/codecombat / onClickAnchor

Method onClickAnchor

app/views/HomeCNView.js:152–176  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

150 }
151
152 onClickAnchor (e) {
153 let anchor, anchorText, properties
154 if (!(anchor = e != null ? e.currentTarget : undefined)) { return }
155 // Track an event with action of the English version of the link text
156 let translationKey = $(anchor).attr('data-i18n')
157 if (translationKey == null) { translationKey = $(anchor).children('[data-i18n]').attr('data-i18n') }
158 if (translationKey) {
159 anchorText = $.i18n.t(translationKey, { lng: 'en-US' })
160 } else {
161 anchorText = anchor.text
162 }
163
164 if (__guard__($(e.target), x => x.hasClass('track-ab-result'))) {
165 properties = { trackABResult: true }
166 }
167
168 if (anchorText) {
169 return this.homePageEvent(`Link: ${anchorText}`, properties || {})
170 } else {
171 _.extend(properties || {}, {
172 clicked: __guard__(e != null ? e.currentTarget : undefined, x1 => x1.host) || 'unknown'
173 })
174 return this.homePageEvent('Link:', properties)
175 }
176 }
177
178 afterRender () {
179 if (me.isAnonymous()) {

Callers

nothing calls this directly

Calls 2

homePageEventMethod · 0.95
__guard__Function · 0.70

Tested by

no test coverage detected