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,53 @@
|
|
|
1
|
+
import type { DrizzleSqliteDODatabase } from "drizzle-orm/durable-sqlite";
|
|
2
|
+
|
|
3
|
+
import type * as schema from "@db/durable/schema";
|
|
4
|
+
export type Durable_DB = DrizzleSqliteDODatabase<typeof schema>;
|
|
5
|
+
export type GetEventsOptions = {
|
|
6
|
+
startDate?: Date;
|
|
7
|
+
endDate?: Date;
|
|
8
|
+
eventType?: string;
|
|
9
|
+
country?: string;
|
|
10
|
+
deviceType?: string;
|
|
11
|
+
referer?: string;
|
|
12
|
+
limit?: number;
|
|
13
|
+
offset?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SiteEventInput {
|
|
17
|
+
bot_data?: object;
|
|
18
|
+
browser?: string;
|
|
19
|
+
city?: string;
|
|
20
|
+
client_page_url?: string;
|
|
21
|
+
country?: string;
|
|
22
|
+
custom_data?: object;
|
|
23
|
+
device_type?: string;
|
|
24
|
+
event: string;
|
|
25
|
+
operating_system?: string;
|
|
26
|
+
page_url?: string;
|
|
27
|
+
postal?: string;
|
|
28
|
+
query_params?: object;
|
|
29
|
+
referer?: string;
|
|
30
|
+
region?: string;
|
|
31
|
+
rid?: string;
|
|
32
|
+
screen_height?: number;
|
|
33
|
+
screen_width?: number;
|
|
34
|
+
tag_id: string;
|
|
35
|
+
createdAt?: Date;
|
|
36
|
+
updatedAt?: Date;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface DashboardOptions {
|
|
40
|
+
site_id: number;
|
|
41
|
+
site_uuid: string;
|
|
42
|
+
team_id: number;
|
|
43
|
+
date?: {
|
|
44
|
+
start?: Date;
|
|
45
|
+
end?: Date;
|
|
46
|
+
/** When true, use end date as-is without adjusting to end of day (for sub-day ranges). */
|
|
47
|
+
endIsExact?: boolean;
|
|
48
|
+
};
|
|
49
|
+
events?: {
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
2
|
+
import { env } from 'cloudflare:workers';
|
|
3
|
+
const resolveConnectionString = () => {
|
|
4
|
+
const workerEnv = env as unknown as { lytx_pg?: { connectionString?: string } };
|
|
5
|
+
return workerEnv.lytx_pg?.connectionString
|
|
6
|
+
?? process.env.WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_lytx_pg
|
|
7
|
+
?? process.env.DATABASE_URL
|
|
8
|
+
?? "";
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const pg_client = (connextionString = resolveConnectionString()) => {
|
|
12
|
+
return drizzle(connextionString);
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig } from 'drizzle-kit';
|
|
2
|
+
|
|
3
|
+
import * as dotenv from 'dotenv';
|
|
4
|
+
dotenv.config();
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
out: './db/postgres/migrations',
|
|
8
|
+
schema: './db/postgres/schema.ts',
|
|
9
|
+
dialect: 'postgresql',
|
|
10
|
+
dbCredentials: { url: process.env.DATABASE_URL }
|
|
11
|
+
});
|
|
12
|
+
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
CREATE TABLE "accounts" (
|
|
2
|
+
"account_id" serial PRIMARY KEY NOT NULL,
|
|
3
|
+
"api_key" text,
|
|
4
|
+
"created_at" timestamp,
|
|
5
|
+
"created_by" text,
|
|
6
|
+
"name" text,
|
|
7
|
+
"website" text
|
|
8
|
+
);
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
CREATE TABLE "dataStore" (
|
|
11
|
+
"id" serial PRIMARY KEY NOT NULL,
|
|
12
|
+
"uuid" text NOT NULL,
|
|
13
|
+
"account" text,
|
|
14
|
+
"adServer" text,
|
|
15
|
+
"adServerData" jsonb,
|
|
16
|
+
"adServerType" text,
|
|
17
|
+
"city" text,
|
|
18
|
+
"client_ip" text,
|
|
19
|
+
"country" text,
|
|
20
|
+
"created_at" timestamp,
|
|
21
|
+
"customData" jsonb,
|
|
22
|
+
"customType" text,
|
|
23
|
+
"data_event" text,
|
|
24
|
+
"data_passback" text,
|
|
25
|
+
"host" text,
|
|
26
|
+
"labels" text,
|
|
27
|
+
"lat" text,
|
|
28
|
+
"long" text,
|
|
29
|
+
"message" text,
|
|
30
|
+
"method" text,
|
|
31
|
+
"path" text,
|
|
32
|
+
"referer" text,
|
|
33
|
+
"referrer" text,
|
|
34
|
+
"region" text,
|
|
35
|
+
"screen_height" text,
|
|
36
|
+
"screen_width" text,
|
|
37
|
+
"thirdPartyId" text,
|
|
38
|
+
"user_agent" text,
|
|
39
|
+
"zip" text
|
|
40
|
+
);
|
|
41
|
+
--> statement-breakpoint
|
|
42
|
+
CREATE TABLE "events" (
|
|
43
|
+
"id" serial PRIMARY KEY NOT NULL,
|
|
44
|
+
"account_id" integer,
|
|
45
|
+
"clickCease" jsonb,
|
|
46
|
+
"condition" text,
|
|
47
|
+
"created_at" timestamp,
|
|
48
|
+
"data_passback" text,
|
|
49
|
+
"event_name" text,
|
|
50
|
+
"google_ads_conversion" jsonb,
|
|
51
|
+
"google_ads_script" text,
|
|
52
|
+
"google_analytics" text,
|
|
53
|
+
"notes" text,
|
|
54
|
+
"param_config" jsonb,
|
|
55
|
+
"parameters" text,
|
|
56
|
+
"quantcast_pixel_id" text,
|
|
57
|
+
"rules" text,
|
|
58
|
+
"simplfi_pixel_id" text,
|
|
59
|
+
"site_id" integer
|
|
60
|
+
);
|
|
61
|
+
--> statement-breakpoint
|
|
62
|
+
CREATE TABLE "site_events" (
|
|
63
|
+
"id" serial PRIMARY KEY NOT NULL,
|
|
64
|
+
"account_id" integer,
|
|
65
|
+
"bot_data" jsonb,
|
|
66
|
+
"browser" text,
|
|
67
|
+
"city" text,
|
|
68
|
+
"client_page_url" text,
|
|
69
|
+
"country" text,
|
|
70
|
+
"created_at" timestamp,
|
|
71
|
+
"custom_data" jsonb,
|
|
72
|
+
"device_type" text,
|
|
73
|
+
"event" text,
|
|
74
|
+
"operating_system" text,
|
|
75
|
+
"page_url" text,
|
|
76
|
+
"postal" text,
|
|
77
|
+
"query_params" jsonb,
|
|
78
|
+
"referer" text,
|
|
79
|
+
"region" text,
|
|
80
|
+
"rid" text,
|
|
81
|
+
"screen_height" integer,
|
|
82
|
+
"screen_width" integer,
|
|
83
|
+
"site_id" integer,
|
|
84
|
+
"tag_id" text
|
|
85
|
+
);
|
|
86
|
+
--> statement-breakpoint
|
|
87
|
+
CREATE TABLE "site_personalization" (
|
|
88
|
+
"id" serial PRIMARY KEY NOT NULL,
|
|
89
|
+
"created_at" timestamp NOT NULL,
|
|
90
|
+
"client_page_url" text,
|
|
91
|
+
"rid" text
|
|
92
|
+
);
|
|
93
|
+
--> statement-breakpoint
|
|
94
|
+
CREATE TABLE "sites" (
|
|
95
|
+
"site_id" serial PRIMARY KEY NOT NULL,
|
|
96
|
+
"tag_id" text NOT NULL,
|
|
97
|
+
"track_web_events" boolean DEFAULT false NOT NULL,
|
|
98
|
+
"event_load_strategy" text DEFAULT 'sdk' NOT NULL,
|
|
99
|
+
"account_id" integer,
|
|
100
|
+
"client" text,
|
|
101
|
+
"created_at" timestamp,
|
|
102
|
+
"domain" text,
|
|
103
|
+
"gdpr" boolean,
|
|
104
|
+
"rid_salt" text,
|
|
105
|
+
"rid_salt_expire" timestamp,
|
|
106
|
+
"tag_id_override" text
|
|
107
|
+
);
|
|
108
|
+
--> statement-breakpoint
|
|
109
|
+
CREATE TABLE "waitlist" (
|
|
110
|
+
"id" serial PRIMARY KEY NOT NULL,
|
|
111
|
+
"company" text,
|
|
112
|
+
"created_at" timestamp,
|
|
113
|
+
"email_address" text,
|
|
114
|
+
"name" text,
|
|
115
|
+
"website" text
|
|
116
|
+
);
|