Closed kesla closed 10 years ago
yes we should do that
currently I have just browserified the example client - and stuck that into megafunnel, do you think that is good enough? else can you make a pull request?
Oh oops I didn't read you right the first time. I think it is convienient to host a compiled file - if a user wants something different they do not have to load it - they can bundle something into their own client app. This at least gets it working with minimum fuss.
okay but I have updated the script to use the latest condor, though.
The condor being served causes this error in the browser:
POST http://example.com/condor 404 (Not Found)
This code works when browserified. It's the same as the condor example usage, except I specified the full trackUri
and require('condor')
.
var host = 'example.com'
var trackUri = 'http://' + host + ':4001/track'
var xhr = require('xhr')
var track = require('condor')({
// default 500ms
// set for how long time scroll & resize events should be
// [debounced](https://www.npmjs.org/package/debounce)
// The `duration`-attribute is the last of these events.
debounceTime: 300
})
, noop = function () {}
track.onevent = function (csv) {
// this callback is called everytime an event happens
// the data is a line of csv, see below for information on the format of the
// csv
xhr({
method: 'POST'
, body: csv
, uri: trackUri
}, noop)
}
// this gets called by beforeunload - so anything in here must be synchronous
track.onend = function (csv) {
// this will be an end-event - meaning that the visit on the page has ended
xhr({
method: 'POST'
, body: csv
, uri: trackUri
, sync: true
}, noop)
}
I think we can use os.networkInterfaces() to determine the ip of the megafunnel-funnel.
Fedor Indutny's 'ip' module
or mafintosh network-address http://npmjs.org/package/network-address
haha, i wrote that same module many years ago but then I found indutny's module which is much more complete / useful.
These modules only show the private ips, but we need a public ip.
So, we can either:
they both show public IPs.
:eyes: I don't see any public ips
By default the following returns the public facing address(es). :)
require('ip').address('public');
https://github.com/indutny/node-ip/blob/master/lib/ip.js#L293
Perhaps the issue is AWS is behind a NAT, so I'm only seeing private ips.
root@ip-172-30-2-232:/home/ubuntu/tmp# node
> require('ip').address('public');
'127.0.0.1'
> require('ip').address()
'172.30.2.232'
Wills-MacBook-Pro:tmp will$ node
> require('ip').address('public');
'127.0.0.1'
> require('ip').address();
'192.168.0.156'
I'm thinking about a module that gets the ip from one of these services (redundancy): http://icanhazip.com/ http://ifconfig.me/ip http://ipinfo.io/ip http://www.trackip.net/ip
If it's a NAT problem use 'aws-instances' module maybe?
okay this should be fixed now.
@dominictarr it's still posting data to /track
instead of http://remotehost:4001/track
@dominictarr it was a typo. fix pushed. please publish.
published as 0.0.11
Hey,
Now that condor is a lot more mature I'm guessing that we want to serve that in a another way that a compiled tracker.js file? Any thoughts on this @dominictarr?