moesif_rack 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 801271db795a8ee81089fbb747ce564424c4800e37713851945bdf37d815b524
4
- data.tar.gz: 5f5b553d5a1c3a2e98958fd057e57621d2ef6ec56153641858a696821f9ae5ca
3
+ metadata.gz: a597bcfb7083d6a0ac126dab64dee86b5dcb31ffcf0e018809768d4bd7e06ea3
4
+ data.tar.gz: cec0a5a1cb82abcb45314173b021534d02ab0a82d4111238a63e171343c7e4d4
5
5
  SHA512:
6
- metadata.gz: b353c6b9999f0308b89ecc937be15b8e7b3a2e96f343db5c24bc1e409445678c9f1172be56c5f5158a173a75c8e09f75892aba138d06c6ad762e03d5e809c502
7
- data.tar.gz: e8832751ed589e0848d45adc2cba1fdb34874e2730d78de5abd5a4e32c0d6e74cb070da004ba59da10f7366e0310405ac36b7af4b393153f9768367f04c8627e
6
+ metadata.gz: 68de312a781cc558dd91a64db9be8510522b0d0241bd723989d2067c63882b0a5d1faecbb256dd843e122f475937cbf64b697ff85b496448aca460f1a6156fd3
7
+ data.tar.gz: 84aa2e7c2d95ba1474e6aeb71d72434d9401b52f372e59914eaaccfba96fde4268498f1cceb7393ab5a05b26d43944d1a75c8fa4e2138b1d6e40cd2e260b26f3
data/README.md CHANGED
@@ -20,7 +20,7 @@ gem install moesif_rack
20
20
  and if you have a `Gemfile` in your project, please add this line to
21
21
 
22
22
  ```
23
- gem 'moesif_rack', '~> 1.3.1'
23
+ gem 'moesif_rack', '~> 1.3.2'
24
24
 
25
25
  ```
26
26
 
@@ -203,6 +203,10 @@ For details for the spec of event model, please see the [Moesif Ruby API Documen
203
203
 
204
204
  Optional. Boolean. Default false. If true, it will print out debug messages. In debug mode, the processing is not done in backend thread.
205
205
 
206
+ #### __`log_body`__
207
+
208
+ Optional. Boolean. Default true. If false, will not log request and response body to Moesif.
209
+
206
210
  #### __`capture_outoing_requests`__
207
211
  Optional. boolean, Default `false`. Set to `true` to capture all outgoing API calls from your app to third parties like Stripe, Github or to your own dependencies while using [Net::HTTP](https://ruby-doc.org/stdlib-2.6.3/libdoc/net/http/rdoc/Net/HTTP.html) package. The options below is applied to outgoing API calls. When the request is outgoing, for options functions that take request and response as input arguments, the request and response objects passed in are [Request](https://www.rubydoc.info/stdlib/net/Net/HTTPRequest) request and [Response](https://www.rubydoc.info/stdlib/net/Net/HTTPResponse) response objects.
208
212
 
@@ -306,6 +310,10 @@ moesif_options['mask_data_outgoing'] = Proc.new { |event_model|
306
310
 
307
311
  ```
308
312
 
313
+ #### __`log_body_outgoing`__
314
+
315
+ Optional. Boolean. Default true. If false, will not log request and response body to Moesif.
316
+
309
317
  ## Update User
310
318
 
311
319
  ### update_user method
@@ -365,6 +373,7 @@ metadata = JSON.parse('{'\
365
373
  '}')
366
374
 
367
375
  company_model = { "company_id" => "testrubyapicompany",
376
+ "company_domain" => "acmeinc.com",
368
377
  "metadata" => metadata }
369
378
 
370
379
  update_company = MoesifRack::MoesifMiddleware.new(@app, @options).update_company(company_model)
@@ -384,9 +393,11 @@ metadata = JSON.parse('{'\
384
393
  company_models = []
385
394
 
386
395
  company_model_A = { "company_id" => "testrubyapicompany",
396
+ "company_domain" => "nowhere.com",
387
397
  "metadata" => metadata }
388
398
 
389
399
  company_model_B = { "company_id" => "testrubyapicompany1",
400
+ "company_domain" => "acmeinc.com",
390
401
  "metadata" => metadata }
391
402
 
392
403
  company_models << company_model_A << company_model_B
@@ -27,6 +27,7 @@ module MoesifRack
27
27
  @debug = options['debug']
28
28
  @config_dict = Hash.new
29
29
  @disable_transaction_id = options['disable_transaction_id'] || false
30
+ @log_body = options.fetch('log_body', true)
30
31
  @sampling_percentage = get_config(nil)
31
32
  if not @sampling_percentage.is_a? Numeric
32
33
  raise "Sampling Percentage should be a number"
@@ -110,13 +111,16 @@ module MoesifRack
110
111
  req_body_string = req.body.read
111
112
  req.body.rewind
112
113
  req_body_transfer_encoding = nil
113
-
114
- if req_body_string && req_body_string.length != 0
115
- begin
116
- req_body = JSON.parse(req_body_string)
117
- rescue
118
- req_body = Base64.encode64(req_body_string)
119
- req_body_transfer_encoding = 'base64'
114
+ req_body = nil
115
+
116
+ if @log_body
117
+ if req_body_string && req_body_string.length != 0
118
+ begin
119
+ req_body = JSON.parse(req_body_string)
120
+ rescue
121
+ req_body = Base64.encode64(req_body_string)
122
+ req_body_transfer_encoding = 'base64'
123
+ end
120
124
  end
121
125
  end
122
126
 
@@ -124,13 +128,16 @@ module MoesifRack
124
128
 
125
129
  rsp_body_string = get_response_body(body);
126
130
  rsp_body_transfer_encoding = nil
127
-
128
- if rsp_body_string && rsp_body_string.length != 0
129
- begin
130
- rsp_body = JSON.parse(rsp_body_string)
131
- rescue
132
- rsp_body = Base64.encode64(rsp_body_string)
133
- rsp_body_transfer_encoding = 'base64'
131
+ rsp_body = nil
132
+
133
+ if @log_body
134
+ if rsp_body_string && rsp_body_string.length != 0
135
+ begin
136
+ rsp_body = JSON.parse(rsp_body_string)
137
+ rescue
138
+ rsp_body = Base64.encode64(rsp_body_string)
139
+ rsp_body_transfer_encoding = 'base64'
140
+ end
134
141
  end
135
142
  end
136
143
 
@@ -22,6 +22,7 @@ module MoesifCaptureOutgoing
22
22
  @identify_session_outgoing = @moesif_options['identify_session_outgoing']
23
23
  @skip_outgoing = options['skip_outgoing']
24
24
  @mask_data_outgoing = options['mask_data_outgoing']
25
+ @log_body_outgoing = options.fetch('log_body_outgoing', true)
25
26
  end
26
27
 
27
28
  def call (url, request, request_time, response, response_time)
@@ -50,25 +51,32 @@ module MoesifCaptureOutgoing
50
51
  # Request Body
51
52
  req_body_string = request.body.nil? || request.body.empty? ? nil : request.body
52
53
  req_body_transfer_encoding = nil
53
- if req_body_string && req_body_string.length != 0
54
- begin
55
- req_body = JSON.parse(req_body_string)
56
- rescue
57
- req_body = Base64.encode64(req_body_string)
58
- req_body_transfer_encoding = 'base64'
54
+ req_body = nil
55
+
56
+ if @log_body_outgoing
57
+ if req_body_string && req_body_string.length != 0
58
+ begin
59
+ req_body = JSON.parse(req_body_string)
60
+ rescue
61
+ req_body = Base64.encode64(req_body_string)
62
+ req_body_transfer_encoding = 'base64'
63
+ end
59
64
  end
60
65
  end
61
66
 
62
67
  # Response Body and encoding
63
68
  rsp_body_string = get_response_body(response.body)
64
69
  rsp_body_transfer_encoding = nil
65
-
66
- if rsp_body_string && rsp_body_string.length != 0
67
- begin
68
- rsp_body = JSON.parse(rsp_body_string)
69
- rescue
70
- rsp_body = Base64.encode64(rsp_body_string)
71
- rsp_body_transfer_encoding = 'base64'
70
+ rsp_body = nil
71
+
72
+ if @log_body_outgoing
73
+ if rsp_body_string && rsp_body_string.length != 0
74
+ begin
75
+ rsp_body = JSON.parse(rsp_body_string)
76
+ rescue
77
+ rsp_body = Base64.encode64(rsp_body_string)
78
+ rsp_body_transfer_encoding = 'base64'
79
+ end
72
80
  end
73
81
  end
74
82
 
@@ -79,7 +87,7 @@ module MoesifCaptureOutgoing
79
87
  event_req.verb = request.method.to_s.upcase
80
88
  event_req.headers = request.each_header.collect.to_h
81
89
  event_req.api_version = nil
82
- event_req.body = req_body_string
90
+ event_req.body = req_body
83
91
  event_req.transfer_encoding = req_body_transfer_encoding
84
92
 
85
93
  # Event Response
@@ -87,7 +95,7 @@ module MoesifCaptureOutgoing
87
95
  event_rsp.time = response_time
88
96
  event_rsp.status = response.code.to_i
89
97
  event_rsp.headers = response.each_header.collect.to_h
90
- event_rsp.body = rsp_body_string
98
+ event_rsp.body = rsp_body
91
99
  event_rsp.transfer_encoding = rsp_body_transfer_encoding
92
100
 
93
101
  # Prepare Event Model
@@ -114,6 +114,7 @@ class MoesifRackTest < Test::Unit::TestCase
114
114
  '}')
115
115
 
116
116
  company_model = { "company_id" => "testrubyapicompany",
117
+ "company_domain" => "acmeinc.com",
117
118
  "metadata" => metadata }
118
119
 
119
120
  response = @moesif_rack_app.update_company(company_model)
@@ -130,9 +131,11 @@ class MoesifRackTest < Test::Unit::TestCase
130
131
  company_models = []
131
132
 
132
133
  company_model_A = { "company_id" => "testrubyapicompany",
134
+ "company_domain" => "nowhere.com",
133
135
  "metadata" => metadata }
134
136
 
135
137
  company_model_B = { "company_id" => "testrubyapicompany1",
138
+ "company_domain" => "acmeinc.com",
136
139
  "metadata" => metadata }
137
140
 
138
141
  company_models << company_model_A << company_model_B
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moesif_rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moesif, Inc
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-24 00:00:00.000000000 Z
12
+ date: 2019-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit