Skip to content

Commit

Permalink
Improve support worksapce (#6360)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
  • Loading branch information
kristina-fefelova authored Aug 23, 2024
1 parent 0fe88a8 commit ae60ab3
Show file tree
Hide file tree
Showing 57 changed files with 1,140 additions and 425 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
"request": "launch",
"args": ["src/index.ts"],
"env": {
"PORT": "4077",
"PORT": "4007",
"SECRET": "secret",
"MONGO_URL": "mongodb://localhost:27017",
"MINIO_ENDPOINT": "localhost",
Expand Down
62 changes: 59 additions & 3 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
"@hcengineering/products-resources": "^0.1.0",
"@hcengineering/analytics-collector": "^0.6.0",
"@hcengineering/analytics-collector-assets": "^0.6.0",
"@hcengineering/analytics-collector-resources": "^0.6.0",
"electron-squirrel-startup": "~1.0.0",
"dotenv": "~16.0.0",
"electron-context-menu": "^4.0.1",
Expand Down
1 change: 1 addition & 0 deletions desktop/src/ui/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export async function configurePlatform (): Promise<void> {
addLocation(notificationId, async () => await import('@hcengineering/notification-resources'))
addLocation(tagsId, async () => await import('@hcengineering/tags-resources'))
addLocation(calendarId, async () => await import('@hcengineering/calendar-resources'))
addLocation(analyticsCollectorId, async () => await import('@hcengineering/analytics-collector-resources'))

addLocation(trackerId, async () => await import('@hcengineering/tracker-resources'))
addLocation(boardId, async () => await import('@hcengineering/board-resources'))
Expand Down
4 changes: 2 additions & 2 deletions dev/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ services:
- GITHUB_URL=http://localhost:3500
- PRINT_URL=http://localhost:4005
- SIGN_URL=http://localhost:4006
- ANALYTICS_COLLECTOR_URL=http://localhost:4077
- ANALYTICS_COLLECTOR_URL=http://localhost:4007
- DESKTOP_UPDATES_URL=https://dist.huly.io
- DESKTOP_UPDATES_CHANNEL=dev
- BRANDING_URL=http://localhost:8087/branding.json
Expand Down Expand Up @@ -200,7 +200,7 @@ services:
image: hardcoreeng/analytics-collector
restart: unless-stopped
ports:
- 4077:4007
- 4007:4007
environment:
- SECRET=secret
- PORT=4007
Expand Down
4 changes: 2 additions & 2 deletions dev/local-mongo/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ services:
- GITHUB_URL=http://localhost:3500
- PRINT_URL=http://localhost:4005
- SIGN_URL=http://localhost:4006
- ANALYTICS_COLLECTOR_URL=http://localhost:4077
- ANALYTICS_COLLECTOR_URL=http://localhost:4007
- DESKTOP_UPDATES_URL=https://dist.huly.io
- DESKTOP_UPDATES_CHANNEL=dev
- BRANDING_URL=http://localhost:8087/branding.json
Expand Down Expand Up @@ -187,7 +187,7 @@ services:
image: hardcoreeng/analytics-collector
restart: unless-stopped
ports:
- 4077:4007
- 4007:4007
environment:
- SECRET=secret
- PORT=4007
Expand Down
1 change: 1 addition & 0 deletions dev/prod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
"@hcengineering/uploader-resources": "^0.6.0",
"@hcengineering/analytics-collector": "^0.6.0",
"@hcengineering/analytics-collector-assets": "^0.6.0",
"@hcengineering/analytics-collector-resources": "^0.6.0",
"@hcengineering/controlled-documents": "^0.1.0",
"@hcengineering/controlled-documents-assets": "^0.1.0",
"@hcengineering/controlled-documents-resources": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion dev/prod/public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"LAST_NAME_FIRST": "true",
"PRINT_URL": "http://localhost:4005",
"SIGN_URL": "http://localhost:4006",
"ANALYTICS_COLLECTOR_URL": "http://localhost:4077",
"ANALYTICS_COLLECTOR_URL": "http://localhost:4007",
"BRANDING_URL": "/branding.json",
"VERSION": null,
"MODEL_VERSION": null
Expand Down
1 change: 1 addition & 0 deletions dev/prod/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ export async function configurePlatform() {
addLocation(diffviewId, () => import(/* webpackChunkName: "diffview" */ '@hcengineering/diffview-resources'))
addLocation(timeId, () => import(/* webpackChunkName: "time" */ '@hcengineering/time-resources'))
addLocation(desktopPreferencesId, () => import(/* webpackChunkName: "desktop-preferences" */ '@hcengineering/desktop-preferences-resources'))
addLocation(analyticsCollectorId, async () => await import('@hcengineering/analytics-collector-resources'))

addLocation(trackerId, () => import(/* webpackChunkName: "tracker" */ '@hcengineering/tracker-resources'))
addLocation(boardId, () => import(/* webpackChunkName: "board" */ '@hcengineering/board-resources'))
Expand Down
12 changes: 11 additions & 1 deletion models/all/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ export default function buildModel (enabled: string[] = ['*'], disabled: string[
[uploaderModel, uploaderId],
[notificationModel, notificationId],
[preferenceModel, preferenceId],
[
analyticsCollectorModel,
analyticsCollectorId,
{
label: inventory.string.ConfigLabel,
description: inventory.string.ConfigDescription,
enabled: false,
beta: false,
classFilter: defaultFilter
}
],
[
hrModel,
hrId,
Expand Down Expand Up @@ -348,7 +359,6 @@ export default function buildModel (enabled: string[] = ['*'], disabled: string[
}
],
[printModel, printId],
[analyticsCollectorModel, analyticsCollectorId],
[driveModel, driveId],
[
documentsModel,
Expand Down
7 changes: 4 additions & 3 deletions models/analytics-collector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@hcengineering/activity": "^0.6.0",
"@hcengineering/analytics-collector": "^0.6.0",
"@hcengineering/attachment": "^0.6.14",
"@hcengineering/chunter": "^0.6.20",
"@hcengineering/core": "^0.6.32",
"@hcengineering/model": "^0.6.11",
"@hcengineering/model-activity": "^0.6.0",
"@hcengineering/model-notification": "^0.6.0",
"@hcengineering/model-chunter": "^0.6.0",
"@hcengineering/model-core": "^0.6.0",
"@hcengineering/model-notification": "^0.6.0",
"@hcengineering/model-view": "^0.6.0",
"@hcengineering/platform": "^0.6.11",
"@hcengineering/ui": "^0.6.15",
"@hcengineering/view": "^0.6.13",
"@hcengineering/analytics-collector": "^0.6.0"
"@hcengineering/view": "^0.6.13"
}
}
70 changes: 63 additions & 7 deletions models/analytics-collector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,79 @@
// limitations under the License.
//

import { type Builder, Mixin } from '@hcengineering/model'
import { type AnalyticsChannel } from '@hcengineering/analytics-collector'
import { type Builder, Model, Prop, ReadOnly, TypeString, UX } from '@hcengineering/model'
import { type OnboardingChannel } from '@hcengineering/analytics-collector'
import chunter from '@hcengineering/chunter'
import { TChannel } from '@hcengineering/model-chunter'
import activity, { type ActivityMessageControl } from '@hcengineering/activity'
import core from '@hcengineering/core'

import analyticsCollector from './plugin'

export { analyticsCollectorId } from '@hcengineering/analytics-collector'
export { analyticsCollectorOperation } from './migration'
export default analyticsCollector

@Mixin(analyticsCollector.mixin.AnalyticsChannel, chunter.class.Channel)
export class TAnalyticsChannel extends TChannel implements AnalyticsChannel {
workspace!: string
email!: string
@Model(analyticsCollector.class.OnboardingChannel, chunter.class.Channel)
@UX(
analyticsCollector.string.OnboardingChannel,
chunter.icon.Hashtag,
undefined,
undefined,
undefined,
analyticsCollector.string.OnboardingChannels
)
export class TOnboardingChannel extends TChannel implements OnboardingChannel {
@Prop(TypeString(), analyticsCollector.string.UserName)
@ReadOnly()
userName!: string

@Prop(TypeString(), analyticsCollector.string.Email)
@ReadOnly()
email!: string

@Prop(TypeString(), analyticsCollector.string.WorkspaceName)
@ReadOnly()
workspaceName!: string

@Prop(TypeString(), analyticsCollector.string.WorkspaceUrl)
@ReadOnly()
workspaceUrl!: string

@Prop(TypeString(), analyticsCollector.string.WorkspaceId)
@ReadOnly()
workspaceId!: string
}

export function createModel (builder: Builder): void {
builder.createModel(TAnalyticsChannel)
builder.createModel(TOnboardingChannel)

builder.createDoc(activity.class.ActivityExtension, core.space.Model, {
ofClass: analyticsCollector.class.OnboardingChannel,
components: { input: chunter.component.ChatMessageInput }
})

builder.createDoc<ActivityMessageControl<OnboardingChannel>>(
activity.class.ActivityMessageControl,
core.space.Model,
{
objectClass: analyticsCollector.class.OnboardingChannel,
skip: [
{ _class: core.class.TxMixin },
{ _class: core.class.TxCreateDoc, objectClass: { $ne: analyticsCollector.class.OnboardingChannel } },
{ _class: core.class.TxRemoveDoc }
],
allowedFields: ['members']
}
)

builder.createDoc(activity.class.DocUpdateMessageViewlet, core.space.Model, {
objectClass: analyticsCollector.class.OnboardingChannel,
action: 'update',
config: {
members: {
presenter: chunter.activity.MembersChangedMessage
}
}
})
}
14 changes: 6 additions & 8 deletions models/analytics-collector/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ import {
type MigrationUpgradeClient,
tryMigrate
} from '@hcengineering/model'
import analyticsCollector, { analyticsCollectorId } from '@hcengineering/analytics-collector'
import { analyticsCollectorId } from '@hcengineering/analytics-collector'
import { DOMAIN_SPACE } from '@hcengineering/model-core'
import { DOMAIN_DOC_NOTIFY, DOMAIN_NOTIFICATION } from '@hcengineering/model-notification'
import { DOMAIN_ACTIVITY } from '@hcengineering/model-activity'

async function removeAnalyticsChannels (client: MigrationClient): Promise<void> {
const channels = await client.find(DOMAIN_SPACE, {
[`${analyticsCollector.mixin.AnalyticsChannel}`]: { $exists: true }
})
async function removeOnboardingChannels (client: MigrationClient): Promise<void> {
const channels = await client.find(DOMAIN_SPACE, { 'analytics:mixin:AnalyticsChannel': { $exists: true } })

if (channels.length === 0) {
return
Expand All @@ -40,15 +38,15 @@ async function removeAnalyticsChannels (client: MigrationClient): Promise<void>
await client.deleteMany(DOMAIN_ACTIVITY, { attachedTo: { $in: channelsIds } })
await client.deleteMany(DOMAIN_NOTIFICATION, { docNotifyContext: { $in: contextsIds } })
await client.deleteMany(DOMAIN_DOC_NOTIFY, { _id: { $in: contextsIds } })
await client.deleteMany(DOMAIN_SPACE, { [`${analyticsCollector.mixin.AnalyticsChannel}`]: { $exists: true } })
await client.deleteMany(DOMAIN_SPACE, { _id: { $in: channelsIds } })
}

export const analyticsCollectorOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {
await tryMigrate(client, analyticsCollectorId, [
{
state: 'remove-analytics-channels-v1',
func: removeAnalyticsChannels
state: 'remove-analytics-channels-v3',
func: removeOnboardingChannels
}
])
},
Expand Down
Loading

0 comments on commit ae60ab3

Please sign in to comment.