Skip to content

Commit

Permalink
experiment docs
Browse files Browse the repository at this point in the history
  • Loading branch information
binjamil committed May 19, 2024
1 parent ffe9db3 commit a7ca6a8
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@mbinjamil/matomo-client

## Installation

```
npm install @mbinjamil/matomo-client
```

## Features

- Injecting and loading Matomo script asynchronously

## Usage

Load script on mount and call tracking functions anywhere in the app

### [API Reference](docs/README.md)
6 changes: 6 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @mbinjamil/matomo-client

- [load](functions/load.md)
- [push](functions/push.md)
- [trackEvent](functions/trackEvent.md)
- [trackPageView](functions/trackPageView.md)
25 changes: 25 additions & 0 deletions docs/functions/load.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[@mbinjamil/matomo-client](../README.md) / load

# Function: load()

> **load**(`trackerUrl`, `siteId`): `void`
Injects the Matomo tracking script into the DOM and loads it asynchronously

## Parameters

**trackerUrl**: `string`

Your Matomo URL

**siteId**: `number`

Site ID of the website you are tracking in Matomo

## Returns

`void`

## Source

[index.ts:13](https://github.com/binjamil/matomo-client/blob/ffe9db3ab8b729a706d4a5e6374173837f833606/src/index.ts#L13)
31 changes: 31 additions & 0 deletions docs/functions/push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[@mbinjamil/matomo-client](../README.md) / push

# Function: push()

> **push**(`values`): `void`
Low-level Matomo API to execute any supported configuration or tracking calls

## Parameters

**values**: readonly (`string` \| `number`)[]

An array defining API method name and its parameters

## Returns

`void`

## See

https://developer.matomo.org/api-reference/tracking-javascript

## Example

```ts
push([ 'API_method_name', parameter_list ]);
```

## Source

[index.ts:71](https://github.com/binjamil/matomo-client/blob/ffe9db3ab8b729a706d4a5e6374173837f833606/src/index.ts#L71)
33 changes: 33 additions & 0 deletions docs/functions/trackEvent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[@mbinjamil/matomo-client](../README.md) / trackEvent

# Function: trackEvent()

> **trackEvent**(`category`, `action`, `name`, `value`): `void`
Logs an event of interest

## Parameters

**category**: `string`

An event category (Videos, Music, Games...)

**action**: `string`

An event action (Play, Pause, Duration, Add Playlist, Downloaded, Clicked...)

**name**: `string`

An optional event name

**value**: `number`

An optional numeric value

## Returns

`void`

## Source

[index.ts:53](https://github.com/binjamil/matomo-client/blob/ffe9db3ab8b729a706d4a5e6374173837f833606/src/index.ts#L53)
22 changes: 22 additions & 0 deletions docs/functions/trackPageView.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[@mbinjamil/matomo-client](../README.md) / trackPageView

# Function: trackPageView()

> **trackPageView**(`pageTitle`?): `void`
Logs a page view. The URL is set to `window.location.href` because Matomo
by default does not support client-side routing

## Parameters

**pageTitle?**: `string`

A custom title that overrides the default HTML page title

## Returns

`void`

## Source

[index.ts:40](https://github.com/binjamil/matomo-client/blob/ffe9db3ab8b729a706d4a5e6374173837f833606/src/index.ts#L40)
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@
"build:js": "node build.mjs",
"build:types": "tsc --emitDeclarationOnly",
"release": "pnpm build && pnpm changeset publish",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"docs": "typedoc src/index.ts --readme none"
},
"devDependencies": {
"@changesets/cli": "^2.27.2",
"esbuild": "^0.21.3",
"prettier": "^3.2.5",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^4.0.2",
"typescript": "^5.4.5"
}
}
92 changes: 92 additions & 0 deletions pnpm-lock.yaml

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

6 changes: 6 additions & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugin": ["typedoc-plugin-markdown"],
"hidePageHeader": true,
"excludeGroups": true,
"out": "./docs"
}

0 comments on commit a7ca6a8

Please sign in to comment.