Skip to content

Commit 3875464

Browse files
author
Erin Peach
authored
Merge pull request code-dot-org#26689 from code-dot-org/TTS-logging
Track how often TTS is played
2 parents 5e4caf1 + 260733e commit 3875464

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

apps/src/templates/instructions/InlineAudio.jsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, {PropTypes} from 'react';
44
import { connect } from 'react-redux';
55
import trackEvent from '../../util/trackEvent';
66
import color from '../../util/color';
7+
import firehoseClient from '@cdo/apps/lib/util/firehose';
78

89
// TODO (elijah): have these constants shared w/dashboard
910
const VOICES = {
@@ -88,7 +89,12 @@ class InlineAudio extends React.Component {
8889
textToSpeechEnabled: PropTypes.bool,
8990
src: PropTypes.string,
9091
message: PropTypes.string,
91-
style: PropTypes.object
92+
style: PropTypes.object,
93+
94+
// Provided by redux
95+
// To Log TTS usage
96+
puzzleNumber: PropTypes.number,
97+
userId: PropTypes.number
9298
};
9399

94100
state = {
@@ -169,6 +175,19 @@ class InlineAudio extends React.Component {
169175
playAudio() {
170176
this.getAudioElement().play();
171177
this.setState({ playing: true });
178+
firehoseClient.putRecord(
179+
{
180+
study: 'tts-play',
181+
study_group: 'v1',
182+
event: 'play',
183+
data_string: this.props.src,
184+
data_json: JSON.stringify({
185+
userId: this.props.userId,
186+
puzzleNumber: this.props.puzzleNumber,
187+
src: this.props.src
188+
}),
189+
}
190+
);
172191
}
173192

174193
pauseAudio() {
@@ -221,5 +240,7 @@ export default connect(function propsFromStore(state) {
221240
assetUrl: state.pageConstants.assetUrl,
222241
textToSpeechEnabled: state.pageConstants.textToSpeechEnabled || state.pageConstants.isK1,
223242
locale: state.pageConstants.locale,
243+
userId: state.pageConstants.userId,
244+
puzzleNumber: state.pageConstants.puzzleNumber
224245
};
225246
})(StatelessInlineAudio);

0 commit comments

Comments
 (0)