Skip to content

Commit

Permalink
Merge pull request #20171 from strapi/fix/ee-not-extending-metrics
Browse files Browse the repository at this point in the history
fix: ee not being extended because no default export
  • Loading branch information
alexandrebodin committed Apr 23, 2024
2 parents 0e2e3db + ab53783 commit bbb5d9c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 21 deletions.
18 changes: 9 additions & 9 deletions packages/core/admin/ee/server/src/services/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ const sendUpdateProjectInformation = async () => {
}

if (EE.features.isEnabled('cms-content-releases')) {
const numberOfContentReleases = await strapi.entityService.count(
'plugin::content-releases.release'
);
const numberOfPublishedContentReleases = await strapi.entityService.count(
'plugin::content-releases.release',
{
filters: { $not: { releasedAt: null } },
}
);
const numberOfContentReleases = await strapi.db
.query('plugin::content-releases.release')
.count();

const numberOfPublishedContentReleases = await strapi.db
.query('plugin::content-releases.release')
.count({
filters: { releasedAt: { $notNull: true } },
});

groupProperties = assign(groupProperties, {
numberOfContentReleases,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/server/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default async ({ strapi }: { strapi: Strapi }) => {
await syncAuthSettings();
await syncAPITokensPermissions();

getService('metrics').sendUpdateProjectInformation();
await getService('metrics').sendUpdateProjectInformation();
getService('metrics').startCron(strapi);

apiTokenService.checkSaltIsDefined();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
sendDidInviteUser,
sendDidUpdateRolePermissions,
sendDidChangeInterfaceLanguage,
} from '../metrics';
import metrics from '../metrics';

describe('Metrics', () => {
test('sendDidInviteUser', async () => {
Expand All @@ -19,7 +15,7 @@ describe('Metrics', () => {
},
} as any;

await sendDidInviteUser();
await metrics.sendDidInviteUser();

expect(send).toHaveBeenCalledWith('didInviteUser', {
groupProperties: {
Expand All @@ -37,7 +33,7 @@ describe('Metrics', () => {
telemetry: { send },
} as any;

await sendDidUpdateRolePermissions();
await metrics.sendDidUpdateRolePermissions();

expect(send).toHaveBeenCalledWith('didUpdateRolePermissions');
});
Expand All @@ -55,7 +51,7 @@ describe('Metrics', () => {
},
} as any;

await sendDidChangeInterfaceLanguage();
await metrics.sendDidChangeInterfaceLanguage();

expect(getLanguagesInUse).toHaveBeenCalledWith();
expect(send).toHaveBeenCalledWith('didChangeInterfaceLanguage', {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/server/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import auth from './auth';
import user from './user';
import role from './role';
import passport from './passport';
import metrics from './metrics';
import * as token from './token';
import * as permission from './permission';
import * as metrics from './metrics';
import * as contentType from './content-type';
import * as constants from './constants';
import * as condition from './condition';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/server/src/services/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const startCron = (strapi: Strapi) => {
});
};

export {
export default {
sendDidInviteUser,
sendDidUpdateRolePermissions,
sendDidChangeInterfaceLanguage,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/server/src/utils/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import auth from '../services/auth';
import role from '../services/role';
import user from '../services/user';
import passport from '../services/passport';
import metrics from '../services/metrics';
import * as permission from '../services/permission';
import * as contentType from '../services/content-type';
import * as metrics from '../services/metrics';
import * as token from '../services/token';
import * as apiToken from '../services/api-token';
import * as projectSettings from '../services/project-settings';
Expand Down
1 change: 1 addition & 0 deletions packages/core/admin/strapi-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const mergeRoutes = (a, b, key) => {
if (strapi.EE) {
const eeAdmin = require('./dist/ee/server');
// module.exports = admin;
// TODO: change to avoid issue with lodash merging frozen objects
module.exports = _.mergeWith({}, admin, eeAdmin, mergeRoutes);
} else {
module.exports = admin;
Expand Down

0 comments on commit bbb5d9c

Please sign in to comment.