From 97eaa80071f1a64fd5a77e2f850d4bd7f791c5b3 Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Tue, 7 Oct 2025 21:59:25 +0300 Subject: [PATCH 1/5] edited links in pacakge.json files to point to this repository, edited npm package name, updated readme.md --- README.md | 13 ++++++------ package-lock.json | 40 ++++++++++++++++++------------------- packages/js/package.json | 8 ++++---- packages/react/package.json | 10 +++++----- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 0e2cb1e4..db33f0f2 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,17 @@ # Matomo Tracker -> **Warning** -> This repository is no longer maintained. I no longer use Matomo, nor do I have enough time between projects to take care of these libraries. +Monorepo for using Matomo tracking in frontend projects. This repository is forked from [jonkoops/matomo-tracker](https://github.com/jonkoops/matomo-tracker). -Monorepo for using Matomo tracking in frontend projects +## New features in this fork + +- Add support for setting 'cookie domain' and 'domains' options to support tracking multiple subdomains of the same domain. ## Content -This monorepo hosts two Matomo projects for tracking (user) analytics in frontend projects, either with (vanilla) JavaScript or React. +This monorepo hosts two Matomo projects for tracking (user) analytics in frontend projects, either with (vanilla) JavaScript/TypeScript or React. -- [@jonkoops/matomo-tracker](https://github.com/jonkoops/matomo-tracker/tree/main/packages/js) -- [@jonkoops/matomo-tracker-react](https://github.com/jonkoops/matomo-tracker/tree/main/packages/react) +- [@streamr/matomo-tracker](https://github.com/streamr-dev/matomo-tracker/tree/main/packages/js) +- [@streamr/matomo-tracker-react](https://github.com/streamr-dev/matomo-tracker/tree/main/packages/react) ## References diff --git a/package-lock.json b/package-lock.json index abcf5325..c832d00b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1169,14 +1169,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jonkoops/matomo-tracker": { - "resolved": "packages/js", - "link": true - }, - "node_modules/@jonkoops/matomo-tracker-react": { - "resolved": "packages/react", - "link": true - }, "node_modules/@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", @@ -2823,6 +2815,14 @@ "@sinonjs/commons": "^1.7.0" } }, + "node_modules/@streamr/matomo-tracker": { + "resolved": "packages/js", + "link": true + }, + "node_modules/@streamr/matomo-tracker-react": { + "resolved": "packages/react", + "link": true + }, "node_modules/@testing-library/dom": { "version": "8.17.1", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.17.1.tgz", @@ -13250,16 +13250,16 @@ } }, "packages/js": { - "name": "@jonkoops/matomo-tracker", + "name": "@streamr/matomo-tracker", "version": "0.7.0", "license": "MPL-2.0" }, "packages/react": { - "name": "@jonkoops/matomo-tracker-react", + "name": "@streamr/matomo-tracker-react", "version": "0.7.0", "license": "MPL-2.0", "dependencies": { - "@jonkoops/matomo-tracker": "^0.7.0" + "@streamr/matomo-tracker": "^0.7.0" }, "peerDependencies": { "react": ">= 16.8.0" @@ -14139,15 +14139,6 @@ "chalk": "^4.0.0" } }, - "@jonkoops/matomo-tracker": { - "version": "file:packages/js" - }, - "@jonkoops/matomo-tracker-react": { - "version": "file:packages/react", - "requires": { - "@jonkoops/matomo-tracker": "^0.7.0" - } - }, "@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", @@ -15484,6 +15475,15 @@ "@sinonjs/commons": "^1.7.0" } }, + "@streamr/matomo-tracker": { + "version": "file:packages/js" + }, + "@streamr/matomo-tracker-react": { + "version": "file:packages/react", + "requires": { + "@streamr/matomo-tracker": "^0.7.0" + } + }, "@testing-library/dom": { "version": "8.17.1", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-8.17.1.tgz", diff --git a/packages/js/package.json b/packages/js/package.json index 417ae3c9..80ea0e5b 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,19 +1,19 @@ { - "name": "@jonkoops/matomo-tracker", + "name": "@streamr/matomo-tracker", "version": "0.7.0", "description": "Matomo tracker for frontend projects", "main": "lib/index.js", "module": "es/index.js", "license": "MPL-2.0", "author": "Jon Koops", - "homepage": "https://github.com/jonkoops/matomo-tracker#readme", + "homepage": "https://github.com/streamr-dev/matomo-tracker#readme", "repository": { "type": "git", - "url": "git+https://github.com/jonkoops/matomo-tracker.git", + "url": "git+https://github.com/streamr-dev/matomo-tracker.git", "directory": "packages/js" }, "bugs": { - "url": "https://github.com/jonkoops/matomo-tracker/issues" + "url": "https://github.com/streamr-dev/matomo-tracker/issues" }, "files": [ "lib", diff --git a/packages/react/package.json b/packages/react/package.json index 470cf243..cf20cf2c 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,19 +1,19 @@ { - "name": "@jonkoops/matomo-tracker-react", + "name": "@streamr/matomo-tracker-react", "version": "0.7.0", "description": "Matomo tracker for react projects", "main": "lib/index.js", "module": "es/index.js", "license": "MPL-2.0", "author": "Jon Koops", - "homepage": "https://github.com/jonkoops/matomo-tracker#readme", + "homepage": "https://github.com/streamr-dev/matomo-tracker#readme", "repository": { "type": "git", - "url": "git+https://github.com/jonkoops/matomo-tracker.git", + "url": "git+https://github.com/streamr-dev/matomo-tracker.git", "directory": "packages/react" }, "bugs": { - "url": "https://github.com/jonkoops/matomo-tracker/issues" + "url": "https://github.com/streamr-dev/matomo-tracker/issues" }, "files": [ "lib", @@ -37,7 +37,7 @@ "access": "public" }, "dependencies": { - "@jonkoops/matomo-tracker": "^0.7.0" + "@streamr/matomo-tracker": "^0.7.0" }, "peerDependencies": { "react": ">= 16.8.0" From 94d0e574a73a0d6e2e0ae813c4b431f2b412517f Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Tue, 7 Oct 2025 22:03:24 +0300 Subject: [PATCH 2/5] update cache action to v4 --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 80dd0a9b..b19343fc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: - name: Cache Node modules id: cache-node-modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: node_modules key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} @@ -33,7 +33,7 @@ jobs: run: npm run build - name: Cache setup - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./* key: ${{ github.sha }} @@ -46,7 +46,7 @@ jobs: command: [lint, test] steps: - name: Restore setup - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./* key: ${{ github.sha }} From b94eba50193aca0265d2b0a296513df7eef8c196 Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Tue, 7 Oct 2025 22:05:47 +0300 Subject: [PATCH 3/5] fix errors in main.yml --- .github/workflows/main.yml | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b19343fc..eb601854 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,34 +9,29 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Node - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: 16 check-latest: true cache: npm - - name: Cache Node modules - id: cache-node-modules - uses: actions/cache@v4 - with: - path: node_modules - key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} - - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' run: npm ci - name: Build project run: npm run build - - name: Cache setup + - name: Cache build artifacts uses: actions/cache@v4 with: - path: ./* - key: ${{ github.sha }} + path: | + packages/*/dist + packages/*/lib + packages/*/build + key: ${{ github.sha }}-build run: needs: setup @@ -45,14 +40,17 @@ jobs: matrix: command: [lint, test] steps: - - name: Restore setup + - name: Restore build artifacts uses: actions/cache@v4 with: - path: ./* - key: ${{ github.sha }} + path: | + packages/*/dist + packages/*/lib + packages/*/build + key: ${{ github.sha }}-build - name: Set up Node - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: 16 From 330da499deca58663571648e84ecaaed183b5253 Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Tue, 7 Oct 2025 22:13:01 +0300 Subject: [PATCH 4/5] fix more links --- packages/js/README.md | 12 ++++++------ packages/react/README.md | 12 ++++++------ packages/react/src/instance.ts | 2 +- packages/react/src/types.ts | 2 +- packages/react/src/useMatomo.test.tsx | 4 ++-- tsconfig.json | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/js/README.md b/packages/js/README.md index 80c4508b..8171583a 100644 --- a/packages/js/README.md +++ b/packages/js/README.md @@ -5,7 +5,7 @@ Stand alone library for using Matamo tracking in frontend projects ## Installation ```sh -npm install @jonkoops/matomo-tracker +npm install @streamr/matomo-tracker ``` ## Usage @@ -15,7 +15,7 @@ Before you're able to use this Matomo Tracker you need to initialize Matomo with **Initialize:** ```ts -import MatomoTracker from '@jonkoops/matomo-tracker' +import MatomoTracker from '@streamr/matomo-tracker' const tracker = new MatomoTracker({ urlBase: 'https://LINK.TO.DOMAIN', @@ -41,7 +41,7 @@ const tracker = new MatomoTracker({ After initialization you can use the Matomo Tracker to track events and page views like this: ```ts -import MatomoTracker from '@jonkoops/matomo-tracker' +import MatomoTracker from '@streamr/matomo-tracker' const tracker = new MatomoTracker({ /* setup */ @@ -66,7 +66,7 @@ tracker.trackLink({ By default the Matomo Tracker will send the window's document title and location, but you're able to send your own values. Also, [custom dimensions](https://matomo.org/docs/custom-dimensions/) can be used: ```ts -import MatomoTracker from '@jonkoops/matomo-tracker' +import MatomoTracker from '@streamr/matomo-tracker' const tracker = new MatomoTracker({ /* setup */ @@ -107,7 +107,7 @@ tracker.trackLink({ Next to the tracking of events, this project also supports tracking site searches: ```ts -import MatomoTracker from '@jonkoops/matomo-tracker' +import MatomoTracker from '@streamr/matomo-tracker' const tracker = new MatomoTracker({ /* setup */ @@ -145,7 +145,7 @@ Or if you want to stay away from inline JavaScript events, this project can be u ``` ```ts -import MatomoTracker from '@jonkoops/matomo-tracker' +import MatomoTracker from '@streamr/matomo-tracker' const tracker = new MatomoTracker({ /* setup */ diff --git a/packages/react/README.md b/packages/react/README.md index 198c9e0d..9a9018bb 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -5,7 +5,7 @@ Stand alone library for using Matamo tracking in React projects ## Installation ```sh -npm install @jonkoops/matomo-tracker-react +npm install @streamr/matomo-tracker-react ``` ## Usage @@ -13,7 +13,7 @@ npm install @jonkoops/matomo-tracker-react Before you're able to use this Matomo Tracker you need to create a Matomo instance with your project specific details, and wrap your application with the `MatomoProvider` that this package exposes. ```tsx -import { MatomoProvider, createInstance } from '@jonkoops/matomo-tracker-react' +import { MatomoProvider, createInstance } from '@streamr/matomo-tracker-react' const instance = createInstance({ urlBase: 'https://LINK.TO.DOMAIN', @@ -46,7 +46,7 @@ After wrapping your application with the `MatomoProvider` you can use the `useMa ```tsx import React from 'react' -import { useMatomo } from '@jonkoops/matomo-tracker-react' +import { useMatomo } from '@streamr/matomo-tracker-react' const MyPage = () => { const { trackPageView, trackEvent } = useMatomo() @@ -75,7 +75,7 @@ By default the Matomo Tracker will send the window's document title and location ```tsx import React from 'react' -import { useMatomo } from '@jonkoops/matomo-tracker-react' +import { useMatomo } from '@streamr/matomo-tracker-react' const MyPage = () => { const { trackPageView, trackEvent } = useMatomo() @@ -111,7 +111,7 @@ And you can do the same for the `trackEvent` method: ```tsx import React from 'react' -import { useMatomo } from '@jonkoops/matomo-tracker-react' +import { useMatomo } from '@streamr/matomo-tracker-react' const MyPage = () => { const { trackEvent } = useMatomo() @@ -162,7 +162,7 @@ pushInstruction('setUserId', 'USER_ID_HERE'); Matomo provides the option to track outbound link, however, this implementation is flaky for a SPA (Single Page Application) **without** SSR (Server Side Rendering) across different versions of Matomo. Therefore you can use the `enableLinkTracking` method to listen to outbound clicks on anchor elements. This method should be placed on a component directly below your `MatomoProvider` on a component that's rendered on every page view. Also, make sure to disable the `linkTracking` option on the instance passed to the provider to prevent Matomo from catching some link clicks: ```tsx -import { MatomoProvider, createInstance, useMatomo } from '@jonkoops/matomo-tracker-react' +import { MatomoProvider, createInstance, useMatomo } from '@streamr/matomo-tracker-react' const instance = createInstance({ urlBase: "https://LINK.TO.DOMAIN", diff --git a/packages/react/src/instance.ts b/packages/react/src/instance.ts index ebcc7136..5bb48e74 100644 --- a/packages/react/src/instance.ts +++ b/packages/react/src/instance.ts @@ -1,4 +1,4 @@ -import MatomoTracker from '@jonkoops/matomo-tracker' +import MatomoTracker from '@streamr/matomo-tracker' import { InstanceParams } from './types' function createInstance(params: InstanceParams): MatomoTracker { diff --git a/packages/react/src/types.ts b/packages/react/src/types.ts index a7a05591..28544ea2 100644 --- a/packages/react/src/types.ts +++ b/packages/react/src/types.ts @@ -1,4 +1,4 @@ -import MatomoTracker, { types } from '@jonkoops/matomo-tracker' +import MatomoTracker, { types } from '@streamr/matomo-tracker' export interface MatomoInstance { trackEvent: MatomoTracker['trackEvent'] diff --git a/packages/react/src/useMatomo.test.tsx b/packages/react/src/useMatomo.test.tsx index c68b53ae..aeb062b8 100644 --- a/packages/react/src/useMatomo.test.tsx +++ b/packages/react/src/useMatomo.test.tsx @@ -1,11 +1,11 @@ -import MatomoTracker from '@jonkoops/matomo-tracker' +import MatomoTracker from '@streamr/matomo-tracker' import { fireEvent, render, renderHook } from '@testing-library/react' import React from 'react' import createInstance from './instance' import MatomoProvider from './MatomoProvider' import useMatomo from './useMatomo' -jest.mock('@jonkoops/matomo-tracker') +jest.mock('@streamr/matomo-tracker') describe('useMatomo', () => { const JustAComponent = function () { diff --git a/tsconfig.json b/tsconfig.json index a912087c..535d8619 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "target": "es5", "baseUrl": ".", "paths": { - "@jonkoops/*": ["packages/*/src"] + "@streamr/*": ["packages/*/src"] }, "composite": true, "sourceMap": true, From 0a2835c1eda8cbdcb089ebfe2ebb3d8db1aea064 Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Tue, 7 Oct 2025 22:29:39 +0300 Subject: [PATCH 5/5] try fixing main.yml again --- .github/workflows/main.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb601854..3393ce5d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,6 +40,19 @@ jobs: matrix: command: [lint, test] steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: 16 + check-latest: true + cache: npm + + - name: Install dependencies + run: npm ci + - name: Restore build artifacts uses: actions/cache@v4 with: @@ -49,10 +62,5 @@ jobs: packages/*/build key: ${{ github.sha }}-build - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: 16 - - name: Run ${{ matrix.command }} task run: npm run ${{ matrix.command }}