gatsby-plugin-google-gtag 4.11.0 → 4.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/package.json +4 -4
- package/gatsby-browser.js +0 -32
- package/gatsby-ssr.js +0 -57
- package/index.js +0 -66
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.11.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-google-gtag@4.11.0/packages/gatsby-plugin-google-gtag) (2022-03-29)
|
|
7
|
+
|
|
8
|
+
[🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v4.11)
|
|
9
|
+
|
|
10
|
+
#### Bug Fixes
|
|
11
|
+
|
|
12
|
+
- compatibility with react rc 2 [#35108](https://github.com/gatsbyjs/gatsby/issues/35108) ([0c61265](https://github.com/gatsbyjs/gatsby/commit/0c6126574d203c0e6fef173b76859cdcab2f13aa))
|
|
13
|
+
|
|
14
|
+
#### Chores
|
|
15
|
+
|
|
16
|
+
- replace all uses of gatsbyjs.org with gatsbyjs.com [#35101](https://github.com/gatsbyjs/gatsby/issues/35101) ([16cff41](https://github.com/gatsbyjs/gatsby/commit/16cff413e154dc4e74fc5be631d52c76273e5cbc))
|
|
17
|
+
|
|
18
|
+
#### Other Changes
|
|
19
|
+
|
|
20
|
+
- Update broken link [#35184](https://github.com/gatsbyjs/gatsby/issues/35184) ([ae999cf](https://github.com/gatsbyjs/gatsby/commit/ae999cff3f79c296d0de72a14883268d80aa8268))
|
|
21
|
+
|
|
6
22
|
## [4.10.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-google-gtag@4.10.0/packages/gatsby-plugin-google-gtag) (2022-03-16)
|
|
7
23
|
|
|
8
24
|
[🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v4.10)
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-plugin-google-gtag",
|
|
3
3
|
"description": "Gatsby plugin to add google gtag onto a site",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.12.0",
|
|
5
5
|
"author": "Tyler Buchea <tyler@buchea.com>",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/gatsbyjs/gatsby/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@babel/runtime": "^7.15.4",
|
|
11
|
-
"minimatch": "^3.
|
|
11
|
+
"minimatch": "^3.1.2"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@babel/cli": "^7.15.4",
|
|
15
15
|
"@babel/core": "^7.15.5",
|
|
16
|
-
"babel-preset-gatsby-package": "^2.
|
|
16
|
+
"babel-preset-gatsby-package": "^2.12.0",
|
|
17
17
|
"cross-env": "^7.0.3"
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-google-gtag#readme",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=14.15.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "12e90fce284eb0a64b7d1f15e293027483826372"
|
|
47
47
|
}
|
package/gatsby-browser.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.onRouteUpdate = function (_ref) {
|
|
4
|
-
var location = _ref.location;
|
|
5
|
-
|
|
6
|
-
if (process.env.NODE_ENV !== "production" || typeof gtag !== "function") {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
var pathIsExcluded = location && typeof window.excludeGtagPaths !== "undefined" && window.excludeGtagPaths.some(function (rx) {
|
|
11
|
-
return rx.test(location.pathname);
|
|
12
|
-
});
|
|
13
|
-
if (pathIsExcluded) return null; // wrap inside a timeout to make sure react-helmet is done with its changes (https://github.com/gatsbyjs/gatsby/issues/11592)
|
|
14
|
-
|
|
15
|
-
var sendPageView = function sendPageView() {
|
|
16
|
-
var pagePath = location ? location.pathname + location.search + location.hash : undefined;
|
|
17
|
-
window.gtag("event", "page_view", {
|
|
18
|
-
page_path: pagePath
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
if ("requestAnimationFrame" in window) {
|
|
23
|
-
requestAnimationFrame(function () {
|
|
24
|
-
requestAnimationFrame(sendPageView);
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
// simulate 2 rAF calls
|
|
28
|
-
setTimeout(sendPageView, 32);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return null;
|
|
32
|
-
};
|
package/gatsby-ssr.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _minimatch = require("minimatch");
|
|
8
|
-
|
|
9
|
-
exports.onRenderBody = function (_ref, pluginOptions) {
|
|
10
|
-
var setHeadComponents = _ref.setHeadComponents,
|
|
11
|
-
setPostBodyComponents = _ref.setPostBodyComponents;
|
|
12
|
-
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test") return null;
|
|
13
|
-
var gtagConfig = pluginOptions.gtagConfig || {};
|
|
14
|
-
var pluginConfig = pluginOptions.pluginConfig || {};
|
|
15
|
-
var origin = pluginConfig.origin || "https://www.googletagmanager.com"; // Lighthouse recommends pre-connecting to google tag manager
|
|
16
|
-
|
|
17
|
-
setHeadComponents([/*#__PURE__*/_react.default.createElement("link", {
|
|
18
|
-
rel: "preconnect",
|
|
19
|
-
key: "preconnect-google-gtag",
|
|
20
|
-
href: origin
|
|
21
|
-
}), /*#__PURE__*/_react.default.createElement("link", {
|
|
22
|
-
rel: "dns-prefetch",
|
|
23
|
-
key: "dns-prefetch-google-gtag",
|
|
24
|
-
href: origin
|
|
25
|
-
})]); // Prevent duplicate or excluded pageview events being emitted on initial load of page by the `config` command
|
|
26
|
-
// https://developers.google.com/analytics/devguides/collection/gtagjs/#disable_pageview_tracking
|
|
27
|
-
|
|
28
|
-
gtagConfig.send_page_view = false;
|
|
29
|
-
var firstTrackingId = pluginOptions.trackingIds && pluginOptions.trackingIds.length ? pluginOptions.trackingIds[0] : "";
|
|
30
|
-
var excludeGtagPaths = [];
|
|
31
|
-
|
|
32
|
-
if (typeof pluginConfig.exclude !== "undefined") {
|
|
33
|
-
pluginConfig.exclude.map(function (exclude) {
|
|
34
|
-
var mm = new _minimatch.Minimatch(exclude);
|
|
35
|
-
excludeGtagPaths.push(mm.makeRe());
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var setComponents = pluginConfig.head ? setHeadComponents : setPostBodyComponents;
|
|
40
|
-
|
|
41
|
-
var renderHtml = function renderHtml() {
|
|
42
|
-
return "\n " + (excludeGtagPaths.length ? "window.excludeGtagPaths=[" + excludeGtagPaths.join(",") + "];" : "") + "\n " + (typeof gtagConfig.anonymize_ip !== "undefined" && gtagConfig.anonymize_ip === true ? "function gaOptout(){document.cookie=disableStr+'=true; expires=Thu, 31 Dec 2099 23:59:59 UTC;path=/',window[disableStr]=!0}var gaProperty='" + firstTrackingId + "',disableStr='ga-disable-'+gaProperty;document.cookie.indexOf(disableStr+'=true')>-1&&(window[disableStr]=!0);" : "") + "\n if(" + (pluginConfig.respectDNT ? "!(navigator.doNotTrack == \"1\" || window.doNotTrack == \"1\")" : "true") + ") {\n window.dataLayer = window.dataLayer || [];\n function gtag(){window.dataLayer && window.dataLayer.push(arguments);}\n gtag('js', new Date());\n\n " + pluginOptions.trackingIds.map(function (trackingId) {
|
|
43
|
-
return "gtag('config', '" + trackingId + "', " + JSON.stringify(gtagConfig) + ");";
|
|
44
|
-
}).join("") + "\n }\n ";
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return setComponents([/*#__PURE__*/_react.default.createElement("script", {
|
|
48
|
-
key: "gatsby-plugin-google-gtag",
|
|
49
|
-
async: true,
|
|
50
|
-
src: origin + "/gtag/js?id=" + firstTrackingId
|
|
51
|
-
}), /*#__PURE__*/_react.default.createElement("script", {
|
|
52
|
-
key: "gatsby-plugin-google-gtag-config",
|
|
53
|
-
dangerouslySetInnerHTML: {
|
|
54
|
-
__html: renderHtml()
|
|
55
|
-
}
|
|
56
|
-
})]);
|
|
57
|
-
};
|
package/index.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
exports.__esModule = true;
|
|
6
|
-
exports.OutboundLink = void 0;
|
|
7
|
-
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
|
-
var _excluded = ["children"];
|
|
17
|
-
|
|
18
|
-
var OutboundLink = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
19
|
-
var children = _ref.children,
|
|
20
|
-
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
21
|
-
return /*#__PURE__*/_react.default.createElement("a", (0, _extends2.default)({
|
|
22
|
-
ref: ref
|
|
23
|
-
}, props, {
|
|
24
|
-
onClick: function onClick(e) {
|
|
25
|
-
if (typeof props.onClick === "function") {
|
|
26
|
-
props.onClick(e);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var redirect = true;
|
|
30
|
-
|
|
31
|
-
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || e.defaultPrevented) {
|
|
32
|
-
redirect = false;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (props.target && props.target.toLowerCase() !== "_self") {
|
|
36
|
-
redirect = false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (window.gtag) {
|
|
40
|
-
window.gtag("event", "click", {
|
|
41
|
-
event_category: "outbound",
|
|
42
|
-
event_label: props.href,
|
|
43
|
-
transport_type: redirect ? "beacon" : "",
|
|
44
|
-
event_callback: function event_callback() {
|
|
45
|
-
if (redirect) {
|
|
46
|
-
document.location = props.href;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
if (redirect) {
|
|
52
|
-
document.location = props.href;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}), children);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
exports.OutboundLink = OutboundLink;
|
|
62
|
-
OutboundLink.propTypes = {
|
|
63
|
-
href: _propTypes.default.string,
|
|
64
|
-
target: _propTypes.default.string,
|
|
65
|
-
onClick: _propTypes.default.func
|
|
66
|
-
};
|