@nu-art/analytics-backend 0.401.9 → 0.500.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Module } from '@nu-art/ts-common';
|
|
2
2
|
import { AnalyticsPlugin_Base } from '../plugins/AnalyticsPlugin_Base.js';
|
|
3
|
+
import { API_Analytics } from '@nu-art/analytics-shared';
|
|
3
4
|
import { AnalyticsPluginRegistry } from '../plugins/index.js';
|
|
4
5
|
type Config = {
|
|
5
6
|
plugins: {
|
|
@@ -12,9 +13,9 @@ declare class ModuleBE_Analytics_Class extends Module<Config> {
|
|
|
12
13
|
addPlugin(plugin: AnalyticsPlugin_Base): void;
|
|
13
14
|
removePlugin(plugin: AnalyticsPlugin_Base): void;
|
|
14
15
|
private initPlugins;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
protected api_sendEvent(body: API_Analytics['sendEvent']['Body']): Promise<API_Analytics['sendEvent']['Response']>;
|
|
17
|
+
protected api_updateUser(body: API_Analytics['updateUser']['Body']): Promise<API_Analytics['updateUser']['Response']>;
|
|
18
|
+
protected api_updateLexicon(body: API_Analytics['updateLexicon']['Body']): Promise<API_Analytics['updateLexicon']['Response']>;
|
|
18
19
|
}
|
|
19
20
|
export declare const ModuleBE_Analytics: ModuleBE_Analytics_Class;
|
|
20
21
|
export {};
|
|
@@ -1,46 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
plugins = new Map();
|
|
6
|
-
init() {
|
|
7
|
-
super.init();
|
|
8
|
-
this.initPlugins();
|
|
9
|
-
addRoutes([
|
|
10
|
-
createBodyServerApi(ApiDef_Analytics()._v1.sendEvent, this.api_sendEvent),
|
|
11
|
-
createBodyServerApi(ApiDef_Analytics()._v1.updateUser, this.api_updateUser),
|
|
12
|
-
createBodyServerApi(ApiDef_Analytics()._v1.updateLexicon, this.api_updateLexicon),
|
|
13
|
-
]);
|
|
14
|
-
}
|
|
15
|
-
//######################### Plugin Management #########################
|
|
16
|
-
addPlugin(plugin) {
|
|
17
|
-
this.plugins.set(plugin.key, plugin);
|
|
18
|
-
}
|
|
19
|
-
removePlugin(plugin) {
|
|
20
|
-
this.plugins.delete(plugin.key);
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
21
5
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { ApiHandler } from '@nu-art/http-server';
|
|
36
|
+
import { Module } from '@nu-art/ts-common';
|
|
37
|
+
import { ApiDef_Analytics } from '@nu-art/analytics-shared';
|
|
38
|
+
let ModuleBE_Analytics_Class = (() => {
|
|
39
|
+
let _classSuper = Module;
|
|
40
|
+
let _instanceExtraInitializers = [];
|
|
41
|
+
let _api_sendEvent_decorators;
|
|
42
|
+
let _api_updateUser_decorators;
|
|
43
|
+
let _api_updateLexicon_decorators;
|
|
44
|
+
return class ModuleBE_Analytics_Class extends _classSuper {
|
|
45
|
+
static {
|
|
46
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
47
|
+
_api_sendEvent_decorators = [ApiHandler(() => ApiDef_Analytics().sendEvent)];
|
|
48
|
+
_api_updateUser_decorators = [ApiHandler(() => ApiDef_Analytics().updateUser)];
|
|
49
|
+
_api_updateLexicon_decorators = [ApiHandler(() => ApiDef_Analytics().updateLexicon)];
|
|
50
|
+
__esDecorate(this, null, _api_sendEvent_decorators, { kind: "method", name: "api_sendEvent", static: false, private: false, access: { has: obj => "api_sendEvent" in obj, get: obj => obj.api_sendEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
51
|
+
__esDecorate(this, null, _api_updateUser_decorators, { kind: "method", name: "api_updateUser", static: false, private: false, access: { has: obj => "api_updateUser" in obj, get: obj => obj.api_updateUser }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
52
|
+
__esDecorate(this, null, _api_updateLexicon_decorators, { kind: "method", name: "api_updateLexicon", static: false, private: false, access: { has: obj => "api_updateLexicon" in obj, get: obj => obj.api_updateLexicon }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
53
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
54
|
+
}
|
|
55
|
+
plugins = (__runInitializers(this, _instanceExtraInitializers), new Map());
|
|
56
|
+
init() {
|
|
57
|
+
super.init();
|
|
58
|
+
this.initPlugins();
|
|
59
|
+
}
|
|
60
|
+
//######################### Plugin Management #########################
|
|
61
|
+
addPlugin(plugin) {
|
|
62
|
+
this.plugins.set(plugin.key, plugin);
|
|
63
|
+
}
|
|
64
|
+
removePlugin(plugin) {
|
|
65
|
+
this.plugins.delete(plugin.key);
|
|
66
|
+
}
|
|
67
|
+
initPlugins() {
|
|
68
|
+
this.plugins.forEach(plugin => {
|
|
69
|
+
const key = plugin.key;
|
|
70
|
+
const pluginConfig = this.config.plugins[key];
|
|
71
|
+
plugin.init(pluginConfig);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//######################### API Callbacks #########################
|
|
75
|
+
async api_sendEvent(body) {
|
|
76
|
+
return this.plugins.forEach(plugin => {
|
|
77
|
+
plugin.registerEvent(body.event);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async api_updateUser(body) {
|
|
81
|
+
return this.plugins.forEach(plugin => {
|
|
82
|
+
plugin.updateUser?.(body);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async api_updateLexicon(body) {
|
|
86
|
+
return this.plugins.forEach(plugin => {
|
|
87
|
+
plugin.updateLexicon?.(body);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
44
90
|
};
|
|
45
|
-
}
|
|
91
|
+
})();
|
|
46
92
|
export const ModuleBE_Analytics = new ModuleBE_Analytics_Class();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/analytics-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.500.0",
|
|
4
4
|
"description": "analytics Backend",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"scripts": {
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"linkDirectory": true
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@nu-art/analytics-shared": "0.
|
|
15
|
-
"@nu-art/ts-common": "0.
|
|
16
|
-
"@nu-art/
|
|
17
|
-
"@nu-art/firebase-
|
|
18
|
-
"@nu-art/
|
|
19
|
-
"@nu-art/
|
|
14
|
+
"@nu-art/analytics-shared": "0.500.0",
|
|
15
|
+
"@nu-art/ts-common": "0.500.0",
|
|
16
|
+
"@nu-art/db-api-backend": "0.500.0",
|
|
17
|
+
"@nu-art/firebase-backend": "0.500.0",
|
|
18
|
+
"@nu-art/firebase-shared": "0.500.0",
|
|
19
|
+
"@nu-art/http-server": "{{THUNDERSTORM_VERSION}}",
|
|
20
20
|
"mixpanel": "~0.18.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {},
|