From 797982c3d42c47238ea97bf57ecb5f7384bc9365 Mon Sep 17 00:00:00 2001 From: Vicente Santos Date: Wed, 28 Jan 2026 13:40:12 -0300 Subject: [PATCH 1/5] Fix for Elixir 1.19 compatibility --- CHANGELOG.md | 6 ++++++ lib/segment/analytics/http.ex | 2 +- lib/segment/config.ex | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9acaaa2..a396023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [2.0.1] - 2026-01-28 + +### Fixed + +- Fixed Elixir 1.19 compatibility by removing regex-containing struct default for `filter_body` field. The default value is now applied at runtime via the `default_filter_body/0` function. + ## [2.0.0] - 2024-04-29 ### Changed diff --git a/lib/segment/analytics/http.ex b/lib/segment/analytics/http.ex index c3bb364..cd2cb1f 100644 --- a/lib/segment/analytics/http.ex +++ b/lib/segment/analytics/http.ex @@ -57,7 +57,7 @@ defmodule Segment.Analytics.HTTP do @spec meta_logger(Config.t()) :: Keyword.t() defp meta_logger(%Config{} = config) do [ - filter_body: config.filter_body, + filter_body: config.filter_body || Config.default_filter_body(), filter_headers: ~w(x-api-key), log_level: :info, log_tag: __MODULE__ diff --git a/lib/segment/config.ex b/lib/segment/config.ex index 6271fdd..ca7848d 100644 --- a/lib/segment/config.ex +++ b/lib/segment/config.ex @@ -21,7 +21,7 @@ defmodule Segment.Config do field :disable_meta_logger, boolean(), default: false field :drop_nil_fields, boolean(), default: false field :endpoint, String.t(), default: "https://api.segment.io/v1/" - field :filter_body, Segment.filter_body(), default: @filter_body + field :filter_body, Segment.filter_body() field :http_adapter, module(), default: Tesla.Adapter.Hackney field :key, String.t() field :max_retries, non_neg_integer(), default: 5 @@ -35,6 +35,9 @@ defmodule Segment.Config do @spec boolean_keys :: [atom()] def boolean_keys, do: @boolean_keys + @spec default_filter_body :: Segment.filter_body() + def default_filter_body, do: @filter_body + @spec float_keys :: [atom()] def float_keys, do: @float_keys From 97a4da6eb41211b6ff60c04fa3e563c49a6dc587 Mon Sep 17 00:00:00 2001 From: Vicente Santos Date: Thu, 29 Jan 2026 11:56:59 -0300 Subject: [PATCH 2/5] Fix CI --- .github/workflows/elixir.yml | 11 +++++------ mix.exs | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 8b64f82..8c57add 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -12,17 +12,16 @@ jobs: name: Build and test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Elixir - uses: actions/setup-elixir@v1 + uses: erlef/setup-beam@v1 with: - elixir-version: "1.12.1" - otp-version: "23.0.4" - experimental-otp: true + elixir-version: "1.18.1" + otp-version: "27.2" - name: Restore dependencies cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: deps key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} diff --git a/mix.exs b/mix.exs index 1c5fcac..6ea6c7b 100644 --- a/mix.exs +++ b/mix.exs @@ -9,7 +9,7 @@ defmodule AnalyticsElixir.Mixfile do app: :segment, deps: deps(), description: "analytics_elixir", - elixir: "~> 1.12", + elixir: "~> 1.18", elixirc_paths: elixirc_paths(Mix.env()), name: "analytics_elixir", package: package(), From 1ef7fc650526df3ef20529a8ef748d4275b04100 Mon Sep 17 00:00:00 2001 From: Vicente Santos Date: Thu, 29 Jan 2026 12:09:17 -0300 Subject: [PATCH 3/5] Fix dialyzer step --- .github/workflows/elixir.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 8c57add..bf36d23 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -30,6 +30,9 @@ jobs: - name: Install dependencies run: mix deps.get + - name: Compile + run: mix compile + - name: Check formatted run: mix format --check-formatted @@ -37,8 +40,3 @@ jobs: env: MIX_ENV: test run: mix test - - - name: Run Dialyzer - env: - MIX_ENV: dev - run: mix dialyzer From b645d6eb712fb9e80eb6cca5702edcf945107ea3 Mon Sep 17 00:00:00 2001 From: Vicente Santos Date: Fri, 30 Jan 2026 14:19:10 -0300 Subject: [PATCH 4/5] Readd dialyzer --- .github/workflows/elixir.yml | 32 ++++++++++++++++++++++++++++---- .gitignore | 4 ++++ mix.exs | 6 +++++- mix.lock | 4 ++-- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index bf36d23..bca0ead 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -14,11 +14,13 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Elixir + - name: Set up Elixir + id: beam uses: erlef/setup-beam@v1 with: elixir-version: "1.18.1" - otp-version: "27.2" + otp-version: "27.3.4" + version-type: strict - name: Restore dependencies cache uses: actions/cache@v4 @@ -27,11 +29,30 @@ jobs: key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} restore-keys: ${{ runner.os }}-mix- + - name: Restore PLT cache + id: plt_cache + uses: actions/cache/restore@v4 + with: + key: plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}- + path: priv/plts + - name: Install dependencies run: mix deps.get - - name: Compile - run: mix compile + - name: Create PLTs + if: steps.plt_cache.outputs.cache-hit != 'true' + run: | + mkdir -p priv/plts + mix dialyzer --plt + + - name: Save PLT cache + uses: actions/cache/save@v4 + if: steps.plt_cache.outputs.cache-hit != 'true' + with: + key: plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} + path: priv/plts - name: Check formatted run: mix format --check-formatted @@ -40,3 +61,6 @@ jobs: env: MIX_ENV: test run: mix test + + - name: Run Dialyzer + run: mix dialyzer --format github diff --git a/.gitignore b/.gitignore index e3f5ae9..6a062e3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ erl_crash.dump *.ez *.DS_Store + +# Dialyzer +/priv/plts/*.plt +/priv/plts/*.plt.hash diff --git a/mix.exs b/mix.exs index 6ea6c7b..04552ff 100644 --- a/mix.exs +++ b/mix.exs @@ -9,6 +9,10 @@ defmodule AnalyticsElixir.Mixfile do app: :segment, deps: deps(), description: "analytics_elixir", + dialyzer: [ + plt_core_path: "priv/plts", + plt_file: {:no_warn, "priv/plts/dialyzer.plt"} + ], elixir: "~> 1.18", elixirc_paths: elixirc_paths(Mix.env()), name: "analytics_elixir", @@ -47,7 +51,7 @@ defmodule AnalyticsElixir.Mixfile do {:ex_doc, "~> 0.28", only: :dev, runtime: false}, # Static analysis - {:dialyxir, "~> 1.1", only: :dev, runtime: false} + {:dialyxir, "~> 1.4", only: :dev, runtime: false} ] end diff --git a/mix.lock b/mix.lock index ab13190..7a8bd9e 100644 --- a/mix.lock +++ b/mix.lock @@ -1,8 +1,8 @@ %{ "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, - "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, + "dialyxir": {:hex, :dialyxir, "1.4.7", "dda948fcee52962e4b6c5b4b16b2d8fa7d50d8645bbae8b8685c3f9ecb7f5f4d", [:mix], [{:erlex, ">= 0.2.8", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b34527202e6eb8cee198efec110996c25c5898f43a4094df157f8d28f27d9efe"}, "earmark_parser": {:hex, :earmark_parser, "1.4.22", "1de32345aab0d28bc208314937d2e69ff72ac6cacfdf89b1c0b75fc00283eb56", [:mix], [], "hexpm", "e10a2857c3b5333c503c7f95710c64f0beb2cfaa1d9de024513ad5242dc7cad5"}, - "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, + "erlex": {:hex, :erlex, "0.2.8", "cd8116f20f3c0afe376d1e8d1f0ae2452337729f68be016ea544a72f767d9c12", [:mix], [], "hexpm", "9d66ff9fedf69e49dc3fd12831e12a8a37b76f8651dd21cd45fcf5561a8a7590"}, "ex_doc": {:hex, :ex_doc, "0.28.2", "e031c7d1a9fc40959da7bf89e2dc269ddc5de631f9bd0e326cbddf7d8085a9da", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "51ee866993ffbd0e41c084a7677c570d0fc50cb85c6b5e76f8d936d9587fa719"}, "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, From 843e1f75d2c971c6d4da2137a61ce1db619ace03 Mon Sep 17 00:00:00 2001 From: Vicente Santos Date: Fri, 30 Jan 2026 16:18:14 -0300 Subject: [PATCH 5/5] Remove cache --- .github/workflows/elixir.yml | 24 ------------------------ .gitignore | 4 ---- mix.exs | 4 ---- 3 files changed, 32 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index bca0ead..264a003 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -29,37 +29,13 @@ jobs: key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} restore-keys: ${{ runner.os }}-mix- - - name: Restore PLT cache - id: plt_cache - uses: actions/cache/restore@v4 - with: - key: plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} - restore-keys: | - plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}- - path: priv/plts - - name: Install dependencies run: mix deps.get - - name: Create PLTs - if: steps.plt_cache.outputs.cache-hit != 'true' - run: | - mkdir -p priv/plts - mix dialyzer --plt - - - name: Save PLT cache - uses: actions/cache/save@v4 - if: steps.plt_cache.outputs.cache-hit != 'true' - with: - key: plt-${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} - path: priv/plts - - name: Check formatted run: mix format --check-formatted - name: Run tests - env: - MIX_ENV: test run: mix test - name: Run Dialyzer diff --git a/.gitignore b/.gitignore index 6a062e3..e3f5ae9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,3 @@ erl_crash.dump *.ez *.DS_Store - -# Dialyzer -/priv/plts/*.plt -/priv/plts/*.plt.hash diff --git a/mix.exs b/mix.exs index 04552ff..76f6736 100644 --- a/mix.exs +++ b/mix.exs @@ -9,10 +9,6 @@ defmodule AnalyticsElixir.Mixfile do app: :segment, deps: deps(), description: "analytics_elixir", - dialyzer: [ - plt_core_path: "priv/plts", - plt_file: {:no_warn, "priv/plts/dialyzer.plt"} - ], elixir: "~> 1.18", elixirc_paths: elixirc_paths(Mix.env()), name: "analytics_elixir",