Skip to content

Commit

Permalink
feat(matomo): migrate matomo frontend and backend plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Yash Oswal <yoswal@redhat.com>
  • Loading branch information
yashoswalyo committed Nov 12, 2024
1 parent fa96259 commit 32d21f2
Show file tree
Hide file tree
Showing 43 changed files with 28,103 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ yarn.lock @backstage/community-plugins
/workspaces/keycloak @backstage/community-plugins-maintainers @AndrienkoAleksandr @schultzp2020
/workspaces/kiali @backstage/community-plugins-maintainers @aljesusg @josunect
/workspaces/linguist @backstage/community-plugins-maintainers @awanlin
/workspaces/matomo @backstage/community-plugins-maintainers @yashoswalyo @deshmukhmayur @riginoommen
/workspaces/mend @backstage/community-plugins-maintainers @dariuszsobkowicz
/workspaces/mta @backstage/community-plugins-maintainers @ibolton336
/workspaces/nexus-repository-manager @backstage/community-plugins-maintainers @schultzp2020
Expand Down
8 changes: 8 additions & 0 deletions workspaces/matomo/.changeset/README.md
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)
14 changes: 14 additions & 0 deletions workspaces/matomo/.changeset/config.json
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
}
}
6 changes: 6 additions & 0 deletions workspaces/matomo/.changeset/empty-rabbits-drop.md
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.
8 changes: 8 additions & 0 deletions workspaces/matomo/.dockerignore
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
1 change: 1 addition & 0 deletions workspaces/matomo/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
playwright.config.ts
1 change: 1 addition & 0 deletions workspaces/matomo/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../.eslintrc.cjs');
54 changes: 54 additions & 0 deletions workspaces/matomo/.gitignore
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/
5 changes: 5 additions & 0 deletions workspaces/matomo/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
dist-types
coverage
.vscode
.eslintrc.js
16 changes: 16 additions & 0 deletions workspaces/matomo/README.md
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
```
25 changes: 25 additions & 0 deletions workspaces/matomo/app-config.yaml
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 #
3 changes: 3 additions & 0 deletions workspaces/matomo/backstage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "1.32.5"
}
13 changes: 13 additions & 0 deletions workspaces/matomo/catalog-info.yaml
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
64 changes: 64 additions & 0 deletions workspaces/matomo/package.json
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"
]
}
}
9 changes: 9 additions & 0 deletions workspaces/matomo/plugins/README.md
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)!
1 change: 1 addition & 0 deletions workspaces/matomo/plugins/matomo-backend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
44 changes: 44 additions & 0 deletions workspaces/matomo/plugins/matomo-backend/README.md
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}
```
32 changes: 32 additions & 0 deletions workspaces/matomo/plugins/matomo-backend/config.d.ts
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;
};
}
Loading

0 comments on commit 32d21f2

Please sign in to comment.