@supernova-studio/client 1.4.20 → 1.4.21
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.d.mts +6234 -6232
- package/dist/index.d.ts +6234 -6232
- package/dist/index.js +94 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4972,6 +4972,98 @@ var PersonalAccessToken = z186.object({
|
|
|
4972
4972
|
expireAt: z186.coerce.date().optional()
|
|
4973
4973
|
});
|
|
4974
4974
|
|
|
4975
|
+
// src/api/conversion/analytics/page-visits-to-dto.ts
|
|
4976
|
+
function pageVisitsToDto(entries) {
|
|
4977
|
+
const result = [];
|
|
4978
|
+
const { userBasedEntries, sessionLessResults } = splitEntries(entries);
|
|
4979
|
+
result.push(...sessionLessResults);
|
|
4980
|
+
const userBasedPageVisitsGroupedByDate = groupBy(
|
|
4981
|
+
userBasedEntries,
|
|
4982
|
+
(entry) => getTimestampKey(entry.timestamp)
|
|
4983
|
+
// Need to group by date and hour.
|
|
4984
|
+
);
|
|
4985
|
+
for (const date of userBasedPageVisitsGroupedByDate.keys()) {
|
|
4986
|
+
const pageData = userBasedPageVisitsGroupedByDate.get(date);
|
|
4987
|
+
if (!pageData) {
|
|
4988
|
+
throw SupernovaException.shouldNotHappen();
|
|
4989
|
+
}
|
|
4990
|
+
const { visitsPerPage, sessionsPerPage } = aggregatePageVisitsAndSessions(pageData);
|
|
4991
|
+
const pageDataGroupedByPageId = groupBy(
|
|
4992
|
+
pageData,
|
|
4993
|
+
(entry) => entry.pagePersistentId
|
|
4994
|
+
);
|
|
4995
|
+
const pagePersistentIds = pageDataGroupedByPageId.keys();
|
|
4996
|
+
for (const id of pagePersistentIds) {
|
|
4997
|
+
const pageData2 = pageDataGroupedByPageId.get(id);
|
|
4998
|
+
if (!pageData2) {
|
|
4999
|
+
throw SupernovaException.shouldNotHappen();
|
|
5000
|
+
}
|
|
5001
|
+
const entry = pageData2[0];
|
|
5002
|
+
if (!entry) {
|
|
5003
|
+
throw SupernovaException.shouldNotHappen();
|
|
5004
|
+
}
|
|
5005
|
+
result.push({
|
|
5006
|
+
versionId: entry.versionId,
|
|
5007
|
+
pagePersistentId: entry.pagePersistentId,
|
|
5008
|
+
timestamp: entry.timestamp,
|
|
5009
|
+
visits: visitsPerPage.get(id) ?? 0,
|
|
5010
|
+
sessions: sessionsPerPage.get(id) ?? 0,
|
|
5011
|
+
locale: entry.locale
|
|
5012
|
+
});
|
|
5013
|
+
}
|
|
5014
|
+
}
|
|
5015
|
+
return result;
|
|
5016
|
+
}
|
|
5017
|
+
function getTimestampKey(timestamp) {
|
|
5018
|
+
const date = timestamp.toISOString().split("T")[0];
|
|
5019
|
+
const hour = timestamp.toISOString().split("T")[1].split(":")[0];
|
|
5020
|
+
return `${date}:${hour}`;
|
|
5021
|
+
}
|
|
5022
|
+
function aggregatePageVisitsAndSessions(pageData) {
|
|
5023
|
+
const visitsPerPage = /* @__PURE__ */ new Map();
|
|
5024
|
+
const sessionsPerPage = /* @__PURE__ */ new Map();
|
|
5025
|
+
const uniqueSessions = /* @__PURE__ */ new Set();
|
|
5026
|
+
for (const entry of pageData) {
|
|
5027
|
+
const pageId = entry.pagePersistentId;
|
|
5028
|
+
const visits = entry.visits;
|
|
5029
|
+
const currentSessionIdsLength = uniqueSessions.size;
|
|
5030
|
+
if (!entry.anonymousId) {
|
|
5031
|
+
throw SupernovaException.shouldNotHappen();
|
|
5032
|
+
}
|
|
5033
|
+
uniqueSessions.add(entry.anonymousId);
|
|
5034
|
+
const newSessionIdsLength = uniqueSessions.size;
|
|
5035
|
+
if (newSessionIdsLength > currentSessionIdsLength) {
|
|
5036
|
+
sessionsPerPage.set(pageId, (sessionsPerPage.get(pageId) ?? 0) + 1);
|
|
5037
|
+
}
|
|
5038
|
+
visitsPerPage.set(pageId, (visitsPerPage.get(pageId) ?? 0) + visits);
|
|
5039
|
+
}
|
|
5040
|
+
return {
|
|
5041
|
+
visitsPerPage,
|
|
5042
|
+
sessionsPerPage
|
|
5043
|
+
};
|
|
5044
|
+
}
|
|
5045
|
+
function splitEntries(entries) {
|
|
5046
|
+
const sessionLessResults = [];
|
|
5047
|
+
const dataCopy = [...entries];
|
|
5048
|
+
const userBasedEntries = dataCopy.filter((entry) => entry.anonymousId);
|
|
5049
|
+
for (const entry of dataCopy) {
|
|
5050
|
+
if (!entry.anonymousId) {
|
|
5051
|
+
sessionLessResults.push({
|
|
5052
|
+
versionId: entry.versionId,
|
|
5053
|
+
pagePersistentId: entry.pagePersistentId,
|
|
5054
|
+
timestamp: entry.timestamp,
|
|
5055
|
+
visits: entry.visits,
|
|
5056
|
+
sessions: 0,
|
|
5057
|
+
locale: entry.locale
|
|
5058
|
+
});
|
|
5059
|
+
}
|
|
5060
|
+
}
|
|
5061
|
+
return {
|
|
5062
|
+
userBasedEntries,
|
|
5063
|
+
sessionLessResults
|
|
5064
|
+
};
|
|
5065
|
+
}
|
|
5066
|
+
|
|
4975
5067
|
// src/api/conversion/documentation/documentation-item-configuration-v1-to-dto.ts
|
|
4976
5068
|
var getDtoDefaultItemConfigurationV1 = () => ({
|
|
4977
5069
|
showSidebar: true,
|
|
@@ -14724,6 +14816,7 @@ export {
|
|
|
14724
14816
|
pageToProsemirrorDoc,
|
|
14725
14817
|
pageToYDoc,
|
|
14726
14818
|
pageToYXmlFragment,
|
|
14819
|
+
pageVisitsToDto,
|
|
14727
14820
|
pipelineToDto,
|
|
14728
14821
|
prosemirrorDocToPage,
|
|
14729
14822
|
prosemirrorDocToRichTextPropertyValue,
|