mixpanel-ruby-openfeature 0.1.0 → 0.3.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 +4 -4
- data/lib/mixpanel/openfeature/provider.rb +41 -11
- data/lib/mixpanel/openfeature/version.rb +7 -0
- data/lib/mixpanel/openfeature.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9d29a0e7b9305a412989e730ec11fdd8b4d57ccb88d068ca7ad3b753b0f3e5f
|
|
4
|
+
data.tar.gz: fdf41866d6fa4148febdbcdc11b791c505fb0f79776ed2d135d6a715bf5900ca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b7edd78404f6305f60c15ff90f7945811dd1a88f42aa9e370180ffa001243ee2b66b60d5cda539ebfb2dd7cdb38a4ba302e75fd2ee308a9a4c83018666b6aa0
|
|
7
|
+
data.tar.gz: 624605591a8ba5039d98db770b64109463328278324f1285c26bec30c9a155244e9b315cf6fcee4dc0e3e4231502f543c464da3f8c5f124425317bb6047e1c9f
|
|
@@ -69,16 +69,41 @@ module Mixpanel
|
|
|
69
69
|
|
|
70
70
|
begin
|
|
71
71
|
result = @flags_provider.get_variant(flag_key, fallback, context, report_exposure: true)
|
|
72
|
-
rescue StandardError
|
|
73
|
-
return error_result(default_value, ::OpenFeature::SDK::Provider::ErrorCode::GENERAL)
|
|
72
|
+
rescue StandardError => e
|
|
73
|
+
return error_result(default_value, ::OpenFeature::SDK::Provider::ErrorCode::GENERAL, e.message)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
# variant_source distinguishes local / remote / fallback. When fallback,
|
|
77
|
+
# fallback_reason carries the specific reason (PHP-aligned constants)
|
|
78
|
+
# so we can map each to the spec-correct OpenFeature response instead
|
|
79
|
+
# of collapsing every fallback to FLAG_NOT_FOUND. SDK-83: BACKEND_ERROR
|
|
80
|
+
# also carries the backend message, forwarded as error_message.
|
|
81
|
+
case result.fallback_reason&.kind
|
|
82
|
+
when :flag_not_found
|
|
77
83
|
return ::OpenFeature::SDK::Provider::ResolutionDetails.new(
|
|
78
84
|
value: default_value,
|
|
79
85
|
error_code: ::OpenFeature::SDK::Provider::ErrorCode::FLAG_NOT_FOUND,
|
|
80
86
|
reason: ::OpenFeature::SDK::Provider::Reason::DEFAULT
|
|
81
87
|
)
|
|
88
|
+
when :missing_context_key
|
|
89
|
+
return error_result(
|
|
90
|
+
default_value,
|
|
91
|
+
::OpenFeature::SDK::Provider::ErrorCode::TARGETING_KEY_MISSING,
|
|
92
|
+
result.fallback_reason.message
|
|
93
|
+
)
|
|
94
|
+
when :no_rollout_match
|
|
95
|
+
# Flag exists, user just didn't match any rollout — per the
|
|
96
|
+
# OpenFeature spec this is `reason: DEFAULT` with no error.
|
|
97
|
+
return ::OpenFeature::SDK::Provider::ResolutionDetails.new(
|
|
98
|
+
value: default_value,
|
|
99
|
+
reason: ::OpenFeature::SDK::Provider::Reason::DEFAULT
|
|
100
|
+
)
|
|
101
|
+
when :backend_error
|
|
102
|
+
return error_result(
|
|
103
|
+
default_value,
|
|
104
|
+
::OpenFeature::SDK::Provider::ErrorCode::GENERAL,
|
|
105
|
+
result.fallback_reason.message
|
|
106
|
+
)
|
|
82
107
|
end
|
|
83
108
|
|
|
84
109
|
value = result.variant_value
|
|
@@ -125,15 +150,19 @@ module Mixpanel
|
|
|
125
150
|
end
|
|
126
151
|
|
|
127
152
|
def build_context(evaluation_context)
|
|
128
|
-
return {} if evaluation_context.nil?
|
|
129
|
-
|
|
130
153
|
ctx = {}
|
|
131
|
-
|
|
132
|
-
evaluation_context.fields
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
154
|
+
unless evaluation_context.nil?
|
|
155
|
+
if evaluation_context.respond_to?(:fields)
|
|
156
|
+
evaluation_context.fields.each { |k, v| ctx[k] = unwrap_value(v) }
|
|
157
|
+
end
|
|
158
|
+
if evaluation_context.respond_to?(:targeting_key) && evaluation_context.targeting_key
|
|
159
|
+
ctx['targetingKey'] = unwrap_value(evaluation_context.targeting_key)
|
|
160
|
+
end
|
|
136
161
|
end
|
|
162
|
+
# SDK-448: marks exposures as coming from the OpenFeature provider. The
|
|
163
|
+
# SDK copies this onto `$experiment_started`; older SDKs ignore the key.
|
|
164
|
+
# Set last so a customer attribute of the same name can't override it.
|
|
165
|
+
ctx['$openfeature_provider'] = true
|
|
137
166
|
ctx
|
|
138
167
|
end
|
|
139
168
|
|
|
@@ -158,10 +187,11 @@ module Mixpanel
|
|
|
158
187
|
end
|
|
159
188
|
end
|
|
160
189
|
|
|
161
|
-
def error_result(default_value, error_code)
|
|
190
|
+
def error_result(default_value, error_code, error_message = nil)
|
|
162
191
|
::OpenFeature::SDK::Provider::ResolutionDetails.new(
|
|
163
192
|
value: default_value,
|
|
164
193
|
error_code: error_code,
|
|
194
|
+
error_message: error_message,
|
|
165
195
|
reason: ::OpenFeature::SDK::Provider::Reason::ERROR
|
|
166
196
|
)
|
|
167
197
|
end
|
data/lib/mixpanel/openfeature.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mixpanel-ruby-openfeature
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mixpanel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: openfeature-sdk
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '3.
|
|
33
|
+
version: '3.5'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '3.
|
|
40
|
+
version: '3.5'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -88,6 +88,7 @@ extra_rdoc_files: []
|
|
|
88
88
|
files:
|
|
89
89
|
- lib/mixpanel/openfeature.rb
|
|
90
90
|
- lib/mixpanel/openfeature/provider.rb
|
|
91
|
+
- lib/mixpanel/openfeature/version.rb
|
|
91
92
|
homepage: https://mixpanel.com
|
|
92
93
|
licenses:
|
|
93
94
|
- Apache-2.0
|