backend-manager 3.2.98 → 3.2.100
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
|
@@ -11,7 +11,7 @@ Module.prototype.main = function () {
|
|
|
11
11
|
|
|
12
12
|
return new Promise(async function(resolve, reject) {
|
|
13
13
|
// Log
|
|
14
|
-
assistant.log('
|
|
14
|
+
assistant.log('Manager.cwd', Manager.cwd)
|
|
15
15
|
|
|
16
16
|
// If not dev, quit
|
|
17
17
|
if (!assistant.isDevelopment()) {
|
|
@@ -26,16 +26,18 @@ Module.prototype.main = function () {
|
|
|
26
26
|
// Load the hook
|
|
27
27
|
let hook;
|
|
28
28
|
try {
|
|
29
|
-
hook = (new (require(pathify(`${
|
|
29
|
+
hook = (new (require(pathify(`${Manager.cwd}/${payload.data.payload.path}.js`)))());
|
|
30
30
|
} catch (e) {
|
|
31
|
-
hook = (new (require(pathify(`${
|
|
31
|
+
hook = (new (require(pathify(`${Manager.cwd}/methods/hooks/${payload.data.payload.path}.js`)))());
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
34
|
+
// Run the hook
|
|
35
|
+
try {
|
|
36
|
+
const result = await hook.main(Manager);
|
|
37
|
+
|
|
38
|
+
return resolve({data: result, status: 200});
|
|
39
|
+
} catch (e) {
|
|
40
|
+
return reject(assistant.errorify(e.message, {code: 500}));
|
|
39
41
|
}
|
|
40
42
|
});
|
|
41
43
|
};
|
|
@@ -196,13 +196,17 @@ Analytics.prototype.event = function (payload) {
|
|
|
196
196
|
// https://support.google.com/analytics/answer/9268042?sjid=4476481583372132143-NC
|
|
197
197
|
// https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#screen_view
|
|
198
198
|
payload = payload || {};
|
|
199
|
+
|
|
200
|
+
// Fix event name
|
|
199
201
|
payload.name = (payload.name || '')
|
|
200
|
-
// Replace
|
|
201
|
-
.replace(
|
|
202
|
+
// Replace anything not a letter, number, or underscore with an underscore
|
|
203
|
+
.replace(/[^a-zA-Z0-9_]/g, '_')
|
|
202
204
|
// Remove leading and trailing underscores
|
|
203
205
|
.replace(/^_+|_+$/g, '')
|
|
204
206
|
// Remove multiple underscores
|
|
205
207
|
.replace(/_+/g, '_');
|
|
208
|
+
|
|
209
|
+
// Fix event params
|
|
206
210
|
payload.params = payload.params || {};
|
|
207
211
|
|
|
208
212
|
// Check if initialized
|