Comments (22)
It is currently configurable to the extent that you can specify the entire api host string in the config, though it's certainly not ideal:
mixpanel.init('MY TOKEN', {
api_host: 'https://api.mixpanel.com'
});
What would be the most useful means of configuration for you?
from mixpanel-js.
Hi, thanks so much for pointing out the issues and potential solutions. Offline support and alternatives to cookie-based tracking would be awesome. Unfortunately there's nothing concrete currently on the roadmap, so pull requests are probably the quickest path to seeing the features you need. A few notes:
- if you do implement both of these, please keep them in separate pull requests
- for localStorage vs cookie stores, maintain backwards compatibility by offering localStorage as a config option and keeping cookie as the default; so you would init the lib somewhat like:
mixpanel.init(TOKEN, {storage: 'localStorage'});
- for offline support, you'll want to queue up requests and then send batched updates (https://mixpanel.com/help/reference/http#batch-requests) of max 40 events at a time. the code of our ios lib offers a good model.
Let us know if you have more questions!
from mixpanel-js.
Hi, yes there is one thing. I'm struggling running tests do you have any guidance on that?
My issue seems to be related with cookie_included getJson calls (which are failing with a 404).
Update : I was able to run them using a basic nodejs server. I still have some tests failing because i'm not returning the expected value. So I guess there is actually something missing from this repository to enable testing.
from mixpanel-js.
Apologies for that; the tests do rely on an external server resource which wasn't included when the lib was open-sourced. I've been meaning to add a little Node server to the repo to handle that. The Django code for it looks basically like:
def test_cookie_included(request, cookie_name):
return json_response(request, 1 if cookie_name in request.COOKIES else 0)
so the response is 1 when the cookie has been set and 0 otherwise. Does that help?
from mixpanel-js.
It does help :) Actually I wrote a basic nodejs/express server which I will update with using that information. I can submit another PR for that too if you want.
from mixpanel-js.
That would be very welcome!
from mixpanel-js.
Just submitted a PR about the test server.
I still have some work to do about localStorage to make it clean but I'm on it.
from mixpanel-js.
I've added a pull request with the localStorage alternative to cookies.
from mixpanel-js.
@sandorfr I see that you already solved one of the two problems for good cordova support. Did you also tackle the queue topic?
from mixpanel-js.
@KeKs0r I have not yet started it.
from mixpanel-js.
here's a queue implementation:
http://meltuhamy.com/dev/offline-resilient-mixpanel-tracking-for-ionic-without-a-cordova-plugin/
https://github.com/meltuhamy/belfastsalah/blob/master/www/js/svc/mixpanel.js
@sandorfr @tdumitrescu any chance to take on this in the foreseeable future?
similarly to what you did with the localstorage support?
from mixpanel-js.
alternative approach here:
https://github.com/skotzko/mixpanel-event-queue
from mixpanel-js.
The best way to push a feature like this forward is with a pull request, otherwise it's largely a matter of us prioritizing the request against a whole pile of other internal development work, which means a longer wait. I'm happy to discuss ideas if you want to validate an approach before submitting code.
from mixpanel-js.
Hi @mobidev111, I don't MEQ is going to be of any help when it comes to offline support because this is using in Memory storage.
I was considering implementing a queue on top of IndexedDb and then batch the events. Since reinventing the wheel is not going to help I think it might be interresting to take a look at this : https://github.com/orthecreedence/hustle.
That being said there is some work and a lot of testing to be done to get something which could be merged here, and I'm also prioritizing things on my side. So unless someone makes it a priority for me I'm very short on time atm.
from mixpanel-js.
To add another consideration for Cordova support, it looks like in all scenarios mixpanel will default the protocol to 'http' rather than 'https', since the protocol is actually 'file'.
See:
mixpanel-js/src/mixpanel-core.js
Line 72 in 40c158c
from mixpanel-js.
@jskrepnek interesting, and it looks like this is not configurable yet.
from mixpanel-js.
@sandorfr I've successfully patched it in place, but that's far from ideal.
from mixpanel-js.
@tdumitrescu That's great, thanks. I'd suggest adding that configuration option to the Javascript Full API Reference.
from mixpanel-js.
Would it make sense to make 'https' the default, rather than 'http'? That way scenarios like cordova where the protocol is 'file' would default the safe way.
from mixpanel-js.
Good call, will need to add it here.
from mixpanel-js.
Yeah, we'll have to think about potential implications for backwards-compatibility with switching the default, though it seems safe to me off the top of my head.
from mixpanel-js.
I believe this issue can be closed. I am using Mixpanel in several Cordova apps at this point. If you are using bower and your app goes offline: notice the section titled: Using Bower to load the entire library which explains how to load Mixpanel without the CDN. This will allow it to pass the CSP for Chrome:extensions as well.
Side note: the instructions are slightly wrong. mixpanel.js
does not exist. It should be mixpanel.min.js
.
from mixpanel-js.
Related Issues (20)
- init loaded callback not always called.
- Mixpanel events inconsistently recorded HOT 1
- Documentation – outdated JavaScript example "Tracking Via Proxy" HOT 2
- Unwanted link navigation from `LinkTracker`
- The latest version of the library is different between NPM and CDN HOT 2
- unintended behavior with marketing campaign tracking in the minified version HOT 2
- Long urls are cut off
- Endpoint with track/? is not a valid URL with recent jars of spring boot 3, is there any chance to remove / after track in mixpanel.cjs.js HOT 1
- Allow async init HOT 6
- Can `api_host` contain a /path? HOT 4
- Cannot read properties of undefined (reading 'persistence')
- Reset not available on mixpanel instance
- Target attribute other than _blank is ignored. HOT 1
- Cannot add event properties to Page View event when track_pageview: true in SPA HOT 1
- Reset Mixpanel before init
- mixpanel.track_pageview does not send any event
- `track_links` does not work in a React app unless wrapped in a `useEffect` + `setTimeout`
- `$initial_referrer` property shows up as `"$direct"`, even when it isn't HOT 8
- Pass custom `device_id` to library initialization HOT 5
- mixpanel.identify() works even when it is turned off. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mixpanel-js.