mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
Change location of user creation analytics call, remove development console log, adjust tests accordingly
This commit is contained in:
parent
b5c98ae0cd
commit
a2ee4bb855
@ -51,6 +51,7 @@ describe('User Controller', () => {
|
||||
const exists = jest.fn(() => Promise.resolve(false));
|
||||
const sanitizeUser = jest.fn((user) => Promise.resolve(user));
|
||||
const created = jest.fn();
|
||||
const sendDidInviteUser = jest.fn();
|
||||
const state = {
|
||||
user: {
|
||||
id: 1,
|
||||
@ -67,6 +68,9 @@ describe('User Controller', () => {
|
||||
create,
|
||||
sanitizeUser,
|
||||
},
|
||||
metrics: {
|
||||
sendDidInviteUser,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -74,9 +78,10 @@ describe('User Controller', () => {
|
||||
await userController.create(ctx);
|
||||
|
||||
expect(exists).toHaveBeenCalledWith({ email: body.email });
|
||||
expect(create).toHaveBeenCalledWith(body, ctx.state.user);
|
||||
expect(create).toHaveBeenCalledWith(body);
|
||||
expect(sanitizeUser).toHaveBeenCalled();
|
||||
expect(created).toHaveBeenCalled();
|
||||
expect(sendDidInviteUser).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -32,7 +32,9 @@ module.exports = {
|
||||
throw new ApplicationError('Email already taken');
|
||||
}
|
||||
|
||||
const createdUser = await getService('user').create(attributes, ctx.state?.user);
|
||||
const createdUser = await getService('user').create(attributes);
|
||||
|
||||
getService('metrics').sendDidInviteUser(ctx.state?.user);
|
||||
|
||||
const userInfo = getService('user').sanitizeUser(createdUser);
|
||||
|
||||
|
||||
@ -28,7 +28,6 @@ describe('User', () => {
|
||||
|
||||
describe('create', () => {
|
||||
const count = jest.fn(() => Promise.resolve(1));
|
||||
const sendDidInviteUser = jest.fn();
|
||||
|
||||
test('Creates a user by merging given and default attributes', async () => {
|
||||
const create = jest.fn(({ data }) => Promise.resolve(data));
|
||||
@ -41,7 +40,6 @@ describe('User', () => {
|
||||
token: { createToken },
|
||||
auth: { hashPassword },
|
||||
role: { count },
|
||||
metrics: { sendDidInviteUser },
|
||||
},
|
||||
},
|
||||
query() {
|
||||
@ -70,7 +68,6 @@ describe('User', () => {
|
||||
token: { createToken },
|
||||
auth: { hashPassword },
|
||||
role: { count },
|
||||
metrics: { sendDidInviteUser },
|
||||
},
|
||||
},
|
||||
query() {
|
||||
@ -112,7 +109,6 @@ describe('User', () => {
|
||||
token: { createToken },
|
||||
auth: { hashPassword },
|
||||
role: { count },
|
||||
metrics: { sendDidInviteUser },
|
||||
},
|
||||
},
|
||||
query() {
|
||||
|
||||
@ -27,7 +27,7 @@ const sanitizeUser = (user) => {
|
||||
* @param attributes A partial user object
|
||||
* @returns {Promise<user>}
|
||||
*/
|
||||
const create = async (attributes, adminUser) => {
|
||||
const create = async (attributes) => {
|
||||
const userInfo = {
|
||||
registrationToken: getService('token').createToken(),
|
||||
...attributes,
|
||||
@ -41,8 +41,6 @@ const create = async (attributes, adminUser) => {
|
||||
|
||||
const createdUser = await strapi.query('admin::user').create({ data: user, populate: ['roles'] });
|
||||
|
||||
getService('metrics').sendDidInviteUser(adminUser);
|
||||
|
||||
return createdUser;
|
||||
};
|
||||
|
||||
|
||||
@ -226,7 +226,6 @@ class Strapi {
|
||||
}
|
||||
|
||||
sendStartupTelemetry() {
|
||||
console.log(this);
|
||||
// Emit started event.
|
||||
// do not await to avoid slower startup
|
||||
// This event is anonymous
|
||||
|
||||
@ -19,7 +19,7 @@ const createMiddleware = ({ sendEvent }) => {
|
||||
|
||||
// Send max. 1000 events per day.
|
||||
if (_state.counter < 1000) {
|
||||
sendEvent('', 'didReceiveRequest', { url: ctx.request.url });
|
||||
sendEvent('didReceiveRequest', { eventProperties: { url: ctx.request.url } });
|
||||
|
||||
// Increase counter.
|
||||
_state.counter++;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user