You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,28 +4,26 @@ Public analytics as a Node.js microservice.
4
4
5
5
With less than 100 lines of code this service is the smallest analytics you'll ever need. It does nothing except count the views of something and making the views accessible via an API.
6
6
7
-
(there is currently no frontend to consume the statistics, though writing one is on the to-do list)
7
+
(there is currently no frontend to display pretty graphs, feel free to build one!)
8
8
9
9
## Built with
10
10
11
11
-[`micro`](https://github.com/zeit/micro) to create the service.
12
12
-[`flat-file-db`](https://github.com/mafintosh/flat-file-db) to store the data. (and [`promise`](https://github.com/then/promise) to promisify `flat-file-db`)
13
13
14
-
## Usage
15
-
16
-
### Starting the service
14
+
## Setup
17
15
18
16
1.`git clone git@github.com:mxstbr/micro-analytics` to get the repo.
19
17
2.`npm install` to install the dependencies.
20
18
3.`npm start` to start the service.
21
19
22
20
And that's it! 🎉 (see [`deployment.md`](./deployment.md) for deployment instructions)
23
21
24
-
### Tracking views
22
+
##Usage
25
23
26
-
To track a view simply send a request to `/<yourpath>`. If you send a `GET` request, the request will increment the views and return the total views. If you send a `POST` request, the views will increment but you're not going to get the total views back.
24
+
### Tracking views
27
25
28
-
If you don't want to increment the views during a `GET` request, set `inc` to `false` in your query parameter. (`/<yourpath>?inc=false`)
26
+
To track a view, simply send a request to `/<yourpath>`. If you send a `GET` request, the request will increment the views and return the total views. If you send a `POST` request, the views will increment but you don't get the total views back.
29
27
30
28
This is how you'd track pageviews for a website: (though note that this can be used to track anything you want)
31
29
@@ -39,6 +37,10 @@ This is how you'd track pageviews for a website: (though note that this can be u
39
37
</script>
40
38
```
41
39
40
+
If you just want to get the views for a path and don't want to increment the views during a `GET` request, set `inc` to `false` in your query parameter. (`/<yourpath>?inc=false`)
41
+
42
+
If you want to get all views for all paths, set the `all` query parameter to `true`. (`/?all=true`)
43
+
42
44
## Contributing
43
45
44
46
If you run `npm run dev` the server will restart every time you edit the code. Perfect for development of `micro-analytics`!
0 commit comments