Commit 35c0b51f authored by jejacks0n's avatar jejacks0n

Don’t push to client layer if not tracking

- This will resolve a potential issue with client side logic including
events that we shouldn’t be linking together. The thinking is that this
would be fine without this, but this future proofs things a bit more.
parent 2ea64369
......@@ -10,9 +10,10 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
end
def publish(_result = nil)
return unless should_track? # don't track events for excluded contexts
track(:assignment) # track that we've assigned a variant for this context
# push the experiment data to the client
begin
Gon.push({ experiment: { name => signature } }, true) # push the experiment data to the client
rescue NoMethodError
......
......@@ -58,6 +58,15 @@ RSpec.describe ApplicationExperiment, :experiment do
end
describe "publishing results" do
it "doesn't track or push data to the client if we shouldn't track", :snowplow do
allow(subject).to receive(:should_track?).and_return(false)
expect(Gon).not_to receive(:push)
subject.publish(:action)
expect_no_snowplow_event
end
it "tracks the assignment" do
expect(subject).to receive(:track).with(:assignment)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment