🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
shared package (#380)
Bill Yang5655d3ff34bf
diff --git a/.claude/settings.local.json b/.claude/settings.local.jsonindex e8f289d70..b505e2962 100644--- a/.claude/settings.local.json+++ b/.claude/settings.local.json@@ -1,3 +1,10 @@{+ "permissions": {+ "allow": [+ "Bash(mkdir:*)",+ "Bash(grep:*)",+ "Bash(npm install)"+ ]+ },"enableAllProjectMcpServers": false}\ No newline at end of filediff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.ymlindex 9418c4e04..5b2661152 100644--- a/.github/workflows/docker-publish.yml+++ b/.github/workflows/docker-publish.yml@@ -5,7 +5,7 @@ on:branches:- mastertags:- - 'v*'+ - "v*"pull_request:branches:- master@@ -21,11 +21,9 @@ jobs:fail-fast: falsematrix:include:- -- os: ubuntu-latest+ - os: ubuntu-latestplatform: linux/amd64- -- os: ubuntu-24.04-arm+ - os: ubuntu-24.04-armplatform: linux/arm64steps:@@ -58,7 +56,7 @@ jobs:id: builduses: docker/build-push-action@v6with:- context: ./client+ context: .file: ./client/Dockerfileplatforms: ${{ matrix.platform }}labels: ${{ steps.meta.outputs.labels }}@@ -73,7 +71,7 @@ jobs:- uses: actions/upload-artifact@v4with:name: digests-client-${{ env.PLATFORM_PAIR }}- path: '/tmp/digests/*'+ path: "/tmp/digests/*"retention-days: 1build-backend:@@ -86,11 +84,9 @@ jobs:fail-fast: falsematrix:include:- -- os: ubuntu-latest+ - os: ubuntu-latestplatform: linux/amd64- -- os: ubuntu-24.04-arm+ - os: ubuntu-24.04-armplatform: linux/arm64steps:@@ -123,7 +119,7 @@ jobs:id: builduses: docker/build-push-action@v6with:- context: ./server+ context: .file: ./server/Dockerfileplatforms: ${{ matrix.platform }}labels: ${{ steps.meta.outputs.labels }}@@ -138,7 +134,7 @@ jobs:- uses: actions/upload-artifact@v4with:name: digests-backend-${{ env.PLATFORM_PAIR }}- path: '/tmp/digests/*'+ path: "/tmp/digests/*"retention-days: 1publish-images:@@ -157,7 +153,7 @@ jobs:uses: actions/download-artifact@v4with:path: /tmp/digests- pattern: 'digests-*'+ pattern: "digests-*"merge-multiple: true- name: Set env varsrun: |diff --git a/client/Dockerfile b/client/Dockerfileindex c64f3297e..9ee00c04b 100644--- a/client/Dockerfile+++ b/client/Dockerfile@@ -5,15 +5,22 @@ FROM base AS depsRUN apk add --no-cache libc6-compatWORKDIR /app-# Install dependencies based on the preferred package manager-COPY package.json package-lock.json* ./+# Copy shared package first+COPY shared ./shared+WORKDIR /app/shared+RUN npm install && npm run build++# Install client dependencies+WORKDIR /app/client+COPY client/package.json client/package-lock.json* ./RUN npm ci --legacy-peer-deps# Rebuild the source code only when neededFROM base AS builderWORKDIR /app-COPY --from=deps /app/node_modules ./node_modules-COPY . .+COPY --from=deps /app/shared ./shared+COPY --from=deps /app/client/node_modules ./client/node_modules+COPY client/ ./client# Next.js collects completely anonymous telemetry data about general usage.# Learn more here: https://nextjs.org/telemetry@@ -25,6 +32,7 @@ ENV NEXT_PUBLIC_BACKEND_URL=${NEXT_PUBLIC_BACKEND_URL}ENV NEXT_PUBLIC_DISABLE_SIGNUP=${NEXT_PUBLIC_DISABLE_SIGNUP}ENV NEXT_PUBLIC_CLOUD=${NEXT_PUBLIC_CLOUD}+WORKDIR /app/clientRUN npm run build# Production image, copy all the files and run next@@ -37,7 +45,7 @@ ENV NEXT_TELEMETRY_DISABLED=1RUN addgroup --system --gid 1001 nodejsRUN adduser --system --uid 1001 nextjs-COPY --from=builder /app/public ./public+COPY --from=builder /app/client/public ./public# Set the correct permission for prerender cacheRUN mkdir .next@@ -45,8 +53,8 @@ RUN chown nextjs:nodejs .next# Automatically leverage output traces to reduce image size# https://nextjs.org/docs/advanced-features/output-file-tracing-COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./-COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static+COPY --from=builder --chown=nextjs:nodejs /app/client/.next/standalone ./+COPY --from=builder --chown=nextjs:nodejs /app/client/.next/static ./.next/staticUSER nextjsdiff --git a/client/package-lock.json b/client/package-lock.jsonindex a0cf4da2c..4d5888fe7 100644--- a/client/package-lock.json+++ b/client/package-lock.json@@ -1,12 +1,12 @@{"name": "client",- "version": "0.4.2",+ "version": "1.1.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "client",- "version": "0.4.2",+ "version": "1.1.0","dependencies": {"@better-auth/stripe": "1.2.7","@hookform/resolvers": "5.0.1",@@ -33,6 +33,7 @@"@radix-ui/themes": "3.2.1","@react-three/drei": "10.0.7","@react-three/fiber": "9.1.2",+ "@rybbit/shared": "file:../shared","@tanstack/react-query": "5.76.0","@tanstack/react-query-devtools": "5.76.0","@tanstack/react-table": "8.21.3",@@ -93,6 +94,15 @@"typescript": "5"}},+ "../shared": {+ "name": "@rybbit/shared",+ "version": "1.0.0",+ "license": "MIT",+ "devDependencies": {+ "@types/node": "^20.10.6",+ "typescript": "^5.3.3"+ }+ },"node_modules/@alloc/quick-lru": {"version": "5.2.0","resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz",@@ -4644,6 +4654,10 @@"url": "https://github.com/sponsors/jonschlinkert"}},+ "node_modules/@rybbit/shared": {+ "resolved": "../shared",+ "link": true+ },"node_modules/@simplewebauthn/browser": {"version": "13.1.0","resolved": "https://registry.npmjs.org/@simplewebauthn/browser/-/browser-13.1.0.tgz",diff --git a/client/package.json b/client/package.jsonindex 502028a77..381c54bc5 100644--- a/client/package.json+++ b/client/package.json@@ -9,6 +9,7 @@"lint": "next lint"},"dependencies": {+ "@rybbit/shared": "file:../shared","@better-auth/stripe": "1.2.7","@hookform/resolvers": "5.0.1","@nivo/bar": "0.96.0",diff --git a/client/src/api/analytics/useGetFunnel.ts b/client/src/api/analytics/useGetFunnel.tsindex e42cf675f..428bdc210 100644--- a/client/src/api/analytics/useGetFunnel.ts+++ b/client/src/api/analytics/useGetFunnel.ts@@ -1,9 +1,10 @@+import { Filter } from "@rybbit/shared";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import { useDebounce } from "@uidotdev/usehooks";import { BACKEND_URL } from "../../lib/const";-import { authedFetch, authedFetchWithError } from "../utils";-import { useStore, Filter } from "../../lib/store";import { timeZone } from "../../lib/dateTimeUtils";-import { useDebounce } from "@uidotdev/usehooks";+import { useStore } from "../../lib/store";+import { authedFetch, authedFetchWithError } from "../utils";export type FunnelStep = {value: string;diff --git a/client/src/api/analytics/useGetFunnels.ts b/client/src/api/analytics/useGetFunnels.tsindex d9816c8b8..fc9565656 100644--- a/client/src/api/analytics/useGetFunnels.ts+++ b/client/src/api/analytics/useGetFunnels.ts@@ -1,6 +1,6 @@+import { Filter } from "@rybbit/shared";import { useQuery } from "@tanstack/react-query";import { BACKEND_URL } from "../../lib/const";-import { Filter } from "../../lib/store";import { FunnelStep } from "./useGetFunnel";import { authedFetchWithError } from "../utils";diff --git a/client/src/api/analytics/useGetGoal.ts b/client/src/api/analytics/useGetGoal.tsindex 7170005ed..1d9d8be55 100644--- a/client/src/api/analytics/useGetGoal.ts+++ b/client/src/api/analytics/useGetGoal.ts@@ -1,8 +1,9 @@+import { Filter } from "@rybbit/shared";import { useQuery } from "@tanstack/react-query";import { BACKEND_URL } from "../../lib/const";import { timeZone } from "../../lib/dateTimeUtils";+import { useStore } from "../../lib/store";import { authedFetch } from "../utils";-import { useStore, Filter } from "../../lib/store";import { Goal } from "./useGetGoals";interface GetGoalResponse {diff --git a/client/src/api/analytics/useGetOverviewBucketed.ts b/client/src/api/analytics/useGetOverviewBucketed.tsindex 83058e706..56dfe6cd6 100644--- a/client/src/api/analytics/useGetOverviewBucketed.ts+++ b/client/src/api/analytics/useGetOverviewBucketed.ts@@ -1,11 +1,12 @@+import { Filter, TimeBucket } from "@rybbit/shared";import {UseQueryOptions,UseQueryResult,useQuery,} from "@tanstack/react-query";import { BACKEND_URL } from "../../lib/const";-import { Filter, TimeBucket, useStore } from "../../lib/store";import { timeZone } from "../../lib/dateTimeUtils";+import { useStore } from "../../lib/store";import { APIResponse } from "../types";import { authedFetch, getStartAndEndDate } from "../utils";diff --git a/client/src/api/analytics/useGetOverviewBucketedWithInView.ts b/client/src/api/analytics/useGetOverviewBucketedWithInView.tsindex 87aa4eb17..9482f287b 100644--- a/client/src/api/analytics/useGetOverviewBucketedWithInView.ts+++ b/client/src/api/analytics/useGetOverviewBucketedWithInView.ts@@ -1,9 +1,9 @@+import { TimeBucket } from "@rybbit/shared";import { useQuery } from "@tanstack/react-query";-import { TimeBucket } from "../../lib/store";import { BACKEND_URL } from "../../lib/const";import { timeZone } from "../../lib/dateTimeUtils";-import { authedFetch } from "../utils";import { APIResponse } from "../types";+import { authedFetch } from "../utils";import { GetOverviewBucketedResponse } from "./useGetOverviewBucketed";/**diff --git a/client/src/api/analytics/useGetPageTitles.ts b/client/src/api/analytics/useGetPageTitles.tsindex 62bfc558e..53a07328f 100644--- a/client/src/api/analytics/useGetPageTitles.ts+++ b/client/src/api/analytics/useGetPageTitles.ts@@ -1,9 +1,10 @@+import { FilterParameter } from "@rybbit/shared";import { useQuery, UseQueryResult } from "@tanstack/react-query";-import { FilterParameter, useStore } from "@/lib/store";+import { BACKEND_URL } from "@/lib/const";import { timeZone } from "@/lib/dateTimeUtils";+import { useStore } from "@/lib/store";import { APIResponse } from "../types";-import { BACKEND_URL } from "@/lib/const";-import { getStartAndEndDate, authedFetch } from "../utils";+import { authedFetch, getStartAndEndDate } from "../utils";// This should match PageTitleItem from the backendexport type PageTitleItem = {diff --git a/client/src/api/analytics/useGetPerformanceByDimension.ts b/client/src/api/analytics/useGetPerformanceByDimension.tsindex 2089607bf..ad6aaa4ab 100644--- a/client/src/api/analytics/useGetPerformanceByDimension.ts+++ b/client/src/api/analytics/useGetPerformanceByDimension.ts@@ -1,9 +1,10 @@-import { authedFetch, getStartAndEndDate } from "../utils";+import { Filter } from "@rybbit/shared";+import { useQuery, UseQueryResult } from "@tanstack/react-query";+import { usePerformanceStore } from "../../app/[site]/performance/performanceStore";import { BACKEND_URL } from "../../lib/const";import { timeZone } from "../../lib/dateTimeUtils";-import { Filter, useStore } from "../../lib/store";-import { usePerformanceStore } from "../../app/[site]/performance/performanceStore";-import { useQuery, UseQueryResult } from "@tanstack/react-query";+import { useStore } from "../../lib/store";+import { authedFetch, getStartAndEndDate } from "../utils";type UseGetPerformanceByDimensionOptions = {site: number | string;diff --git a/client/src/api/analytics/useGetPerformanceByPath.ts b/client/src/api/analytics/useGetPerformanceByPath.tsindex 18deb2ff6..7a3910ff6 100644--- a/client/src/api/analytics/useGetPerformanceByPath.ts+++ b/client/src/api/analytics/useGetPerformanceByPath.ts@@ -1,9 +1,10 @@-import { authedFetch, getStartAndEndDate } from "../utils";+import { Filter } from "@rybbit/shared";+import { useQuery, UseQueryResult } from "@tanstack/react-query";+import { usePerformanceStore } from "../../app/[site]/performance/performanceStore";import { BACKEND_URL } from "../../lib/const";import { timeZone } from "../../lib/dateTimeUtils";-import { Filter, useStore } from "../../lib/store";-import { usePerformanceStore } from "../../app/[site]/performance/performanceStore";-import { useQuery, UseQueryResult } from "@tanstack/react-query";+import { useStore } from "../../lib/store";+import { authedFetch, getStartAndEndDate } from "../utils";type UseGetPerformanceByPathOptions = {site: number | string;diff --git a/client/src/api/analytics/useGetPerformanceTimeSeries.ts b/client/src/api/analytics/useGetPerformanceTimeSeries.tsindex c247a9d33..a28a56d24 100644--- a/client/src/api/analytics/useGetPerformanceTimeSeries.ts+++ b/client/src/api/analytics/useGetPerformanceTimeSeries.ts@@ -1,12 +1,13 @@+import { Filter, TimeBucket } from "@rybbit/shared";import {UseQueryOptions,UseQueryResult,useQuery,} from "@tanstack/react-query";-import { BACKEND_URL } from "../../lib/const";-import { Filter, TimeBucket, useStore } from "../../lib/store";import { usePerformanceStore } from "../../app/[site]/performance/performanceStore";+import { BACKEND_URL } from "../../lib/const";import { timeZone } from "../../lib/dateTimeUtils";+import { useStore } from "../../lib/store";import { APIResponse } from "../types";import { authedFetch, getStartAndEndDate } from "../utils";diff --git a/client/src/api/analytics/useInfiniteSingleCol.ts b/client/src/api/analytics/useInfiniteSingleCol.tsindex 902a0d255..7868ea35d 100644--- a/client/src/api/analytics/useInfiniteSingleCol.ts+++ b/client/src/api/analytics/useInfiniteSingleCol.ts@@ -1,13 +1,14 @@-import { SingleColResponse } from "@/api/analytics/useSingleCol";-import { authedFetch, getStartAndEndDate } from "@/api/utils";-import { BACKEND_URL } from "@/lib/const";-import { timeZone } from "@/lib/dateTimeUtils";-import { FilterParameter, useStore } from "@/lib/store";+import { FilterParameter } from "@rybbit/shared";import {useInfiniteQuery,UseInfiniteQueryResult,InfiniteData,} from "@tanstack/react-query";+import { SingleColResponse } from "@/api/analytics/useSingleCol";+import { authedFetch, getStartAndEndDate } from "@/api/utils";+import { BACKEND_URL } from "@/lib/const";+import { timeZone } from "@/lib/dateTimeUtils";+import { useStore } from "@/lib/store";type UseInfiniteSingleColOptions = {parameter: FilterParameter;diff --git a/client/src/api/analytics/usePaginatedSingleCol.ts b/client/src/api/analytics/usePaginatedSingleCol.tsindex f680e3912..2aba7bfc7 100644--- a/client/src/api/analytics/usePaginatedSingleCol.ts+++ b/client/src/api/analytics/usePaginatedSingleCol.ts@@ -1,9 +1,10 @@+import { Filter, FilterParameter } from "@rybbit/shared";+import { useQuery, UseQueryResult } from "@tanstack/react-query";import { SingleColResponse } from "@/api/analytics/useSingleCol";import { authedFetch, getStartAndEndDate } from "@/api/utils";import { BACKEND_URL } from "@/lib/const";import { timeZone } from "@/lib/dateTimeUtils";-import { Filter, FilterParameter, useStore } from "@/lib/store";-import { useQuery, UseQueryResult } from "@tanstack/react-query";+import { useStore } from "@/lib/store";type UsePaginatedSingleColOptions = {parameter: FilterParameter;diff --git a/client/src/api/analytics/useSingleCol.ts b/client/src/api/analytics/useSingleCol.tsindex 3e6b894f7..1a9f9617f 100644--- a/client/src/api/analytics/useSingleCol.ts+++ b/client/src/api/analytics/useSingleCol.ts@@ -1,9 +1,10 @@+import { FilterParameter } from "@rybbit/shared";import { useQuery, UseQueryResult } from "@tanstack/react-query";-import { FilterParameter, useStore } from "../../lib/store";+import { BACKEND_URL } from "../../lib/const";import { timeZone } from "../../lib/dateTimeUtils";+import { useStore } from "../../lib/store";import { APIResponse } from "../types";-import { BACKEND_URL } from "../../lib/const";-import { getStartAndEndDate, authedFetch } from "../utils";+import { authedFetch, getStartAndEndDate } from "../utils";type PeriodTime = "current" | "previous";diff --git a/client/src/api/analytics/users.ts b/client/src/api/analytics/users.tsindex 59728415f..da4fea730 100644--- a/client/src/api/analytics/users.ts+++ b/client/src/api/analytics/users.ts@@ -1,13 +1,13 @@+import { Filter } from "@rybbit/shared";import { useQuery } from "@tanstack/react-query";import { BACKEND_URL } from "../../lib/const";import { timeZone } from "../../lib/dateTimeUtils";import {useStore,- Filter,USER_PAGE_FILTERS,getFilteredFilters,} from "../../lib/store";-import { getStartAndEndDate, authedFetch } from "../utils";+import { authedFetch, getStartAndEndDate } from "../utils";import { APIResponse } from "../types";import { getQueryTimeParams } from "./utils";diff --git a/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx b/client/src/app/[site]/components/SubHeader/Filters/Filters.tsxindex f58fe7439..137d6dd34 100644--- a/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx+++ b/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx@@ -1,3 +1,4 @@+import { FilterParameter, FilterType } from "@rybbit/shared";import { X } from "lucide-react";import {Tooltip,@@ -6,8 +7,6 @@ import {} from "../../../../../components/ui/tooltip";import { useGetRegionName } from "../../../../../lib/geo";import {- FilterParameter,- FilterType,removeFilter,updateFilter,useStore,diff --git a/client/src/app/[site]/components/SubHeader/Filters/NewFilterButton.tsx b/client/src/app/[site]/components/SubHeader/Filters/NewFilterButton.tsxindex 68daff930..1d0ad78a6 100644--- a/client/src/app/[site]/components/SubHeader/Filters/NewFilterButton.tsx+++ b/client/src/app/[site]/components/SubHeader/Filters/NewFilterButton.tsx@@ -1,4 +1,5 @@"use client";+import { Filter, FilterParameter } from "@rybbit/shared";import { ListFilterPlus, Plus } from "lucide-react";import { useState } from "react";import { Button } from "../../../../../components/ui/button";@@ -7,7 +8,7 @@ import {DropdownMenuContent,DropdownMenuTrigger,} from "../../../../../components/ui/dropdown-menu";-import { Filter, FilterParameter, useStore } from "../../../../../lib/store";+import { useStore } from "../../../../../lib/store";import { sleep } from "../../../../../lib/utils";import { FilterComponent } from "../../shared/Filters/FilterComponent";diff --git a/client/src/app/[site]/components/SubHeader/SubHeader.tsx b/client/src/app/[site]/components/SubHeader/SubHeader.tsxindex 9a41f223d..4321f82da 100644--- a/client/src/app/[site]/components/SubHeader/SubHeader.tsx+++ b/client/src/app/[site]/components/SubHeader/SubHeader.tsx@@ -1,10 +1,10 @@"use client";-import { Filters } from "./Filters/Filters";--import { Button } from "@/components/ui/button";-import { FilterParameter, goBack, goForward, useStore } from "@/lib/store";+import { FilterParameter } from "@rybbit/shared";import { ChevronLeft, ChevronRight } from "lucide-react";import { DateTime } from "luxon";+import { Button } from "@/components/ui/button";+import { goBack, goForward, useStore } from "@/lib/store";+import { Filters } from "./Filters/Filters";import { DateSelector } from "../../../../components/DateSelector/DateSelector";import { Time } from "../../../../components/DateSelector/types";diff --git a/client/src/app/[site]/components/shared/Filters/FilterComponent.tsx b/client/src/app/[site]/components/shared/Filters/FilterComponent.tsxindex 1e86f4fa2..7d8b51b81 100644--- a/client/src/app/[site]/components/shared/Filters/FilterComponent.tsx+++ b/client/src/app/[site]/components/shared/Filters/FilterComponent.tsx@@ -1,3 +1,4 @@+import { Filter, FilterParameter, FilterType } from "@rybbit/shared";import { Trash } from "lucide-react";import { Button } from "../../../../../components/ui/button";import {@@ -7,7 +8,6 @@ import {SelectTrigger,SelectValue,} from "../../../../../components/ui/select";-import { Filter, FilterParameter, FilterType } from "../../../../../lib/store";import { FilterOptions, OperatorOptions } from "./const";import { ValueSelect } from "./ValueSelect";diff --git a/client/src/app/[site]/components/shared/Filters/ValueSelect.tsx b/client/src/app/[site]/components/shared/Filters/ValueSelect.tsxindex 3403475f5..a8f52a289 100644--- a/client/src/app/[site]/components/shared/Filters/ValueSelect.tsx+++ b/client/src/app/[site]/components/shared/Filters/ValueSelect.tsx@@ -1,14 +1,11 @@"use client";+import { FilterParameter } from "@rybbit/shared";import { useMemo } from "react";--import { getCountryName, getLanguageName } from "../../../../../lib/utils";--import { FilterParameter } from "../../../../../lib/store";-import { useSingleCol } from "../../../../../api/analytics/useSingleCol";import { MultiSelect } from "../../../../../components/MultiSelect";import { useGetRegionName } from "../../../../../lib/geo";+import { getCountryName, getLanguageName } from "../../../../../lib/utils";export function ValueSelect({parameter,diff --git a/client/src/app/[site]/components/shared/Filters/const.tsx b/client/src/app/[site]/components/shared/Filters/const.tsxindex 7d9b89634..edf34a737 100644--- a/client/src/app/[site]/components/shared/Filters/const.tsx+++ b/client/src/app/[site]/components/shared/Filters/const.tsx@@ -1,3 +1,4 @@+import { FilterParameter } from "@rybbit/shared";import {AppWindow,Brain,@@ -23,7 +24,6 @@ import {Target,} from "lucide-react";import React from "react";-import { FilterParameter } from "../../../../../lib/store";export const FilterOptions: {label: string;diff --git a/client/src/app/[site]/components/shared/Filters/utils.ts b/client/src/app/[site]/components/shared/Filters/utils.tsindex befe4201e..f8f7cc182 100644--- a/client/src/app/[site]/components/shared/Filters/utils.ts+++ b/client/src/app/[site]/components/shared/Filters/utils.ts@@ -1,4 +1,4 @@-import { Filter, FilterParameter, FilterType } from "../../../../../lib/store";+import { Filter, FilterParameter, FilterType } from "@rybbit/shared";import { getCountryName } from "../../../../../lib/utils";export function getParameterNameLabel(parameter: FilterParameter) {diff --git a/client/src/app/[site]/components/shared/Map.tsx b/client/src/app/[site]/components/shared/Map.tsxindex 505e74347..87145bf35 100644--- a/client/src/app/[site]/components/shared/Map.tsx+++ b/client/src/app/[site]/components/shared/Map.tsx@@ -1,18 +1,19 @@"use client";+import { FilterParameter } from "@rybbit/shared";import { useSingleCol } from "@/api/analytics/useSingleCol";import { useMeasure } from "@uidotdev/usehooks";import { scalePow } from "d3-scale";import { Feature, GeoJsonObject } from "geojson";import { Layer } from "leaflet";import "leaflet/dist/leaflet.css";+import { round } from "lodash";import { useEffect, useMemo, useState } from "react";import { GeoJSON, MapContainer, useMapEvent } from "react-leaflet";+import { getCountryPopulation } from "../../../../lib/countryPopulation";import { useCountries, useSubdivisions } from "../../../../lib/geo";-import { addFilter, FilterParameter } from "../../../../lib/store";+import { addFilter } from "../../../../lib/store";import { CountryFlag } from "./icons/CountryFlag";-import { getCountryPopulation } from "../../../../lib/countryPopulation";-import { round } from "lodash";interface TooltipContent {name: string;diff --git a/client/src/app/[site]/components/shared/StandardSection/Row.tsx b/client/src/app/[site]/components/shared/StandardSection/Row.tsxindex 796aed146..ae749b959 100644--- a/client/src/app/[site]/components/shared/StandardSection/Row.tsx+++ b/client/src/app/[site]/components/shared/StandardSection/Row.tsx@@ -1,3 +1,4 @@+import { FilterParameter } from "@rybbit/shared";import NumberFlow from "@number-flow/react";import { round } from "lodash";import { ChevronDown, ChevronRight, SquareArrowOutUpRight } from "lucide-react";@@ -6,7 +7,6 @@ import { usePaginatedSingleCol } from "../../../../../api/analytics/usePaginatedimport { SingleColResponse } from "../../../../../api/analytics/useSingleCol";import {addFilter,- FilterParameter,removeFilter,useStore,} from "../../../../../lib/store";diff --git a/client/src/app/[site]/components/shared/StandardSection/StandardSection.tsx b/client/src/app/[site]/components/shared/StandardSection/StandardSection.tsxindex f5288b6e1..2723091ce 100644--- a/client/src/app/[site]/components/shared/StandardSection/StandardSection.tsx+++ b/client/src/app/[site]/components/shared/StandardSection/StandardSection.tsx@@ -1,12 +1,12 @@"use client";+import { FilterParameter } from "@rybbit/shared";import { Button } from "@/components/ui/button";import { AlertCircle, Info, RefreshCcw } from "lucide-react";import { ReactNode } from "react";import { usePaginatedSingleCol } from "../../../../../api/analytics/usePaginatedSingleCol";import { SingleColResponse } from "../../../../../api/analytics/useSingleCol";import { CardLoader } from "../../../../../components/ui/card";-import { FilterParameter } from "../../../../../lib/store";import { StandardSectionDialog } from "./StandardSectionDialog";import { Row } from "./Row";import { Skeleton } from "./Skeleton";diff --git a/client/src/app/[site]/components/shared/StandardSection/StandardSectionDialog.tsx b/client/src/app/[site]/components/shared/StandardSection/StandardSectionDialog.tsxindex 01aeaf241..878d06c07 100644--- a/client/src/app/[site]/components/shared/StandardSection/StandardSectionDialog.tsx+++ b/client/src/app/[site]/components/shared/StandardSection/StandardSectionDialog.tsx@@ -24,7 +24,8 @@ import {import { ReactNode, useEffect, useMemo, useState } from "react";import { useInfiniteSingleCol } from "../../../../../api/analytics/useInfiniteSingleCol";import { SingleColResponse } from "../../../../../api/analytics/useSingleCol";-import { addFilter, FilterParameter } from "../../../../../lib/store";+import { FilterParameter } from "@rybbit/shared";+import { addFilter } from "../../../../../lib/store";import { cn, formatSecondsAsMinutesAndSeconds } from "../../../../../lib/utils";interface StandardSectionDialogProps {diff --git a/client/src/app/[site]/funnels/components/CreateFunnel.tsx b/client/src/app/[site]/funnels/components/CreateFunnel.tsxindex 6064d4c1f..7eb1eb185 100644--- a/client/src/app/[site]/funnels/components/CreateFunnel.tsx+++ b/client/src/app/[site]/funnels/components/CreateFunnel.tsx@@ -20,7 +20,7 @@ import { useState } from "react";import { toast } from "sonner";import { getStartAndEndDate } from "../../../../api/utils";import { FunnelForm } from "./FunnelForm";-import { Filter } from "../../../../lib/store";+import { Filter } from "@rybbit/shared";export function CreateFunnelDialog() {const [open, setOpen] = useState(false);diff --git a/client/src/app/[site]/funnels/components/EditFunnel.tsx b/client/src/app/[site]/funnels/components/EditFunnel.tsxindex 94d1145d9..2774e27aa 100644--- a/client/src/app/[site]/funnels/components/EditFunnel.tsx+++ b/client/src/app/[site]/funnels/components/EditFunnel.tsx@@ -17,7 +17,7 @@ import { DateTime } from "luxon";import { useEffect, useState } from "react";import { toast } from "sonner";import { getStartAndEndDate } from "../../../../api/utils";-import { Filter } from "../../../../lib/store";+import { Filter } from "@rybbit/shared";import { FunnelForm } from "./FunnelForm";interface EditFunnelDialogProps {diff --git a/client/src/app/[site]/funnels/components/FunnelForm.tsx b/client/src/app/[site]/funnels/components/FunnelForm.tsxindex db4e81f4d..2b3d6d2c1 100644--- a/client/src/app/[site]/funnels/components/FunnelForm.tsx+++ b/client/src/app/[site]/funnels/components/FunnelForm.tsx@@ -13,7 +13,7 @@ import {import { ListFilterPlus, Plus, Save, Trash2 } from "lucide-react";import { useState } from "react";import { ThreeDotLoader } from "../../../../components/Loaders";-import { Filter } from "../../../../lib/store";+import { Filter } from "@rybbit/shared";import { FilterComponent } from "../../components/shared/Filters/FilterComponent";import { Funnel } from "./Funnel";import { SavedFunnel } from "../../../../api/analytics/useGetFunnels";diff --git a/client/src/app/[site]/main/components/MainSection/Chart.tsx b/client/src/app/[site]/main/components/MainSection/Chart.tsxindex fd596d65c..5a110d777 100644--- a/client/src/app/[site]/main/components/MainSection/Chart.tsx+++ b/client/src/app/[site]/main/components/MainSection/Chart.tsx@@ -1,6 +1,7 @@"use client";+import { TimeBucket } from "@rybbit/shared";import { nivoTheme } from "@/lib/nivo";-import { StatType, TimeBucket, useStore } from "@/lib/store";+import { StatType, useStore } from "@/lib/store";import {LineCustomSvgLayer,LineCustomSvgLayerProps,diff --git a/client/src/app/[site]/pages/components/PageListItem.tsx b/client/src/app/[site]/pages/components/PageListItem.tsxindex 6798984ae..b77fe43c3 100644--- a/client/src/app/[site]/pages/components/PageListItem.tsx+++ b/client/src/app/[site]/pages/components/PageListItem.tsx@@ -8,7 +8,8 @@ import {import { SingleColResponse } from "@/api/analytics/useSingleCol";import { usePageMetadata } from "@/api/usePageMetadata";import { Card, CardContent } from "@/components/ui/card";-import { Filter, useStore } from "@/lib/store";+import { Filter } from "@rybbit/shared";+import { useStore } from "@/lib/store";import { truncateString } from "@/lib/utils";import { formatShortDuration } from "@/lib/dateTimeUtils";import { ExternalLink } from "lucide-react";diff --git a/client/src/app/[site]/performance/components/PerformanceTable.tsx b/client/src/app/[site]/performance/components/PerformanceTable.tsxindex 6e74894d4..ce34c2591 100644--- a/client/src/app/[site]/performance/components/PerformanceTable.tsx+++ b/client/src/app/[site]/performance/components/PerformanceTable.tsx@@ -33,11 +33,11 @@ import {useGetPerformanceByDimension,} from "../../../../api/analytics/useGetPerformanceByDimension";import { TablePagination } from "../../../../components/pagination";+import { FilterParameter } from "@rybbit/shared";import {useStore,addFilter,removeFilter,- FilterParameter,} from "../../../../lib/store";import { PerformanceMetric, usePerformanceStore } from "../performanceStore";import {diff --git a/client/src/lib/store.ts b/client/src/lib/store.tsindex b5e10fcab..1b34490b2 100644--- a/client/src/lib/store.ts+++ b/client/src/lib/store.ts@@ -1,18 +1,8 @@+import { Filter, FilterParameter, FilterType, TimeBucket } from "@rybbit/shared";import { DateTime } from "luxon";import { create } from "zustand";import { Time } from "../components/DateSelector/types";-export type TimeBucket =- | "minute"- | "five_minutes"- | "ten_minutes"- | "fifteen_minutes"- | "hour"- | "day"- | "week"- | "month"- | "year";-export type StatType =| "pageviews"| "sessions"@@ -21,35 +11,6 @@ export type StatType =| "bounce_rate"| "session_duration";-export type FilterType = "equals" | "not_equals" | "contains" | "not_contains";--export type FilterParameter =- | "browser"- | "operating_system"- | "language"- | "country"- | "region"- | "city"- | "device_type"- | "referrer"- | "hostname"- | "pathname"- | "page_title"- | "querystring"- | "event_name"- | "channel"- | "utm_source"- | "utm_medium"- | "utm_campaign"- | "utm_term"- | "utm_content"- // derivative parameters- | "entry_page"- | "exit_page"- | "dimensions"- | "browser_version"- | "operating_system_version";-export const SESSION_PAGE_FILTERS: FilterParameter[] = ["hostname","browser",@@ -130,12 +91,6 @@ export const USER_PAGE_FILTERS: FilterParameter[] = ["referrer",];-export type Filter = {- parameter: FilterParameter;- value: string[];- type: FilterType;-};-type Store = {site: string;setSite: (site: string) => void;diff --git a/client/src/lib/urlParams.ts b/client/src/lib/urlParams.tsindex ca6a5dbd2..7ac2c57e3 100644--- a/client/src/lib/urlParams.ts+++ b/client/src/lib/urlParams.ts@@ -1,7 +1,8 @@+import { Filter, TimeBucket } from "@rybbit/shared";import { usePathname, useRouter, useSearchParams } from "next/navigation";import React, { useEffect } from "react";import { Time } from "../components/DateSelector/types";-import { Filter, StatType, TimeBucket, useStore } from "./store";+import { StatType, useStore } from "./store";// Serialize store state to URL parametersexport const serializeStateToUrl = (diff --git a/docker-compose.cloud.yml b/docker-compose.cloud.ymlindex 2247f5038..9a6e15700 100644--- a/docker-compose.cloud.yml+++ b/docker-compose.cloud.yml@@ -64,8 +64,8 @@ services:backend:container_name: backendbuild:- context: ./server- dockerfile: Dockerfile+ context: .+ dockerfile: ./server/Dockerfileenvironment:- NODE_ENV=production- CLICKHOUSE_HOST=http://clickhouse:8123@@ -100,8 +100,8 @@ services:client:container_name: clientbuild:- context: ./client- dockerfile: Dockerfile+ context: .+ dockerfile: ./client/Dockerfileargs:NEXT_PUBLIC_BACKEND_URL: ${BASE_URL}NEXT_PUBLIC_DISABLE_SIGNUP: ${DISABLE_SIGNUP}diff --git a/docker-compose.dev.yml b/docker-compose.dev.ymlindex 5e87c689a..9049d54f4 100644--- a/docker-compose.dev.yml+++ b/docker-compose.dev.yml@@ -64,8 +64,8 @@ services:backend:container_name: backendbuild:- context: ./server- dockerfile: Dockerfile+ context: .+ dockerfile: server/Dockerfileenvironment:- NODE_ENV=production- CLICKHOUSE_HOST=http://clickhouse:8123@@ -100,8 +100,8 @@ services:client:container_name: clientbuild:- context: ./client- dockerfile: Dockerfile+ context: .+ dockerfile: client/Dockerfileargs:NEXT_PUBLIC_BACKEND_URL: ${BASE_URL}NEXT_PUBLIC_DISABLE_SIGNUP: ${DISABLE_SIGNUP}diff --git a/docker-compose.yml b/docker-compose.ymlindex 227a556db..e273a2d79 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -69,8 +69,8 @@ services:image: ghcr.io/rybbit-io/rybbit-backend:${IMAGE_TAG:-latest}container_name: backendbuild:- context: ./server- dockerfile: Dockerfile+ context: .+ dockerfile: server/Dockerfileports:- "${HOST_BACKEND_PORT}"environment:@@ -103,8 +103,8 @@ services:image: ghcr.io/rybbit-io/rybbit-client:${IMAGE_TAG:-latest}container_name: clientbuild:- context: ./client- dockerfile: Dockerfile+ context: .+ dockerfile: client/Dockerfileargs:NEXT_PUBLIC_BACKEND_URL: ${BASE_URL}NEXT_PUBLIC_DISABLE_SIGNUP: ${DISABLE_SIGNUP}diff --git a/memory-bank/activeContext.md b/memory-bank/activeContext.mdindex 71ba8a7ee..8cf9198e9 100644--- a/memory-bank/activeContext.md+++ b/memory-bank/activeContext.md@@ -18,3 +18,5 @@ This file tracks the project's current status, including recent changes, current- Are there any known technical debt items or performance issues to address? (Previously existing)- What new features or enhancements are planned for the platform? (Previously existing)- Are there any deployment or infrastructure concerns that need attention? (Previously existing)++[2025-06-08 06:42:07] - Docker build diagnosis confirmed: Build context mismatch identified as root cause. COPY shared ./shared fails because shared/ directory not present in ./server context. Dockerfiles from commit 974e6cc expect monorepo root context but CI uses subdirectory contexts.diff --git a/memory-bank/decisionLog.md b/memory-bank/decisionLog.mdindex 32a855e40..04235991f 100644--- a/memory-bank/decisionLog.md+++ b/memory-bank/decisionLog.md@@ -21,3 +21,5 @@ Implemented a comprehensive Memory Bank system to maintain project context acros- Established initial project context based on projectBrief.md- Set up tracking mechanisms for ongoing development activities- Prepared framework for documenting future architectural decisions and patterns++[2025-06-08 06:53:49] - Docker Build Context Fix: Changed all build contexts from subdirectory (./client, ./server) to monorepo root (.) in docker-compose.cloud.yml and GitHub Actions workflow. Updated Dockerfiles to use correct paths from monorepo root (e.g., COPY client/package.json instead of COPY package.json). This resolves the shared package access issue while maintaining compatibility between local and CI builds.diff --git a/server/Dockerfile b/server/Dockerfileindex 6154634aa..ac2495532 100644--- a/server/Dockerfile+++ b/server/Dockerfile@@ -4,12 +4,18 @@ FROM node:20-alpine AS builderWORKDIR /app-# Install dependencies-COPY package*.json ./+# Copy and build shared package first+COPY shared ./shared+WORKDIR /app/shared+RUN npm install && npm run build++# Install server dependencies+WORKDIR /app/server+COPY server/package*.json ./RUN npm ci-# Copy source code-COPY . .+# Copy server source code+COPY server/ .# Build the applicationRUN npm run build@@ -23,14 +29,15 @@ WORKDIR /appRUN apk add --no-cache postgresql-client# Copy built application and dependencies-COPY --from=builder /app/package*.json ./-COPY --from=builder /app/GeoLite2-City.mmdb ./GeoLite2-City.mmdb-COPY --from=builder /app/dist ./dist-COPY --from=builder /app/node_modules ./node_modules-COPY --from=builder /app/docker-entrypoint.sh /docker-entrypoint.sh-COPY --from=builder /app/drizzle.config.ts ./drizzle.config.ts-COPY --from=builder /app/public ./public-COPY --from=builder /app/src ./src+COPY --from=builder /app/server/package*.json ./+COPY --from=builder /app/server/GeoLite2-City.mmdb ./GeoLite2-City.mmdb+COPY --from=builder /app/server/dist ./dist+COPY --from=builder /app/server/node_modules ./node_modules+COPY --from=builder /app/server/docker-entrypoint.sh /docker-entrypoint.sh+COPY --from=builder /app/server/drizzle.config.ts ./drizzle.config.ts+COPY --from=builder /app/server/public ./public+COPY --from=builder /app/server/src ./src+COPY --from=builder /app/shared ./shared# Make the entrypoint executableRUN chmod +x /docker-entrypoint.shdiff --git a/server/package-lock.json b/server/package-lock.jsonindex ef0dddf5a..8632c91dc 100644--- a/server/package-lock.json+++ b/server/package-lock.json@@ -14,6 +14,7 @@"@fastify/one-line-logger": "2.0.2","@fastify/static": "8.1.1","@maxmind/geoip2-node": "6.1.0",+ "@rybbit/shared": "file:../shared","better-auth": "1.2.7","dotenv": "16.5.0","drizzle-orm": "0.43.1",@@ -47,6 +48,15 @@"vitest": "^3.2.2"}},+ "../shared": {+ "name": "@rybbit/shared",+ "version": "1.0.0",+ "license": "MIT",+ "devDependencies": {+ "@types/node": "^20.10.6",+ "typescript": "^5.3.3"+ }+ },"node_modules/@better-auth/stripe": {"version": "1.2.7","resolved": "https://registry.npmjs.org/@better-auth/stripe/-/stripe-1.2.7.tgz",@@ -1653,6 +1663,10 @@"win32"]},+ "node_modules/@rybbit/shared": {+ "resolved": "../shared",+ "link": true+ },"node_modules/@selderee/plugin-htmlparser2": {"version": "0.11.0","resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.11.0.tgz",diff --git a/server/package.json b/server/package.jsonindex 66e7a0db5..6b4412497 100644--- a/server/package.json+++ b/server/package.json@@ -20,6 +20,7 @@"db:check": "drizzle-kit check --config=drizzle.config.ts"},"dependencies": {+ "@rybbit/shared": "file:../shared","@better-auth/stripe": "1.2.7","@clickhouse/client": "1.11.1","@fastify/cors": "11.0.1",diff --git a/server/src/api/analytics/createFunnel.ts b/server/src/api/analytics/createFunnel.tsindex a5f668786..c2f587d18 100644--- a/server/src/api/analytics/createFunnel.ts+++ b/server/src/api/analytics/createFunnel.ts@@ -3,6 +3,7 @@ import { FastifyReply, FastifyRequest } from "fastify";import { db } from "../../db/postgres/postgres.js";import { funnels as funnelsTable } from "../../db/postgres/schema.js";import { getUserHasAccessToSite } from "../../lib/auth-utils.js";+import { Filter } from "./types.js";type FunnelStep = {value: string;@@ -10,12 +11,6 @@ type FunnelStep = {type: "page" | "event";};-type Filter = {- parameter: string;- type: string;- value: string[];-};-type Funnel = {steps: FunnelStep[];name: string;diff --git a/server/src/api/analytics/getFunnel.ts b/server/src/api/analytics/getFunnel.tsindex 2496e4839..ca0eeca16 100644--- a/server/src/api/analytics/getFunnel.ts+++ b/server/src/api/analytics/getFunnel.ts@@ -9,6 +9,7 @@ import {} from "./utils.js";import { getUserHasAccessToSitePublic } from "../../lib/auth-utils.js";import SqlString from "sqlstring";+import { Filter } from "./types.js";type FunnelStep = {value: string;@@ -18,12 +19,6 @@ type FunnelStep = {eventPropertyValue?: string | number | boolean;};-type Filter = {- parameter: string;- type: string;- value: string[];-};-type Funnel = {steps: FunnelStep[];startDate: string;diff --git a/server/src/api/analytics/types.ts b/server/src/api/analytics/types.tsindex b480557bd..170601105 100644--- a/server/src/api/analytics/types.ts+++ b/server/src/api/analytics/types.ts@@ -1,54 +1,23 @@-export type FilterType = "equals" | "not_equals" | "contains" | "not_contains";--export type FilterParameter =- | "browser"- | "operating_system"- | "language"- | "country"- | "region"- | "city"- | "device_type"- | "referrer"- | "hostname"- | "pathname"- | "page_title"- | "querystring"- | "event_name"- | "channel"- | "utm_source"- | "utm_medium"- | "utm_campaign"- | "utm_term"- | "utm_content"- // derivative parameters- | "entry_page"- | "exit_page"- | "dimensions"- | "browser_version"- | "operating_system_version";--export type Filter = {- parameter: FilterParameter;- value: string[];- type: FilterType;+// Import and re-export shared types+import type {+ Filter,+ FilterType,+ FilterParameter,+ TimeBucket,+ WebVitalMetric,+ PercentileLevel+} from "@rybbit/shared";++// Re-export for other modules+export {+ Filter,+ FilterType,+ FilterParameter,+ TimeBucket,+ WebVitalMetric,+ PercentileLevel};-// Performance-related types-export type WebVitalMetric = "lcp" | "cls" | "inp" | "fcp" | "ttfb";--export type PercentileLevel = "p50" | "p75" | "p90" | "p99";--export type TimeBucket =- | "minute"- | "five_minutes"- | "ten_minutes"- | "fifteen_minutes"- | "hour"- | "day"- | "week"- | "month"- | "year";-export type PerformanceOverviewMetrics = {[K in WebVitalMetric as `${K}_${PercentileLevel}`]: number | null;} & {diff --git a/server/src/db/postgres/schema.ts b/server/src/db/postgres/schema.tsindex 5c4aa01d0..f590bcdf7 100644--- a/server/src/db/postgres/schema.ts+++ b/server/src/db/postgres/schema.ts@@ -52,7 +52,7 @@ export const sites = pgTable({siteId: serial("site_id").primaryKey().notNull(),name: text("name").notNull(),- domain: text("domain").notNull().unique(),+ domain: text("domain").notNull(),createdAt: timestamp("created_at").defaultNow(),updatedAt: timestamp("updated_at").defaultNow(),createdBy: text("created_by")diff --git a/shared/.gitignore b/shared/.gitignorenew file mode 100644index 000000000..7bd106894--- /dev/null+++ b/shared/.gitignore@@ -0,0 +1,4 @@+node_modules/+dist/+*.log+.DS_Store\ No newline at end of filediff --git a/shared/package-lock.json b/shared/package-lock.jsonnew file mode 100644index 000000000..d2fd97304--- /dev/null+++ b/shared/package-lock.json@@ -0,0 +1,45 @@+{+ "name": "@rybbit/shared",+ "version": "1.0.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "@rybbit/shared",+ "version": "1.0.0",+ "license": "MIT",+ "devDependencies": {+ "@types/node": "^20.10.6",+ "typescript": "^5.3.3"+ }+ },+ "node_modules/@types/node": {+ "version": "20.19.0",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.0.tgz",+ "integrity": "sha512-hfrc+1tud1xcdVTABC2JiomZJEklMcXYNTVtZLAeqTVWD+qL5jkHKT+1lOtqDdGxt+mB53DTtiz673vfjU8D1Q==",+ "dev": true,+ "dependencies": {+ "undici-types": "~6.21.0"+ }+ },+ "node_modules/typescript": {+ "version": "5.8.3",+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",+ "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",+ "dev": true,+ "bin": {+ "tsc": "bin/tsc",+ "tsserver": "bin/tsserver"+ },+ "engines": {+ "node": ">=14.17"+ }+ },+ "node_modules/undici-types": {+ "version": "6.21.0",+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",+ "dev": true+ }+ }+}diff --git a/shared/package.json b/shared/package.jsonnew file mode 100644index 000000000..b495a8328--- /dev/null+++ b/shared/package.json@@ -0,0 +1,20 @@+{+ "name": "@rybbit/shared",+ "version": "1.0.0",+ "description": "Shared types for Rybbit analytics",+ "main": "./dist/index.js",+ "types": "./dist/index.d.ts",+ "files": [+ "dist"+ ],+ "scripts": {+ "build": "tsc",+ "dev": "tsc --watch",+ "clean": "rm -rf dist"+ },+ "devDependencies": {+ "@types/node": "^20.10.6",+ "typescript": "^5.3.3"+ },+ "license": "MIT"+}\ No newline at end of filediff --git a/shared/src/filters.ts b/shared/src/filters.tsnew file mode 100644index 000000000..431762811--- /dev/null+++ b/shared/src/filters.ts@@ -0,0 +1,33 @@+export type FilterType = "equals" | "not_equals" | "contains" | "not_contains";++export type FilterParameter =+ | "browser"+ | "operating_system"+ | "language"+ | "country"+ | "region"+ | "city"+ | "device_type"+ | "referrer"+ | "hostname"+ | "pathname"+ | "page_title"+ | "querystring"+ | "event_name"+ | "channel"+ | "utm_source"+ | "utm_medium"+ | "utm_campaign"+ | "utm_term"+ | "utm_content"+ | "entry_page"+ | "exit_page"+ | "dimensions"+ | "browser_version"+ | "operating_system_version";++export interface Filter {+ parameter: FilterParameter;+ value: string[];+ type: FilterType;+}\ No newline at end of filediff --git a/shared/src/index.ts b/shared/src/index.tsnew file mode 100644index 000000000..31c424999--- /dev/null+++ b/shared/src/index.ts@@ -0,0 +1,8 @@+export * from "./filters";+export * from "./time";+export * from "./performance";+// export * from "./goals";+// export * from "./funnels";+// export * from "./pagination";+// export * from "./analytics";+// export * from "./events";diff --git a/shared/src/performance.ts b/shared/src/performance.tsnew file mode 100644index 000000000..faf8ea679--- /dev/null+++ b/shared/src/performance.ts@@ -0,0 +1,37 @@+export type WebVitalMetric = "lcp" | "cls" | "inp" | "fcp" | "ttfb";+export type PercentileLevel = "p50" | "p75" | "p90" | "p99";++export interface PerformanceOverviewMetrics {+ lcp: number;+ fcp: number;+ cls: number;+ inp: number;+ ttfb: number;+}++export interface PerformanceTimeSeriesPoint {+ time: string;+ p50: number;+ p75: number;+ p90: number;+ p99: number;+}++export interface PerformanceByPathItem {+ path: string;+ page_title: string;+ sample_count: number;+ p50: number;+ p75: number;+ p90: number;+ p99: number;+}++export interface PerformanceByDimensionItem {+ dimension: string;+ page_count: number;+ p50: number;+ p75: number;+ p90: number;+ p99: number;+}\ No newline at end of filediff --git a/shared/src/time.ts b/shared/src/time.tsnew file mode 100644index 000000000..acdecad38--- /dev/null+++ b/shared/src/time.ts@@ -0,0 +1,10 @@+export type TimeBucket =+ | "minute"+ | "five_minutes"+ | "ten_minutes"+ | "fifteen_minutes"+ | "hour"+ | "day"+ | "week"+ | "month"+ | "year";diff --git a/shared/tsconfig.json b/shared/tsconfig.jsonnew file mode 100644index 000000000..fc05d0e13--- /dev/null+++ b/shared/tsconfig.json@@ -0,0 +1,20 @@+{+ "compilerOptions": {+ "target": "ES2020",+ "module": "commonjs",+ "lib": ["ES2020"],+ "declaration": true,+ "declarationMap": true,+ "outDir": "./dist",+ "rootDir": "./src",+ "strict": true,+ "esModuleInterop": true,+ "skipLibCheck": true,+ "forceConsistentCasingInFileNames": true,+ "resolveJsonModule": true,+ "moduleResolution": "node",+ "composite": true+ },+ "include": ["src/**/*"],+ "exclude": ["node_modules", "dist"]+}\ No newline at end of file