416416 expect ( hc . get_request [ "authorization" ] ) . to eq "sdk_key"
417417 end
418418
419+ it "sends unique payload IDs" do
420+ @ep = subject . new ( "sdk_key" , default_config , hc )
421+ e = { kind : "identify" , user : user }
422+
423+ @ep . add_event ( e )
424+ @ep . flush
425+ @ep . wait_until_inactive
426+ req0 = hc . get_request
427+
428+ @ep . add_event ( e )
429+ @ep . flush
430+ @ep . wait_until_inactive
431+ req1 = hc . get_request
432+
433+ id0 = req0 [ "x-launchdarkly-payload-id" ]
434+ id1 = req1 [ "x-launchdarkly-payload-id" ]
435+ expect ( id0 ) . not_to be_nil
436+ expect ( id0 ) . not_to eq ""
437+ expect ( id1 ) . not_to be nil
438+ expect ( id1 ) . not_to eq ""
439+ expect ( id1 ) . not_to eq id0
440+ end
441+
419442 def verify_unrecoverable_http_error ( status )
420443 @ep = subject . new ( "sdk_key" , default_config , hc )
421444 e = { kind : "identify" , user : user }
@@ -442,8 +465,15 @@ def verify_recoverable_http_error(status)
442465 @ep . flush
443466 @ep . wait_until_inactive
444467
445- expect ( hc . get_request ) . not_to be_nil
446- expect ( hc . get_request ) . not_to be_nil
468+ req0 = hc . get_request
469+ expect ( req0 ) . not_to be_nil
470+ req1 = hc . get_request
471+ expect ( req1 ) . not_to be_nil
472+ id0 = req0 [ "x-launchdarkly-payload-id" ]
473+ expect ( id0 ) . not_to be_nil
474+ expect ( id0 ) . not_to eq ""
475+ expect ( req1 [ "x-launchdarkly-payload-id" ] ) . to eq id0
476+
447477 expect ( hc . get_request ) . to be_nil # no 3rd request
448478
449479 # now verify that a subsequent flush still generates a request
0 commit comments