Skip to content

Commit

Permalink
Added log for #6158 (#6955)
Browse files Browse the repository at this point in the history
  • Loading branch information
bansalnitish authored and aks681 committed Jun 18, 2019
1 parent a456e0d commit 450426c
Showing 1 changed file with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ oppia.factory('StatsReportingService', [
var explorationStarted = false;
var explorationActuallyStarted = false;
var explorationIsComplete = false;
var currentStateName = null;
var nextExpId = null;
var previousStateName = null;
var nextStateName = null;

var _editorPreviewMode = ContextService.isInExplorationEditorPage();
var _questionPlayerMode = ContextService.isInQuestionPlayerMode();
Expand Down Expand Up @@ -83,10 +87,29 @@ oppia.factory('StatsReportingService', [
};

var getFullStatsUrl = function(urlIdentifier) {
return UrlInterpolationService.interpolateUrl(
STATS_REPORTING_URLS[urlIdentifier], {
exploration_id: explorationId
});
try {
return UrlInterpolationService.interpolateUrl(
STATS_REPORTING_URLS[urlIdentifier], {
exploration_id: explorationId
});
} catch (e) {
var additionalInfo = ('\nUndefined exploration id error debug logs:' +
'\nThe event being recorded: ' + urlIdentifier +
'\nExploration ID: ' + ContextService.getExplorationId()
);
if (currentStateName) {
additionalInfo += ('\nCurrent State name: ' + currentStateName);
}
if (nextExpId) {
additionalInfo += ('\nRefresher exp id: ' + nextExpId);
}
if (previousStateName && nextStateName) {
additionalInfo += ('\nOld State name: ' + previousStateName +
'\nNew State name: ' + nextStateName);
}
e.message += additionalInfo;
throw e;
}
};

if (!_editorPreviewMode && !_questionPlayerMode ) {
Expand Down Expand Up @@ -134,6 +157,7 @@ oppia.factory('StatsReportingService', [

postStatsToBackend();

currentStateName = stateName;
$http.post(getFullStatsUrl('EXPLORATION_STARTED'), {
params: params,
session_id: sessionId,
Expand Down Expand Up @@ -166,6 +190,7 @@ oppia.factory('StatsReportingService', [
return;
}
aggregatedStats.num_actual_starts += 1;
currentStateName = stateName;
$http.post(getFullStatsUrl('EXPLORATION_ACTUALLY_STARTED'), {
exploration_version: explorationVersion,
state_name: stateName,
Expand All @@ -181,7 +206,7 @@ oppia.factory('StatsReportingService', [
}
aggregatedStats.state_stats_mapping[
stateName].num_times_solution_viewed += 1;

currentStateName = stateName;
$http.post(getFullStatsUrl('SOLUTION_HIT'), {
exploration_version: explorationVersion,
state_name: stateName,
Expand All @@ -190,6 +215,8 @@ oppia.factory('StatsReportingService', [
});
},
recordLeaveForRefresherExp: function(stateName, refresherExpId) {
currentStateName = stateName;
nextExpId = refresherExpId;
$http.post(getFullStatsUrl('LEAVE_FOR_REFRESHER_EXP'), {
exploration_version: explorationVersion,
refresher_exp_id: refresherExpId,
Expand All @@ -210,6 +237,8 @@ oppia.factory('StatsReportingService', [
newStateName].first_hit_count += 1;
}

previousStateName = oldStateName;
nextStateName = newStateName;
$http.post(getFullStatsUrl('STATE_HIT'), {
// This is the time spent since the last submission.
client_time_spent_in_secs: stateStopwatch.getTimeInSecs(),
Expand Down Expand Up @@ -242,6 +271,7 @@ oppia.factory('StatsReportingService', [
}
aggregatedStats.state_stats_mapping[stateName].num_completions += 1;

currentStateName = stateName;
$http.post(getFullStatsUrl('STATE_COMPLETED'), {
exp_version: explorationVersion,
state_name: stateName,
Expand All @@ -251,6 +281,7 @@ oppia.factory('StatsReportingService', [
},
recordExplorationCompleted: function(stateName, params) {
aggregatedStats.num_completions += 1;
currentStateName = stateName;
$http.post(getFullStatsUrl('EXPLORATION_COMPLETED'), {
client_time_spent_in_secs: stateStopwatch.getTimeInSecs(),
collection_id: optionalCollectionId,
Expand Down Expand Up @@ -285,6 +316,7 @@ oppia.factory('StatsReportingService', [
aggregatedStats.state_stats_mapping[
stateName].useful_feedback_count += 1;
}
currentStateName = stateName;
$http.post(getFullStatsUrl('ANSWER_SUBMITTED'), {
answer: answer,
params: params,
Expand All @@ -298,6 +330,7 @@ oppia.factory('StatsReportingService', [
});
},
recordMaybeLeaveEvent: function(stateName, params) {
currentStateName = stateName;
$http.post(getFullStatsUrl('EXPLORATION_MAYBE_LEFT'), {
client_time_spent_in_secs: stateStopwatch.getTimeInSecs(),
collection_id: optionalCollectionId,
Expand Down

0 comments on commit 450426c

Please sign in to comment.