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

Possibility to "accumulate" properties ? #27

Open
allan-simon opened this issue Nov 4, 2021 · 3 comments
Open

Possibility to "accumulate" properties ? #27

allan-simon opened this issue Nov 4, 2021 · 3 comments

Comments

@allan-simon
Copy link

I would like to use posthog in a symfony php application , due to the it's architectured I would like to do the following

  1. when the "User" constructed to set some of his properties in posthog internal state (the same as the ::init() will save the api key)
  2. Later in some place where it's not convenient to access the user object to be able to capture events with the pre-saved user properties

is it something possible to do ?

@pauldambra
Copy link
Member

pauldambra commented Nov 4, 2021

Hi Allan,

Do the properties need to remain only in state on the client?

Could you call

PostHog::identify(array(
  'distinctId' => 'user:123',
  'properties' => array(
    'theInformation' => 'I want to save',
  )
));

And then call the API to query for events by property

e.g. to find events where a custom person is as above you would call

https://app.posthog.com/api/projects/2/events/?properties=[{"key":"theInformation","value":["I want to save"],"operator":"exact","type":"person"}]&orderBy=["-timestamp"]

Would that work for you?

@allan-simon
Copy link
Author

thanks your remark permitted me to refine my problem

the main problem i face is I may call PostHog::capture in some place where having the user:123 is not easily accessible so regardless if i was able to do identify with most of properties set at this moment. I would be missing the "distinctId" that permits to link the event to that user

so yes my problem is more "Could it be possible to tell posthog to keep a 'current distinct id' "

@pauldambra
Copy link
Member

pauldambra commented Nov 4, 2021

Hmm, that's how the JS SDK works...

If I make a call to identify and then on the same device make a call to capture

Screenshot 2021-11-04 at 22 46 06

I can see that the captured event is from an identified user

Screenshot 2021-11-04 at 22 47 45

We link the two together so we know the event comes from the user

I'm completely new to the PHP library, and don't know symfony at all.

Is the problem that Symfony is stopping that happening, or that the PHP library doesn't do it?

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

No branches or pull requests

2 participants