@doreamonjs/plugin-analysis 0.3.12
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 +41 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +8 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +17 -0
- package/lib/instance.d.ts +4 -0
- package/lib/instance.js +7 -0
- package/lib/model.d.ts +12 -0
- package/lib/model.js +147 -0
- package/lib/service.d.ts +18 -0
- package/lib/service.js +185 -0
- package/lib/types.d.ts +25 -0
- package/lib/types.js +2 -0
- package/package.json +81 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [0.3.12](https://github.com/zcorky/zodash/compare/v0.3.11...v0.3.12) (2022-08-31)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @doreamonjs/plugin-analysis
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.3.3](https://github.com/zcorky/zodash/compare/v0.3.2...v0.3.3) (2022-08-30)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @doreamonjs/plugin-analysis
|
|
17
|
+
|
|
18
|
+
## [0.3.2](https://github.com/zcorky/zodash/compare/v0.3.1...v0.3.2) (2022-08-30)
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
- dependencies ([60d97c5](https://github.com/zcorky/zodash/commit/60d97c5f857228f91bdbda6e833438559b3ea7d6))
|
|
23
|
+
- package.json main and typings ([5a23e68](https://github.com/zcorky/zodash/commit/5a23e689ce467ddba1deeec674a8639fef3ba5a8))
|
|
24
|
+
|
|
25
|
+
# 0.3.0 (2022-08-30)
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
- test ([ab09558](https://github.com/zcorky/zodash/commit/ab0955886a268210cef6cbfe2a6b2362f6d826d6))
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- add plugin-request/forms/analysiss ([7901413](https://github.com/zcorky/zodash/commit/79014135cbae3337e5bf4c8372627f784ffe476e))
|
|
34
|
+
|
|
35
|
+
## [1.1.8](https://github.com/zcorky/zodash/compare/@zodash/get@1.1.7...@zodash/get@1.1.8) (2021-04-05)
|
|
36
|
+
|
|
37
|
+
**Note:** Version bump only for package @zodash/get
|
|
38
|
+
|
|
39
|
+
## 1.1.7 (2021-04-05)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @zodash/get
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Eason
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/lib/constants.js
ADDED
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./types"), exports);
|
|
14
|
+
__exportStar(require("./constants"), exports);
|
|
15
|
+
__exportStar(require("./model"), exports);
|
|
16
|
+
__exportStar(require("./service"), exports);
|
|
17
|
+
__exportStar(require("./instance"), exports);
|
package/lib/instance.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.service = exports.model = void 0;
|
|
4
|
+
const model_1 = require("./model");
|
|
5
|
+
const service_1 = require("./service");
|
|
6
|
+
exports.model = new model_1.Model();
|
|
7
|
+
exports.service = new service_1.Service();
|
package/lib/model.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Model as DvaModel } from 'dva';
|
|
2
|
+
export interface ModelOptions {
|
|
3
|
+
}
|
|
4
|
+
export declare class Model {
|
|
5
|
+
readonly options?: ModelOptions;
|
|
6
|
+
private _service;
|
|
7
|
+
constructor(options?: ModelOptions);
|
|
8
|
+
private get service();
|
|
9
|
+
get namespace(): string;
|
|
10
|
+
build(): DvaModel;
|
|
11
|
+
toDva(): DvaModel;
|
|
12
|
+
}
|
package/lib/model.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Model = void 0;
|
|
4
|
+
const doreamon_1 = require("@zodash/doreamon");
|
|
5
|
+
const service = require("@doreamonjs/plugin-service");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
const service_1 = require("./service");
|
|
8
|
+
class Model {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
}
|
|
12
|
+
get service() {
|
|
13
|
+
if (!this._service) {
|
|
14
|
+
this._service = new service_1.Service();
|
|
15
|
+
}
|
|
16
|
+
return this._service;
|
|
17
|
+
}
|
|
18
|
+
get namespace() {
|
|
19
|
+
return constants_1.NAMESPACE;
|
|
20
|
+
}
|
|
21
|
+
build() {
|
|
22
|
+
return {
|
|
23
|
+
namespace: constants_1.NAMESPACE,
|
|
24
|
+
state: {
|
|
25
|
+
captcha: `/captcha?_t=${Date.now()}`,
|
|
26
|
+
},
|
|
27
|
+
reducers: {
|
|
28
|
+
'captcha/save'(state, { payload: captcha }) {
|
|
29
|
+
return { ...state, captcha };
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
effects: {
|
|
33
|
+
*login({ payload: { username, password, captcha }, done }, { race, call, put }) {
|
|
34
|
+
yield call(doreamon_1.default.delay, 1000);
|
|
35
|
+
try {
|
|
36
|
+
const { timeout } = yield race({
|
|
37
|
+
data: call(service.authorization.login.bind(service.authorization.login), username, password, captcha),
|
|
38
|
+
timeout: call(doreamon_1.default.delay, 10000),
|
|
39
|
+
});
|
|
40
|
+
if (timeout) {
|
|
41
|
+
yield put({
|
|
42
|
+
type: 'message/tip/error',
|
|
43
|
+
payload: '服务器开小差啦',
|
|
44
|
+
});
|
|
45
|
+
done();
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
yield put({ type: 'refresh/captcha' });
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
// @TODO hack clear captcha
|
|
53
|
+
const node = document.querySelector('input#captcha');
|
|
54
|
+
if (node) {
|
|
55
|
+
node.value = '';
|
|
56
|
+
}
|
|
57
|
+
}, 0);
|
|
58
|
+
done();
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
yield call(doreamon_1.default.delay, 1000);
|
|
62
|
+
// router change
|
|
63
|
+
// @TODO should support redirect
|
|
64
|
+
const query = doreamon_1.default.qs.parse(window.location.search);
|
|
65
|
+
const redirect = query.redirect || '/';
|
|
66
|
+
window.location.href = redirect;
|
|
67
|
+
},
|
|
68
|
+
*logout(action, { select, race, call, put }) {
|
|
69
|
+
// @TODO request call backend api
|
|
70
|
+
const { username } = yield select((state) => state.user.values);
|
|
71
|
+
const { timeout } = yield race({
|
|
72
|
+
data: call(service.authorization.logout.bind(service.authorization), username),
|
|
73
|
+
timeout: call(doreamon_1.default.delay, 10000),
|
|
74
|
+
});
|
|
75
|
+
if (timeout) {
|
|
76
|
+
yield put({
|
|
77
|
+
type: 'message/tip/error',
|
|
78
|
+
payload: '服务器开小差啦',
|
|
79
|
+
});
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
// solution @2
|
|
83
|
+
// const currentPath = window.location.pathname;
|
|
84
|
+
// window.location.href = `/login?redirect=${encodeURIComponent(currentPath)}`;
|
|
85
|
+
const currentPath = window.location.pathname;
|
|
86
|
+
window.location.href = `/logout?from=${encodeURIComponent(currentPath)}`;
|
|
87
|
+
},
|
|
88
|
+
*register({ payload }, { race, call, put }) {
|
|
89
|
+
const { username, password, confirmPassword, captcha } = payload;
|
|
90
|
+
const { data, timeout } = yield race({
|
|
91
|
+
data: call(service.authorization.register.bind(service.authorization), username, password, confirmPassword, captcha),
|
|
92
|
+
timeout: call(doreamon_1.default.delay, 10000),
|
|
93
|
+
});
|
|
94
|
+
if (timeout) {
|
|
95
|
+
yield put({
|
|
96
|
+
type: 'message/tip/error',
|
|
97
|
+
payload: '服务器开小差啦',
|
|
98
|
+
});
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
yield put({
|
|
102
|
+
type: 'message/tip/success',
|
|
103
|
+
payload: '注册成功, 正在跳转登陆界面...',
|
|
104
|
+
});
|
|
105
|
+
yield call(doreamon_1.default.delay, 1000);
|
|
106
|
+
window.location.href = '/';
|
|
107
|
+
},
|
|
108
|
+
// login
|
|
109
|
+
*'refresh/captcha'(action, { race, call, put }) {
|
|
110
|
+
const { data, timeout } = yield race({
|
|
111
|
+
data: call(service.authorization.captcha.bind(service.authorization)),
|
|
112
|
+
timeout: call(doreamon_1.default.delay, 10000),
|
|
113
|
+
});
|
|
114
|
+
if (timeout) {
|
|
115
|
+
yield put({
|
|
116
|
+
type: 'message/tip/error',
|
|
117
|
+
payload: '服务器开小差啦',
|
|
118
|
+
});
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
yield put({ type: 'captcha/save', payload: data.url });
|
|
122
|
+
},
|
|
123
|
+
*'send/captcha/to/email_or_other'({ payload: { username } }, { race, call, put }) {
|
|
124
|
+
const { timeout } = yield race({
|
|
125
|
+
data: call(service.authorization.sendCaptchaToEmailOrOther.bind(service.authorization), username),
|
|
126
|
+
timeout: call(doreamon_1.default.delay, 10000),
|
|
127
|
+
});
|
|
128
|
+
if (timeout) {
|
|
129
|
+
yield put({
|
|
130
|
+
type: 'message/tip/error',
|
|
131
|
+
payload: '服务器开小差啦',
|
|
132
|
+
});
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
yield put({
|
|
136
|
+
type: 'message/tip/success',
|
|
137
|
+
payload: '验证码发送成功,请查看邮箱',
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
toDva() {
|
|
144
|
+
return this.build();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.Model = Model;
|
package/lib/service.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface ServiceConfig {
|
|
2
|
+
clients: AnalysisClient[];
|
|
3
|
+
}
|
|
4
|
+
interface AnalysisClient {
|
|
5
|
+
provider: string;
|
|
6
|
+
config: any;
|
|
7
|
+
}
|
|
8
|
+
export declare class Service {
|
|
9
|
+
private logger;
|
|
10
|
+
private config;
|
|
11
|
+
private isInitialized;
|
|
12
|
+
get namespace(): string;
|
|
13
|
+
private get user();
|
|
14
|
+
private sdks;
|
|
15
|
+
setup(config: ServiceConfig): Promise<void>;
|
|
16
|
+
track(event: string, attributes?: any): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
package/lib/service.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Service = void 0;
|
|
4
|
+
const doreamon_1 = require("@zodash/doreamon");
|
|
5
|
+
const shared = require("@doreamonjs/plugin-shared");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
class Service {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.logger = shared.logger.getLogger(constants_1.NAMESPACE);
|
|
10
|
+
this.config = null;
|
|
11
|
+
this.isInitialized = false;
|
|
12
|
+
this.sdks = {
|
|
13
|
+
thinkingdata: {
|
|
14
|
+
setup: async (config) => {
|
|
15
|
+
const thinkingdata = await Promise.resolve().then(() => require('thinkingdata-browser'));
|
|
16
|
+
thinkingdata.init(config);
|
|
17
|
+
return thinkingdata;
|
|
18
|
+
},
|
|
19
|
+
track: (instance, event, attributes) => {
|
|
20
|
+
instance === null || instance === void 0 ? void 0 : instance.track(event, attributes);
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
'google-analytics': {
|
|
24
|
+
setup: async (config) => {
|
|
25
|
+
if (!(config === null || config === void 0 ? void 0 : config.id)) {
|
|
26
|
+
this.logger.error('google-analytics config id missing');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
window.dataLayer = window.dataLayer || [];
|
|
30
|
+
const gtag = (window.gtag = function gtag(...args) {
|
|
31
|
+
window.dataLayer.push(args);
|
|
32
|
+
});
|
|
33
|
+
gtag('js', new Date());
|
|
34
|
+
gtag('config', config === null || config === void 0 ? void 0 : config.id);
|
|
35
|
+
await doreamon_1.default.fs.loadJs('https://www.googletagmanager.com/gtag/js?id=' + (config === null || config === void 0 ? void 0 : config.id));
|
|
36
|
+
return {
|
|
37
|
+
gtag,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
track: (instance, event, attributes) => {
|
|
41
|
+
instance === null || instance === void 0 ? void 0 : instance.gtag(event, attributes);
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
sentry: {
|
|
45
|
+
setup: async (config) => {
|
|
46
|
+
var _a;
|
|
47
|
+
if (!(config === null || config === void 0 ? void 0 : config.dsn)) {
|
|
48
|
+
this.logger.error('sentry config dsn missing');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const Sentry = await Promise.resolve().then(() => require('@sentry/browser'));
|
|
52
|
+
const SentryTracing = await Promise.resolve().then(() => require('@sentry/tracing'));
|
|
53
|
+
// await doreamon.fs.loadJs('https://browser.sentry-cdn.com/5.26.0/bundle.tracing.min.js', {
|
|
54
|
+
// integrity: 'sha384-o3PmxWd0Sgy+qiulNfK/K+YxK4Neya0uoBhAdI1YCdS6yuHZM7vN8v9r0cBDmQ9K',
|
|
55
|
+
// crossorigin: 'anonymous',
|
|
56
|
+
// });
|
|
57
|
+
window.Sentry = Sentry;
|
|
58
|
+
window.SentryTracing = SentryTracing;
|
|
59
|
+
window.Sentry.init({
|
|
60
|
+
integrations: [new SentryTracing.BrowserTracing()],
|
|
61
|
+
//
|
|
62
|
+
dsn: config.dsn,
|
|
63
|
+
// We recommend adjusting this value in production, or using tracesSampler
|
|
64
|
+
// for finer control
|
|
65
|
+
tracesSampleRate: (_a = config.tracesSampleRate) !== null && _a !== void 0 ? _a : 1.0,
|
|
66
|
+
//
|
|
67
|
+
release: config.release,
|
|
68
|
+
});
|
|
69
|
+
return Sentry;
|
|
70
|
+
},
|
|
71
|
+
track: (instance, event, attributes) => {
|
|
72
|
+
// ignore,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
mixpanel: {
|
|
76
|
+
setup: async (config) => {
|
|
77
|
+
if (!(config === null || config === void 0 ? void 0 : config.id)) {
|
|
78
|
+
this.logger.error('mixpanel config id missing');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const { default: Mixpanel } = await Promise.resolve().then(() => require('mixpanel-browser'));
|
|
82
|
+
window.Mixpanel = Mixpanel;
|
|
83
|
+
window.Mixpanel.init(config.id, {
|
|
84
|
+
debug: config.debug,
|
|
85
|
+
});
|
|
86
|
+
return Mixpanel;
|
|
87
|
+
},
|
|
88
|
+
track: (instance, event, attributes) => {
|
|
89
|
+
var _a;
|
|
90
|
+
(_a = instance === null || instance === void 0 ? void 0 : instance.track) === null || _a === void 0 ? void 0 : _a.call(instance, event, attributes);
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
get namespace() {
|
|
96
|
+
return constants_1.NAMESPACE;
|
|
97
|
+
}
|
|
98
|
+
get user() {
|
|
99
|
+
return window.doreamon_sdk.user.getCurrent();
|
|
100
|
+
}
|
|
101
|
+
async setup(config) {
|
|
102
|
+
var _a;
|
|
103
|
+
try {
|
|
104
|
+
if (this.isInitialized)
|
|
105
|
+
return;
|
|
106
|
+
this.isInitialized = true;
|
|
107
|
+
if (!config) {
|
|
108
|
+
this.logger.error('analysis config missing');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.config = config;
|
|
112
|
+
if (!config) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// this.sdks['thinkingdata']?.track(event, attributes)
|
|
116
|
+
const promises = (_a = config === null || config === void 0 ? void 0 : config.clients) === null || _a === void 0 ? void 0 : _a.map(async (client) => {
|
|
117
|
+
if (!(client === null || client === void 0 ? void 0 : client.provider))
|
|
118
|
+
return;
|
|
119
|
+
if (!this.sdks[client.provider]) {
|
|
120
|
+
this.logger.error(`unsupport provider: ${client.provider}`);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const wrapper = this.sdks[client.provider];
|
|
124
|
+
if (!wrapper.isInitialized) {
|
|
125
|
+
// this.logger.info(`initialize provider: ${client.provider}`);
|
|
126
|
+
wrapper.instance = await wrapper.setup(client.config);
|
|
127
|
+
wrapper.isInitialized = true;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
if (promises) {
|
|
131
|
+
await Promise.all(promises);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
this.logger.error('setup error: ', error);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async track(event, attributes) {
|
|
139
|
+
var _a;
|
|
140
|
+
const userX = this.user;
|
|
141
|
+
const user = {
|
|
142
|
+
id: userX === null || userX === void 0 ? void 0 : userX.id,
|
|
143
|
+
nickname: userX === null || userX === void 0 ? void 0 : userX.nickname,
|
|
144
|
+
email: userX === null || userX === void 0 ? void 0 : userX.email,
|
|
145
|
+
open_id: userX === null || userX === void 0 ? void 0 : userX.open_id,
|
|
146
|
+
union_id: userX === null || userX === void 0 ? void 0 : userX.union_id,
|
|
147
|
+
};
|
|
148
|
+
try {
|
|
149
|
+
const config = this.config;
|
|
150
|
+
if (!this.config) {
|
|
151
|
+
this.logger.error('should not run analysis track before setup');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
// @TODO
|
|
155
|
+
if (!this.isInitialized) {
|
|
156
|
+
await this.setup(this.config);
|
|
157
|
+
}
|
|
158
|
+
// this.sdks['thinkingdata']?.track(event, attributes)
|
|
159
|
+
const promises = (_a = config === null || config === void 0 ? void 0 : config.clients) === null || _a === void 0 ? void 0 : _a.map(async (client) => {
|
|
160
|
+
if (!(client === null || client === void 0 ? void 0 : client.provider))
|
|
161
|
+
return;
|
|
162
|
+
if (!this.sdks[client.provider]) {
|
|
163
|
+
this.logger.error(`unsupport provider: ${client.provider}`);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const wrapper = this.sdks[client.provider];
|
|
167
|
+
wrapper.track.apply(null, [
|
|
168
|
+
wrapper.instance,
|
|
169
|
+
event,
|
|
170
|
+
{
|
|
171
|
+
user,
|
|
172
|
+
attributes,
|
|
173
|
+
},
|
|
174
|
+
]);
|
|
175
|
+
});
|
|
176
|
+
if (promises) {
|
|
177
|
+
await Promise.all(promises);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
this.logger.error('track error: ', error);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.Service = Service;
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface State {
|
|
2
|
+
visible: boolean;
|
|
3
|
+
attributes: Attributes;
|
|
4
|
+
datasets: Datasets;
|
|
5
|
+
queue: State[];
|
|
6
|
+
callback?: (err: Error | null, type: 'open' | 'close' | 'cancel' | 'ok', vallues?: any) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface Attributes {
|
|
9
|
+
type?: 'modal' | 'drawer';
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
cancelText?: string;
|
|
13
|
+
analysisText?: string;
|
|
14
|
+
target: AttributeTarget;
|
|
15
|
+
}
|
|
16
|
+
export interface Datasets {
|
|
17
|
+
origin: object;
|
|
18
|
+
values: object;
|
|
19
|
+
}
|
|
20
|
+
export interface AttributeTarget {
|
|
21
|
+
namespace: string;
|
|
22
|
+
effect: string;
|
|
23
|
+
props: any;
|
|
24
|
+
}
|
|
25
|
+
export declare type Type = 'modal' | 'drawer';
|
package/lib/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@doreamonjs/plugin-analysis",
|
|
3
|
+
"version": "0.3.12",
|
|
4
|
+
"description": "analysis plugin for doreamonjs",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"doreamonjs",
|
|
7
|
+
"plugin"
|
|
8
|
+
],
|
|
9
|
+
"author": "zero <tobewhatwewant@gmail.com>",
|
|
10
|
+
"homepage": "https://github.com/zcorky/zodash#readme",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"main": "lib/index.js",
|
|
13
|
+
"typings": "lib/index.d.ts",
|
|
14
|
+
"directories": {
|
|
15
|
+
"lib": "lib"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"lib"
|
|
19
|
+
],
|
|
20
|
+
"jest": {
|
|
21
|
+
"roots": [
|
|
22
|
+
"__tests__"
|
|
23
|
+
],
|
|
24
|
+
"transform": {
|
|
25
|
+
"^.+\\.tsx?$": "ts-jest"
|
|
26
|
+
},
|
|
27
|
+
"testRegex": ".*\\.(spec|test)\\.(ts|tsx)$",
|
|
28
|
+
"moduleDirectories": [
|
|
29
|
+
"node_modules",
|
|
30
|
+
"src"
|
|
31
|
+
],
|
|
32
|
+
"moduleFileExtensions": [
|
|
33
|
+
"ts",
|
|
34
|
+
"tsx",
|
|
35
|
+
"js",
|
|
36
|
+
"jsx"
|
|
37
|
+
],
|
|
38
|
+
"coverageDirectory": "./coverage/",
|
|
39
|
+
"collectCoverage": true,
|
|
40
|
+
"collectCoverageFrom": [
|
|
41
|
+
"src/**/*.{ts,tsx}"
|
|
42
|
+
],
|
|
43
|
+
"coverageThreshold": {
|
|
44
|
+
"global": {
|
|
45
|
+
"branches": 60,
|
|
46
|
+
"functions": 60,
|
|
47
|
+
"lines": 60,
|
|
48
|
+
"statements": -10
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "git+https://github.com/zcorky/zodash.git"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsc",
|
|
61
|
+
"test": "jest -w 1",
|
|
62
|
+
"coverage": "codecov"
|
|
63
|
+
},
|
|
64
|
+
"bugs": {
|
|
65
|
+
"url": "https://github.com/zcorky/zodash/issues"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@doreamonjs/plugin-request": "^0.3.2",
|
|
69
|
+
"@doreamonjs/plugin-shared": "^0.3.12",
|
|
70
|
+
"@sentry/browser": "^7.11.1",
|
|
71
|
+
"@sentry/tracing": "^7.11.1",
|
|
72
|
+
"@zcorky/delay": "^1.0.1",
|
|
73
|
+
"@zcorky/query-string": "^1.0.2",
|
|
74
|
+
"@zodash/doreamon": "^1.0.17",
|
|
75
|
+
"dva": "^2.4.1",
|
|
76
|
+
"immer": "^9.0.15",
|
|
77
|
+
"mixpanel-browser": "^2.45.0",
|
|
78
|
+
"thinkingdata-browser": "^1.6.0"
|
|
79
|
+
},
|
|
80
|
+
"gitHead": "efeb8d0d8b1e496c165164fbb4f9508c65ee21d9"
|
|
81
|
+
}
|