Skip to content

Commit a39bb44

Browse files
committed
chore: change guidance on starting application
Since Elixir 1.4 (January, 2017), Elixir automatically starts all Applications in your dependencies. Adding `:posthog` to your `:extra_applications` is thus unnecessary, and probably bad advice for new-comers to the language. Starting it as part of your application supervision tree is also probably misguided. As an aside, if this library wanted to give users more control over supervising their instance, it should not start an application, and instead expose a root GenServer where all configuration is passed.
1 parent 627c5bf commit a39bb44

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

README.md

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -27,62 +27,6 @@ def deps do
2727
end
2828
```
2929

30-
You'll also need to include this library under your application tree. You can do so by including `:posthog` under your `:extra_applications` key inside `mix.exs`
31-
32-
```elixir
33-
# mix.exs
34-
def application do
35-
[
36-
extra_applications: [
37-
# ... your existing applications
38-
:posthog
39-
]
40-
]
41-
```
42-
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-
62-
### Application Customization
63-
64-
This library includes a `Posthog.Application` because we bundle `Cachex` to allow you to track inside PostHog your FF usage.
65-
66-
This cache is located under `:posthog_feature_flag_cache`. If you want more control over the application, you can init it yourself in your own `application.ex`
67-
68-
```elixir
69-
# lib/my_app/application.ex
70-
71-
defmodule MyApp.Application do
72-
use Application
73-
74-
def start(_type, _args) do
75-
children = [
76-
# Your other application children...
77-
{Posthog.Application, []}
78-
]
79-
80-
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
81-
Supervisor.start_link(children, opts)
82-
end
83-
end
84-
```
85-
8630
## Configuration
8731

8832
Add your PostHog configuration to your application's config:

0 commit comments

Comments
 (0)