Skip to content

Commit

Permalink
Merge pull request #57 from electerious/develop
Browse files Browse the repository at this point in the history
v1.4.0
  • Loading branch information
electerious authored Nov 5, 2019
2 parents 143030c + 308be25 commit c76dcaa
Show file tree
Hide file tree
Showing 33 changed files with 427 additions and 203 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.4.0] - 2019-11-05

### Added

- "New referrers"
- Custom tracker URL (#53)

### Fixed

- Incorrect content type for JS files (#54)

## [1.3.0] - 2019-10-19

### Added
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ Specifies how long a generated token is valid. Defaults to `3600000` (1 day).
ACKEE_TTL=3600000
```

#### Tracker

Pick a custom name for the tracking script of Ackee to avoid getting blocked by browser extensions. The default script will always be available via `/tracker.js`. You custom script will be available via `/custom%20name.js`. Ackee will encode your custom name to a URL encoded format.

Make sure to adjust the tracking script URL on your sites when changing this option. Sites that are using the default URL won't be affected.

```
ACKEE_TRACKER=custom name
```

#### Environment

Set the environment to `development` to see additional details in the console and to disable caching.
Expand Down
2 changes: 1 addition & 1 deletion docs/CORS headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ When a site wants to send data to a different domain it needs the permissions to
```
Access-Control-Allow-Origin: https://example.com
Access-Control-Allow-Methods: GET, POST, PATCH, OPTIONS
Access-Control-Allow-Headers: DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type
Access-Control-Allow-Headers: Content-Type
```

### Origin
Expand Down
4 changes: 4 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ The last 25 page visits of the last 7 days. Sorted by time.

The top 25 pages from which your visitors have come in the last 7 days. Sorted by popularity.

### Referrers > New referrers

Pages from which your visitors have come in the last 7 days. Ignores old referrers. Sorted by time.

### Referrers > Recent referrers

The last 25 pages from which your visitors have come in the last 7 days. Sorted by time.
Expand Down
17 changes: 17 additions & 0 deletions docs/UI.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# UI

- [Index](#index)
- [Favicon](#favicon)
- [Styles](#styles)
- [Scripts](#scripts)
- [Tracker](#tracker)
Expand Down Expand Up @@ -31,6 +32,22 @@ Status: 200 OK
```

## Favicon

Favicon of Ackee.

### Request

```
GET /favicon.ico
```

### Response

```
Status: 200 OK
```

## Styles

CSS used to display the UI of Ackee.
Expand Down
2 changes: 1 addition & 1 deletion docs/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Status: 200 OK

## Get recent languages

Get the 25 most recent user languages ([ISO-639-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)).
Get the 25 most recent user languages ([ISO-639-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)) of the last 7 days.

### Request

Expand Down
2 changes: 1 addition & 1 deletion docs/pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Status: 200 OK

## Get recent pages

Get the 25 most recent page views.
Get the 25 most recent page views of the last 7 days.

### Request

Expand Down
41 changes: 40 additions & 1 deletion docs/referrers.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Referrers

- [Get top referrers](#get-top-referrers)
- [Get new referrers](#get-new-referrers)
- [Get recent referrers](#get-recent-referrers)

## Get top referrers
Expand Down Expand Up @@ -40,9 +41,47 @@ Status: 200 OK
}
```

## Get new referrers

Get the 25 most recent referrers who have linked to your site for the first time in the last 7 days.

### Request

```
GET /domains/:domainId/referrers?sorting=new
```

### Headers

| Name | Example |
|:-----------|:------------|
| Authorization | `Authorization: Bearer :tokenId` |

### Response

```
Status: 200 OK
```

```json
{
"type": "referrers",
"data": [
{
"type": "referrer",
"data": {
"id": "https://www.example.com/",
"count": 1,
"created": "2019-09-19T15:54:00.020Z"
}
}
]
}
```

## Get recent referrers

Get the 25 most recent referrers.
Get the 25 most recent referrers of the last 7 days.

### Request

Expand Down
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ackee",
"private": true,
"version": "1.3.0",
"version": "1.4.0",
"authors": [
"Tobias Reich <tobias@electerious.com>"
],
Expand All @@ -22,30 +22,30 @@
"start": "node src/index.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"test": "nyc ava",
"lint": "eslint 'src/**/*.js'"
"lint": "eslint '{src,test}/**/*.js'"
},
"eslintConfig": {
"extends": "@electerious/eslint-config"
},
"dependencies": {
"@babel/core": "^7.6.3",
"@babel/preset-env": "^7.6.3",
"ackee-tracker": "^3.2.1",
"ackee-tracker": "^3.2.2",
"classnames": "^2.2.6",
"dotenv": "^8.2.0",
"formbase": "^11.0.0",
"immer": "^4.0.1",
"immer": "^5.0.0",
"is-url": "^1.2.4",
"micro": "^9.3.4",
"microrouter": "^3.1.3",
"mongoose": "^5.7.5",
"mongoose": "^5.7.7",
"node-schedule": "^1.3.2",
"normalize-url": "^4.5.0",
"normalize.css": "^8.0.0",
"permit": "^0.2.4",
"prop-types": "^15.7.2",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-redux": "^7.1.1",
"redux": "^4.0.4",
"redux-devtools-extension": "^2.13.8",
Expand All @@ -62,18 +62,21 @@
"@electerious/eslint-config": "^1.3.1",
"ava": "2.4.0",
"coveralls": "^3.0.6",
"eslint": "^6.5.1",
"eslint": "^6.6.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.1.2",
"eslint-plugin-react-native": "^3.7.0",
"eslint-plugin-react-hooks": "^2.2.0",
"eslint-plugin-react-native": "^3.8.1",
"node-fetch": "^2.6.0",
"nyc": "^14.1.1",
"test-listen": "^1.1.0"
},
"ava": {
"babel": false,
"verbose": true
"verbose": true,
"environmentVariables": {
"ACKEE_TRACKER": "custom name"
}
},
"engines": {
"node": ">= 10"
Expand Down
2 changes: 2 additions & 0 deletions src/constants/referrers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Constants will be shared between client and server.
// They will be used as values in the DOM and in the URL of the referrer calls.
const REFERRERS_SORTING_TOP = 'top'
const REFERRERS_SORTING_NEW = 'new'
const REFERRERS_SORTING_RECENT = 'recent'

module.exports = {
REFERRERS_SORTING_TOP,
REFERRERS_SORTING_NEW,
REFERRERS_SORTING_RECENT
}
43 changes: 43 additions & 0 deletions src/database/referrers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const dateWithOffset = require('../utils/dateWithOffset')

const {
REFERRERS_SORTING_TOP,
REFERRERS_SORTING_NEW,
REFERRERS_SORTING_RECENT
} = require('../constants/referrers')

Expand Down Expand Up @@ -42,6 +43,47 @@ const getTop = async (id) => {

}

const getNew = async (id) => {

return Record.aggregate([
{
$match: {
domainId: id,
siteReferrer: {
$ne: null
}
}
},
{
$group: {
_id: '$siteReferrer',
count: {
$sum: 1
},
created: {
$first: '$created'
}
}
},
{
$match: {
created: {
$gte: dateWithOffset(-6)
}
}
},
{
$sort: {
created: -1
}
},
{
$limit: 25
}
])

}

const getRecent = async (id) => {

return Record.aggregate([
Expand Down Expand Up @@ -78,6 +120,7 @@ const get = async (id, sorting) => {

switch (sorting) {
case REFERRERS_SORTING_TOP: return getTop(id)
case REFERRERS_SORTING_NEW: return getNew(id)
case REFERRERS_SORTING_RECENT: return getRecent(id)
}

Expand Down
2 changes: 2 additions & 0 deletions src/routes/referrers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const referrers = require('../database/referrers')

const {
REFERRERS_SORTING_TOP,
REFERRERS_SORTING_NEW,
REFERRERS_SORTING_RECENT
} = require('../constants/referrers')

Expand All @@ -32,6 +33,7 @@ const get = async (req) => {

switch (sorting) {
case REFERRERS_SORTING_TOP: return responses(entries)
case REFERRERS_SORTING_NEW: return responses(entries)
case REFERRERS_SORTING_RECENT: return responses(entries)
default: throw createError(400, 'Unknown sorting')
}
Expand Down
18 changes: 0 additions & 18 deletions src/routes/tracker.js

This file was deleted.

Loading

0 comments on commit c76dcaa

Please sign in to comment.