Skip to content

Commit dfd7853

Browse files
committed
Merge branch 'release/2.1.0'
2 parents 3a38c9c + c982c83 commit dfd7853

38 files changed

+1884
-1723
lines changed

Diff for: .dockerignore

+13-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,23 @@
1616
**/Network Trash Folder
1717
**/Temporary Items
1818

19+
# Test artifacts
20+
coverage
21+
.nyc_output
22+
1923
# Package Managers
24+
package-lock.json
2025
npm-debug.log
2126
node_modules
2227

28+
# User data
29+
/data
30+
.env
31+
2332
# Dist folder
24-
dist
33+
dist/*
34+
!dist/.gitkeep
2535

26-
# Miscellaneous
36+
# Files not required by Docker
2737
Dockerfile
28-
.git
29-
.env
38+
.git

Diff for: .gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/**/* binary

Diff for: .gitignore

+33-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
1-
data/
2-
node_modules/
3-
coverage/
4-
.nyc_output/
1+
# Temporary files
2+
**/.DS_Store
3+
**/.AppleDouble
4+
**/.LSOverride
5+
**/.idea/
6+
**/Icon\r\r
7+
8+
# External disk files
9+
**/.Spotlight-V100
10+
**/.Trashes
11+
12+
# AFP share files
13+
**/.AppleDB
14+
**/.AppleDesktop
15+
**/.apdisk
16+
**/Network Trash Folder
17+
**/Temporary Items
18+
19+
# Test artifacts
20+
coverage
21+
.nyc_output
22+
23+
# Package Managers
524
package-lock.json
6-
.env
25+
npm-debug.log
26+
node_modules
27+
28+
# User data
29+
/data
30+
.env
31+
32+
# Dist folder
33+
dist/*
34+
!dist/.gitkeep

Diff for: CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
44

55
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).
66

7+
## [2.1.0] - 2020-10-24
8+
9+
This release introduces support for serverless functions. You can now deploy Ackee to Netlify 🚀 It also reduces the memory usage and allows you to build all static files into `/dist` by running `yarn build`. Run `yarn server` to start the server without building those files, again. This reduces the initial startup time. `yarn start` combines both commands for convenience and is still the recommended way to run Ackee.
10+
11+
### Added
12+
13+
- Support for serverless functions and Netlify (#155)
14+
- Added "Deploy to Netlify" to the [Get Started](https://github.com/electerious/Ackee/blob/master/docs/Get%20started.md) guide
15+
- Build all static files into `/dist` by running `yarn build`
16+
- Start the server without rebuilding static files using `yarn server`
17+
18+
### Fixed
19+
20+
- Reduce high memory usage by building files in a different step (#170)
21+
- Show only active records in visitor counter (#161)
22+
- Labels in modals sometimes not clickable because of invalid ids
23+
724
## [2.0.3] - 2020-09-20
825

926
### Fixed

Diff for: Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ COPY . /srv/app/
2323

2424
# Wait for external service and start Ackee
2525

26-
CMD /wait && yarn run start
26+
CMD /wait && yarn start

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[![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)
88

9-
Self-hosted, Node.js based analytics tool for those who care about privacy. Ackee runs on your own server, analyses the traffic of your websites and provides useful statistics in a minimal interface.
9+
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.
1010

1111
[🌍 Website](https://ackee.electerious.com) | [🔮 Live Demo](https://demo.ackee.electerious.com) | [🧸 GraphQL Playground](https://demo.ackee.electerious.com/api)
1212

@@ -34,6 +34,7 @@ Get Ackee up and running…
3434
- […with Docker](docs/Get%20started.md#with-docker)
3535
- […with Helm](docs/Get%20started.md#with-helm)
3636
- […without Docker](docs/Get%20started.md#without-docker)
37+
- […with Netlify](docs/Get%20started.md#with-netlify)
3738
- […with Heroku](docs/Get%20started.md#with-heroku)
3839
- […with Render](docs/Get%20started.md#with-render)
3940

Diff for: build.js

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/usr/bin/env node
2+
'use strict'
3+
require('dotenv').config()
4+
5+
const { resolve } = require('path')
6+
const { writeFile, readFile } = require('fs').promises
7+
const sass = require('rosid-handler-sass')
8+
const js = require('rosid-handler-js')
9+
10+
const html = require('./src/ui/index')
11+
const isDemoMode = require('./src/utils/isDemoMode')
12+
const isDevelopmentMode = require('./src/utils/isDevelopmentMode')
13+
const customTracker = require('./src/utils/customTracker')
14+
const signale = require('./src/utils/signale')
15+
16+
const index = async () => {
17+
18+
const data = html()
19+
20+
return data
21+
22+
}
23+
24+
const favicon = async () => {
25+
26+
const filePath = resolve(__dirname, 'src/ui/images/favicon.ico')
27+
const data = readFile(filePath)
28+
29+
return data
30+
31+
}
32+
33+
const styles = async () => {
34+
35+
const filePath = resolve(__dirname, 'src/ui/styles/index.scss')
36+
const data = sass(filePath, { optimize: isDevelopmentMode === false })
37+
38+
return data
39+
40+
}
41+
42+
const scripts = async () => {
43+
44+
const filePath = resolve(__dirname, 'src/ui/scripts/index.js')
45+
46+
const babel = {
47+
presets: [
48+
[
49+
'@babel/preset-env', {
50+
targets: {
51+
browsers: [
52+
'last 2 Safari versions',
53+
'last 2 Chrome versions',
54+
'last 2 Opera versions',
55+
'last 2 Firefox versions'
56+
]
57+
}
58+
}
59+
]
60+
],
61+
babelrc: false
62+
}
63+
64+
const data = js(filePath, {
65+
optimize: isDevelopmentMode === false,
66+
env: {
67+
ACKEE_TRACKER: process.env.ACKEE_TRACKER,
68+
ACKEE_DEMO: isDemoMode === true ? 'true' : 'false',
69+
NODE_ENV: isDevelopmentMode === true ? 'development' : 'production'
70+
},
71+
babel
72+
})
73+
74+
return data
75+
76+
}
77+
78+
const tracker = async () => {
79+
80+
const filePath = require.resolve('ackee-tracker')
81+
const data = readFile(filePath, 'utf8')
82+
83+
return data
84+
85+
}
86+
87+
const build = async (path, fn) => {
88+
89+
try {
90+
signale.await(`Building and writing '${ path }'`)
91+
const data = await fn()
92+
await writeFile(path, data)
93+
signale.success(`Finished building '${ path }'`)
94+
} catch (err) {
95+
signale.fatal(err)
96+
process.exit(1)
97+
}
98+
99+
}
100+
101+
// Required files
102+
build('dist/index.html', index)
103+
build('dist/favicon.ico', favicon)
104+
build('dist/index.css', styles)
105+
build('dist/index.js', scripts)
106+
build('dist/tracker.js', tracker)
107+
108+
// Optional files
109+
if (customTracker.exists === true) {
110+
build(`dist/${ customTracker.path }`, tracker)
111+
}

Diff for: dist/.gitkeep

Whitespace-only changes.

Diff for: docs/FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ You run the Ackee server which then waits for requests through its API.
1414

1515
The API of Ackee accepts information about your visitors sent to it using [ackee-tracker](https://github.com/electerious/ackee-tracker). It's a small script you add to your sites, similar to the JavaScript tracking snippet provided by Google Analytics.
1616

17-
The interface of Ackee lets you view and analyse your tracked information.
17+
The interface of Ackee lets you view and analyze your tracked information.
1818

1919
## Features
2020

Diff for: docs/Get started.md

+17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [With Docker](#with-docker)
55
- [With Helm](#with-helm)
66
- [Without Docker](#without-docker)
7+
- [With Netlify](#with-netlify)
78
- [With Heroku](#with-heroku)
89
- [With Render](#with-render)
910

@@ -160,6 +161,22 @@ Ackee now runs on port `3000` and is only accessible from you local network. It'
160161
- [SSL and HTTPS](SSL%20and%20HTTPS.md)
161162
- [CORS headers](CORS%20headers.md)
162163

164+
## With Netlify
165+
166+
### 1. Deploy to Netlify
167+
168+
[![Deploy](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/electerious/Ackee)
169+
170+
### 2. Configure Ackee
171+
172+
- You need to have a MongoDB instance running (e.g. [MongoDB Atlas](https://www.mongodb.com/cloud/atlas))
173+
- Set a username and password to protect your interface
174+
- Ensure that you're using the correct CORS headers by setting [`ACKEE_ALLOW_ORIGIN`](CORS%20headers.md#heroku-or-platforms-as-a-service-configuration).
175+
176+
### 3. Updating Ackee
177+
178+
Netlify adds a forked version of Ackee to your GitHub repositories. You can always [pull the newest code](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/syncing-a-fork) from the original project. Pushing those changes to your repository will automatically deploy the new version of Ackee on Netlify.
179+
163180
## With Heroku
164181

165182
### 1. Deploy to Heroku

Diff for: docs/Options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ACKEE_TTL=3600000
5656

5757
## Tracker
5858

59-
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.
59+
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. Avoid characters that can't be used in filenames.
6060

6161
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.
6262

Diff for: functions/api.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict'
2+
3+
const { ApolloServer } = require('apollo-server-lambda')
4+
const { UnsignedIntResolver, UnsignedIntTypeDefinition, DateTimeResolver, DateTimeTypeDefinition } = require('graphql-scalars')
5+
6+
const connect = require('../src/utils/connect')
7+
const isDemoMode = require('../src/utils/isDemoMode')
8+
const isDevelopmentMode = require('../src/utils/isDevelopmentMode')
9+
const { createServerlessContext } = require('../src/utils/createContext')
10+
11+
const dbUrl = process.env.ACKEE_MONGODB || process.env.MONGODB_URI
12+
13+
if (dbUrl == null) {
14+
throw new Error('MongoDB connection URI missing in environment')
15+
}
16+
17+
connect(dbUrl)
18+
19+
const apolloServer = new ApolloServer({
20+
introspection: isDemoMode === true || isDevelopmentMode === true,
21+
playground: isDemoMode === true || isDevelopmentMode === true,
22+
debug: isDevelopmentMode === true,
23+
typeDefs: [
24+
UnsignedIntTypeDefinition,
25+
DateTimeTypeDefinition,
26+
require('../src/types')
27+
],
28+
resolvers: {
29+
UnsignedInt: UnsignedIntResolver,
30+
DateTime: DateTimeResolver,
31+
...require('../src/resolvers')
32+
},
33+
context: createServerlessContext
34+
})
35+
36+
exports.handler = apolloServer.createHandler()

Diff for: netlify.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[build]
2+
publish = "dist"
3+
command = "yarn build"
4+
functions = "functions/"
5+
environment = { NODE_VERSION = "14.9.0", NODE_ENV = "production" }
6+
7+
[[redirects]]
8+
from = "/api"
9+
to = "/.netlify/functions/api"
10+
status = 200
11+
force = true
12+
13+
[template.environment]
14+
ACKEE_MONGODB = "ACKEE_MONGODB"
15+
ACKEE_USERNAME = "ACKEE_USERNAME"
16+
ACKEE_PASSWORD = "ACKEE_PASSWORD"
17+
ACKEE_ALLOW_ORIGIN = "ACKEE_ALLOW_ORIGIN"

0 commit comments

Comments
 (0)