gatsby-plugin-google-gtag 5.0.0 → 5.1.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 CHANGED
@@ -3,6 +3,15 @@
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
+ ## [5.0.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-google-gtag@5.0.0/packages/gatsby-plugin-google-gtag) (2022-11-08)
7
+
8
+ [🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v5.0)
9
+
10
+ #### Chores
11
+
12
+ - Update peerDeps [#36965](https://github.com/gatsbyjs/gatsby/issues/36965) ([b624442](https://github.com/gatsbyjs/gatsby/commit/b6244424fe8b724cbc23b80b2b4f5424cc2055a4))
13
+ - apply patches for v5 [#36796](https://github.com/gatsbyjs/gatsby/issues/36796) ([25f79b6](https://github.com/gatsbyjs/gatsby/commit/25f79b6c3719fdf09584ade620a05c66ba2a697c))
14
+
6
15
  ## [4.24.0](https://github.com/gatsbyjs/gatsby/commits/gatsby-plugin-google-gtag@4.24.0/packages/gatsby-plugin-google-gtag) (2022-09-27)
7
16
 
8
17
  [🧾 Release notes](https://www.gatsbyjs.com/docs/reference/release-notes/v4.24)
package/README.md CHANGED
@@ -50,6 +50,8 @@ module.exports = {
50
50
  exclude: ["/preview/**", "/do-not-track/me/too/"],
51
51
  // Defaults to https://www.googletagmanager.com
52
52
  origin: "YOUR_SELF_HOSTED_ORIGIN",
53
+ // Delays processing pageview events on route update (in milliseconds)
54
+ delayOnRouteUpdate: 0,
53
55
  },
54
56
  },
55
57
  },
@@ -137,3 +139,7 @@ If you enable this optional option, Google Global Site Tag will not be loaded at
137
139
  ## The "pluginConfig.exclude" option
138
140
 
139
141
  If you need to exclude any path from the tracking system, you can add it (one or more) to this optional array as glob expressions.
142
+
143
+ ## The "pluginConfig.delayOnRouteUpdate" option
144
+
145
+ If you need to delay processing pageview events on route update (e.g. to wait for page transitions with [`gatsby-plugin-transition-link`](https://www.gatsbyjs.com/plugins/gatsby-plugin-transition-link/)), then this option adds a delay before generating the pageview event.
package/gatsby-browser.js CHANGED
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
 
3
- exports.onRouteUpdate = function (_ref) {
3
+ exports.onRouteUpdate = function (_ref, pluginOptions) {
4
4
  var location = _ref.location;
5
5
 
6
+ if (pluginOptions === void 0) {
7
+ pluginOptions = {};
8
+ }
9
+
6
10
  if (process.env.NODE_ENV !== "production" || typeof gtag !== "function") {
7
11
  return null;
8
12
  }
9
13
 
14
+ var pluginConfig = pluginOptions.pluginConfig || {};
10
15
  var pathIsExcluded = location && typeof window.excludeGtagPaths !== "undefined" && window.excludeGtagPaths.some(function (rx) {
11
16
  return rx.test(location.pathname);
12
17
  });
@@ -19,13 +24,18 @@ exports.onRouteUpdate = function (_ref) {
19
24
  });
20
25
  };
21
26
 
27
+ var _pluginConfig$delayOn = pluginConfig.delayOnRouteUpdate,
28
+ delayOnRouteUpdate = _pluginConfig$delayOn === void 0 ? 0 : _pluginConfig$delayOn;
29
+
22
30
  if ("requestAnimationFrame" in window) {
23
31
  requestAnimationFrame(function () {
24
- requestAnimationFrame(sendPageView);
32
+ requestAnimationFrame(function () {
33
+ return setTimeout(sendPageView, delayOnRouteUpdate);
34
+ });
25
35
  });
26
36
  } else {
27
- // simulate 2 rAF calls
28
- setTimeout(sendPageView, 32);
37
+ // Delay by 32ms to simulate 2 requestOnAnimationFrame calls
38
+ setTimeout(sendPageView, 32 + delayOnRouteUpdate);
29
39
  }
30
40
 
31
41
  return null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatsby-plugin-google-gtag",
3
3
  "description": "Gatsby plugin to add google gtag onto a site",
4
- "version": "5.0.0",
4
+ "version": "5.1.0",
5
5
  "author": "Tyler Buchea <tyler@buchea.com>",
6
6
  "bugs": {
7
7
  "url": "https://github.com/gatsbyjs/gatsby/issues"
@@ -13,7 +13,7 @@
13
13
  "devDependencies": {
14
14
  "@babel/cli": "^7.15.4",
15
15
  "@babel/core": "^7.15.5",
16
- "babel-preset-gatsby-package": "^3.0.0",
16
+ "babel-preset-gatsby-package": "^3.1.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": ">=18.0.0"
45
45
  },
46
- "gitHead": "0c6cd6126c9ccb7fbd62ad3aa3a75efaa7bc7427"
46
+ "gitHead": "2cfb64b6a7d2fac447f4535c30a82fbcbc6251bf"
47
47
  }