backend-manager 3.1.0 → 3.1.2
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/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
15
15
|
- `Security` in case of vulnerabilities.
|
|
16
16
|
|
|
17
17
|
---
|
|
18
|
+
## [3.1.0] - 2023-12-19
|
|
19
|
+
### Added
|
|
20
|
+
- Added `.analytics()` API GA4 support.
|
|
21
|
+
|
|
22
|
+
#### New Analytics Format
|
|
23
|
+
```js
|
|
24
|
+
analytics.send({
|
|
25
|
+
name: 'tutorial_begin',
|
|
26
|
+
params: {
|
|
27
|
+
tutorial_id: 'tutorial_1',
|
|
28
|
+
tutorial_name: 'the_beginning',
|
|
29
|
+
tutorial_step: 1,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
- Added `.usage()` API to track user usage.
|
|
34
|
+
- Added `.middleware()` API to help setup http functions.
|
|
35
|
+
- Added `.respond()` function to `assistant.js` to help with http responses.
|
|
36
|
+
|
|
18
37
|
## [3.0.0] - 2023-09-05
|
|
19
38
|
### ⚠️ BREAKING
|
|
20
39
|
- Updated `firebase-admin` from `9.12.0` --> `11.10.1`
|
|
@@ -30,6 +49,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
30
49
|
- Removed `backend-assistant` dependency and moved to custom library within this module at `./src/manager/helpers/assistant.js`
|
|
31
50
|
- Replaced `require('firebase-functions/lib/logger/compat')` with the updated `require('firebase-functions/logger/compat')`
|
|
32
51
|
- Changed default for `options.setupFunctionsLegacy` from `true` --> `false`
|
|
52
|
+
- `.analytics()` is broken due to GA4 updates and should not be used until the next feature release
|
|
33
53
|
- Updated geolocation and client data retrieval to new format:
|
|
34
54
|
#### New Way
|
|
35
55
|
```js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backend-manager",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Quick tools for developing Firebase functions",
|
|
5
5
|
"main": "src/manager/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -69,4 +69,4 @@
|
|
|
69
69
|
"wonderful-log": "^1.0.5",
|
|
70
70
|
"yargs": "^17.7.2"
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|
|
@@ -283,7 +283,7 @@ BackendAssistant.prototype.emergency = function () {
|
|
|
283
283
|
self.log.apply(self, args);
|
|
284
284
|
};
|
|
285
285
|
|
|
286
|
-
BackendAssistant.prototype._log = function() {
|
|
286
|
+
BackendAssistant.prototype._log = function () {
|
|
287
287
|
const self = this;
|
|
288
288
|
|
|
289
289
|
// 1. Convert args to a normal array
|
|
@@ -344,7 +344,7 @@ BackendAssistant.prototype._log = function() {
|
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
BackendAssistant.prototype.errorManager = function(e, options) {
|
|
347
|
+
BackendAssistant.prototype.errorManager = function (e, options) {
|
|
348
348
|
const self = this;
|
|
349
349
|
|
|
350
350
|
// Set options
|
|
@@ -361,6 +361,9 @@ BackendAssistant.prototype.errorManager = function(e, options) {
|
|
|
361
361
|
options.send = typeof options.send === 'undefined'
|
|
362
362
|
? true
|
|
363
363
|
: options.send;
|
|
364
|
+
options.stack = typeof options.stack === 'undefined'
|
|
365
|
+
? true
|
|
366
|
+
: options.stack;
|
|
364
367
|
|
|
365
368
|
// Construct error
|
|
366
369
|
const newError = e instanceof Error
|
|
@@ -390,12 +393,15 @@ BackendAssistant.prototype.errorManager = function(e, options) {
|
|
|
390
393
|
|
|
391
394
|
// Quit and respond to the request
|
|
392
395
|
if (options.send && self.ref.res && self.ref.res.status) {
|
|
396
|
+
const sendable = newError?.stack && options.stack
|
|
397
|
+
? newError?.stack
|
|
398
|
+
: newError?.message;
|
|
399
|
+
|
|
393
400
|
self.ref.res
|
|
394
401
|
.status(options.code)
|
|
395
402
|
.send((
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
? newError.message
|
|
403
|
+
sendable
|
|
404
|
+
? sendable
|
|
399
405
|
: newError
|
|
400
406
|
) || 'Unknown error');
|
|
401
407
|
}
|
|
@@ -419,6 +425,14 @@ BackendAssistant.prototype.respond = function(response, options) {
|
|
|
419
425
|
? true
|
|
420
426
|
: options.log;
|
|
421
427
|
|
|
428
|
+
// Handle error
|
|
429
|
+
if (
|
|
430
|
+
response instanceof Error
|
|
431
|
+
|| (options.code >= 400 && options.code <= 599)
|
|
432
|
+
) {
|
|
433
|
+
return self.errorify(response, options);
|
|
434
|
+
}
|
|
435
|
+
|
|
422
436
|
// Attach properties
|
|
423
437
|
_attachHeaderProperties(self, options);
|
|
424
438
|
|
package/src/manager/index.js
CHANGED
|
@@ -198,8 +198,8 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
198
198
|
exporter.bm_api =
|
|
199
199
|
self.libraries.functions
|
|
200
200
|
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
201
|
-
|
|
202
|
-
.onRequest(async (req, res) => {
|
|
201
|
+
// TODO: Replace this with new API
|
|
202
|
+
.https.onRequest(async (req, res) => {
|
|
203
203
|
return self._process((new (require(`${core}/actions/api.js`))()).init(self, { req: req, res: res, }))
|
|
204
204
|
});
|
|
205
205
|
|