export class Serializable {

    constructor(props) {
        this.properties = props || {};
    }

    toObject() {
        return this.properties;
    }

    toString() {
        return JSON.stringify(this.toObject());
    }

    toJSON() {
        return JSON.stringify(this.properties);
    }

    toQueryString() {
        var str = [];
        var obj = this.toObject();
        for (var p in obj) {
            if (obj.hasOwnProperty(p) && obj[p]) {
                str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
            }
        }
        return str.join('&');
    }
}

class Hit extends Serializable {
    
    sent = false

    constructor(props){
        super(props);
    }
}


export class PageHit extends Hit {
    constructor(screenName) {
        super({ dp: screenName, t: 'pageview' });
    }
}

export class ScreenHit extends Hit {
    constructor(screenName) {
        super({ dp: screenName, t: 'screenview' });
    }
}

export class Event extends Hit {
    constructor(category, action, label, value) {
        super({ ec: category, ea: action, el: label, ev: value, t: 'event' });
    }
}
export class Serializable {

    constructor(props) {
        this.properties = props || {};
    }

    toObject() {
        return this.properties;
    }

    toString() {
        return JSON.stringify(this.toObject());
    }

    toJSON() {
        return JSON.stringify(this.properties);
    }

    toQueryString() {
        var str = [];
        var obj = this.toObject();
        for (var p in obj) {
            if (obj.hasOwnProperty(p) && obj[p]) {
                str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
            }
        }
        return str.join('&');
    }
}

class Hit extends Serializable {
    
    sent = false

    constructor(props){
        super(props);
    }
}


export class PageHit extends Hit {
    constructor(screenName) {
        super({ dp: screenName, t: 'pageview' });
    }
}

export class ScreenHit extends Hit {
    constructor(screenName) {
        super({ cd: screenName, t: 'screenview' });
    }
}

export class Event extends Hit {
    constructor(category, action, label, value) {
        super({ ec: category, ea: action, el: label, ev: value, t: 'event' });
    }
}

Fix screenName parameter in ScreenHit class
Fix screenName parameter in ScreenHit class

Changed property dp to cd to match Google Analytics screen hit request reference

See https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide

*Request*

``
v=1                         // Version.
&tid=UA-XXXXX-Y             // Tracking ID / Property ID.
&cid=555                    // Anonymous Client ID.

&t=screenview               // Screenview hit type.
&an=funTimes                // App name.
&av=1.5.0                   // App version.
&aid=com.foo.App            // App Id.
&aiid=com.android.vending   // App Installer Id.
&cd=Home                    // Screen name / content description.
``