point-hub

The point platform which can collect the events of user.

Require:

Run for production

For server site

Edit conf.json file, fill your mysql info.

Run:

npm install
npm start

It will listen 3000 port and receive data form '/events'

For client

Import sdk:

<script src="https://example.com/sdk/1.0/browser.js"></script>

Init sdk to set built-in info and send a point:

(function () {
    const eventSender = new EventSender('https://example.com/events', {
        // ses sdk/browser.ts#EventBody
        uid: 123456,
        app_name: 'my-app',
        get referer() { return location.href; },
    });
    eventSender.setContent({
        ua: navigator.userAgent,
    });

    // Send a point
    eventSender.send('pv', {
        // extra data
    });
})();

Deploy using docker

docker run pea3nut/point-hub:master

It will expose 80, 3000 and 3306 port for:

Transfer From Older

1.0 -> 1.1

  1. Run sql below:
ALTER TABLE `events` ADD `date` INT NULL AFTER `uid`;
ALTER TABLE `events` ADD INDEX(`date`);
  1. update point-server

  2. Run sql, it need some time:

UPDATE `events` SET `date` = date_format(time, '%Y%m%d') where date is NULL;