dopaminekit 4.0.0.beta2 → 4.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfa9bb69b04240c0e7d7df6ca455cfedd084e868
4
- data.tar.gz: 986835950fdb8a08480ae23bb5115c30bfa44398
3
+ metadata.gz: 61687937283304b91056745b3f2d421383581f84
4
+ data.tar.gz: 71223e1a02792beed15c2f8a243fe753b9dd713a
5
5
  SHA512:
6
- metadata.gz: 8308afdcdc4e20db698d2cb86000d889de9c85a1fa6a17b8391540126bb97fa9dc39aa585412050d6bc9befbd0639f908c7cc2fcc2293a06fc0e1a50784c8b75
7
- data.tar.gz: 3dc54a13ebdef0ae3cff7526fb08f8424eadb4770a4ecedc29db5ebdf068c3d1871ec614ce5a461fa4e5fe4f6b0e4709962461584d5089de90155def3f89db25
6
+ metadata.gz: 434e16e3415129ae773a09e4d69aaca024d2d35c9e2bf914f594b99d94e078080b4837c1d805f2a51c41b7e4ec1f4bc36464ea884b3c1e39b19eb27a720f73e1
7
+ data.tar.gz: 65d01ec40a63bfcf1ae5f9af270ccc22990860106fe4c9785c47756c3634655634009c529b77dd6f8a52fad569f322b425a42520a85600a7fad0de192cb6772a
data/README.md CHANGED
@@ -18,13 +18,13 @@ Learn more at [http://usedopamine.com](http://usedopamine.com).
18
18
  1. Add this line to your application's Gemfile:
19
19
 
20
20
  ```ruby
21
- gem 'dopaminekit'
21
+ gem 'dopaminekit', '~> 4.0.0'
22
22
  ```
23
23
 
24
24
  2. And then in terminal execute:
25
25
 
26
26
  ```
27
- $ bundle
27
+ $ bundle install
28
28
  ```
29
29
 
30
30
  Or
@@ -50,157 +50,27 @@ Or
50
50
  3. Create a DopamineKit object with your credentials passed in as Strings
51
51
 
52
52
  ```
53
- ## Credentials for your Dopamine account
54
- appID = "generated from dashboard.usedopamine.com"
55
- developmentSecret = "generated from dashboard.usedopamine.com"
56
- productionSecret = "generated from dashboard.usedopamine.com"
57
- versionID = "testing"
58
- inProduction = false
59
- debugMode = true
53
+ ## Credentials for your Dopamine account
54
+ @appID = "generated from dashboard.usedopamine.com"
55
+ @developmentSecret = "generated from dashboard.usedopamine.com"
56
+ @productionSecret = "generated from dashboard.usedopamine.com"
57
+ @versionID = "testing"
58
+ @inProduction = false
59
+ @debugMode = true
60
60
 
61
- ## Create a DopamineKit object
62
- dopaminekit = DopamineKit.new(appID, developmentSecret, productionSecret, versionID, inProduction, debugMode)
63
-
64
- ...
65
- ## Reinforcement Call
66
- responseFunction = dopaminekit.reinforce("action1", "ken@hotmail.com")
67
-
68
- ...
69
- ## Tracking Call
70
- dopaminekit.track("trackedAction", "ken@hotmail.com")
61
+ @dopaminekit = DopamineKit.new(appID, developmentSecret, productionSecret, versionID, inProduction, debugMode)
62
+
63
+ ## Track
64
+ response = dopaminekit.track( jsonAsHash )
65
+
66
+ ## Report
67
+ response = dopaminekit.report( jsonAsHash )
68
+
69
+ ## Refresh
70
+ response = dopaminekit.refresh( jsonAsHash )
71
+
71
72
  ```
72
-
73
- 4. Start using Dopamine! The main features of DopamineAPI are the `reinforce()` and `track()` functions. These should be added into the response functions of any _action_ to be reinforced or tracked.
74
-
75
- There is also the `addPersistentMetaData(key, value)` to add metadata that is persistent throughout calls, and is cleared with the `clearPersistentMetaData()`.
76
-
77
-
78
- ### Actions that represent Habits
79
-
80
- Reinforce your apps ​_essential_​ actions; what users come to your app to do. Three actions is definitely enough, and one is often best.
81
-
82
- ## Super Users
83
-
84
- There are additional parameters for the `track()` and `reinforce()` functions that are used to gather rich information from your app and better create a user story of better engagement.
85
-
86
- ========
87
-
88
- ####Object Initialization
89
-
90
- The object initialization takes in the API credentials (appID, development and production secrets, and the versionID). There are also the options inProduction, which selects between the development and billed production mode, and debugmode, which prints out the sent and received API calls when set to True.
91
-
92
- ######General syntax
93
-
94
- ```
95
- dopaminekit = DopamineKit.new(appID, developmentSecret, productionSecret, versionID, inProduction, debugMode=false)
96
- ```
97
-
98
- ######Parameters:
99
- - `appID: String` - Uniquely identifies your app, get this from your [developer dashboard](http://dev.usedopamine.com).
100
-
101
- - `developmentSecret : String` - secret key for development
102
-
103
- - `productionSecret : String` - secret key for production
104
-
105
- - `versionID : String` - this is a unique identifier that you choose that marks this implementation as unique in our system. This could be something like 'summer2015Implementation' or 'ClinicalTrial4'. Your `versionID` is what we use to keep track of what users are exposed to what reinforcement and how to best optimize that.
106
-
107
- - `inProduction : Boolean` - indicates whether app is in production or development mode, when you're happy with how you're integrating Dopamine and ready to launch set this argument to `true`. This will activate optimized reinforcement and start your billing cycle. While set to `false` your app will receive dummy reinforcement, new users will not be registered with our system, and no billing occurs.
108
-
109
- - `debugMode : Boolean=false` - Enables debug mode, where the sent and received data are printed. Can be updated with `enableDebugMode(Boolean)`.
110
-
111
-
112
- ========
113
-
114
- ####Tracking Calls
115
-
116
- A tracking call should be used to record and communicate to DopamineAPI that a particular action has been performed by the user, each of these calls will be used to improve the reinforcement model used for the particular user. The tracking call itself is asynchronous and non-blocking. Failed tracking calls will not return errors, but will be noted in the log.
117
-
118
- ######General syntax
119
-
120
- ```
121
- Dopamine.track(actionID, identity, metaData=nil)
122
- ```
123
-
124
- ######Parameters:
125
- - `actionID : String` - A descriptive name for action that the user has performed
126
-
127
- - `identity : String` - A string used to identify a particular user, such as an email or username or UUID.
128
-
129
- - `metaData : Hash=nil` - An optional hash containing extra data about the user or environment to generate better results.
130
-
131
- ========
132
-
133
- ####Reinforcement Calls
134
-
135
- A reinforcement call should be used when the user has performed a particular action that you wish to become a 'habit', the reinforcement call will return the name of the feedback function that should be called to inform, delight or congratulate the user. The names of the reinforcement functions, the feedback functions and their respective pairings may be found and configured on the developer dashboard.
136
-
137
- ######General syntax
138
-
139
- ```
140
- Dopamine.(actionID, identity, metaData=nil)
141
- ```
142
-
143
- ######Parameters:
144
-
145
- - `actionID : String` - A descriptive name for action that the user has performed
146
-
147
- - `identity : String` - A string used to identify a particular user, such as an email or username or UUID.
148
-
149
- - `metaData : Hash=nil` - An optional hash containing extra data about the user or environment to generate better results.
150
-
151
- ========
152
-
153
- ####Persistent MetaData
154
- The DopamineKit object can hold some metaData that is stored and sent with all calls. This can be used in place of, or in addition to the `metaData` parameter for the `reinforce()` and `track()` calls.
155
-
156
-
157
- #####Add or Update PersistentMetaData
158
- Add or update some metaData that you want to include multiple reinforce/tracking calls.
159
-
160
- ######General syntax
161
- ```
162
- dopaminekit.addPersistentMetaData(key, value)
163
- ```
164
-
165
- ######Parameters:
166
- - `key : String` - A descriptive name for the metaData
167
-
168
- - `value : var` - A JSON compliant variable. For example, an Int, Float, String, array, or another Hash.
169
-
170
- #####Get PersistentMetaData
171
- Retrieve a copy of the persistentMetaData Hash. Can be modified and then put back using `setPersistentMetaData()`
172
-
173
- ######General syntax
174
- ```
175
- dopaminekit.getPersistentMetaData()
176
- ```
177
-
178
- ######Returns:
179
- - `Hash` - A copy of the persistentMetaData Hash.
180
-
181
-
182
-
183
- #####Set PersistentMetaData
184
- Replace all contents within the persistentMetaData Hash, and replace them with the Hash passed in.
185
73
 
186
- ######General syntax
187
- ```
188
- dopaminekit.setPersistentMetaData(hash)
189
- ```
190
-
191
- ######Parameters:
192
- - `hash : Hash` - A Hash of JSON compliant key-value pairs. For example, Ints, Floats, Strings, arrays, or other Hashes.
193
-
194
-
195
-
196
- #####Clear PersistentMetaData
197
- Clear all entries in the persistentMetaData Hash.
198
-
199
- ######General syntax
200
- ```
201
- dopaminekit.clearPersistentMetaData()
202
- ```
203
-
204
74
  ========
205
75
 
206
76
  ## Development
data/lib/dopaminekit.rb CHANGED
@@ -18,7 +18,7 @@ class DopamineKit
18
18
  # +debugMode+:: boolean=false - Enables debug mode, where the sent and received data are printed. Can be updated with `enableDebugMode(bool)`.
19
19
  #
20
20
  def initialize(appID, developmentSecret, productionSecret, versionID, inProduction, debugMode=false)
21
- @clientSDKVersion = '3.0.0'
21
+ @clientSDKVersion = '4.0.0'
22
22
  @persistentMetaData = Hash.new
23
23
  @debugMode = debugMode
24
24
 
@@ -41,12 +41,10 @@ class DopamineKit
41
41
  end
42
42
 
43
43
  ##
44
- # Used to send tracking calls to the DopamineAPI.
44
+ # Used to send track calls to the DopamineAPI.
45
45
  #
46
46
  # Params:
47
- # +actionID+:: String - A descriptive name for action that the user has performed
48
- # +identity+:: String - A string used to identify a particular user, such as an email or username or UUID.
49
- # +metaData+:: Hash=nil - A hash containing extra data about the user or environment to generate better results.
47
+ # +payload+:: Hash - Contains the keys :utc, :timezoneOffset, :primaryIdentity, and :actions
50
48
  #
51
49
  # Return:
52
50
  # +response+:: String - a JSON string containing the key 'status', and if 'status' != 200 also another key 'errors'
@@ -55,10 +53,28 @@ class DopamineKit
55
53
  return send(:track, payload)
56
54
  end
57
55
 
56
+ ##
57
+ # Used to send report calls to the DopamineAPI.
58
+ #
59
+ # Params:
60
+ # +payload+:: Hash - Contains the keys :utc, :timezoneOffset, :primaryIdentity, and :actions
61
+ #
62
+ # Return:
63
+ # +response+:: String - a JSON string containing the key 'status', and if 'status' != 200 also another key 'errors'
64
+ #
58
65
  def report(payload)
59
66
  return send(:report, payload)
60
67
  end
61
68
 
69
+ ##
70
+ # Used to send refresh calls to the DopamineAPI.
71
+ #
72
+ # Params:
73
+ # +payload+:: Hash - Contains the keys :utc, :timezoneOffset, :primaryIdentity, and :actionID
74
+ #
75
+ # Return:
76
+ # +response+:: String - a JSON string containing the key 'status', and possibly 'reinforcementCartridge' and 'expiresIn'
77
+ #
62
78
  def refresh(payload)
63
79
  return send(:refresh, payload)
64
80
  end
@@ -74,7 +90,7 @@ class DopamineKit
74
90
  ##
75
91
  # Privately used function to get POST data with basic information and time
76
92
  #
77
- def getBasePostData()
93
+ private def getBasePostData()
78
94
  postData = {
79
95
  :clientOS => "Ruby",
80
96
  :clientOSVersion => "#{RUBY_VERSION}",
@@ -88,7 +104,7 @@ class DopamineKit
88
104
  ##
89
105
  # Privately used function to send an HTTP POST
90
106
  #
91
- def send(type, data)
107
+ private def send(type, data)
92
108
  if !data.is_a? Hash
93
109
  puts "[DopamineKit] - Invalid data for api call:#{data} -- needs to be a Hash"
94
110
  return
@@ -1,3 +1,3 @@
1
1
  class Dopaminekit
2
- VERSION = "4.0.0.beta2"
2
+ VERSION = "4.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dopaminekit
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akash Desai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,9 +119,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 1.3.1
124
+ version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
127
  rubygems_version: 2.4.5.1