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

fix: Introduce Event::fromArray #25

Closed
wants to merge 3 commits into from

Conversation

ruudk
Copy link

@ruudk ruudk commented Sep 5, 2024

This makes it possible to reconstruct an Event from an array.

This is required when you want to track assignments asynchronously.

This makes it possible to reconstruct an Event from an array.

This is required when you want to track assignments asynchronously.
@ruudk
Copy link
Author

ruudk commented Sep 5, 2024

@bgiori Please approve the workflow.

@tyiuhc tyiuhc changed the title Introduce Event::fromArray fix: Introduce Event::fromArray Sep 9, 2024
@tyiuhc
Copy link
Collaborator

tyiuhc commented Sep 9, 2024

@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
Copy link
Collaborator

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);
    }

Copy link
Author

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.

@tyiuhc
Copy link
Collaborator

tyiuhc commented Sep 10, 2024

@ruudk Many thanks for your input and comments on this issue. Event::fromArray is now available in v1.1.0

@ruudk
Copy link
Author

ruudk commented Sep 10, 2024

Thanks!

@ruudk ruudk closed this Sep 10, 2024
@ruudk ruudk deleted the ruudk/2024/9/from-array branch September 10, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants