📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Make data warehouse integrations a Plus feature
Blue Mouse16564c835167
diff --git a/backend/apps/cloud/src/data-export/README.md b/backend/apps/cloud/src/data-export/README.mdindex e38bee4ed..afcfc5b63 100644--- a/backend/apps/cloud/src/data-export/README.md+++ b/backend/apps/cloud/src/data-export/README.md@@ -1,6 +1,6 @@# Cloud warehouse exports-This module owns Cloud-only BigQuery delivery and the scoped raw-event export API. Community Edition does not register the module. Customer instructions and the schema are in `docs/content/docs/integrations/data-warehouse.mdx`.+This module owns Cloud-only BigQuery delivery and the scoped raw-event export API. Both require the project owner's effective plan to include `PlanFeatureCode.dataWarehouse`: Plus and Enterprise qualify; Standard does not. The caller's own plan does not override the project owner's plan. Community Edition does not register the module. Customer instructions and the schema are in `docs/content/docs/integrations/data-warehouse.mdx`.## Deployment@@ -22,6 +22,8 @@ The module uses the existing Google authentication library and queue infrastruct- Populated partitions are replaced using load jobs; empty days remove that date's existing rows. A successful day requires both destination tables to finish.- Pausing or disconnecting prevents subsequent work. A request already uploading a day can finish. Disconnecting never deletes Google tables.- Workers recheck the current project owner and account status before each day. An ownership change disables delivery until the connection is saved with new credentials. Changes to the destination, start date, or owner reset the backfill checkpoint. Credential-only rotation preserves progress.+- Plan checks apply to raw exports, connection tests, creation, configuration or credential changes, resume, manual sync, scheduled dispatch, and each day's background export. Losing warehouse access disables delivery and clears its next scheduled run while preserving credentials and checkpoints. A day already in flight may finish. Upgrading requires an explicit resume.+- Viewing status, pausing an existing connection without changing its configuration, and disconnecting remain available after a downgrade. The ordinary aggregated Statistics API is unchanged.- Deletion in Swetrix does not guarantee deletion from old BigQuery partitions, derived tables, or other exported copies. Customers manage warehouse retention and erasure.## Verification before customer rollout@@ -37,5 +39,7 @@ Local mocked tests cannot establish Google IAM, upload, or production scheduling5. Check automatic scheduling across multiple workers, pause/resume, credential rotation, disconnection, project deletion, and project ownership changes.6. Call the raw export endpoint with a project-restricted key granting Analytics and Events read access. Verify wrong-project keys, missing scopes, public visitors, and read-only project users cannot export.7. Verify download cancellation closes the source query and failed/incomplete downloads are not published by the example pipeline.+8. Verify a Standard project owner cannot create, edit, test, resume, manually sync, or use raw exports, even when the collaborator making the request has Plus. Repeat with Plus and Enterprise project owners to confirm access. Verify trial, free, and no-plan owners do not gain access.+9. Downgrade a project with a queued or running export and verify no new day starts after the next plan check. Status, pause, and disconnect must still work. Upgrade again and confirm Resume preserves progress and restarts delivery. Verify the ordinary Statistics API still works on Standard.Keep service-account JSON, access tokens, and raw event contents out of logs and incident reports. Diagnose failures from the safe error status, the destination's Google job history, and queue state.diff --git a/backend/apps/cloud/src/data-export/data-export.service.spec.ts b/backend/apps/cloud/src/data-export/data-export.service.spec.tsindex a1c0b4c8e..afd6e5403 100644--- a/backend/apps/cloud/src/data-export/data-export.service.spec.ts+++ b/backend/apps/cloud/src/data-export/data-export.service.spec.ts@@ -1,4 +1,4 @@-import { ForbiddenException } from '@nestjs/common'+import { ForbiddenException, HttpException, HttpStatus } from '@nestjs/common'import { generateKeyPairSync } from 'crypto'jest.mock('../project/project.service', () => ({ ProjectService: class {} }))@@ -13,6 +13,12 @@ import { DataExportService } from './data-export.service'import { DataExport } from './entity/data-export.entity'import { SaveDataExportDto, validateExportDate } from './data-export.dto'import { WarehouseExportError } from './data-export.schema'+import {+ PlanCode,+ PlanFeatureCode,+ PlanType,+ userHasPlanFeature,+} from '../user/entities/user.entity'const key = generateKeyPairSync('rsa', { modulusLength: 2048 }).privateKey.export({ format: 'pem', type: 'pkcs8' })@@ -61,14 +67,19 @@ function setup(initial: DataExport | null = makeConnection()) {findOne: jest.fn(async () => record && { ...record }),find: jest.fn(async () => (record ? [{ ...record }] : [])),update: jest.fn(async (where, value) => {- if (+ const matches =record &&(!where.id || where.id === record.id) &&- (!where.revision || where.revision === record.revision)- ) {+ (!where.revision || where.revision === record.revision) &&+ (where.enabled === undefined || where.enabled === record.enabled) &&+ (!where.status ||+ (typeof where.status === 'string'+ ? where.status === record.status+ : where.status.value.includes(record.status)))+ if (matches) {record = { ...record, ...value }}- return { affected: record ? 1 : 0 }+ return { affected: matches ? 1 : 0 }}),save: jest.fn(async (value) => {record = { ...record, ...value }@@ -90,10 +101,28 @@ function setup(initial: DataExport | null = makeConnection()) {repository.manager = {transaction: async (fn: any) => fn({ getRepository: () => repository }),}- const project = { id: 'abcdefghijkl', admin: { id: 'owner-id' } }+ const project = {+ id: 'abcdefghijkl',+ admin: {+ id: 'owner-id',+ planCode: PlanCode['100k'],+ planType: PlanType.plus,+ },+ }const projects: any = {getFullProject: jest.fn(async () => project),allowedToManage: jest.fn(),+ projectOwnerHasFeature: jest.fn((project, feature) =>+ userHasPlanFeature(project?.admin, feature),+ ),+ assertProjectOwnerFeatureAccess: jest.fn((project, feature) => {+ if (!userHasPlanFeature(project?.admin, feature)) {+ throw new HttpException(+ 'This feature is not available on the current project owner plan.',+ HttpStatus.PAYMENT_REQUIRED,+ )+ }+ }),}const bigQuery: any = {validate: jest.fn(async () => {}),@@ -160,6 +189,223 @@ describe('warehouse orchestration', () => {expect(bigQuery.validate).not.toHaveBeenCalled()})+ it.each([+ [PlanCode['100k'], PlanType.plus, true],+ [PlanCode['100k'], PlanType.enterprise, true],+ [PlanCode['100k'], PlanType.standard, false],+ [PlanCode['100k'], null, false],+ [PlanCode.trial, PlanType.plus, false],+ [PlanCode.free, PlanType.plus, false],+ [PlanCode.none, PlanType.enterprise, false],+ ])(+ 'uses the existing plan policy for %s / %s (warehouse access: %s)',+ async (planCode, planType, allowed) => {+ const { service, project, projects } = setup()+ Object.assign(project.admin, { planCode, planType })+ expect(+ userHasPlanFeature(project.admin, PlanFeatureCode.dataWarehouse),+ ).toBe(allowed)+ if (allowed) {+ await expect(+ service.authorizeExport(project.id, 'owner-id'),+ ).resolves.toBe(project)+ } else {+ await expect(+ service.authorizeExport(project.id, 'owner-id'),+ ).rejects.toMatchObject({ status: HttpStatus.PAYMENT_REQUIRED })+ }+ expect(projects.assertProjectOwnerFeatureAccess).toHaveBeenCalledWith(+ project,+ PlanFeatureCode.dataWarehouse,+ )+ },+ )++ it.each([+ 'raw export',+ 'test connection',+ 'sync now',+ 'create enabled',+ 'create paused',+ 'change destination while paused',+ 'rotate credentials while paused',+ 'resume',+ 'save enabled',+ ])('rejects %s for a Standard owner before external work', async (action) => {+ const initial = action.startsWith('create')+ ? null+ : makeConnection({ enabled: action !== 'resume' })+ const { service, project, bigQuery, queue, repository, dto } =+ setup(initial)+ project.admin.planType = PlanType.standard+ let operation: Promise<unknown>+ switch (action) {+ case 'raw export':+ operation = service.authorizeExport(project.id, 'owner-id')+ break+ case 'test connection':+ operation = service.test(project.id, 'owner-id', dto())+ break+ case 'sync now':+ operation = service.sync(project.id, 'owner-id')+ break+ default:+ operation = service.save(+ project.id,+ 'owner-id',+ dto({+ ...(action.startsWith('create') ? { credentials } : {}),+ ...(action === 'change destination while paused'+ ? { datasetId: 'another_dataset' }+ : {}),+ ...(action === 'rotate credentials while paused'+ ? { credentials }+ : {}),+ enabled: !action.includes('paused'),+ }),+ )+ }+ await expect(operation).rejects.toMatchObject({+ status: HttpStatus.PAYMENT_REQUIRED,+ })+ expect(bigQuery.validate).not.toHaveBeenCalled()+ expect(bigQuery.exportDay).not.toHaveBeenCalled()+ expect(queue.add).not.toHaveBeenCalled()+ expect(repository.save).not.toHaveBeenCalled()+ })++ it('keeps status, unchanged pause and disconnect available after a downgrade', async () => {+ const { service, project, dto, bigQuery, queue, record, projects } = setup()+ project.admin.planType = PlanType.standard+ await expect(service.get(project.id, 'owner-id')).resolves.toHaveProperty(+ 'connection.id',+ 'connection-id',+ )+ await service.save(project.id, 'owner-id', dto({ enabled: false }))+ expect(record().enabled).toBe(false)+ await service.remove(project.id, 'owner-id')+ expect(record()).toBeNull()+ expect(projects.assertProjectOwnerFeatureAccess).not.toHaveBeenCalled()+ expect(bigQuery.validate).not.toHaveBeenCalled()+ expect(bigQuery.exportDay).not.toHaveBeenCalled()+ expect(queue.add).not.toHaveBeenCalled()+ })++ it('uses the billed project owner plan rather than the requesting manager plan', async () => {+ const { service, project, projects } = setup()+ await expect(+ service.authorizeExport(project.id, 'standard-manager'),+ ).resolves.toBe(project)+ expect(projects.allowedToManage).toHaveBeenLastCalledWith(+ project,+ 'standard-manager',+ )+ project.admin.planType = PlanType.standard+ await expect(+ service.authorizeExport(project.id, 'plus-manager'),+ ).rejects.toMatchObject({ status: HttpStatus.PAYMENT_REQUIRED })+ expect(projects.allowedToManage).toHaveBeenLastCalledWith(+ project,+ 'plus-manager',+ )+ expect(projects.assertProjectOwnerFeatureAccess).toHaveBeenLastCalledWith(+ project,+ PlanFeatureCode.dataWarehouse,+ )+ })++ it('disables a scheduled export after downgrade without adding a queue job', async () => {+ const { service, project, queue, bigQuery, record } = setup()+ project.admin.planType = PlanType.standard+ await service.schedule()+ expect(queue.add).not.toHaveBeenCalled()+ expect(bigQuery.exportDay).not.toHaveBeenCalled()+ expect(record()).toMatchObject({+ enabled: false,+ status: 'error',+ nextSyncAt: null,+ nextDate: '2026-10-27',+ lastSyncedDate: '2026-10-26',+ })+ expect(record().lastError).toContain('Plus')+ })++ it('disables an already queued export after downgrade without losing its checkpoint', async () => {+ const { service, project, bigQuery, job, record } = setup(+ makeConnection({ status: 'queued' }),+ )+ project.admin.planType = PlanType.standard+ await service.process(job)+ expect(bigQuery.exportDay).not.toHaveBeenCalled()+ expect(record()).toMatchObject({+ enabled: false,+ status: 'error',+ nextSyncAt: null,+ nextDate: '2026-10-27',+ lastSyncedDate: '2026-10-26',+ })+ expect(record().lastError).toContain('Plus')+ })++ it('preserves the plan error when a queued job or retry runs after the scheduler disabled it', async () => {+ const { service, project, bigQuery, job, record } = setup(+ makeConnection({ status: 'queued' }),+ )+ project.admin.planType = PlanType.standard+ await service.schedule()+ await service.process(job)+ await service.process(job)+ expect(bigQuery.exportDay).not.toHaveBeenCalled()+ expect(record()).toMatchObject({+ enabled: false,+ status: 'error',+ nextSyncAt: null,+ })+ expect(record().lastError).toContain('Plus')+ })++ it('preserves a scheduler downgrade during the final day instead of reporting success', async () => {+ const { service, project, bigQuery, job, record } = setup(+ makeConnection({ startDate: '2026-10-26', nextDate: '2026-10-26' }),+ )+ bigQuery.exportDay.mockImplementationOnce(async () => {+ project.admin.planType = PlanType.standard+ await service.schedule()+ return 10+ })+ await service.process(job)+ expect(bigQuery.exportDay).toHaveBeenCalledTimes(1)+ expect(record()).toMatchObject({+ enabled: false,+ status: 'error',+ nextSyncAt: null,+ nextDate: '2026-10-27',+ lastSyncedDate: '2026-10-26',+ })+ expect(record().lastError).toContain('Plus')+ })++ it('stops between days after downgrade and preserves the completed day checkpoint', async () => {+ const { service, project, bigQuery, job, record } = setup(+ makeConnection({ nextDate: '2026-10-01', lastSyncedDate: null }),+ )+ bigQuery.exportDay.mockImplementationOnce(async () => {+ project.admin.planType = PlanType.standard+ return 10+ })+ await service.process(job)+ expect(bigQuery.exportDay).toHaveBeenCalledTimes(1)+ expect(record()).toMatchObject({+ enabled: false,+ status: 'error',+ nextSyncAt: null,+ nextDate: '2026-10-02',+ lastSyncedDate: '2026-10-01',+ lastRowCount: 10,+ })+ expect(record().lastError).toContain('Plus')+ })+it('refreshes the latest three completed days without moving the high-water mark backwards', async () => {const { service, bigQuery, job, record } = setup()await service.process(job)@@ -252,6 +498,20 @@ describe('warehouse orchestration', () => {expect(record().status).toBe('idle')})+ it('clears syncing status when manually paused during the final day', async () => {+ const { service, bigQuery, job, repository, record } = setup(+ makeConnection({ startDate: '2026-10-26', nextDate: '2026-10-26' }),+ )+ bigQuery.exportDay.mockImplementationOnce(async () => {+ await repository.update({}, { enabled: false })+ return 10+ })+ await service.process(job)+ expect(record().enabled).toBe(false)+ expect(record().status).toBe('idle')+ expect(record().nextDate).toBe('2026-10-27')+ })+it('disables the connector after an ownership transfer before exporting data', async () => {const { service, bigQuery, job, project, record } = setup()project.admin.id = 'new-owner'diff --git a/backend/apps/cloud/src/data-export/data-export.service.ts b/backend/apps/cloud/src/data-export/data-export.service.tsindex 368955e9a..5269e00e2 100644--- a/backend/apps/cloud/src/data-export/data-export.service.ts+++ b/backend/apps/cloud/src/data-export/data-export.service.ts@@ -15,6 +15,7 @@ import { Queue } from 'bullmq'import { In, LessThanOrEqual, Repository } from 'typeorm'import { ProjectService } from '../project/project.service'import { Project } from '../project/entity/project.entity'+import { PlanFeatureCode } from '../user/entities/user.entity'import { DataExport } from './entity/data-export.entity'import { BigQueryService } from './bigquery.service'import {@@ -81,6 +82,10 @@ export class DataExportService {async authorizeExport(projectId: string, uid: string) {const project = await this.authorize(projectId, uid)+ this.projects.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.dataWarehouse,+ )this.assertAccountActive(project)return project}@@ -182,6 +187,12 @@ export class DataExportService {previous.ownerId !== project.admin.id ||configKeys.some((key) => previous[key] !== dto[key])const changed = resetHistory || Boolean(dto.credentials)+ if (changed || dto.enabled) {+ this.projects.assertProjectOwnerFeatureAccess(+ project,+ PlanFeatureCode.dataWarehouse,+ )+ }const credentials = changed? this.credentials(dto, previous, project.admin.id): null@@ -350,6 +361,12 @@ export class DataExportService {})for (const connection of due) {try {+ const project = await this.projects.getFullProject(connection.projectId)+ if (+ !project ||+ (await this.pauseIfPlanUnavailable(connection, project))+ )+ continueawait this.enqueue(connection)} catch {this.logger.warn(@@ -359,6 +376,31 @@ export class DataExportService {}}+ private async pauseIfPlanUnavailable(+ connection: DataExport,+ project: Project,+ ) {+ if (+ this.projects.projectOwnerHasFeature(+ project,+ PlanFeatureCode.dataWarehouse,+ )+ ) {+ return false+ }+ await this.connections.update(+ { id: connection.id, revision: connection.revision },+ {+ enabled: false,+ status: 'error',+ nextSyncAt: null,+ lastError:+ 'Data warehouse integrations require the project owner to have a Plus or Enterprise plan. Upgrade and resume the connection.',+ },+ )+ return true+ }+async process(data: DataExportJob) {const connection = await this.connections.createQueryBuilder('connection')@@ -371,7 +413,10 @@ export class DataExportService {if (!connection) returnconst criteria = { id: connection.id, revision: connection.revision }if (!connection.enabled) {- await this.connections.update(criteria, { status: 'idle' })+ await this.connections.update(+ { ...criteria, enabled: false, status: In(['queued', 'syncing']) },+ { status: 'idle' },+ )return}try {@@ -386,11 +431,15 @@ export class DataExportService {})return}+ if (await this.pauseIfPlanUnavailable(connection, project)) returnthis.assertAccountActive(project)- await this.connections.update(criteria, {- status: 'syncing',- lastError: null,- })+ await this.connections.update(+ { ...criteria, enabled: true },+ {+ status: 'syncing',+ lastError: null,+ },+ )const credentials = this.credentials({} as SaveDataExportDto,connection,@@ -409,7 +458,14 @@ export class DataExportService {const current = await this.connections.findOneBy(criteria)if (!current || !current.enabled) {if (current)- await this.connections.update(criteria, { status: 'idle' })+ await this.connections.update(+ {+ ...criteria,+ enabled: false,+ status: In(['queued', 'syncing']),+ },+ { status: 'idle' },+ )return}const currentProject = await this.projects.getFullProject(@@ -427,6 +483,8 @@ export class DataExportService {})return}+ if (await this.pauseIfPlanUnavailable(connection, currentProject))+ returnthis.assertAccountActive(currentProject)rows += await this.bigQuery.exportDay(connection,@@ -452,18 +510,36 @@ export class DataExportService {: new Date() < todayMorning? todayMorning: tomorrowMorning- await this.connections.update(criteria, {- status: 'idle',- nextSyncAt,- lastError: null,- })+ const completed = await this.connections.update(+ { ...criteria, enabled: true },+ {+ status: 'idle',+ nextSyncAt,+ lastError: null,+ },+ )+ if (!completed.affected) {+ await this.connections.update(+ { ...criteria, enabled: false, status: In(['queued', 'syncing']) },+ { status: 'idle' },+ )+ }} catch (error) {const message = this.safeError(error)- await this.connections.update(criteria, {- status: 'error',- lastError: message,- nextSyncAt: new Date(Date.now() + 6 * 60 * 60 * 1000),- })+ const failed = await this.connections.update(+ { ...criteria, enabled: true },+ {+ status: 'error',+ lastError: message,+ nextSyncAt: new Date(Date.now() + 6 * 60 * 60 * 1000),+ },+ )+ if (!failed.affected) {+ await this.connections.update(+ { ...criteria, enabled: false, status: In(['queued', 'syncing']) },+ { status: 'idle' },+ )+ }throw new Error(message)}}diff --git a/backend/apps/cloud/src/project/project.service.ts b/backend/apps/cloud/src/project/project.service.tsindex 509160dfa..bb9bccae2 100644--- a/backend/apps/cloud/src/project/project.service.ts+++ b/backend/apps/cloud/src/project/project.service.ts@@ -614,6 +614,10 @@ export class ProjectService {project,PlanFeatureCode.replays,),+ [PlanFeatureCode.dataWarehouse]: this.projectOwnerHasFeature(+ project,+ PlanFeatureCode.dataWarehouse,+ ),}}diff --git a/backend/apps/cloud/src/user/entities/user.entity.ts b/backend/apps/cloud/src/user/entities/user.entity.tsindex 54ae844d4..eef7b21f6 100644--- a/backend/apps/cloud/src/user/entities/user.entity.ts+++ b/backend/apps/cloud/src/user/entities/user.entity.ts@@ -43,6 +43,7 @@ export enum PlanFeatureCode {featureFlags = 'featureFlags',experiments = 'experiments',replays = 'replays',+ dataWarehouse = 'dataWarehouse',}export enum DashboardBlockReason {@@ -115,6 +116,7 @@ const PLAN_FEATURE_REQUIRED_PLAN = {[PlanFeatureCode.featureFlags]: PlanType.plus,[PlanFeatureCode.experiments]: PlanType.plus,[PlanFeatureCode.replays]: PlanType.plus,+ [PlanFeatureCode.dataWarehouse]: PlanType.plus,} as constinterface PaddleProductIds {diff --git a/docs/content/docs/accountsettings/api-keys.mdx b/docs/content/docs/accountsettings/api-keys.mdxindex 8fe158e39..64f4b9d8d 100644--- a/docs/content/docs/accountsettings/api-keys.mdx+++ b/docs/content/docs/accountsettings/api-keys.mdx@@ -47,7 +47,7 @@ Some responses combine resources and require multiple read permissions:- Project lists and details include saved funnels, so they need **Project settings** and **Funnels**.- Funnel and journey session lists also need **Analytics**, **Events**, and **Errors**. Error session lists also need **Analytics**.- Queries that filter on custom events or event metadata also require **Events**.-- Cloud [raw warehouse exports](/integrations/data-warehouse#export-api-for-other-warehouses) require **Analytics** and **Events**, plus permission to manage the project.+- Cloud [raw warehouse exports](/integrations/data-warehouse#export-api-for-other-warehouses) require **Analytics** and **Events**, permission to manage the project, and the project owner's **Plus** or **Enterprise** plan.Permissions apply to API-enabled endpoints. Account credentials, billing, and API-key management still require a signed-in session. Public tracking endpoints continue to accept ordinary tracker requests without a key; when a key is supplied, its permissions and project access are checked. A key does not grant any rights beyond those of its account.diff --git a/docs/content/docs/integration-guides.mdx b/docs/content/docs/integration-guides.mdxindex 26a55012a..a4a59f2cd 100644--- a/docs/content/docs/integration-guides.mdx+++ b/docs/content/docs/integration-guides.mdx@@ -70,7 +70,7 @@ Swetrix integrates with a wide range of platforms, frameworks, and tools. Choose-- [BigQuery and data warehouse exports (Cloud)](/integrations/data-warehouse)+- [BigQuery and data warehouse exports (Cloud Plus and Enterprise)](/integrations/data-warehouse)- [Google Search Console](/integrations/google-search-console)- [Google Tag Manager](/gtm-integration)diff --git a/docs/content/docs/integrations/data-warehouse.mdx b/docs/content/docs/integrations/data-warehouse.mdxindex 935ead471..b9c99692c 100644--- a/docs/content/docs/integrations/data-warehouse.mdx+++ b/docs/content/docs/integrations/data-warehouse.mdx@@ -2,16 +2,16 @@id: data-warehousetitle: Data warehouse connectorssidebar_label: Data warehouse connectors-description: "Export Swetrix Cloud pageviews and custom events to BigQuery, or use the raw export API to build pipelines for other data warehouses."+description: "Export Swetrix Cloud pageviews and custom events to BigQuery on Plus or Enterprise, or use the raw export API to build pipelines for other data warehouses."---Connect Swetrix Cloud to BigQuery to keep a daily copy of your pageviews and custom events in your own Google Cloud project. Use these tables in SQL queries, Looker Studio, or another BI tool that supports BigQuery.For Snowflake, Redshift, and other destinations, use the [raw export API](#export-api-for-other-warehouses) in your own pipeline. BigQuery is the built-in destination; Swetrix does not provide a native Snowflake, Redshift, Airbyte, or Fivetran connector.-<Callout type="info" title="Cloud Edition only">+<Callout type="info" title="Plus and Enterprise · Cloud Edition">-Warehouse settings and the raw export API are available in Swetrix Cloud. They are not included in Community Edition. You need permission to manage the project to configure a connection or export raw data.+The BigQuery connector and raw warehouse export API require the project owner's **Plus** or **Enterprise** plan. They are not included in Standard or Community Edition. A collaborator's subscription does not change the project's access. You also need permission to manage the project to configure a connection or export raw data.</Callout>@@ -75,6 +75,12 @@ Swetrix manages the contents and schema of its export tables. Keep your derivedChanging destination settings or the start date restarts backfill from the configured start date. Rotating only the service account key preserves progress. Wait for the current export to finish before making these changes. A change of project ownership disables the saved connection; the new owner must save it with a new service account key to resume delivery and restart backfill.+### After a plan downgrade++When the project owner's plan no longer includes warehouse exports, Swetrix disables scheduled delivery. Queued jobs and running syncs recheck plan access before exporting each day; a day already being uploaded can finish. The saved connection, credentials, and backfill progress are retained, and previously exported BigQuery data stays in your account.++You can still view the connection's status, pause it, or disconnect it. Creating or editing a connection, testing it, resuming delivery, syncing manually, and using the raw export API require Plus or Enterprise. After upgrading, choose **Resume** to continue from the saved progress.+## Query the exported dataReplace the example project, dataset, and prefix with your settings. Include an `event_date` filter to limit the partitions scanned.@@ -141,7 +147,7 @@ Deleting data in Swetrix does not automatically delete every previously exported## Export API for other warehouses-Use the raw export API to load Snowflake, Redshift, object storage, or another destination from your own scheduled job. A BigQuery connection is not required.+Use the raw export API to load Snowflake, Redshift, object storage, or another destination from your own scheduled job. A BigQuery connection is not required, but the project owner must have Plus or Enterprise.From the project owner's account, create a [scoped API key](/settings/api-keys) with **Analytics: Read only**, **Events: Read only**, and access to the selected project. Scoped keys currently select projects owned by that account. Public dashboard access, a dashboard password, or read-only sharing does not grant raw export access.@@ -178,9 +184,9 @@ For a reliable pipeline:4. Advance your checkpoint only after both loads succeed. Re-fetch the three most recent completed days to pick up late arrivals.5. Retry transient errors and `429` responses with backoff. API requests share the account's API rate limit.-Invalid dates or event types return a client error. Missing or invalid credentials return `401`; insufficient permissions return `403`. If the connection closes during a streamed response, treat the entire download as incomplete even if some valid JSON lines were received.+Invalid dates or event types return a client error. Missing or invalid credentials return `401`; insufficient permissions return `403`. A project owner's plan without warehouse access returns `402`. If the connection closes during a streamed response, treat the entire download as incomplete even if some valid JSON lines were received.-For aggregated reports rather than individual events, use the [Statistics API v2](/statistics-api-v2).+For aggregated reports rather than individual events, use the [Statistics API v2](/statistics-api-v2). Its existing availability on Standard is unchanged; the Plus requirement applies to the warehouse connector and raw export API.## Troubleshooting@@ -194,3 +200,4 @@ For aggregated reports rather than individual events, use the [Statistics API v2| Missing recent data | Exports contain completed UTC days and run asynchronously. Check progress and the last error in project settings. || Quota or temporary Google error | Correct any quota issue, then use Sync now. Retrying replaces the affected daily partition. || Daily export size limit | Use the streaming export API if a day's combined uncompressed export exceeds 10 GiB. |+| Plan access error | The project owner needs Plus or Enterprise. After upgrading, resume the saved connection. |diff --git a/docs/content/docs/sitesettings/project-configuration.mdx b/docs/content/docs/sitesettings/project-configuration.mdxindex d328f8f0a..3bf2819d1 100644--- a/docs/content/docs/sitesettings/project-configuration.mdx+++ b/docs/content/docs/sitesettings/project-configuration.mdx@@ -72,7 +72,7 @@ See [Session Replays](/analytics-dashboard/session-replays) for setup, privacy m## Data warehouse (Cloud)-The **Data warehouse** tab connects a Cloud project to BigQuery for daily pageview and custom event exports, including historical backfill. Project managers can configure the destination, follow sync progress, and pause or disconnect it. See [Data warehouse connectors](/integrations/data-warehouse) for Google Cloud setup, the export schema, and the API for other warehouses.+The **Data warehouse** tab connects a Cloud project to BigQuery for daily pageview and custom event exports, including historical backfill. The project owner must have **Plus** or **Enterprise**. Project managers can configure the destination, follow sync progress, and pause or disconnect it. Existing connection status and pause/disconnect controls remain available after a downgrade. See [Data warehouse connectors](/integrations/data-warehouse) for Google Cloud setup, the export schema, and the API for other warehouses.## Access Controldiff --git a/web/app/components/pricing/MarketingPricing.tsx b/web/app/components/pricing/MarketingPricing.tsxindex 0eb46813b..d840d85b0 100644--- a/web/app/components/pricing/MarketingPricing.tsx+++ b/web/app/components/pricing/MarketingPricing.tsx@@ -6,6 +6,7 @@ import {CaretDownIcon,CaretUpIcon,CubeIcon,+ DatabaseIcon,DownloadSimpleIcon,EnvelopeSimpleIcon,FlagIcon,@@ -125,6 +126,8 @@ const captchaDocsUrl = 'https://swetrix.com/docs/captcha/introduction'const botProtectionDocsUrl ='https://swetrix.com/docs/sitesettings/bot-protection'const managedProxyDocsUrl = 'https://swetrix.com/docs/adblockers/managed-proxy'+const dataWarehouseDocsUrl =+ 'https://swetrix.com/docs/integrations/data-warehouse'const formatEvents = (value: number) => value.toLocaleString('en-US')@@ -328,6 +331,13 @@ const getBenefits = (planType: PlanTypeCode, t: TFunction): Benefit[] => {t,statsApiDocsUrl,),+ benefitWithTooltip(+ DatabaseIcon,+ 'pricing.benefits.dataWarehouse',+ 'pricing.benefits.tooltips.dataWarehouse',+ t,+ dataWarehouseDocsUrl,+ ),{ icon: HeadsetIcon, label: t('pricing.benefits.prioritySupport') },]}diff --git a/web/app/components/pricing/PricingComparisonTable.tsx b/web/app/components/pricing/PricingComparisonTable.tsxindex 7fdbbe8af..1d23b3560 100644--- a/web/app/components/pricing/PricingComparisonTable.tsx+++ b/web/app/components/pricing/PricingComparisonTable.tsx@@ -57,6 +57,7 @@ const docs = {revenue: 'https://swetrix.com/docs/analytics-dashboard/revenue-tracking',segments: 'https://swetrix.com/docs/analytics-dashboard/segments',seo: 'https://swetrix.com/docs/analytics-dashboard/seo',+ dataWarehouse: 'https://swetrix.com/docs/integrations/data-warehouse',} as constconst ALL: [CellValue, CellValue, CellValue] = [true, true, true]@@ -246,6 +247,12 @@ const getCategories = (t: TFunction): FeatureCategory[] => [{title: t('pricing.comparison.categories.developer'),rows: [+ {+ label: t('pricing.benefits.dataWarehouse'),+ tooltip: t('pricing.benefits.tooltips.dataWarehouse'),+ tooltipHref: docs.dataWarehouse,+ values: PLUS_UP,+ },{label: t('pricing.benefits.restfulApiSdks'),tooltip: t('pricing.benefits.tooltips.restfulApiSdks'),diff --git a/web/app/lib/pricing/features.ts b/web/app/lib/pricing/features.tsindex 137f4fd9a..223ca6f4f 100644--- a/web/app/lib/pricing/features.ts+++ b/web/app/lib/pricing/features.ts@@ -1,3 +1,7 @@-export type PlanFeatureCode = 'featureFlags' | 'experiments' | 'replays'+export type PlanFeatureCode =+ | 'featureFlags'+ | 'experiments'+ | 'replays'+ | 'dataWarehouse'export type ProjectFeatureAccess = Record<PlanFeatureCode, boolean>diff --git a/web/app/pages/Project/Settings/ProjectSettings.tsx b/web/app/pages/Project/Settings/ProjectSettings.tsxindex 62c13d74b..a0a090cf4 100644--- a/web/app/pages/Project/Settings/ProjectSettings.tsx+++ b/web/app/pages/Project/Settings/ProjectSettings.tsx@@ -1197,7 +1197,14 @@ const ProjectSettings = () => {description={activeTabConfig.description}iconColorClass={activeTabConfig.iconColor}/>- <DataWarehouseTab key={id} projectId={id} />+ <DataWarehouseTab+ key={id}+ projectId={id}+ hasAccess={+ initialProject.featureAccess?.dataWarehouse === true+ }+ isOwner={initialProject.role === 'owner'}+ /></>) : null}{activeTab === 'proxy' && activeTabConfig ? (diff --git a/web/app/pages/Project/Settings/components/DataWarehouseTab.tsx b/web/app/pages/Project/Settings/components/DataWarehouseTab.tsxindex cd13701b9..d58a2f022 100644--- a/web/app/pages/Project/Settings/components/DataWarehouseTab.tsx+++ b/web/app/pages/Project/Settings/components/DataWarehouseTab.tsx@@ -14,6 +14,7 @@ import { Link } from '~/ui/Link'import Loader from '~/ui/Loader'import Modal from '~/ui/Modal'import { Text } from '~/ui/Text'+import routes from '~/utils/routes'const DOCS_URL = 'https://swetrix.com/docs/integrations/data-warehouse'const MAX_CREDENTIAL_BYTES = 20000@@ -50,7 +51,15 @@ const connectionForm = (startDate: connection.startDate,})-export default function DataWarehouseTab({ projectId }: { projectId: string }) {+export default function DataWarehouseTab({+ projectId,+ hasAccess,+ isOwner,+}: {+ projectId: string+ hasAccess: boolean+ isOwner: boolean+}) {const { t } = useTranslation('common')const [connection, setConnection] = useState<DataWarehouseConnection | null>(null,@@ -80,7 +89,7 @@ export default function DataWarehouseTab({ projectId }: { projectId: string }) {const syncing =connection?.status === 'syncing' || connection?.status === 'queued'const busy = actionFetcher.state !== 'idle'- const editingDisabled = busy || syncing+ const editingDisabled = busy || syncing || !hasAccessconst fetchConnection = useCallback(() => {submitList(@@ -184,6 +193,7 @@ export default function DataWarehouseTab({ projectId }: { projectId: string }) {const submitConfiguration = (intent: 'save-data-warehouse' | 'test-data-warehouse',) => {+ if (!hasAccess) returnif (!formRef.current?.reportValidity()) returnconst raw = credentials.trim()if (raw) {@@ -223,13 +233,14 @@ export default function DataWarehouseTab({ projectId }: { projectId: string }) {const submitAction = (intent: 'sync-data-warehouse' | 'delete-data-warehouse',) => {+ if (intent === 'sync-data-warehouse' && !hasAccess) returnsetActionError(null)actionMode.current = intent === 'delete-data-warehouse' ? 'delete' : 'sync'actionFetcher.submit({ intent }, { method: 'post', action: settingsAction })}const toggleEnabled = () => {- if (!connection) return+ if (!connection || (!connection.enabled && !hasAccess)) returnsetActionError(null)actionMode.current = 'toggle'actionFetcher.submit(@@ -261,6 +272,28 @@ export default function DataWarehouseTab({ projectId }: { projectId: string }) {</Link></div>+ {!hasAccess ? (+ <Alert+ variant='info'+ title={t('project.settings.warehouse.upgradeTitle')}+ >+ <div className='flex flex-col items-start gap-3'>+ <span>+ {t(+ isOwner+ ? 'project.settings.warehouse.upgradeDescription'+ : 'project.settings.warehouse.askOwner',+ )}+ </span>+ {isOwner ? (+ <Button to={routes.billing_choose_plan} size='sm'>+ {t('project.settings.warehouse.upgrade')}+ </Button>+ ) : null}+ </div>+ </Alert>+ ) : null}+{loadError ? (<Alert variant='error'><div className='flex flex-wrap items-center justify-between gap-3'>@@ -287,7 +320,13 @@ export default function DataWarehouseTab({ projectId }: { projectId: string }) {<Text weight='semibold'>Google BigQuery</Text><Text size='sm' colour='secondary' aria-live='polite'>{t(- `project.settings.warehouse.status.${connection.enabled ? connection.status : 'paused'}`,+ `project.settings.warehouse.status.${+ !connection.enabled+ ? 'paused'+ : hasAccess+ ? connection.status+ : 'planRequired'+ }`,)}</Text></div>@@ -295,7 +334,7 @@ export default function DataWarehouseTab({ projectId }: { projectId: string }) {<Buttonvariant='secondary'size='sm'- disabled={busy || syncing || !connection.enabled}+ disabled={busy || syncing || !connection.enabled || !hasAccess}onClick={() => submitAction('sync-data-warehouse')}><ArrowClockwiseIcon@@ -307,7 +346,7 @@ export default function DataWarehouseTab({ projectId }: { projectId: string }) {<Buttonvariant='secondary'size='sm'- disabled={busy}+ disabled={busy || (!connection.enabled && !hasAccess)}onClick={toggleEnabled}>{t(@@ -357,13 +396,13 @@ export default function DataWarehouseTab({ projectId }: { projectId: string }) {</dd></div></dl>- {connection.enabled && syncing ? (+ {hasAccess && connection.enabled && syncing ? (<Text size='sm' colour='secondary'>{t('project.settings.warehouse.nextDate', {date: connection.nextDate,})}</Text>- ) : connection.enabled && connection.nextSyncAt ? (+ ) : hasAccess && connection.enabled && connection.nextSyncAt ? (<Text size='sm' colour='secondary'>{t('project.settings.warehouse.nextSync', {date: new Date(connection.nextSyncAt).toLocaleString(),@@ -383,7 +422,7 @@ export default function DataWarehouseTab({ projectId }: { projectId: string }) {{actionError ? <Alert variant='error'>{actionError}</Alert> : null}- {!loadError || connection ? (+ {hasAccess && (!loadError || connection) ? (<formref={formRef}className='flex flex-col gap-5'diff --git a/web/app/pages/Project/View/components/PlanFeatureLocked.tsx b/web/app/pages/Project/View/components/PlanFeatureLocked.tsxindex b211cb78f..465b48277 100644--- a/web/app/pages/Project/View/components/PlanFeatureLocked.tsx+++ b/web/app/pages/Project/View/components/PlanFeatureLocked.tsx@@ -27,7 +27,7 @@ const featureDocsAriaLabels: Record<(typeof allowedFeatures)[number], string> =const PlanFeatureLocked = ({ feature }: PlanFeatureLockedProps) => {const { t } = useTranslation('common')- const safeFeature = allowedFeatures.includes(feature) ? feature : null+ const safeFeature = allowedFeatures.find((allowed) => allowed === feature)const { isOwner } = useProjectFeatureAccess(safeFeature || 'featureFlags')const audience = isOwner ? 'owner' : 'viewer'diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex e114479b3..81a553412 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -515,7 +515,7 @@"items": [{"q": "What plan should I choose?",- "a": "Standard plans are best if you need privacy-first analytics, funnels, error tracking, bot filtering, email reports and API access. Plus plans include everything in Standard and add session replays, feature flags, A/B testing, higher API rate limits, more websites, more team members and priority support.\n\nOnce you've picked a plan type, choose the event volume based on your traffic. You can start with the {{lowestPlanEventsAmount}} events per month plan. If you already have some traffic, you can start with the {{moderatePlanEventsAmount}} events per month plan.\n\nIn any case, you can upgrade or downgrade your plan anytime, and we will pro-rate your subscription if you change your plan so it would be fair for you."+ "a": "Standard plans are best if you need privacy-first analytics, funnels, error tracking, bot filtering, email reports and Stats and Events API access. Plus plans include everything in Standard and add session replays, feature flags, A/B testing, data warehouse integrations, higher API rate limits, more websites, more team members and priority support.\n\nOnce you've picked a plan type, choose the event volume based on your traffic. You can start with the {{lowestPlanEventsAmount}} events per month plan. If you already have some traffic, you can start with the {{moderatePlanEventsAmount}} events per month plan.\n\nIn any case, you can upgrade or downgrade your plan anytime, and we will pro-rate your subscription if you change your plan so it would be fair for you."},{"q": "What happens if I exceed my plan's limit?",@@ -2401,6 +2401,10 @@"upgradeCta": "Go to billing"},"warehouse": {+ "upgradeTitle": "Available on Plus and Enterprise",+ "upgradeDescription": "Upgrade to Plus to enable scheduled BigQuery exports and the raw export API for your data pipelines.",+ "askOwner": "Ask the project owner to upgrade to Plus to enable scheduled BigQuery exports and the raw export API.",+ "upgrade": "Upgrade to Plus","description": "Send your Swetrix pageviews and custom events to Google BigQuery every day. Exports cover complete UTC days through yesterday, including outbound clicks. Data imported from Google Analytics or other providers is not included.","setupGuide": "Setup guide and export API","destination": "BigQuery destination",@@ -2443,13 +2447,14 @@"disconnectTitle": "Disconnect BigQuery?","disconnectMessage": "This removes the saved credentials and stops future exports. A day already in progress may finish. Data already exported to BigQuery stays in your dataset.","otherWarehouses": "Snowflake, Redshift, and other destinations",- "otherWarehousesHint": "Use the export API with your own pipeline to load other warehouses. The setup guide includes the API format and examples.",+ "otherWarehousesHint": "On Plus and Enterprise, use the export API with your own pipeline to load other warehouses. The setup guide includes the API format and examples.","status": {"idle": "Daily exports enabled","queued": "Export queued","syncing": "Export in progress","error": "Export needs attention",- "paused": "Exports paused"+ "paused": "Exports paused",+ "planRequired": "Plus or Enterprise is required to export"}},"dataImport": {@@ -3369,6 +3374,7 @@"sessionReplays": "Session replays","featureFlags": "Feature flags","abTesting": "A/B testing",+ "dataWarehouse": "Data warehouse integrations","twentyXHigherApiRateLimits": "20x higher API rate limits","prioritySupport": "Priority support","dedicatedAccountManager": "Dedicated account manager for ongoing support",@@ -3400,6 +3406,7 @@},"featureFlags": "Roll features out gradually, target cohorts or individual users, and turn changes off without another deploy.","abTesting": "Run experiments against goals, split visitors across variants, and compare conversion results before shipping a change to everyone.",+ "dataWarehouse": "Export pageviews and custom events to Google BigQuery daily, with historical backfill. Use the raw export API with your own pipeline for Snowflake, Redshift, or other warehouses.","twentyXHigherApiRateLimits": "Standard plans include 300 API requests per hour. Plus plans include 6,000 API requests per hour, which is 20x higher.","teamMembers": {"projects": "Members are people you invite to your projects, such as teammates or clients. Give them admin or viewer access to collaborate on your analytics.",@@ -3508,7 +3515,7 @@},"included": {"title": "What's included",- "subtitle": "The event allowance below follows the volume selected above. Standard includes the complete analytics toolkit; Plus raises workspace limits and adds replays and experiments.",+ "subtitle": "The event allowance below follows the volume selected above. Standard includes the complete analytics toolkit; Plus raises workspace limits and adds replays, experiments and data warehouse integrations.","cards": {"events": {"title": "events per month",@@ -3575,7 +3582,7 @@},{"q": "Should I choose Standard or Plus?",- "a": "Choose Standard for the core analytics suite, including traffic, funnels, performance monitoring, error tracking, reports and API access. Choose Plus if you also need session replays, feature flags, A/B testing, higher workspace limits or priority support."+ "a": "Choose Standard for the core analytics suite, including traffic, funnels, performance monitoring, error tracking, reports and Stats and Events API access. Choose Plus if you also need session replays, feature flags, A/B testing, data warehouse integrations, higher workspace limits or priority support."},{"q": "What happens if I exceed my event limit?",