Skip to content

Commit

Permalink
Merge branch 'release/2.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
electerious committed Dec 20, 2020
2 parents b7d5caf + e669a95 commit 48fbf54
Show file tree
Hide file tree
Showing 11 changed files with 374 additions and 775 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ 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).

## [2.4.1] - 2020-12-20

### Changed

- Updated Dockerfile reduces the size of the Docker build by ~58% (#195, thanks @omBratteng)

### Fixed

- Errors from permanent tokens not showing up in the UI
- Remove console logs from `apollo-server-plugin-http-headers`
- Log GraphQL error instead of `undefined`

## [2.4.0] - 2020-11-15

Ackee now ignores your own visits once you have logged into the dashboard. Make sure to enable the [`ignoreOwnVisits` option in ackee-tracker](https://github.com/electerious/ackee-tracker#-options) to use this feature. It's currently opt-in, because it requires [a new `Access-Control-Allow-Credentials` header](docs/CORS%20headers.md#credentials), which wasn't previously required. It will be turned on by default in the next major release of Ackee.
Expand Down
40 changes: 25 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
FROM mhart/alpine-node:14

EXPOSE 3000
# Start with first build stage

RUN mkdir -p /srv/app/
FROM mhart/alpine-node:14 AS build
WORKDIR /srv/app/

# Add wait script to the image

ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.5.0/wait /wait
RUN chmod +x /wait

# Add dependencies first so that the docker image build can use
# the cache as long as the dependencies stay unchanged.

COPY package.json yarn.lock /srv/app/
RUN yarn install
RUN yarn install --production --frozen-lockfile

# Copy and compile the source after the dependency step as it's
# more likely that the source changes.

COPY build.js /srv/app/
COPY src /srv/app/src
RUN mkdir dist && yarn build

# Start with second build stage

FROM mhart/alpine-node:14
EXPOSE 3000
WORKDIR /srv/app/

# Copy the source from the build stage to the second stage

COPY --from=build /srv/app/ /srv/app/

# Copy and compile source in the last step as the source
# might change the most.
# Run healthcheck against MongoDB, server and API.
# Wait a bit before start to ensure the `yarn build` is done.

COPY . /srv/app/
HEALTHCHECK --interval=1m --timeout=45s --start-period=45s CMD [ "/srv/app/src/healthcheck.js" ]

# Wait for external service and start Ackee
# Start Ackee

CMD /wait && yarn start
CMD yarn start
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Ackee

[![Travis Build Status](https://travis-ci.org/electerious/Ackee.svg?branch=master)](https://travis-ci.org/electerious/Ackee) [![Coverage Status](https://coveralls.io/repos/github/electerious/Ackee/badge.svg?branch=master)](https://coveralls.io/github/electerious/Ackee?branch=master) [![Dependencies](https://david-dm.org/electerious/Ackee.svg)](https://david-dm.org/electerious/Ackee#info=dependencies) [![Mentioned in Awesome Selfhosted](https://awesome.re/mentioned-badge.svg)](https://github.com/awesome-selfhosted/awesome-selfhosted) [![Donate via PayPal](https://img.shields.io/badge/paypal-donate-009cde.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CYKBESW577YWE)
[![Travis Build Status](https://travis-ci.org/electerious/Ackee.svg?branch=master)](https://travis-ci.org/electerious/Ackee) [![Coverage Status](https://coveralls.io/repos/github/electerious/Ackee/badge.svg?branch=master)](https://coveralls.io/github/electerious/Ackee?branch=master) [![Mentioned in Awesome Selfhosted](https://awesome.re/mentioned-badge.svg)](https://github.com/awesome-selfhosted/awesome-selfhosted) [![Donate via PayPal](https://img.shields.io/badge/paypal-donate-009cde.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CYKBESW577YWE)

Self-hosted, Node.js based analytics tool for those who care about privacy. Ackee runs on your own server, analyzes the traffic of your websites and provides useful statistics in a minimal interface.

Expand Down Expand Up @@ -85,6 +85,7 @@ I am working hard on continuously developing and maintaining Ackee. Please consi
- [Ackee-PHP](https://github.com/BrookeDot/ackee-php) - A PHP Class for Ackee
- [use-ackee](https://github.com/electerious/use-ackee) - Use Ackee in React
- [nuxt-ackee](https://github.com/bdrtsky/nuxt-ackee) - Nuxt.js module for Ackee
- [ngx-ackee-wrapper](https://github.com/oakify/ngx-ackee-wrapper) - Angular wrapper for Ackee
- [django-ackee-middleware](https://github.com/suda/django-ackee-middleware) - Django middleware for Ackee
- [gridsome-plugin-ackee](https://github.com/DenzoNL/gridsome-plugin-ackee) - Gridsome plugin for Ackee
- [vuepress-plugin-ackee](https://github.com/spekulatius/vuepress-plugin-ackee) - VuePress plugin for Ackee
Expand Down
13 changes: 10 additions & 3 deletions docs/Get started.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Get started

Ackee is a simple analytics tool that consists of two parts:

1) A node server running on a server of your choice
2) A tracking script that talks to that server

The node server shows you the UI and receives the request from all of your sites, while the tracking script is set up on each site you want to analyze. Since normally your site and your analytics server are running on the same machine, a subdomain is recommended to proxy all requests from that subdomain to the node server. The following guides help you to set up Ackee on an infrastructure of your choice.

- [With Docker Compose](#with-docker-compose)
- [With Docker](#with-docker)
- [With Helm](#with-helm)
Expand All @@ -13,7 +20,7 @@

### 1. Create the configuration

Create a [`.env` file](https://www.npmjs.com/package/dotenv) in the root of this project to store all environment variables in one file.
Pull the project and create a [`.env` file](https://www.npmjs.com/package/dotenv) in the root to store all environment variables in one file.

```
ACKEE_USERNAME=username
Expand Down Expand Up @@ -125,7 +132,7 @@ Make sure to install and update all dependencies before you continue. The instal

### 2. Create the configuration

Configure Ackee using environment variables or create a [`.env` file](https://www.npmjs.com/package/dotenv) in the root of the project to store all variables in one file.
Pull the project and configure Ackee using environment variables or create a [`.env` file](https://www.npmjs.com/package/dotenv) in the root of the project to store all variables in one file.

```
ACKEE_MONGODB=mongodb://localhost:27017/ackee
Expand All @@ -144,7 +151,7 @@ The username and password variables are used to secure your Ackee interface/API.
Install all required dependencies.

```sh
yarn
yarn install
```

### 4. Run Ackee
Expand Down
6 changes: 3 additions & 3 deletions docs/Privacy Policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Although, we recommend to mention Ackee in your privacy policy. Let your visitor
To get information about the behavior of our visitors, we use
<a href="https://ackee.electerious.com" target="_blank">Ackee</a>. This
analytics software gives us insight about our visitors only in general, but not
about individuals per say, as it does not track visitors and does not store any
about individuals per se, as it does not track visitors and does not store any
personal identifiable information.
<a href="https://docs.ackee.electerious.com/#/docs/Anonymization" target="_blank">Go
to their documentation</a> to find out what Ackee collects.
Expand All @@ -24,8 +24,8 @@ to their documentation</a> to find out what Ackee collects.
To get information about the behavior of our visitors, we use
[Ackee](https://ackee.electerious.com). This
analytics software gives us insight about our visitors only in general, but not
about individuals per say, as it does not track visitors and does not store any
about individuals per se, as it does not track visitors and does not store any
personal identifiable information.
[Go
to their documentation](https://docs.ackee.electerious.com/#/docs/Anonymization) to find out what Ackee collects.
```
```
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ackee",
"private": true,
"version": "2.4.0",
"version": "2.4.1",
"authors": [
"Tobias Reich <tobias@electerious.com>"
],
Expand Down Expand Up @@ -37,30 +37,30 @@
"ackee-tracker": "^4.2.0",
"apollo-server-lambda": "^2.19.0",
"apollo-server-micro": "^2.19.0",
"apollo-server-plugin-http-headers": "^0.1.3",
"apollo-server-plugin-http-headers": "^0.1.4",
"classnames": "^2.2.6",
"date-fns": "^2.16.1",
"date-fns-tz": "^1.0.10",
"debounce-promise": "^3.1.2",
"dotenv": "^8.2.0",
"formbase": "^12.0.1",
"graphql": "^15.4.0",
"graphql-scalars": "^1.4.1",
"graphql-tools": "^7.0.1",
"graphql-scalars": "^1.6.1",
"graphql-tools": "^7.0.2",
"human-number": "^1.0.6",
"immer": "^7.0.14",
"immer": "^8.0.0",
"is-url": "^1.2.4",
"micro": "^9.3.4",
"microrouter": "^3.1.3",
"mongoose": "^5.10.14",
"mongoose": "^5.11.8",
"node-fetch": "^2.6.1",
"node-schedule": "^1.3.2",
"normalize-url": "^5.0.0",
"normalize.css": "^8.0.1",
"prop-types": "^15.7.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-error-boundary": "^3.0.1",
"react-error-boundary": "^3.1.0",
"react-fast-compare": "^3.2.0",
"react-hotkeys-hook": "^2.4.0",
"react-redux": "^7.2.2",
Expand All @@ -70,23 +70,23 @@
"redux-thunk": "^2.3.0",
"request-ip": "^2.1.3",
"rosid-handler-js": "^13.0.1",
"rosid-handler-sass": "^7.0.0",
"rosid-handler-sass": "^8.0.0",
"s-ago": "^2.2.0",
"sanitize-filename": "^1.6.3",
"shortid": "^2.2.16",
"signale": "^1.4.0",
"uuid": "^8.3.0"
"uuid": "^8.3.2"
},
"devDependencies": {
"@electerious/eslint-config": "^1.3.4",
"ava": "3.13.0",
"ava": "3.14.0",
"coveralls": "^3.1.0",
"eslint": "^7.12.1",
"eslint": "^7.16.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-native": "^3.9.1",
"husky": "^4.3.0",
"husky": "^4.3.6",
"mocked-env": "^1.3.2",
"mongodb-memory-server": "^6.9.2",
"nodemon": "^2.0.6",
Expand Down
55 changes: 55 additions & 0 deletions src/healthcheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env node
'use strict'
require('dotenv').config()

const fetch = require('node-fetch')

const signale = require('./utils/signale')
const checkMongoDB = require('./utils/connect')

const port = process.env.ACKEE_PORT || process.env.PORT || 3000
const dbUrl = process.env.ACKEE_MONGODB || process.env.MONGODB_URI
const serverUrl = `http://localhost:${ port }`

if (dbUrl == null) {
signale.fatal('MongoDB connection URI missing in environment')
process.exit(1)
}

const checkServer = async (url) => {
const res = await fetch(url)

if (res.ok === false) {
throw new Error(`Server is unhealthy and returned with the status '${ res.status }'`)
}
}

const checkApi = async (url) => {
const res = await fetch(url)

if (res.ok === false) {
throw new Error(`API is unhealthy and returned with the status '${ res.status }'`)
}
}

const exit = (healthy) => process.exit(healthy === true ? 0 : 1)

const check = () => Promise.all([
checkMongoDB(dbUrl),
checkServer(serverUrl),
checkApi(`${ serverUrl }/.well-known/apollo/server-health`)
])

const handleSuccess = () => {
signale.success('Ackee is up and running')
exit(true)
}

const handleFailure = (err) => {
signale.fatal(err)
exit(false)
}

check()
.then(handleSuccess)
.catch(handleFailure)
9 changes: 5 additions & 4 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ const handleGraphError = (err) => {
// errors will only show up in the response and as a warning
// in the console output.

const originalError = err.originalError
const isKnownError = originalError instanceof KnownError
const suitableError = err.originalError || err
const isKnownError = suitableError instanceof KnownError

// Only log the full error stack when the error isn't a known response
if (isKnownError === false) {
signale.fatal(originalError)
signale.fatal(suitableError)
return err
}

signale.warn(err.originalError.message)
signale.warn(suitableError.message)
return err

}
Expand Down Expand Up @@ -139,6 +139,7 @@ const routes = [

post(graphqlPath, graphqlHandler),
get(graphqlPath, graphqlHandler),
get('/.well-known/apollo/server-health', graphqlHandler),

get('/*', notFound),
post('/*', notFound),
Expand Down
6 changes: 4 additions & 2 deletions src/ui/scripts/enhancers/enhanceState.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default (state) => {
state.sizes.fetching === true ||
state.languages.fetching === true ||
state.domains.fetching === true ||
state.token.fetching === true
state.token.fetching === true ||
state.permanentTokens.fetching === true
)

const errors = [
Expand All @@ -33,7 +34,8 @@ export default (state) => {
state.sizes.error,
state.languages.error,
state.domains.error,
state.token.error
state.token.error,
state.permanentTokens.error
].filter(isDefined)

return Object.assign({}, state, {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ module.exports = (dbUrl) => mongoose.connect(dbUrl, {
useFindAndModify: false,
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true
useUnifiedTopology: true,
connectTimeoutMS: 60000
})
Loading

1 comment on commit 48fbf54

@vercel
Copy link

@vercel vercel bot commented on 48fbf54 Dec 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.