@strapi/strapi 4.5.2 → 4.5.4
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/lib/Strapi.js +7 -4
- package/lib/commands/opt-in-telemetry.js +2 -2
- package/lib/commands/opt-out-telemetry.js +2 -2
- package/lib/core/domain/content-type/index.js +1 -1
- package/lib/services/entity-service/index.js +16 -10
- package/lib/services/entity-validator/index.js +38 -30
- package/lib/services/metrics/admin-user-hash.js +15 -0
- package/lib/services/metrics/index.js +6 -4
- package/lib/services/metrics/middleware.js +1 -1
- package/lib/services/metrics/sender.js +17 -9
- package/lib/utils/success.js +1 -1
- package/package.json +15 -15
package/lib/Strapi.js
CHANGED
|
@@ -242,11 +242,14 @@ class Strapi {
|
|
|
242
242
|
sendStartupTelemetry() {
|
|
243
243
|
// Emit started event.
|
|
244
244
|
// do not await to avoid slower startup
|
|
245
|
+
// This event is anonymous
|
|
245
246
|
this.telemetry.send('didStartServer', {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
groupProperties: {
|
|
248
|
+
database: strapi.config.get('database.connection.client'),
|
|
249
|
+
plugins: Object.keys(strapi.plugins),
|
|
250
|
+
// TODO: to add back
|
|
251
|
+
// providers: this.config.installedProviders,
|
|
252
|
+
},
|
|
250
253
|
});
|
|
251
254
|
}
|
|
252
255
|
|
|
@@ -53,12 +53,12 @@ const generateNewPackageJSON = (packageObj) => {
|
|
|
53
53
|
|
|
54
54
|
const sendEvent = async (uuid) => {
|
|
55
55
|
try {
|
|
56
|
-
await fetch('https://analytics.strapi.io/track', {
|
|
56
|
+
await fetch('https://analytics.strapi.io/api/v2/track', {
|
|
57
57
|
method: 'POST',
|
|
58
58
|
body: JSON.stringify({
|
|
59
59
|
event: 'didOptInTelemetry',
|
|
60
|
-
uuid,
|
|
61
60
|
deviceId: machineID(),
|
|
61
|
+
groupProperties: { projectId: uuid },
|
|
62
62
|
}),
|
|
63
63
|
headers: { 'Content-Type': 'application/json' },
|
|
64
64
|
});
|
|
@@ -28,12 +28,12 @@ const writePackageJSON = async (path, file, spacing) => {
|
|
|
28
28
|
|
|
29
29
|
const sendEvent = async (uuid) => {
|
|
30
30
|
try {
|
|
31
|
-
await fetch('https://analytics.strapi.io/track', {
|
|
31
|
+
await fetch('https://analytics.strapi.io/api/v2/track', {
|
|
32
32
|
method: 'POST',
|
|
33
33
|
body: JSON.stringify({
|
|
34
34
|
event: 'didOptOutTelemetry',
|
|
35
|
-
uuid,
|
|
36
35
|
deviceId: machineID(),
|
|
36
|
+
groupProperties: { projectId: uuid },
|
|
37
37
|
}),
|
|
38
38
|
headers: { 'Content-Type': 'application/json' },
|
|
39
39
|
});
|
|
@@ -54,7 +54,7 @@ const createContentType = (uid, definition) => {
|
|
|
54
54
|
});
|
|
55
55
|
} else {
|
|
56
56
|
throw new Error(
|
|
57
|
-
`Incorrect Content Type UID "${uid}". The UID should start with api::, plugin:: or
|
|
57
|
+
`Incorrect Content Type UID "${uid}". The UID should start with api::, plugin:: or admin::.`
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -134,17 +134,20 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|
|
134
134
|
// TODO: wrap into transaction
|
|
135
135
|
const componentData = await createComponents(uid, validData);
|
|
136
136
|
|
|
137
|
+
const entityData = creationPipeline(
|
|
138
|
+
Object.assign(omitComponentData(model, validData), componentData),
|
|
139
|
+
{
|
|
140
|
+
contentType: model,
|
|
141
|
+
}
|
|
142
|
+
);
|
|
137
143
|
let entity = await db.query(uid).create({
|
|
138
144
|
...query,
|
|
139
|
-
data:
|
|
140
|
-
contentType: model,
|
|
141
|
-
}),
|
|
145
|
+
data: entityData,
|
|
142
146
|
});
|
|
143
147
|
|
|
144
148
|
// TODO: upload the files then set the links in the entity like with compo to avoid making too many queries
|
|
145
|
-
// FIXME: upload in components
|
|
146
149
|
if (files && Object.keys(files).length > 0) {
|
|
147
|
-
await this.uploadFiles(uid, entity, files);
|
|
150
|
+
await this.uploadFiles(uid, Object.assign(entityData, entity), files);
|
|
148
151
|
entity = await this.findOne(uid, entity.id, wrappedParams);
|
|
149
152
|
}
|
|
150
153
|
|
|
@@ -180,19 +183,22 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|
|
180
183
|
|
|
181
184
|
// TODO: wrap in transaction
|
|
182
185
|
const componentData = await updateComponents(uid, entityToUpdate, validData);
|
|
186
|
+
const entityData = updatePipeline(
|
|
187
|
+
Object.assign(omitComponentData(model, validData), componentData),
|
|
188
|
+
{
|
|
189
|
+
contentType: model,
|
|
190
|
+
}
|
|
191
|
+
);
|
|
183
192
|
|
|
184
193
|
let entity = await db.query(uid).update({
|
|
185
194
|
...query,
|
|
186
195
|
where: { id: entityId },
|
|
187
|
-
data:
|
|
188
|
-
contentType: model,
|
|
189
|
-
}),
|
|
196
|
+
data: entityData,
|
|
190
197
|
});
|
|
191
198
|
|
|
192
199
|
// TODO: upload the files then set the links in the entity like with compo to avoid making too many queries
|
|
193
|
-
// FIXME: upload in components
|
|
194
200
|
if (files && Object.keys(files).length > 0) {
|
|
195
|
-
await this.uploadFiles(uid, entity, files);
|
|
201
|
+
await this.uploadFiles(uid, Object.assign(entityData, entity), files);
|
|
196
202
|
entity = await this.findOne(uid, entity.id, wrappedParams);
|
|
197
203
|
}
|
|
198
204
|
|
|
@@ -293,40 +293,48 @@ const buildRelationsStore = ({ uid, data }) => {
|
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
case 'component': {
|
|
296
|
-
return castArray(value).reduce(
|
|
297
|
-
(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
296
|
+
return castArray(value).reduce((relationsStore, componentValue) => {
|
|
297
|
+
if (!attribute.component) {
|
|
298
|
+
throw new ValidationError(
|
|
299
|
+
`Cannot build relations store from component, component identifier is undefined`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return mergeWith(
|
|
304
|
+
relationsStore,
|
|
305
|
+
buildRelationsStore({
|
|
306
|
+
uid: attribute.component,
|
|
307
|
+
data: componentValue,
|
|
308
|
+
}),
|
|
309
|
+
(objValue, srcValue) => {
|
|
310
|
+
if (isArray(objValue)) {
|
|
311
|
+
return objValue.concat(srcValue);
|
|
308
312
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
);
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
}, result);
|
|
312
316
|
}
|
|
313
317
|
case 'dynamiczone': {
|
|
314
|
-
return value.reduce(
|
|
315
|
-
(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
318
|
+
return value.reduce((relationsStore, dzValue) => {
|
|
319
|
+
if (!dzValue.__component) {
|
|
320
|
+
throw new ValidationError(
|
|
321
|
+
`Cannot build relations store from dynamiczone, component identifier is undefined`
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return mergeWith(
|
|
326
|
+
relationsStore,
|
|
327
|
+
buildRelationsStore({
|
|
328
|
+
uid: dzValue.__component,
|
|
329
|
+
data: dzValue,
|
|
330
|
+
}),
|
|
331
|
+
(objValue, srcValue) => {
|
|
332
|
+
if (isArray(objValue)) {
|
|
333
|
+
return objValue.concat(srcValue);
|
|
326
334
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
);
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
}, result);
|
|
330
338
|
}
|
|
331
339
|
default:
|
|
332
340
|
break;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const crypto = require('crypto');
|
|
4
|
+
|
|
5
|
+
const generateAdminUserHash = () => {
|
|
6
|
+
const ctx = strapi?.requestContext?.get();
|
|
7
|
+
if (!ctx?.state?.user) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
return crypto.createHash('sha256').update(ctx.state.user.email).digest('hex');
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
generateAdminUserHash,
|
|
15
|
+
};
|
|
@@ -55,10 +55,12 @@ const createTelemetryInstance = (strapi) => {
|
|
|
55
55
|
return sendEvent(
|
|
56
56
|
'didCheckLicense',
|
|
57
57
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
groupProperties: {
|
|
59
|
+
licenseInfo: {
|
|
60
|
+
...ee.licenseInfo,
|
|
61
|
+
projectHash: hashProject(strapi),
|
|
62
|
+
dependencyHash: hashDep(strapi),
|
|
63
|
+
},
|
|
62
64
|
},
|
|
63
65
|
},
|
|
64
66
|
{
|
|
@@ -19,7 +19,7 @@ const createMiddleware = ({ sendEvent }) => {
|
|
|
19
19
|
|
|
20
20
|
// Send max. 1000 events per day.
|
|
21
21
|
if (_state.counter < 1000) {
|
|
22
|
-
sendEvent('didReceiveRequest', { url: ctx.request.url });
|
|
22
|
+
sendEvent('didReceiveRequest', { eventProperties: { url: ctx.request.url } });
|
|
23
23
|
|
|
24
24
|
// Increase counter.
|
|
25
25
|
_state.counter += 1;
|
|
@@ -10,7 +10,7 @@ const { isUsingTypeScriptSync } = require('@strapi/typescript-utils');
|
|
|
10
10
|
const { env } = require('@strapi/utils');
|
|
11
11
|
const ee = require('../../utils/ee');
|
|
12
12
|
const machineID = require('../../utils/machine-id');
|
|
13
|
-
const
|
|
13
|
+
const { generateAdminUserHash } = require('./admin-user-hash');
|
|
14
14
|
|
|
15
15
|
const defaultQueryOpts = {
|
|
16
16
|
timeout: 1000,
|
|
@@ -42,41 +42,49 @@ module.exports = (strapi) => {
|
|
|
42
42
|
const serverRootPath = strapi.dirs.app.root;
|
|
43
43
|
const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const anonymousUserProperties = {
|
|
46
46
|
environment: strapi.config.environment,
|
|
47
47
|
os: os.type(),
|
|
48
48
|
osPlatform: os.platform(),
|
|
49
49
|
osArch: os.arch(),
|
|
50
50
|
osRelease: os.release(),
|
|
51
51
|
nodeVersion: process.versions.node,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const anonymousGroupProperties = {
|
|
52
55
|
docker: process.env.DOCKER || isDocker(),
|
|
53
56
|
isCI: ciEnv.isCI,
|
|
54
57
|
version: strapi.config.get('info.strapi'),
|
|
55
58
|
projectType: isEE ? 'Enterprise' : 'Community',
|
|
56
59
|
useTypescriptOnServer: isUsingTypeScriptSync(serverRootPath),
|
|
57
60
|
useTypescriptOnAdmin: isUsingTypeScriptSync(adminRootPath),
|
|
61
|
+
projectId: uuid,
|
|
58
62
|
isHostedOnStrapiCloud: env('STRAPI_HOSTING', null) === 'strapi.cloud',
|
|
59
63
|
};
|
|
60
64
|
|
|
61
|
-
addPackageJsonStrapiMetadata(
|
|
65
|
+
addPackageJsonStrapiMetadata(anonymousGroupProperties, strapi);
|
|
62
66
|
|
|
63
67
|
return async (event, payload = {}, opts = {}) => {
|
|
68
|
+
const userId = generateAdminUserHash();
|
|
69
|
+
|
|
64
70
|
const reqParams = {
|
|
65
71
|
method: 'POST',
|
|
66
72
|
body: JSON.stringify({
|
|
67
73
|
event,
|
|
68
|
-
|
|
74
|
+
userId,
|
|
69
75
|
deviceId,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
eventProperties: payload.eventProperties,
|
|
77
|
+
userProperties: userId ? { ...anonymousUserProperties, ...payload.userProperties } : {},
|
|
78
|
+
groupProperties: {
|
|
79
|
+
...anonymousGroupProperties,
|
|
80
|
+
...payload.groupProperties,
|
|
81
|
+
},
|
|
74
82
|
}),
|
|
75
83
|
..._.merge({}, defaultQueryOpts, opts),
|
|
76
84
|
};
|
|
77
85
|
|
|
78
86
|
try {
|
|
79
|
-
const res = await fetch(`${ANALYTICS_URI}/track`, reqParams);
|
|
87
|
+
const res = await fetch(`${ANALYTICS_URI}/api/v2/track`, reqParams);
|
|
80
88
|
return res.ok;
|
|
81
89
|
} catch (err) {
|
|
82
90
|
return false;
|
package/lib/utils/success.js
CHANGED
|
@@ -17,7 +17,7 @@ try {
|
|
|
17
17
|
process.env.npm_config_global === 'true' ||
|
|
18
18
|
JSON.parse(process.env.npm_config_argv).original.includes('global')
|
|
19
19
|
) {
|
|
20
|
-
fetch('https://analytics.strapi.io/track', {
|
|
20
|
+
fetch('https://analytics.strapi.io/api/v2/track', {
|
|
21
21
|
method: 'POST',
|
|
22
22
|
body: JSON.stringify({
|
|
23
23
|
event: 'didInstallStrapi',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.4",
|
|
4
4
|
"description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -80,18 +80,18 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@koa/cors": "3.4.3",
|
|
82
82
|
"@koa/router": "10.1.1",
|
|
83
|
-
"@strapi/admin": "4.5.
|
|
84
|
-
"@strapi/database": "4.5.
|
|
85
|
-
"@strapi/generate-new": "4.5.
|
|
86
|
-
"@strapi/generators": "4.5.
|
|
87
|
-
"@strapi/logger": "4.5.
|
|
88
|
-
"@strapi/permissions": "4.5.
|
|
89
|
-
"@strapi/plugin-content-manager": "4.5.
|
|
90
|
-
"@strapi/plugin-content-type-builder": "4.5.
|
|
91
|
-
"@strapi/plugin-email": "4.5.
|
|
92
|
-
"@strapi/plugin-upload": "4.5.
|
|
93
|
-
"@strapi/typescript-utils": "4.5.
|
|
94
|
-
"@strapi/utils": "4.5.
|
|
83
|
+
"@strapi/admin": "4.5.4",
|
|
84
|
+
"@strapi/database": "4.5.4",
|
|
85
|
+
"@strapi/generate-new": "4.5.4",
|
|
86
|
+
"@strapi/generators": "4.5.4",
|
|
87
|
+
"@strapi/logger": "4.5.4",
|
|
88
|
+
"@strapi/permissions": "4.5.4",
|
|
89
|
+
"@strapi/plugin-content-manager": "4.5.4",
|
|
90
|
+
"@strapi/plugin-content-type-builder": "4.5.4",
|
|
91
|
+
"@strapi/plugin-email": "4.5.4",
|
|
92
|
+
"@strapi/plugin-upload": "4.5.4",
|
|
93
|
+
"@strapi/typescript-utils": "4.5.4",
|
|
94
|
+
"@strapi/utils": "4.5.4",
|
|
95
95
|
"bcryptjs": "2.4.3",
|
|
96
96
|
"boxen": "5.1.2",
|
|
97
97
|
"chalk": "4.1.2",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"cli-table3": "0.6.2",
|
|
101
101
|
"commander": "8.2.0",
|
|
102
102
|
"configstore": "5.0.1",
|
|
103
|
-
"debug": "4.3.
|
|
103
|
+
"debug": "4.3.4",
|
|
104
104
|
"delegates": "1.0.0",
|
|
105
105
|
"dotenv": "10.0.0",
|
|
106
106
|
"execa": "5.1.1",
|
|
@@ -140,5 +140,5 @@
|
|
|
140
140
|
"node": ">=14.19.1 <=18.x.x",
|
|
141
141
|
"npm": ">=6.0.0"
|
|
142
142
|
},
|
|
143
|
-
"gitHead": "
|
|
143
|
+
"gitHead": "8716ecc920130db5341b0904cf868c6e6b581a5d"
|
|
144
144
|
}
|