gatsby-plugin-rudderstack 3.0.0-beta.1 → 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.
- package/CHANGELOG.md +11 -0
- package/README.md +81 -58
- package/gatsby-ssr.js +20 -25
- package/package.json +25 -23
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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
|
+
## [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
|
+
|
|
5
16
|
## 2.0.0 (2022-12-14)
|
|
6
17
|
|
|
7
18
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<p align="center"
|
|
4
|
-
<
|
|
1
|
+
## [](https://github.com/rudderlabs/gatsby-plugin-rudderstack/releases) [](https://sonarcloud.io/summary/new_code?id=rudderlabs_gatsby-plugin-rudderstack) [](https://sonarcloud.io/summary/new_code?id=rudderlabs_gatsby-plugin-rudderstack) [](https://sonarcloud.io/summary/new_code?id=rudderlabs_gatsby-plugin-rudderstack) [](https://sonarcloud.io/summary/new_code?id=rudderlabs_gatsby-plugin-rudderstack) [](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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
41
|
+
## [Setup](https://github.com/rudderlabs/gatsby-plugin-rudderstack/blob/master/README.md#setup)
|
|
28
42
|
|
|
29
|
-
|
|
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/
|
|
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
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
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
|
-
|
|
187
|
+
'test track event GA3',
|
|
165
188
|
{
|
|
166
189
|
revenue: 30,
|
|
167
|
-
currency:
|
|
190
|
+
currency: 'USD',
|
|
168
191
|
user_actual_id: 12345,
|
|
169
192
|
},
|
|
170
193
|
() => {
|
|
171
|
-
console.log(
|
|
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
|
-
|
|
207
|
+
'test track event GA3',
|
|
185
208
|
{
|
|
186
209
|
revenue: 30,
|
|
187
|
-
currency:
|
|
210
|
+
currency: 'USD',
|
|
188
211
|
user_actual_id: 12345,
|
|
189
212
|
},
|
|
190
213
|
() => {
|
|
191
|
-
console.log(
|
|
192
|
-
}
|
|
214
|
+
console.log('in track call');
|
|
215
|
+
},
|
|
193
216
|
);
|
|
194
217
|
```
|
|
195
218
|
|
|
196
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
240
|
-
rudderanalytics.track(
|
|
241
|
-
rudderanalytics.setAnonymousId(
|
|
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)
|
|
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
|
-
|
|
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(
|
|
308
|
+
console.log('sync done!');
|
|
286
309
|
},
|
|
287
310
|
},
|
|
288
311
|
});
|
|
289
312
|
```
|
|
290
313
|
|
|
291
|
-
|
|
314
|
+
## License
|
|
292
315
|
|
|
293
316
|
RudderStack **gatsby-plugin-rudderstack** is released under the [AGPLv3 License][agplv3_license].
|
|
294
317
|
|
|
295
|
-
|
|
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
|
-
|
|
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
|
-
|
|
334
|
+
## :clap: Our Supporters
|
|
312
335
|
|
|
313
|
-
[](https://github.com/rudderlabs/gatsby-plugin-rudderstack/stargazers)
|
|
337
|
+
[](https://github.com/rudderlabs/gatsby-plugin-rudderstack/network/members)
|
|
315
338
|
|
|
316
339
|
<!----variables---->
|
|
317
340
|
|
package/gatsby-ssr.js
CHANGED
|
@@ -1,60 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
function ownKeys(
|
|
6
|
-
function _objectSpread(
|
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
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); }
|
|
8
10
|
exports.onRenderBody = function (_ref, pluginOptions) {
|
|
9
11
|
var setHeadComponents = _ref.setHeadComponents;
|
|
10
12
|
var prodKey = pluginOptions.prodKey,
|
|
11
13
|
devKey = pluginOptions.devKey,
|
|
12
14
|
_pluginOptions$dataPl = pluginOptions.dataPlaneUrl,
|
|
13
|
-
dataPlaneUrl = _pluginOptions$dataPl === void 0 ?
|
|
15
|
+
dataPlaneUrl = _pluginOptions$dataPl === void 0 ? 'https://hosted.rudderlabs.com' : _pluginOptions$dataPl,
|
|
14
16
|
controlPlaneUrl = pluginOptions.controlPlaneUrl,
|
|
15
17
|
delayLoad = pluginOptions.delayLoad,
|
|
16
18
|
delayLoadTime = pluginOptions.delayLoadTime,
|
|
17
19
|
manualLoad = pluginOptions.manualLoad,
|
|
18
20
|
loadType = pluginOptions.loadType,
|
|
19
21
|
_pluginOptions$sdkURL = pluginOptions.sdkURL,
|
|
20
|
-
sdkURL = _pluginOptions$sdkURL === void 0 ?
|
|
22
|
+
sdkURL = _pluginOptions$sdkURL === void 0 ? 'https://cdn.rudderlabs.com/v3' : _pluginOptions$sdkURL,
|
|
21
23
|
_pluginOptions$loadOp = pluginOptions.loadOptions,
|
|
22
24
|
loadOptions = _pluginOptions$loadOp === void 0 ? {} : _pluginOptions$loadOp,
|
|
23
25
|
useLegacySDK = pluginOptions.useLegacySDK;
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
if (devKey && devKey.length < 10) console.error("If present, your RudderStack devKey must be at least 10 char in length.");
|
|
28
|
-
|
|
29
|
-
var writeKey = process.env.NODE_ENV === "production" ? prodKey : devKey;
|
|
30
|
-
|
|
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;
|
|
31
29
|
var finalLoadOptions = _objectSpread(_objectSpread({}, loadOptions), {}, {
|
|
32
30
|
configUrl: controlPlaneUrl || loadOptions.configUrl
|
|
33
31
|
});
|
|
34
32
|
var loadConfig = "'".concat(writeKey, "', '").concat(dataPlaneUrl, "', ").concat(JSON.stringify(finalLoadOptions));
|
|
35
|
-
var snippet = "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\",\"
|
|
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 ");
|
|
36
34
|
if (useLegacySDK) {
|
|
37
35
|
var scriptTagStr = "var s = document.createElement(\"script\");\n s.type = \"text/javascript\";\n s.src = \"".concat(sdkURL, "\";");
|
|
38
|
-
if (loadType ===
|
|
39
|
-
scriptTagStr +=
|
|
40
|
-
} else if (loadType ===
|
|
41
|
-
scriptTagStr +=
|
|
36
|
+
if (loadType === 'async') {
|
|
37
|
+
scriptTagStr += 's.async = true;';
|
|
38
|
+
} else if (loadType === 'defer') {
|
|
39
|
+
scriptTagStr += 's.defer = true;';
|
|
42
40
|
}
|
|
43
|
-
scriptTagStr +=
|
|
41
|
+
scriptTagStr += 'document.head.appendChild(s);';
|
|
44
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);
|
|
45
43
|
}
|
|
46
44
|
var instantLoader = "".concat(snippet).concat(manualLoad ? "" : "window.rudderanalytics.load(".concat(loadConfig, ")"), ";");
|
|
47
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 ");
|
|
48
|
-
|
|
49
46
|
var snippetToUse = "".concat(delayLoad && !manualLoad ? delayedLoader : instantLoader);
|
|
50
|
-
|
|
51
47
|
if (writeKey) {
|
|
52
|
-
var tags = [
|
|
53
|
-
key: "plugin-rudderstack",
|
|
48
|
+
var tags = [(0, _jsxRuntime.jsx)("script", {
|
|
54
49
|
dangerouslySetInnerHTML: {
|
|
55
50
|
__html: snippetToUse
|
|
56
51
|
}
|
|
57
|
-
})];
|
|
52
|
+
}, "plugin-rudderstack")];
|
|
58
53
|
setHeadComponents(tags);
|
|
59
54
|
}
|
|
60
55
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-plugin-rudderstack",
|
|
3
|
-
"version": "3.0.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": "
|
|
44
|
-
"@babel/core": "
|
|
45
|
-
"@babel/eslint-parser": "7.
|
|
46
|
-
"@babel/plugin-proposal-object-rest-spread": "
|
|
47
|
-
"@babel/preset-env": "
|
|
48
|
-
"@babel/preset-react": "
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
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
|
-
"
|
|
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": "
|
|
59
|
-
"eslint-plugin-compat": "4.0
|
|
60
|
-
"eslint-plugin-import": "2.
|
|
61
|
-
"eslint-plugin-sonarjs": "0.
|
|
62
|
-
"eslint-plugin-unicorn": "
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
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
|
},
|