Skip to content

Commit

Permalink
ci: add plausible to api docs if ENABLE_ANALYTICS is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Nov 24, 2024
1 parent 3eaac21 commit b6eb9ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docs-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
run: frontend/docs/copy-api-docs.sh
env:
DOCS_SOURCE_URL: https://app.browsertrix.com
ENABLE_ANALYTICS: true

- name: Build Docs
run: cd frontend/docs; mkdocs gh-deploy --force
Expand Down
7 changes: 7 additions & 0 deletions frontend/docs/copy-api-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ mkdir $TARGET
curl "$DOCS_SOURCE_URL/api/openapi.json" > $TARGET/openapi.json
curl "$DOCS_SOURCE_URL/api/redoc" > $TARGET/index.html
curl "$DOCS_SOURCE_URL/docs-logo.svg" > $TARGET/../docs-logo.svg

if [ -n $ENABLE_ANALYTICS ]; then
SCRIPT_1=' <script defer data-domain=\"docs.browsertrix.com\" src=\"https://p.webrecorder.net/js/script.outbound-links.js\"></script>'
SCRIPT_2=' <script>window.plausible = window.plausible || function () { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>'
awk "1;/<head>/{ print \"$SCRIPT_1\"; print \"$SCRIPT_2\" }" $TARGET/index.html > $TARGET/index.html.new
mv $TARGET/index.html.new $TARGET/index.html
fi

0 comments on commit b6eb9ff

Please sign in to comment.