 
 		@request "#{@query_types[type]}?#{queryString}"
 
+	# ### record
+	# ----------
+
+	# Query the Kissmetrics API
+	#
+	# `endpoint` (String): URL path (without a leading slash) that will be used
+	#   as a Kissmetrics API endpoint.
 	request: (endpoint) ->
 		httpRequest "https://#{@host}:#{@port}/#{endpoint}"
 
 
+# ### Exports
+# -----------
+
+# Make `KissmetricsClient` available either as a Node module or a property
+# on the current context in the browser.
 if ENV is 'node'
 	exports.KissmetricsClient = KissmetricsClient
 else

		(new Image()).src = url


class KissmetricsClient
	constructor: (@key, @person) ->
		@host        = 'trk.kissmetrics.com'

# # Kissmetrics JS

# ## Bootstrap
# -------------

# Keep track of what environment we're running in, Node.js or a browser.
# If we're in Node, require the `https` module for our network requests.
# If we're in a browser we'll just use the implicit requests generated by
# `Image`'s `src` property. Kissmetrics responds to API requests with an
# `image/gif` content type, so the browser won't throw up any warnings.
ENV = if typeof exports isnt 'undefined' then 'node' else 'browser'

https = require 'https' if ENV is 'node'


# ## Requests
# ------------

# Generic wrapper for HTTP requests that abstracts the differences between
# requests made in Node and in a browser.
httpRequest = (url) ->
	if ENV is 'node'
		https.get url
