Skip to content

Commit

Permalink
Rollback newly introduced API methods (unnecessary)
Browse files Browse the repository at this point in the history
  • Loading branch information
benvinegar committed Dec 28, 2024
1 parent 1754cf2 commit df018d7
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/reporter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,15 @@ const config: ConfigType = {};

const commands = {
set: set,
reportPageview: reportPageview,
trackPageview: reportPageview, // backwards compat
setReporterUrl: setReporterUrl,
setTrackerUrl: setReporterUrl, // backwards compat
trackPageview: trackPageview, // backwards compat
setTrackerUrl: setTrackerUrl, // backwards compat
};

function set<K extends keyof ConfigType>(key: K, value: ConfigType[K]) {
config[key] = value;
}

function setReporterUrl(value: string) {
function setTrackerUrl(value: string) {
return set("reporterUrl", value);
}

Expand All @@ -79,7 +77,7 @@ function findReporterScript() {
return el;
}

function reportPageview(vars: { [key: string]: string }) {
function trackPageview(vars: { [key: string]: string }) {
vars = vars || {};

// ignore prerendered pages
Expand All @@ -93,7 +91,7 @@ function reportPageview(vars: { [key: string]: string }) {
// if <body> did not load yet, try again at dom ready event
if (document.body === null) {
document.addEventListener("DOMContentLoaded", () => {
reportPageview(vars);
trackPageview(vars);
});
return;
}
Expand Down Expand Up @@ -203,6 +201,6 @@ queue.forEach(function (cmd: Command) {
const siteId = script.getAttribute("data-site-id");
if (siteId) {
set("siteId", siteId);
reportPageview({});
trackPageview({});
}
})();

0 comments on commit df018d7

Please sign in to comment.