1
0
mirror of https://github.com/barthuijgen/factorio-sites.git synced 2024-12-04 10:44:44 +02:00

Add cloudflare web analytics

This commit is contained in:
Bart 2021-04-02 14:35:35 +02:00
parent c100e3a20a
commit 7b3c480506
4 changed files with 15 additions and 4 deletions

View File

@ -27,6 +27,8 @@ jobs:
- run: yarn
- run: yarn db-gen
- run: yarn nx build blueprints
env:
CF_WEB_ANALYTICS: 6c563c1e5db141129a5fc95d5c459722
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
@ -42,4 +44,4 @@ jobs:
push: true
tags: eu.gcr.io/factorio-sites/blueprints:dev
- run: gsutil -h "Cache-Control:public, max-age=31536000" -m rsync -r -d ./dist/apps/blueprints/.next/static gs://factorio-blueprints-assets/dev/_next/static
- run: gcloud run deploy factorio-blueprints-dev --image=eu.gcr.io/factorio-sites/blueprints:dev --platform managed --region=europe-west4 --remove-env-vars PUBLIC_URL --update-env-vars ASSET_PREFIX=https://storage.googleapis.com/factorio-blueprints-assets/dev
- run: gcloud run deploy factorio-blueprints-dev --image=eu.gcr.io/factorio-sites/blueprints:dev --platform managed --region=europe-west4 --remove-env-vars PUBLIC_URL --update-env-vars ASSET_PREFIX=https://storage.googleapis.com/factorio-blueprints-assets/dev,CF_WEB_ANALYTICS=6c563c1e5db141129a5fc95d5c459722

View File

@ -8,7 +8,8 @@ module.exports = {
reactStrictMode: true,
assetPrefix: process.env.ASSET_PREFIX ? process.env.ASSET_PREFIX : "",
publicRuntimeConfig: {
PUBLIC_URL: process.env.PUBLIC_URL || "",
PUBLIC_URL: process.env.PUBLIC_URL,
CF_WEB_ANALYTICS: process.env.CF_WEB_ANALYTICS,
},
webpack(config, options) {
const { dev, isServer } = options;

View File

@ -9,7 +9,7 @@ import { getSessionToken } from "@factorio-sites/node-utils";
import { Header } from "../components/Header";
import { AuthContext, AuthContextProps } from "../providers/auth";
import { useFetch } from "../hooks/fetch";
import { PUBLIC_URL } from "../utils/env";
import { CF_WEB_ANALYTICS, PUBLIC_URL } from "../utils/env";
const globalStyles = css`
@font-face {
@ -95,6 +95,13 @@ const BlueprintsApp = ({
</main>
</>
)}
{CF_WEB_ANALYTICS && (
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon={`{"token": "${CF_WEB_ANALYTICS}"}`}
></script>
)}
</AuthContext.Provider>
</CookiesProvider>
</ChakraProvider>

View File

@ -1,4 +1,5 @@
import getConfig from "next/config";
const { publicRuntimeConfig } = getConfig();
export const PUBLIC_URL = publicRuntimeConfig.PUBLIC_URL as string;
export const PUBLIC_URL = (publicRuntimeConfig.PUBLIC_URL as string) || "";
export const CF_WEB_ANALYTICS = (publicRuntimeConfig.CF_WEB_ANALYTICS as string) || null;