Commit graph

229 commits

Author SHA1 Message Date
Bill Yang
93a6639d2e
New env (#122)
* Allow setting all variables in .env file

* Fix postgres version

* pin versions

* bump

---------

Co-authored-by: pe1uca <edga.alva@gmail.com>
2025-05-05 20:31:11 -07:00
Bill Yang
7f3a338001 Add URL normalization to allowed domains
- Introduced a new function to normalize URL origins by removing the "www." prefix.
- Updated the allowed domains loading logic to apply normalization to each domain in the list.
2025-05-05 15:35:02 -07:00
Andrii Andrushchyshyn
f4ca270abe
Fix users page (sorting) (#114)
* fix sortings in users page
* use DESC sorting by default
2025-05-06 01:04:11 +03:00
Bill Yang
09f0568d14 Remove example HTML file and fix script tag formatting in ScriptBuilder component 2025-05-04 09:23:41 -07:00
Bill Yang
24aa7e54c5
fix usage checker (#109)
* fix usage checker

* fix

* fix tax
2025-05-03 23:19:59 -07:00
Bill Yang
0f43f62103 Refactor Stripe pricing retrieval and update pricing constants
- Replaced direct usage of STRIPE_PRICES with a new getStripePrices function for improved flexibility in pricing retrieval.
- Updated pricing details in the STRIPE_PRICES constant to reflect new price IDs.
- Enhanced subscription handling in various components to utilize the updated pricing structure.
2025-05-03 22:51:42 -07:00
Bill Yang
e1adb3a2a3 Update subscription pricing and improve subscription handling
- Changed subscription cancellation message from "Ends on" to "Cancels on" for clarity.
- Updated subscription data structure to require `cancelAtPeriodEnd` field.
- Adjusted Stripe pricing for various plans, increasing monthly and annual prices.
- Modified pricing display logic in the PricingSection component to reflect new prices.
- Increased default event limit for users without an active subscription from 10,000 to 100,000.
- Enhanced subscription retrieval to include `cancelAtPeriodEnd` status.
2025-05-03 22:17:41 -07:00
Bill Yang
696c6b6145
Fix allow (#108)
* fix allow

* wip

* wio
2025-05-03 22:06:08 -07:00
Bill Yang
e0a8634a35 Enhance CORS handling and add origin normalization
- Updated CORS origin validation to use a new `normalizeOrigin` function, ensuring consistent handling of incoming requests.
- Introduced `normalizeOrigin` utility to standardize URLs by removing the 'www.' prefix.
- Adjusted allowed domains loading to directly use domain names without adding 'https://' prefix, improving flexibility.
2025-05-03 17:34:08 -07:00
Bill Yang
97c29dafac
Fix callbacks (#107)
* Fix callbacks

* fix layout

* Remove callbacks

* Disable redirects

* fix caddy

* test disable basepath

* wip

* test caddy fix

* remove basepath

* fml

* pray

* kms

* pray

* wip

* Test
2025-05-03 16:27:46 -07:00
Bill Yang
1d0ffdf9d9 Refactor authentication and environment configuration
- Removed the .env.example file as it is no longer needed.
- Added DISABLE_SIGNUP environment variable to docker-compose files for cloud and development environments.
- Updated setup script to include DISABLE_SIGNUP with a default value of false.
- Modified auth.ts to utilize DISABLE_SIGNUP for controlling signup functionality.
- Introduced DISABLE_SIGNUP constant in const.ts to manage its value from environment variables.
2025-05-03 13:14:13 -07:00
Bill Yang
990861aca6 Enhance site management with domain handling
- Added domain property to site configuration in addSite and changeSiteDomain functions.
- Implemented domain retrieval and update methods in SiteConfig class.
- Introduced origin validation in trackEvent to ensure requests come from registered domains, improving security.
- Added a constant to disable origin checking for development environments.
2025-05-03 12:59:01 -07:00
Bill Yang
55bf9c60f7 try to fix sso 2025-05-03 12:05:25 -07:00
Bill Yang
d3cb3a5a82 try to fix sso 2025-05-03 12:03:43 -07:00
Bill Yang
b34aff1153 Update environment variables for cloud integration in Docker configurations
- Added GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET to both docker-compose files for cloud support.
- Included GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET in the environment variables.
- Updated the auth.ts file to enable social login providers for cloud deployments.
2025-05-03 11:43:09 -07:00
Bill Yang
ddcb5704d1 Refactor ProPlan component and enhance subscription management features
- Renamed handleManageSubscription to createPortalSession for clarity and added flowType parameter to support different subscription actions.
- Introduced new handlers for changing, viewing, and canceling subscriptions, improving user interaction with the subscription management process.
- Updated UI to include separate buttons for changing plans, viewing subscription details, and canceling subscriptions, enhancing user experience and accessibility.
- Modified createPortalSession API to handle different flow types for subscription updates and cancellations, ensuring proper session management with Stripe.
2025-05-02 17:31:40 -07:00
Bill Yang
191e4c27e4 Update UI elements and enhance pricing page layout
- Changed button text from "Get Started for Free" to "Start 14 day free trial" for clarity.
- Removed the "No credit card required. Free plan available for small projects." text to simplify messaging.
- Improved the pricing page layout with background gradients for a more visually appealing design.
- Adjusted slider component styles for better user interaction and aesthetics.
- Cleaned up code formatting for consistency across components.
2025-05-02 15:58:12 -07:00
Bill Yang
7ab608eddb Update dependencies and enhance documentation structure
- Added @radix-ui/react-slider dependency to package.json and package-lock.json for improved UI components.
- Introduced a new pricing page metadata in _meta.js to enhance site navigation.
- Adjusted trial event limit in monthly-usage-checker.ts to better reflect user subscription tiers.
2025-05-02 15:37:04 -07:00
Bill Yang
b220d01a70
events (#103)
* events

* wip

* Remove standardsection

* Enhance EventList and EventProperties components with loading skeletons and size prop

- Added a loading skeleton to EventList and EventProperties components for improved user experience during data fetching.
- Introduced a size prop to both components to allow for flexible rendering of elements based on size (small or large).
- Updated EventsPage to pass the size prop to EventList for consistent styling.

* Implement pagination and filtering for event retrieval

- Enhanced the analytics API to support pagination and filtering for event data retrieval.
- Introduced a new endpoint for fetching events with pagination and filtering capabilities.
- Updated the `useGetEvents` hook to support infinite scrolling and real-time updates.
- Added a new `EventLog` component to the EventsPage for better event tracking.
- Refactored existing event fetching logic to accommodate new query parameters and maintain backward compatibility.
2025-05-02 13:24:30 -07:00
Bill Yang
46fdce73dd Enhance user information and analytics components
- Added 'city' field to UserInfo type and updated related API to include city data.
- Introduced getLanguageName utility function for improved language display in user and session details.
- Updated UserPage and SessionDetails components to display city and formatted language information.
- Refactored Countries component to remove redundant language name logic, utilizing the new utility function instead.
2025-05-01 16:48:00 -07:00
Bill Yang
611d8ac088 Refactor analytics to utilize structured URL parameters
- Updated the analytics API to extract UTM parameters from a new structured `url_parameters` map instead of individual fields.
- Refactored SQL query generation to use a unified `getSqlParam` function for improved consistency and maintainability.
- Enhanced the `PageviewQueue` to capture all URL parameters, streamlining data collection for analytics.
- Introduced a new utility function, `getAllUrlParams`, to parse and manage URL parameters effectively.
2025-04-30 22:56:10 -07:00
Bill Yang
41c4f63742 Enhance analytics and filters with UTM parameters
- Updated the analytics API and data models to include UTM parameters: utm_source, utm_medium, utm_campaign, utm_term, and utm_content.
- Refactored the useGetGoals and useGetSessions functions to utilize filtered UTM parameters for improved data retrieval.
- Enhanced the Filters component to support UTM parameters, adding new filter options and updating the UI accordingly.
- Updated the Referrers section to include tabs for UTM parameters, allowing users to filter and analyze data based on UTM attributes.
- Improved documentation and type definitions to reflect the addition of UTM parameters across the application.
2025-04-30 21:51:52 -07:00
Bill Yang
5525e99ebb Refactor analytics queries to utilize events table for session data
- Updated the getSession function to derive session data from the events table, enhancing data accuracy and detail.
- Modified the getUserSessionCount function to count distinct session IDs from events instead of sessions, improving session tracking.
- Removed obsolete session table creation and materialized view definitions from Clickhouse initialization, streamlining the database setup.
2025-04-30 17:58:10 -07:00
Bill Yang
9b38ed2e23 Refactor analytics API to support funnel management
- Replaced the deleteReport functionality with deleteFunnel, allowing for the deletion of funnels instead of reports.
- Updated the createFunnel API to reference the new funnels table and adjusted error handling for funnel existence and ownership checks.
- Modified the getFunnels API to fetch data from the funnels table, ensuring consistency in data retrieval.
- Removed the obsolete deleteReport file and updated schema to reflect the new funnels structure.
2025-04-30 17:09:02 -07:00
Bill Yang
f8b579511b Enhance funnel step functionality with event property filtering
- Added support for event property key and value in FunnelStep type to allow filtering based on event properties.
- Updated FunnelForm component to manage property filtering state and toggle functionality for event steps.
- Enhanced FunnelRow component to display event property information when applicable.
- Modified getFunnel API to include property matching in event queries, improving analytics capabilities.
2025-04-28 22:56:31 -07:00
Bill Yang
fb31a0c160 Enhance FunnelForm component layout and functionality
- Adjusted grid layout for better spacing in the FunnelForm.
- Updated card padding for Funnel Steps and Filters sections to improve visual consistency.
- Enhanced input fields with additional styling and placeholder text for clarity.
- Implemented wildcard path matching support in the analytics API for funnel steps, improving flexibility in path definitions.
2025-04-28 22:46:28 -07:00
Bill Yang
ca0faeb484
Add goal management functionality in analytics (#100)
* Add goal management functionality in analytics

- Introduced goal creation, deletion, and updating capabilities in the analytics API, allowing users to define conversion goals based on path or event types.
- Implemented corresponding React hooks for managing goals, including fetching, creating, updating, and deleting goals.
- Enhanced the UI with a dedicated Goals page and components for listing and managing goals, improving user experience in tracking conversions.
- Updated package dependencies to include necessary libraries for form handling and validation.

* Enhance goals management with pagination and sorting

- Added pagination and sorting capabilities to the goals fetching logic in the analytics API, allowing users to navigate through goals more efficiently.
- Updated the GoalsPage component to manage current page state and handle page changes, improving user experience.
- Modified the GoalsList component to display pagination metadata and navigation controls, facilitating better goal management.
- Adjusted the server-side getGoals function to support pagination and sorting parameters, ensuring accurate data retrieval.

* Refactor GoalsPage and GoalCard components for improved UI and functionality

- Updated GoalsPage to include a SubHeader component and adjusted layout for better responsiveness.
- Enhanced loading and empty state handling in GoalsPage for a smoother user experience.
- Modified GoalCard to use icons for goal types, improving visual clarity and consistency in the UI.

* Refactor CreateGoalButton and GoalCard components for improved modal handling

- Updated CreateGoalButton to utilize a trigger prop for the GoalFormModal, simplifying modal state management.
- Refactored GoalCard to integrate GoalFormModal for editing goals, enhancing user interaction and reducing state complexity.
- Removed unnecessary state management and modal handling from both components, streamlining the codebase.

* Refactor GoalCard and Clickhouse initialization for improved code clarity

- Removed unnecessary imports in GoalCard component, streamlining the code.
- Updated Clickhouse initialization to include a new 'props' JSON field alongside 'properties', enhancing data structure for analytics.
- Added a utility function in PageviewQueue to parse properties, improving error handling and data integrity.

* enable clickhouse

* fix ch build

* fix ch build

* fix ch build

* wip

* wip

* wip

* Enable json

* add network

* add network

* Refactor Clickhouse configuration and remove unused properties from data models

* Refactor property value handling in analytics queries to utilize native JSON types in ClickHouse, improving type safety and performance.
2025-04-28 20:58:43 -07:00
Bill Yang
db1bbe2fb1 Update deleteSite response to include success status
- Modified the response of the deleteSite function to return a success message in the response body, enhancing clarity for the client regarding the operation's outcome.
2025-04-27 21:38:18 -07:00
Bill Yang
09e08d7f3c Refactor site access control and user permissions
- Updated the getSite function to utilize getUserHasAccessToSitePublic for improved access control based on user permissions.
- Introduced a godMode boolean in the user schema to allow users with elevated privileges to access all sites.
- Enhanced the getSitesUserHasAccessTo function to check for godMode status, enabling users with this privilege to retrieve all sites directly.
2025-04-27 19:43:11 -07:00
Bill Yang
1628b01b64
Free trial (#99)
* Refactor subscription management to introduce trial plan functionality

- Removed the FreePlan component and integrated trial plan logic into the SubscriptionPage.
- Added TrialPlan and ExpiredTrialPlan components to handle trial subscription states.
- Updated the useStripeSubscription hook to manage trial status and expiration messages.
- Adjusted constants and plan utilities to support trial duration and event limits.
- Enhanced the Subscribe page to reflect changes in plan selection and pricing structure.

* Add FreeTrialBanner component to Home and Header, and update plan utilities

- Integrated FreeTrialBanner into the Home and Header components to enhance user visibility of trial status.
- Introduced DEFAULT_EVENT_LIMIT constant to standardize event limits across subscription plans.
- Refactored plan utilities to include a free plan template with event limits and features for better clarity in subscription options.

* Refactor monthly usage checker to improve date handling and logging

- Updated getStartOfMonth function to use Luxon for date management, enhancing accuracy and readability.
- Adjusted user subscription info retrieval to use account creation date for trial users, ensuring correct event counting.
- Enhanced logging to provide clearer information about user subscriptions and event limits, improving traceability during usage checks.
2025-04-27 19:24:37 -07:00
Bill Yang
8fcfb58dc3 Implement authedFetchWithError for improved error handling in API requests
- Added a new utility function `authedFetchWithError` to handle fetch requests with error checking.
- Updated existing API calls in `organizations.ts`, `sites.ts`, and other files to utilize the new error handling function.
- Refactored the `getUserOrganizations`, `addSite`, `deleteSite`, and other functions to enhance error management and response handling.
- Adjusted the `getUserHasAccessToSite` function to support admin-only checks, improving authorization logic.
- Modified the `AddMemberDialog` to set the default role to "admin" for new members, enhancing user management capabilities.
2025-04-26 09:19:01 -07:00
Bill Yang
0d0b7c33b2 Add member functionality and organization management enhancements
- Introduced `AddMemberDialog` to facilitate adding members to organizations in the settings page.
- Updated the organization component layout for improved user experience and accessibility.
- Refactored member handling logic to ensure proper refresh and state management.
- Added a new API endpoint for adding users to organizations, enhancing backend functionality.
- Modified account creation to include organization association, improving user onboarding process.
2025-04-26 00:00:51 -07:00
Bill Yang
229df3982c Enhance SQL query handling in analytics API for improved security and maintainability
- Integrated `SqlString.escape` for parameterized inputs in `getLiveSessionLocations`, `getOverviewBucketed`, and `getSingleCol` to prevent SQL injection vulnerabilities.
- Refactored SQL query construction to ensure consistent escaping of parameters, enhancing overall code clarity and reliability.
- Improved limit handling in `getSingleCol` by validating and sanitizing the limit parameter, ensuring robust input validation.
2025-04-25 15:48:18 -07:00
Bill Yang
36c6205800 Refactor analytics API SQL queries for improved clarity and consistency
- Simplified SQL limit handling in `getSingleCol` by consolidating limit logic into a single statement.
- Updated `getUserSessionCount` to ensure consistent SQL string escaping for timezone parameters.
- Enhanced overall readability and maintainability of SQL query construction across analytics endpoints.
2025-04-25 15:41:36 -07:00
Bill Yang
42480f14fb Enhance analytics API with SQL string handling and validation improvements
- Added `sqlstring` package for safer SQL query construction across various analytics endpoints.
- Updated `getFunnel`, `getUserSessionCount`, and other functions to utilize `SqlString.escape` for parameterized inputs, enhancing security against SQL injection.
- Refactored input validation by replacing the `sql-sanitization` module with a new `query-validation` module, improving clarity and maintainability of parameter handling.
- Removed the deprecated `sql-sanitization.ts` file to streamline the codebase.
2025-04-25 15:37:27 -07:00
Bill Yang
227fe8cdec Enhance SQL sanitization module with comprehensive date and filter schemas
- Introduced detailed Zod schemas for date parameters, including validation for date format and timezone.
- Added new schemas for simplified date parameters and filter objects to improve input validation.
- Enhanced sanitization functions for `getTimeStatement` and `getFilterStatement` to ensure robust data handling and clarity in parameter validation.
2025-04-24 09:58:19 -07:00
Bill Yang
2d451b38f9 Refactor analytics API for improved parameter handling and input validation
- Updated SQL queries in `getFunnel`, `getLiveUsercount`, and `getOverviewBucketed` to utilize parameterized inputs for enhanced security and maintainability.
- Introduced a new `sql-sanitization.ts` module to validate and sanitize input parameters using Zod schemas, ensuring robust data handling.
- Refactored the `getTimeStatement` and `getFilterStatement` functions to incorporate input sanitization, improving code clarity and reliability.
2025-04-23 23:10:27 -07:00
Bill Yang
1726811398 Enhance analytics API and documentation for improved data handling and user clarity
- Updated various analytics API endpoints to utilize parameterized queries for better security and performance.
- Refactored the `getJourneys`, `getOverview`, and `getSessions` functions to improve query structure and readability.
- Enhanced the documentation in the `IndexPage` to provide clearer comparisons with other analytics tools and added new FAQs for user guidance.
- Introduced a refetch interval in the `useSiteHasData` hook to improve data freshness.
- Improved the `MapComponent` by integrating lodash for better number formatting.
2025-04-23 22:45:15 -07:00
Bill Yang
53d198a282 Enhance Tailwind configuration and update styles for data visualization
- Added a new `dataviz` color configuration in `tailwind.config.ts` for improved data visualization styling.
- Introduced a new CSS variable `--dataviz` in `globals.css` to define the color used for data visualization elements.
- Updated various components to utilize the new `dataviz` color, replacing previous `accent` colors for consistency in charts and UI elements.
- Adjusted background and hover styles in the `Weekdays` component to reflect the new color scheme.
2025-04-22 22:55:56 -07:00
Bill Yang
a1f4c60fb9 Add site settings for public analytics and user ID salting
- Enhanced the `addSite` function to accept optional settings for `isPublic` and `saltUserIds`.
- Updated the `AddSite` component to include toggles for public analytics visibility and user ID salting.
- Refactored the `SiteSettings` component to manage these new settings with appropriate UI elements and state management.
- Improved form reset functionality to ensure a clean state when opening the dialog.
2025-04-22 21:37:27 -07:00
Bill Yang
17ca7a6c2e Add saltUserIds to site response in getSite API
- Included the `saltUserIds` field in the response of the `getSite` function to enhance user ID salting management.
- This change supports the recent updates to site settings related to user ID security.
2025-04-22 20:41:24 -07:00
Bill Yang
afd3f68d5e Add user ID salting feature and update site settings
- Introduced a new boolean field `saltUserIds` in the `SiteResponse` and `GetSitesResponse` types to manage user ID salting.
- Implemented `changeSiteSalt` function to update the salting configuration for a site.
- Updated `SiteSettingsInner` component to include a toggle for enabling/disabling user ID salting, with appropriate UI feedback.
- Refactored server-side logic to replace `publicSites` with `siteConfig` for managing site configurations, including salting settings.
2025-04-22 20:37:54 -07:00
Bill Yang
b0ad344162 Update docker-entrypoint.sh to force database migrations during startup 2025-04-22 20:10:54 -07:00
Bill Yang
18851c3d0e Add daily salt generation for user ID hashing and new salt field in sites schema
- Introduced a new boolean field `saltUserIds` in the `sites` schema to manage user ID salting.
- Implemented `getDailySalt` function in `trackingUtils.ts` to generate a deterministic daily salt based on an environment variable, enhancing user ID security.
- Updated `getUserId` function to incorporate the daily salt in the hashing process for improved uniqueness and security.
2025-04-22 17:46:38 -07:00
Bill Yang
1c9b88a333 Refactor utils and tracking modules to streamline session management and device type detection
- Removed unused functions and constants from utils.ts, including various OS sets and the getUserId function.
- Introduced new session update logic in trackEvent.ts to handle both pageviews and events, ensuring accurate session tracking.
- Consolidated session management logic into a single updateSession function for clarity and efficiency.
- Added device type detection directly within the session creation process.
- Implemented IP address retrieval logic in trackingUtils.ts to enhance session tracking capabilities.
2025-04-22 17:28:41 -07:00
Bill Yang
2a3550358c update docker 2025-04-21 23:03:52 -07:00
Bill Yang
df26d8e8a9 Remove GeoLite2-City.mmdb database file and update geolocation.ts to adjust database path handling and improve error management for uninitialized reader. 2025-04-21 22:44:51 -07:00
Bill Yang
03152db284 Update package.json and package-lock.json to include @maxmind/geoip2-node dependency; refactor pageviewQueue to utilize local geolocation service for IP address tracking 2025-04-21 22:33:05 -07:00
Bill Yang
feff66e720
Add D3.js library and update Sidebar component (#94)
* Add D3.js library and update Sidebar component

* Enhance JourneysPage visualization and data handling

- Increased SVG dimensions for better visibility and layout.
- Expanded journey data processing to include more entries and track incoming/outgoing links for each node.
- Improved node representation by switching from circles to bars, with dynamic heights based on link values.
- Added tooltips to links for displaying counts and enhanced step labels with card backgrounds for better clarity.
- Updated API to adjust journey retrieval criteria and ensure accurate data types for counts and percentages.

* Add hover effects and unique identifiers to links in JourneysPage

- Implemented hover effects for links to enhance user interaction, making connected nodes and links more prominent.
- Added unique identifiers to each link for better tracking during interactions.
- Updated node bars, cards, and text to adjust opacity based on hover state for improved visual feedback.

* Refactor JourneysPage for improved data handling and visualization

- Introduced a constant for maximum link height to enhance visual consistency.
- Updated data handling to directly reference journey data, improving reliability.
- Adjusted SVG margins and dimensions for better layout.
- Enhanced node representation with additional percentage metrics displayed alongside counts.
- Modified text positioning and styling for improved readability and clarity in node cards.
- Expanded step selection options for user flexibility.

* Enhance JourneysPage functionality and data handling

- Introduced a maximum journeys selection feature to allow users to customize the number of journeys displayed.
- Updated timezone handling to dynamically reflect the user's local timezone.
- Adjusted the data processing logic to utilize the new maximum journeys setting for improved flexibility.
- Enhanced node card dimensions for better visual representation and readability.
- Modified text display in node cards to show counts in a localized format for improved clarity.
2025-04-20 13:52:08 -07:00
Bill Yang
c99068508c Enhance BaseStandardSectionDialog and getSingleCol API for improved data metrics
- Updated BaseStandardSectionDialog to display session and pageviews percentages with improved formatting.
- Enhanced getSingleCol API to calculate and return unique sessions and pageviews metrics, including their respective percentages for better analytics insights.
- Refined data handling in the dialog to ensure accurate representation of new metrics.
2025-04-19 22:32:29 -07:00