d145684966
Refactored the code to introduce two different concepts: - AuditLogs (immutable, raw data) - TimelineActivities (user-friendly, transformed data) Still some work needed: - Add message, files, calendar events to timeline (~2 hours if done naively) - Refactor repository to try to abstract concept when we can (tbd, wait for Twenty ORM) - Introduce ability to display child timelines on parent timeline with filtering (~2 days) - Improve UI: add links to open note/task, improve diff display, etc (half a day) - Decide the path forward for Task vs Notes: either introduce a new field type "Record Type" and start going into that direction ; or split in two objects? - Trigger updates when a field is changed (will be solved by real-time / websockets: 2 weeks) - Integrate behavioral events (1 day for POC, 1 week for clean/documented) <img width="1248" alt="Screenshot 2024-04-12 at 09 24 49" src="https://github.com/twentyhq/twenty/assets/6399865/9428db1a-ab2b-492c-8b0b-d4d9a36e81fa">
91 lines
3.1 KiB
TypeScript
91 lines
3.1 KiB
TypeScript
import { FeatureFlagKeys } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
|
|
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
|
import { behavioralEventStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
|
import { standardObjectIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
|
|
import { FieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/field-metadata.decorator';
|
|
import { Gate } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/gate.decorator';
|
|
import { IsNullable } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-nullable.decorator';
|
|
import { IsSystem } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-system.decorator';
|
|
import { ObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/object-metadata.decorator';
|
|
import { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
|
|
|
|
@ObjectMetadata({
|
|
standardId: standardObjectIds.behavioralEvent,
|
|
namePlural: 'behavioralEvents',
|
|
labelSingular: 'Behavioral Event',
|
|
labelPlural: 'Behavioral Events',
|
|
description: 'An event related to user behavior',
|
|
icon: 'IconIconTimelineEvent',
|
|
})
|
|
@IsSystem()
|
|
@Gate({
|
|
featureFlag: FeatureFlagKeys.IsEventObjectEnabled,
|
|
})
|
|
export class BehavioralEventObjectMetadata extends BaseObjectMetadata {
|
|
/**
|
|
*
|
|
* Common in Segment, Rudderstack, etc.
|
|
* = Track, Screen, Page...
|
|
* But doesn't feel that useful.
|
|
* Let's try living without it.
|
|
*
|
|
@FieldMetadata({
|
|
standardId: behavioralEventStandardFieldIds.type,
|
|
type: FieldMetadataType.TEXT,
|
|
label: 'Event type',
|
|
description: 'Event type',
|
|
icon: 'IconAbc',
|
|
})
|
|
type: string;
|
|
*/
|
|
|
|
@FieldMetadata({
|
|
standardId: behavioralEventStandardFieldIds.name,
|
|
type: FieldMetadataType.TEXT,
|
|
label: 'Event name',
|
|
description: 'Event name',
|
|
icon: 'IconAbc',
|
|
})
|
|
name: string;
|
|
|
|
@FieldMetadata({
|
|
standardId: behavioralEventStandardFieldIds.properties,
|
|
type: FieldMetadataType.RAW_JSON,
|
|
label: 'Event details',
|
|
description: 'Json value for event details',
|
|
icon: 'IconListDetails',
|
|
})
|
|
@IsNullable()
|
|
properties: JSON;
|
|
|
|
@FieldMetadata({
|
|
standardId: behavioralEventStandardFieldIds.context,
|
|
type: FieldMetadataType.RAW_JSON,
|
|
label: 'Event context',
|
|
description:
|
|
'Json object to provide context (user, device, workspace, etc.)',
|
|
icon: 'IconListDetails',
|
|
})
|
|
@IsNullable()
|
|
context: JSON;
|
|
|
|
@FieldMetadata({
|
|
standardId: behavioralEventStandardFieldIds.objectName,
|
|
type: FieldMetadataType.TEXT,
|
|
label: 'Object name',
|
|
description: 'If the event is related to a particular object',
|
|
icon: 'IconAbc',
|
|
})
|
|
objectName: string;
|
|
|
|
@FieldMetadata({
|
|
standardId: behavioralEventStandardFieldIds.recordId,
|
|
type: FieldMetadataType.UUID,
|
|
label: 'Object id',
|
|
description: 'Event name/type',
|
|
icon: 'IconAbc',
|
|
})
|
|
@IsNullable()
|
|
recordId: string;
|
|
}
|