lytx 0.3.0
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/.env.example +37 -0
- package/README.md +486 -0
- package/alchemy.run.ts +155 -0
- package/cli/bootstrap-admin.ts +284 -0
- package/cli/deploy-staging.ts +692 -0
- package/cli/import-events.ts +628 -0
- package/cli/import-sites.ts +518 -0
- package/cli/index.ts +609 -0
- package/cli/init-db.ts +269 -0
- package/cli/migrate-to-durable-objects.ts +564 -0
- package/cli/migration-worker.ts +300 -0
- package/cli/performance-test.ts +588 -0
- package/cli/pg/client.ts +4 -0
- package/cli/pg/new-site.ts +153 -0
- package/cli/rollback-durable-objects.ts +622 -0
- package/cli/seed-data.ts +459 -0
- package/cli/setup.js +18 -0
- package/cli/setup.ts +463 -0
- package/cli/validate-migration.ts +200 -0
- package/cli/wrangler-migration.jsonc +28 -0
- package/db/adapter.ts +166 -0
- package/db/analytics_engine/client.ts +0 -0
- package/db/analytics_engine/sites.ts +0 -0
- package/db/client.ts +16 -0
- package/db/d1/client.ts +8 -0
- package/db/d1/drizzle.config.ts +35 -0
- package/db/d1/migrations/0000_true_maelstrom.sql +165 -0
- package/db/d1/migrations/0001_wonderful_bloodaxe.sql +12 -0
- package/db/d1/migrations/0002_late_frightful_four.sql +1 -0
- package/db/d1/migrations/0003_cuddly_obadiah_stane.sql +16 -0
- package/db/d1/migrations/0004_mute_stardust.sql +1 -0
- package/db/d1/migrations/0005_awesome_silvermane.sql +3 -0
- package/db/d1/migrations/0006_volatile_shriek.sql +2 -0
- package/db/d1/migrations/0007_superb_lila_cheney.sql +1 -0
- package/db/d1/migrations/0008_bitter_longshot.sql +17 -0
- package/db/d1/migrations/0009_wonderful_madame_masque.sql +28 -0
- package/db/d1/migrations/meta/0000_snapshot.json +1112 -0
- package/db/d1/migrations/meta/0001_snapshot.json +1187 -0
- package/db/d1/migrations/meta/0002_snapshot.json +1194 -0
- package/db/d1/migrations/meta/0003_snapshot.json +1296 -0
- package/db/d1/migrations/meta/0004_snapshot.json +1303 -0
- package/db/d1/migrations/meta/0005_snapshot.json +1325 -0
- package/db/d1/migrations/meta/0006_snapshot.json +1339 -0
- package/db/d1/migrations/meta/0007_snapshot.json +1347 -0
- package/db/d1/migrations/meta/0008_snapshot.json +1464 -0
- package/db/d1/migrations/meta/0009_snapshot.json +1648 -0
- package/db/d1/migrations/meta/_journal.json +76 -0
- package/db/d1/schema.ts +407 -0
- package/db/d1/sites.ts +374 -0
- package/db/d1/teamAiUsage.ts +101 -0
- package/db/d1/teams.ts +127 -0
- package/db/durable/drizzle.config.ts +8 -0
- package/db/durable/durableObjectClient.ts +480 -0
- package/db/durable/events.ts +100 -0
- package/db/durable/migrations/0000_fair_bucky.sql +38 -0
- package/db/durable/migrations/meta/0000_snapshot.json +278 -0
- package/db/durable/migrations/meta/_journal.json +13 -0
- package/db/durable/migrations/migrations.js +10 -0
- package/db/durable/schema.ts +5 -0
- package/db/durable/siteDurableObject.ts +1352 -0
- package/db/durable/types.ts +53 -0
- package/db/postgres/client.ts +13 -0
- package/db/postgres/drizzle.config.ts +12 -0
- package/db/postgres/migrations/0000_brainy_sprite.sql +116 -0
- package/db/postgres/migrations/meta/0000_snapshot.json +681 -0
- package/db/postgres/migrations/meta/_journal.json +13 -0
- package/db/postgres/schema.ts +145 -0
- package/db/postgres/sites.ts +118 -0
- package/db/tranformReports.ts +595 -0
- package/db/types.ts +55 -0
- package/endpoints/api_worker.tsx +1854 -0
- package/endpoints/site_do_worker.ts +11 -0
- package/index.d.ts +63 -0
- package/index.ts +83 -0
- package/lib/auth.ts +279 -0
- package/lib/geojson/world_countries.json +45307 -0
- package/lib/random_name.ts +41 -0
- package/lib/sendMail.ts +252 -0
- package/package.json +142 -0
- package/public/favicon.ico +0 -0
- package/public/images/android-chrome-192x192.png +0 -0
- package/public/images/android-chrome-512x512.png +0 -0
- package/public/images/apple-touch-icon.png +0 -0
- package/public/images/favicon-16x16.png +0 -0
- package/public/images/favicon-32x32.png +0 -0
- package/public/images/lytx_dark_dashboard.png +0 -0
- package/public/images/lytx_light_dashboard.png +0 -0
- package/public/images/safari-pinned-tab.svg +4 -0
- package/public/logo.png +0 -0
- package/public/site.webmanifest +26 -0
- package/public/sw.js +107 -0
- package/src/Document.tsx +86 -0
- package/src/api/ai_api.ts +1156 -0
- package/src/api/authMiddleware.ts +45 -0
- package/src/api/auth_api.ts +465 -0
- package/src/api/event_labels_api.ts +193 -0
- package/src/api/events_api.ts +210 -0
- package/src/api/queueWorker.ts +303 -0
- package/src/api/reports_api.ts +278 -0
- package/src/api/seed_api.ts +288 -0
- package/src/api/sites_api.ts +904 -0
- package/src/api/tag_api.ts +458 -0
- package/src/api/tag_api_v2.ts +289 -0
- package/src/api/team_api.ts +456 -0
- package/src/app/Dashboard.tsx +1339 -0
- package/src/app/Events.tsx +974 -0
- package/src/app/Explore.tsx +312 -0
- package/src/app/Layout.tsx +58 -0
- package/src/app/Settings.tsx +1302 -0
- package/src/app/components/DashboardCard.tsx +118 -0
- package/src/app/components/EditableCell.tsx +123 -0
- package/src/app/components/EventForm.tsx +93 -0
- package/src/app/components/MarketingFooter.tsx +49 -0
- package/src/app/components/MarketingNav.tsx +150 -0
- package/src/app/components/Nav.tsx +755 -0
- package/src/app/components/NewSiteSetup.tsx +298 -0
- package/src/app/components/SQLEditor.tsx +740 -0
- package/src/app/components/SiteSelector.tsx +126 -0
- package/src/app/components/SiteTag.tsx +42 -0
- package/src/app/components/SiteTagInstallCard.tsx +241 -0
- package/src/app/components/WorldMapCard.tsx +337 -0
- package/src/app/components/charts/ChartComponents.tsx +1481 -0
- package/src/app/components/charts/EventFunnel.tsx +45 -0
- package/src/app/components/charts/EventSummary.tsx +194 -0
- package/src/app/components/charts/SankeyFlows.tsx +72 -0
- package/src/app/components/marketing/CheckIcon.tsx +16 -0
- package/src/app/components/marketing/MarketingLayout.tsx +23 -0
- package/src/app/components/marketing/SectionHeading.tsx +35 -0
- package/src/app/components/reports/AskAiWorkspace.tsx +371 -0
- package/src/app/components/reports/CreateReportStarter.tsx +74 -0
- package/src/app/components/reports/DashboardRouteFiltersContext.tsx +14 -0
- package/src/app/components/reports/DashboardToolbar.tsx +154 -0
- package/src/app/components/reports/DashboardWorkspaceLayout.tsx +63 -0
- package/src/app/components/reports/DashboardWorkspaceShell.tsx +118 -0
- package/src/app/components/reports/ReportBuilderWorkspace.tsx +76 -0
- package/src/app/components/reports/custom/CustomReportBuilderPage.tsx +1667 -0
- package/src/app/components/reports/custom/ReportWidgetChart.tsx +297 -0
- package/src/app/components/reports/custom/buildWidgetSql.ts +151 -0
- package/src/app/components/reports/custom/chartPalettes.ts +18 -0
- package/src/app/components/reports/custom/types.ts +50 -0
- package/src/app/components/reports/reportBuilderMenuItems.ts +17 -0
- package/src/app/components/reports/useDashboardToolbarControls.tsx +235 -0
- package/src/app/components/ui/AlertBanner.tsx +101 -0
- package/src/app/components/ui/Button.tsx +55 -0
- package/src/app/components/ui/Card.tsx +80 -0
- package/src/app/components/ui/Input.tsx +72 -0
- package/src/app/components/ui/Link.tsx +23 -0
- package/src/app/components/ui/ReportBuilderMenu.tsx +246 -0
- package/src/app/components/ui/ThemeToggle.tsx +54 -0
- package/src/app/constants.ts +6 -0
- package/src/app/headers.ts +33 -0
- package/src/app/providers/AuthProvider.tsx +189 -0
- package/src/app/providers/ClientProviders.tsx +18 -0
- package/src/app/providers/QueryProvider.tsx +23 -0
- package/src/app/providers/ThemeProvider.tsx +88 -0
- package/src/app/utils/chartThemes.ts +146 -0
- package/src/app/utils/keybinds.ts +96 -0
- package/src/app/utils/media.tsx +24 -0
- package/src/client.tsx +114 -0
- package/src/config/createLytxAppConfig.ts +252 -0
- package/src/config/resourceNames.ts +88 -0
- package/src/db/index.ts +67 -0
- package/src/index.css +285 -0
- package/src/lib/featureFlags.ts +69 -0
- package/src/pages/GetStarted.tsx +290 -0
- package/src/pages/Home.tsx +268 -0
- package/src/pages/Login.tsx +283 -0
- package/src/pages/PrivacyPolicy.tsx +120 -0
- package/src/pages/Signup.tsx +267 -0
- package/src/pages/TermsOfService.tsx +126 -0
- package/src/pages/VerifyEmail.tsx +56 -0
- package/src/session/durableObject.ts +7 -0
- package/src/session/siteSchema.ts +86 -0
- package/src/session/types.ts +36 -0
- package/src/templates/README.md +80 -0
- package/src/templates/cleanFunctions.js +44 -0
- package/src/templates/embedFunctions.js +52 -0
- package/src/templates/lytx-shared.ts +662 -0
- package/src/templates/lytxpixel-core.ts +144 -0
- package/src/templates/lytxpixel.ts +267 -0
- package/src/templates/lytxpixelBrowser.js +634 -0
- package/src/templates/lytxpixelBrowser.mjs +634 -0
- package/src/templates/parseData.js +12 -0
- package/src/templates/script.ts +31 -0
- package/src/templates/template.tsx +50 -0
- package/src/templates/test.js +3 -0
- package/src/templates/trackWebEvents.ts +177 -0
- package/src/templates/vendors/clickcease.ts +8 -0
- package/src/templates/vendors/google.ts +174 -0
- package/src/templates/vendors/linkedin.ts +23 -0
- package/src/templates/vendors/meta.ts +56 -0
- package/src/templates/vendors/quantcast.ts +22 -0
- package/src/templates/vendors/simplfi.ts +7 -0
- package/src/types/app-context.ts +16 -0
- package/src/utilities/dashboardParams.ts +188 -0
- package/src/utilities/dashboardQueries.ts +537 -0
- package/src/utilities/dashboardTransforms.ts +167 -0
- package/src/utilities/dataValidation.ts +414 -0
- package/src/utilities/detector.ts +73 -0
- package/src/utilities/encrypt.ts +103 -0
- package/src/utilities/index.ts +13 -0
- package/src/utilities/parser.ts +117 -0
- package/src/utilities/performanceMonitoring.ts +570 -0
- package/src/utilities/route_interuptors.ts +24 -0
- package/src/worker.tsx +675 -0
- package/tsconfig.json +78 -0
- package/types/env.d.ts +16 -0
- package/types/rw.d.ts +7 -0
- package/types/shims.d.ts +53 -0
- package/types/vite.d.ts +19 -0
- package/vite/vite-plugin-pixel-bundle.ts +126 -0
- package/vite.config.ts +53 -0
- package/worker-configuration.d.ts +8401 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
} from "react";
|
|
11
|
+
import { AuthContext } from "@/app/providers/AuthProvider";
|
|
12
|
+
import { DashboardToolbar } from "@/app/components/reports/DashboardToolbar";
|
|
13
|
+
import type { ToolbarSiteOption } from "@/app/components/reports/DashboardToolbar";
|
|
14
|
+
import { useDashboardToolbarControls } from "@/app/components/reports/useDashboardToolbarControls";
|
|
15
|
+
import { DashboardRouteFiltersContext } from "@/app/components/reports/DashboardRouteFiltersContext";
|
|
16
|
+
import {
|
|
17
|
+
getBrowserTimeZone,
|
|
18
|
+
getDateStringInTimeZone,
|
|
19
|
+
isValidTimeZone,
|
|
20
|
+
type DashboardFilters,
|
|
21
|
+
} from "@/app/components/charts/ChartComponents";
|
|
22
|
+
import type { ReportBuilderMenuActiveId } from "@/app/components/ui/ReportBuilderMenu";
|
|
23
|
+
|
|
24
|
+
type DashboardWorkspaceShellProps = {
|
|
25
|
+
activeReportBuilderItemId: ReportBuilderMenuActiveId;
|
|
26
|
+
reportBuilderEnabled: boolean;
|
|
27
|
+
askAiEnabled: boolean;
|
|
28
|
+
initialSites?: ToolbarSiteOption[];
|
|
29
|
+
initialSiteId?: number | null;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function DashboardWorkspaceShell({
|
|
34
|
+
activeReportBuilderItemId,
|
|
35
|
+
reportBuilderEnabled,
|
|
36
|
+
askAiEnabled,
|
|
37
|
+
initialSites = [],
|
|
38
|
+
initialSiteId = null,
|
|
39
|
+
children,
|
|
40
|
+
}: DashboardWorkspaceShellProps) {
|
|
41
|
+
const { data: session, isPending: isSessionLoading, current_site } = useContext(AuthContext) || {
|
|
42
|
+
data: null,
|
|
43
|
+
isPending: true,
|
|
44
|
+
current_site: null,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const browserTimezone = useMemo(() => getBrowserTimeZone(), []);
|
|
48
|
+
const savedTimezone = session?.timezone;
|
|
49
|
+
const effectiveTimezone = isValidTimeZone(savedTimezone) ? savedTimezone : browserTimezone;
|
|
50
|
+
const today = useMemo(() => getDateStringInTimeZone(new Date(), effectiveTimezone), [effectiveTimezone]);
|
|
51
|
+
|
|
52
|
+
const [filters, setFilters] = useState<DashboardFilters>({
|
|
53
|
+
dateRange: {
|
|
54
|
+
start: today,
|
|
55
|
+
end: today,
|
|
56
|
+
preset: "Today",
|
|
57
|
+
},
|
|
58
|
+
deviceType: undefined,
|
|
59
|
+
country: undefined,
|
|
60
|
+
city: undefined,
|
|
61
|
+
region: undefined,
|
|
62
|
+
source: undefined,
|
|
63
|
+
pageUrl: undefined,
|
|
64
|
+
eventName: undefined,
|
|
65
|
+
siteId: undefined,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const hasInitializedDateRange = useRef(false);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (isSessionLoading || hasInitializedDateRange.current) return;
|
|
71
|
+
|
|
72
|
+
setFilters((prev) => ({
|
|
73
|
+
...prev,
|
|
74
|
+
dateRange: {
|
|
75
|
+
start: today,
|
|
76
|
+
end: today,
|
|
77
|
+
preset: "Today",
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
hasInitializedDateRange.current = true;
|
|
82
|
+
}, [today, isSessionLoading]);
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const nextSiteId =
|
|
86
|
+
current_site?.id?.toString()
|
|
87
|
+
?? session?.userSites?.[0]?.site_id?.toString()
|
|
88
|
+
?? initialSiteId?.toString();
|
|
89
|
+
if (!nextSiteId) return;
|
|
90
|
+
|
|
91
|
+
setFilters((prev) => ({
|
|
92
|
+
...prev,
|
|
93
|
+
siteId: nextSiteId,
|
|
94
|
+
}));
|
|
95
|
+
}, [current_site?.id, initialSiteId, session?.userSites]);
|
|
96
|
+
|
|
97
|
+
const { controls, footer, modal } = useDashboardToolbarControls({
|
|
98
|
+
filters,
|
|
99
|
+
setFilters,
|
|
100
|
+
timezone: effectiveTimezone,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<DashboardRouteFiltersContext.Provider value={{ filters, timezone: effectiveTimezone }}>
|
|
105
|
+
<DashboardToolbar
|
|
106
|
+
activeReportBuilderItemId={activeReportBuilderItemId}
|
|
107
|
+
reportBuilderEnabled={reportBuilderEnabled}
|
|
108
|
+
askAiEnabled={askAiEnabled}
|
|
109
|
+
controls={controls}
|
|
110
|
+
footer={footer}
|
|
111
|
+
initialSites={initialSites}
|
|
112
|
+
initialSiteId={initialSiteId}
|
|
113
|
+
/>
|
|
114
|
+
<div className="p-4 sm:p-6 lg:p-8">{children}</div>
|
|
115
|
+
{modal}
|
|
116
|
+
</DashboardRouteFiltersContext.Provider>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { CreateReportStarter } from "@/app/components/reports/CreateReportStarter";
|
|
5
|
+
import { AskAiWorkspace } from "@/app/components/reports/AskAiWorkspace";
|
|
6
|
+
import type { ReportBuilderActionId } from "@/app/components/ui/ReportBuilderMenu";
|
|
7
|
+
|
|
8
|
+
type ReportBuilderWorkspaceProps = {
|
|
9
|
+
activeReportBuilderItemId: ReportBuilderActionId;
|
|
10
|
+
initialAiConfigured?: boolean;
|
|
11
|
+
initialAiModel?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const reportWorkspaceCopy: Partial<Record<Exclude<ReportBuilderActionId, "create-report">, { title: string; description: string }>> = {
|
|
15
|
+
"create-reference": {
|
|
16
|
+
title: "Create reference",
|
|
17
|
+
description: "Reference report setup is next. This route is now separated and ready for dedicated UI.",
|
|
18
|
+
},
|
|
19
|
+
"create-dashboard": {
|
|
20
|
+
title: "Create dashboard",
|
|
21
|
+
description: "Dashboard builder setup is next. This route is now separated and ready for dedicated UI.",
|
|
22
|
+
},
|
|
23
|
+
"create-notification": {
|
|
24
|
+
title: "Create notification rule",
|
|
25
|
+
description: "Notification rule setup is next. This route is now separated and ready for dedicated UI.",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function ReportBuilderWorkspace({
|
|
30
|
+
activeReportBuilderItemId,
|
|
31
|
+
initialAiConfigured = false,
|
|
32
|
+
initialAiModel = "",
|
|
33
|
+
}: ReportBuilderWorkspaceProps) {
|
|
34
|
+
const inactiveCopy = useMemo(
|
|
35
|
+
() =>
|
|
36
|
+
activeReportBuilderItemId === "create-report"
|
|
37
|
+
? null
|
|
38
|
+
: reportWorkspaceCopy[activeReportBuilderItemId],
|
|
39
|
+
[activeReportBuilderItemId],
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (activeReportBuilderItemId === "create-report") {
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<CreateReportStarter
|
|
46
|
+
onStartCustomReport={() => {
|
|
47
|
+
window.location.assign("/dashboard/reports/custom/new");
|
|
48
|
+
}}
|
|
49
|
+
onStartTemplate={(templateId) => {
|
|
50
|
+
const query = new URLSearchParams({ template: templateId });
|
|
51
|
+
window.location.assign(`/dashboard/reports/custom/new?${query.toString()}`);
|
|
52
|
+
}}
|
|
53
|
+
/>
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (activeReportBuilderItemId === "ask-ai") {
|
|
59
|
+
return (
|
|
60
|
+
<AskAiWorkspace initialAiConfigured={initialAiConfigured} initialAiModel={initialAiModel} />
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<section className="max-w-4xl mx-auto">
|
|
66
|
+
<div className="rounded-xl border border-(--theme-border-primary) bg-(--theme-card-bg) p-6 sm:p-8">
|
|
67
|
+
<h2 className="text-2xl font-semibold text-(--theme-text-primary)">
|
|
68
|
+
{inactiveCopy?.title}
|
|
69
|
+
</h2>
|
|
70
|
+
<p className="mt-2 text-(--theme-text-secondary)">
|
|
71
|
+
{inactiveCopy?.description}
|
|
72
|
+
</p>
|
|
73
|
+
</div>
|
|
74
|
+
</section>
|
|
75
|
+
);
|
|
76
|
+
}
|