volto-google-analytics
Advanced tools
Comparing version 0.1.0 to 1.0.0
{ | ||
"name": "volto-google-analytics", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Volto addon for Google Analytics integration", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
105
README.md
@@ -9,108 +9,3 @@ # volto-google-analytics | ||
## Setup with voltocli | ||
```bash | ||
voltocli | ||
``` | ||
and insert `volto-google-analytics` as addon name and `git@github.com:collective/volto-google-analytics.git` as addon URL. | ||
## Manual setup | ||
In your Volto project: | ||
```bash | ||
yarn add mrs-developer collective/volto-google-analytics | ||
``` | ||
and in `package.json`: | ||
```json | ||
"scripts": { | ||
"develop:npx": "npx -p mrs-developer missdev --config=jsconfig.json --output=addons", | ||
"develop": "missdev --config=jsconfig.json --output=addons", | ||
"preinstall": "if [ -f $(pwd)/node_modules/.bin/missdev ]; then yarn develop; else yarn develop:npx; fi", | ||
"postinstall": "rm -rf ./node_modules/volto-* && yarn omelette", | ||
... | ||
} | ||
``` | ||
Create a `mrs.developer.json` file: | ||
```json | ||
{ | ||
"volto-google-analytics": { | ||
"url": "git@github.com:collective/volto-google-analytics.git" | ||
} | ||
} | ||
``` | ||
In `jsconfig.json`: | ||
```json | ||
{ | ||
"compilerOptions": { | ||
"paths": { | ||
"volto-google-analytics": ["addons/volto-google-analytics"] | ||
}, | ||
"baseUrl": "src" | ||
} | ||
} | ||
``` | ||
Fix tests, in `package.json`: | ||
```json | ||
"jest": { | ||
... | ||
"moduleNameMapper": { | ||
"@plone/volto/(.*)$": "<rootDir>/node_modules/@plone/volto/src/$1", | ||
"@package/(.*)$": "<rootDir>/src/$1", | ||
"volto-google-analytics/(.*)$": "<rootDir>/src/addons/volto-google-analytics/src/$1", | ||
"~/(.*)$": "<rootDir>/src/$1" | ||
}, | ||
"testMatch": [ | ||
"**/__tests__/**/*.[jt]s?(x)", | ||
"**/?(*.)+(spec|test).[jt]s?(x)", | ||
"!**/src/addons/volto/**/*" | ||
], | ||
... | ||
``` | ||
Edit `.eslintrc`: | ||
```json | ||
{ | ||
"extends": "./node_modules/@plone/volto/.eslintrc", | ||
"settings": { | ||
"import/resolver": { | ||
"alias": { | ||
"map": [ | ||
["@plone/volto", "@plone/volto/src"], | ||
["@package", "./src"], | ||
["volto-google-analytics", "./src/addons/volto-google-analytics/src"] | ||
], | ||
"extensions": [".js", ".jsx", ".json"] | ||
}, | ||
"babel-plugin-root-import": { | ||
"rootPathSuffix": "src" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
Add `src/addons` in `.gitignore`: | ||
``` | ||
# .gitignore | ||
src/addons | ||
``` | ||
Then, run `yarn` and install dependencies: | ||
```bash | ||
yarn | ||
``` | ||
## Usage | ||
@@ -117,0 +12,0 @@ |
@@ -1,6 +0,6 @@ | ||
import { useEffect } from 'react' | ||
import { useLocation } from 'react-router-dom' | ||
import ReactGA from 'react-ga' | ||
import { useEffect } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import ReactGA from 'react-ga'; | ||
const trackingCode = process.env.RAZZLE_GA_CODE | ||
const trackingCode = process.env.RAZZLE_GA_CODE; | ||
@@ -13,13 +13,15 @@ if (__CLIENT__ && trackingCode) { | ||
}, | ||
}) | ||
}); | ||
} | ||
const useGoogleAnalytics = () => { | ||
let location = useLocation() | ||
let location = useLocation(); | ||
useEffect(() => { | ||
ReactGA.pageview(location.pathname) | ||
}, [location]) | ||
} | ||
ReactGA.pageview(location.pathname); | ||
}, [location]); | ||
}; | ||
export { useGoogleAnalytics } | ||
export { useGoogleAnalytics }; | ||
export default config => config; |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5
34
1
3433
31