PJUllrich

PJUllrich

Author of Building Table Views with Phoenix LiveView

A Library for Homemade Analytics with Elixir and Ecto

I recently read the wonderful article Homemade Analytics with Elixir and Ecto by @josevalim and decided on using the described approach in a couple of my projects. I didn’t want to copy&paste the code into every project and decided on creating a library instead.

Disclaimer: I absolutely do not want to take credit for José’s code, so I tried to reference his blog article everywhere I could. This library is simply meant as a helper for using his code in your project.

AnalyticsEx

GitHub: GitHub - PJUllrich/analytics_ex · GitHub
Hex: API Reference — analytics_ex v0.2.2

A library tracking how many visitors a Phoenix-based application receives per day without collecting any data from the user. It encapsulates the Homemade Analytics code of José Valim and simply counts the page-requests per path per day. The collected data is stored in a configurable Ecto-repository.

I hope that you find this helpful. My next steps will be to create a nice UI for the collected data. Feel free to help and contribute :slight_smile:

Most Liked

josevalim

josevalim

Creator of Elixir

Awesome work!

After I announced the blog post, I learned about Plausible.io, which is an open source analytics focused on privacy that is written in Elixir. We are using them since then and we are very happy with it, so I definitely recommend them.

So between analytics_ex and plausible, it seems we are well served in the analytics area. :slight_smile:

17
Post #1
PJUllrich

PJUllrich

Author of Building Table Views with Phoenix LiveView

I added a LiveDashboard-page to AnalyticsEx which gives you a quick overview of the counted requests per day, week, and month.

Simply update AnalyticsEx to 0.2.1 and include this in the live_dashboard route in your router.ex.

live_dashboard "/dashboard",
      additional_pages: [
        {:analytics, AnalyticsEx.LiveDashboard.AnalyticsPage}
      ]

You will then have a Tab called Analytics in your LiveDashboard!

If you want to always ignore certain routes in the overview, add them to the live_dashboard-route:

live_dashboard "/dashboard",
      additional_pages: [
        {:analytics, {AnalyticsEx.LiveDashboard.AnalyticsPage, ignore: ["/this-route", "/and-this-route-including-subpaths"]}
      ]

It’s been a bit tricky to add this tab to LiveDashboard using the predefined components, mostly because LiveDashboard was not yet refactored enough in order support adding custom pages with ease. I will create a GitHub ticket for the issues I had with adding this page, but in general, it only took me 1 day to include this page and that is without having any examples! So, it certainly is possible :slight_smile:

11
Post #4
PJUllrich

PJUllrich

Author of Building Table Views with Phoenix LiveView

thanks! I pay for Plausible, but you can also self-host it. Otherwise, here’s a promising new library that could satisfy you needs too: GitHub - lalabuy948/PhoenixAnalytics: 📊 Plug and play analytics for Phoenix applications. · GitHub

Last Post!

KristerV

KristerV

yeah, several rabbit holes later, I was unable to deploy this to fly.io. here’s my issue.

https://github.com/lalabuy948/PhoenixAnalytics/issues/31

Where Next?

Popular in Announcing Top

Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
Crowdhailer
Raxx is an alternative to Plug and is inspired by projects such as Rack(Ruby) and Ring(Clojure). 1.0-rc.1 is now available. To use it re...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New
josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 19951 141
New
kip
ex_cldr provides localisation and internationalisation support based upon the data from the Unicode CLDR project. Unicode released CLDR ...
407 13366 120
New
tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement