gatsby-plugin-rudderstack 3.0.0-beta.0 → 3.0.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +81 -58
  3. package/gatsby-ssr.js +55 -0
  4. package/package.json +25 -23
  5. package/.eslintcache +0 -1
  6. package/.eslintignore +0 -8
  7. package/.eslintrc.json +0 -41
  8. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -39
  9. package/.github/ISSUE_TEMPLATE/feature-request.md +0 -20
  10. package/.github/pull_request_template.md +0 -13
  11. package/.github/workflows/build-and-quality-checks.yml +0 -36
  12. package/.github/workflows/check_pr_title.yml +0 -17
  13. package/.github/workflows/codeql-analysis.yml +0 -70
  14. package/.github/workflows/create-hotfix-branch.yml +0 -21
  15. package/.github/workflows/deploy-npm.yml +0 -82
  16. package/.github/workflows/draft-new-release.yml +0 -86
  17. package/.github/workflows/housekeeping.yaml +0 -40
  18. package/.github/workflows/notion-pr-sync.yml +0 -55
  19. package/.github/workflows/publish-new-release.yml +0 -111
  20. package/.github/workflows/test.yml +0 -44
  21. package/.husky/commit-msg +0 -4
  22. package/.husky/pre-commit +0 -4
  23. package/.idea/gatsby-plugin-rudderstack.iml +0 -10
  24. package/.idea/misc.xml +0 -6
  25. package/.idea/modules.xml +0 -8
  26. package/.idea/vcs.xml +0 -6
  27. package/.nvmrc +0 -1
  28. package/.prettierignore +0 -6
  29. package/.prettierrc +0 -7
  30. package/CODEOWNERS +0 -2
  31. package/CODE_OF_CONDUCT.md +0 -80
  32. package/CONTRIBUTING.md +0 -47
  33. package/commitlint.config.js +0 -3
  34. package/dist/LICENSE.md +0 -21
  35. package/dist/README.md +0 -331
  36. package/dist/gatsby-node.js +0 -1
  37. package/dist/gatsby-ssr.js +0 -60
  38. package/dist/package.json +0 -98
  39. package/sonar-project.properties +0 -35
  40. /package/{dist/gatsby-browser.js → gatsby-browser.js} +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
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
+
5
+ ## [3.0.0](https://github.com/rudderlabs/gatsby-plugin-rudderstack/compare/v2.0.0...v3.0.0) (2023-12-05)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * Default JS SDK version is now v3.x, this version comes with [breaking changes](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/v3/#breaking-changes) and [new features](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/v3/#new-features)
11
+
12
+ ### Features
13
+
14
+ * 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))
15
+
16
+ ## 2.0.0 (2022-12-14)
17
+
18
+
19
+ ### ⚠ BREAKING CHANGES
20
+
21
+ * modify delayLoad functionality (#17)
22
+
23
+ ### Features
24
+
25
+ * modify delayLoad functionality ([#17](https://github.com/rudderlabs/gatsby-plugin-rudderstack/issues/17)) ([65f176d](https://github.com/rudderlabs/gatsby-plugin-rudderstack/commit/65f176dd8e7fff4749b7142ba16d63519651fe45))
package/README.md CHANGED
@@ -1,7 +1,21 @@
1
- <p align="center"><a href="https://rudderstack.com"><img src="https://user-images.githubusercontent.com/59817155/121357083-1c571300-c94f-11eb-8cc7-ce6df13855c9.png" alt="RudderStack - An Open Source Customer Data Platform" height="90"/></a></p>
2
- <h1 align="center">gatsby-plugin-rudderstack</h1>
3
- <p align="center"><b>The warehouse-first customer data platform built for devs.</b></p>
4
- <br/>
1
+ ## [![Releases](https://img.shields.io/github/release/rudderlabs/gatsby-plugin-rudderstack.svg)](https://github.com/rudderlabs/gatsby-plugin-rudderstack/releases) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rudderlabs_gatsby-plugin-rudderstack&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rudderlabs_gatsby-plugin-rudderstack) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=rudderlabs_gatsby-plugin-rudderstack&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=rudderlabs_gatsby-plugin-rudderstack) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=rudderlabs_gatsby-plugin-rudderstack&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=rudderlabs_gatsby-plugin-rudderstack) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=rudderlabs_gatsby-plugin-rudderstack&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=rudderlabs_gatsby-plugin-rudderstack) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=rudderlabs_gatsby-plugin-rudderstack&metric=coverage)](https://sonarcloud.io/summary/new_code?id=rudderlabs_gatsby-plugin-rudderstack)
2
+
3
+ <p align="center">
4
+ <a href="https://rudderstack.com/">
5
+ <img alt="RudderStack" width="512" src="https://raw.githubusercontent.com/rudderlabs/rudder-sdk-js/develop/assets/rs-logo-full-light.jpg">
6
+ </a>
7
+ <br />
8
+ <caption>The Customer Data Platform for Developers</caption>
9
+ </p>
10
+ <p align="center">
11
+ <b>
12
+ <a href="https://rudderstack.com">Website</a>
13
+ ·
14
+ <a href="https://rudderstack.com/docs/stream-sources/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk/">Documentation</a>
15
+ ·
16
+ <a href="https://rudderstack.com/join-rudderstack-slack-community">Community Slack</a>
17
+ </b>
18
+ </p>
5
19
 
6
20
  # The RudderStack Plugin for Gatsby.
7
21
 
@@ -9,11 +23,11 @@ This is a way for you to quickly and easily get RudderStack up and running in yo
9
23
 
10
24
  Questions? Please join our [Slack channel](https://resources.rudderstack.com/join-rudderstack-slack) or read about us on [Product Hunt](https://www.producthunt.com/posts/rudderstack).
11
25
 
12
- # Why Use This plugin
26
+ ## Why Use This plugin
13
27
 
14
28
  This plugin makes it easy to integrate your Gatsby website with the RudderStack API and easily track events.
15
29
 
16
- # Key Features
30
+ ## Key Features
17
31
 
18
32
  - use multiple write keys (one for prod env, another optional one for dev)
19
33
  - disable page view tracking (just in case you want to add it later manually)
@@ -24,9 +38,9 @@ This plugin makes it easy to integrate your Gatsby website with the RudderStack
24
38
  - NPM: `$ npm install --save gatsby-plugin-rudderstack`
25
39
  - YARN: `$ yarn add gatsby-plugin-rudderstack`
26
40
 
27
- # [](https://github.com/rudderlabs/gatsby-plugin-rudderstack/blob/master/README.md#setup) Setup
41
+ ## [Setup](https://github.com/rudderlabs/gatsby-plugin-rudderstack/blob/master/README.md#setup)
28
42
 
29
- ## [](https://github.com/rudderlabs/gatsby-plugin-rudderstack/blob/master/README.md#step-1-configure-gatsby) Step 1: Configure Your Gatsby Config File
43
+ ### [Step 1: Configure Your Gatsby Config File](https://github.com/rudderlabs/gatsby-plugin-rudderstack/blob/master/README.md#step-1-configure-gatsby)
30
44
 
31
45
  In your gatsby-config.js file:
32
46
 
@@ -40,7 +54,7 @@ plugins: [
40
54
  // required; non-empty string
41
55
  //NOTE: Do not commit this to git. Process from env.
42
56
  prodKey: `RUDDERSTACK_PRODUCTION_WRITE_KEY`,
43
-
57
+
44
58
  // if you have a development env for your rudderstack account, paste that key here
45
59
  // when process.env.NODE_ENV === 'development'
46
60
  // optional; non-empty string
@@ -98,7 +112,7 @@ plugins: [
98
112
  // Can be used to override where the SDK should be loaded from. This is useful
99
113
  // if you want to serve the SDK from a custom domain other than RudderStack to tackle ad-blockers
100
114
  // By default, the plugin will use the latest JS SDK from RudderStack's CDN
101
- sdkURL: `https://subdomain.yourdomain.com/v1.1/rudder-analytics.min.js`,
115
+ sdkURL: `https://subdomain.yourdomain.com/v3`,
102
116
 
103
117
  // string ('async' or 'defer'); whether to load the RudderStack SDK async or defer. Anything else
104
118
  // will load normally.
@@ -106,6 +120,10 @@ plugins: [
106
120
  // 'defer' will load the SDK as <script defer></script>
107
121
  loadType: 'default',
108
122
 
123
+ // Whether to use the snippet for JS SDK v2.x
124
+ // Useful for only loading the previous major version of the SDK if you do not want to migrate to v3 yet.
125
+ useLegacySDK: false,
126
+
109
127
  // Options to the `load` API
110
128
  // Note: The above `controlPlaneUrl` overrides the `configUrl` field in this object
111
129
  // You can find all the available load options here,
@@ -118,7 +136,7 @@ plugins: [
118
136
  ];
119
137
  ```
120
138
 
121
- ## [](https://github.com/rudderlabs/gatsby-plugin-rudderstack/blob/master/README.md#step-2-identify-your-users-using-the-identify-method)Step 2: Identify Your Users With the `identify()` Method:
139
+ ### [Step 2: Identify Your Users With the `identify()` Method:](https://github.com/rudderlabs/gatsby-plugin-rudderstack/blob/master/README.md#step-2-identify-your-users-using-the-identify-method)
122
140
 
123
141
  The `identify()` method allows you to link users and their actions to a specific userid.
124
142
 
@@ -126,26 +144,31 @@ A sample example of how the `identify()` method works in Gatsby is as shown:
126
144
 
127
145
  ```javascript
128
146
  class CallToAction extends React.Component {
129
- _handleCallToAction() {
130
- window.rudderanalytics.identify(
131
- "12345", {
132
- email: "name@domain.com"
133
- }, {
134
- page: {
135
- path: "/post",
136
- referrer: "internal",
137
- search: "",
138
- title: "Post Page",
139
- url: "",
140
- },
141
- }
142
- }
143
-
144
- render() {
145
- return (
146
- <Link onClick={ this._handleCallToAction } to="/write-post">Write a Post</Link>
147
- )
148
- }
147
+ _handleCallToAction() {
148
+ window.rudderanalytics.identify(
149
+ '12345',
150
+ {
151
+ email: 'name@domain.com',
152
+ },
153
+ {
154
+ page: {
155
+ path: '/post',
156
+ referrer: 'internal',
157
+ search: '',
158
+ title: 'Post Page',
159
+ url: '',
160
+ },
161
+ },
162
+ );
163
+ }
164
+
165
+ render() {
166
+ return (
167
+ <Link onClick={this._handleCallToAction} to="/write-post">
168
+ Write a Post
169
+ </Link>
170
+ );
171
+ }
149
172
  }
150
173
  ```
151
174
 
@@ -153,7 +176,7 @@ In the above example, information such as the user ID, email along with contextu
153
176
 
154
177
  > **NOTE**: There is no need to call `identify()` for anonymous visitors to your website. Such visitors are automatically assigned an `anonymousId`.
155
178
 
156
- ## [](https://github.com/rudderlabs/rudder-sdk-js/blob/master/README.md#step-3-track-your-users-actions-using-the-track-method)Step 3: Track Your Users’ Actions With the `track()` Method
179
+ ### [Step 3: Track Your Users’ Actions With the `track()` Method](https://github.com/rudderlabs/rudder-sdk-js/blob/master/README.md#step-3-track-your-users-actions-using-the-track-method)
157
180
 
158
181
  The `track()` method allows you to track any actions that your users might perform.
159
182
 
@@ -161,15 +184,15 @@ A sample example of how the `track()` method works is as shown:
161
184
 
162
185
  ```javascript
163
186
  window.rudderanalytics.track(
164
- "test track event GA3",
187
+ 'test track event GA3',
165
188
  {
166
189
  revenue: 30,
167
- currency: "USD",
190
+ currency: 'USD',
168
191
  user_actual_id: 12345,
169
192
  },
170
193
  () => {
171
- console.log("in track call");
172
- }
194
+ console.log('in track call');
195
+ },
173
196
  );
174
197
  ```
175
198
 
@@ -181,19 +204,19 @@ You can use this method to track various other success metrics for your website,
181
204
 
182
205
  ```javascript
183
206
  window.rudderanalytics.track(
184
- "test track event GA3",
207
+ 'test track event GA3',
185
208
  {
186
209
  revenue: 30,
187
- currency: "USD",
210
+ currency: 'USD',
188
211
  user_actual_id: 12345,
189
212
  },
190
213
  () => {
191
- console.log("in track call");
192
- }
214
+ console.log('in track call');
215
+ },
193
216
  );
194
217
  ```
195
218
 
196
- ### Track Pageviews
219
+ #### Track Pageviews
197
220
 
198
221
  **If you want to track pageviews automatically,** set `trackPage` to `true` in your `gatsby-config.js` file. What we mean by _"automatically"_ is that whenever there is a route change, we leverage Gatsby's `onRouteUpdate` API in the `gatsby-browser.js` file ([link](https://www.gatsbyjs.org/docs/browser-apis/#onRouteUpdate)) to invoke `window.rudderanalytics.page()` on each route change. But if you want to pass in properties along with the pageview call (ie, it's common to see folks pass in some user or account data with each page call), then you'll have to set `trackPage: false` and call it yourself in your `gatsby-browser.js` file, like this:
199
222
 
@@ -208,7 +231,7 @@ Note: The above code snippet might not give the best results all the time as it
208
231
 
209
232
  You’ve now successfully installed `rudder-analytics.js` tracking. You can enable and use any event destination to send your event data via RudderStack, in no time at all!
210
233
 
211
- ## [](https://github.com/rudderlabs/rudder-sdk-js/blob/master/README.md#step-4-check-ready-state)Step 4: Check Ready State
234
+ ### [Step 4: Check Ready State](https://github.com/rudderlabs/rudder-sdk-js/blob/master/README.md#step-4-check-ready-state)
212
235
 
213
236
  **There are cases when you may want to tap into the features provide by end destination SDKs to enhance tracking and other functionalities.** RudderStack's JavaScript SDK exposes a `ready` API with a `callback` parameter, that fires when the SDK is done initializing itself and other third-party native SDK destinations.
214
237
 
@@ -216,29 +239,29 @@ For example:
216
239
 
217
240
  ```javascript
218
241
  window.rudderanalytics.ready(() => {
219
- console.log("we are all set!!!");
242
+ console.log('we are all set!!!');
220
243
  });
221
244
  ```
222
245
 
223
246
  | **For detailed technical documentation and troubleshooting guide on the RudderStack’s JavaScript SDK, check out our [docs](https://docs.rudderlabs.com/sdk-integration-guide/getting-started-with-javascript-sdk).** |
224
247
  | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
225
248
 
226
- # [](https://github.com/rudderlabs/rudder-sdk-js/blob/master/README.md#querystring-api)Querystring API
249
+ ## [Querystring API](https://github.com/rudderlabs/rudder-sdk-js/blob/master/README.md#querystring-api)
227
250
 
228
251
  RudderStack's Querystring API allows you to trigger `track`, `identify` calls using query parameters. If you pass the following parameters in the URL, then it will trigger the corresponding SDK API call.
229
252
 
230
253
  For example:
231
254
 
232
255
  ```html
233
- http://hostname.com/?ajs_uid=12345&ajs_event=test%20event&ajs_aid=abcde&ajs_prop_testProp=prop1&ajs_trait_name=Firstname+Lastname
256
+ https://hostname.com/?ajs_uid=12345&ajs_event=test%20event&ajs_aid=abcde&ajs_prop_testProp=prop1&ajs_trait_name=Firstname+Lastname
234
257
  ```
235
258
 
236
259
  For the above URL, the below SDK calls will be triggered:
237
260
 
238
261
  ```javascript
239
- rudderanalytics.identify("12345", { name: "Firstname Lastname" });
240
- rudderanalytics.track("test event", { testProp: "prop1" });
241
- rudderanalytics.setAnonymousId("abcde");
262
+ rudderanalytics.identify('12345', { name: 'Firstname Lastname' });
263
+ rudderanalytics.track('test event', { testProp: 'prop1' });
264
+ rudderanalytics.setAnonymousId('abcde');
242
265
  ```
243
266
 
244
267
  You may use the below parameters as querystring parameter and trigger the corresponding call.
@@ -253,7 +276,7 @@ You may use the below parameters as querystring parameter and trigger the corres
253
276
 
254
277
  `ajs_trait_<trait>` : If `ajs_uid` is provided as querysting, value of this parameter will populate the `traits` of the `identify` call made.
255
278
 
256
- # [](https://github.com/rudderlabs/rudder-sdk-js/blob/master/README.md#adding-callbacks-to-standard-methods)Adding Callbacks to Standard Methods
279
+ # [Adding Callbacks to Standard Methods](https://github.com/rudderlabs/rudder-sdk-js/blob/master/README.md#adding-callbacks-to-standard-methods)
257
280
 
258
281
  You can also define callbacks to the common methods of the `rudderanalytics` object.
259
282
 
@@ -264,9 +287,9 @@ For example, you can load the rudderanalytics with callbacks in your Gatsby brow
264
287
  ```javascript
265
288
  window.rudderanalytics.syncPixelCallback = (obj) => {
266
289
  window.rudderanalytics.track(
267
- "sync lotame",
290
+ 'sync lotame',
268
291
  { destination: obj.destination },
269
- { integrations: { All: false, S3: true } }
292
+ { integrations: { All: false, S3: true } },
270
293
  );
271
294
  };
272
295
  ```
@@ -282,21 +305,21 @@ The callback can be supplied in options parameter like below as well:
282
305
  rudderanalytics.load(YOUR_WRITE_KEY, DATA_PLANE_URL, {
283
306
  clientSuppliedCallbacks: {
284
307
  syncPixelCallback: () => {
285
- console.log("sync done!");
308
+ console.log('sync done!');
286
309
  },
287
310
  },
288
311
  });
289
312
  ```
290
313
 
291
- # License
314
+ ## License
292
315
 
293
316
  RudderStack **gatsby-plugin-rudderstack** is released under the [AGPLv3 License][agplv3_license].
294
317
 
295
- # Contribute
318
+ ## Contribute
296
319
 
297
320
  We would love to see you contribute to RudderStack. Get more information on how to contribute [here](CONTRIBUTING.md).
298
321
 
299
- # Follow Us
322
+ ## Follow Us
300
323
 
301
324
  - [RudderStack Blog][rudderstack-blog]
302
325
  - [Slack][slack]
@@ -308,10 +331,10 @@ We would love to see you contribute to RudderStack. Get more information on how
308
331
  - [HackerNews][hackernews]
309
332
  - [Product Hunt][producthunt]
310
333
 
311
- # :clap: Our Supporters
334
+ ## :clap: Our Supporters
312
335
 
313
- [![Stargazers repo roster for @rudderlabs/rudder-server](https://reporoster.com/stars/rudderlabs/gatsby-plugin-rudderstack)](https://github.com/rudderlabs/gatsby-plugin-rudderstack/stargazers)
314
- [![Forkers repo roster for @rudderlabs/rudder-server](https://reporoster.com/forks/rudderlabs/gatsby-plugin-rudderstack)](https://github.com/rudderlabs/gatsby-plugin-rudderstack/network/members)
336
+ [![Stargazers repo roster for @rudderlabs/gatsby-plugin-rudderstack](https://reporoster.com/stars/rudderlabs/gatsby-plugin-rudderstack)](https://github.com/rudderlabs/gatsby-plugin-rudderstack/stargazers)
337
+ [![Forkers repo roster for @rudderlabs/gatsby-plugin-rudderstack](https://reporoster.com/forks/rudderlabs/gatsby-plugin-rudderstack)](https://github.com/rudderlabs/gatsby-plugin-rudderstack/network/members)
315
338
 
316
339
  <!----variables---->
317
340
 
package/gatsby-ssr.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _jsxRuntime = require("react/jsx-runtime");
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
+ 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
+ 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); }
10
+ exports.onRenderBody = function (_ref, pluginOptions) {
11
+ var setHeadComponents = _ref.setHeadComponents;
12
+ var prodKey = pluginOptions.prodKey,
13
+ devKey = pluginOptions.devKey,
14
+ _pluginOptions$dataPl = pluginOptions.dataPlaneUrl,
15
+ dataPlaneUrl = _pluginOptions$dataPl === void 0 ? 'https://hosted.rudderlabs.com' : _pluginOptions$dataPl,
16
+ controlPlaneUrl = pluginOptions.controlPlaneUrl,
17
+ delayLoad = pluginOptions.delayLoad,
18
+ delayLoadTime = pluginOptions.delayLoadTime,
19
+ manualLoad = pluginOptions.manualLoad,
20
+ loadType = pluginOptions.loadType,
21
+ _pluginOptions$sdkURL = pluginOptions.sdkURL,
22
+ sdkURL = _pluginOptions$sdkURL === void 0 ? 'https://cdn.rudderlabs.com/v3' : _pluginOptions$sdkURL,
23
+ _pluginOptions$loadOp = pluginOptions.loadOptions,
24
+ loadOptions = _pluginOptions$loadOp === void 0 ? {} : _pluginOptions$loadOp,
25
+ useLegacySDK = pluginOptions.useLegacySDK;
26
+ if (!prodKey || prodKey.length < 10) console.error('Your RudderStack prodKey must be at least 10 char in length.');
27
+ if (devKey && devKey.length < 10) console.error('If present, your RudderStack devKey must be at least 10 char in length.');
28
+ var writeKey = process.env.NODE_ENV === 'production' ? prodKey : devKey;
29
+ var finalLoadOptions = _objectSpread(_objectSpread({}, loadOptions), {}, {
30
+ configUrl: controlPlaneUrl || loadOptions.configUrl
31
+ });
32
+ var loadConfig = "'".concat(writeKey, "', '").concat(dataPlaneUrl, "', ").concat(JSON.stringify(finalLoadOptions));
33
+ var snippet = "window.RudderSnippetVersion=\"3.0.0-beta.14\";var sdkBaseUrl=\"".concat(sdkURL, "\";var sdkName=\"rsa.min.js\";var asyncScript=true;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(){window.rudderanalytics.push([e].concat(Array.prototype.slice.call(arguments)))}}(t)}\n try{new Function('return import(\"\")'),window.rudderAnalyticsBuildType=\"modern\"}catch(a){}\n if(window.rudderAnalyticsMount=function(){\"undefined\"==typeof globalThis&&(Object.defineProperty(Object.prototype,\"__globalThis_magic__\",{get:function get(){return this},configurable:true}),__globalThis_magic__.globalThis=__globalThis_magic__,delete Object.prototype.__globalThis_magic__);\n var e=document.createElement(\"script\");e.src=\"\".concat(sdkBaseUrl,\"/\").concat(window.rudderAnalyticsBuildType,\"/\").concat(sdkName),e.async=asyncScript,document.head?document.head.appendChild(e):document.body.appendChild(e)},\"undefined\"==typeof Promise||\"undefined\"==typeof globalThis){\n var d=document.createElement(\"script\");d.src=\"https://polyfill.io/v3/polyfill.min.js?features=Symbol%2CPromise&callback=rudderAnalyticsMount\",d.async=asyncScript,document.head?document.head.appendChild(d):document.body.appendChild(d)}else{window.rudderAnalyticsMount()}\n ");
34
+ if (useLegacySDK) {
35
+ var scriptTagStr = "var s = document.createElement(\"script\");\n s.type = \"text/javascript\";\n s.src = \"".concat(sdkURL, "\";");
36
+ if (loadType === 'async') {
37
+ scriptTagStr += 's.async = true;';
38
+ } else if (loadType === 'defer') {
39
+ scriptTagStr += 's.defer = true;';
40
+ }
41
+ scriptTagStr += 'document.head.appendChild(s);';
42
+ snippet = "rudderanalytics=window.rudderanalytics=[];for(var methods=[\"load\",\"page\",\"track\",\"identify\",\"alias\",\"group\",\"ready\",\"reset\",\"getAnonymousId\",\"setAnonymousId\"],i=0;i<methods.length;i++){var method=methods[i];rudderanalytics[method]=function(a){return function(){rudderanalytics.push([a].concat(Array.prototype.slice.call(arguments)))}}(method)}\n ".concat(scriptTagStr);
43
+ }
44
+ var instantLoader = "".concat(snippet).concat(manualLoad ? "" : "window.rudderanalytics.load(".concat(loadConfig, ")"), ";");
45
+ 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 ");
46
+ var snippetToUse = "".concat(delayLoad && !manualLoad ? delayedLoader : instantLoader);
47
+ if (writeKey) {
48
+ var tags = [(0, _jsxRuntime.jsx)("script", {
49
+ dangerouslySetInnerHTML: {
50
+ __html: snippetToUse
51
+ }
52
+ }, "plugin-rudderstack")];
53
+ setHeadComponents(tags);
54
+ }
55
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-plugin-rudderstack",
3
- "version": "3.0.0-beta.0",
3
+ "version": "3.0.0",
4
4
  "description": "Event tracking with RudderStack in your Gatsby frontend.",
5
5
  "main": "gatsby-ssr.js",
6
6
  "scripts": {
@@ -40,31 +40,32 @@
40
40
  },
41
41
  "homepage": "https://github.com/rudderlabs/gatsby-plugin-rudderstack#readme",
42
42
  "devDependencies": {
43
- "@babel/cli": "^7.19.3",
44
- "@babel/core": "^7.20.2",
45
- "@babel/eslint-parser": "7.19.1",
46
- "@babel/plugin-proposal-object-rest-spread": "^7.20.2",
47
- "@babel/preset-env": "^7.20.2",
48
- "@babel/preset-react": "^7.18.6",
49
- "commitizen": "4.2.5",
50
- "commitlint": "17.3.0",
51
- "conventional-changelog-cli": "2.2.2",
43
+ "@babel/cli": "7.23.4",
44
+ "@babel/core": "7.23.5",
45
+ "@babel/eslint-parser": "7.23.3",
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",
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",
52
54
  "conventional-github-releaser": "3.1.5",
53
- "@commitlint/config-conventional": "17.3.0",
54
- "@digitalroute/cz-conventional-changelog-for-jira": "7.4.2",
55
- "eslint": "8.28.0",
55
+ "eslint": "8.55.0",
56
56
  "eslint-config-airbnb": "19.0.4",
57
57
  "eslint-config-airbnb-base": "15.0.0",
58
- "eslint-config-prettier": "8.5.0",
59
- "eslint-plugin-compat": "4.0.2",
60
- "eslint-plugin-import": "2.26.0",
61
- "eslint-plugin-sonarjs": "0.16.0",
62
- "eslint-plugin-unicorn": "45.0.0",
63
- "husky": "8.0.2",
64
- "jscpd": "3.5.1",
65
- "lint-staged": "13.0.4",
66
- "madge": "5.0.1",
67
- "prettier": "2.8.0",
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",
68
69
  "standard-version": "9.5.0"
69
70
  },
70
71
  "eslintConfig": {
@@ -87,6 +88,7 @@
87
88
  },
88
89
  "overrides": {
89
90
  "dot-prop": "5.3.0",
91
+ "http-cache-semantics": "4.1.1",
90
92
  "semver-regex": "3.1.4",
91
93
  "trim-newlines": "3.0.1"
92
94
  },
package/.eslintcache DELETED
@@ -1 +0,0 @@
1
- [{"/Volumes/sourcecode/gatsby-plugin-rudderstack/src/gatsby-ssr.js":"1"},{"size":4519,"mtime":1689958450990}]
package/.eslintignore DELETED
@@ -1,8 +0,0 @@
1
- .husky/
2
- dist/
3
- node_modules/
4
- reports/
5
- stats/
6
- *.json
7
- *.md
8
- *.d.ts
package/.eslintrc.json DELETED
@@ -1,41 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "es2020": true,
5
- "jest": true
6
- },
7
- "extends": ["airbnb-base", "plugin:sonarjs/recommended", "prettier", "plugin:compat/recommended"],
8
- "plugins": ["unicorn", "compat"],
9
- "parser": "@babel/eslint-parser",
10
- "globals": {},
11
- "parserOptions": {
12
- "ecmaVersion": 11,
13
- "sourceType": "module"
14
- },
15
- "rules": {
16
- "import/prefer-default-export": "off",
17
- "unicorn/filename-case": [
18
- "error",
19
- { "cases": { "camelCase": true, "pascalCase": true, "kebabCase": true } }
20
- ],
21
- "unicorn/no-instanceof-array": "error",
22
- "unicorn/no-static-only-class": "error",
23
- "unicorn/consistent-destructuring": "error",
24
- "unicorn/better-regex": "error",
25
- "unicorn/no-for-loop": "error",
26
- "unicorn/prefer-array-some": "error",
27
- "unicorn/explicit-length-check": "error",
28
- "unicorn/prefer-array-find": "error",
29
- "unicorn/no-lonely-if": "error",
30
- "unicorn/prefer-includes": "error",
31
- "unicorn/prefer-array-flat-map": "error",
32
- "unicorn/no-useless-spread": "error",
33
- "unicorn/no-useless-length-check": "error",
34
- "unicorn/prefer-export-from": "error",
35
- "sonarjs/prefer-immediate-return": "off",
36
- "sonarjs/no-nested-template-literals": "off",
37
- "sonarjs/max-switch-cases": "off",
38
- "sonarjs/cognitive-complexity": ["error", 40],
39
- "compat/compat": "warn"
40
- }
41
- }
@@ -1,39 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Create a report to help us improve
4
- title: "[ISSUE]"
5
- labels: bug
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Describe the issue**
11
- Enter a clear and concise description of what the bug/issue is.
12
-
13
- **To Reproduce**
14
- Mention the steps to reproduce the behavior that causes the bug/issue:
15
-
16
- 1. Go to '...'
17
- 2. Click on '....'
18
- 3. Scroll down to '....'
19
- 4. See error
20
-
21
- **Expected behavior**
22
- A clear and concise description of what you expected to happen.
23
-
24
- **Screenshots**
25
- If applicable, add screenshots to help explain your problem.
26
-
27
- **Desktop (please complete the following information):**
28
- - OS: [e.g. iOS]
29
- - Browser [e.g. chrome, safari]
30
- - Version [e.g. 22]
31
-
32
- **Smartphone (please complete the following information):**
33
- - Device: [e.g. iPhone6]
34
- - OS: [e.g. iOS8.1]
35
- - Browser [e.g. stock browser, safari]
36
- - Version [e.g. 22]
37
-
38
- **Additional context**
39
- Add any other context about the problem here.
@@ -1,20 +0,0 @@
1
- ---
2
- name: Feature Request
3
- about: Suggest an idea for this project
4
- title: "[ENHANCEMENT]"
5
- labels: enhancement
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Is your feature request related to a problem? Please describe.**
11
- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
-
13
- **Describe the solution you'd like**
14
- A clear and concise description of what you want to happen.
15
-
16
- **Describe alternatives you've considered**
17
- A clear and concise description of any alternative solutions or features you've considered.
18
-
19
- **Additional context**
20
- Add any other context or screenshots about the feature request here.
@@ -1,13 +0,0 @@
1
- **Fixes** # (*issue*)
2
-
3
- ## Type of change
4
- - [ ] Bug fix (non-breaking change which fixes an issue)
5
- - [ ] New feature (non-breaking change which adds functionality)
6
- - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
7
- - [ ] This change requires a documentation update
8
- ## Checklist:
9
- - [ ] My code follows the style guidelines of this project
10
- - [ ] I have performed a self-review of my own code
11
- - [ ] I have commented my code, particularly in hard-to-understand areas
12
- - [ ] I have added unit tests for the code
13
- - [ ] I have made corresponding changes to the documentation
@@ -1,36 +0,0 @@
1
- name: Build & Code Quality Checks
2
-
3
- on:
4
- pull_request:
5
- branches: ['main', 'develop']
6
- types: ['opened', 'reopened', 'synchronize']
7
-
8
- jobs:
9
- build:
10
- name: Build & Code Quality Checks
11
- runs-on: ubuntu-latest
12
-
13
- steps:
14
- - name: Checkout
15
- uses: actions/checkout@v3
16
-
17
- - name: Setup Node
18
- uses: actions/setup-node@v3
19
- with:
20
- node-version-file: '.nvmrc'
21
- cache: 'npm'
22
-
23
- - name: Install dependencies
24
- env:
25
- HUSKY: 0
26
- run: |
27
- npm ci
28
-
29
- - name: Execute quality checks
30
- run: |
31
- npm run check:circular
32
- npm run check:duplicates
33
-
34
- - name: Execute security checks
35
- run: |
36
- npm run check:security
@@ -1,17 +0,0 @@
1
- name: Check PR title
2
-
3
- on:
4
- pull_request:
5
- branches: ['main', 'develop']
6
- types: ['opened', 'reopened', 'edited', 'synchronize']
7
-
8
- jobs:
9
- check_pr_title:
10
- name: Check PR title
11
- runs-on: ubuntu-latest
12
- steps:
13
- - name: Checkout source branch
14
- uses: actions/checkout@v3
15
-
16
- - name: Check PR title
17
- uses: rudderlabs/github-action-check-pr-title@v1.0.7