Skip to content

Commit b6139de

Browse files
docs: Small docs fixes
1 parent f2ed899 commit b6139de

File tree

3 files changed

+72
-4
lines changed

3 files changed

+72
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ You can disable PostHog tracking by setting `enabled_capture: false` in your con
147147

148148
When `enabled_capture` is set to `false`:
149149

150-
- All `Posthog.capture/3` and `Posthog.batch/3` calls will succeed silently
150+
- All `Posthog.capture/3` and `Posthog.batch/2` calls will succeed silently
151151
- PostHog will still communicate with the server for Feature Flags
152152

153153
This is useful for:
@@ -355,4 +355,4 @@ When contributing to this project, please ensure your code passes all the develo
355355

356356
## License
357357

358-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
358+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.

lib/posthog.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ defmodule Posthog do
3131
to send actual events to PostHog.
3232
3333
When `enabled_capture` is set to `false`:
34-
- All `Posthog.capture/3` and `Posthog.batch/3` calls will succeed silently
34+
- All `Posthog.capture/3` and `Posthog.batch/2` calls will succeed silently
3535
- PostHog will still communicate with the server for Feature Flags
3636
3737
This is useful for:

lib/posthog/application.ex

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,80 @@
11
defmodule Posthog.Application do
2-
@moduledoc false
2+
@moduledoc """
3+
The main application module for PostHog Elixir client.
4+
5+
This module handles the application lifecycle and supervises the necessary processes
6+
for the PostHog client to function properly. It primarily manages the Cachex instance
7+
used for feature flag event deduplication.
8+
9+
## Features
10+
11+
* Validates configuration before starting
12+
* Manages a Cachex instance for feature flag event deduplication
13+
* Implements LRU (Least Recently Used) caching strategy
14+
* Automatically prunes cache entries to maintain size limits
15+
16+
## Cache Configuration
17+
18+
The Cachex instance is configured with:
19+
* Maximum of 50,000 entries (matching posthog-python's limit)
20+
* LRU (Least Recently Used) eviction policy
21+
* Automatic pruning every 10 seconds
22+
* Access tracking for LRU implementation
23+
24+
## Usage
25+
26+
The application is automatically started by the Elixir runtime when included
27+
in your application's supervision tree. You don't need to start it manually.
28+
29+
To access the cache name in your code:
30+
31+
Posthog.Application.cache_name()
32+
# Returns: :posthog_feature_flag_cache
33+
"""
334

435
use Application
536
import Cachex.Spec
637

738
@cache_name :posthog_feature_flag_cache
39+
40+
@doc """
41+
Returns the name of the Cachex instance used for feature flag event deduplication.
42+
43+
## Returns
44+
45+
* `atom()` - The cache name, always `:posthog_feature_flag_cache` at the moment
46+
47+
## Examples
48+
49+
iex> Posthog.Application.cache_name()
50+
:posthog_feature_flag_cache
51+
"""
852
def cache_name, do: @cache_name
953

54+
@doc """
55+
Starts the PostHog application.
56+
57+
This callback is called by the Elixir runtime when the application starts.
58+
It performs the following tasks:
59+
1. Validates the PostHog configuration
60+
2. Sets up the Cachex instance for feature flag event deduplication
61+
3. Starts the supervision tree
62+
63+
## Parameters
64+
65+
* `_type` - The type of start (ignored)
66+
* `args` - Keyword list of arguments, can include:
67+
68+
## Returns
69+
70+
* `{:ok, pid()}` on successful start
71+
* `{:error, term()}` on failure
72+
73+
## Examples
74+
75+
# Start with default configuration
76+
Posthog.Application.start(:normal, [])
77+
"""
1078
def start(_type, args) do
1179
# Validate configuration before starting
1280
Posthog.Config.validate_config!()

0 commit comments

Comments
 (0)