Skip to content

Commit

Permalink
setup tinybird client
Browse files Browse the repository at this point in the history
  • Loading branch information
yujonglee committed Jul 10, 2024
1 parent 56542bc commit d3ecf3e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ npm-debug.log

# Ignore ssr build for svelte.
/priv/svelte/

.tinyb
16 changes: 16 additions & 0 deletions core/lib/canary/analytics/tinybird.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule Canary.Analytics.Tinybird do
@datasource "web"

defp client() do
base_url = Application.get_env(:canary, :tinybird) |> Keyword.fetch!(:base_url)
api_key = Application.get_env(:canary, :tinybird) |> Keyword.fetch!(:api_key)
end

def event(data) do
client()
|> Req.post(
url: "/v0/events?name=#{@datasource}",
json: Map.merge(data, %{"timestamp" => DateTime.to_iso8601(DateTime.utc_now())})
)
end
end

0 comments on commit d3ecf3e

Please sign in to comment.