Skip to content

Commit

Permalink
Merge pull request #60 from shrouti1507/new-updated-sanity
Browse files Browse the repository at this point in the history
New updated sanity
  • Loading branch information
shrouti1507 authored Aug 8, 2023
2 parents 5378517 + 7302822 commit 4237f21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 42 deletions.
25 changes: 19 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// main.js
import {
updateRudderAnalytics,
cacheValues,
Expand All @@ -7,6 +8,7 @@ import {
handlePageScenario,
handleGroupScenario,
handleAliasScenario,
updateFunctionBodies
} from './util.js';

window.updateRudderAnalytics = () => {
Expand All @@ -21,27 +23,38 @@ document.addEventListener("DOMContentLoaded", function () {
});

// Add event listeners to the select elements
document.getElementById("identify").addEventListener("change", function () {
handleIdentifyScenario();
});

document.getElementById("track").addEventListener("change", function () {
const selectedScenario = document.getElementById("track").value;
handleTrackScenario();
updateFunctionBodies("track", selectedScenario);
});

document.getElementById("identify").addEventListener("change", function () {
const selectedScenario = document.getElementById("identify").value;
handleIdentifyScenario();
updateFunctionBodies("identify", selectedScenario);
});

document.getElementById("page").addEventListener("change", function () {
const selectedScenario = document.getElementById("page").value;
handlePageScenario();
updateFunctionBodies("page", selectedScenario);
});

document.getElementById("group").addEventListener("change", function () {
const selectedScenario = document.getElementById("group").value;
handleGroupScenario();
updateFunctionBodies("group", selectedScenario);
});

document.getElementById("alias").addEventListener("change", function () {
const selectedScenario = document.getElementById("alias").value;
handleAliasScenario();
updateFunctionBodies("alias", selectedScenario);
});

document.getElementById("ecommerce").addEventListener("change", function () {
handleScenarioSelection();
const selectedScenario = document.getElementById("ecommerce").value;
handlePageScenario();
updateFunctionBodies("ecommerce", selectedScenario);
});

37 changes: 1 addition & 36 deletions util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// util.js
// This file contains the functions to handle the CDN URL selection, update the RudderAnalytics object and cache the entered values

import {
Expand Down Expand Up @@ -382,42 +383,6 @@ export function updateFunctionBodies(eventType, scenario) {
functionBodiesDiv.innerText = functionBodyText;
}

// Add event listeners for all event type dropdowns
document.getElementById("track").addEventListener("change", function () {
const selectedScenario = document.getElementById("track").value;
handleTrackScenario();
updateFunctionBodies("track", selectedScenario);
});

document.getElementById("identify").addEventListener("change", function () {
const selectedScenario = document.getElementById("identify").value;
handleIdentifyScenario();
updateFunctionBodies("identify", selectedScenario);
});

document.getElementById("page").addEventListener("change", function () {
const selectedScenario = document.getElementById("page").value;
handlePageScenario();
updateFunctionBodies("page", selectedScenario);
});

document.getElementById("group").addEventListener("change", function () {
const selectedScenario = document.getElementById("group").value;
handleGroupScenario();
updateFunctionBodies("group", selectedScenario);
});

document.getElementById("alias").addEventListener("change", function () {
const selectedScenario = document.getElementById("alias").value;
handleAliasScenario();
updateFunctionBodies("alias", selectedScenario);
});

document.getElementById("ecommerce").addEventListener("change", function () {
const selectedScenario = document.getElementById("ecommerce").value;
handlePageScenario();
updateFunctionBodies("ecommerce", selectedScenario);
});



0 comments on commit 4237f21

Please sign in to comment.