Skip to content

Commit 4078645

Browse files
authored
Merge pull request #1002 from BoostIO/add-ama-event-for-snippet-lang
Add ama event for snippet lang
2 parents d249967 + 955ade0 commit 4078645

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

browser/main/Detail/SnippetNoteDetail.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,16 @@ class SnippetNoteDetail extends React.Component {
266266
}
267267

268268
renameSnippetByIndex (index, name) {
269-
let snippets = this.state.note.snippets.slice()
269+
const snippets = this.state.note.snippets.slice()
270270
snippets[index].name = name
271-
let syntax = CodeMirror.findModeByFileName(name.trim())
272-
let mode = syntax != null ? syntax.name : null
273-
if (mode != null) snippets[index].mode = mode
271+
const syntax = CodeMirror.findModeByFileName(name.trim())
272+
const mode = syntax != null ? syntax.name : null
273+
if (mode != null) {
274+
snippets[index].mode = mode
275+
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('SNIPPET_LANG', {
276+
name: mode
277+
})
278+
}
274279
this.setState({note: Object.assign(this.state.note, {snippets: snippets})})
275280

276281
this.setState({
@@ -291,6 +296,10 @@ class SnippetNoteDetail extends React.Component {
291296
}, () => {
292297
this.save()
293298
})
299+
300+
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('SELECT_LANG', {
301+
name
302+
})
294303
}
295304
}
296305

browser/main/lib/AwsMobileAnalyticsConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ function initAwsMobileAnalytics () {
4444
})
4545
}
4646

47-
function recordDynamicCustomEvent (type) {
47+
function recordDynamicCustomEvent (type, options = {}) {
4848
if (process.env.NODE_ENV !== 'production' || !ConfigManager.default.get().amaEnabled) return
4949
try {
50-
mobileAnalyticsClient.recordEvent(type)
50+
mobileAnalyticsClient.recordEvent(type, options)
5151
} catch (analyticsError) {
5252
if (analyticsError instanceof ReferenceError) {
5353
console.log(analyticsError.name + ': ' + analyticsError.message)

0 commit comments

Comments
 (0)