Skip to content

Commit 5abc3f9

Browse files
authored
Add analytics event for when people change code and then hit run (#356)
1 parent 915eb51 commit 5abc3f9

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/views/ExamplesView.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,24 @@ class ExamplesView extends PureComponent<ExamplesViewProps, ExamplesViewState> {
7878

7979
handleRunCode = () => {
8080
if (this.editorRef.current) {
81-
sendEvent({
82-
category: 'Examples',
83-
action: 'Run Code',
84-
label: this.getPage(),
85-
});
86-
this.setState({
87-
// @ts-ignore
88-
exampleCode: this.editorRef.current.getValue(),
89-
});
81+
// @ts-ignore
82+
const newCode = this.editorRef.current.getValue();
83+
if (newCode === this.state.exampleCode) {
84+
sendEvent({
85+
category: 'Examples',
86+
action: 'Run Code',
87+
label: this.getPage(),
88+
});
89+
} else {
90+
sendEvent({
91+
category: 'Examples',
92+
action: 'Run Code - Code Changed',
93+
label: this.getPage(),
94+
});
95+
this.setState({
96+
exampleCode: newCode,
97+
});
98+
}
9099
}
91100
};
92101

0 commit comments

Comments
 (0)