Last active
May 30, 2022 17:05
-
-
Save objectiveSee/7243760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gross