Skip to content

viodotcom/analytics-elixir

 
 

Repository files navigation

analytics-elixir analytics-elixir

analytics-elixir is a non-supported third-party client for Segment

Installation

Add the following to deps section of your mix.exs:

{:segment, github: "FindHotel/analytics-elixir"}

And then run:

mix deps.get

Usage

For general usage, first define the :key configuration:

config :segment, key: "your_segment_key"

For detailed information about configuration, see t:Segment.options/0.

Then call Segment.Analytics functions to send analytics.

There are then two ways to call the functions:

  • By using a collection of parameters
  • By using the related struct as a parameter

Track

Segment.Analytics.track(user_id, event, %{property1: "", property2: ""})

or the full way using a struct with all the possible options for the track call

%Segment.Analytics.Track{ userId: "sdsds",
                          event: "eventname",
                          properties: %{property1: "", property2: ""}
                        }
  |> Segment.Analytics.track

Identify

Segment.Analytics.identify(user_id, %{trait1: "", trait2: ""})

or the full way using a struct with all the possible options for the identify call

%Segment.Analytics.Identify{ userId: "sdsds",
                             traits: %{trait1: "", trait2: ""}
                           }
  |> Segment.Analytics.identify

Screen

Segment.Analytics.screen(user_id, name)

or the full way using a struct with all the possible options for the screen call

%Segment.Analytics.Screen{ userId: "sdsds",
                           name: "dssd"
                         }
  |> Segment.Analytics.screen

Alias

Segment.Analytics.alias(user_id, previous_id)

or the full way using a struct with all the possible options for the alias call

%Segment.Analytics.Alias{ userId: "sdsds",
                          previousId: "dssd"
                         }
  |> Segment.Analytics.alias

Group

Segment.Analytics.group(user_id, group_id)

or the full way using a struct with all the possible options for the group call

%Segment.Analytics.Group{ userId: "sdsds",
                          groupId: "dssd"
                         }
  |> Segment.Analytics.group

Page

Segment.Analytics.page(user_id, name)

or the full way using a struct with all the possible options for the page call

%Segment.Analytics.Page{ userId: "sdsds",
                         name:   "dssd"
                       }
  |> Segment.Analytics.page

Testing

Clone the repository and run:

mix test

Release

After merge a new feature/bug you can bump the version and push it to upstream:

make release
git push origin master && git push origin --tags

Packages

No packages published

Languages

  • Elixir 92.7%
  • Makefile 7.3%