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

Ability to set user on javascript #27

Open
gknedo opened this issue Mar 22, 2018 · 7 comments
Open

Ability to set user on javascript #27

gknedo opened this issue Mar 22, 2018 · 7 comments

Comments

@gknedo
Copy link

gknedo commented Mar 22, 2018

If the API ins't running on the same server i couldn't found a way to track the user of the action

@ankane
Copy link
Owner

ankane commented Mar 22, 2018

There's no way to do this right now, but happy to accept a PR (will need to get it added to Ahoy Ruby project as well). Maybe something like:

ahoy.setUserId(1);

@gknedo
Copy link
Author

gknedo commented Mar 24, 2018

Working on it

@nabilfreeman
Copy link

I'd also be really interested in this feature - @gknedo looking forward to seeing the result!!!

@gknedo
Copy link
Author

gknedo commented Mar 30, 2018

@nabilfreeman WIP, working o ruby gem now.

@artyrcheek
Copy link

Is this available?

@nabilfreeman
Copy link

Still interested too... lol. Prepare yourself for the following crime against humanity...

I wrote a Lambda that checks the Ahoy tables every 30 min and copies properties.user_id to the user_id column in both events and visits table. Works great as our throughput is currently below 1m rows per 30min, but very wasteful and kind of dumb to maintain.

(This is because we don't run rails but still use Ahoy separately from our Node stack)

@artyrcheek
Copy link

This was my hacky solution using the ruby gem.

def track_event(data)
    if data[:properties]["shop_id"]
      data[:shop_id] = data[:properties]["shop_id"]
      data[:properties].delete("shop_id")
    end
    super(data)
  end

I set the user_id (or shop id in my case) as a property, then i listen track_event, and set the shop if if there is a shop id property

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants