-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c3ea394
Showing
137 changed files
with
25,235 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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,39 @@ | ||
# This is a comment. | ||
# Each line is a file pattern followed by one or more owners. | ||
|
||
# These owners will be the default owners for everything in | ||
# the repo. Unless a later match takes precedence, | ||
# @global-owner1 and @global-owner2 will be requested for | ||
# review when someone opens a pull request. | ||
* @alejandromav @kukukaka | ||
|
||
# Order is important; the last matching pattern takes the most | ||
# precedence. When someone opens a pull request that only | ||
# modifies JS files, only @js-owner and not the global | ||
# owner(s) will be requested for a review. | ||
# *.js @js-owner | ||
|
||
# You can also use email addresses if you prefer. They'll be | ||
# used to look up users just like we do for commit author | ||
# emails. | ||
# *.go [email protected] | ||
|
||
# In this example, @doctocat owns any files in the build/logs | ||
# directory at the root of the repository and any of its | ||
# subdirectories. | ||
# /build/logs/ @doctocat | ||
|
||
# The `docs/*` pattern will match files like | ||
# `docs/getting-started.md` but not further nested files like | ||
# `docs/build-app/troubleshooting.md`. | ||
# docs/* [email protected] | ||
|
||
# In this example, @octocat owns any file in an apps directory | ||
# anywhere in your repository. | ||
# apps/ @octocat | ||
|
||
# In this example, @doctocat owns any file in the `/docs` | ||
# directory in the root of your repository. | ||
# /docs/ @doctocat | ||
|
||
/dashboard @raqyuste @rmorehig |
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,44 @@ | ||
name: CI | ||
|
||
on: [ push ] | ||
|
||
jobs: | ||
dashboard: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18.x | ||
cache: 'npm' | ||
cache-dependency-path: dashboard/package-lock.json | ||
- name: npm install, build, and test | ||
run: | | ||
npm install --prefix dashboard | ||
npm run lint --prefix dashboard --if-present | ||
npm run test --prefix dashboard --if-present | ||
npm run build --prefix dashboard | ||
env: | ||
CI: true | ||
|
||
script: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18.x | ||
cache: 'npm' | ||
cache-dependency-path: middleware/package-lock.json | ||
- name: npm install, build, and test | ||
run: | | ||
npm install --prefix middleware | ||
npm run lint --prefix middleware --if-present | ||
npm run test --prefix middleware --if-present | ||
npm run build --prefix middleware | ||
env: | ||
CI: true |
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,32 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: published | ||
|
||
jobs: | ||
script: | ||
name: "Publish tracking script to npm" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 18.x | ||
- name: npm install, build, and test | ||
run: | | ||
npm install --prefix middleware | ||
npm run lint --prefix middleware --if-present | ||
npm run test:coverage --prefix middleware --if-present | ||
npm run build --prefix middleware | ||
env: | ||
CI: true | ||
- name: npm publish | ||
run: | | ||
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN | ||
npm publish ./middleware --access public | ||
env: | ||
CI: true | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
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,7 @@ | ||
.DS_Store | ||
.venv | ||
.tinyb | ||
.vercel | ||
node_modules | ||
dist | ||
.e |
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,22 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## Unreleased | ||
|
||
## [1.0.0] - 2022-09-02 | ||
### Added | ||
- [Data project] Create data project template | ||
- [Middleware] Add Vercel middleware | ||
- [Script] Add tracking script | ||
- [Dashboard] Add dashboard | ||
|
||
[Unreleased]: https://github.com/tinybirdco/web-analytics-starter-kit/compare/1.0.0...HEAD | ||
<!-- [0.6.0]: https://github.com/tinybirdco/web-analytics-starter-kit/compare/0.5.0...0.6.0 | ||
[0.5.0]: https://github.com/tinybirdco/web-analytics-starter-kit/compare/0.4.0...0.5.0 | ||
[0.4.0]: https://github.com/tinybirdco/web-analytics-starter-kit/compare/0.3.0...0.4.0 | ||
[0.3.0]: https://github.com/tinybirdco/web-analytics-starter-kit/compare/0.2.0...0.3.0 | ||
[0.2.0]: https://github.com/tinybirdco/web-analytics-starter-kit/compare/0.1.0...0.2.0 --> | ||
[1.0.0]: https://github.com/tinybirdco/web-analytics-starter-kit/tree/1.0.0 |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Tinybird.co | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,156 @@ | ||
# Tinybird Web Analytics Starter Kit | ||
|
||
Build your own web analytics platform using [Tinybird](https://www.tinybird.co/)'s Events API and Endpoints. Built with privacy and speed as top priorities, this Starter Kit lets you get real-time metrics in a pre-built dashboard in just a few minutes without any knowledge about Tinybird. Our [free accounts](https://www.tinybird.co/pricing) serve up to 1000 requests per day and unlimited processed GB, more than enough to get started. | ||
|
||
<!-- You can look at the [Web Analytics Starter Kit](https://www.tinybird.co/starter-kits) site to get a better glimpse of the final result. --> | ||
Once you've finished the basic setup, expand your analytics with custom events tailored to your specific use cases (eCommerce, marketing, etc.), keeping the same real-time performance. If you need to be GDPR compliant, check out the GDPR best practices section. | ||
|
||
![Tinybird Web Analytics Dashboard](./assets/img/repo-banner.png) | ||
|
||
|
||
## Basic setup | ||
|
||
### Set up the data project | ||
|
||
To get started in Tinybird, follow these steps: | ||
|
||
1. Create a [Tinybird account](https://ui.tinybird.co/signup). | ||
2. Create a Workspace and go to **Manage Auth tokens** to copy your admin token. | ||
3. Clone this repository: | ||
|
||
```bash | ||
git clone https://github.com/tinybirdco/web-analytics-starter-kit | ||
cd web-analytics-starter-kit | ||
cd tinybird | ||
``` | ||
|
||
4. Install the Tinybird CLI using `pip install tinybird-cli`. [Detailed instructions here](https://docs.tinybird.co/cli.html#how-to-install). | ||
|
||
5. Authenticate on the CLI using `tb auth` and paste the token you just copied. | ||
|
||
6. Push the project using `tb push`. | ||
|
||
Your Tinybird workspace is now ready to start receiving events. All your Data Sources, [Materialized Views](https://www.tinybird.co/guide/materialized-columns) (to make the queries blazing fast), and API Endpoints should be installed and ready. If you go to the Data Flow tab in your browser you should see something like this: | ||
|
||
![Tinybird Web Analytics Dashboard](./assets/img/data_flow.png) | ||
<!-- maybe add some explanations on top of the flow? --> | ||
|
||
### Send events to your data source | ||
|
||
1. Go to your browser, click Manage Auth Tokens, and copy the `tracker` token. | ||
|
||
2. Add the tracking script to your website, using that token: | ||
|
||
```html | ||
<script src="https://unpkg.com/@tinybirdco/flock.js" data-token="YOUR_TRACKER_TOKEN"></script> | ||
|
||
<!-- | ||
Alternatives: | ||
- Custom host (dedicated cluster, another region, etc.) | ||
<script src="https://unpkg.com/@tinybirdco/flock.js" data-host="https://api.us-east.tinybird.co" data-token="YOUR_TRACKER_TOKEN"></script> | ||
- Append to another datasource | ||
<script src="https://unpkg.com/@tinybirdco/flock.js" data-datasource="analytics_events__v2" data-token="YOUR_TRACKER_TOKEN"></script> | ||
--> | ||
``` | ||
|
||
If everything is working correctly, you should start seeing rows in your Data Source as visitors view and interact with your website | ||
|
||
![Tinybird Web Analytics Dashboard](./assets/img/events-incoming.png) | ||
|
||
And you're done! 🙌 | ||
|
||
### Visualize the metrics on a readymade dashboard | ||
|
||
In the Tinybird project, you'll find a `dashboard` token with all the required permissions to visualized your site metrics in our readymade dashboard. | ||
Go to the following URL, customizing it with your `dashboard` token: | ||
|
||
https://analytics.tinybird.co/?token={your-dashboard-token} | ||
|
||
|
||
<details> | ||
<summary><h2>Custom events (optional)</h2></summary> | ||
|
||
> :warning: **GDPR**: Don't track any personal (PII), ids, codes, or any other information that may lead to identify an individual (not even fingerprinting). Track only the essential events when needed, and use aggregated metrics. | ||
The script also provides you with a function to send custom events. You can simply add this to your application at any point: | ||
|
||
```js | ||
Tinybird.trackEvent('add_to_cart', { | ||
partnumber: 'A1708 (EMC 3164)', | ||
quantity: 1 | ||
}); | ||
``` | ||
|
||
You can also fork the dashboard project in this repository and create custom components for your new events. It's a Next.js project, so you can deploy it easily on [Vercel](https://vercel.com/). | ||
|
||
> *Custom Ecommerce events examples coming soon!* | ||
</details> | ||
|
||
|
||
<details> | ||
<summary><h2>GDPR best practices (optional)</h2></summary> | ||
|
||
> :warning: **GDPR**: These are some tips to follow the GDPR guidelines, but compliance is not guaranteed. Follow these instructions and assess with your legal team. For more details on how to implement a privacy-first tracker for compliance, [read this](https://www.tinybird.co/blog-posts/privacy-first-google-analytics-alternative). | ||
Requirements: | ||
|
||
- Create your Tinybird Workspace in **EU** region. | ||
- Don't track any personal (PII), ids, codes, or any other information that may lead to identify an individual (not even fingerprinting). | ||
- Track only the essential events when needed. | ||
- Use aggregated metrics, never at individual level (session). | ||
- Your visitors should be able to opt out at ANY time. | ||
|
||
### Instructions to make it a first-party solution | ||
|
||
To make this a first-party solution end-to-end, you'll need to send the events to the data pipeline using your own domain. You'll own the data, and Tinybird won't analyze it in any way. | ||
|
||
You will need to set up: | ||
|
||
- A tracking script delivery under <!-- this seems incomplete? --> | ||
- A proxy to Tinybird Events API | ||
|
||
<!-- add an option to test with a data generator? --> | ||
|
||
1. Deploy the [middleware](./middleware/) to Vercel. | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Ftinybirdco%2Fweb-analytics-starter-kit%2Ftree%2Fmain%2Fmiddleware&env=TINYBIRD_TOKEN&envDescription=Tinybird%20token%20needed%20for%20ingestion&project-name=web-analytics) | ||
|
||
2. Fill in the `TINYBIRD_TOKEN` environment variable with the ingestion token you created in the basic setup. | ||
|
||
3. Add a subdomain to your site, for example `events.example.com`. Most ad-blockers won't block a subdomain on your root domain, but just to be sure, avoid `analytics.example.com`, `tracking.example.com` or similar so anti-trackers don't block your requests. | ||
|
||
4. Update the snippet from the basic setup to this, using your configured subdomain: | ||
|
||
```html | ||
<script src="https://events.example.com/index.js" data-proxy="https://events.example.com"></script> | ||
``` | ||
|
||
</details> | ||
|
||
|
||
<details id='next'> | ||
<summary><h2>What's next?</h2></summary> | ||
|
||
- **Need more inspiration?** Check out our upcoming [live coding session](https://www.tinybird.co/live-coding-sessions/google-analytics-free). | ||
- **The big picture:** [How an eCommerce giant replaced Google Analytics for privacy and scale](https://www.tinybird.co/blog-posts/ecommerce-google-analytics-alternative) | ||
|
||
</details> | ||
|
||
## Authors | ||
|
||
- [Rafa Moreno](https://github.com/rmorehig) | ||
- [Raquel Yuste](https://github.com/raqyuste) | ||
- [Alasdair Brown](https://github.com/sdairs) | ||
- [Kike Alonso](https://github.com/kukukaka) | ||
- [Cameron Archer](https://github.com/tb-peregrine) | ||
- [Javier Álvarez](https://github.com/xavijam) | ||
- [Sergio Álvarez](https://github.com/saleiva) | ||
- [Jorge Gomez](https://github.com/jorgesancha) | ||
- [Alejandro Martin](https://github.com/alejandromav) | ||
|
||
--- | ||
|
||
Need help?: [Community Slack](https://www.tinybird.co/join-our-slack-community) • [Tinybird Docs](https://docs.tinybird.co/) • [Email](mailto:[email protected]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
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,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
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,7 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"arrowParens": "avoid" | ||
} |
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,8 @@ | ||
{ | ||
"eslint.workingDirectories": [ | ||
{ | ||
"directory": "./", | ||
"changeProcessCWD": true | ||
} | ||
] | ||
} |
Oops, something went wrong.