Settings

Theme

Open Source Visitor.js

github.com

198 points by codejoust 14 years ago · 55 comments

Reader

memnips 14 years ago

It is now apparently Session.js https://github.com/codejoust/session.js

bradly 14 years ago

Here is a live demo showing your own information. http://visitorjs.herokuapp.com/

Fyi: I am not storing the information.

dsl 14 years ago

Damn, you beat me to it. After I saw the original visitor.js was a paid service (which blew my mind), I started hacking together the JS implementations of most of the functionality I had laying around already.

gojomo 14 years ago

The original visitor.js identified my city correctly; this only put me in the USA.

Is there a free reliable precise geolocation service that can take as many hits as a script like this could throw at it?

  • ryanmahoski 14 years ago

    Your best bet is html5 geolocation + modernizr.js + a shim. Browsers that support html5 geolocation will return highly accurate results while those that don't support it will fall back to calling the google maps api (ip to geo).

    https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Brow...

    • nl 14 years ago

      HTML5 Geolocation requires people to opt-in, which is pretty messy.

      Better off getting the free version of the MaxMind city database[1] and running it on a server somewhere.

      [1] http://www.maxmind.com/app/geolitecity

      • ryanmahoski 14 years ago

        The opt-in button is messy but results are very precise and reliable. Some use cases warrant it, some do not. Maxmind claims 79% accuracy on a city level: is the google api worse? All other things being equal I would be inclined to pick the one that didn't require me to frequently install binary patches or update a database.

        • ryanmahoski 14 years ago

          But I agree with you, it's a ux dealbreaker for most situations. Solution: control the hardware. :)

  • codejoustOP 14 years ago

    I added in support for http://ipinfodb.com/ (see bottom of README) which might be better than Google's api, although you need to register for an API key. You might want to give that a shot.

  • ibrahimcesar 14 years ago

    Worked fine with me, here in Brazil.

    • pygy_ 14 years ago

      It properly identify my country (Belgium) and my region, but it returned another unrelated city.

peteretep 14 years ago

I'm glad you've done this, because I'd have wasted a few hours on it I didn't have otherwise :-)

tonywebster 14 years ago

I love when disruption disrupts disruption.

grantjgordon 14 years ago

I don't think there are any ethical issues here. The paid service is doing something that was mostly, if not completely, available in other open source projects such as piwik and OWA in the first place. It's very educational to look at the differences in the way codejoust implemented his javascript vs. these other projects, and very convenient that you don't have to dig through a gigantor open source code base to do it.

slavin 14 years ago

I don't understand the pricing model behind visitorjs, and we had to implement a similar solution at my company. But the fact is - they created something and shared it here. If you think you can do a better job at it - fine, but why haven't you done it before, or at the very least named it differently. I don't mean to exaggerate, but it just doesn't feel ethical to me.

DannyPage 14 years ago

What are the ethical concerns about using this and storing the data? If I wanted to use this on my site, should I let visitors know, or is this data fair game to store? I rather not use the location data (or any of it) if there could be an issue.

  • driverdan 14 years ago

    Since websites need a privacy policy if they have users in California anyway, you might as well put your use of the data into it.

    You should always tell your users what data you gather and how you use it. If you only let the data stay in the browser and never send it to the server then tell them.

  • codejoustOP 14 years ago

    1: You can turn off location data.

    2: None of this is being stored, beyond a cookie. Of course, you can call back to the server with that data, but the server has your IP address, which is where the location data came from.

Flimm 14 years ago

Is this version created or endorsed by the authors of the other Visitor.js implementation?

  • codejoustOP 14 years ago

    No. And the recently-posted paid visitor.js site does have a few advantages, most being that this is using pure javascript, while they have the server side doing most of the heavy lifting.

    • Flimm 14 years ago

      In that case, this implementation really should have a different name. It's confusing to have two competing implementations share the same name, and it may be a trademark violation.

      • pbhjpbhj 14 years ago

        >"and it may be a trademark violation."

        "visitor.js" isn't distinct in the field, particularly as it's descriptive and of a common form, I'd warrant it's not novel either.

        That doesn't mean that you wouldn't be sued for using it just that any sane TM office shouldn't allow it to be registered and that a sane IP judge should dismiss a case brought against it's use as passing off. The law isn't sane of course ....

        I think it's reasonable to use the same name if the scope is largely co-terminous.

        • Flimm 14 years ago

          It's because the scope is co-terminous that having different names is so important. IANAL, but trademarks don't have to be distinct or novel to be legitimate. They are allowed to be descriptive (like Windows or iPhone).

          The fork of OpenOffice.org was named LibreOffice, because it would be unfair to name a competing product with the same name. I'm glad the author of this library has decided to do the same.

          • pbhjpbhj 14 years ago

            First up, "iphone" is definitely not descriptive, it's abstract, a made up word. "touchPhone" would be descriptive. "Windows", well ... it's a generic term now but at the time, despite it being to some extent descriptive of a WIMP system it was arguably a distinctive term for an OS (but I'm surprised it was allowed).

            OpenOffice.org is interesting because they previously named the project "Open Office" and suffered trademark problems and had to be very careful to use the full name of the project. But had the former project been called "Computer Office Suite" then trademark issues wouldn't have arisen because that's not a distinctive mark and so couldn't be protected, it's descriptive anyone selling such software could use that description.

            It's not unfair to use an identical descriptive name for things that serve the same function - for example Microsoft and Apple both sell something that they use the term "Operating System" to describe. OS is a descriptve term that is expected to be used in the field and so can't be a trademark, it doesn't serve to indicate origin.

            I'd argue that visitor.js is an expected name for a piece javascript that logs visitors in some way, it's not distinctive of origin. Moreover it is descriptive of the function of the code. Kinda like having an ad loader that's called ads.js.

            FWIW, and I've not been paying too much attention (!), only one of the pieces of code labelled visitor.js appears to be a product.

        • codejoustOP 14 years ago

          I believe the earlier comments have merit, thus I've renamed the library.

latchkey 14 years ago

The best part about this whole thing is the location lookup. Seriously nice job.

josscrowcroft 14 years ago

I'm super impressed you turned this out so quickly. I think that really sums up the spirit in the HN community...

When you look at something that seems overpriced (or wrongly-priced) and you say "hey, I bet I could do this"

I still see value in potentially paying for a service like this when it's a big enough pain-point. But I really think they'd have had more traction with a open-source-to-paid model, where anyone can use the client-side code for free, but the extra stats and support provided are worth paying for.

mise 14 years ago

Having a "first session" and "current session" exposes very interesting functionality. It suddenly provides a quick way to keep track of what search keywords they used to get to the site, and could be later linked to an account if later created.

sbarre 14 years ago

location is either "null" or "err/google" for me all the time.

Although I am probably an edge-case, I'm tethering from an iPhone on Rogers in Canada.

Visitor.js (the paid service) correctly positions me in Toronto, Canada though.

wehriam 14 years ago

Outstanding! I also was going to have to re-implement this.

dchuk 14 years ago

well...that didn't take long

jpulgarin 14 years ago

Localization doesn't seem to work very well. I'm in Waterloo, Canada. This is what the script outputs for me:

> session.locale.country

"US"

> session.locale.location

undefined

  • arnoooooo 14 years ago

    Are you not confusing

    1) session.locale, which is the locale (ie. regional settings) configuration of your browser and might very well be US,

    and

    2) session.location, which gives your geographic location ?

  • okal 14 years ago

    I'm in Nairobi, Kenya. The output indicates I'm in the US as well.

kmax12 14 years ago

where's the server stuff? is google providing everything that the pay service did, but for free?

  • codejoustOP 14 years ago

    Google provides it as an extra for the JSAPI, no telling how long it will last, though.

    • wavephorm 14 years ago

      Developers should have learned by now not rely on Google for anything. Once all competing paid services (just like visitor.js) get driven out of business by Google's free service, you can count on Google doing the ol' bait and switch, by taking down the free API, erecting a paywall leaving themselves with a monopoly.

tomhallett 14 years ago

i'm curious about the timing here.

did you see vistor.js hit HN and rewrite it in a few hours? or were you working on this in isolation and when you saw it on HN decided it was the perfect time to ship?

dlitz 14 years ago

Visitor.js should be the new FizzBuzz

desireco42 14 years ago

The only thing that would make this better is to have it in coffeescript... :) which I might do for you if you don't.

  • codejoustOP 14 years ago

    I thought about doing that. I've used a lot of coffeescript in the past, but I just didn't see it being a big advantage here. The biggest issue with using CoffeeScript here is that I wanted control over the syntax as I wanted to have less code. CoffeeScript (generated) really creates more code than what it's worth.

alpb 14 years ago

Gives 404?

  • cag_ii 14 years ago

    the repository has been renamed. see session.js link in memnips comment.

buremba 14 years ago

404?

necenzurat 14 years ago

after reading visitorjs.com thread i asked myself WHY

Question: who would pay 10 bucks a month for using a js file for 30K requests?

  • Terretta 14 years ago

    People who understand it's not a JS file, it's a generated JS file containing data the server of that file had to look up and process to create the JS.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection