micnews / megafunnel

artisanal big data analytics
MIT License
11 stars 0 forks source link

Serve condor #2

Closed kesla closed 10 years ago

kesla commented 10 years ago

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?

dominictarr commented 10 years ago

yes we should do that

dominictarr commented 10 years ago

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?

dominictarr commented 10 years ago

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.

dominictarr commented 10 years ago

okay but I have updated the script to use the latest condor, though.

will123195 commented 10 years ago

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)
}
will123195 commented 10 years ago

I think we can use os.networkInterfaces() to determine the ip of the megafunnel-funnel.

policymicadmin commented 10 years ago

Fedor Indutny's 'ip' module

kesla commented 10 years ago

or mafintosh network-address http://npmjs.org/package/network-address

heapwolf commented 10 years ago

haha, i wrote that same module many years ago but then I found indutny's module which is much more complete / useful.

will123195 commented 10 years ago

These modules only show the private ips, but we need a public ip.

So, we can either:

heapwolf commented 10 years ago

they both show public IPs.

will123195 commented 10 years ago

:eyes: I don't see any public ips

heapwolf commented 10 years ago

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

will123195 commented 10 years ago

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

policymicadmin commented 10 years ago

If it's a NAT problem use 'aws-instances' module maybe?

dominictarr commented 10 years ago

okay this should be fixed now.

will123195 commented 10 years ago

@dominictarr it's still posting data to /track instead of http://remotehost:4001/track

will123195 commented 10 years ago

@dominictarr it was a typo. fix pushed. please publish.

dominictarr commented 10 years ago

published as 0.0.11