Closed msaspence closed 11 years ago
Hi @msaspence,
Sorry, I hadn't time to answer you before.
If I understand your problem correctly, I am seeing as only option to track events with a queue or even a simple cron job can make it work.
To avoid repetition you can wrap the lib with your own class that will use Javascript if it is available on the client or his http counter part if it is not.
Please let me know if you understood your problem correctly.
By other hand, I was thinking a little bit about the Gem design, and thinking loud it might be interesting to stop using a middleware to inject scripts. Just call a method from the layout that adds Mixpanel js snippet and a small piece of code to handle XHR responses globally, that way tracking metadata can be passed through response headers.
Yeah I'm using delayed job to queue events so not so much a problem for me now
However your suggestion makes sense to me as a better implementation for append_track as it removes the requirement for a html doc in the response body
Well actually you should include it in your layout once. Then use just headers, I hope to get time to do it.
On Sunday, February 24, 2013, msaspence wrote:
Yeah I'm using delayed job to queue events so not so much a problem for me now
However your suggestion makes sense to me as a better implementation for append_track as it removes the requirement for a html doc in the response body
— Reply to this email directly or view it on GitHubhttps://github.com/zevarito/mixpanel/issues/77#issuecomment-14018855.
Alvaro
I have an app, that in addition to using pjax is doing lots of ajax, all of this gracefully degrades without javascript. What is the best way to handle the mixpanel events triggered in both these xhr requests and their normal http alternatives, given that both share the same application logic. The options as I see it:
<script></script>
when the xhr is returning html but when returning json then the request would need to be jsonp and the mixpanel code would need to be outside the callback.Essentially what I'm asking is, is there another better way that I've missed? And if you are interested in 3. or 4. as a pull request? I think having thought over my options as I've written this issue option 2. is best or me but I still wonder if there is a use case for 3. or 4.?