moesif_rack 1.1.1 → 1.2.0

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
  SHA1:
3
- metadata.gz: 59bc5bff5591983a5003206528366ee0c34f3aff
4
- data.tar.gz: 4a0bcc09a7dcad7a050dd69c34f28c4508099d77
3
+ metadata.gz: a3430c81bf72498e9f28af81f8a3499ebd65ec42
4
+ data.tar.gz: e290f3cc3f22d2f7fb8dc08df23970e33177c5c3
5
5
  SHA512:
6
- metadata.gz: 8250f76dd528fc69e2969de9e1f1dedff45189ef312b45d5c5421005802c46079211089295a62bf5ccfffc268897f958dbed89813cee571d7f2200b185048d1e
7
- data.tar.gz: f384af017db404d23ad402e3cc175be9043c4467a2b6e2bbd67ad32ba7cca356434072cbeaf29764a0f8fb24d32b546b16b96a4292d7e6ff41078f6ea45c89ed
6
+ metadata.gz: 9f40f2d4e9e939823de3335562a31a375e8674c1b3e7ce290971d2063d6ca2320992b37e3d20f547500e06606bfb0c4d244e58c72caf66c5832cea8bffd42dca
7
+ data.tar.gz: 86a3f26d882c26a5f3875ed62600289e87edb70dbdd8f57aa36a5fd7940c2bf19af52ef9fdf61c9e179a8443bfcc11981ada257c711fabf05843ff14a298c1d2
data/README.md CHANGED
@@ -106,6 +106,27 @@ moesif_options['identify_user'] = Proc.new { |env, headers, body|
106
106
 
107
107
  ```
108
108
 
109
+ #### __`get_metadata`__
110
+
111
+ Optional.
112
+ get_metadata is a Proc that takes env, headers, and body as arguments and returns a Hash that is
113
+ representation of a JSON object. This allows you to attach any
114
+ metadata to this event.
115
+
116
+ ```ruby
117
+
118
+ moesif_options['get_metadata'] = Proc.new { |env, headers, body|
119
+
120
+ #snip
121
+ value = {
122
+ 'foo' => 'abc',
123
+ 'bar' => '123'
124
+ }
125
+
126
+ value
127
+ }
128
+ ```
129
+
109
130
  #### __`identify_session`__
110
131
 
111
132
  Optional. A Proc that takes env, headers, body and returns a string.
@@ -161,6 +182,11 @@ For details for the spec of event model, please see the [Moesif Ruby API Documen
161
182
 
162
183
  Optional. Boolean. Default false. If true, it will print out debug messages. In debug mode, the processing is not done in backend thread.
163
184
 
185
+ ## Example Code
186
+
187
+ [Moesif Rack Example](https://github.com/Moesif/moesif-rack-example) is an
188
+ example of Moesif Rack applied to an Rail application. Please check it out
189
+ for reference.
164
190
 
165
191
  ## Other integrations
166
192
 
@@ -16,6 +16,7 @@ module MoesifRack
16
16
 
17
17
  @api_version = options['api_version']
18
18
  @identify_user = options['identify_user']
19
+ @get_metadata = options['get_metadata']
19
20
  @identify_session = options['identify_session']
20
21
  @mask_data = options['mask_data']
21
22
  @skip = options['skip']
@@ -93,12 +94,21 @@ module MoesifRack
93
94
  event_model = MoesifApi::EventModel.new()
94
95
  event_model.request = event_req
95
96
  event_model.response = event_rsp
97
+
96
98
  if @identify_user
97
99
  if @debug
98
100
  puts "calling identify user proc"
99
101
  end
100
102
  event_model.user_id = @identify_user.call(env, headers, body)
101
103
  end
104
+
105
+ if @get_metadata
106
+ if @debug
107
+ puts "calling get_metadata proc"
108
+ end
109
+ event_model.metadata = @get_metadata.call(env, headers, body)
110
+ end
111
+
102
112
  if @identify_session
103
113
  if @debug
104
114
  puts "calling identify session proc"
@@ -117,7 +127,17 @@ module MoesifRack
117
127
  puts event_model.to_json
118
128
  end
119
129
  # Perform the API call through the SDK function
120
- @api_controller.create_event(event_model)
130
+ begin
131
+ @api_controller.create_event(event_model)
132
+ rescue MoesifApi::APIException => e
133
+ if e.response_code.between?(401, 403)
134
+ puts "Unathorized accesss sending event to Moesif. Please verify your Application Id."
135
+ end
136
+ if @debug
137
+ puts "Error sending event to Moesif, with status code: "
138
+ puts e.response_code
139
+ end
140
+ end
121
141
 
122
142
  end
123
143
 
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.1.1
4
+ version: 1.2.0
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: 2017-03-28 00:00:00.000000000 Z
12
+ date: 2017-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 1.1.1
62
+ version: 1.2.0
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 1.1.1
69
+ version: 1.2.0
70
70
  description: Collection/Data Ingestion SDK for Rack (also Rails) Middleware / RoR
71
71
  email: xing@moesif.com
72
72
  executables: []