convert_sdk 1.0.0 → 2.0.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.
data/lib/convert_sdk.rb CHANGED
@@ -78,6 +78,42 @@ module ConvertSdk
78
78
  @at_exit_registration_enabled = value
79
79
  end
80
80
 
81
+ # Numeric-only segment pattern used to validate both the experience id and
82
+ # variation id halves of a preview param value (qs-03 AC9).
83
+ # @api private
84
+ PREVIEW_PARAM_NUMERIC_ONLY = /\A\d+\z/
85
+
86
+ # Parse a preview link param value of the form
87
+ # +"{experienceId}.{variationId}"+ (mirrors the web tracking script's force
88
+ # param +_conv_eforce={experienceId}.{variationId}+ and the JS SDK's
89
+ # +parsePreviewParam+ — javascript-sdk packages/js-sdk/src/parse-preview-param.ts).
90
+ #
91
+ # Splits on the FIRST dot only; both segments must be non-empty, numeric-only
92
+ # strings. Any other shape (missing dot, extra dot, empty segment,
93
+ # non-numeric segment, non-String input) returns +nil+.
94
+ #
95
+ # PURE: never raises, no side effects, no logging. Ruby-specific return
96
+ # contract (qs-03): a 2-element String array on success, not the JS oracle's
97
+ # +{experienceId, variationId}+ object shape.
98
+ #
99
+ # @param value [Object] expected to be a +String+; anything else returns +nil+.
100
+ # @return [Array(String, String), nil]
101
+ def self.parse_preview_param(value)
102
+ return nil unless value.is_a?(String)
103
+
104
+ dot_index = value.index(".")
105
+ return nil if dot_index.nil?
106
+ return nil if value.index(".", dot_index + 1)
107
+
108
+ experience_id = value[0...dot_index] #: String
109
+ variation_id = value[(dot_index + 1)..] #: String
110
+
111
+ return nil unless PREVIEW_PARAM_NUMERIC_ONLY.match?(experience_id)
112
+ return nil unless PREVIEW_PARAM_NUMERIC_ONLY.match?(variation_id)
113
+
114
+ [experience_id, variation_id]
115
+ end
116
+
81
117
  # Build an SDK client from an SDK key (live config fetch) or a pre-fetched
82
118
  # +data:+ object (direct data mode). THE public entry point.
83
119
  #
@@ -199,6 +235,11 @@ module ConvertSdk
199
235
  # DataManager is config-read-only). The account/project resolvers are left to
200
236
  # the DataManager's own readers (its constructor defaults to +#account_id+ /
201
237
  # +#project_id+) — the live config IS the source of those store-key halves here.
238
+ # +config_cache_disabled+ is derived from +!config.debug_token.nil?+ (qs-03,
239
+ # Ruby-SDK-only hardening — NOT a JS-parity concern): while a debug token is
240
+ # configured, the config-cache WRITE is suppressed so a shared store cannot
241
+ # be poisoned with a debug-widened config that a production reader might
242
+ # later pick up.
202
243
  # @api private
203
244
  def self.build_data_manager(config, log_manager, data_store_manager, clock,
204
245
  bucketing_manager, rule_manager)
@@ -211,6 +252,7 @@ module ConvertSdk
211
252
  ttl: config.data_refresh_interval,
212
253
  bucketing_manager: bucketing_manager,
213
254
  rule_manager: rule_manager,
255
+ config_cache_disabled: !config.debug_token.nil?,
214
256
  **clock_option
215
257
  )
216
258
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convert_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Convert Insights, Inc.