Fix PostHog release startup

abda46ab664e · AtlantisPleb · · parent 17d665bd3dd3

Fix PostHog release startup

Deploy story

What this commit did to the running system — joined from the forge receipt chain, the part a commit page elsewhere cannot show.

Not deployed through the forge lane

No push, promotion, build, or deploy receipt references this commit (receipts are scanned over a bounded recent window). Changes shipped by full node replacement carry their proof in the release gate receipt instead.

Changed files

  • modified lib/openagents/application.ex
  • added test/openagents/application_test.exs

Diff

2 files changed, +41 -3

lib/openagents/application.ex modified +4 -3

@@ -98,12 +98,13 @@ defmodule OpenAgents.Application do

98 98
    end
99 99
  end
100 100
101
  defp posthog_config do
101
  @doc false
102
  def posthog_config do
102 103
    case Application.get_env(:posthog, :api_key) do
103 104
      key when is_binary(key) and key != "" ->
104 105
        :posthog
105
        |> Application.get_env([])
106
        |> Keyword.put(:enable, false)
106
        |> Application.get_all_env()
107
        |> Keyword.drop([:enable, :enable_error_tracking])
107 108
        |> PostHog.Config.validate!()
108 109
109 110
      _missing ->
test/openagents/application_test.exs added +37

@@ -0,0 +1,37 @@

1
defmodule OpenAgents.ApplicationTest do
2
  use ExUnit.Case, async: false
3
4
  setup do
5
    original_posthog_env = Application.get_all_env(:posthog)
6
7
    on_exit(fn ->
8
      for {key, _value} <- Application.get_all_env(:posthog) do
9
        Application.delete_env(:posthog, key)
10
      end
11
12
      for {key, value} <- original_posthog_env do
13
        Application.put_env(:posthog, key, value)
14
      end
15
    end)
16
17
    :ok
18
  end
19
20
  test "builds supervisor configuration without convenience options" do
21
    Application.put_env(:posthog, :api_key, "phc_test_token")
22
    Application.put_env(:posthog, :enable, false)
23
    Application.put_env(:posthog, :enable_error_tracking, false)
24
25
    config = OpenAgents.Application.posthog_config()
26
27
    assert config.enabled
28
    assert config.api_key == "phc_test_token"
29
    assert config.api_host == "https://us.i.posthog.com"
30
  end
31
32
  test "returns nil without a project token" do
33
    Application.put_env(:posthog, :api_key, nil)
34
35
    assert OpenAgents.Application.posthog_config() == nil
36
  end
37
end

This page updates live while a promote is in flight · changelog