Revert "Merge pull request #4545 from edx/renzo/bi-analytics-overhaul"

This reverts commit 252038c376, reversing
changes made to 7caf8c53b1.
This commit is contained in:
Julia Hansbrough
2014-07-29 17:41:46 +00:00
parent 4353e1e48f
commit 079808ee47
26 changed files with 58 additions and 244 deletions

View File

@@ -47,8 +47,6 @@ from course_modes.models import CourseMode
from ratelimitbackend import admin
import analytics
unenroll_done = Signal(providing_args=["course_enrollment"])
log = logging.getLogger(__name__)
AUDIT_LOG = logging.getLogger("audit")
@@ -708,7 +706,6 @@ class CourseEnrollment(models.Model):
if activation_changed or mode_changed:
self.save()
if activation_changed:
if self.is_active:
self.emit_event(EVENT_NAME_ENROLLMENT_ACTIVATED)
@@ -722,7 +719,7 @@ class CourseEnrollment(models.Model):
else:
unenroll_done.send(sender=None, course_enrollment=self)
self.emit_event(EVENT_NAME_ENROLLMENT_DEACTIVATED)
dog_stats_api.increment(
@@ -752,16 +749,6 @@ class CourseEnrollment(models.Model):
with tracker.get_tracker().context(event_name, context):
tracker.emit(event_name, data)
if settings.FEATURES.get('SEGMENT_IO_LMS') and settings.SEGMENT_IO_LMS_KEY:
analytics.track(self.user_id, event_name, {
'category': 'conversion',
'label': self.course_id.to_deprecated_string(),
'org': self.course_id.org,
'course': self.course_id.course,
'run': self.course_id.run,
'mode': self.mode,
})
except: # pylint: disable=bare-except
if event_name and self.course_id:
log.exception('Unable to emit event %s for user %s and course %s', event_name, self.user.username, self.course_id)
@@ -786,8 +773,6 @@ class CourseEnrollment(models.Model):
It is expected that this method is called from a method which has already
verified the user authentication and access.
Also emits relevant events for analytics purposes.
"""
enrollment = cls.get_or_create_enrollment(user, course_key)
enrollment.update_enrollment(is_active=True, mode=mode)

View File

@@ -300,8 +300,7 @@ class @Problem
Logger.log 'problem_check', @answers
# Segment.io
analytics.track "edx.bi.course.problem.checked",
category: "courseware"
analytics.track "Problem Checked",
problem_id: @id
answers: @answers

View File

@@ -128,8 +128,7 @@ class @Sequence
analytics.pageview @id
# navigation by clicking the tab directly
analytics.track "edx.bi.course.sequential.direct.clicked",
category: "courseware"
analytics.track "Accessed Sequential Directly",
sequence_id: @id
current_sequential: @position
target_sequential: new_position
@@ -168,10 +167,9 @@ class @Sequence
# navigation using the next or previous arrow button.
tracking_messages =
seq_prev: "edx.bi.course.sequential.previous.clicked"
seq_next: "edx.bi.course.sequential.next.clicked"
seq_prev: "Accessed Previous Sequential"
seq_next: "Accessed Next Sequential"
analytics.track tracking_messages[direction],
category: "courseware"
sequence_id: @id
current_sequential: @position
target_sequential: new_position

View File

@@ -16,26 +16,3 @@ describe('utility.rewriteStaticLinks', function () {
).toBe('<img src="http://www.mysite.org/static/foo.x"/>')
});
});
describe('utility.appendParameter', function() {
it('creates and populates query string with provided parameter', function() {
expect(appendParameter('/cambridge', 'season', 'fall')).toBe('/cambridge?season=fall')
});
it('appends provided parameter to existing query string parameters', function() {
expect(appendParameter('/cambridge?season=fall', 'color', 'red')).toBe('/cambridge?season=fall&color=red')
});
it('appends provided parameter to existing query string with a trailing ampersand', function() {
expect(appendParameter('/cambridge?season=fall&', 'color', 'red')).toBe('/cambridge?season=fall&color=red')
});
it('overwrites existing parameter with provided value', function() {
expect(appendParameter('/cambridge?season=fall', 'season', 'winter')).toBe('/cambridge?season=winter');
expect(appendParameter('/cambridge?season=fall&color=red', 'color', 'orange')).toBe('/cambridge?season=fall&color=orange');
});
});
describe('utility.parseQueryString', function() {
it('converts a non-empty query string into a key/value object', function() {
expect(JSON.stringify(parseQueryString('season=fall'))).toBe(JSON.stringify({season:'fall'}));
expect(JSON.stringify(parseQueryString('season=fall&color=red'))).toBe(JSON.stringify({season:'fall', color:'red'}));
});
});

View File

@@ -38,129 +38,4 @@ window.rewriteStaticLinks = function(content, from, to) {
// note: add other protocols here
var regex = new RegExp("(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}([-a-zA-Z0-9@:%_\+.~#?&//=]*))?"+from, 'g');
return content.replace(regex, replacer);
};
// Appends a parameter to a path; useful for indicating initial or return signin, for example
window.appendParameter = function(path, key, value) {
// Check if the given path already contains a query string by looking for the ampersand separator
if (path.indexOf("?") > -1) {
var splitPath = path.split("?");
var parameters = window.parseQueryString(splitPath[1]);
// Check if the provided key already exists in the query string
if (key in parameters) {
// Overwrite the existing key's value with the provided value
parameters[key] = value;
// Reconstruct the path, including the overwritten key/value pair
var reconstructedPath = splitPath[0] + "?";
for (var k in parameters) {
reconstructedPath = reconstructedPath + k + "=" + parameters[k] + "&";
}
// Strip the trailing ampersand
return reconstructedPath.slice(0, -1);
} else {
// Check for a trailing ampersand
if (path[path.length - 1] != "&") {
// Append signin parameter to the existing query string
return path + "&" + key + "=" + value;
} else {
// Append signin parameter to the existing query string, excluding the ampersand
return path + key + "=" + value;
}
}
} else {
// Append new query string containing the provided parameter
return path + "?" + key + "=" + value;
}
};
// Convert a query string to a key/value object
window.parseQueryString = function(queryString) {
var parameters = {}, queries, pair, i, l;
// Split the query string into key/value pairs
queries = queryString.split("&");
// Break the array of strings into an object
for (i = 0, l = queries.length; i < l; i++) {
pair = queries[i].split('=');
parameters[pair[0]] = pair[1];
}
return parameters
};
// Check if the user recently enrolled in a course by looking at a referral URL
window.checkRecentEnrollment = function(referrer) {
var enrolledIn = null;
// Check if the referrer URL contains a query string
if (referrer.indexOf("?") > -1) {
referrerQueryString = referrer.split("?")[1];
} else {
referrerQueryString = "";
}
if (referrerQueryString != "") {
// Convert a non-empty query string into a key/value object
var referrerParameters = window.parseQueryString(referrerQueryString);
if ("course_id" in referrerParameters && "enrollment_action" in referrerParameters) {
if (referrerParameters.enrollment_action == "enroll") {
enrolledIn = referrerParameters.course_id;
}
}
}
return enrolledIn
};
window.assessUserSignIn = function(parameters, userID, email, username) {
// Check if the user has logged in to enroll in a course - designed for when "Register" button registers users on click (currently, this could indicate a course registration when there may not have yet been one)
var enrolledIn = window.checkRecentEnrollment(document.referrer);
// Check if the user has just registered
if (parameters.signin == "initial") {
window.trackAccountRegistration(enrolledIn, userID, email, username);
} else {
window.trackReturningUserSignIn(enrolledIn, userID, email, username);
}
};
window.trackAccountRegistration = function(enrolledIn, userID, email, username) {
// Alias the user's anonymous history with the user's new identity (for Mixpanel)
analytics.alias(userID);
// Map the user's activity to their newly assigned ID
analytics.identify(userID, {
email: email,
username: username
});
// Track the user's account creation
analytics.track("edx.bi.user.account.registered", {
category: "conversion",
label: enrolledIn != null ? enrolledIn : "none"
});
};
window.trackReturningUserSignIn = function(enrolledIn, userID, email, username) {
// Map the user's activity to their assigned ID
analytics.identify(userID, {
email: email,
username: username
});
// Track the user's sign in
analytics.track("edx.bi.user.account.authenticated", {
category: "conversion",
label: enrolledIn != null ? enrolledIn : "none"
});
};
window.identifyUser = function(userID, email, username) {
// If the signin parameter isn't present but the query string is non-empty, map the user's activity to their assigned ID
analytics.identify(userID, {
email: email,
username: username
});
};
};