ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - novabyte/pathway: An Erlang/Elixir client library for the Trak.io REST API.
An Erlang/Elixir client library for the Trak.io REST API. - novabyte/pathway
Visit Site

GitHub - novabyte/pathway: An Erlang/Elixir client library for the Trak.io REST API.

GitHub - novabyte/pathway: An Erlang/Elixir client library for the Trak.io REST API.

Pathway

An Erlang/Elixir client for the Trak.io REST API.

Trak.io is a service that allows you to save details about your users (people) and their behaviour (events). The service can take in different types of customer data, such as feature usage, payments, support tickets and email history, and then automatically segment users based on that data.

Pathway is created and maintained by Chris Molozian (@novabyte) and contributors. Code licensed under the Apache License v2.0. Documentation licensed under CC BY 3.0.

Download

Pathway is available on Hex.pm.

Adding Pathway to your application takes two steps:

  1. Add pathway to your mix.exs dependencies:

    def deps do
      [{:pathway, "~> 0.1"}]
    end
    
  2. Add :pathway to your application dependencies:

    def application do
      [applications: [:pathway]]
    end
    

Usage

You'll need an API key to use the Trak.io service so you must create an account before you can configure the client.

Configuration

The client can be configured in the usual way by adding these settings to your config.exs file:

config :pathway,
  apikey: "a Trak.io apikey",
  timeout: 3000 # optional
  retries: 2    # optional

Only the apikey is a required configuration property. The other properties are initialised with default values.

Example

The client creates a connection to the Trak.io API server on Pathway.Client.start_link. The Pathway.Client is a GenServer whose process is linked to the connection's pid. If the connection dies the Pathway.Client will also die. For this reason it's recommended to supervise the client in your application:

  # within your Application start callback
  children = [
    worker(Pathway.Client, [[]])
  ]
  opts = [strategy: :one_for_one, name: YourApp.Supervisor]
  Supervisor.start_link(children, opts)

Alternatively, if you don't want to supervise the client or you're experimenting in the iex console you can manually start the client:

{:ok, _pid} = Pathway.Client.start_link()

See Supervisor and Application and Application for more information.

Sending Events

Once the client has been initialised you can start making requests to the Trak.io API. For example, let's assume you have a signup function that gets called when a user signs up, this would be a good opportunity to create an identity for the new user.

# create a map of whatever properties you want to associate
# with the user's identity
user = %{name: "Some User", email: "[email protected]", id: "a new user's ID"}
Pathway.identity(user.id, user)

# you might also want to send an event for the action
Pathway.track(user.id, "user signed up")

For more detailed examples on using Pathway check out the documentation and Trak.io's API documentation.

Note: This client is complete but under development, any feedback and bug reports are welcome.

Usage with Erlang

Elixir code compiles down directly to BEAM bytecode and is completely compatible with Erlang without requiring a "translation layer", runtime introspection or any kind of compatibility layer.

Working with this library from Erlang is as simple as remembering the module prefix created by the Elixir compiler and calling the module's function.

An equivalent Erlang example to the one above:

User = #{"name" => <<"Some User">>, "email" => <<"[email protected]">>, "id" => <<"a new user's ID">>}
UserId = maps:get(User, "id")
'Elixir.Pathway':identify(UserId, User)
'Elixir.Pathway':track(UserId, <<"user signed up">>)

Developer Notes

This codebase uses fusco to make HTTP requests to the Trak.io API and poison to handle JSON serialization.

Errors

If you see a GenServer error message like (or similar):

** (exit) exited in: GenServer.call(Pathway.Client, ["..."], 5000)
    ** (EXIT) no process
     (elixir) lib/gen_server.ex:356: GenServer.call/3
    (pathway) lib/pathway/client.ex:43: Pathway.Client.request/2

It means the Pathway.Client process has died or was not started. See here for how to supervise the client.

Contribute

All contributions to the documentation and the codebase are very welcome.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory