Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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@v2
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
uses: actions/cache@v2
- 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
Expand All @@ -45,16 +40,27 @@ jobs:
matrix:
command: [lint, test]
steps:
- name: Restore setup
uses: actions/cache@v2
with:
path: ./*
key: ${{ github.sha }}
- name: Check out repository
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: Install dependencies
run: npm ci

- name: Restore build artifacts
uses: actions/cache@v4
with:
path: |
packages/*/dist
packages/*/lib
packages/*/build
key: ${{ github.sha }}-build

- name: Run ${{ matrix.command }} task
run: npm run ${{ matrix.command }}
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions packages/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand All @@ -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 */
Expand All @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions packages/js/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 6 additions & 6 deletions packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ 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

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',
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -37,7 +37,7 @@
"access": "public"
},
"dependencies": {
"@jonkoops/matomo-tracker": "^0.7.0"
"@streamr/matomo-tracker": "^0.7.0"
},
"peerDependencies": {
"react": ">= 16.8.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/instance.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MatomoTracker, { types } from '@jonkoops/matomo-tracker'
import MatomoTracker, { types } from '@streamr/matomo-tracker'

export interface MatomoInstance {
trackEvent: MatomoTracker['trackEvent']
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/useMatomo.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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 () {

Check warning on line 11 in packages/react/src/useMatomo.test.tsx

View workflow job for this annotation

GitHub Actions / run (lint)

Unexpected unnamed function
const { trackPageView, trackEvent } = useMatomo()

// Track page view after page load
Expand Down Expand Up @@ -45,7 +45,7 @@
siteId: 3,
})

const Component = function () {

Check warning on line 48 in packages/react/src/useMatomo.test.tsx

View workflow job for this annotation

GitHub Actions / run (lint)

Unexpected unnamed function
return (
<MatomoProvider value={instance}>
<JustAComponent />
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"target": "es5",
"baseUrl": ".",
"paths": {
"@jonkoops/*": ["packages/*/src"]
"@streamr/*": ["packages/*/src"]
},
"composite": true,
"sourceMap": true,
Expand Down
Loading