Skip to content

Commit

Permalink
Merge branch 'dev' into analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Oct 30, 2024
2 parents 1073ed0 + 1225473 commit 9211c5f
Show file tree
Hide file tree
Showing 25 changed files with 783 additions and 772 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/cd-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,26 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Extract version parts from input
id: extract_version
run: |
echo "version=$(echo ${{ github.event.inputs.version }})" >> $GITHUB_ENV
echo "major=$(echo ${{ github.event.inputs.version }} | cut -d. -f1)" >> $GITHUB_ENV
echo "minor=$(echo ${{ github.event.inputs.version }} | cut -d. -f2)" >> $GITHUB_ENV
- name: Generate tags
id: generate_tags
run: |
echo "tag_major=$(echo ${{ matrix.db-type }}-${{ env.major }})" >> $GITHUB_ENV
echo "tag_minor=$(echo ${{ matrix.db-type }}-${{ env.major }}.${{ env.minor }})" >> $GITHUB_ENV
echo "tag_patch=$(echo ${{ matrix.db-type }}-${{ env.version }})" >> $GITHUB_ENV
echo "tag_latest=$(echo ${{ matrix.db-type }}-latest)" >> $GITHUB_ENV
- uses: mr-smithers-excellent/docker-build-push@v6
name: Build & push Docker image to ghcr.io for ${{ matrix.db-type }}
with:
image: umami
tags: ${{ matrix.db-type }}-${{ inputs.version }}, ${{ matrix.db-type }}-latest
tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }}
buildArgs: DATABASE_TYPE=${{ matrix.db-type }}
registry: ghcr.io
multiPlatform: true
Expand All @@ -36,7 +51,7 @@ jobs:
name: Build & push Docker image to docker.io for ${{ matrix.db-type }}
with:
image: umamisoftware/umami
tags: ${{ matrix.db-type }}-${{ inputs.version }}, ${{ matrix.db-type }}-latest
tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }}
buildArgs: DATABASE_TYPE=${{ matrix.db-type }}
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,33 @@ jobs:

- name: Set env
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "NOW=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: Generate tags
id: generate_tags
run: |
echo "tag_patch=$(echo ${{ matrix.db-type }})-${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "tag_minor=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1,2)" >> $GITHUB_ENV
echo "tag_major=$(echo ${{ matrix.db-type }})-$(echo ${GITHUB_REF#refs/tags/} | cut -d. -f1)" >> $GITHUB_ENV
echo "tag_latest=$(echo ${{ matrix.db-type }})-latest" >> $GITHUB_ENV
- uses: mr-smithers-excellent/docker-build-push@v6
name: Build & push Docker image to ghcr.io for ${{ matrix.db-type }}
with:
image: umami
tags: ${{ matrix.db-type }}-${{ env.RELEASE_VERSION }}, ${{ matrix.db-type }}-latest
tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }}
buildArgs: DATABASE_TYPE=${{ matrix.db-type }}
registry: ghcr.io
multiPlatform: true
platform: linux/amd64,linux/arm64
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- uses: mr-smithers-excellent/docker-build-push@v6
name: Build & push Docker image to docker.io for ${{ matrix.db-type }}
with:
image: umamisoftware/umami
tags: ${{ matrix.db-type }}-${{ env.RELEASE_VERSION }}, ${{ matrix.db-type }}-latest
tags: ${{ env.tag_major }}, ${{ env.tag_minor }}, ${{ env.tag_patch }}, ${{ env.tag_latest }}
buildArgs: DATABASE_TYPE=${{ matrix.db-type }}
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://umami.is/images/umami-logo.png" alt="Umami Logo" width="100">
<img src="https://content.umami.is/website/images/umami-logo.png" alt="Umami Logo" width="100">
</p>

<h1 align="center">Umami</h1>
Expand Down Expand Up @@ -36,7 +36,7 @@ A detailed getting started guide can be found at [umami.is/docs](https://umami.i
### Requirements

- A server with Node.js version 16.13 or newer
- A database. Umami supports [MySQL](https://www.mysql.com/) (minimum v8.0) and [PostgreSQL](https://www.postgresql.org/) (minimum v12.14) databases.
- A database. Umami supports [MariaDB](https://www.mariadb.org/) (minimum v10.5), [MySQL](https://www.mysql.com/) (minimum v8.0) and [PostgreSQL](https://www.postgresql.org/) (minimum v12.14) databases.

### Install Yarn

Expand Down
77 changes: 52 additions & 25 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ require('dotenv').config();
const path = require('path');
const pkg = require('./package.json');

const TRACKER_SCRIPT = '/script.js';

const basePath = process.env.BASE_PATH;
const collectApiEndpoint = process.env.COLLECT_API_ENDPOINT;
const cloudMode = process.env.CLOUD_MODE;
Expand All @@ -14,6 +16,7 @@ const forceSSL = process.env.FORCE_SSL;
const frameAncestors = process.env.ALLOWED_FRAME_URLS;
const privateMode = process.env.PRIVATE_MODE;
const trackerScriptName = process.env.TRACKER_SCRIPT_NAME;
const trackerScriptURL = process.env.TRACKER_SCRIPT_URL;

const contentSecurityPolicy = [
`default-src 'self'`,
Expand All @@ -24,7 +27,7 @@ const contentSecurityPolicy = [
`frame-ancestors 'self' ${frameAncestors}`,
];

const headers = [
const defaultHeaders = [
{
key: 'X-DNS-Prefetch-Control',
value: 'on',
Expand All @@ -39,34 +42,46 @@ const headers = [
];

if (forceSSL) {
headers.push({
defaultHeaders.push({
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
});
}

const trackerHeaders = [
{
key: 'Access-Control-Allow-Origin',
value: '*',
},
];

const headers = [
{
source: '/:path*',
headers: defaultHeaders,
},
{
source: TRACKER_SCRIPT,
headers: trackerHeaders,
},
];

const rewrites = [];

if (trackerScriptURL) {
rewrites.push({
source: TRACKER_SCRIPT,
destination: trackerScriptURL,
});
}

if (collectApiEndpoint) {
rewrites.push({
source: collectApiEndpoint,
destination: '/api/send',
});
}

if (trackerScriptName) {
const names = trackerScriptName?.split(',').map(name => name.trim());

if (names) {
names.forEach(name => {
rewrites.push({
source: `/${name.replace(/^\/+/, '')}`,
destination: '/tracker.js',
});
});
}
}

const redirects = [
{
source: '/settings',
Expand All @@ -85,6 +100,27 @@ const redirects = [
},
];

// Adding rewrites + headers for all alternative tracker script names.
if (trackerScriptName) {
const names = trackerScriptName?.split(',').map(name => name.trim());

if (names) {
names.forEach(name => {
const normalizedSource = `/${name.replace(/^\/+/, '')}`;

rewrites.push({
source: normalizedSource,
destination: TRACKER_SCRIPT,
});

headers.push({
source: normalizedSource,
headers: trackerHeaders,
});
});
}
}

if (cloudMode && cloudUrl) {
redirects.push({
source: '/settings/:path*',
Expand Down Expand Up @@ -153,20 +189,11 @@ const config = {
return config;
},
async headers() {
return [
{
source: '/:path*',
headers,
},
];
return headers;
},
async rewrites() {
return [
...rewrites,
{
source: '/script.js',
destination: 'https://tracker-script.umami.dev/',
},
{
source: '/telemetry.js',
destination: '/api/scripts/telemetry',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "umami",
"version": "2.13.2",
"version": "2.14.0",
"description": "A simple, fast, privacy-focused alternative to Google Analytics.",
"author": "Umami Software, Inc. <hello@umami.is>",
"license": "MIT",
Expand Down
Loading

0 comments on commit 9211c5f

Please sign in to comment.