416
416
expect ( hc . get_request [ "authorization" ] ) . to eq "sdk_key"
417
417
end
418
418
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
+
419
442
def verify_unrecoverable_http_error ( status )
420
443
@ep = subject . new ( "sdk_key" , default_config , hc )
421
444
e = { kind : "identify" , user : user }
@@ -442,8 +465,15 @@ def verify_recoverable_http_error(status)
442
465
@ep . flush
443
466
@ep . wait_until_inactive
444
467
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
+
447
477
expect ( hc . get_request ) . to be_nil # no 3rd request
448
478
449
479
# now verify that a subsequent flush still generates a request
0 commit comments