devcycle-ruby-server-sdk 1.2.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -0
  3. data/devcycle-ruby-server-sdk.gemspec +9 -1
  4. data/lib/devcycle-ruby-server-sdk/api/devcycle_api.rb +128 -21
  5. data/lib/devcycle-ruby-server-sdk/api_client.rb +1 -1
  6. data/lib/devcycle-ruby-server-sdk/configuration.rb +5 -5
  7. data/lib/devcycle-ruby-server-sdk/localbucketing/bucketed_user_config.rb +21 -0
  8. data/lib/devcycle-ruby-server-sdk/localbucketing/bucketing-lib.release.wasm +0 -0
  9. data/lib/devcycle-ruby-server-sdk/localbucketing/config_manager.rb +97 -0
  10. data/lib/devcycle-ruby-server-sdk/localbucketing/dvc_options.rb +119 -0
  11. data/lib/devcycle-ruby-server-sdk/localbucketing/event_queue.rb +120 -0
  12. data/lib/devcycle-ruby-server-sdk/localbucketing/event_types.rb +8 -0
  13. data/lib/devcycle-ruby-server-sdk/localbucketing/events_payload.rb +23 -0
  14. data/lib/devcycle-ruby-server-sdk/localbucketing/local_bucketing.rb +257 -0
  15. data/lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb +29 -0
  16. data/lib/devcycle-ruby-server-sdk/models/event.rb +6 -6
  17. data/lib/devcycle-ruby-server-sdk/models/user_data.rb +78 -107
  18. data/lib/devcycle-ruby-server-sdk/models/variable.rb +0 -13
  19. data/lib/devcycle-ruby-server-sdk/version.rb +1 -1
  20. data/lib/devcycle-ruby-server-sdk.rb +9 -0
  21. data/spec/api/devcycle_api_spec.rb +26 -37
  22. metadata +77 -25
  23. data/Gemfile.lock +0 -70
  24. data/Rakefile +0 -10
  25. data/docs/DevcycleApi.md +0 -290
  26. data/docs/ErrorResponse.md +0 -20
  27. data/docs/Event.md +0 -26
  28. data/docs/Feature.md +0 -26
  29. data/docs/UserData.md +0 -48
  30. data/docs/Variable.md +0 -24
  31. data/examples/sinatra/Gemfile +0 -8
  32. data/examples/sinatra/Gemfile.lock +0 -51
  33. data/examples/sinatra/README.md +0 -14
  34. data/examples/sinatra/app.rb +0 -48
  35. data/git_push.sh +0 -57
data/docs/DevcycleApi.md DELETED
@@ -1,290 +0,0 @@
1
- # DevCycle::DevcycleApi
2
-
3
- All URIs are relative to *https://bucketing-api.devcycle.com*
4
-
5
- | Method | HTTP request | Description |
6
- | ------ | ------------ | ----------- |
7
- | [**all_features**](DevcycleApi.md#all_features) | **POST** /v1/features | Get all features by key for user data |
8
- | [**variable**](DevcycleApi.md#variable) | **POST** /v1/variables/{key} | Get variable by key for user data |
9
- | [**all_variables**](DevcycleApi.md#all_variables) | **POST** /v1/variables | Get all variables by key for user data |
10
- | [**track**](DevcycleApi.md#track) | **POST** /v1/track | Post events to DevCycle for user |
11
-
12
-
13
- ## all_features
14
-
15
- > <Hash<String, Feature>> all_features(user_data)
16
-
17
- Get all features by key for user data
18
-
19
- ### Examples
20
-
21
- ```ruby
22
- require 'time'
23
- require 'devcycle-ruby-server-sdk'
24
- # setup authorization
25
- DevCycle.configure do |config|
26
- # Configure API key authorization: bearerAuth
27
- config.api_key['bearerAuth'] = 'YOUR API KEY'
28
- # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
29
- # config.api_key_prefix['bearerAuth'] = 'Bearer'
30
- end
31
-
32
- api_instance = DevCycle::DevcycleApi.new
33
- user_data = DevCycle::UserData.new({user_id: 'user_id_example'}) # UserData |
34
-
35
- begin
36
- # Get all features by key for user data
37
- result = api_instance.all_features(user_data)
38
- p result
39
- rescue DevCycle::ApiError => e
40
- puts "Error when calling DevcycleApi->all_features: #{e}"
41
- end
42
- ```
43
-
44
- #### Using the all_features_with_http_info variant
45
-
46
- This returns an Array which contains the response data, status code and headers.
47
-
48
- > <Array(<Hash<String, Feature>>, Integer, Hash)> all_features_with_http_info(user_data)
49
-
50
- ```ruby
51
- begin
52
- # Get all features by key for user data
53
- data, status_code, headers = api_instance.all_features_with_http_info(user_data)
54
- p status_code # => 2xx
55
- p headers # => { ... }
56
- p data # => <Hash<String, Feature>>
57
- rescue DevCycle::ApiError => e
58
- puts "Error when calling DevcycleApi->all_features_with_http_info: #{e}"
59
- end
60
- ```
61
-
62
- ### Parameters
63
-
64
- | Name | Type | Description | Notes |
65
- | ---- | ---- | ----------- | ----- |
66
- | **user_data** | [**UserData**](UserData.md) | | |
67
-
68
- ### Return type
69
-
70
- [**Hash&lt;String, Feature&gt;**](Feature.md)
71
-
72
- ### Authorization
73
-
74
- [bearerAuth](../README.md#bearerAuth)
75
-
76
- ### HTTP request headers
77
-
78
- - **Content-Type**: application/json
79
- - **Accept**: application/json
80
-
81
-
82
- ## variable
83
-
84
- > <Variable> variable(user_data, key)
85
-
86
- Get variable by key for user data
87
-
88
- ### Examples
89
-
90
- ```ruby
91
- require 'time'
92
- require 'devcycle-ruby-server-sdk'
93
- # setup authorization
94
- DevCycle.configure do |config|
95
- # Configure API key authorization: bearerAuth
96
- config.api_key['bearerAuth'] = 'YOUR API KEY'
97
- # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
98
- # config.api_key_prefix['bearerAuth'] = 'Bearer'
99
- end
100
-
101
- api_instance = DevCycle::DevcycleApi.new
102
- key = 'key_example' # String | Variable key
103
- user_data = DevCycle::UserData.new({user_id: 'user_id_example'}) # UserData |
104
-
105
- begin
106
- # Get variable by key for user data
107
- result = api_instance.variable(user_data, key)
108
- p result
109
- rescue DevCycle::ApiError => e
110
- puts "Error when calling DevcycleApi->variable: #{e}"
111
- end
112
- ```
113
-
114
- #### Using the variable_with_http_info variant
115
-
116
- This returns an Array which contains the response data, status code and headers.
117
-
118
- > <Array(<Variable>, Integer, Hash)> variable_with_http_info(key, user_data)
119
-
120
- ```ruby
121
- begin
122
- # Get variable by key for user data
123
- data, status_code, headers = api_instance.variable_with_http_info(key, user_data)
124
- p status_code # => 2xx
125
- p headers # => { ... }
126
- p data # => <Variable>
127
- rescue DevCycle::ApiError => e
128
- puts "Error when calling DevcycleApi->variable_with_http_info: #{e}"
129
- end
130
- ```
131
-
132
- ### Parameters
133
-
134
- | Name | Type | Description | Notes |
135
- | ---- | ---- | ----------- | ----- |
136
- | **key** | **String** | Variable key | |
137
- | **user_data** | [**UserData**](UserData.md) | | |
138
-
139
- ### Return type
140
-
141
- [**Variable**](Variable.md)
142
-
143
- ### Authorization
144
-
145
- [bearerAuth](../README.md#bearerAuth)
146
-
147
- ### HTTP request headers
148
-
149
- - **Content-Type**: application/json
150
- - **Accept**: application/json
151
-
152
-
153
- ## all_variables
154
-
155
- > <Hash<String, Variable>> all_variables(user_data)
156
-
157
- Get all variables by key for user data
158
-
159
- ### Examples
160
-
161
- ```ruby
162
- require 'time'
163
- require 'devcycle-ruby-server-sdk'
164
- # setup authorization
165
- DevCycle.configure do |config|
166
- # Configure API key authorization: bearerAuth
167
- config.api_key['bearerAuth'] = 'YOUR API KEY'
168
- # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
169
- # config.api_key_prefix['bearerAuth'] = 'Bearer'
170
- end
171
-
172
- api_instance = DevCycle::DevcycleApi.new
173
- user_data = DevCycle::UserData.new({user_id: 'user_id_example'}) # UserData |
174
-
175
- begin
176
- # Get all variables by key for user data
177
- result = api_instance.all_variables(user_data)
178
- p result
179
- rescue DevCycle::ApiError => e
180
- puts "Error when calling DevcycleApi->all_variables: #{e}"
181
- end
182
- ```
183
-
184
- #### Using the all_variables_with_http_info variant
185
-
186
- This returns an Array which contains the response data, status code and headers.
187
-
188
- > <Array(<Hash<String, Variable>>, Integer, Hash)> all_variables_with_http_info(user_data)
189
-
190
- ```ruby
191
- begin
192
- # Get all variables by key for user data
193
- data, status_code, headers = api_instance.all_variables_with_http_info(user_data)
194
- p status_code # => 2xx
195
- p headers # => { ... }
196
- p data # => <Hash<String, Variable>>
197
- rescue DevCycle::ApiError => e
198
- puts "Error when calling DevcycleApi->all_variables_with_http_info: #{e}"
199
- end
200
- ```
201
-
202
- ### Parameters
203
-
204
- | Name | Type | Description | Notes |
205
- | ---- | ---- | ----------- | ----- |
206
- | **user_data** | [**UserData**](UserData.md) | | |
207
-
208
- ### Return type
209
-
210
- [**Hash&lt;String, Variable&gt;**](Variable.md)
211
-
212
- ### Authorization
213
-
214
- [bearerAuth](../README.md#bearerAuth)
215
-
216
- ### HTTP request headers
217
-
218
- - **Content-Type**: application/json
219
- - **Accept**: application/json
220
-
221
-
222
- ## track
223
-
224
- > <InlineResponse201> track(user_data, event_data)
225
-
226
- Post events to DevCycle for user
227
-
228
- ### Examples
229
-
230
- ```ruby
231
- require 'time'
232
- require 'devcycle-ruby-server-sdk'
233
- # setup authorization
234
- DevCycle.configure do |config|
235
- # Configure API key authorization: bearerAuth
236
- config.api_key['bearerAuth'] = 'YOUR API KEY'
237
- # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
238
- # config.api_key_prefix['bearerAuth'] = 'Bearer'
239
- end
240
-
241
- api_instance = DevCycle::DevcycleApi.new
242
- user_data = DevCycle::UserData.new # UserData |
243
- event_data = DevCycle::Event.new # Event |
244
-
245
- begin
246
- # Post events to DevCycle for user
247
- result = api_instance.track(user_data, event_data)
248
- p result
249
- rescue DevCycle::ApiError => e
250
- puts "Error when calling DevcycleApi->track: #{e}"
251
- end
252
- ```
253
-
254
- #### Using the track_with_http_info variant
255
-
256
- This returns an Array which contains the response data, status code and headers.
257
-
258
- > <Array(<InlineResponse201>, Integer, Hash)> track_with_http_info(user_data_and_events_body)
259
-
260
- ```ruby
261
- begin
262
- # Post events to DevCycle for user
263
- data, status_code, headers = api_instance.track_with_http_info(user_data_and_events_body)
264
- p status_code # => 2xx
265
- p headers # => { ... }
266
- p data # => <InlineResponse201>
267
- rescue DevCycle::ApiError => e
268
- puts "Error when calling DevcycleApi->track_with_http_info: #{e}"
269
- end
270
- ```
271
-
272
- ### Parameters
273
-
274
- | Name | Type | Description | Notes |
275
- | ---- | ---- | ----------- | ----- |
276
- | **user_data_and_events_body** | [**UserDataAndEventsBody**](UserDataAndEventsBody.md) | | |
277
-
278
- ### Return type
279
-
280
- [**InlineResponse201**](InlineResponse201.md)
281
-
282
- ### Authorization
283
-
284
- [bearerAuth](../README.md#bearerAuth)
285
-
286
- ### HTTP request headers
287
-
288
- - **Content-Type**: application/json
289
- - **Accept**: application/json
290
-
@@ -1,20 +0,0 @@
1
- # DevCycle::ErrorResponse
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
- | **message** | **String** | Error message | |
8
- | **data** | **Object** | Additional error information detailing the error reasoning | [optional] |
9
-
10
- ## Example
11
-
12
- ```ruby
13
- require 'devcycle-ruby-server-sdk'
14
-
15
- instance = DevCycle::ErrorResponse.new(
16
- message: null,
17
- data: null
18
- )
19
- ```
20
-
data/docs/Event.md DELETED
@@ -1,26 +0,0 @@
1
- # DevCycle::Event
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
- | **type** | **String** | Custom event type | |
8
- | **target** | **String** | Custom event target / subject of event. Contextual to event type | [optional] |
9
- | **date** | **Float** | Unix epoch time the event occurred according to client | [optional] |
10
- | **value** | **Float** | Value for numerical events. Contextual to event type | [optional] |
11
- | **meta_data** | **Object** | Extra JSON metadata for event. Contextual to event type | [optional] |
12
-
13
- ## Example
14
-
15
- ```ruby
16
- require 'devcycle-server-sdk'
17
-
18
- instance = DevCycle::Event.new(
19
- type: null,
20
- target: null,
21
- date: null,
22
- value: null,
23
- meta_data: null
24
- )
25
- ```
26
-
data/docs/Feature.md DELETED
@@ -1,26 +0,0 @@
1
- # DevCycle::Feature
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
- | **_id** | **String** | unique database id | |
8
- | **key** | **String** | Unique key by Project, can be used in the SDK / API to reference by &#39;key&#39; rather than _id. | |
9
- | **type** | **String** | Feature type | |
10
- | **_variation** | **String** | Bucketed feature variation | |
11
- | **eval_reason** | **String** | Evaluation reasoning | [optional] |
12
-
13
- ## Example
14
-
15
- ```ruby
16
- require 'devcycle-server-sdk'
17
-
18
- instance = DevCycle::Feature.new(
19
- _id: null,
20
- key: null,
21
- type: null,
22
- _variation: null,
23
- eval_reason: null
24
- )
25
- ```
26
-
data/docs/UserData.md DELETED
@@ -1,48 +0,0 @@
1
- # DevCycle::UserData
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
- | **user_id** | **String** | Unique id to identify the user | |
8
- | **email** | **String** | User&#39;s email used to identify the user on the dashboard / target audiences | [optional] |
9
- | **name** | **String** | User&#39;s name used to identify the user on the dashboard / target audiences | [optional] |
10
- | **language** | **String** | User&#39;s language in ISO 639-1 format | [optional] |
11
- | **country** | **String** | User&#39;s country in ISO 3166 alpha-2 format | [optional] |
12
- | **app_version** | **String** | App Version of the running application | [optional] |
13
- | **app_build** | **String** | App Build number of the running application | [optional] |
14
- | **custom_data** | **Object** | User&#39;s custom data to target the user with, data will be logged to DevCycle for use in dashboard. | [optional] |
15
- | **private_custom_data** | **Object** | User&#39;s custom data to target the user with, data will not be logged to DevCycle only used for feature bucketing. | [optional] |
16
- | **created_date** | **Float** | Date the user was created, Unix epoch timestamp format | [optional] |
17
- | **last_seen_date** | **Float** | Date the user was created, Unix epoch timestamp format | [optional] |
18
- | **platform** | **String** | Platform the Client SDK is running on | [optional] |
19
- | **platform_version** | **String** | Version of the platform the Client SDK is running on | [optional] |
20
- | **device_model** | **String** | User&#39;s device model | [optional] |
21
- | **sdk_type** | **String** | DevCycle SDK type | [optional] |
22
- | **sdk_version** | **String** | DevCycle SDK Version | [optional] |
23
-
24
- ## Example
25
-
26
- ```ruby
27
- require 'devcycle-ruby-server-sdk'
28
-
29
- instance = DevCycle::UserData.new(
30
- user_id: null,
31
- email: null,
32
- name: null,
33
- language: null,
34
- country: null,
35
- app_version: null,
36
- app_build: null,
37
- custom_data: null,
38
- private_custom_data: null,
39
- created_date: null,
40
- last_seen_date: null,
41
- platform: null,
42
- platform_version: null,
43
- device_model: null,
44
- sdk_type: null,
45
- sdk_version: null
46
- )
47
- ```
48
-
data/docs/Variable.md DELETED
@@ -1,24 +0,0 @@
1
- # DevCycle::Variable
2
-
3
- ## Properties
4
-
5
- | Name | Type | Description | Notes |
6
- | ---- | ---- | ----------- | ----- |
7
- | **_id** | **String** | unique database id | |
8
- | **key** | **String** | Unique key by Project, can be used in the SDK / API to reference by &#39;key&#39; rather than _id. | |
9
- | **type** | **String** | Variable type | |
10
- | **value** | **Object** | Variable value can be a string, number, boolean, or JSON | |
11
-
12
- ## Example
13
-
14
- ```ruby
15
- require 'devcycle-server-sdk'
16
-
17
- instance = DevCycle::Variable.new(
18
- _id: null,
19
- key: null,
20
- type: null,
21
- value: null
22
- )
23
- ```
24
-
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'sinatra'
4
- gem 'sinatra-contrib'
5
- gem 'thin'
6
- # gem 'devcycle-server-sdk'
7
- gem 'devcycle-ruby-server-sdk', path: "../../"
8
-
@@ -1,51 +0,0 @@
1
- PATH
2
- remote: ../..
3
- specs:
4
- devcycle-ruby-server-sdk (1.2.0)
5
- typhoeus (~> 1.0, >= 1.0.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- daemons (1.4.1)
11
- ethon (0.15.0)
12
- ffi (>= 1.15.0)
13
- eventmachine (1.2.7)
14
- ffi (1.15.5)
15
- multi_json (1.15.0)
16
- mustermann (1.1.1)
17
- ruby2_keywords (~> 0.0.1)
18
- rack (2.2.3)
19
- rack-protection (2.2.0)
20
- rack
21
- ruby2_keywords (0.0.5)
22
- sinatra (2.2.0)
23
- mustermann (~> 1.0)
24
- rack (~> 2.2)
25
- rack-protection (= 2.2.0)
26
- tilt (~> 2.0)
27
- sinatra-contrib (2.2.0)
28
- multi_json
29
- mustermann (~> 1.0)
30
- rack-protection (= 2.2.0)
31
- sinatra (= 2.2.0)
32
- tilt (~> 2.0)
33
- thin (1.8.1)
34
- daemons (~> 1.0, >= 1.0.9)
35
- eventmachine (~> 1.0, >= 1.0.4)
36
- rack (>= 1, < 3)
37
- tilt (2.0.10)
38
- typhoeus (1.4.0)
39
- ethon (>= 0.9.0)
40
-
41
- PLATFORMS
42
- ruby
43
-
44
- DEPENDENCIES
45
- devcycle-ruby-server-sdk!
46
- sinatra
47
- sinatra-contrib
48
- thin
49
-
50
- BUNDLED WITH
51
- 1.17.3
@@ -1,14 +0,0 @@
1
- # DevCycle Ruby SDK Example App
2
-
3
- This is a test application demonstrating the use of the DevCycle Ruby SDK. It uses Sinatra as
4
- a web framework to define several routes which can be called to trigger SDK functionality.
5
-
6
- ## Installation
7
- Install the dependencies using bundler:
8
- `bundle install`
9
-
10
- ## Run
11
- Run the application using bundler:
12
- `bundle exec ruby app.rb <YOUR SDK TOKEN>`
13
-
14
- A valid DevCycle SDK token must be provided.
@@ -1,48 +0,0 @@
1
- require 'sinatra'
2
- require "sinatra/reloader" if development?
3
- require 'devcycle-ruby-server-sdk'
4
-
5
- token = ARGV[0]
6
-
7
- if !token
8
- fail Exception, 'Must provide server SDK token'
9
- end
10
-
11
- DevCycle.configure do |config|
12
- # Configure API key authorization: bearerAuth
13
- config.api_key['bearerAuth'] = token
14
- # config.debugging = true
15
- config.enable_edge_db = false
16
- end
17
-
18
- api_instance = DevCycle::DVCClient.new
19
- user_data = DevCycle::UserData.new({
20
- user_id: 'my-user',
21
- app_version: '1.2.3'
22
- })
23
-
24
- get '/' do
25
- 'Hello world!'
26
- end
27
-
28
- get '/experiment' do
29
- result = api_instance.variable(user_data, "test-feature", false)
30
- p result
31
-
32
- "Your variable result is: #{result.value}"
33
- end
34
-
35
- get '/track-event' do
36
- event_data = DevCycle::Event.new({
37
- type: "my-event",
38
- target: "some_event_target",
39
- value: 12,
40
- meta_data: {
41
- myKey: "my-value"
42
- }
43
- })
44
-
45
- result = api_instance.track(user_data, event_data)
46
-
47
- p result
48
- end
data/git_push.sh DELETED
@@ -1,57 +0,0 @@
1
- #!/bin/sh
2
- # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3
- #
4
- # Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
5
-
6
- git_user_id=$1
7
- git_repo_id=$2
8
- release_note=$3
9
- git_host=$4
10
-
11
- if [ "$git_host" = "" ]; then
12
- git_host="github.com"
13
- echo "[INFO] No command line input provided. Set \$git_host to $git_host"
14
- fi
15
-
16
- if [ "$git_user_id" = "" ]; then
17
- git_user_id="GIT_USER_ID"
18
- echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
- fi
20
-
21
- if [ "$git_repo_id" = "" ]; then
22
- git_repo_id="GIT_REPO_ID"
23
- echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24
- fi
25
-
26
- if [ "$release_note" = "" ]; then
27
- release_note="Minor update"
28
- echo "[INFO] No command line input provided. Set \$release_note to $release_note"
29
- fi
30
-
31
- # Initialize the local directory as a Git repository
32
- git init
33
-
34
- # Adds the files in the local repository and stages them for commit.
35
- git add .
36
-
37
- # Commits the tracked changes and prepares them to be pushed to a remote repository.
38
- git commit -m "$release_note"
39
-
40
- # Sets the new remote
41
- git_remote=$(git remote)
42
- if [ "$git_remote" = "" ]; then # git remote not defined
43
-
44
- if [ "$GIT_TOKEN" = "" ]; then
45
- echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
46
- git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
47
- else
48
- git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
49
- fi
50
-
51
- fi
52
-
53
- git pull origin master
54
-
55
- # Pushes (Forces) the changes in the local repository up to the remote repository
56
- echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
57
- git push origin master 2>&1 | grep -v 'To https'