Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created June 2, 2016 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4d6d38240aa2aeeefb0d0274b6f08969 to your computer and use it in GitHub Desktop.
Save anonymous/4d6d38240aa2aeeefb0d0274b6f08969 to your computer and use it in GitHub Desktop.
class MixpanelService {
static transactional = false
void createOrUpdateUserProfile(User user) {
if(Environment.current != Environment.TEST) {
Executors.newFixedThreadPool(1).execute({
User.withNewSession {
user = User.get(user.id)
MessageBuilder messageBuilder = new MessageBuilder(MIXPANEL_TOKEN)
JSONObject props = new JSONObject()
props.put('$name', user.username)
props.put('$email', user.email)
props.put('$distinct_id', user.id)
props.put('Date created', user.dateCreated)
props.put('Role', user.authorities*.authority?.join(','))
new MixpanelAPI().sendMessage(messageBuilder.set(user.id.toString(), props))
}
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment