Skip to content

Instantly share code, notes, and snippets.

@objectiveSee
Last active May 30, 2022 17:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save objectiveSee/7243760 to your computer and use it in GitHub Desktop.
Save objectiveSee/7243760 to your computer and use it in GitHub Desktop.
var traits = {
coins: usr.coins,
cake: usr.cake,
name: usr.name,
avatar: usr.avatar
};
var identity = {
userId : usr._id,
traits : traits
}
Logger.info('Identity = '+JSON.stringify(identity));
analytics.identify(identity);
/// ALSO FAILS IN THE SAME WAY WITH:
// send the mongo doc
Anal.identify = function(usr) {
var traits = {
coins: usr.coins,
cake: usr.cake,
username: usr.name,
avatar: usr.avatar
};
var identity = {
userId : usr._id,
traits : traits
}
Logger.info('Identity = '+JSON.stringify(identity));
analytics.identify(usr._id, traits);
}
/**
Console:
2013-10-31T02:55:49.154Z - info: Identity = {"userId":"5271c56078fea74403000007","traits":{"coins":20,"cake":2,"name":"Burt Hubbard","avatar":"image_0"}}
/Users/danny/workspace/easerver/node_modules/mongoose/lib/utils.js:419
throw err;
^
Error: [analytics]#identify: options.userId is a required string.
at Client.identify (/Users/danny/workspace/easerver/node_modules/analytics-node/lib/client.js:112:13)
at Object._.each.exports.(anonymous function) [as identify] (/Users/danny/workspace/easerver/node_modules/analytics-node/lib/index.js:21:34)
at Function.Anal.identify (/Users/danny/workspace/easerver/lib/anal.js:46:15)
*/
@hazowskey
Copy link

gross

@JaJaBinxx
Copy link

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment