gatsby-plugin-rudderstack 4.0.0 → 4.0.2

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
@@ -2,25 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ## [4.0.0](https://github.com/rudderlabs/gatsby-plugin-rudderstack/compare/v3.0.0...v4.0.0) (2024-03-28)
5
+ ### [4.0.2](https://github.com/rudderlabs/gatsby-plugin-rudderstack/compare/v4.0.1...v4.0.2) (2024-10-09)
6
6
 
7
7
 
8
- ### Features
8
+ ### Bug Fixes
9
9
 
10
- * use js sdk v3 ([#30](https://github.com/rudderlabs/gatsby-plugin-rudderstack/issues/30)) ([3c81fd7](https://github.com/rudderlabs/gatsby-plugin-rudderstack/commit/3c81fd7eefefdf3afe1f8a28fd5a5eff7b6009c6))
11
- * use JS SDK v3 loading snippet with new useLegacySDK option for v2.x usage ([#26](https://github.com/rudderlabs/gatsby-plugin-rudderstack/issues/26)) ([c05cdbb](https://github.com/rudderlabs/gatsby-plugin-rudderstack/commit/c05cdbb15ef5fb6862d7d9804e980219d7ab6fe3))
10
+ * update js sdk loading snippet to latest version ([#35](https://github.com/rudderlabs/gatsby-plugin-rudderstack/issues/35)) ([7aa3d58](https://github.com/rudderlabs/gatsby-plugin-rudderstack/commit/7aa3d586e2d9a569a9609d7025ba6f7c6e3ba266))
12
11
 
13
- ## [2.0.0](https://github.com/rudderlabs/gatsby-plugin-rudderstack/compare/a2ed4a794130f7a0dd783f42c1107aa44089a45c...v2.0.0) (2022-12-14)
12
+ ## [4.0.1](https://github.com/rudderlabs/gatsby-plugin-rudderstack/compare/v4.0.0...v4.0.1) (2024-03-29)
14
13
 
14
+ ### Bug Fixes
15
15
 
16
- ### BREAKING CHANGES
16
+ * fix: loading snippet ([766f805]https://github.com/rudderlabs/gatsby-plugin-rudderstack/commit/766f8056cf1cc064207bf6caa2108928999d90b9)
17
+
18
+
19
+ ## [4.0.0](https://github.com/rudderlabs/gatsby-plugin-rudderstack/compare/v3.0.0...v4.0.0) (2024-03-28)
17
20
 
18
- * modify delayLoad functionality (#17)
19
21
 
20
22
  ### Features
21
23
 
22
- * Added option to use new JS SDK ([#10](https://github.com/rudderlabs/gatsby-plugin-rudderstack/issues/10)) ([a2ed4a7](https://github.com/rudderlabs/gatsby-plugin-rudderstack/commit/a2ed4a794130f7a0dd783f42c1107aa44089a45c))
23
- * modify delayLoad functionality ([#17](https://github.com/rudderlabs/gatsby-plugin-rudderstack/issues/17)) ([65f176d](https://github.com/rudderlabs/gatsby-plugin-rudderstack/commit/65f176dd8e7fff4749b7142ba16d63519651fe45))
24
+ * use js sdk v3 ([#30](https://github.com/rudderlabs/gatsby-plugin-rudderstack/issues/30)) ([3c81fd7](https://github.com/rudderlabs/gatsby-plugin-rudderstack/commit/3c81fd7eefefdf3afe1f8a28fd5a5eff7b6009c6))
25
+ * use JS SDK v3 loading snippet with new useLegacySDK option for v2.x usage ([#26](https://github.com/rudderlabs/gatsby-plugin-rudderstack/issues/26)) ([c05cdbb](https://github.com/rudderlabs/gatsby-plugin-rudderstack/commit/c05cdbb15ef5fb6862d7d9804e980219d7ab6fe3))
24
26
 
25
27
  ## [3.0.0](https://github.com/rudderlabs/gatsby-plugin-rudderstack/compare/v2.0.0...v3.0.0) (2023-12-05)
26
28
 
package/gatsby-browser.js CHANGED
@@ -9,7 +9,9 @@ exports.onRouteUpdate = function (_ref, _ref2) {
9
9
  if (trackPage) {
10
10
  var delay = Math.max(0, trackPageDelay);
11
11
  window.setTimeout(function () {
12
- window.rudderanalytics && window.rudderanalytics.page(document.title);
12
+ if (window.rudderanalytics) {
13
+ window.rudderanalytics.page(document.title);
14
+ }
13
15
  }, delay);
14
16
  }
15
17
  }
@@ -18,17 +20,15 @@ exports.onRouteUpdate = function (_ref, _ref2) {
18
20
  window.rudderSnippetLoadedCallback = function () {
19
21
  trackRudderStackPage();
20
22
  };
23
+ } else if (prevLocation) {
24
+ window.rudderSnippetLoadedCallback = undefined;
25
+ window.rudderSnippetLoader(function () {
26
+ trackRudderStackPage();
27
+ });
21
28
  } else {
22
- if (prevLocation) {
23
- window.rudderSnippetLoadedCallback = undefined;
24
- window.rudderSnippetLoader(function () {
25
- trackRudderStackPage();
26
- });
27
- } else {
28
- window.rudderSnippetLoadedCallback = function () {
29
- trackRudderStackPage();
30
- };
31
- }
29
+ window.rudderSnippetLoadedCallback = function () {
30
+ trackRudderStackPage();
31
+ };
32
32
  }
33
33
  } else {
34
34
  trackRudderStackPage();
package/gatsby-node.js CHANGED
@@ -1 +1,2 @@
1
- exports.onPreInit = () => console.log("Loaded gatsby-plugin-rudderstack");
1
+ // eslint-disable-next-line no-console
2
+ exports.onPreInit = () => console.log('Loaded gatsby-plugin-rudderstack');
package/gatsby-ssr.js CHANGED
@@ -4,9 +4,9 @@ var _jsxRuntime = require("react/jsx-runtime");
4
4
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
10
  exports.onRenderBody = function (_ref, pluginOptions) {
11
11
  var setHeadComponents = _ref.setHeadComponents;
12
12
  var prodKey = pluginOptions.prodKey,
@@ -29,7 +29,7 @@ exports.onRenderBody = function (_ref, pluginOptions) {
29
29
  configUrl: controlPlaneUrl || loadOptions.configUrl
30
30
  });
31
31
  var loadConfig = "'".concat(writeKey, "', '").concat(dataPlaneUrl, "', ").concat(JSON.stringify(finalLoadOptions));
32
- var snippet = "!function(){\"use strict\";window.RudderSnippetVersion=\"3.0.3\";var sdkBaseUrl=".concat(sdkURL, ";var sdkName=\"rsa.min.js\";var asyncScript=").concat(loadType === 'async', ";var deferScript=").concat(loadType === 'defer', ";window.rudderAnalyticsBuildType=\"legacy\",window.rudderanalytics=[]\n ;var e=[\"setDefaultInstanceKey\",\"load\",\"ready\",\"page\",\"track\",\"identify\",\"alias\",\"group\",\"reset\",\"setAnonymousId\",\"startSession\",\"endSession\",\"consent\"]\n ;for(var n=0;n<e.length;n++){var t=e[n];window.rudderanalytics[t]=function(e){return function(){\n window.rudderanalytics.push([e].concat(Array.prototype.slice.call(arguments)))}}(t)}try{\n new Function('return import(\"\")'),window.rudderAnalyticsBuildType=\"modern\"}catch(a){}\n if(window.rudderAnalyticsMount=function(){\n \"undefined\"==typeof globalThis&&(Object.defineProperty(Object.prototype,\"__globalThis_magic__\",{get:function get(){\n return this},configurable:true}),__globalThis_magic__.globalThis=__globalThis_magic__,\n delete Object.prototype.__globalThis_magic__);var e=document.createElement(\"script\")\n ;e.src=\"\".concat(sdkBaseUrl,\"/\").concat(window.rudderAnalyticsBuildType,\"/\").concat(sdkName);if(asyncScript){e.async=true};if(deferScript){e.defer=true};document.head?document.head.appendChild(e):document.body.appendChild(e)\n },\"undefined\"==typeof Promise||\"undefined\"==typeof globalThis){var d=document.createElement(\"script\")\n ;d.src=\"https://polyfill-fastly.io/v3/polyfill.min.js?version=3.111.0&features=Symbol%2CPromise&callback=rudderAnalyticsMount\",\n d.async=asyncScript,document.head?document.head.appendChild(d):document.body.appendChild(d)}else{\n window.rudderAnalyticsMount()}}();");
32
+ var snippet = "!function(){\"use strict\";window.RudderSnippetVersion=\"3.0.32\";var e=\"rudderanalytics\";window[e]||(window[e]=[])\n;var rudderanalytics=window[e];if(Array.isArray(rudderanalytics)){\nif(true===rudderanalytics.snippetExecuted&&window.console&&console.error){\nconsole.error(\"RudderStack JavaScript SDK snippet included more than once.\")}else{rudderanalytics.snippetExecuted=true,\nwindow.rudderAnalyticsBuildType=\"legacy\";var sdkBaseUrl=\"".concat(sdkURL, "\";var sdkName=\"rsa.min.js\"\n;var scriptLoadingMode=\"").concat(loadType, "\"\n;var r=[\"setDefaultInstanceKey\",\"load\",\"ready\",\"page\",\"track\",\"identify\",\"alias\",\"group\",\"reset\",\"setAnonymousId\",\"startSession\",\"endSession\",\"consent\"]\n;for(var n=0;n<r.length;n++){var t=r[n];rudderanalytics[t]=function(r){return function(){var n\n;Array.isArray(window[e])?rudderanalytics.push([r].concat(Array.prototype.slice.call(arguments))):null===(n=window[e][r])||void 0===n||n.apply(window[e],arguments)\n}}(t)}try{\nnew Function('class Test{field=()=>{};test({prop=[]}={}){return prop?(prop?.property??[...prop]):import(\"\");}}'),\nwindow.rudderAnalyticsBuildType=\"modern\"}catch(o){}var d=document.head||document.getElementsByTagName(\"head\")[0]\n;var i=document.body||document.getElementsByTagName(\"body\")[0];window.rudderAnalyticsAddScript=function(e,r,n){\nvar t=document.createElement(\"script\");t.src=e,t.setAttribute(\"data-loader\",\"RS_JS_SDK\"),r&&n&&t.setAttribute(r,n),\n\"async\"===scriptLoadingMode?t.async=true:\"defer\"===scriptLoadingMode&&(t.defer=true),\nd?d.insertBefore(t,d.firstChild):i.insertBefore(t,i.firstChild)},window.rudderAnalyticsMount=function(){!function(){\nif(\"undefined\"==typeof globalThis){var e;var r=function getGlobal(){\nreturn\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:null}();r&&Object.defineProperty(r,\"globalThis\",{\nvalue:r,configurable:true})}\n}(),window.rudderAnalyticsAddScript(\"\".concat(sdkBaseUrl,\"/\").concat(window.rudderAnalyticsBuildType,\"/\").concat(sdkName),\"data-rsa-write-key\",\"").concat(writeKey, "\")\n},\n\"undefined\"==typeof Promise||\"undefined\"==typeof globalThis?window.rudderAnalyticsAddScript(\"https://polyfill-fastly.io/v3/polyfill.min.js?version=3.111.0&features=Symbol%2CPromise&callback=rudderAnalyticsMount\"):window.rudderAnalyticsMount()}}}();");
33
33
  var instantLoader = "".concat(snippet).concat(manualLoad ? "" : "window.rudderanalytics.load(".concat(loadConfig, ")"), ";");
34
34
  var delayedLoader = "\n window.rudderSnippetLoaded = false;\n window.rudderSnippetLoading = false;\n window.rudderSnippetLoadedCallback = undefined;\n window.rudderSnippetLoader = function (callback) {\n if (!window.rudderSnippetLoaded && !window.rudderSnippetLoading) {\n window.rudderSnippetLoading = true;\n function loader() {\n ".concat(snippet, "\n window.rudderanalytics.load(").concat(loadConfig, ");\n window.rudderSnippetLoading = false;\n window.rudderSnippetLoaded = true;\n if (callback) { callback(); }\n if (window.rudderSnippetLoadedCallback) {\n window.rudderSnippetLoadedCallback();\n window.rudderSnippetLoadedCallback = undefined;\n }\n };\n\n \"requestIdleCallback\" in window\n ? requestIdleCallback(function () { loader(); })\n : loader();\n }\n }\n window.addEventListener('scroll',function () {window.rudderSnippetLoader()}, { once: true });\n setTimeout(\n function () {\n \"requestIdleCallback\" in window\n ? requestIdleCallback(function () { window.rudderSnippetLoader(); })\n : window.rudderSnippetLoader();\n },\n ").concat(delayLoadTime, " || 1000\n );\n ");
35
35
  var snippetToUse = "".concat(delayLoad && !manualLoad ? delayedLoader : instantLoader);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-plugin-rudderstack",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Event tracking with RudderStack in your Gatsby frontend.",
5
5
  "main": "gatsby-ssr.js",
6
6
  "scripts": {
@@ -14,7 +14,7 @@
14
14
  "check:security": "npm audit --recursive --audit-level=high",
15
15
  "format": "prettier --write .",
16
16
  "lint:fix": "eslint . --fix",
17
- "prepare": "husky install",
17
+ "prepare": "husky",
18
18
  "pre-commit": "npm run test && npx lint-staged",
19
19
  "commit-msg": "commitlint --edit",
20
20
  "commit": "git-cz",
@@ -40,39 +40,34 @@
40
40
  },
41
41
  "homepage": "https://github.com/rudderlabs/gatsby-plugin-rudderstack#readme",
42
42
  "devDependencies": {
43
- "@babel/cli": "7.23.4",
44
- "@babel/core": "7.23.5",
45
- "@babel/eslint-parser": "7.23.3",
43
+ "@babel/cli": "7.25.7",
44
+ "@babel/core": "7.25.7",
45
+ "@babel/eslint-parser": "7.25.7",
46
46
  "@babel/plugin-proposal-object-rest-spread": "7.20.7",
47
- "@babel/preset-env": "7.23.5",
48
- "@babel/preset-react": "7.23.3",
49
- "@commitlint/config-conventional": "18.4.3",
47
+ "@babel/preset-env": "7.25.7",
48
+ "@babel/preset-react": "7.25.7",
49
+ "@commitlint/config-conventional": "19.5.0",
50
50
  "@digitalroute/cz-conventional-changelog-for-jira": "8.0.1",
51
- "commitizen": "4.3.0",
52
- "commitlint": "18.4.3",
53
- "conventional-changelog-cli": "4.1.0",
51
+ "commitizen": "4.3.1",
52
+ "commitlint": "19.5.0",
53
+ "conventional-changelog-cli": "5.0.0",
54
54
  "conventional-github-releaser": "3.1.5",
55
- "eslint": "8.55.0",
55
+ "eslint": "8.57.0",
56
56
  "eslint-config-airbnb": "19.0.4",
57
57
  "eslint-config-airbnb-base": "15.0.0",
58
58
  "eslint-config-prettier": "9.1.0",
59
- "eslint-plugin-compat": "4.2.0",
60
- "eslint-plugin-import": "2.29.0",
61
- "eslint-plugin-sonarjs": "0.23.0",
62
- "eslint-plugin-unicorn": "49.0.0",
63
- "git-cz": "^4.9.0",
64
- "husky": "8.0.3",
65
- "jscpd": "3.5.10",
66
- "lint-staged": "15.2.0",
67
- "madge": "6.1.0",
68
- "prettier": "3.1.0",
59
+ "eslint-plugin-compat": "6.0.1",
60
+ "eslint-plugin-import": "2.31.0",
61
+ "eslint-plugin-sonarjs": "2.0.3",
62
+ "eslint-plugin-unicorn": "56.0.0",
63
+ "git-cz": "4.9.0",
64
+ "husky": "9.1.6",
65
+ "jscpd": "4.0.5",
66
+ "lint-staged": "15.2.10",
67
+ "madge": "8.0.0",
68
+ "prettier": "3.3.3",
69
69
  "standard-version": "9.5.0"
70
70
  },
71
- "eslintConfig": {
72
- "rules": {
73
- "strict": "off"
74
- }
75
- },
76
71
  "lint-staged": {
77
72
  "*.js": "eslint --cache --fix",
78
73
  "*.{json,js,md,ts}": "prettier --write"
@@ -90,7 +85,10 @@
90
85
  "dot-prop": "5.3.0",
91
86
  "http-cache-semantics": "4.1.1",
92
87
  "semver-regex": "3.1.4",
93
- "trim-newlines": "3.0.1"
88
+ "trim-newlines": "3.0.1",
89
+ "conventional-github-releaser": {
90
+ "conventional-changelog-core": "4.2.2"
91
+ }
94
92
  },
95
93
  "resolutions": {
96
94
  "dot-prop": "5.3.0",