rivia 0.0.46 → 0.0.48
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/dist/index.js +93 -59
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -73,10 +73,10 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
73
73
|
visitedPages[it.event_name] = it.id;
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
|
-
let
|
|
76
|
+
let storedVisited2 = JSON.parse(
|
|
77
77
|
sessionStorage.getItem("onboardingVisited") || "[]"
|
|
78
78
|
);
|
|
79
|
-
if (!Array.isArray(
|
|
79
|
+
if (!Array.isArray(storedVisited2)) storedVisited2 = [];
|
|
80
80
|
let user_var1 = user_var;
|
|
81
81
|
if (!user_var1) {
|
|
82
82
|
user_var1 = "User_" + Math.random().toString(36).substring(2, 8);
|
|
@@ -91,16 +91,16 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
91
91
|
const data2 = await res.json();
|
|
92
92
|
let userData = data2[user_var1];
|
|
93
93
|
if (Array.isArray(userData)) {
|
|
94
|
-
|
|
94
|
+
storedVisited2 = userData;
|
|
95
95
|
} else if (typeof userData === "object" && userData !== null && Array.isArray(userData.completed_items)) {
|
|
96
|
-
|
|
96
|
+
storedVisited2 = userData.completed_items;
|
|
97
97
|
} else {
|
|
98
|
-
|
|
98
|
+
storedVisited2 = [];
|
|
99
99
|
}
|
|
100
100
|
let path;
|
|
101
101
|
return {
|
|
102
|
-
completedPages:
|
|
103
|
-
progress:
|
|
102
|
+
completedPages: storedVisited2,
|
|
103
|
+
progress: storedVisited2.length,
|
|
104
104
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
105
105
|
start_date: userData?.start_date || "",
|
|
106
106
|
end_date: userData?.end_date || userData?.end_data || ""
|
|
@@ -110,7 +110,7 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
110
110
|
"\u26A0\uFE0F Invalid checklist Id",
|
|
111
111
|
err
|
|
112
112
|
);
|
|
113
|
-
const
|
|
113
|
+
const storedVisited22 = [];
|
|
114
114
|
return {
|
|
115
115
|
completedPages: [],
|
|
116
116
|
progress: 0,
|
|
@@ -120,7 +120,7 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
storedVisited2 = sessionStorage.getItem("onboardingVisited");
|
|
124
124
|
async function getUserProgress22() {
|
|
125
125
|
const backendUrl2 = `https://demoapi.rivia.ai/clients/${checklist_id}/${user_var1}`;
|
|
126
126
|
try {
|
|
@@ -129,16 +129,16 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
129
129
|
const data2 = await res.json();
|
|
130
130
|
let userData = data2[user_var1];
|
|
131
131
|
if (Array.isArray(userData)) {
|
|
132
|
-
|
|
132
|
+
storedVisited2 = userData;
|
|
133
133
|
} else if (typeof userData === "object" && userData !== null && Array.isArray(userData.completed_items)) {
|
|
134
|
-
|
|
134
|
+
storedVisited2 = userData.completed_items;
|
|
135
135
|
} else {
|
|
136
|
-
|
|
136
|
+
storedVisited2 = [];
|
|
137
137
|
}
|
|
138
138
|
let path;
|
|
139
139
|
return {
|
|
140
|
-
completedPages:
|
|
141
|
-
progress:
|
|
140
|
+
completedPages: storedVisited2,
|
|
141
|
+
progress: storedVisited2.length,
|
|
142
142
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
143
143
|
start_date: userData?.start_date || "",
|
|
144
144
|
end_date: userData?.end_date || userData?.end_data || ""
|
|
@@ -157,9 +157,9 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
if (!
|
|
160
|
+
if (!storedVisited2 || storedVisited2 == "[]") {
|
|
161
161
|
getUserProgress22().then((progressData) => {
|
|
162
|
-
if (
|
|
162
|
+
if (storedVisited2 && storedVisited2.length >= checklistItems.length) {
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
165
|
sessionStorage.setItem(
|
|
@@ -177,7 +177,7 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
177
177
|
checklist_id,
|
|
178
178
|
cssConfig,
|
|
179
179
|
items,
|
|
180
|
-
|
|
180
|
+
storedVisited2,
|
|
181
181
|
backendUrl,
|
|
182
182
|
progressData,
|
|
183
183
|
visitedPages,
|
|
@@ -187,15 +187,15 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
187
187
|
});
|
|
188
188
|
} else {
|
|
189
189
|
try {
|
|
190
|
-
|
|
190
|
+
storedVisited2 = storedVisited2 ? JSON.parse(storedVisited2) : [];
|
|
191
191
|
} catch (e) {
|
|
192
192
|
console.warn(
|
|
193
193
|
"Invalid onboardingVisited data, resetting cache:",
|
|
194
|
-
|
|
194
|
+
storedVisited2
|
|
195
195
|
);
|
|
196
|
-
|
|
196
|
+
storedVisited2 = [];
|
|
197
197
|
}
|
|
198
|
-
if (
|
|
198
|
+
if (storedVisited2 && storedVisited2.length >= checklistItems.length) {
|
|
199
199
|
if (sessionStorage.getItem("CompletedAll") != "true") return;
|
|
200
200
|
const label = document.createElement("div");
|
|
201
201
|
label.id = "route-label";
|
|
@@ -237,7 +237,7 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
237
237
|
checklist_id,
|
|
238
238
|
cssConfig,
|
|
239
239
|
items,
|
|
240
|
-
|
|
240
|
+
storedVisited2,
|
|
241
241
|
backendUrl,
|
|
242
242
|
[],
|
|
243
243
|
visitedPages,
|
|
@@ -246,7 +246,7 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
|
|
|
246
246
|
);
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion = 0, checklistItems = [], cssText = [], targetingData = {}, user_var, checklist_id, cssConfig = {}, items = [],
|
|
249
|
+
async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion = 0, checklistItems = [], cssText = [], targetingData = {}, user_var, checklist_id, cssConfig = {}, items = [], storedVisited2 = [], backendUrl = "", progressData = {}, visitedPages = {}, cleanUrlItems = [], custom_css = "") {
|
|
250
250
|
console.log("inside fetchWithTimeout", user_var);
|
|
251
251
|
if (!user_var)
|
|
252
252
|
return;
|
|
@@ -561,7 +561,7 @@ transform: translateY(-20%);
|
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
createSlabs(items.length);
|
|
564
|
-
if (
|
|
564
|
+
if (storedVisited2) updateProgress(storedVisited2.length);
|
|
565
565
|
Object.assign(label.style, {
|
|
566
566
|
position: "fixed",
|
|
567
567
|
bottom: "80px",
|
|
@@ -702,9 +702,11 @@ transform: translateY(-20%);
|
|
|
702
702
|
window.updateUIFromVisited = updateUIFromVisited;
|
|
703
703
|
window.updateProgress = updateProgress;
|
|
704
704
|
window.updateProgress2 = updateProgress2;
|
|
705
|
-
window.storedVisited =
|
|
705
|
+
window.storedVisited = storedVisited2;
|
|
706
706
|
window.uploadVisitedPagesInBackground = uploadVisitedPagesInBackground;
|
|
707
707
|
window.items = items;
|
|
708
|
+
window.label = label;
|
|
709
|
+
window.showBtn = showBtn;
|
|
708
710
|
const closeBtn = document.createElement("button");
|
|
709
711
|
closeBtn.id = "tooltip-close-btn";
|
|
710
712
|
closeBtn.innerHTML = "\u2715";
|
|
@@ -749,7 +751,7 @@ transform: translateY(-20%);
|
|
|
749
751
|
return false;
|
|
750
752
|
}
|
|
751
753
|
visitedSet.add(cleanUrl);
|
|
752
|
-
|
|
754
|
+
storedVisited2 = [...visitedSet];
|
|
753
755
|
persistVisited();
|
|
754
756
|
try {
|
|
755
757
|
uploadVisitedPagesInBackground([...visitedSet], true);
|
|
@@ -788,7 +790,7 @@ transform: translateY(-20%);
|
|
|
788
790
|
check = 1;
|
|
789
791
|
const path = it.url || "";
|
|
790
792
|
const cleanUrl = path.startsWith("/") ? path.slice(1) : path;
|
|
791
|
-
if (
|
|
793
|
+
if (storedVisited2.length >= checklistItems.length) {
|
|
792
794
|
(() => {
|
|
793
795
|
if (label2 && label2.parentNode) label2.remove();
|
|
794
796
|
if (showBtn && showBtn.parentNode) showBtn.remove();
|
|
@@ -814,7 +816,7 @@ transform: translateY(-20%);
|
|
|
814
816
|
})();
|
|
815
817
|
}
|
|
816
818
|
handleVisit(cleanUrl, { source: "click" });
|
|
817
|
-
if (
|
|
819
|
+
if (storedVisited2.length >= checklistItems.length) {
|
|
818
820
|
(() => {
|
|
819
821
|
if (label && label.parentNode) label.remove();
|
|
820
822
|
if (showBtn && showBtn.parentNode) showBtn.remove();
|
|
@@ -884,12 +886,12 @@ transform: translateY(-20%);
|
|
|
884
886
|
}
|
|
885
887
|
let activeStepId = sessionStorage.getItem("activeStepId") || null;
|
|
886
888
|
function updateUIFromVisited() {
|
|
887
|
-
|
|
889
|
+
storedVisited2 = JSON.parse(
|
|
888
890
|
sessionStorage.getItem("onboardingVisited") || "[]"
|
|
889
891
|
);
|
|
890
892
|
let path;
|
|
891
|
-
|
|
892
|
-
if (!
|
|
893
|
+
storedVisited2 = sessionStorage.getItem("onboardingVisited");
|
|
894
|
+
if (!storedVisited2 || storedVisited2 == "[]") {
|
|
893
895
|
async function getUserProgress22() {
|
|
894
896
|
const backendUrl2 = `https://demoapi.rivia.ai/clients/${checklist_id}/${user_var}`;
|
|
895
897
|
try {
|
|
@@ -898,16 +900,16 @@ transform: translateY(-20%);
|
|
|
898
900
|
const data2 = await res.json();
|
|
899
901
|
let userData = data2[user_var];
|
|
900
902
|
if (Array.isArray(userData)) {
|
|
901
|
-
|
|
903
|
+
storedVisited2 = userData;
|
|
902
904
|
} else if (typeof userData === "object" && userData !== null && Array.isArray(userData.completed_items)) {
|
|
903
|
-
|
|
905
|
+
storedVisited2 = userData.completed_items;
|
|
904
906
|
} else {
|
|
905
|
-
|
|
907
|
+
storedVisited2 = [];
|
|
906
908
|
}
|
|
907
909
|
let path2;
|
|
908
910
|
return {
|
|
909
|
-
completedPages:
|
|
910
|
-
progress:
|
|
911
|
+
completedPages: storedVisited2,
|
|
912
|
+
progress: storedVisited2.length,
|
|
911
913
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
912
914
|
start_date: userData?.start_date || "",
|
|
913
915
|
end_date: userData?.end_date || userData?.end_data || ""
|
|
@@ -917,7 +919,7 @@ transform: translateY(-20%);
|
|
|
917
919
|
"\u26A0\uFE0F Invalid checklist Id",
|
|
918
920
|
err
|
|
919
921
|
);
|
|
920
|
-
const
|
|
922
|
+
const storedVisited22 = [];
|
|
921
923
|
return {
|
|
922
924
|
completedPages: [],
|
|
923
925
|
progress: 0,
|
|
@@ -981,12 +983,12 @@ transform: translateY(-20%);
|
|
|
981
983
|
if (btnFraction2) {
|
|
982
984
|
btnFraction2.textContent = `${completed2.length}/${items.length}`;
|
|
983
985
|
}
|
|
984
|
-
|
|
986
|
+
storedVisited2 = completed2;
|
|
985
987
|
updateProgress(completed2.length);
|
|
986
988
|
updateProgress2(completed2.length);
|
|
987
989
|
});
|
|
988
990
|
} else {
|
|
989
|
-
let completed2 =
|
|
991
|
+
let completed2 = storedVisited2;
|
|
990
992
|
if (completed2) {
|
|
991
993
|
try {
|
|
992
994
|
completed2 = JSON.parse(completed2);
|
|
@@ -1050,11 +1052,11 @@ transform: translateY(-20%);
|
|
|
1050
1052
|
if (btnFraction2) {
|
|
1051
1053
|
btnFraction2.textContent = `${completed2.length}/${items.length} `;
|
|
1052
1054
|
}
|
|
1053
|
-
|
|
1055
|
+
storedVisited2 = completed2;
|
|
1054
1056
|
updateProgress(completed2.length);
|
|
1055
1057
|
updateProgress2(completed2.length);
|
|
1056
1058
|
}
|
|
1057
|
-
let completed =
|
|
1059
|
+
let completed = storedVisited2;
|
|
1058
1060
|
}
|
|
1059
1061
|
if (completion == 0) {
|
|
1060
1062
|
items.forEach((it) => {
|
|
@@ -1074,10 +1076,10 @@ transform: translateY(-20%);
|
|
|
1074
1076
|
startSelect.style.display = "block";
|
|
1075
1077
|
activeStepId = it.id;
|
|
1076
1078
|
sessionStorage.setItem("activeStepId", activeStepId);
|
|
1077
|
-
|
|
1079
|
+
storedVisited2 = JSON.parse(
|
|
1078
1080
|
sessionStorage.getItem("onboardingVisited") || "[]"
|
|
1079
1081
|
);
|
|
1080
|
-
if (!
|
|
1082
|
+
if (!storedVisited2 || storedVisited2 == "[]") {
|
|
1081
1083
|
getUserProgress2().then((progressData2) => {
|
|
1082
1084
|
sessionStorage.setItem(
|
|
1083
1085
|
"onboardingVisited",
|
|
@@ -1085,26 +1087,26 @@ transform: translateY(-20%);
|
|
|
1085
1087
|
);
|
|
1086
1088
|
});
|
|
1087
1089
|
}
|
|
1088
|
-
|
|
1090
|
+
storedVisited2 = JSON.parse(
|
|
1089
1091
|
sessionStorage.getItem("onboardingVisited") || "[]"
|
|
1090
1092
|
);
|
|
1091
1093
|
let path = it.url;
|
|
1092
1094
|
let cleanUrl = path.startsWith("/") ? path.slice(1) : path;
|
|
1093
|
-
if (!
|
|
1094
|
-
|
|
1095
|
+
if (!storedVisited2.includes(cleanUrl) && cleanUrlItems.includes(cleanUrl)) {
|
|
1096
|
+
storedVisited2.push(cleanUrl);
|
|
1095
1097
|
sessionStorage.setItem(
|
|
1096
1098
|
"onboardingVisited",
|
|
1097
|
-
JSON.stringify(
|
|
1099
|
+
JSON.stringify(storedVisited2)
|
|
1098
1100
|
);
|
|
1099
1101
|
}
|
|
1100
|
-
if (
|
|
1102
|
+
if (storedVisited2.length >= checklistItems.length) {
|
|
1101
1103
|
sessionStorage.setItem("CompletedAll", "true");
|
|
1102
1104
|
}
|
|
1103
|
-
uploadVisitedPagesInBackground(
|
|
1104
|
-
updateProgress(
|
|
1105
|
-
updateProgress2(
|
|
1105
|
+
uploadVisitedPagesInBackground(storedVisited2, true);
|
|
1106
|
+
updateProgress(storedVisited2.length);
|
|
1107
|
+
updateProgress2(storedVisited2.length);
|
|
1106
1108
|
updateUIFromVisited();
|
|
1107
|
-
if (
|
|
1109
|
+
if (storedVisited2.length >= checklistItems.length) {
|
|
1108
1110
|
sessionStorage.setItem("CompletedAll", "true");
|
|
1109
1111
|
}
|
|
1110
1112
|
}
|
|
@@ -1141,18 +1143,18 @@ transform: translateY(-20%);
|
|
|
1141
1143
|
sessionStorage.setItem("activeStepId", activeStepId);
|
|
1142
1144
|
let path = it.url;
|
|
1143
1145
|
let cleanUrl = path.startsWith("/") ? path.slice(1) : path;
|
|
1144
|
-
if (!
|
|
1145
|
-
|
|
1146
|
+
if (!storedVisited2.includes(cleanUrl) && cleanUrlItems.includes(cleanUrl)) {
|
|
1147
|
+
storedVisited2.push(cleanUrl);
|
|
1146
1148
|
sessionStorage.setItem(
|
|
1147
1149
|
"onboardingVisited",
|
|
1148
|
-
JSON.stringify(
|
|
1150
|
+
JSON.stringify(storedVisited2)
|
|
1149
1151
|
);
|
|
1150
1152
|
}
|
|
1151
|
-
uploadVisitedPagesInBackground(
|
|
1152
|
-
updateProgress(
|
|
1153
|
-
updateProgress2(
|
|
1153
|
+
uploadVisitedPagesInBackground(storedVisited2, true);
|
|
1154
|
+
updateProgress(storedVisited2.length);
|
|
1155
|
+
updateProgress2(storedVisited2.length);
|
|
1154
1156
|
updateUIFromVisited();
|
|
1155
|
-
if (
|
|
1157
|
+
if (storedVisited2.length >= checklistItems.length) {
|
|
1156
1158
|
sessionStorage.setItem("CompletedAll", "true");
|
|
1157
1159
|
}
|
|
1158
1160
|
window.location.href = it.url;
|
|
@@ -4079,6 +4081,38 @@ var triggerEvent = async (message) => {
|
|
|
4079
4081
|
window.updateProgress2(window.storedVisited);
|
|
4080
4082
|
window.updateUIFromVisited();
|
|
4081
4083
|
window.uploadVisitedPagesInBackground(window.storedVisited);
|
|
4084
|
+
if (storedVisited.length === window.items.length) {
|
|
4085
|
+
window.showBtn.remove();
|
|
4086
|
+
window.label.remove();
|
|
4087
|
+
() => {
|
|
4088
|
+
const label2 = document.createElement("div");
|
|
4089
|
+
label2.id = "route-label";
|
|
4090
|
+
label2.innerText = "\u{1F389} Congrats! You've completed all items!";
|
|
4091
|
+
Object.assign(label2.style, {
|
|
4092
|
+
position: "fixed",
|
|
4093
|
+
bottom: "20px",
|
|
4094
|
+
left: "20px",
|
|
4095
|
+
backgroundColor: "#4CAF50",
|
|
4096
|
+
color: "white",
|
|
4097
|
+
padding: "10px 20px",
|
|
4098
|
+
borderRadius: "10px",
|
|
4099
|
+
boxShadow: "0 4px 6px rgba(0,0,0,0.2)",
|
|
4100
|
+
fontSize: "16px",
|
|
4101
|
+
fontWeight: "bold",
|
|
4102
|
+
zIndex: 9999,
|
|
4103
|
+
opacity: 0,
|
|
4104
|
+
transition: "opacity 0.5s ease"
|
|
4105
|
+
});
|
|
4106
|
+
document.body.appendChild(label2);
|
|
4107
|
+
requestAnimationFrame(() => {
|
|
4108
|
+
label2.style.opacity = 1;
|
|
4109
|
+
});
|
|
4110
|
+
setTimeout(() => {
|
|
4111
|
+
label2.style.opacity = 0;
|
|
4112
|
+
setTimeout(() => label2.remove(), 500);
|
|
4113
|
+
}, 3e3);
|
|
4114
|
+
};
|
|
4115
|
+
}
|
|
4082
4116
|
}
|
|
4083
4117
|
}
|
|
4084
4118
|
} catch (error) {
|