mirror of
https://github.com/kremalicious/gatsby-plugin-matomo.git
synced 2024-12-22 17:23:23 +01:00
* Add support for error tracking [Fixes #168] * fix missing cookieDomain Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
parent
4858debe66
commit
ae2e8e7a61
@ -66,7 +66,7 @@ _NOTE: By default, this plugin only generates output when run in production mode
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Option | Explanation |
|
| Option | Explanation |
|
||||||
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| `siteId` | Your Matomo site ID configured in your Matomo installation. |
|
| `siteId` | Your Matomo site ID configured in your Matomo installation. |
|
||||||
| `matomoUrl` | The url of your Matomo installation. |
|
| `matomoUrl` | The url of your Matomo installation. |
|
||||||
| `siteUrl` | The url of your site, usually the same as `siteMetadata.siteUrl`. Only used for generating the url for `noscript` image tracking fallback. |
|
| `siteUrl` | The url of your site, usually the same as `siteMetadata.siteUrl`. Only used for generating the url for `noscript` image tracking fallback. |
|
||||||
@ -81,6 +81,7 @@ _NOTE: By default, this plugin only generates output when run in production mode
|
|||||||
| `trackLoad` | (optional) If true, it will track the loading of the matomo library. Defaults to `true`. |
|
| `trackLoad` | (optional) If true, it will track the loading of the matomo library. Defaults to `true`. |
|
||||||
| `respectDnt` | (optional) If false, will load all scripts without respecting user preference to `Do Not Track` on browsers. Defaults to `true`. |
|
| `respectDnt` | (optional) If false, will load all scripts without respecting user preference to `Do Not Track` on browsers. Defaults to `true`. |
|
||||||
| `dev` | (optional) Activate dev mode by setting to `true`. Will load all scripts despite not running in `production` environment. Ignores your local browser's DNT header too. Outputs some information in console about what it is doing. Useful for local testing but careful: all hits will be send like in production. |
|
| `dev` | (optional) Activate dev mode by setting to `true`. Will load all scripts despite not running in `production` environment. Ignores your local browser's DNT header too. Outputs some information in console about what it is doing. Useful for local testing but careful: all hits will be send like in production. |
|
||||||
|
| `enableJSErrorTracking` | (optional) Enable basic JavaScript error tracking and reporting in Matomo by setting to `true`. |
|
||||||
|
|
||||||
```js
|
```js
|
||||||
plugins: [
|
plugins: [
|
||||||
@ -99,7 +100,8 @@ plugins: [
|
|||||||
disableCookies: false,
|
disableCookies: false,
|
||||||
cookieDomain: '*.example.org',
|
cookieDomain: '*.example.org',
|
||||||
localScript: '/piwik.js',
|
localScript: '/piwik.js',
|
||||||
dev: false
|
dev: false,
|
||||||
|
enableJSErrorTracking: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -93,6 +93,14 @@ describe('gatsby-plugin-google-analytics', () => {
|
|||||||
expect(result).toMatch(/disableCookies/)
|
expect(result).toMatch(/disableCookies/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('sets enableJSErrorTracking', () => {
|
||||||
|
const { setPostBodyComponents } = setup({
|
||||||
|
enableJSErrorTracking: true
|
||||||
|
})
|
||||||
|
const result = JSON.stringify(setPostBodyComponents.mock.calls[0][0])
|
||||||
|
expect(result).toMatch(/enableJSErrorTracking/)
|
||||||
|
})
|
||||||
|
|
||||||
it('sets localScript', () => {
|
it('sets localScript', () => {
|
||||||
const { setPostBodyComponents } = setup({
|
const { setPostBodyComponents } = setup({
|
||||||
localScript: 'TEST_LOCAL_SCRIPT'
|
localScript: 'TEST_LOCAL_SCRIPT'
|
||||||
|
@ -13,6 +13,7 @@ function buildTrackingCode(pluginOptions) {
|
|||||||
requireCookieConsent,
|
requireCookieConsent,
|
||||||
disableCookies,
|
disableCookies,
|
||||||
cookieDomain,
|
cookieDomain,
|
||||||
|
enableJSErrorTracking,
|
||||||
respectDnt = true
|
respectDnt = true
|
||||||
} = pluginOptions
|
} = pluginOptions
|
||||||
|
|
||||||
@ -33,6 +34,11 @@ function buildTrackingCode(pluginOptions) {
|
|||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
${disableCookies ? "window._paq.push(['disableCookies']);" : ''}
|
${disableCookies ? "window._paq.push(['disableCookies']);" : ''}
|
||||||
|
${
|
||||||
|
enableJSErrorTracking
|
||||||
|
? "window._paq.push(['enableJSErrorTracking']);"
|
||||||
|
: ''
|
||||||
|
}
|
||||||
${
|
${
|
||||||
cookieDomain
|
cookieDomain
|
||||||
? `window._paq.push(['setCookieDomain', '${cookieDomain}']);`
|
? `window._paq.push(['setCookieDomain', '${cookieDomain}']);`
|
||||||
|
Loading…
Reference in New Issue
Block a user