Skip to content

Commit

Permalink
Merge pull request #83 from electerious/develop
Browse files Browse the repository at this point in the history
v1.6.0
  • Loading branch information
electerious authored Mar 6, 2020
2 parents a852cd7 + e98b8f9 commit 6393198
Show file tree
Hide file tree
Showing 65 changed files with 831 additions and 367 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ 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.6.0] - 2020-03-06

### Added

- Switch between daily, weekly and yearly views
- `ACKEE_ALLOW_ORIGIN` now supports multiple domains (#79 #82, thanks @jaryl)

### Improved

- JS error handling with React error boundary

### Fixed

- Loading indicator when the sizes-view is loading
- Catch errors when the sizes-view throws an error

## [1.5.0] - 2020-02-16

### Added
Expand Down
16 changes: 13 additions & 3 deletions docs/CORS headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@ Access-Control-Allow-Headers: Content-Type

If you are running Ackee on a platform which handles SSL for you, you may want a quick solution for setting CORS headers instead of using a [reverse proxy](SSL%20and%20HTTPS.md).

As an environment variable, you will need to just set:
As an environment variable, you will need to set:

```bash
```
ACKEE_ALLOW_ORIGIN="https://example.com"
```

The proper header value for `Access-Control-Allow-Origin` will be set with the other headers being the recommended values.
The proper header value for `Access-Control-Allow-Origin` will be set with the other headers being the recommended values.

It's also possible to allow requests from all domains (not recommended) or from multiple domains:

```
ACKEE_ALLOW_ORIGIN="*"
```

```
ACKEE_ALLOW_ORIGIN="https://example.com,https://example2.com"
```
20 changes: 20 additions & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,24 @@ Set the environment to `development` to see additional details in the console an

```
NODE_ENV=development
```

## CORS headers

Quick solution for setting [CORS headers](CORS%20headers.md) instead of using a [reverse proxy](SSL%20and%20HTTPS.md). This is helpful if you are running Ackee on a platform which handles SSL for you.

```
ACKEE_ALLOW_ORIGIN="*"
```

*or*

```
ACKEE_ALLOW_ORIGIN="https://example.com"
```

*or*

```
ACKEE_ALLOW_ORIGIN="https://example.com,https://example2.com"
```
16 changes: 8 additions & 8 deletions docs/sizes.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Sizes

- [Get browser width](#get-browser-width)
- [Get browser height](#get-browser-height)
- [Get screen width](#get-screen-width)
- [Get screen height](#get-screen-height)
- [Get browser widths](#get-browser-widths)
- [Get browser heights](#get-browser-heights)
- [Get screen widths](#get-screen-widths)
- [Get screen heights](#get-screen-heights)

## Get browser width
## Get browser widths

Get the top 25 browser widths of the last 7 days.

Expand Down Expand Up @@ -42,7 +42,7 @@ Status: 200 OK
}
```

## Get browser height
## Get browser heights

Get the top 25 browser heights of the last 7 days.

Expand Down Expand Up @@ -79,7 +79,7 @@ Status: 200 OK
}
```

## Get screen width
## Get screen widths

Get the top 25 screen widths of the last 7 days.

Expand Down Expand Up @@ -116,7 +116,7 @@ Status: 200 OK
}
```

## Get screen height
## Get screen heights

Get the top 25 screen heights of the last 7 days.

Expand Down
12 changes: 8 additions & 4 deletions docs/views.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

## Get unique site views

Get the unique amount of visits per day for the last 14 days. Days without entries are omitted. A user is unique when he visits a site for the first time a day.
Get the unique amount of visits per day, month or year for the last 14 intervals. Entries without views are omitted. A user is unique when he visits a site for the first time a day.

### Request

```
GET /domains/:domainId/views?type=unique
GET /domains/:domainId/views?type=unique&interval=daily
GET /domains/:domainId/views?type=unique&interval=monthly
GET /domains/:domainId/views?type=unique&interval=yearly
```

### Headers
Expand Down Expand Up @@ -46,12 +48,14 @@ Status: 200 OK

## Get total page views

Get the total amount of visits per day for the last 14 days. Days without entries are omitted.
Get the total amount of visits per day, month or year for the last 14 intervals. Entries without views are omitted.

### Request

```
GET /domains/:domainId/views?type=total
GET /domains/:domainId/views?type=total&interval=daily
GET /domains/:domainId/views?type=total&interval=monthly
GET /domains/:domainId/views?type=total&interval=yearly
```

### Headers
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ackee",
"private": true,
"version": "1.5.0",
"version": "1.6.0",
"authors": [
"Tobias Reich <tobias@electerious.com>"
],
Expand Down Expand Up @@ -33,13 +33,14 @@
"@babel/preset-env": "^7.8.3",
"ackee-tracker": "^3.2.2",
"classnames": "^2.2.6",
"date-fns": "^2.9.0",
"dotenv": "^8.2.0",
"formbase": "^12.0.0",
"immer": "^5.3.2",
"is-url": "^1.2.4",
"micro": "^9.3.4",
"microrouter": "^3.1.3",
"mongoose": "^5.8.9",
"mongoose": "^5.9.1",
"node-fetch": "^2.6.0",
"node-schedule": "^1.3.2",
"normalize-url": "^5.0.0",
Expand All @@ -48,8 +49,9 @@
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-redux": "^7.1.3",
"react-use": "^13.26.0",
"react-error-boundary": "^1.2.5",
"react-redux": "^7.2.0",
"react-use": "^13.26.1",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
Expand All @@ -68,14 +70,15 @@
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^2.3.0",
"eslint-plugin-react-hooks": "^2.4.0",
"eslint-plugin-react-native": "^3.8.1",
"mocked-env": "^1.3.2",
"nyc": "^15.0.0",
"test-listen": "^1.1.0"
},
"ava": {
"verbose": true,
"timeout": "20s",
"environmentVariables": {
"ACKEE_TRACKER": "custom name"
}
Expand Down
48 changes: 48 additions & 0 deletions src/aggregations/aggregateDailyViews.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict'

module.exports = (id, unique) => {

const aggregation = [
{
$match: {
domainId: id
}
},
{
$group: {
_id: {
day: {
$dayOfMonth: '$created'
},
month: {
$month: '$created'
},
year: {
$year: '$created'
}
},
count: {
$sum: 1
}
}
},
{
$sort: {
'_id.year': -1,
'_id.month': -1,
'_id.day': -1
}
},
{
$limit: 14
}
]

if (unique === true) aggregation[0].$match.clientId = {
$exists: true,
$ne: null
}

return aggregation

}
44 changes: 44 additions & 0 deletions src/aggregations/aggregateMonthlyViews.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict'

module.exports = (id, unique) => {

const aggregation = [
{
$match: {
domainId: id
}
},
{
$group: {
_id: {
month: {
$month: '$created'
},
year: {
$year: '$created'
}
},
count: {
$sum: 1
}
}
},
{
$sort: {
'_id.year': -1,
'_id.month': -1
}
},
{
$limit: 14
}
]

if (unique === true) aggregation[0].$match.clientId = {
$exists: true,
$ne: null
}

return aggregation

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

const dateWithOffset = require('./dateWithOffset')
const { subDays } = require('date-fns')

const zeroDate = require('../utils/zeroDate')

module.exports = (id, property) => [
{
Expand All @@ -25,7 +27,7 @@ module.exports = (id, property) => [
{
$match: {
created: {
$gte: dateWithOffset(-6)
$gte: subDays(zeroDate(), 6)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

const dateWithOffset = require('./dateWithOffset')
const { subDays } = require('date-fns')

const zeroDate = require('../utils/zeroDate')

module.exports = (id, property) => [
{
Expand All @@ -10,7 +12,7 @@ module.exports = (id, property) => [
$ne: null
},
created: {
$gte: dateWithOffset(-6)
$gte: subDays(zeroDate(), 6)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'

const dateWithOffset = require('./dateWithOffset')
const { subDays } = require('date-fns')

const zeroDate = require('../utils/zeroDate')

module.exports = (id, property) => [
{
Expand All @@ -10,7 +12,7 @@ module.exports = (id, property) => [
$ne: null
},
created: {
$gte: dateWithOffset(-6)
$gte: subDays(zeroDate(), 6)
}
}
},
Expand Down
Loading

0 comments on commit 6393198

Please sign in to comment.