Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
electerious committed Oct 24, 2020
2 parents 3a38c9c + c982c83 commit dfd7853
Show file tree
Hide file tree
Showing 38 changed files with 1,884 additions and 1,723 deletions.
17 changes: 13 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@
**/Network Trash Folder
**/Temporary Items

# Test artifacts
coverage
.nyc_output

# Package Managers
package-lock.json
npm-debug.log
node_modules

# User data
/data
.env

# Dist folder
dist
dist/*
!dist/.gitkeep

# Miscellaneous
# Files not required by Docker
Dockerfile
.git
.env
.git
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/**/* binary
38 changes: 33 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
data/
node_modules/
coverage/
.nyc_output/
# Temporary files
**/.DS_Store
**/.AppleDouble
**/.LSOverride
**/.idea/
**/Icon\r\r

# External disk files
**/.Spotlight-V100
**/.Trashes

# AFP share files
**/.AppleDB
**/.AppleDesktop
**/.apdisk
**/Network Trash Folder
**/Temporary Items

# Test artifacts
coverage
.nyc_output

# Package Managers
package-lock.json
.env
npm-debug.log
node_modules

# User data
/data
.env

# Dist folder
dist/*
!dist/.gitkeep
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ 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.1.0] - 2020-10-24

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.

### Added

- Support for serverless functions and Netlify (#155)
- Added "Deploy to Netlify" to the [Get Started](https://github.com/electerious/Ackee/blob/master/docs/Get%20started.md) guide
- Build all static files into `/dist` by running `yarn build`
- Start the server without rebuilding static files using `yarn server`

### Fixed

- Reduce high memory usage by building files in a different step (#170)
- Show only active records in visitor counter (#161)
- Labels in modals sometimes not clickable because of invalid ids

## [2.0.3] - 2020-09-20

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ COPY . /srv/app/

# Wait for external service and start Ackee

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

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

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

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

Expand Down Expand Up @@ -34,6 +34,7 @@ Get Ackee up and running…
- […with Docker](docs/Get%20started.md#with-docker)
- […with Helm](docs/Get%20started.md#with-helm)
- […without Docker](docs/Get%20started.md#without-docker)
- […with Netlify](docs/Get%20started.md#with-netlify)
- […with Heroku](docs/Get%20started.md#with-heroku)
- […with Render](docs/Get%20started.md#with-render)

Expand Down
111 changes: 111 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env node
'use strict'
require('dotenv').config()

const { resolve } = require('path')
const { writeFile, readFile } = require('fs').promises
const sass = require('rosid-handler-sass')
const js = require('rosid-handler-js')

const html = require('./src/ui/index')
const isDemoMode = require('./src/utils/isDemoMode')
const isDevelopmentMode = require('./src/utils/isDevelopmentMode')
const customTracker = require('./src/utils/customTracker')
const signale = require('./src/utils/signale')

const index = async () => {

const data = html()

return data

}

const favicon = async () => {

const filePath = resolve(__dirname, 'src/ui/images/favicon.ico')
const data = readFile(filePath)

return data

}

const styles = async () => {

const filePath = resolve(__dirname, 'src/ui/styles/index.scss')
const data = sass(filePath, { optimize: isDevelopmentMode === false })

return data

}

const scripts = async () => {

const filePath = resolve(__dirname, 'src/ui/scripts/index.js')

const babel = {
presets: [
[
'@babel/preset-env', {
targets: {
browsers: [
'last 2 Safari versions',
'last 2 Chrome versions',
'last 2 Opera versions',
'last 2 Firefox versions'
]
}
}
]
],
babelrc: false
}

const data = js(filePath, {
optimize: isDevelopmentMode === false,
env: {
ACKEE_TRACKER: process.env.ACKEE_TRACKER,
ACKEE_DEMO: isDemoMode === true ? 'true' : 'false',
NODE_ENV: isDevelopmentMode === true ? 'development' : 'production'
},
babel
})

return data

}

const tracker = async () => {

const filePath = require.resolve('ackee-tracker')
const data = readFile(filePath, 'utf8')

return data

}

const build = async (path, fn) => {

try {
signale.await(`Building and writing '${ path }'`)
const data = await fn()
await writeFile(path, data)
signale.success(`Finished building '${ path }'`)
} catch (err) {
signale.fatal(err)
process.exit(1)
}

}

// Required files
build('dist/index.html', index)
build('dist/favicon.ico', favicon)
build('dist/index.css', styles)
build('dist/index.js', scripts)
build('dist/tracker.js', tracker)

// Optional files
if (customTracker.exists === true) {
build(`dist/${ customTracker.path }`, tracker)
}
Empty file added dist/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You run the Ackee server which then waits for requests through its API.

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.

The interface of Ackee lets you view and analyse your tracked information.
The interface of Ackee lets you view and analyze your tracked information.

## Features

Expand Down
17 changes: 17 additions & 0 deletions docs/Get started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [With Docker](#with-docker)
- [With Helm](#with-helm)
- [Without Docker](#without-docker)
- [With Netlify](#with-netlify)
- [With Heroku](#with-heroku)
- [With Render](#with-render)

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

## With Netlify

### 1. Deploy to Netlify

[![Deploy](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/electerious/Ackee)

### 2. Configure Ackee

- You need to have a MongoDB instance running (e.g. [MongoDB Atlas](https://www.mongodb.com/cloud/atlas))
- Set a username and password to protect your interface
- Ensure that you're using the correct CORS headers by setting [`ACKEE_ALLOW_ORIGIN`](CORS%20headers.md#heroku-or-platforms-as-a-service-configuration).

### 3. Updating Ackee

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.

## With Heroku

### 1. Deploy to Heroku
Expand Down
2 changes: 1 addition & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ 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.
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.

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.

Expand Down
36 changes: 36 additions & 0 deletions functions/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict'

const { ApolloServer } = require('apollo-server-lambda')
const { UnsignedIntResolver, UnsignedIntTypeDefinition, DateTimeResolver, DateTimeTypeDefinition } = require('graphql-scalars')

const connect = require('../src/utils/connect')
const isDemoMode = require('../src/utils/isDemoMode')
const isDevelopmentMode = require('../src/utils/isDevelopmentMode')
const { createServerlessContext } = require('../src/utils/createContext')

const dbUrl = process.env.ACKEE_MONGODB || process.env.MONGODB_URI

if (dbUrl == null) {
throw new Error('MongoDB connection URI missing in environment')
}

connect(dbUrl)

const apolloServer = new ApolloServer({
introspection: isDemoMode === true || isDevelopmentMode === true,
playground: isDemoMode === true || isDevelopmentMode === true,
debug: isDevelopmentMode === true,
typeDefs: [
UnsignedIntTypeDefinition,
DateTimeTypeDefinition,
require('../src/types')
],
resolvers: {
UnsignedInt: UnsignedIntResolver,
DateTime: DateTimeResolver,
...require('../src/resolvers')
},
context: createServerlessContext
})

exports.handler = apolloServer.createHandler()
17 changes: 17 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[build]
publish = "dist"
command = "yarn build"
functions = "functions/"
environment = { NODE_VERSION = "14.9.0", NODE_ENV = "production" }

[[redirects]]
from = "/api"
to = "/.netlify/functions/api"
status = 200
force = true

[template.environment]
ACKEE_MONGODB = "ACKEE_MONGODB"
ACKEE_USERNAME = "ACKEE_USERNAME"
ACKEE_PASSWORD = "ACKEE_PASSWORD"
ACKEE_ALLOW_ORIGIN = "ACKEE_ALLOW_ORIGIN"
Loading

0 comments on commit dfd7853

Please sign in to comment.