Skip to content

Commit f2ed899

Browse files
feat: Add proper docs about our application tree
1 parent 9096a3a commit f2ed899

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

MIGRATION.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,22 @@ PostHog is consistently upgrading our internal data representation so that's bet
2424

2525
### Posthog.Application
2626

27-
This library now depends on `Cachex`, and includes a supervision tree. To use features that require in-memory caching, you need to add `Posthog.Application` to your own supervision tree:
27+
This library now depends on `Cachex`, and includes a supervision tree. There are 2 options:
2828

29-
#### Add to Your Supervision Tree
29+
1. If you have a simple application without a `YourApp.Application` application, then you can simply add `:posthog` to your `mix.exs` `application` definition
30+
31+
```elixir
32+
def application do
33+
[
34+
extra_applications: [
35+
# ... your existing applications ...
36+
:posthog
37+
],
38+
]
39+
end
40+
```
41+
42+
2. Or, if you're already using an Application, you can add add `Posthog.Application` to your own supervision tree:
3043

3144
```elixir
3245
# lib/my_app/application.ex

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ def application do
4040
]
4141
```
4242

43+
or if you already have a `YourApp.Application` application, you can also add `Posthog.Application` under your supervision tree:
44+
45+
```elixir
46+
# lib/my_app/application.ex
47+
defmodule MyApp.Application do
48+
use Application
49+
50+
def start(_type, _args) do
51+
children = [
52+
# Your other children...
53+
{Posthog.Application, []}
54+
]
55+
56+
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
57+
Supervisor.start_link(children, opts)
58+
end
59+
end
60+
```
61+
4362
### Application Customization
4463

4564
This library includes a `Posthog.Application` because we bundle `Cachex` to allow you to track inside PostHog your FF usage.

0 commit comments

Comments
 (0)