Pregunta

I love graphs.

I'd love to get my hands on some data and make it look pretty. But alas, I'm a little lost on what would be considered best practice.

I've selected mixpanel (only as an example) as I seems wonderfully easy to track custom events, and doesn't have any subdomain limitation like Google Analytics.

Say I had 100-1000+ users who have an account (which is publicly facing), and I'm currently tracking the public interactions their pages get. With mixpanel, I can see the data which is lovely, and I've segmented it to individual accounts. So far, so good!

But then, I want to show my users this information. And here my head begins to hurt. Do I schedule a cron jobs, pulling in the data from mixpanel and writing it to their respective accounts? Or is there a better way? I've looked into mixpanel's api (I'm using Ruby), but they keep telling me I should use the javascript api. But in using JS, how does one prevent others getting the data (ie. what's stopping someone faking mixpanel api-posts in the console, or viewing my private key?).

What would you consider a practical solution in such a case?

¿Fue útil?

Solución

You can achieve this by storing the user specific events of each user with a $bucket property attached which has a value unique to each user as explained in the mixpanel docs here Mixpanel docs. If you want to still use ruby to serve the events, have a look at Mixpanel's recommended ruby client libraries mixpanel_client looks like the much maintained option of the 2 mentioned. If you go with that then you can serve user specific events as shown in the example below(which is also in the gem's readme):

data = client.request do
  # Available options
  resource  'events/properties'
  event     '["test-event"]'
  name      'hello'
  values    '["uno", "dos"]'
  timezone  '-8'
  type      'general'
  unit      'hour'
  interval   24
  limit      5
  bucket    'contents'
  from_date '2011-08-11'
  to_date   '2011-08-12'
  on        'properties["product_id"]'
  where     '1 in properties["product_id"]'
  buckets   '5'
end

Otros consejos

You could try a service like Keen IO that will allow you to generate encrypted scoped write and read API keys. Keen IO is built for customizable and programmatic analytics features such as exposing analytics to your customers, where as MixPanel is more for exploring your data in their UI. The idea with an encrypted scoped key is they will never be able to access your account, only the data you want them to see. You could easily tag your events with a customer ID and then use the Scoped Keys to ensure that you only ever show customers their own data.

https://keen.io/docs/security/#scoped-key

Also, Keen IO has an "importer" which allows you to export your mixpanel events into your Keen IO database.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top