Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6071 return only updated fields of records in zapier update trigger #8193

Conversation

martmull
Copy link
Contributor

@martmull martmull commented Oct 30, 2024

  • move webhook triggers into entity-events-to-db.listener.ts
  • refactor event management
  • add a @OnDatabaseEvent decorator to manage database events
  • add updatedFields in updated events
  • update openApi webhooks docs
  • update zapier integration

@martmull martmull linked an issue Oct 30, 2024 that may be closed by this pull request
@martmull martmull force-pushed the 6071-return-only-updated-fields-of-records-in-zapier-update-trigger branch 2 times, most recently from c31f079 to a4b5524 Compare October 31, 2024 13:25
@martmull martmull force-pushed the 6071-return-only-updated-fields-of-records-in-zapier-update-trigger branch from a4b5524 to a9f36df Compare October 31, 2024 19:56
Copy link

github-actions bot commented Nov 4, 2024

Warnings
⚠️

Changes were made to package.json, but not to yarn.lock - Perhaps you need to run yarn install?

Generated by 🚫 dangerJS against 34441d8

let newOperation = webhook.operation;
let newOpe = webhook.operation;

newOpe = newOpe.replace(/\bcreate\b(?=\.|$)/g, 'created');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bit surprise about \b operator. shouldn't it be ^ (start with) direclty?
Not a problem just curious about this \b operator which is not super usual in regex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i will update that, I just used the chatgpt -> 101 validated REGEX

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might work with ^but it has sense

updatedFields,
diff,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok why not adding the diff to the event api

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by "event api"?


@Injectable()
export class EntityEventsToDbListener {
constructor(
@InjectMessageQueue(MessageQueue.entityEventsToDbQueue)
private readonly messageQueueService: MessageQueueService,
private readonly entityEventsToDbQueueService: MessageQueueService,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entity is not a valid term anymore.

entity is either ObjectRecord (aka Record) or ObjectMetadata (aka Object when confusion is not possible)
Also in this particular case, why not keeping messageQueueService, it's the first time we have a service not having the same name as its class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because they are different, either injected by @InjectMessageQueue(MessageQueue.entityEventsToDbQueue) or @InjectMessageQueue(MessageQueue.webhookQueue)

@@ -195,7 +196,7 @@ export class CreateCompanyAndContactService {
);

this.workspaceEventEmitter.emit(
'person.created',
`person.${DatabaseEventAction.CREATED}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the usage it looks a bit verbose to use the enum. I wonder if a string literal wouldn't provide a better DX

https://claritydev.net/blog/typescript-type-literals-practical-use-cases-code-quality

I think it's more elegant but might be individual opinion, don't want to force it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verbose I agree, but far more clear than a type that checks string ends with .created in my opinion

@@ -1,6 +1,6 @@
{
"name": "twenty-zapier",
"version": "1.0.2",
"version": "2.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.0 ? :p should we follow the twenty versions for now: 0.32.0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a breaking change update, so I need to update X in X.Y.Z

@martmull martmull force-pushed the 6071-return-only-updated-fields-of-records-in-zapier-update-trigger branch from f069c5c to 34441d8 Compare November 4, 2024 15:45
Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@charlesBochet charlesBochet merged commit 6959918 into main Nov 4, 2024
19 checks passed
@charlesBochet charlesBochet deleted the 6071-return-only-updated-fields-of-records-in-zapier-update-trigger branch November 4, 2024 16:44
charlesBochet pushed a commit that referenced this pull request Nov 12, 2024
Fixes bug introduced in #8193

Taking into account linked event name `linked-{eventName}` as before
issue

## Before
`linked-created` and `linked-updated` activity targets were not created
in `timelineActivity` table

## After
`linked-created` and `linked-updated` activity targets are created in
`timelineActivity` table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return only updated fields of records in zapier update trigger
2 participants