-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: Introduce Event::fromArray #25
Conversation
This makes it possible to reconstruct an Event from an array. This is required when you want to track assignments asynchronously.
@bgiori Please approve the workflow. |
Many thanks for raising this issue! The workflow has been approved |
} | ||
|
||
/** | ||
* @return array<string, mixed> | ||
* @return Payload | ||
*/ | ||
public function toArray(): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested update:
public function toArray(): array
{
return array_filter([
'event_type' => $this->eventType,
'event_properties' => $this->eventProperties,
'user_properties' => $this->userProperties,
'user_id' => $this->userId,
'device_id' => $this->deviceId,
'insert_id' => $this->insertId,
'time' => $this->time,
], fn($value) => $value !== null);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you don't pass a callable to array_filter, it does filter anything that is null. So there is no point in providing this callable, as it does the same, but only being explicit.
@ruudk Many thanks for your input and comments on this issue. |
Thanks! |
This makes it possible to reconstruct an Event from an array.
This is required when you want to track assignments asynchronously.