shipeasy-sdk 3.5.1 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 936c7071cc2d4302c9523145eaa5ee80b184167bea8047ee7be9f539d2a3538e
4
- data.tar.gz: ae302e9e648ed16fcf4687ad90668779434a9fda602266e0a4d7fc6a319bda81
3
+ metadata.gz: ad9abca98f87069daf53c2e2347e9f2975595b437576738aef381fbc2a4a9a10
4
+ data.tar.gz: 300a69f50db74da6279666d9d6d8698dbb22d08365e846f20403609e001ea638
5
5
  SHA512:
6
- metadata.gz: eab22b5a957b8be557fd605f3e19024872217179b43d27d1356caec5f1c6829f2049a6ca4663bf53f58ff31dfc92bdacdbf183655b160fc653aa74d916d81304
7
- data.tar.gz: 3a79b37580852b152b783dc3265232ebd123aac3176ea82b8d5a3acdd3c1285ff2163d2b682180f20005ccf0d702d862b2c7bf1cc5c6a4dcc3ac739613d527ff
6
+ metadata.gz: cfb4185054243325d9130de44d40fff6d28af91ee2100150a7f594c2a9925c8ab20f931a2d1ccb433b830521ac07b7ff2381ff2325cf3b1ada0591d674f30c0d
7
+ data.tar.gz: 5b89a4b38c9f6b9eebc9946e50ebd74bbfb5336c0354cee43321b7ea94652fff7da669deebf74317a7aee6492db6760e471ea29b0c375885474e5ab2e37fbdab
@@ -485,6 +485,8 @@ module Shipeasy
485
485
  attr("data-api-url", base),
486
486
  ]
487
487
  attrs << attr("data-anon-id", anon_id) if anon_id && !anon_id.empty?
488
+ data_user = identity_attrs(user)
489
+ attrs << attr("data-user", data_user) if data_user
488
490
  %(<script src="#{CGI.escapeHTML("#{base}/sdk/bootstrap.js")}" #{attrs.join(' ')}></script>)
489
491
  end
490
492
 
@@ -745,6 +747,28 @@ module Shipeasy
745
747
  %(#{name}="#{CGI.escapeHTML(value.to_s)}")
746
748
  end
747
749
 
750
+ # Serialize the server-identified user's traits for the SSR bootstrap tag's
751
+ # data-user attribute: the request user minus `anonymous_id`, dropping
752
+ # nil values only (empty strings and other present values are kept, to
753
+ # match the cross-SDK contract). Returns a stable-keyed JSON object, or nil when nothing
754
+ # identified remains (a purely anonymous request) so data-user is omitted.
755
+ # The browser SDK adopts this identity on first paint, killing the
756
+ # anon->identified flip. See experiment-platform/18-identity-bucketing.md.
757
+ def identity_attrs(user)
758
+ return nil unless user.is_a?(Hash)
759
+
760
+ traits = {}
761
+ user.each do |k, v|
762
+ next if k.to_s == "anonymous_id"
763
+ next if v.nil?
764
+
765
+ traits[k.to_s] = v
766
+ end
767
+ return nil if traits.empty?
768
+
769
+ JSON.generate(traits.sort.to_h)
770
+ end
771
+
748
772
  def start_poll
749
773
  @timer = Thread.new do
750
774
  loop do
@@ -1,5 +1,5 @@
1
1
  module Shipeasy
2
2
  module SDK
3
- VERSION = "3.5.1"
3
+ VERSION = "3.6.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shipeasy-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shipeasy, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-19 00:00:00.000000000 Z
11
+ date: 2026-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec