Skip to content

Commit 11f97df

Browse files
committed
Merge shared schema earlier
1 parent b6e2b75 commit 11f97df

File tree

1 file changed

+60
-59
lines changed

1 file changed

+60
-59
lines changed

lib/posthog/config.ex

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,4 @@
11
defmodule PostHog.Config do
2-
@configuration_schema [
3-
public_url: [
4-
type: :string,
5-
required: true,
6-
doc: "`https://us.i.posthog.com` for US cloud or `https://eu.i.posthog.com` for EU cloud"
7-
],
8-
api_key: [
9-
type: :string,
10-
required: true,
11-
doc: """
12-
Your PostHog Project API key. Find it in your project's settings under the Project ID section.
13-
"""
14-
],
15-
api_client_module: [
16-
type: :atom,
17-
default: PostHog.API.Client,
18-
doc: "API client to use"
19-
],
20-
supervisor_name: [
21-
type: :atom,
22-
default: PostHog,
23-
doc: "Name of the supervisor process running PostHog"
24-
],
25-
metadata: [
26-
type: {:list, :atom},
27-
default: [],
28-
doc: "List of metadata keys to include in event properties"
29-
],
30-
capture_level: [
31-
type: {:or, [{:in, Logger.levels()}, nil]},
32-
default: :error,
33-
doc:
34-
"Minimum level for logs that should be captured as errors. Errors with `crash_reason` are always captured."
35-
],
36-
in_app_otp_apps: [
37-
type: {:list, :atom},
38-
default: [],
39-
doc:
40-
"List of OTP app names of your applications. Stacktrace entries that belong to these apps will be marked as \"in_app\"."
41-
]
42-
]
43-
44-
@convenience_schema [
45-
enable: [
46-
type: :boolean,
47-
default: true,
48-
doc: "Automatically start PostHog?"
49-
],
50-
enable_error_tracking: [
51-
type: :boolean,
52-
default: true,
53-
doc: "Automatically start the logger handler for error tracking?"
54-
]
55-
]
56-
572
@shared_schema [
583
test_mode: [
594
type: :boolean,
@@ -62,8 +7,64 @@ defmodule PostHog.Config do
627
]
638
]
649

65-
@compiled_configuration_schema NimbleOptions.new!(@configuration_schema ++ @shared_schema)
66-
@compiled_convenience_schema NimbleOptions.new!(@convenience_schema ++ @shared_schema)
10+
@configuration_schema [
11+
public_url: [
12+
type: :string,
13+
required: true,
14+
doc:
15+
"`https://us.i.posthog.com` for US cloud or `https://eu.i.posthog.com` for EU cloud"
16+
],
17+
api_key: [
18+
type: :string,
19+
required: true,
20+
doc: """
21+
Your PostHog Project API key. Find it in your project's settings under the Project ID section.
22+
"""
23+
],
24+
api_client_module: [
25+
type: :atom,
26+
default: PostHog.API.Client,
27+
doc: "API client to use"
28+
],
29+
supervisor_name: [
30+
type: :atom,
31+
default: PostHog,
32+
doc: "Name of the supervisor process running PostHog"
33+
],
34+
metadata: [
35+
type: {:list, :atom},
36+
default: [],
37+
doc: "List of metadata keys to include in event properties"
38+
],
39+
capture_level: [
40+
type: {:or, [{:in, Logger.levels()}, nil]},
41+
default: :error,
42+
doc:
43+
"Minimum level for logs that should be captured as errors. Errors with `crash_reason` are always captured."
44+
],
45+
in_app_otp_apps: [
46+
type: {:list, :atom},
47+
default: [],
48+
doc:
49+
"List of OTP app names of your applications. Stacktrace entries that belong to these apps will be marked as \"in_app\"."
50+
]
51+
] ++ @shared_schema
52+
53+
@convenience_schema [
54+
enable: [
55+
type: :boolean,
56+
default: true,
57+
doc: "Automatically start PostHog?"
58+
],
59+
enable_error_tracking: [
60+
type: :boolean,
61+
default: true,
62+
doc: "Automatically start the logger handler for error tracking?"
63+
]
64+
] ++ @shared_schema
65+
66+
@compiled_configuration_schema NimbleOptions.new!(@configuration_schema)
67+
@compiled_convenience_schema NimbleOptions.new!(@convenience_schema)
6768

6869
@moduledoc """
6970
PostHog configuration
@@ -96,11 +97,11 @@ defmodule PostHog.Config do
9697
def read!() do
9798
configuration_options =
9899
Application.get_all_env(:posthog)
99-
|> Keyword.take(Keyword.keys(@configuration_schema ++ @shared_schema))
100+
|> Keyword.take(Keyword.keys(@configuration_schema))
100101

101102
convenience_options =
102103
Application.get_all_env(:posthog)
103-
|> Keyword.take(Keyword.keys(@convenience_schema ++ @shared_schema))
104+
|> Keyword.take(Keyword.keys(@convenience_schema))
104105

105106
convenience_options
106107
|> NimbleOptions.validate!(@compiled_convenience_schema)

0 commit comments

Comments
 (0)