PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
20.73k stars 1.24k forks source link

Groups list does not show group when group has no properties #7746

Open EDsCODE opened 2 years ago

EDsCODE commented 2 years ago

Currently, posthog.group(type, id) doesn't create a group unless a property is set because we prevent groupidentify from being emitted if there are no properties set.

It's unclear from our docs that you need to send properties in order for the group to show up on the list of groups page

macobo commented 2 years ago

Clarified the title a bit and moved it under the main repo.

To answer the first half: .group calls in posthog-js without setting any properties does:

  1. Set groups information on subsequent events
  2. Does not send us any properties for the group

We don't create the group objects until we receive properties for them. This is to avoid overloading the db - equivelent logic for persons takes up majority of work/load of plugin-server and is hard to scale, and we'd potentially be 6x-ing that.

You're right we don't communicate this well. For now I think we should:

  1. Add this under limitations under group analytics docs - will handle today! Done
  2. Communicate this in the group pages

@clarkus I'd like to recruit your help for (2). How could we make it clear on the group list page that only groups with properties are shown?

Two options pop to mind: a. Add a tooltip next to the table header here outlining the limitation image b. Rephrasing the empty state to indicate that only groups with properties are shown.

venkatd commented 7 months ago

Hi folks, I would suggest adding some help text or a tip there or at least in the docs. I lost an hour trying to debug why groups weren't showing up during implementation.

Edit: just realized there was a note in the docs! One idea would be to update the sample code to include a property to ensure that it shows up while someone is test-driving groups:

posthog.group('company', 'company_id_in_your_db', {name: 'ACME'});
// For this session, any event captured after calling `posthog.group` will be associated with company `company_id_on_your_db`
posthog.capture('user_signed_up')

When I am going through tutorials I tend to skim and copy/paste code quickly to get something up and running.

ShubhamPalriwala commented 7 months ago

Hey folks, We have been using Posthog actively and are now integrating the Teams feature!

I have the below node-sdk in place:

    client.capture({
      event: eventName,
      distinctId: userId,
      groups: { environment: environmentId },
      properties,
    });

My issue is that, a group is not visible in the dashboard unless it has a property set! And to set a property, as per my knowledge, I need to call the below:

    client.groupIdentify({
      groupType: "environment",
      groupKey: environmentId,
      properties: {
        name: teamName,
      },
    });

Now I need to combine both to make it work which results in net 2x the number of calls I make to posthog! Is there a cleaner way to achieve this functionality?