-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(matomo): migrate matomo frontend and backend plugins
Signed-off-by: Yash Oswal <yoswal@redhat.com>
- Loading branch information
1 parent
fa96259
commit 32d21f2
Showing
43 changed files
with
28,103 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
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 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
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,14 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"privatePackages": { | ||
"tag": false, | ||
"version": false | ||
} | ||
} |
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,6 @@ | ||
--- | ||
'@backstage-community/plugin-matomo-backend': major | ||
'@backstage-community/plugin-matomo': major | ||
--- | ||
|
||
The matomo and matomo-backend plugins from [janus-idp/backstage-plugins](https://github.com/janus-idp/backstage-plugins/tree/main/plugins/) are migrated to community-plugins. The migrations is performed using manual steps. |
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 @@ | ||
.git | ||
.yarn/cache | ||
.yarn/install-state.gz | ||
node_modules | ||
packages/*/src | ||
packages/*/node_modules | ||
plugins | ||
*.local.yaml |
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 @@ | ||
playwright.config.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 @@ | ||
module.exports = require('../../.eslintrc.cjs'); |
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,54 @@ | ||
# macOS | ||
.DS_Store | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Coverage directory generated when running tests with coverage | ||
coverage | ||
|
||
# Dependencies | ||
node_modules/ | ||
|
||
# Yarn 3 files | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
# Node version directives | ||
.nvmrc | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# Build output | ||
dist | ||
dist-types | ||
|
||
# Temporary change files created by Vim | ||
*.swp | ||
|
||
# MkDocs build output | ||
site | ||
|
||
# Local configuration files | ||
*.local.yaml | ||
|
||
# Sensitive credentials | ||
*-credentials.yaml | ||
|
||
# vscode database functionality support files | ||
*.session.sql | ||
|
||
# E2E test reports | ||
e2e-test-report/ |
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,5 @@ | ||
dist | ||
dist-types | ||
coverage | ||
.vscode | ||
.eslintrc.js |
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,16 @@ | ||
# [Matomo Plugin Workspace](https://backstage.io) | ||
|
||
This is your newly scaffolded Backstage App, Good Luck! | ||
|
||
To start the app, run: | ||
|
||
```sh | ||
yarn install | ||
yarn dev | ||
``` | ||
|
||
To generate knip reports for this app, run: | ||
|
||
```sh | ||
yarn backstage-repo-tools knip-reports | ||
``` |
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,25 @@ | ||
app: | ||
title: Matomo Dev App | ||
baseUrl: http://localhost:3000 | ||
|
||
backend: | ||
baseUrl: http://localhost:7007 | ||
cors: | ||
origin: http://localhost:3000 | ||
methods: [GET, HEAD, PATCH, POST, PUT, DELETE] | ||
credentials: true | ||
reading: | ||
allow: | ||
- host: localhost | ||
|
||
# Config for dev app | ||
matomo: | ||
# frontend | ||
frontendBaseUrl: ${MATOMO_HOST} | ||
contactUsLink: ${SLACK_CONTACT_LINK} | ||
|
||
# backend | ||
apiUrl: ${MATOMO_HOST} | ||
apiToken: ${MATOMO_TOKEN_AUTH} | ||
# (OPTIONAL) Set to false if you get SSL certificate error | ||
secure: false # |
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 @@ | ||
{ | ||
"version": "1.32.5" | ||
} |
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,13 @@ | ||
apiVersion: backstage.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: matomo | ||
description: An example of a Backstage application. | ||
# Example for optional annotations | ||
# annotations: | ||
# github.com/project-slug: backstage/backstage | ||
# backstage.io/techdocs-ref: dir:. | ||
spec: | ||
type: website | ||
owner: john@example.com | ||
lifecycle: experimental |
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,64 @@ | ||
{ | ||
"name": "@internal/matomo", | ||
"version": "1.0.0", | ||
"private": true, | ||
"engines": { | ||
"node": "18 || 20" | ||
}, | ||
"scripts": { | ||
"tsc": "tsc", | ||
"tsc:full": "tsc --skipLibCheck false --incremental false", | ||
"build:all": "backstage-cli repo build --all", | ||
"build:api-reports": "yarn build:api-reports:only --tsc", | ||
"build:api-reports:only": "backstage-repo-tools api-reports -o ae-wrong-input-file-type --validate-release-tags", | ||
"clean": "backstage-cli repo clean", | ||
"test": "backstage-cli repo test", | ||
"test:all": "backstage-cli repo test --coverage", | ||
"fix": "backstage-cli repo fix", | ||
"lint": "backstage-cli repo lint --since origin/main", | ||
"lint:all": "backstage-cli repo lint", | ||
"prettier:check": "prettier --check .", | ||
"prettier:write": "prettier --write .", | ||
"new": "backstage-cli new --scope @backstage-community", | ||
"postinstall": "cd ../../ && yarn install" | ||
}, | ||
"workspaces": { | ||
"packages": [ | ||
"packages/*", | ||
"plugins/*" | ||
] | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/backstage/community-plugins", | ||
"directory": "workspaces/matomo" | ||
}, | ||
"devDependencies": { | ||
"@backstage/cli": "^0.28.2", | ||
"@backstage/e2e-test-utils": "^0.1.1", | ||
"@backstage/repo-tools": "^0.10.0", | ||
"@changesets/cli": "^2.27.1", | ||
"@spotify/prettier-config": "^12.0.0", | ||
"node-gyp": "^9.0.0", | ||
"prettier": "^2.3.2", | ||
"react-router-dom": "^6.28.0", | ||
"typescript": "~5.3.0" | ||
}, | ||
"dependencies": { | ||
"knip": "^5.27.4" | ||
}, | ||
"resolutions": { | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18" | ||
}, | ||
"prettier": "@spotify/prettier-config", | ||
"lint-staged": { | ||
"*.{js,jsx,ts,tsx,mjs,cjs}": [ | ||
"eslint --fix", | ||
"prettier --write" | ||
], | ||
"*.{json,md}": [ | ||
"prettier --write" | ||
] | ||
} | ||
} |
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,9 @@ | ||
# The Plugins Folder | ||
|
||
This is where your own plugins and their associated modules live, each in a | ||
separate folder of its own. | ||
|
||
If you want to create a new plugin here, go to your project root directory, run | ||
the command `yarn new`, and follow the on-screen instructions. | ||
|
||
You can also check out existing plugins on [the plugin marketplace](https://backstage.io/plugins)! |
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 @@ | ||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); |
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 @@ | ||
# Matomo Backend | ||
|
||
This is the matomo backend plugin that act as a proxy with matomo instance. | ||
|
||
Plugin will inject the auth token and ensure that the request are only read only operations. | ||
|
||
Matomo API cannot be used as proxy layer due to the token auth it follows. Thus this plugin will act as proxy layer | ||
|
||
## Getting Started | ||
|
||
### Installing the NPM package | ||
|
||
```bash | ||
yarn add --cwd packages/backend @backstage-community/plugin-matomo-backend | ||
``` | ||
|
||
### Installing the plugin | ||
|
||
#### Adding the plugin to the new backend | ||
|
||
Add the following to your `packages/backend/src/index.ts` file: | ||
|
||
```ts title="packages/backend/src/index.ts" | ||
const backend = createBackend(); | ||
|
||
// Add the following line | ||
backend.add(import('@backstage-community/plugin-matomo-backend')); | ||
|
||
backend.start(); | ||
``` | ||
|
||
### Plugin Configurations | ||
|
||
Add the following configurations into your `app-config.yaml` file: | ||
|
||
```yaml | ||
matomo: | ||
apiToken: ${MATOMO_API_TOKEN} | ||
|
||
apiUrl: ${MATOMO_API_URL} | ||
|
||
# (OPTIONAL) Set to false if you get SSL certificate error | ||
secure: ${MATOMO_SECURE_FLAG} | ||
``` |
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 @@ | ||
/* | ||
* Copyright 2024 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export interface Config { | ||
matomo: { | ||
/** | ||
* @visibility backend | ||
*/ | ||
apiToken: string; | ||
/** | ||
* @visibility backend | ||
*/ | ||
apiUrl: string; | ||
/** | ||
* Set to false if you get SSL certificate error | ||
* @visibility backend | ||
*/ | ||
secure: boolean; | ||
}; | ||
} |
Oops, something went wrong.