Skip to content

LogHog -> PostHog #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: v2.0.0-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ posthog-*.tar

# Ignore .DS_Store
.DS_Store

# Local Config
config/dev.exs
config/integration.exs
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.18.3
elixir 1.18.3-otp-27
erlang 27.3.3
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

- Elixir v1.14+ is now a requirement
- Feature Flags now return a key called `payload` rather than `value` to better align with the other SDKs
- PostHog now requires you to initialize `Posthog.Application` alongside your supervisor tree. This is required because of our `Cachex` system to properly track your FF usage.
- PostHog now requires you to initialize `PostHog.Application` alongside your supervisor tree. This is required because of our `Cachex` system to properly track your FF usage.
- We'll also include local evaluation in the near term, which will also require a GenServer, therefore, requiring us to use a Supervisor.
- Added `enabled_capture` configuration option to disable PostHog tracking in development/test environments
- `Posthog.capture` now requires `distinct_id` as a required second argument
- `PostHog.capture` now requires `distinct_id` as a required second argument

## 0.4.4 - 2025-04-14

Expand Down
28 changes: 16 additions & 12 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

This is a migration guide for all major version bumps

## v0-v1
## v1 -> v2

TODO: New library

## v0 -> v1

When we stabilized our library, we decided to pull some breaking changes, here are they and how you can migrate:

Expand All @@ -17,12 +21,12 @@ The library previously supported Elixir v1.12+. You'll need to migrate to Elixir

PostHog is consistently upgrading our internal data representation so that's better for customers each and every time. We've recently launched a new version of our `/decide` endpoint called `v4`. This endpoint is slightly different, which caused a small change in behavior for our flags.

`Posthog.FeatureFlag` previously included a key `value` that to represent the internal structure of a flag. It was renamed to `payload` to:
`PostHog.FeatureFlag` previously included a key `value` that to represent the internal structure of a flag. It was renamed to `payload` to:

1. better represent the fact that it can be both an object and a boolean
2. align it more closely with our other SDKs

### Posthog.Application
### PostHog.Application

This library now depends on `Cachex`, and includes a supervision tree. There are 2 options:

Expand All @@ -39,7 +43,7 @@ def application do
end
```

2. Or, if you're already using an Application, you can add add `Posthog.Application` to your own supervision tree:
2. Or, if you're already using an Application, you can add add `PostHog.Application` to your own supervision tree:

```elixir
# lib/my_app/application.ex
Expand All @@ -49,7 +53,7 @@ defmodule MyApp.Application do
def start(_type, _args) do
children = [
# Your other children...
{Posthog.Application, []}
{PostHog.Application, []}
]

opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Expand All @@ -58,32 +62,32 @@ defmodule MyApp.Application do
end
```

### `Posthog.capture` new signature
### `PostHog.capture` new signature

The signature to `Posthog.capture` has changed. `distinct_id` is now a required argument.
The signature to `PostHog.capture` has changed. `distinct_id` is now a required argument.

Here are some examples on how the method is now used:

```elixir
# Basic event with `event` and `distinct_id`, both required
Posthog.capture("page_view", "user_123")
PostHog.capture("page_view", "user_123")

# Event with properties
Posthog.capture("purchase", "user_123", %{
PostHog.capture("purchase", "user_123", %{
product_id: "prod_123",
price: 99.99,
currency: "USD"
})

# Event with custom timestamp
Posthog.capture("signup_completed", "user_123", %{}, timestamp: DateTime.utc_now())
PostHog.capture("signup_completed", "user_123", %{}, timestamp: DateTime.utc_now())

# Event with custom UUID
uuid = "..."
Posthog.capture("signup_completed", "user_123", %{}, uuid: uuid)
PostHog.capture("signup_completed", "user_123", %{}, uuid: uuid)

# Event with custom headers
Posthog.capture(
PostHog.capture(
"login",
"user_123",
%{},
Expand Down
Loading