Skip to content

Commit

Permalink
Merge branch 'chore.clean-up' of github.com:rudderlabs/rudder-sdk-js …
Browse files Browse the repository at this point in the history
…into chore.clean-up
  • Loading branch information
ItsSudip committed Jun 7, 2024
2 parents 1bee16d + f61a200 commit 3946f3f
Show file tree
Hide file tree
Showing 36 changed files with 1,724 additions and 1,522 deletions.
42 changes: 31 additions & 11 deletions examples/angular/sample-app/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,37 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script>
window.RudderSnippetVersion = "3.0.4";
window.rudderanalytics = [];
var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
window.rudderanalytics[method] = function(methodName) {
return function() {
window.rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
};
}(method);
}
(function() {
"use strict";
window.RudderSnippetVersion = "3.0.9";
var identifier = "rudderanalytics";
if (!window[identifier]) {
window[identifier] = [];
}
var rudderanalytics = window[identifier];
if (Array.isArray(rudderanalytics)) {
if (rudderanalytics.snippetExecuted === true && window.console && console.error) {
console.error("RudderStack JavaScript SDK snippet included more than once.");
} else {
rudderanalytics.snippetExecuted = true;

var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
rudderanalytics[method] = function(methodName) {
return function() {
if (Array.isArray(window[identifier])) {
rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
} else {
var _methodName;
(_methodName = window[identifier][methodName]) === null || _methodName === void 0 || _methodName.apply(window[identifier], arguments);
}
};
}(method);
}
}
}
})();
// Below line is only for demonstration purpose, SPA code is better place for auto page call
window.rudderanalytics.page('sample page call');
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,27 @@
-->
<title>React App</title>
<script type="text/javascript">
!function(){"use strict";var sdkBaseUrl="https://cdn.rudderlabs.com/v3";var sdkName="rsa.min.js";var asyncScript=true
;window.rudderAnalyticsBuildType="legacy",window.rudderanalytics=[]
;var e=["setDefaultInstanceKey","load","ready","page","track","identify","alias","group","reset","setAnonymousId","startSession","endSession"]
;for(var t=0;t<e.length;t++){var n=e[t];window.rudderanalytics[n]=function(e){return function(){
window.rudderanalytics.push([e].concat(Array.prototype.slice.call(arguments)))}}(n)}try{
new Function('return import("")'),window.rudderAnalyticsBuildType="modern"}catch(a){}
if(window.rudderAnalyticsMount=function(){
!function(){"use strict";window.RudderSnippetVersion="3.0.9";var e="rudderanalytics";window[e]||(window[e]=[])
;var t=window[e];if(Array.isArray(t)){if(true===t.snippetExecuted&&window.console&&console.error){
console.error("RudderStack JavaScript SDK snippet included more than once.")}else{t.snippetExecuted=true,
window.rudderAnalyticsBuildType="legacy";var sdkBaseUrl="https://cdn.rudderlabs.com/v3";var sdkName="rsa.min.js"
;var r="async"
;var n=["setDefaultInstanceKey","load","ready","page","track","identify","alias","group","reset","setAnonymousId","startSession","endSession","consent"]
;for(var i=0;i<n.length;i++){var d=n[i];t[d]=function(r){return function(){var n
;Array.isArray(window[e])?t.push([r].concat(Array.prototype.slice.call(arguments))):null===(n=window[e][r])||void 0===n||n.apply(window[e],arguments)
}}(d)}try{new Function('return import("")'),window.rudderAnalyticsBuildType="modern"}catch(c){}
var o=document.head||document.getElementsByTagName("head")[0]
;var a=document.body||document.getElementsByTagName("body")[0];window.rudderAnalyticsAddScript=function(e,t,n){
var i=document.createElement("script");i.src=e,i.setAttribute("data-loader","RS_JS_SDK"),t&&n&&i.setAttribute(t,n),
"async"===r?i.async=true:"defer"===r&&(i.defer=true),o?o.insertBefore(i,o.firstChild):a.insertBefore(i,a.firstChild)},
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__);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){var d=document.createElement("script")
;d.src="https://polyfill.io/v3/polyfill.min.js?version=3.111.0&features=Symbol%2CPromise&callback=rudderAnalyticsMount",
d.async=asyncScript,document.head?document.head.appendChild(d):document.body.appendChild(d)}else{
window.rudderAnalyticsMount()}}();
delete Object.prototype.__globalThis_magic__),
window.rudderAnalyticsAddScript("".concat(sdkBaseUrl,"/").concat(window.rudderAnalyticsBuildType,"/").concat(sdkName),"data-rsa-write-key","dummyWriteKey")
},
"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()
;}}}();
</script>
</head>
<body>
Expand Down
44 changes: 32 additions & 12 deletions examples/nextjs/hooks/sample-app/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,40 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<head>
<Script id='bufferEvents'>
{`
window.RudderSnippetVersion = '3.0.4';
window.rudderanalytics = [];
var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
window.rudderanalytics[method] = function(methodName) {
return function() {
window.rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
};
}(method);
}
(function() {
"use strict";
window.RudderSnippetVersion = "3.0.9";
var identifier = "rudderanalytics";
if (!window[identifier]) {
window[identifier] = [];
}
var rudderanalytics = window[identifier];
if (Array.isArray(rudderanalytics)) {
if (rudderanalytics.snippetExecuted === true && window.console && console.error) {
console.error("RudderStack JavaScript SDK snippet included more than once.");
} else {
rudderanalytics.snippetExecuted = true;
var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
rudderanalytics[method] = function(methodName) {
return function() {
if (Array.isArray(window[identifier])) {
rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
} else {
var _methodName;
(_methodName = window[identifier][methodName]) === null || _methodName === void 0 || _methodName.apply(window[identifier], arguments);
}
};
}(method);
}
}
}
})();
// Below line is only for demonstration purpose, SPA code is better place for auto page call
window.rudderanalytics.page('sample page call');
`}
`}
</Script>
</head>
<body className={inter.className}>{children}</body>
Expand Down
44 changes: 32 additions & 12 deletions examples/nextjs/js/sample-app/src/app/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,40 @@ export default function RootLayout({ children }) {
<head>
<Script id='bufferEvents'>
{`
window.RudderSnippetVersion = '3.0.4';
window.rudderanalytics = [];
var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
window.rudderanalytics[method] = function(methodName) {
return function() {
window.rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
};
}(method);
}
(function() {
"use strict";
window.RudderSnippetVersion = "3.0.9";
var identifier = "rudderanalytics";
if (!window[identifier]) {
window[identifier] = [];
}
var rudderanalytics = window[identifier];
if (Array.isArray(rudderanalytics)) {
if (rudderanalytics.snippetExecuted === true && window.console && console.error) {
console.error("RudderStack JavaScript SDK snippet included more than once.");
} else {
rudderanalytics.snippetExecuted = true;
var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
rudderanalytics[method] = function(methodName) {
return function() {
if (Array.isArray(window[identifier])) {
rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
} else {
var _methodName;
(_methodName = window[identifier][methodName]) === null || _methodName === void 0 || _methodName.apply(window[identifier], arguments);
}
};
}(method);
}
}
}
})();
// Below line is only for demonstration purpose, SPA code is better place for auto page call
window.rudderanalytics.page('sample page call');
`}
`}
</Script>
</head>
<body className={inter.className}>{children}</body>
Expand Down
44 changes: 32 additions & 12 deletions examples/nextjs/page-router/sample-app/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,40 @@ export default function Document() {
<Head>
<Script id='bufferEvents' strategy='beforeInteractive'>
{`
window.RudderSnippetVersion = '3.0.4';
window.rudderanalytics = [];
var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
window.rudderanalytics[method] = function(methodName) {
return function() {
window.rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
};
}(method);
}
(function() {
"use strict";
window.RudderSnippetVersion = "3.0.9";
var identifier = "rudderanalytics";
if (!window[identifier]) {
window[identifier] = [];
}
var rudderanalytics = window[identifier];
if (Array.isArray(rudderanalytics)) {
if (rudderanalytics.snippetExecuted === true && window.console && console.error) {
console.error("RudderStack JavaScript SDK snippet included more than once.");
} else {
rudderanalytics.snippetExecuted = true;
var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
rudderanalytics[method] = function(methodName) {
return function() {
if (Array.isArray(window[identifier])) {
rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
} else {
var _methodName;
(_methodName = window[identifier][methodName]) === null || _methodName === void 0 || _methodName.apply(window[identifier], arguments);
}
};
}(method);
}
}
}
})();
// Below line is only for demonstration purpose, SPA code is better place for auto page call
window.rudderanalytics.page('sample page call');
`}
`}
</Script>
</Head>
<body>
Expand Down
58 changes: 32 additions & 26 deletions examples/nextjs/ts/sample-app/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,40 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<head>
<Script id='bufferEvents'>
{`
window.RudderSnippetVersion = '3.0.1';
window.rudderanalytics = [];
var methods = [
'setDefaultInstanceKey',
'load',
'ready',
'page',
'track',
'identify',
'alias',
'group',
'reset',
'setAnonymousId',
'startSession',
'endSession',
'consent'
];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
window.rudderanalytics[method] = (function (methodName) {
return function () {
window.rudderanalytics.push([methodName].concat(Array.prototype.slice.call(arguments)));
};
})(method);
}
(function() {
"use strict";
window.RudderSnippetVersion = "3.0.9";
var identifier = "rudderanalytics";
if (!window[identifier]) {
window[identifier] = [];
}
var rudderanalytics = window[identifier];
if (Array.isArray(rudderanalytics)) {
if (rudderanalytics.snippetExecuted === true && window.console && console.error) {
console.error("RudderStack JavaScript SDK snippet included more than once.");
} else {
rudderanalytics.snippetExecuted = true;
var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
rudderanalytics[method] = function(methodName) {
return function() {
if (Array.isArray(window[identifier])) {
rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
} else {
var _methodName;
(_methodName = window[identifier][methodName]) === null || _methodName === void 0 || _methodName.apply(window[identifier], arguments);
}
};
}(method);
}
}
}
})();
// Below line is only for demonstration purpose, SPA code is better place for auto page call
window.rudderanalytics.page('sample page call');
`}
`}
</Script>
</head>
<body className={inter.className}>{children}</body>
Expand Down
43 changes: 31 additions & 12 deletions examples/reactjs/hooks/sample-app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,37 @@
-->
<title>React App</title>
<script>
window.RudderSnippetVersion = "3.0.4";
window.rudderanalytics = [];

var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
window.rudderanalytics[method] = function(methodName) {
return function() {
window.rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
};
}(method);
}
(function() {
"use strict";
window.RudderSnippetVersion = "3.0.9";
var identifier = "rudderanalytics";
if (!window[identifier]) {
window[identifier] = [];
}
var rudderanalytics = window[identifier];
if (Array.isArray(rudderanalytics)) {
if (rudderanalytics.snippetExecuted === true && window.console && console.error) {
console.error("RudderStack JavaScript SDK snippet included more than once.");
} else {
rudderanalytics.snippetExecuted = true;

var methods = [ "setDefaultInstanceKey", "load", "ready", "page", "track", "identify", "alias", "group", "reset", "setAnonymousId", "startSession", "endSession", "consent" ];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
rudderanalytics[method] = function(methodName) {
return function() {
if (Array.isArray(window[identifier])) {
rudderanalytics.push([ methodName ].concat(Array.prototype.slice.call(arguments)));
} else {
var _methodName;
(_methodName = window[identifier][methodName]) === null || _methodName === void 0 || _methodName.apply(window[identifier], arguments);
}
};
}(method);
}
}
}
})();
// Below line is only for demonstration purpose, SPA code is better place for auto page call
window.rudderanalytics.page('sample page call');
</script>
Expand Down
Loading

0 comments on commit 3946f3f

Please sign in to comment.