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
19
.github/workflows/mkdocs.yml
vendored
19
.github/workflows/mkdocs.yml
vendored
|
|
@ -17,22 +17,21 @@ permissions:
|
|||
contents: write
|
||||
|
||||
jobs:
|
||||
|
||||
|
||||
# get_docs_changes:
|
||||
# name: run docs changes
|
||||
# uses: ./.github/workflows/get_docs_changes.yml
|
||||
get_docs_changes:
|
||||
name: run docs changes
|
||||
uses: ./.github/workflows/get_docs_changes.yml
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
# needs: get_docs_changes
|
||||
needs: get_docs_changes
|
||||
if: needs.get_docs_changes.outputs.changes_outside_docs == 'false'
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Install Poetry
|
||||
uses: snok/install-poetry@v1.3.1
|
||||
|
||||
- name: Use output
|
||||
run: echo "The stage is finished"
|
||||
|
||||
|
|
@ -41,7 +40,6 @@ jobs:
|
|||
with:
|
||||
python-version: '3.11.x'
|
||||
|
||||
|
||||
- name: Install APT packages
|
||||
run: |
|
||||
sudo apt-get update &&
|
||||
|
|
@ -49,9 +47,10 @@ jobs:
|
|||
|
||||
- name: Install via Poetry
|
||||
run: poetry install --with dev,docs
|
||||
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.PAT_FOR_CROSS_REPOS_CICD_TRIGGERING }}
|
||||
|
||||
- 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
|
||||
custom_dir: docs/overrides
|
||||
|
||||
extra:
|
||||
analytics:
|
||||
provider: segment
|
||||
key: !ENV DOCS_SEGMENT_KEY
|
||||
|
||||
extra_css:
|
||||
- stylesheets/extra.css
|
||||
|
||||
|
|
@ -120,25 +125,24 @@ nav:
|
|||
- Add data: 'data_ingestion.md'
|
||||
- Create LLM enriched data store: 'templates.md'
|
||||
- Explore data: 'search.md'
|
||||
# - SDK:
|
||||
# - Overview: 'sdk_overview.md'
|
||||
- Configuration: 'configuration.md'
|
||||
- What is cognee:
|
||||
- Introduction: 'conceptual_overview.md'
|
||||
- API reference: 'api_reference.md'
|
||||
- Blog:
|
||||
- "blog/index.md"
|
||||
|
||||
|
||||
plugins:
|
||||
- mkdocs-jupyter:
|
||||
ignore_h1_titles: true
|
||||
execute: false
|
||||
- social
|
||||
- search:
|
||||
separator: '[\s\u200b\-_,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])'
|
||||
|
||||
- minify:
|
||||
minify_html: true
|
||||
minify_js: true
|
||||
minify_css: true
|
||||
htmlmin_opts:
|
||||
remove_comments: true
|
||||
cache_safe: true
|
||||
|
||||
- mkdocstrings:
|
||||
handlers:
|
||||
python:
|
||||
|
|
@ -146,13 +150,3 @@ plugins:
|
|||
members_order: alphabetical
|
||||
allow_inspection: 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"
|
||||
|
||||
[tool.poetry.group.docs.dependencies]
|
||||
mkdocs = "^1.4.3"
|
||||
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-material = "^9.5.42"
|
||||
mkdocs-minify-plugin = "^0.8.0"
|
||||
mkdocs-redirects = "^1.2.1"
|
||||
|
||||
[tool.poetry.group.test-docs.dependencies]
|
||||
fastapi = "^0.109.2"
|
||||
diskcache = "^5.6.3"
|
||||
pandas = "2.0.3"
|
||||
tabulate = "^0.9.0"
|
||||
mkdocstrings = {extras = ["python"], version = "^0.26.2"}
|
||||
|
||||
[tool.ruff] # https://beta.ruff.rs/docs/
|
||||
line-length = 100
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue