Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/quiet-cycles-shutdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"posthog-ruby": patch
Comment thread
marandaneto marked this conversation as resolved.
"posthog-rails": patch
---

Clear the feature flag call dedupe cache on shutdown.
3 changes: 3 additions & 0 deletions lib/posthog/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,9 @@ def shutdown
@worker&.shutdown
@worker_thread&.join(1)
end
@distinct_id_has_sent_flag_calls_mutex.synchronize do
@distinct_id_has_sent_flag_calls.clear
end
end

private
Expand Down
8 changes: 8 additions & 0 deletions spec/posthog/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,14 @@ def run
end

describe '#shutdown' do
it 'clears feature flag call dedupe cache' do
client.instance_variable_get(:@distinct_id_has_sent_flag_calls)['user'] = ['flag_true']

client.shutdown

expect(client.instance_variable_get(:@distinct_id_has_sent_flag_calls).length).to eq(0)
end

it 'is idempotent and stops accepting new events' do
worker = instance_spy(PostHog::NoopWorker, is_requesting?: false)
client.instance_variable_set(:@worker, worker)
Expand Down
Loading