class Matomo

Constants

DOMAINPATH_RE

domain name (characters separated by a dot), optional port, optional URI path, no slash

SETUP_CODE
SITEID_RE

numeric ID

Public Class Methods

new(config) click to toggle source
# File lib/analytics/Matomo.rb, line 34
def initialize(config)

    if !(DOMAINPATH_RE.match(config['url']))
        raise ArgumentError, 'Invalid url. Must be a domain name, optionally followed by an URI path, no trailing slash (e.g. matomo.example.com or my.matomo.server/path)'
    end

    if !(SITEID_RE.match(config['siteId']))
        raise ArgumentError, 'Invalid site id. Must be a number.'
    end

    @config = Hash[config.map{ |k, v| [k.to_sym, v.to_s] }]

end

Public Instance Methods

render() click to toggle source
# File lib/analytics/Matomo.rb, line 48
def render
    return SETUP_CODE % @config
end