feature: add tracking to docs website (#165)
* feat: add segment tracking snippet
This commit is contained in:
parent
1088b58f11
commit
351355a48d
5 changed files with 1315 additions and 1404 deletions
17
.github/workflows/mkdocs.yml
vendored
17
.github/workflows/mkdocs.yml
vendored
|
|
@ -17,22 +17,21 @@ permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
get_docs_changes:
|
||||||
|
name: run docs changes
|
||||||
# get_docs_changes:
|
uses: ./.github/workflows/get_docs_changes.yml
|
||||||
# name: run docs changes
|
|
||||||
# uses: ./.github/workflows/get_docs_changes.yml
|
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# needs: get_docs_changes
|
needs: get_docs_changes
|
||||||
|
if: needs.get_docs_changes.outputs.changes_outside_docs == 'false'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
|
|
||||||
- name: Install Poetry
|
- name: Install Poetry
|
||||||
uses: snok/install-poetry@v1.3.1
|
uses: snok/install-poetry@v1.3.1
|
||||||
|
|
||||||
- name: Use output
|
- name: Use output
|
||||||
run: echo "The stage is finished"
|
run: echo "The stage is finished"
|
||||||
|
|
||||||
|
|
@ -41,7 +40,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
python-version: '3.11.x'
|
python-version: '3.11.x'
|
||||||
|
|
||||||
|
|
||||||
- name: Install APT packages
|
- name: Install APT packages
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update &&
|
sudo apt-get update &&
|
||||||
|
|
@ -49,9 +47,10 @@ jobs:
|
||||||
|
|
||||||
- name: Install via Poetry
|
- name: Install via Poetry
|
||||||
run: poetry install --with dev,docs
|
run: poetry install --with dev,docs
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.PAT_FOR_CROSS_REPOS_CICD_TRIGGERING }}
|
GH_TOKEN: ${{ secrets.PAT_FOR_CROSS_REPOS_CICD_TRIGGERING }}
|
||||||
|
|
||||||
- name: Build and deploy MkDocs
|
- name: Build and deploy MkDocs
|
||||||
run: poetry run mkdocs gh-deploy --force
|
run: poetry run mkdocs gh-deploy --force
|
||||||
|
env:
|
||||||
|
DOCS_SEGMENT_KEY: ${{ secrets.DOCS_SEGMENT_KEY }}
|
||||||
|
|
|
||||||
15
docs/overrides/partials/integrations/analytics/segment.html
Normal file
15
docs/overrides/partials/integrations/analytics/segment.html
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<script>
|
||||||
|
var segmentKey = "{{ config.extra.analytics.key }}"
|
||||||
|
|
||||||
|
/* Wait for page to load and application to mount */
|
||||||
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
try {
|
||||||
|
!function(){var i="analytics",analytics=window[i]=window[i]||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","screen","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware","register"];analytics.factory=function(e){return function(){if(window[i].initialized)return window[i][e].apply(window[i],arguments);var n=Array.prototype.slice.call(arguments);if(["track","screen","alias","group","page","identify"].indexOf(e)>-1){var c=document.querySelector("link[rel='canonical']");n.push({__t:"bpc",c:c&&c.getAttribute("href")||void 0,p:location.pathname,u:location.href,s:location.search,t:document.title,r:document.referrer})}n.unshift(e);analytics.push(n);return analytics}};for(var n=0;n<analytics.methods.length;n++){var key=analytics.methods[n];analytics[key]=analytics.factory(key)}analytics.load=function(key,n){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.setAttribute("data-global-segment-analytics-key",i);t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";var r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(t,r);analytics._loadOptions=n};analytics._writeKey=segmentKey;;analytics.SNIPPET_VERSION="5.2.0";
|
||||||
|
analytics.load(segmentKey);
|
||||||
|
analytics.page();
|
||||||
|
}}();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load Segment analytics", error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
30
mkdocs.yml
30
mkdocs.yml
|
|
@ -63,6 +63,11 @@ theme:
|
||||||
code: Roboto Mono
|
code: Roboto Mono
|
||||||
custom_dir: docs/overrides
|
custom_dir: docs/overrides
|
||||||
|
|
||||||
|
extra:
|
||||||
|
analytics:
|
||||||
|
provider: segment
|
||||||
|
key: !ENV DOCS_SEGMENT_KEY
|
||||||
|
|
||||||
extra_css:
|
extra_css:
|
||||||
- stylesheets/extra.css
|
- stylesheets/extra.css
|
||||||
|
|
||||||
|
|
@ -120,25 +125,24 @@ nav:
|
||||||
- Add data: 'data_ingestion.md'
|
- Add data: 'data_ingestion.md'
|
||||||
- Create LLM enriched data store: 'templates.md'
|
- Create LLM enriched data store: 'templates.md'
|
||||||
- Explore data: 'search.md'
|
- Explore data: 'search.md'
|
||||||
# - SDK:
|
|
||||||
# - Overview: 'sdk_overview.md'
|
|
||||||
- Configuration: 'configuration.md'
|
- Configuration: 'configuration.md'
|
||||||
- What is cognee:
|
- What is cognee:
|
||||||
- Introduction: 'conceptual_overview.md'
|
- Introduction: 'conceptual_overview.md'
|
||||||
- API reference: 'api_reference.md'
|
- API reference: 'api_reference.md'
|
||||||
- Blog:
|
|
||||||
- "blog/index.md"
|
|
||||||
|
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
- mkdocs-jupyter:
|
|
||||||
ignore_h1_titles: true
|
|
||||||
execute: false
|
|
||||||
- social
|
|
||||||
- search:
|
- search:
|
||||||
separator: '[\s\u200b\-_,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])'
|
separator: '[\s\u200b\-_,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])'
|
||||||
|
|
||||||
- minify:
|
- minify:
|
||||||
minify_html: true
|
minify_html: true
|
||||||
|
minify_js: true
|
||||||
|
minify_css: true
|
||||||
|
htmlmin_opts:
|
||||||
|
remove_comments: true
|
||||||
|
cache_safe: true
|
||||||
|
|
||||||
- mkdocstrings:
|
- mkdocstrings:
|
||||||
handlers:
|
handlers:
|
||||||
python:
|
python:
|
||||||
|
|
@ -146,13 +150,3 @@ plugins:
|
||||||
members_order: alphabetical
|
members_order: alphabetical
|
||||||
allow_inspection: true
|
allow_inspection: true
|
||||||
show_bases: true
|
show_bases: true
|
||||||
- blog:
|
|
||||||
enabled: !ENV CI
|
|
||||||
blog_dir: "blog"
|
|
||||||
blog_toc: true
|
|
||||||
post_dir: blog/posts
|
|
||||||
post_date_format: yyyy/MM/dd
|
|
||||||
post_url_format: "{date}/{slug}"
|
|
||||||
authors_file: "{blog}/.authors.yml"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
2640
poetry.lock
generated
2640
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -90,20 +90,9 @@ mypy = "^1.7.1"
|
||||||
notebook = "^7.1.1"
|
notebook = "^7.1.1"
|
||||||
|
|
||||||
[tool.poetry.group.docs.dependencies]
|
[tool.poetry.group.docs.dependencies]
|
||||||
mkdocs = "^1.4.3"
|
mkdocs-material = "^9.5.42"
|
||||||
mkdocs-material = {extras = ["imaging"], version = "^9.5.9"}
|
|
||||||
mkdocstrings = "^0.22.0"
|
|
||||||
mkdocstrings-python = "^1.1.2"
|
|
||||||
pytest-examples = "^0.0.10"
|
|
||||||
mkdocs-jupyter = "^0.24.6"
|
|
||||||
mkdocs-minify-plugin = "^0.8.0"
|
mkdocs-minify-plugin = "^0.8.0"
|
||||||
mkdocs-redirects = "^1.2.1"
|
mkdocstrings = {extras = ["python"], version = "^0.26.2"}
|
||||||
|
|
||||||
[tool.poetry.group.test-docs.dependencies]
|
|
||||||
fastapi = "^0.109.2"
|
|
||||||
diskcache = "^5.6.3"
|
|
||||||
pandas = "2.0.3"
|
|
||||||
tabulate = "^0.9.0"
|
|
||||||
|
|
||||||
[tool.ruff] # https://beta.ruff.rs/docs/
|
[tool.ruff] # https://beta.ruff.rs/docs/
|
||||||
line-length = 100
|
line-length = 100
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue