1212 <a href =" https://codecov.io/gh/securenative/securenative-ruby " >
1313 <img src="https://codecov.io/gh/securenative/securenative-ruby/branch/master/graph/badge.svg" />
1414 </a >
15+ <a href =" https://badge.fury.io/rb/securenative " ><img src =" https://badge.fury.io/rb/securenative.svg " alt =" Gem Version " height =" 18 " ></a >
1516</p >
1617<p align =" center " >
1718 <a href =" https://docs.securenative.com " >Documentation</a > |
@@ -60,19 +61,15 @@ secureative = SecureNative.init
6061require ' securenative'
6162
6263
63- securenative = SecureNative .init_with_api_key(" YOUR_API_KEY" )
64+ securenative = SecureNative .init_with_api_key(' YOUR_API_KEY' )
6465```
6566
6667### Option 3: Initialize via ConfigurationBuilder
6768``` ruby
6869require ' securenative'
6970
7071
71- securenative = SecureNative .init_with_options(SecureNative .config_builder
72- .with_api_key(" API_KEY" )
73- .with_max_events(10 )
74- .with_log_level(" ERROR" )
75- .build)
72+ securenative = SecureNative .init_with_options(SecureNative .config_builder(api_key = ' API_KEY' , max_event = 10 , log_level = ' ERROR' ))
7673```
7774
7875## Getting SecureNative instance
@@ -94,22 +91,17 @@ require 'securenative'
9491require ' securenative/enums/event_types'
9592require ' securenative/event_options_builder'
9693require ' securenative/models/user_traits'
94+ require ' securenative/context/context_builder'
9795
9896
9997securenative = SecureNative .instance
10098
101- context = SecureNative .context_builder
102- .with_ip(" 127.0.0.1" )
103- .with_client_token(" SECURED_CLIENT_TOKEN" )
104- .with_headers({" user-agent" => " Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405" })
105- .build
99+ context = securenative.context_builder(ip = ' 127.0.0.1' , client_token = ' SECURED_CLIENT_TOKEN' ,
100+ headers = { ' user-agent' => ' Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405' })
106101
107- event_options = EventOptionsBuilder (EventTypes ::LOG_IN )
108- .with_user_id(" USER_ID" )
109- .with_user_traits(UserTraits (" USER_NAME" , " USER_EMAIL" ))
110- .with_context(context)
111- .with_properties({" prop1" => " CUSTOM_PARAM_VALUE" , " prop2" => true , " prop3" => 3 })
112- .build
102+ event_options = EventOptionsBuilder (event_type = EventTypes ::LOG_IN ,
103+ user_id = ' USER_ID' , user_traits = UserTraits (' USER_NAME' , ' USER_EMAIL' ),
104+ context = context, properties = {prop1 => ' CUSTOM_PARAM_VALUE' , prop2 => true , prop3 => 3 }).build
113105
114106securenative.track(event_options)
115107 ```
@@ -127,12 +119,9 @@ def track(request)
127119 securenative = SecureNative .instance
128120 context = SecureNative .context_builder.from_http_request(request).build
129121
130- event_options = EventOptionsBuilder (EventTypes ::LOG_IN )
131- .with_user_id(" USER_ID" )
132- .with_user_traits(UserTraits (" USER_NAME" , " USER_EMAIL" ))
133- .with_context(context)
134- .with_properties({" prop1" => " CUSTOM_PARAM_VALUE" , " prop2" => true , " prop3" => 3 })
135- .build
122+ event_options = EventOptionsBuilder (event_type = EventTypes ::LOG_IN ,
123+ user_id = ' USER_ID' , user_traits = UserTraits (' USER_NAME' , ' USER_EMAIL' ),
124+ context = context, properties = {prop1 => ' CUSTOM_PARAM_VALUE' , prop2 => true , prop3 => 3 }).build
136125
137126 securenative.track(event_options)
138127end
@@ -153,12 +142,9 @@ def track(request)
153142 securenative = SecureNative .instance
154143 context = SecureNative .context_builder.from_http_request(request).build
155144
156- event_options = EventOptionsBuilder (EventTypes ::LOG_IN )
157- .with_user_id(" USER_ID" )
158- .with_user_traits(UserTraits (" USER_NAME" , " USER_EMAIL" ))
159- .with_context(context)
160- .with_properties({" prop1" => " CUSTOM_PARAM_VALUE" , " prop2" => true , " prop3" => 3 })
161- .build
145+ event_options = EventOptionsBuilder (event_type = EventTypes ::LOG_IN ,
146+ user_id = ' USER_ID' , user_traits = UserTraits (' USER_NAME' , ' USER_EMAIL' ),
147+ context = context, properties = {prop1 => ' CUSTOM_PARAM_VALUE' , prop2 => true , prop3 => 3 }).build
162148
163149 verify_result = securenative.verify(event_options)
164150 verify_result.risk_level # Low, Medium, High
0 commit comments