backend-manager 3.0.59 → 3.0.60

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.0.59",
3
+ "version": "3.0.60",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -172,12 +172,15 @@ Usage.prototype.increment = function (path, value, options) {
172
172
  const Manager = self.Manager;
173
173
  const assistant = self.assistant;
174
174
 
175
+ value = value || 1;
176
+
175
177
  options = options || {};
176
178
  options.id = options.id || null;
177
179
 
178
180
  // Update total and period
179
181
  ['total', 'period', 'last'].forEach((key) => {
180
182
  const resolved = `usage.${path}.${key}`;
183
+ const existing = _.get(self.user, resolved, 0);
181
184
 
182
185
  if (key === 'last') {
183
186
  const now = moment(
@@ -190,9 +193,7 @@ Usage.prototype.increment = function (path, value, options) {
190
193
  timestampUNIX: now.unix(),
191
194
  });
192
195
  } else {
193
- _.set(self.user, resolved,
194
- _.get(self.user, resolved, 0) + value
195
- );
196
+ _.set(self.user, resolved, existing + value);
196
197
  }
197
198
  });
198
199
 
@@ -209,6 +210,10 @@ Usage.prototype.set = function (path, value) {
209
210
 
210
211
  // Update total and period
211
212
  const resolved = `usage.${path}.${key}`;
213
+
214
+ value = value || 0;
215
+
216
+ // Set the value
212
217
  _.set(self.user, resolved, value);
213
218
 
214
219
  // Log the updated user