| OLD | NEW |
| 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. | 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. |
| 2 // limitations under the License. | 2 // limitations under the License. |
| 3 // See the License for the specific language governing permissions and | 3 // See the License for the specific language governing permissions and |
| 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 5 // distributed under the License is distributed on an "AS-IS" BASIS, | 5 // distributed under the License is distributed on an "AS-IS" BASIS, |
| 6 // Unless required by applicable law or agreed to in writing, software | 6 // Unless required by applicable law or agreed to in writing, software |
| 7 // | 7 // |
| 8 // http://www.apache.org/licenses/LICENSE-2.0 | 8 // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 // | 9 // |
| 10 // You may obtain a copy of the License at | 10 // You may obtain a copy of the License at |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 * @param {string} source . | 224 * @param {string} source . |
| 225 * @param {string} target . | 225 * @param {string} target . |
| 226 * @param {number} targetIndex The target index. | 226 * @param {number} targetIndex The target index. |
| 227 * @param {!TriggerType} triggerType The trigger type. | 227 * @param {!TriggerType} triggerType The trigger type. |
| 228 */ | 228 */ |
| 229 Statistics.prototype.recordCommit = function( | 229 Statistics.prototype.recordCommit = function( |
| 230 source, target, targetIndex, triggerType) { | 230 source, target, targetIndex, triggerType) { |
| 231 if (!this.inputMethodId_) { | 231 if (!this.inputMethodId_) { |
| 232 return; | 232 return; |
| 233 } | 233 } |
| 234 var CommitTypes = Statistics.CommitTypes; |
| 235 var commitType = -1; |
| 234 var length = target.length; | 236 var length = target.length; |
| 235 // Increment to include space. | 237 |
| 236 if (triggerType == TriggerType.RESET) { | 238 if (triggerType == TriggerType.REVERT) { |
| 239 length -= this.lastCommitLength_; |
| 240 commitType = CommitTypes.REVERT; |
| 241 } else if (triggerType == TriggerType.VOICE) { |
| 242 commitType = CommitTypes.VOICE; |
| 243 } else if (triggerType == TriggerType.RESET) { |
| 244 // Increment to include space. |
| 237 length++; | 245 length++; |
| 238 } else if (triggerType == TriggerType.REVERT) { | 246 } else if (triggerType == TriggerType.CANDIDATE || |
| 239 length -= this.lastCommitLength_; | 247 triggerType == TriggerType.SPACE) { |
| 248 if (!source && target) { |
| 249 commitType = CommitTypes.PREDICTION; |
| 250 } else if (targetIndex == 0 && source == target) { |
| 251 commitType = CommitTypes.X_X0; |
| 252 } else if (targetIndex == 0 && source != target) { |
| 253 commitType = CommitTypes.X_Y0; |
| 254 } else if (targetIndex == 1 && source == target) { |
| 255 commitType = CommitTypes.X_X1; |
| 256 } else if (targetIndex == 1 && source != target) { |
| 257 commitType = CommitTypes.X_Y1; |
| 258 } else if (targetIndex > 1 && source == target) { |
| 259 commitType = CommitTypes.X_X2; |
| 260 } else if (targetIndex > 1 && source != target) { |
| 261 commitType = CommitTypes.X_Y2; |
| 262 } |
| 240 } | 263 } |
| 241 this.lastCommitLength_ = length; | 264 this.lastCommitLength_ = length; |
| 242 this.charactersCommitted_ += length; | 265 this.charactersCommitted_ += length; |
| 243 | 266 |
| 244 var CommitTypes = Statistics.CommitTypes; | |
| 245 var commitType = -1; | |
| 246 if (targetIndex == 0 && source == target) { | |
| 247 commitType = CommitTypes.X_X0; | |
| 248 } else if (targetIndex == 0 && source != target) { | |
| 249 commitType = CommitTypes.X_Y0; | |
| 250 } else if (targetIndex == 1 && source == target) { | |
| 251 commitType = CommitTypes.X_X1; | |
| 252 } else if (targetIndex == 1 && source != target) { | |
| 253 commitType = CommitTypes.X_Y1; | |
| 254 } else if (targetIndex > 1 && source == target) { | |
| 255 commitType = CommitTypes.X_X2; | |
| 256 } else if (targetIndex > 1 && source != target) { | |
| 257 commitType = CommitTypes.X_Y2; | |
| 258 } else if (!source && source != target) { | |
| 259 commitType = CommitTypes.PREDICTION; | |
| 260 } else if (triggerType == TriggerType.REVERT) { | |
| 261 commitType = CommitTypes.REVERT; | |
| 262 } else if (triggerType == TriggerType.VOICE) { | |
| 263 commitType = CommitTypes.VOICE; | |
| 264 } | |
| 265 if (commitType < 0) { | 267 if (commitType < 0) { |
| 266 return; | 268 return; |
| 267 } | 269 } |
| 268 | 270 |
| 269 // For latin transliteration, record the logs under the name with 'Pk' which | 271 // For latin transliteration, record the logs under the name with 'Pk' which |
| 270 // means Physical Keyboard. | 272 // means Physical Keyboard. |
| 271 var name = this.isPhysicalKeyboard_ ? | 273 var name = this.isPhysicalKeyboard_ ? |
| 272 'InputMethod.PkCommit.' : 'InputMethod.Commit.'; | 274 'InputMethod.PkCommit.' : 'InputMethod.Commit.'; |
| 273 var type = this.isPhysicalKeyboard_ ? 'Type' : 'Type2'; | 275 var type = this.isPhysicalKeyboard_ ? 'Type' : 'Type2'; |
| 274 | 276 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 Statistics.prototype.recordBackspace = function() { | 426 Statistics.prototype.recordBackspace = function() { |
| 425 // Ignore multiple backspaces typed in succession. | 427 // Ignore multiple backspaces typed in succession. |
| 426 if (this.charactersBetweenBackspaces_ > 0) { | 428 if (this.charactersBetweenBackspaces_ > 0) { |
| 427 this.recordValue( | 429 this.recordValue( |
| 428 'InputMethod.VirtualKeyboard.CharactersBetweenBackspaces', | 430 'InputMethod.VirtualKeyboard.CharactersBetweenBackspaces', |
| 429 this.charactersBetweenBackspaces_, 4096, 50); | 431 this.charactersBetweenBackspaces_, 4096, 50); |
| 430 } | 432 } |
| 431 this.charactersBetweenBackspaces_ = 0; | 433 this.charactersBetweenBackspaces_ = 0; |
| 432 }; | 434 }; |
| 433 }); // goog.scope | 435 }); // goog.scope |
| OLD | NEW |