From c0269c71e223bf8ed4529de67ed1968ad9679de0 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 15 Feb 2020 14:07:20 +0100 Subject: [PATCH 1/2] updates and cleanup --- .babelrc | 5 +---- .editorconfig | 10 ---------- .eslintrc | 8 ++------ .prettierrc | 3 ++- LICENSE | 2 +- README.md | 4 ++-- package.json | 33 ++++++++++++++++----------------- src/gatsby-browser.js | 9 ++++----- src/gatsby-ssr.js | 29 ++++++++++++++--------------- 9 files changed, 42 insertions(+), 61 deletions(-) delete mode 100644 .editorconfig diff --git a/.babelrc b/.babelrc index 832bdea..3104352 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,3 @@ { - "presets": [ - ["@babel/env"], - ["@babel/react"] - ] + "presets": [["babel-preset-gatsby-package", { "browser": true }]] } diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 7e07638..0000000 --- a/.editorconfig +++ /dev/null @@ -1,10 +0,0 @@ - -# EditorConfig is awesome: http://EditorConfig.org - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -insert_final_newline = true -charset = utf-8 -trim_trailing_whitespace = true \ No newline at end of file diff --git a/.eslintrc b/.eslintrc index 10808f9..8aad754 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,10 +1,6 @@ { - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:prettier/recommended" - ], - "plugins": ["react", "prettier"], + "extends": ["eslint:recommended", "plugin:prettier/recommended"], + "plugins": ["prettier"], "parserOptions": { "sourceType": "module", "ecmaFeatures": { diff --git a/.prettierrc b/.prettierrc index 49955e2..338a8b9 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,6 @@ { "semi": false, "singleQuote": true, - "trailingComma": "none" + "trailingComma": "none", + "tabWidth": 2 } diff --git a/LICENSE b/LICENSE index abee374..027df04 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018 Matthias Kretschmann m@kretschmann.io +Copyright (c) 2020 Matthias Kretschmann m@kretschmann.io Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 0ab59d3..7bb15fd 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ plugins: [ options: { siteId: 'YOUR_SITE_ID', matomoUrl: 'https://YOUR_MATOMO_URL.COM', - siteUrl: 'https://YOUR_LIVE_SITE_URL.COM' + siteUrl: 'https://YOUR_LIVE_SITE_URL.COM', // All the optional settings exclude: ['/offline-plugin-app-shell-fallback/'], requireConsent: false, @@ -118,7 +118,7 @@ See [CHANGELOG.md](CHANGELOG.md). The MIT License -Copyright (c) 2018 Matthias Kretschmann +Copyright (c) 2020 Matthias Kretschmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/package.json b/package.json index c0684d5..510c90c 100644 --- a/package.json +++ b/package.json @@ -7,39 +7,38 @@ "build": "babel src --out-dir . --ignore __tests__", "start": "babel -w src --out-dir . --ignore __tests__", "test": "eslint ./src/**/*.js", - "format": "prettier --write 'src/**/*.{js,jsx}'", + "format": "prettier --write 'src/**/*.js'", "release": "release-it --non-interactive", "changelog": "auto-changelog -p", "prepublishOnly": "cross-env NODE_ENV=production npm run build" }, "dependencies": {}, "devDependencies": { - "@babel/cli": "^7.4.4", - "@babel/core": "^7.4.5", - "@babel/preset-env": "^7.4.5", - "@babel/preset-react": "^7.0.0", - "auto-changelog": "^1.13.0", - "cross-env": "^5.2.0", - "eslint": "^5.16.0", - "eslint-config-prettier": "^4.3.0", - "eslint-plugin-prettier": "^3.1.0", - "eslint-plugin-react": "^7.13.0", - "prettier": "^1.18.2", - "react": "^16.8.6", - "react-dom": "^16.8.6", - "release-it": "^12.3.0" + "@babel/cli": "^7.8.4", + "@babel/core": "^7.8.4", + "auto-changelog": "^1.16.2", + "babel-preset-gatsby-package": "^0.2.16", + "cross-env": "^7.0.0", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.10.0", + "eslint-plugin-prettier": "^3.1.2", + "prettier": "^1.19.1", + "release-it": "^12.4.3" }, - "homepage": "https://github.com/kremalicious/gatsby-plugin-matomo", + "homepage": "https://kremalicious.com/gatsby-plugin-matomo", "keywords": [ "gatsby", "gatsby-plugin", + "analytics", "matomo", "piwik" ], "license": "MIT", "main": "index.js", "peerDependencies": { - "gatsby": ">=1.9.0" + "gatsby": ">=2.0.0", + "react": ">=16.4.2", + "react-dom": ">=16.4.2" }, "repository": "github:kremalicious/gatsby-plugin-matomo", "bugs": { diff --git a/src/gatsby-browser.js b/src/gatsby-browser.js index 496d005..93f5b7f 100644 --- a/src/gatsby-browser.js +++ b/src/gatsby-browser.js @@ -1,5 +1,3 @@ -/* eslint-disable no-console */ - let first = true function getDuration() { @@ -14,7 +12,7 @@ function getDuration() { return difference } -exports.onRouteUpdate = ({ location, prevLocation }) => { +export const onRouteUpdate = ({ location, prevLocation }) => { if ( (process.env.NODE_ENV === 'production' && typeof _paq !== 'undefined') || window.dev === true @@ -40,7 +38,7 @@ exports.onRouteUpdate = ({ location, prevLocation }) => { _paq.push(['trackAllContentImpressions']) if (dev) { - console.log(`[Matomo] Page view for: ${url} - ${title}`) + console.debug(`[Matomo] Page view for: ${url} - ${title}`) } } @@ -58,9 +56,10 @@ exports.onRouteUpdate = ({ location, prevLocation }) => { _paq.push(['trackEvent', 'javascript', 'load', 'duration', getDuration()]) if (dev) { - console.log(`[Matomo] Tracking duration for: ${url}`) + console.debug(`[Matomo] Tracking duration for: ${url}`) } } } + return null } diff --git a/src/gatsby-ssr.js b/src/gatsby-ssr.js index dbaff2c..dc48de1 100644 --- a/src/gatsby-ssr.js +++ b/src/gatsby-ssr.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line no-unused-vars import React from 'react' function buildTrackingCode(pluginOptions) { @@ -29,29 +30,28 @@ function buildTrackingCode(pluginOptions) { })(); if (window.dev === true) { - console.log('[Matomo] Tracking initialized') - console.log('[Matomo] matomoUrl: ${matomoUrl}, siteId: ${siteId}') + console.debug('[Matomo] Tracking initialized') + console.debug('[Matomo] matomoUrl: ${matomoUrl}, siteId: ${siteId}') } } ` return (