Skip to content

Instantly share code, notes, and snippets.

@gjrevans
Last active September 22, 2017 15:44
Show Gist options
  • Save gjrevans/1205c1993d391813ef19dede5a9cbfd9 to your computer and use it in GitHub Desktop.
Save gjrevans/1205c1993d391813ef19dede5a9cbfd9 to your computer and use it in GitHub Desktop.
/* Identify the current logged-in user with Segment.io */
segment_user = {
first_name: "<%= @current_user.first_name %>",
last_name: "<%= @current_user.last_name %>",
email: "<%= @current_user.email %>",
date_of_birth: "<%= @current_user.birthdate %>"
};
/* Add a company if the user is part of a group */
<%= if assigns[:group] do %>
segment_user.company = {
name: "<%= @group.name %>",
id: "<%= @group.slug %>",
createdAt: "<%= @group.inserted_at %>",
}
<% end %>
analytics.identify("<%= @current_user.id %>", segment_user, {
Intercom: {
user_hash: "<%= :crypto.hmac(:sha256, Logit.Helper.Variables.intercom_identity_verification_secret, Integer.to_string(@current_user.id)) |> Base.encode16 |> String.downcase %>"
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment