-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(docs): adding analytics #6350
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8776230
feat: new docs structure
signorecello 77de7c4
path fixes
signorecello 13364d7
chore(docs) adding analytics
signorecello 25e180f
broken links
signorecello 20449fc
chore: replace relative paths to noir-protocol-circuits
AztecBot 49af0f1
git subrepo push --branch=master noir-projects/aztec-nr
AztecBot 9d2ed57
syncing
signorecello 9772c62
syncing
signorecello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,13 @@ Documentation for the Aztec Network, built with docusaurus | |
|
||
You can view the latest successful build here: https://docs.aztec.network | ||
|
||
## Files | ||
## Docusaurus | ||
|
||
This website is built using [Docusaurus 3](https://docusaurus.io/), a modern static website generator. | ||
|
||
### Files | ||
|
||
Here are the most relevant files you should be aware of: | ||
|
||
- `.gitignore` - This specifies which files Git should ignore when committing and pushing to remote repositories. | ||
- `docusaurus.config.js` - This is the configuration file for Docusaurus. You can manage the links in the header and footer, and site metadata here. A more in-depth introduction to this configuration file is available on the [Docusaurus website](https://docusaurus.io/docs/configuration) and full documentation for the API is [here](https://docusaurus.io/docs/docusaurus.config.js). | ||
|
@@ -15,52 +21,61 @@ You can view the latest successful build here: https://docs.aztec.network | |
|
||
The .md files in the `docs/` directory are the docs. See the [Docusaurus website](https://docusaurus.io/docs/docs-introduction) for the full documentation on how to create docs and to manage the metadata. | ||
|
||
## Contributing | ||
|
||
We welcome contributions from the community. Please review our [contribution guidelines](CONTRIBUTING.md) for more information. | ||
|
||
## Docusaurus | ||
|
||
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. | ||
|
||
### Installation | ||
|
||
To install the dependencies and dev dependencies, run: | ||
|
||
``` | ||
$ yarn | ||
``` | ||
|
||
### Development | ||
|
||
#### Locally | ||
Aztec docs pull some code from the rest of the repository. This allows for great flexibility and maintainability. Some documentation is also autogenerated. | ||
|
||
For that reason, there's a preprocessing step. You can run that step ad-hoc with `yarn preprocess` or `yarn preprocess:dev` if you want it to stay running and watching for changes. | ||
|
||
To build; serve to `localhost:3000`; and watch for changes: | ||
This step does the following: | ||
- Pulls the code from the source files using the `#include` macros explained below. | ||
- Autogenerates documentation using the scripts in the `src` file. | ||
- Puts the final documentation in a `processed-docs` folder. | ||
|
||
> [!NOTE] | ||
> You likely want to benefit from webpack's hot reload, which allows you to immediately see your changes when you develop on the docs. For this reason, the `yarn dev` commands will add the `ENV=dev` environment variable, which makes docusaurus serve the `docs folder` instead of the `processed docs`. | ||
> If you're making changes to included code or aztec.nr reference, you can run `yarn docs` instead. | ||
|
||
#### Run locally | ||
|
||
To run docusaurus development server and use hot reload (watch for changes), run: | ||
|
||
``` | ||
$ yarn start:dev:local | ||
$ yarn dev:local | ||
``` | ||
|
||
#### Remotely (on mainframe) | ||
#### Run remotely (on mainframe) | ||
|
||
To build; serve to `localhost:3000`; and watch for changes: | ||
It's common for developers to work on codespaces or other remote targets. For this you need to expose your development server. This is common enough to be the default development command: | ||
|
||
``` | ||
$ yarn start:dev | ||
$ yarn dev | ||
``` | ||
|
||
This command preprocesses `#include_code` macros, then builds the html, then starts a local development server and opens up a browser window (at `localhost:3000`, by default). | ||
Most changes are reflected live without having to restart the server. | ||
|
||
### Build | ||
|
||
To build the final version of the docs (which includes processes not present in dev, like broken links checking and minification), you can run: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice this is here (related to previous comment) |
||
|
||
``` | ||
$ yarn build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static contents hosting service. When run on Netlify, it will also build the typescript projects needed for extracting type information via typedoc. | ||
|
||
This command runs the preprocess command, generates static content into the `build` directory and can be served using any static contents hosting service. | ||
|
||
## Macros | ||
|
||
As mentioned above, Aztec docs pull code from the source files. This makes it easy to include sections of the source code in tutorials and other examples. | ||
|
||
This is done via macros which are processed in the `process` step described above. | ||
|
||
### `#include_code` | ||
|
||
You can embed code snippets into a `.md`/`.mdx` file from code which lives elsewhere in the repo. | ||
|
@@ -133,3 +148,7 @@ Alternatively, you can also use the `AztecPackagesVersion()` js function, which | |
import { AztecPackagesVersion } from "@site/src/components/Version"; | ||
<>{AztecPackagesVersion()}</> | ||
``` | ||
|
||
## Contributing | ||
|
||
We welcome contributions from the community. Please review our [contribution guidelines](CONTRIBUTING.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
import { useEffect, useState } from "react"; | ||
import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; | ||
import Link from "@docusaurus/Link"; | ||
import { useLocation } from "@docusaurus/router"; | ||
|
||
function getSiteId(env) { | ||
if (env == "dev") { | ||
return "4"; | ||
} else if (env == "staging") { | ||
return "5"; | ||
} else { | ||
return "6"; | ||
} | ||
} | ||
function pushInstruction(name, ...args) { | ||
return window._paq.push([name, ...args]); | ||
} | ||
|
||
export default function useMatomo() { | ||
const { siteConfig } = useDocusaurusContext(); | ||
const [showBanner, setShowBanner] = useState(false); | ||
const location = useLocation(); | ||
|
||
const env = siteConfig.customFields.MATOMO_ENV; | ||
const urlBase = "https://noirlang.matomo.cloud/"; | ||
const trackerUrl = `${urlBase}matomo.php`; | ||
const srcUrl = `${urlBase}matomo.js`; | ||
|
||
window._paq = window._paq || []; | ||
|
||
useEffect(() => { | ||
const storedConsent = localStorage.getItem("matomoConsent"); | ||
if (storedConsent === null) { | ||
setShowBanner(true); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
pushInstruction("setTrackerUrl", trackerUrl); | ||
pushInstruction("setSiteId", getSiteId(env)); | ||
if (env !== "prod") { | ||
pushInstruction("setSecureCookie", false); | ||
} | ||
|
||
const doc = document; | ||
const scriptElement = doc.createElement("script"); | ||
const scripts = doc.getElementsByTagName("script")[0]; | ||
|
||
scriptElement.type = "text/javascript"; | ||
scriptElement.async = true; | ||
scriptElement.defer = true; | ||
scriptElement.src = srcUrl; | ||
|
||
if (scripts && scripts.parentNode) { | ||
scripts.parentNode.insertBefore(scriptElement, scripts); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
pushInstruction("trackPageView"); | ||
}, [location]); | ||
|
||
const optIn = () => { | ||
pushInstruction("rememberConsentGiven"); | ||
localStorage.setItem("matomoConsent", true); | ||
setShowBanner(false); | ||
}; | ||
|
||
const optOut = () => { | ||
pushInstruction("forgetConsentGiven"); | ||
localStorage.setItem("matomoConsent", false); | ||
setShowBanner(false); | ||
}; | ||
|
||
const debug = () => { | ||
pushInstruction(function () { | ||
console.log(this.getRememberedConsent()); | ||
console.log(localStorage.getItem("matomoConsent")); | ||
}); | ||
}; | ||
|
||
const reset = () => { | ||
pushInstruction("forgetConsentGiven"); | ||
localStorage.clear("matomoConsent"); | ||
}; | ||
|
||
if (!showBanner && env === "dev") { | ||
return ( | ||
<div id="optout-form"> | ||
<div className="homepage_footer"> | ||
<p>Debugging analytics</p> | ||
<div className="homepage_cta_footer_container"> | ||
<button | ||
className="cta-button button button--secondary button--sm" | ||
onClick={debug} | ||
> | ||
Debug | ||
</button> | ||
<button | ||
className="cta-button button button--secondary button--sm" | ||
onClick={reset} | ||
> | ||
Reset | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} else if (!showBanner) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div id="optout-form"> | ||
<div className="homepage_footer"> | ||
<p> | ||
We value your privacy and we only collect statistics and essential | ||
cookies. If you'd like to help us improve our websites, you can allow | ||
cookies for tracking page views, time on site, and other analytics. | ||
<br /> | ||
<br /> | ||
<Link to="https://aztec.network/privacy-policy/"> | ||
Find out how we use cookies and how you can change your settings. | ||
</Link> | ||
</p> | ||
<div className="homepage_cta_footer_container"> | ||
<button | ||
className="cta-button button button--primary button--sm" | ||
onClick={optIn} | ||
> | ||
I accept cookies | ||
</button> | ||
<button | ||
className="cta-button button button--secondary button--sm" | ||
onClick={optOut} | ||
> | ||
I refuse cookies | ||
</button> | ||
{env === "dev" && ( | ||
<button | ||
className="cta-button button button--secondary button--sm" | ||
onClick={debug} | ||
> | ||
Debug | ||
</button> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great for visual changes.
Apart from URLs, what is in processed docs that might need to be tested? Might just need a comment with what is not accurate between
docs
vsprocessed_docs
.Saw that CI is building
staging
docs 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree that it would be useful to list all of the things that the preprocess step does.
i think its this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, it just adds the autogenerated stuff