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

Add group analytics support #26

Merged
merged 4 commits into from
Oct 28, 2021
Merged

Add group analytics support #26

merged 4 commits into from
Oct 28, 2021

Conversation

macobo
Copy link
Contributor

@macobo macobo commented Oct 27, 2021

This PR:

To capture an event with groups:

PostHog::capture(array(
    'distinctId' => 'user:123',
    'event' => 'movie played',
    '$groups' => array("organization" => "id:5")
));

To update group properties:

PostHog::groupIdentify(array(
    'groupType' => 'organization',
    'groupKey' => 'id:5',
    'properties' => array("employees" => 11)
));

Tested manually + with unit tests.

@liyiy for group analytics change review
@yakkomajuri since this includes some library-level fixes

To capture an event with groups:

```php
PostHog::capture(array(
  'distinctId' => 'user:123',
  'event' => 'movie played',
  '$groups' => array("organization" => "id:5")
));
```

To update group properties:

```php
PostHog::groupIdentify(array(
  'groupType' => 'organization',
  'groupKey' => 'id:5',
  'properties' => array("employees" => 11)
));
```
"\n" .
"\n Usage:" .
"\n posthog --type capture --distinctId \"id\" --event \"event name\" --properties \"{ json: 'object' }\"" .
"\n posthog --type identify --distinctId \"id\" --properties \"{ json: 'object' }" .
"\n posthog --type capture --distinctId \"id\" --event \"event name\" --properties '{ \"json\": \"object\" }'" .
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm actually for just getting rid of the CLIs altogether - I think a lot of them are broken too.

Copy link
Contributor

Choose a reason for hiding this comment

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

not relevant here though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using the CLI was the only way I could test this though. Fixed what I found broken though

lib/PostHog.php Show resolved Hide resolved
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