Skip to content

feat: rudderstack analytics #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
(function () {
"use strict";
window.RudderSnippetVersion = "3.0.60";
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;
window.rudderAnalyticsBuildType = "legacy";
var sdkBaseUrl = "https://cdn.rudderlabs.com";
var sdkVersion = "v3";
var sdkFileName = "rsa.min.js";
var scriptLoadingMode = "async";
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 === undefined || _methodName.apply(window[identifier], arguments);
}
};
}(method);
}
try {
new Function('class Test{field=()=>{};test({prop=[]}={}){return prop?(prop?.property??[...prop]):import("");}}');
window.rudderAnalyticsBuildType = "modern";
} catch (e) {
}
var head = document.head || document.getElementsByTagName("head")[0];
var body = document.body || document.getElementsByTagName("body")[0];
window.rudderAnalyticsAddScript = function (url, extraAttributeKey, extraAttributeVal) {
var scriptTag = document.createElement("script");
scriptTag.src = url;
scriptTag.setAttribute("data-loader", "RS_JS_SDK");
if (extraAttributeKey && extraAttributeVal) {
scriptTag.setAttribute(extraAttributeKey, extraAttributeVal);
}
if (scriptLoadingMode === "async") {
scriptTag.async = true;
} else if (scriptLoadingMode === "defer") {
scriptTag.defer = true;
}
if (head) {
head.insertBefore(scriptTag, head.firstChild);
} else {
body.insertBefore(scriptTag, body.firstChild);
}
};
window.rudderAnalyticsMount = function () {
(function () {
if (typeof globalThis === "undefined") {
var getGlobal = function getGlobal() {
if (typeof self !== "undefined") {
return self;
}
if (typeof window !== "undefined") {
return window;
}
return null;
};
var global = getGlobal();
if (global) {
Object.defineProperty(global, "globalThis", {
value: global,
configurable: true
});
}
}
})();
window.rudderAnalyticsAddScript("".concat(sdkBaseUrl, "/").concat(sdkVersion, "/").concat(window.rudderAnalyticsBuildType, "/").concat(sdkFileName), "data-rsa-write-key", "1tLM5JN9u3GhRUidt5zjU0Uc5Qf");
};
if (typeof Promise === "undefined" || typeof globalThis === "undefined") {
window.rudderAnalyticsAddScript("https://polyfill-fastly.io/v3/polyfill.min.js?version=3.111.0&features=Symbol%2CPromise&callback=rudderAnalyticsMount");
} else {
window.rudderAnalyticsMount();
}
var loadOptions = {};
rudderanalytics.load("1tLM5JN9u3GhRUidt5zjU0Uc5Qf", "https://analytics.lightdash.com", loadOptions);
}
}

// Track page view
window.rudderanalytics.page();
})();