Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-12653] Fixed analytics library to set the uid cookie and not pass in the app_id. #31

Merged
merged 1 commit into from
Feb 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fixed Titanium module detection library to properly handle the deploy-type property. [TIMOB-12422]
* Removed the deprecated Uglify 1 AST walker since we've upgraded to Uglify 2. [TIMOB-12439]
* Updated auth library to use request module instead of node.js built-in request functions. [TIMOB-12423]
* Fixed analytics library to set the uid cookie and not pass in the app_id. [TIMOB-12653]

0.1.27 (1/22/2013)
-------------------
Expand Down
38 changes: 34 additions & 4 deletions lib/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ process.on('message', function(m) {
getOSInfo(function (info) {
cb(null, info);
});
},

ifaces: function (cb) {
interfaces(function (ifaces) {
cb(null, ifaces);
});
}
}, function (err, results) {
var directory = afs.resolvePath(m.directory),
Expand All @@ -66,7 +72,26 @@ process.on('message', function(m) {
now = (new Date).getTime(),
mid = results.mid,
sid,
sessionExpiration;
sessionExpiration,
macAddr = '',
ipAddr = '',
ifaces = Object.keys(results.ifaces).sort();

// try to find us the mac address and ip address
// note: this finds the first physical interface which may not necessarily be the default gateway interface
for (var i = 0; i < ifaces.length; i++) {
if (results.ifaces[ifaces[i]].macAddress) {
var ips = results.ifaces[ifaces[i]].ipAddresses;
for (var j = 0; j < ips.length; j++) {
ipAddr = ips[j].address;
if (ips[j].family.toLowerCase() == 'ipv4') {
break;
}
}
macAddr = results.ifaces[ifaces[i]].macAddress;
break;
}
}

function add(type, event, id, ts, data) {
payload.push(mix({
Expand All @@ -75,11 +100,12 @@ process.on('message', function(m) {
sid: sid,
guid: m.appGuid,
mid: mid,
mac_addr: macAddr,
ip: ipAddr,
creator_user_id: m.uid,
app_id: m.appId,
app_name: m.appName,
app_version: m.version,
version: '1.1.0',
version: m.version,
tz: (new Date()).getTimezoneOffset(),
ver: '2',
un: m.email,
Expand Down Expand Up @@ -150,14 +176,18 @@ process.on('message', function(m) {

// console.log(payload);

var status = auth.status(),
sessionCookie = status.cookie.match(/(PHPSESSID=[A-Za-z0-9]+)/),
cookie = (sessionCookie ? sessionCookie[1] + ';' : '') + 'uid=' + status.guid; // no, this is not a bug... it really is called uid and expects the guid

async.series(payload.map(function (data) {
return function (callback) {
request({
uri: url,
method: 'POST',
proxy: m.httpProxyServer || undefined,
headers: {
Cookie: auth.status().cookie
Cookie: cookie
},
body: urlEncode(data)
}, function (error, response, body) {
Expand Down
2 changes: 2 additions & 0 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ exports.login = function (username, password, callback, proxy) {
cookie: cookie[0],
data: {
uid: res.uid,
guid: res.guid,
email: res.email
}
};
Expand Down Expand Up @@ -146,6 +147,7 @@ exports.status = function () {
result = {
loggedIn: session.loggedIn,
uid: session.data && session.data.uid,
guid: session.data && session.data.guid,
email: session.data && session.data.email,
cookie: session.cookie
};
Expand Down