Skip to content

Commit 625591b

Browse files
Merge pull request #57 from PostHog/move-to-api-host
2 parents db105c9 + 6cd3287 commit 625591b

7 files changed

Lines changed: 18 additions & 18 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Configure the `PostHog` application environment:
3232
config :posthog,
3333
enable: true,
3434
enable_error_tracking: true,
35-
public_url: "https://us.i.posthog.com", # Or `https://eu.posthog.com` or your self-hosted PostHog instance URL
35+
api_host: "https://us.i.posthog.com", # Or `https://eu.posthog.com` or your self-hosted PostHog instance URL
3636
api_key: "phc_my_api_key",
3737
in_app_otp_apps: [:my_app]
3838
```
@@ -215,6 +215,6 @@ minimal example:
215215
import Config
216216

217217
config :posthog,
218-
public_url: "https://us.i.posthog.com",
218+
api_host: "https://us.i.posthog.com",
219219
api_key: "phc_XXXX"
220220
```

config/integration.example.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Config
22

33
config :posthog, :integration_config,
4-
public_url: "https://us.i.posthog.com",
4+
api_host: "https://us.i.posthog.com",
55
api_key: "phc_mykey",
66
metadata: [:extra],
77
capture_level: :info,

guides/advanced-configuration.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This behavior is configured by the `:posthog` option in your global configuratio
77
config :posthog,
88
enable: true,
99
enable_error_tracking: true,
10-
public_url: "https://us.i.posthog.com",
10+
api_host: "https://us.i.posthog.com",
1111
api_key: "phc_asdf"
1212
...
1313
```
@@ -22,7 +22,7 @@ to your application tree with its own configuration:
2222
config :posthog, enable: false
2323

2424
config :my_app, :posthog,
25-
public_url: "https://us.i.posthog.com",
25+
api_host: "https://us.i.posthog.com",
2626
api_key: "phc_asdf"
2727

2828
# application.ex
@@ -32,7 +32,7 @@ defmodule MyApp.Application do
3232

3333
def start(_type, _args) do
3434
posthog_config = Application.fetch_env!(:my_app, :posthog) |> PostHog.Config.validate!()
35-
35+
3636
:logger.add_handler(:posthog, PostHog.Handler, %{config: posthog_config})
3737

3838
children = [
@@ -53,21 +53,21 @@ one of which can be the default one:
5353
```elixir
5454
# config.exs
5555
config :posthog,
56-
public_url: "https://us.i.posthog.com",
56+
api_host: "https://us.i.posthog.com",
5757
api_key: "phc_key1"
5858

5959
config :my_app, :another_posthog,
60-
public_url: "https://us.i.posthog.com",
60+
api_host: "https://us.i.posthog.com",
6161
api_key: "phc_key2",
6262
supervisor_name: AnotherPostHog
63-
63+
6464
# application.ex
6565
defmodule MyApp.Application do
6666
use Application
6767

6868
def start(_type, _args) do
6969
posthog_config = Application.fetch_env!(:my_app, :another_posthog) |> PostHog.Config.validate!()
70-
70+
7171
children = [
7272
{PostHog.Supervisor, posthog_config}
7373
]

lib/posthog/api/client.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ defmodule PostHog.API.Client do
66
example just in case:
77
88
## Example
9-
9+
1010
> client = PostHog.API.Client.client("phc_abcdedfgh", "https://us.i.posthog.com")
1111
%PostHog.API.Client{
1212
client: %Req.Request{...},
1313
module: PostHog.API.Client
1414
}
15-
15+
1616
> client.module.request(client.client, :post, "/flags", json: %{distinct_id: "user123"}, params: %{v: 2, config: true})
1717
{:ok, %Req.Response{status: 200, body: %{...}}}
1818
"""
@@ -46,9 +46,9 @@ defmodule PostHog.API.Client do
4646
response()
4747

4848
@impl __MODULE__
49-
def client(api_key, public_url) do
49+
def client(api_key, api_host) do
5050
client =
51-
Req.new(base_url: public_url)
51+
Req.new(base_url: api_host)
5252
|> Req.Request.put_private(:api_key, api_key)
5353

5454
%__MODULE__{client: client, module: __MODULE__}

lib/posthog/config.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule PostHog.Config do
88
]
99

1010
@configuration_schema [
11-
public_url: [
11+
api_host: [
1212
type: :string,
1313
required: true,
1414
doc:
@@ -144,7 +144,7 @@ defmodule PostHog.Config do
144144
def validate(options) do
145145
with {:ok, validated} <- NimbleOptions.validate(options, @compiled_configuration_schema) do
146146
config = Map.new(validated)
147-
client = config.api_client_module.client(config.api_key, config.public_url)
147+
client = config.api_client_module.client(config.api_key, config.api_host)
148148
global_properties = Map.merge(config.global_properties, @system_global_properties)
149149

150150
final_config =

test/support/api/stub.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule PostHog.API.Stub do
22
@behaviour PostHog.API.Client
33

44
@impl PostHog.API.Client
5-
def client(_api_key, _public_url) do
5+
def client(_api_key, _api_host) do
66
%PostHog.API.Client{client: :stub_client, module: PostHog.API.Mock}
77
end
88

test/support/case.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule PostHog.Case do
1313

1414
config =
1515
[
16-
public_url: "https://us.i.posthog.com",
16+
api_host: "https://us.i.posthog.com",
1717
api_key: "my_api_key",
1818
api_client_module: PostHog.API.Mock,
1919
supervisor_name: context[:test],

0 commit comments

Comments
 (0)