@doreamonjs/plugin-analysis 0.3.12 → 0.3.15
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 +22 -9
- package/README.md +1 -9
- package/lib/model.js +21 -106
- package/lib/service.d.ts +2 -3
- package/lib/service.js +6 -5
- package/lib/types.d.ts +4 -22
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,36 +3,49 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [0.3.
|
|
6
|
+
## [0.3.15](https://github.com/doreamonjs/doreamon/compare/v0.3.14...v0.3.15) (2022-08-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* merge confict and clean changelog ([b5b0428](https://github.com/doreamonjs/doreamon/commit/b5b042803ef660e6c8faf214bd24fc27934deb91))
|
|
12
|
+
|
|
7
13
|
|
|
8
|
-
**Note:** Version bump only for package @doreamonjs/plugin-analysis
|
|
9
14
|
|
|
10
15
|
|
|
11
16
|
|
|
17
|
+
## [0.3.13](https://github.com/zcorky/zodash/compare/v0.3.12...v0.3.13) (2022-08-31)
|
|
12
18
|
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- plugin-authorization model + types ([7c4058c](https://github.com/doreamonjs/doreamon/commit/7c4058c47429eda26de6af08ce6b2d2a423f83c9))
|
|
22
|
+
|
|
23
|
+
## [0.3.12](https://github.com/doreamonjs/doreamon/compare/v0.3.11...v0.3.12) (2022-08-31)
|
|
24
|
+
|
|
25
|
+
**Note:** Version bump only for package @doreamonjs/plugin-analysis
|
|
13
26
|
|
|
14
|
-
## [0.3.3](https://github.com/
|
|
27
|
+
## [0.3.3](https://github.com/doreamonjs/doreamon/compare/v0.3.2...v0.3.3) (2022-08-30)
|
|
15
28
|
|
|
16
29
|
**Note:** Version bump only for package @doreamonjs/plugin-analysis
|
|
17
30
|
|
|
18
|
-
## [0.3.2](https://github.com/
|
|
31
|
+
## [0.3.2](https://github.com/doreamonjs/doreamon/compare/v0.3.1...v0.3.2) (2022-08-30)
|
|
19
32
|
|
|
20
33
|
### Bug Fixes
|
|
21
34
|
|
|
22
|
-
- dependencies ([60d97c5](https://github.com/
|
|
23
|
-
- package.json main and typings ([5a23e68](https://github.com/
|
|
35
|
+
- dependencies ([60d97c5](https://github.com/doreamonjs/doreamon/commit/60d97c5f857228f91bdbda6e833438559b3ea7d6))
|
|
36
|
+
- package.json main and typings ([5a23e68](https://github.com/doreamonjs/doreamon/commit/5a23e689ce467ddba1deeec674a8639fef3ba5a8))
|
|
24
37
|
|
|
25
38
|
# 0.3.0 (2022-08-30)
|
|
26
39
|
|
|
27
40
|
### Bug Fixes
|
|
28
41
|
|
|
29
|
-
- test ([ab09558](https://github.com/
|
|
42
|
+
- test ([ab09558](https://github.com/doreamonjs/doreamon/commit/ab0955886a268210cef6cbfe2a6b2362f6d826d6))
|
|
30
43
|
|
|
31
44
|
### Features
|
|
32
45
|
|
|
33
|
-
- add plugin-request/forms/analysiss ([7901413](https://github.com/
|
|
46
|
+
- add plugin-request/forms/analysiss ([7901413](https://github.com/doreamonjs/doreamon/commit/79014135cbae3337e5bf4c8372627f784ffe476e))
|
|
34
47
|
|
|
35
|
-
## [1.1.8](https://github.com/
|
|
48
|
+
## [1.1.8](https://github.com/doreamonjs/doreamon/compare/@zodash/get@1.1.7...@zodash/get@1.1.8) (2021-04-05)
|
|
36
49
|
|
|
37
50
|
**Note:** Version bump only for package @zodash/get
|
|
38
51
|
|
package/README.md
CHANGED
package/lib/model.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Model = void 0;
|
|
4
4
|
const doreamon_1 = require("@zodash/doreamon");
|
|
5
|
-
const service = require("@doreamonjs/plugin-service");
|
|
6
5
|
const constants_1 = require("./constants");
|
|
7
6
|
const service_1 = require("./service");
|
|
8
7
|
class Model {
|
|
@@ -19,123 +18,39 @@ class Model {
|
|
|
19
18
|
return constants_1.NAMESPACE;
|
|
20
19
|
}
|
|
21
20
|
build() {
|
|
21
|
+
const service = this.service;
|
|
22
22
|
return {
|
|
23
23
|
namespace: constants_1.NAMESPACE,
|
|
24
|
-
state: {
|
|
25
|
-
captcha: `/captcha?_t=${Date.now()}`,
|
|
26
|
-
},
|
|
24
|
+
state: {},
|
|
27
25
|
reducers: {
|
|
28
|
-
|
|
29
|
-
return {
|
|
26
|
+
save(state, { payload: config }) {
|
|
27
|
+
return {
|
|
28
|
+
...state,
|
|
29
|
+
config,
|
|
30
|
+
};
|
|
30
31
|
},
|
|
31
32
|
},
|
|
32
33
|
effects: {
|
|
33
|
-
*
|
|
34
|
-
|
|
34
|
+
*setup({ payload: config }, { put }) {
|
|
35
|
+
var _a;
|
|
36
|
+
yield put({ type: 'save', payload: config });
|
|
35
37
|
try {
|
|
36
|
-
|
|
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;
|
|
38
|
+
(_a = service.setup) === null || _a === void 0 ? void 0 : _a.call(service, config);
|
|
60
39
|
}
|
|
61
|
-
|
|
62
|
-
|
|
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;
|
|
40
|
+
catch (error) {
|
|
41
|
+
doreamon_1.default.logger.error('[model] analysis setup error', error);
|
|
81
42
|
}
|
|
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
43
|
},
|
|
88
|
-
*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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;
|
|
44
|
+
*track({ payload: { event, attributes } }, { select }) {
|
|
45
|
+
var _a;
|
|
46
|
+
// fix eslint: This generator function does not have 'yield' require-yield
|
|
47
|
+
yield select((state) => state[constants_1.NAMESPACE]);
|
|
48
|
+
try {
|
|
49
|
+
(_a = service.track) === null || _a === void 0 ? void 0 : _a.call(service, event, attributes);
|
|
120
50
|
}
|
|
121
|
-
|
|
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;
|
|
51
|
+
catch (error) {
|
|
52
|
+
doreamon_1.default.logger.error('[model] analysis track error', error);
|
|
134
53
|
}
|
|
135
|
-
yield put({
|
|
136
|
-
type: 'message/tip/success',
|
|
137
|
-
payload: '验证码发送成功,请查看邮箱',
|
|
138
|
-
});
|
|
139
54
|
},
|
|
140
55
|
},
|
|
141
56
|
};
|
package/lib/service.d.ts
CHANGED
package/lib/service.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Service = void 0;
|
|
4
4
|
const doreamon_1 = require("@zodash/doreamon");
|
|
5
5
|
const shared = require("@doreamonjs/plugin-shared");
|
|
6
|
+
const user = require("@doreamonjs/plugin-user");
|
|
6
7
|
const constants_1 = require("./constants");
|
|
7
8
|
class Service {
|
|
8
9
|
constructor() {
|
|
@@ -96,7 +97,7 @@ class Service {
|
|
|
96
97
|
return constants_1.NAMESPACE;
|
|
97
98
|
}
|
|
98
99
|
get user() {
|
|
99
|
-
return
|
|
100
|
+
return user.service.getCurrent();
|
|
100
101
|
}
|
|
101
102
|
async setup(config) {
|
|
102
103
|
var _a;
|
|
@@ -136,14 +137,14 @@ class Service {
|
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
async track(event, attributes) {
|
|
139
|
-
var _a;
|
|
140
|
+
var _a, _b, _c;
|
|
140
141
|
const userX = this.user;
|
|
141
142
|
const user = {
|
|
142
143
|
id: userX === null || userX === void 0 ? void 0 : userX.id,
|
|
143
144
|
nickname: userX === null || userX === void 0 ? void 0 : userX.nickname,
|
|
144
145
|
email: userX === null || userX === void 0 ? void 0 : userX.email,
|
|
145
|
-
open_id: userX === null ||
|
|
146
|
-
union_id: userX === null ||
|
|
146
|
+
open_id: (_a = userX) === null || _a === void 0 ? void 0 : _a.open_id,
|
|
147
|
+
union_id: (_b = userX) === null || _b === void 0 ? void 0 : _b.union_id,
|
|
147
148
|
};
|
|
148
149
|
try {
|
|
149
150
|
const config = this.config;
|
|
@@ -156,7 +157,7 @@ class Service {
|
|
|
156
157
|
await this.setup(this.config);
|
|
157
158
|
}
|
|
158
159
|
// this.sdks['thinkingdata']?.track(event, attributes)
|
|
159
|
-
const promises = (
|
|
160
|
+
const promises = (_c = config === null || config === void 0 ? void 0 : config.clients) === null || _c === void 0 ? void 0 : _c.map(async (client) => {
|
|
160
161
|
if (!(client === null || client === void 0 ? void 0 : client.provider))
|
|
161
162
|
return;
|
|
162
163
|
if (!this.sdks[client.provider]) {
|
package/lib/types.d.ts
CHANGED
|
@@ -1,25 +1,7 @@
|
|
|
1
1
|
export interface State {
|
|
2
|
-
|
|
3
|
-
attributes: Attributes;
|
|
4
|
-
datasets: Datasets;
|
|
5
|
-
queue: State[];
|
|
6
|
-
callback?: (err: Error | null, type: 'open' | 'close' | 'cancel' | 'ok', vallues?: any) => void;
|
|
2
|
+
clients: Client[];
|
|
7
3
|
}
|
|
8
|
-
export interface
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
description?: string;
|
|
12
|
-
cancelText?: string;
|
|
13
|
-
analysisText?: string;
|
|
14
|
-
target: AttributeTarget;
|
|
4
|
+
export interface Client {
|
|
5
|
+
provider: string;
|
|
6
|
+
config: any;
|
|
15
7
|
}
|
|
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/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doreamonjs/plugin-analysis",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"description": "analysis plugin for doreamonjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"doreamonjs",
|
|
7
7
|
"plugin"
|
|
8
8
|
],
|
|
9
|
-
"author": "
|
|
10
|
-
"homepage": "https://github.com/
|
|
9
|
+
"author": "whatwewant <tobewhatwewant@gmail.com>",
|
|
10
|
+
"homepage": "https://github.com/doreamonjs/doreamon#readme",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"main": "lib/index.js",
|
|
13
13
|
"typings": "lib/index.d.ts",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|
|
56
56
|
"type": "git",
|
|
57
|
-
"url": "git+https://github.com/
|
|
57
|
+
"url": "git+https://github.com/doreamonjs/doreamon.git"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsc",
|
|
@@ -62,11 +62,12 @@
|
|
|
62
62
|
"coverage": "codecov"
|
|
63
63
|
},
|
|
64
64
|
"bugs": {
|
|
65
|
-
"url": "https://github.com/
|
|
65
|
+
"url": "https://github.com/doreamonjs/doreamon/issues"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@doreamonjs/plugin-request": "^0.3.
|
|
69
|
-
"@doreamonjs/plugin-shared": "^0.3.
|
|
68
|
+
"@doreamonjs/plugin-request": "^0.3.15",
|
|
69
|
+
"@doreamonjs/plugin-shared": "^0.3.15",
|
|
70
|
+
"@doreamonjs/plugin-user": "^0.3.15",
|
|
70
71
|
"@sentry/browser": "^7.11.1",
|
|
71
72
|
"@sentry/tracing": "^7.11.1",
|
|
72
73
|
"@zcorky/delay": "^1.0.1",
|
|
@@ -77,5 +78,5 @@
|
|
|
77
78
|
"mixpanel-browser": "^2.45.0",
|
|
78
79
|
"thinkingdata-browser": "^1.6.0"
|
|
79
80
|
},
|
|
80
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "1c8a50e361f15a083ca5edd02dafa22dffca196a"
|
|
81
82
|
}
|