📈 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
feat: Plausible Analytics data importer (#516)
Andrii Romasiun719c211b8a65
diff --git a/backend/apps/cloud/src/data-import/mappers/index.ts b/backend/apps/cloud/src/data-import/mappers/index.tsindex 3fadcac89..112e9e49d 100644--- a/backend/apps/cloud/src/data-import/mappers/index.ts+++ b/backend/apps/cloud/src/data-import/mappers/index.ts@@ -3,12 +3,14 @@ import { UmamiMapper } from './umami.mapper'import { SimpleAnalyticsMapper } from './simple-analytics.mapper'import { FathomMapper } from './fathom.mapper'import { Ga4Mapper } from './ga4.mapper'+import { PlausibleMapper } from './plausible.mapper'export const SUPPORTED_PROVIDERS = ['umami','simple-analytics','fathom','google-analytics',+ 'plausible',] as constconst mappers: Record<string, ImportMapper> = {@@ -16,6 +18,7 @@ const mappers: Record<string, ImportMapper> = {'simple-analytics': new SimpleAnalyticsMapper(),fathom: new FathomMapper(),'google-analytics': new Ga4Mapper(),+ plausible: new PlausibleMapper(),}export function getMapper(provider: string): ImportMapper | undefined {diff --git a/backend/apps/cloud/src/data-import/mappers/plausible.mapper.ts b/backend/apps/cloud/src/data-import/mappers/plausible.mapper.tsnew file mode 100644index 000000000..99141bb58--- /dev/null+++ b/backend/apps/cloud/src/data-import/mappers/plausible.mapper.ts@@ -0,0 +1,954 @@+import * as fs from 'fs'+import * as path from 'path'+import * as crypto from 'crypto'+import { unzipSync, UnzipFileInfo } from 'fflate'+import { parse as parseSync } from 'csv-parse/sync'++import {+ ImportMapper,+ ImportError,+ AnalyticsImportRow,+} from './mapper.interface'+import {+ normalizeNull,+ truncate,+ sessionIdToPsid,+ MOBILE_BROWSER_VARIANTS,+} from './mapper.utils'++const MAX_PLAUSIBLE_ZIP_BYTES = 100 * 1024 * 1024+const MAX_PLAUSIBLE_UNCOMPRESSED_BYTES = 500 * 1024 * 1024+const MAX_CSV_BYTES = 50 * 1024 * 1024+const MIN_PAGE_GAP_SEC = 5+const MAX_PAGE_GAP_SEC = 30 * 60+const DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/++const MAX_SESSIONS_PER_DAY = 1_000_000+const MAX_PAGEVIEWS_PER_SESSION = 1_000+const MAX_EVENTS_PER_DAY = 1_000_000+const MAX_GENERATED_ROWS_PER_IMPORT = 100_000_000+const MAX_SAFE_COUNT = Number.MAX_SAFE_INTEGER++const FILE_PATTERNS: Record<string, RegExp> = {+ visitors: /(^|\/)imported_visitors[^/]*\.csv$/i,+ pages: /(^|\/)imported_pages[^/]*\.csv$/i,+ browsers: /(^|\/)imported_browsers[^/]*\.csv$/i,+ devices: /(^|\/)imported_devices[^/]*\.csv$/i,+ operatingSystems: /(^|\/)imported_operating_systems[^/]*\.csv$/i,+ locations: /(^|\/)imported_locations[^/]*\.csv$/i,+ sources: /(^|\/)imported_sources[^/]*\.csv$/i,+ entryPages: /(^|\/)imported_entry_pages[^/]*\.csv$/i,+ exitPages: /(^|\/)imported_exit_pages[^/]*\.csv$/i,+ customEvents: /(^|\/)imported_custom_events[^/]*\.csv$/i,+}++const OS_MAP: Record<string, string> = {+ Mac: 'macOS',+ GNU: 'Linux',+ Ubuntu: 'Linux',+ iOS: 'iOS',+ Android: 'Android',+ Windows: 'Windows',+ 'Chrome OS': 'Chrome OS',+}++const DEVICE_MAP: Record<string, string> = {+ Desktop: 'desktop',+ Laptop: 'desktop',+ Mobile: 'mobile',+ Tablet: 'tablet',+}++interface VisitorRow {+ date: string+ visitors: number+ pageviews: number+ visits: number+ bounces: number+ visit_duration: number+}++interface BrowserRow {+ browser: string | null+ browser_version: string | null+ visits: number+}++interface DeviceRow {+ device: string | null+ visits: number+}++interface OsRow {+ operating_system: string | null+ operating_system_version: string | null+ visits: number+}++interface LocationRow {+ country: string | null+ region: string | null+ visits: number+}++interface SourceRow {+ source: string | null+ referrer: string | null+ utm_source: string | null+ utm_medium: string | null+ utm_campaign: string | null+ utm_content: string | null+ utm_term: string | null+ visits: number+}++interface PageRow {+ hostname: string | null+ page: string | null+ pageviews: number+}++interface EntryPageRow {+ entry_page: string | null+ entrances: number+}++interface ExitPageRow {+ exit_page: string | null+ exits: number+}++interface CustomEventRow {+ name: string+ events: number+}++interface DailyData {+ visitors: VisitorRow+ browsers: BrowserRow[]+ devices: DeviceRow[]+ os: OsRow[]+ locations: LocationRow[]+ sources: SourceRow[]+ pages: PageRow[]+ entryPages: EntryPageRow[]+ exitPages: ExitPageRow[]+ customEvents: CustomEventRow[]+}++function seededPrng(seed: number): () => number {+ let s = seed >>> 0+ return () => {+ s = (s + 0x6d2b79f5) >>> 0+ let t = s+ t = Math.imul(t ^ (t >>> 15), t | 1)+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61)+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296+ }+}++function seedFromString(s: string): number {+ return crypto.createHash('sha256').update(s).digest().readUInt32BE(0)+}++function toInt(value: string | undefined, fieldName = 'value'): number {+ if (value === undefined || value === null || value === '') return 0+ const n = parseInt(value, 10)+ if (!Number.isFinite(n) || Number.isNaN(n) || !Number.isSafeInteger(n)) {+ throw new ImportError(+ `Plausible export contains an invalid numeric ${fieldName}: ${value}`,+ )+ }+ if (n < 0) {+ throw new ImportError(+ `Plausible export contains a negative numeric ${fieldName}: ${value}`,+ )+ }+ return Math.min(n, MAX_SAFE_COUNT)+}++function parseCsv(bytes: Uint8Array): Record<string, string>[] {+ if (bytes.length > MAX_CSV_BYTES) {+ throw new ImportError(+ `Plausible export contains a CSV larger than ${MAX_CSV_BYTES} bytes.`,+ )+ }+ return parseSync(Buffer.from(bytes), {+ bom: true,+ columns: true,+ skip_empty_lines: true,+ trim: true,+ relax_quotes: true,+ relax_column_count: true,+ }) as Record<string, string>[]+}++function mapBrowser(raw: string | null, device: string | null): string | null {+ if (!raw) return null+ const isMobile = device === 'mobile' || device === 'tablet'+ if (isMobile && MOBILE_BROWSER_VARIANTS[raw]) {+ return MOBILE_BROWSER_VARIANTS[raw]+ }+ return raw+}++function mapOS(raw: string | null): string | null {+ if (!raw) return null+ return OS_MAP[raw] ?? raw+}++function mapDevice(raw: string | null): string {+ if (!raw) return 'desktop'+ return DEVICE_MAP[raw] ?? raw.toLowerCase()+}++function parseRegion(raw: string | null): string | null {+ if (!raw) return null+ const dash = raw.indexOf('-')+ if (dash < 0) return raw.slice(0, 10)+ return raw.slice(dash + 1).slice(0, 10) || null+}++function buildReferrer(+ referrer: string | null,+ source: string | null,+ hostname: string | null,+): string | null {+ const candidate = referrer || source+ if (!candidate || candidate.toLowerCase() === 'direct') return null++ let url: string+ if (candidate.includes('://')) {+ url = candidate+ } else if (candidate.includes('.')) {+ url = `https://${candidate}`+ } else {+ return null+ }++ if (hostname) {+ try {+ const parsed = new URL(url)+ const cleanRef = parsed.hostname.replace(/^www\./, '')+ const cleanHost = hostname.replace(/^www\./, '')+ if (cleanRef === cleanHost) return null+ } catch {+ // ignore+ }+ }++ return url+}++function pickSiteHostname(pages: PageRow[]): string | null {+ if (pages.length === 0) return null+ const counts = new Map<string, number>()+ for (const p of pages) {+ if (!p.hostname) continue+ counts.set(p.hostname, (counts.get(p.hostname) ?? 0) + p.pageviews)+ }+ let best: string | null = null+ let bestCount = -1+ for (const [host, count] of counts) {+ if (count > bestCount) {+ best = host+ bestCount = count+ }+ }+ return best+}++const MAX_POOL_SIZE = 2_000_000++function buildShuffledPool<T>(+ items: T[],+ counts: number[],+ prng: () => number,+): T[] {+ if (items.length === 0) return []++ const safeCounts: number[] = new Array(items.length)+ let total = 0+ for (let i = 0; i < items.length; i++) {+ const c = counts[i]+ const safe = c > 0 ? c : 0+ safeCounts[i] = safe+ total += safe+ }+ if (total <= 0) return []++ // Allocate per-item slots, scaling proportionally if the total would+ // exceed MAX_POOL_SIZE. Largest-remainder method keeps the assigned+ // counts as close to the original ratios as possible while preserving+ // the exact target total.+ let allocations: number[]+ let poolSize: number+ if (total > MAX_POOL_SIZE) {+ allocations = new Array(items.length).fill(0)+ const fractions: { idx: number; rem: number }[] = []+ let assigned = 0+ for (let i = 0; i < items.length; i++) {+ if (safeCounts[i] === 0) continue+ const scaled = (safeCounts[i] * MAX_POOL_SIZE) / total+ const floor = Math.floor(scaled)+ allocations[i] = floor+ assigned += floor+ fractions.push({ idx: i, rem: scaled - floor })+ }+ fractions.sort((a, b) => b.rem - a.rem || a.idx - b.idx)+ let remaining = MAX_POOL_SIZE - assigned+ for (let i = 0; i < fractions.length && remaining > 0; i++) {+ allocations[fractions[i].idx] += 1+ remaining -= 1+ }+ poolSize = MAX_POOL_SIZE+ } else {+ allocations = safeCounts+ poolSize = total+ }++ const pool: T[] = new Array(poolSize)+ let p = 0+ for (let i = 0; i < items.length; i++) {+ const c = allocations[i]+ for (let j = 0; j < c; j++) {+ pool[p++] = items[i]+ }+ }++ for (let i = pool.length - 1; i > 0; i--) {+ const j = Math.floor(prng() * (i + 1))+ const tmp = pool[i]+ pool[i] = pool[j]+ pool[j] = tmp+ }++ return pool+}++function pickFromPool<T>(pool: T[], idx: number): T | null {+ if (pool.length === 0) return null+ return pool[idx % pool.length]+}++interface PoolBundle {+ browsers: BrowserRow[]+ devices: DeviceRow[]+ os: OsRow[]+ locations: LocationRow[]+ sources: SourceRow[]+ pages: PageRow[]+ entryPages: EntryPageRow[]+ exitPages: ExitPageRow[]+}++function buildPools(+ daily: DailyData,+ importID: number,+ date: string,+): PoolBundle {+ const seedFor = (label: string) =>+ seededPrng(seedFromString(`${importID}|${date}|pool|${label}`))++ return {+ browsers: buildShuffledPool(+ daily.browsers,+ daily.browsers.map((r) => r.visits),+ seedFor('browsers'),+ ),+ devices: buildShuffledPool(+ daily.devices,+ daily.devices.map((r) => r.visits),+ seedFor('devices'),+ ),+ os: buildShuffledPool(+ daily.os,+ daily.os.map((r) => r.visits),+ seedFor('os'),+ ),+ locations: buildShuffledPool(+ daily.locations,+ daily.locations.map((r) => r.visits),+ seedFor('locations'),+ ),+ sources: buildShuffledPool(+ daily.sources,+ daily.sources.map((r) => r.visits),+ seedFor('sources'),+ ),+ pages: buildShuffledPool(+ daily.pages,+ daily.pages.map((r) => r.pageviews),+ seedFor('pages'),+ ),+ entryPages: buildShuffledPool(+ daily.entryPages,+ daily.entryPages.map((r) => r.entrances),+ seedFor('entryPages'),+ ),+ exitPages: buildShuffledPool(+ daily.exitPages,+ daily.exitPages.map((r) => r.exits),+ seedFor('exitPages'),+ ),+ }+}++function formatDateTime(epochSec: number): string {+ const d = new Date(epochSec * 1000)+ const yyyy = d.getUTCFullYear()+ const mm = String(d.getUTCMonth() + 1).padStart(2, '0')+ const dd = String(d.getUTCDate()).padStart(2, '0')+ const hh = String(d.getUTCHours()).padStart(2, '0')+ const mi = String(d.getUTCMinutes()).padStart(2, '0')+ const ss = String(d.getUTCSeconds()).padStart(2, '0')+ return `${yyyy}-${mm}-${dd} ${hh}:${mi}:${ss}`+}++function dateToEpochSec(date: string): number {+ return Math.floor(new Date(`${date}T00:00:00Z`).getTime() / 1000)+}++export class PlausibleMapper implements ImportMapper {+ readonly provider = 'plausible'+ readonly expectedFileExtension = '.zip'++ private extractCsvs(zipPath: string): Map<string, Uint8Array> {+ const stat = fs.statSync(zipPath)+ if (stat.size > MAX_PLAUSIBLE_ZIP_BYTES) {+ throw new ImportError(+ `Plausible ZIP exceeds the ${MAX_PLAUSIBLE_ZIP_BYTES} byte limit.`,+ )+ }++ const buf = fs.readFileSync(zipPath)++ const matchedKeys = new Set<string>()+ const nameToKey = new Map<string, string>()+ let totalUncompressed = 0++ const filter = (file: UnzipFileInfo): boolean => {+ const base = path.basename(file.name).toLowerCase()+ if (!base.endsWith('.csv')) return false+ for (const [key, pattern] of Object.entries(FILE_PATTERNS)) {+ if (matchedKeys.has(key)) continue+ if (!pattern.test(file.name)) continue++ const declaredSize = Number.isSafeInteger(file.originalSize)+ ? file.originalSize+ : -1+ if (declaredSize < 0) {+ throw new ImportError(+ `Plausible ZIP entry ${file.name} reports an invalid uncompressed size.`,+ )+ }+ if (declaredSize > MAX_CSV_BYTES) {+ throw new ImportError(+ `Plausible ZIP entry ${file.name} exceeds the ${MAX_CSV_BYTES} byte CSV limit (declared ${declaredSize}).`,+ )+ }+ if (+ totalUncompressed + declaredSize >+ MAX_PLAUSIBLE_UNCOMPRESSED_BYTES+ ) {+ throw new ImportError(+ `Plausible ZIP uncompressed size exceeds the ${MAX_PLAUSIBLE_UNCOMPRESSED_BYTES} byte limit.`,+ )+ }+ totalUncompressed += declaredSize+ matchedKeys.add(key)+ nameToKey.set(file.name, key)+ return true+ }+ return false+ }++ let entries: Record<string, Uint8Array>+ try {+ entries = unzipSync(+ new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength),+ { filter },+ )+ } catch (err) {+ if (err instanceof ImportError) throw err+ throw new ImportError(+ 'Could not read the uploaded file as a ZIP archive. Please upload the export ZIP from Plausible.',+ )+ }++ const found = new Map<string, Uint8Array>()+ for (const [name, data] of Object.entries(entries)) {+ const key = nameToKey.get(name)+ if (!key || found.has(key)) continue+ if (data.byteLength > MAX_CSV_BYTES) {+ throw new ImportError(+ `Plausible ZIP entry ${name} exceeds the ${MAX_CSV_BYTES} byte CSV limit after decompression.`,+ )+ }+ found.set(key, data)+ }++ return found+ }++ private buildDailyData(+ csvs: Map<string, Uint8Array>,+ ): Map<string, DailyData> {+ const visitorsBytes = csvs.get('visitors')+ if (!visitorsBytes) {+ throw new ImportError(+ 'ZIP does not contain imported_visitors_*.csv. Please upload the full export ZIP from Plausible.',+ )+ }++ const days = new Map<string, DailyData>()++ const ensureDay = (date: string): DailyData => {+ let d = days.get(date)+ if (!d) {+ d = {+ visitors: {+ date,+ visitors: 0,+ pageviews: 0,+ visits: 0,+ bounces: 0,+ visit_duration: 0,+ },+ browsers: [],+ devices: [],+ os: [],+ locations: [],+ sources: [],+ pages: [],+ entryPages: [],+ exitPages: [],+ customEvents: [],+ }+ days.set(date, d)+ }+ return d+ }++ for (const row of parseCsv(visitorsBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !DATE_REGEX.test(date)) continue+ const visits = toInt(row.visits, 'visits')+ const pageviews = toInt(row.pageviews, 'pageviews')+ if (visits <= 0 && pageviews <= 0) continue+ const day = ensureDay(date)+ day.visitors = {+ date,+ visitors: toInt(row.visitors, 'visitors'),+ pageviews,+ visits,+ bounces: toInt(row.bounces, 'bounces'),+ visit_duration: toInt(row.visit_duration, 'visit_duration'),+ }+ }++ if (days.size === 0) {+ throw new ImportError(+ 'imported_visitors_*.csv contains no valid daily rows.',+ )+ }++ const pagesBytes = csvs.get('pages')+ if (pagesBytes) {+ for (const row of parseCsv(pagesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const pageviews = toInt(row.pageviews)+ if (pageviews <= 0) continue+ days.get(date)!.pages.push({+ hostname: normalizeNull(row.hostname),+ page: normalizeNull(row.page),+ pageviews,+ })+ }+ }++ const browsersBytes = csvs.get('browsers')+ if (browsersBytes) {+ for (const row of parseCsv(browsersBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.browsers.push({+ browser: normalizeNull(row.browser),+ browser_version: normalizeNull(row.browser_version),+ visits,+ })+ }+ }++ const devicesBytes = csvs.get('devices')+ if (devicesBytes) {+ for (const row of parseCsv(devicesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.devices.push({+ device: normalizeNull(row.device),+ visits,+ })+ }+ }++ const osBytes = csvs.get('operatingSystems')+ if (osBytes) {+ for (const row of parseCsv(osBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.os.push({+ operating_system: normalizeNull(row.operating_system),+ operating_system_version: normalizeNull(row.operating_system_version),+ visits,+ })+ }+ }++ const locationsBytes = csvs.get('locations')+ if (locationsBytes) {+ for (const row of parseCsv(locationsBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.locations.push({+ country: normalizeNull(row.country),+ region: normalizeNull(row.region),+ visits,+ })+ }+ }++ const sourcesBytes = csvs.get('sources')+ if (sourcesBytes) {+ for (const row of parseCsv(sourcesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.sources.push({+ source: normalizeNull(row.source),+ referrer: normalizeNull(row.referrer),+ utm_source: normalizeNull(row.utm_source),+ utm_medium: normalizeNull(row.utm_medium),+ utm_campaign: normalizeNull(row.utm_campaign),+ utm_content: normalizeNull(row.utm_content),+ utm_term: normalizeNull(row.utm_term),+ visits,+ })+ }+ }++ const entryPagesBytes = csvs.get('entryPages')+ if (entryPagesBytes) {+ for (const row of parseCsv(entryPagesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const entrances = toInt(row.entrances)+ if (entrances <= 0) continue+ days.get(date)!.entryPages.push({+ entry_page: normalizeNull(row.entry_page),+ entrances,+ })+ }+ }++ const exitPagesBytes = csvs.get('exitPages')+ if (exitPagesBytes) {+ for (const row of parseCsv(exitPagesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const exits = toInt(row.exits)+ if (exits <= 0) continue+ days.get(date)!.exitPages.push({+ exit_page: normalizeNull(row.exit_page),+ exits,+ })+ }+ }++ const customEventsBytes = csvs.get('customEvents')+ if (customEventsBytes) {+ for (const row of parseCsv(customEventsBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const name = normalizeNull(row.name)+ const events = toInt(row.events, 'events')+ if (!name || events <= 0) continue+ days.get(date)!.customEvents.push({ name, events })+ }+ }++ return days+ }++ async *createRowStream(+ filePath: string,+ pid: string,+ importID: number,+ ): AsyncIterable<AnalyticsImportRow> {+ const csvs = this.extractCsvs(filePath)+ const days = this.buildDailyData(csvs)+ const sortedDates = Array.from(days.keys()).sort()++ let yielded = 0+ for (const date of sortedDates) {+ const daily = days.get(date)!+ for (const row of this.synthesizeDay(daily, pid, importID)) {+ yielded += 1+ if (yielded > MAX_GENERATED_ROWS_PER_IMPORT) {+ throw new ImportError(+ `Plausible export would generate more than ${MAX_GENERATED_ROWS_PER_IMPORT} rows. Please split the export into smaller archives and re-import.`,+ )+ }+ yield row+ }+ }+ }++ private *synthesizeDay(+ daily: DailyData,+ pid: string,+ importID: number,+ ): Iterable<AnalyticsImportRow> {+ const { date } = daily.visitors+ const visits = Math.min(+ Math.max(daily.visitors.visits, 0),+ MAX_SESSIONS_PER_DAY,+ )+ const pageviews = Math.max(daily.visitors.pageviews, 0)++ if (pageviews === 0 && daily.customEvents.length === 0) return++ const sessionCount = visits > 0 ? visits : pageviews > 0 ? 1 : 0+ if (sessionCount === 0) return++ const pools = buildPools(daily, importID, date)+ const fallbackHost = pickSiteHostname(daily.pages)+ const dayStartSec = dateToEpochSec(date)+ const dayEndSec = dayStartSec + 86399+ const sessionSpacingSec =+ sessionCount > 1 ? Math.floor(86400 / sessionCount) : 86400++ const cappedPageviews = Math.min(+ pageviews,+ sessionCount * MAX_PAGEVIEWS_PER_SESSION,+ )+ const basePerSession = Math.min(+ Math.floor(cappedPageviews / sessionCount),+ MAX_PAGEVIEWS_PER_SESSION,+ )+ const remainder = cappedPageviews % sessionCount++ const avgVisitDuration =+ sessionCount > 0 ? daily.visitors.visit_duration / sessionCount : 0++ interface SessionInfo {+ psid: string+ browser: BrowserRow | null+ device: DeviceRow | null+ os: OsRow | null+ location: LocationRow | null+ source: SourceRow | null+ host: string | null+ startSec: number+ }++ const sessions: SessionInfo[] = []++ for (let i = 0; i < sessionCount; i++) {+ const psid = sessionIdToPsid(`${importID}|${date}|${i}`)++ const browser = pickFromPool(pools.browsers, i)+ const device = pickFromPool(pools.devices, i)+ const os = pickFromPool(pools.os, i)+ const location = pickFromPool(pools.locations, i)+ const source = pickFromPool(pools.sources, i)++ const startSec = dayStartSec + i * sessionSpacingSec++ sessions.push({+ psid,+ browser,+ device,+ os,+ location,+ source,+ host: fallbackHost,+ startSec,+ })+ }++ let middlePageIdx = 0++ for (let i = 0; i < sessions.length; i++) {+ const session = sessions[i]+ const pvCount = basePerSession + (i < remainder ? 1 : 0)+ if (pvCount <= 0) continue++ const entryPage = pickFromPool(pools.entryPages, i)+ const exitPage = pickFromPool(pools.exitPages, i)++ const pages: PageRow[] = []+ const entryPagePath = entryPage?.entry_page ?? null+ const exitPagePath = exitPage?.exit_page ?? null++ for (let j = 0; j < pvCount; j++) {+ if (j === 0 && entryPagePath) {+ pages.push({+ hostname: session.host,+ page: entryPagePath,+ pageviews: 1,+ })+ continue+ }+ if (j === pvCount - 1 && pvCount > 1 && exitPagePath) {+ pages.push({+ hostname: session.host,+ page: exitPagePath,+ pageviews: 1,+ })+ continue+ }+ const sampled = pickFromPool(pools.pages, middlePageIdx++)+ if (sampled) {+ pages.push(sampled)+ } else if (entryPagePath || exitPagePath) {+ pages.push({+ hostname: session.host,+ page: entryPagePath ?? exitPagePath,+ pageviews: 1,+ })+ } else {+ pages.push({ hostname: session.host, page: '/', pageviews: 1 })+ }+ }++ let pageGapSec = MIN_PAGE_GAP_SEC+ if (pvCount > 1) {+ pageGapSec = Math.round(avgVisitDuration / Math.max(pvCount - 1, 1))+ if (pageGapSec < MIN_PAGE_GAP_SEC) pageGapSec = MIN_PAGE_GAP_SEC+ if (pageGapSec > MAX_PAGE_GAP_SEC) pageGapSec = MAX_PAGE_GAP_SEC+ }++ for (let j = 0; j < pages.length; j++) {+ const page = pages[j]+ const rawTsSec = session.startSec + j * pageGapSec+ const tsSec = rawTsSec > dayEndSec ? dayEndSec : rawTsSec+ const created = formatDateTime(tsSec)++ const data = this.buildEventData({+ pid,+ importID,+ psid: session.psid,+ browser: session.browser,+ device: session.device,+ os: session.os,+ location: session.location,+ source: session.source,+ host: page.hostname ?? session.host,+ page: page.page,+ created,+ })++ yield { table: 'analytics', data }+ }+ }++ if (daily.customEvents.length > 0 && sessions.length > 0) {+ for (const ev of daily.customEvents) {+ const eventSeed = seedFromString(`${importID}|${date}|ev|${ev.name}`)+ const evPrng = seededPrng(eventSeed)+ const eventCount = Math.min(Math.max(ev.events, 0), MAX_EVENTS_PER_DAY)++ for (let k = 0; k < eventCount; k++) {+ const sessionIdx = Math.floor(evPrng() * sessions.length)+ const session = sessions[Math.min(sessionIdx, sessions.length - 1)]+ const tsSec =+ session.startSec + Math.floor(evPrng() * sessionSpacingSec)+ const created = formatDateTime(tsSec)++ const data = this.buildEventData({+ pid,+ importID,+ psid: session.psid,+ browser: session.browser,+ device: session.device,+ os: session.os,+ location: session.location,+ source: session.source,+ host: session.host,+ page: null,+ created,+ })+ data.ev = truncate(ev.name, 256) || ''+ yield { table: 'customEV', data }+ }+ }+ }+ }++ private buildEventData(args: {+ pid: string+ importID: number+ psid: string+ browser: BrowserRow | null+ device: DeviceRow | null+ os: OsRow | null+ location: LocationRow | null+ source: SourceRow | null+ host: string | null+ page: string | null+ created: string+ }): Record<string, unknown> {+ const device = mapDevice(args.device?.device ?? null)+ const browser = mapBrowser(args.browser?.browser ?? null, device)+ const os = mapOS(args.os?.operating_system ?? null)++ const cc = args.location?.country+ const validCC = cc && /^[A-Z]{2}$/.test(cc) ? cc : null+ const rgc = parseRegion(args.location?.region ?? null)++ const ref = buildReferrer(+ args.source?.referrer ?? null,+ args.source?.source ?? null,+ args.host,+ )++ return {+ psid: args.psid,+ profileId: null,+ pid: args.pid,+ host: truncate(args.host, 253),+ pg: truncate(args.page, 2048),+ dv: device,+ br: truncate(browser, 30),+ brv: truncate(args.browser?.browser_version ?? null, 20),+ os: truncate(os, 25),+ osv: truncate(args.os?.operating_system_version ?? null, 20),+ lc: null,+ ref: truncate(ref, 2048),+ so: truncate(args.source?.utm_source ?? null, 256),+ me: truncate(args.source?.utm_medium ?? null, 256),+ ca: truncate(args.source?.utm_campaign ?? null, 256),+ te: truncate(args.source?.utm_term ?? null, 256),+ co: truncate(args.source?.utm_content ?? null, 256),+ cc: validCC,+ rg: null,+ rgc,+ ct: null,+ 'meta.key': [],+ 'meta.value': [],+ importID: args.importID,+ created: args.created,+ }+ }+}diff --git a/backend/apps/community/src/data-import/mappers/index.ts b/backend/apps/community/src/data-import/mappers/index.tsindex e967d14c0..ce163a82d 100644--- a/backend/apps/community/src/data-import/mappers/index.ts+++ b/backend/apps/community/src/data-import/mappers/index.ts@@ -2,17 +2,20 @@ import { ImportMapper } from './mapper.interface'import { UmamiMapper } from './umami.mapper'import { SimpleAnalyticsMapper } from './simple-analytics.mapper'import { FathomMapper } from './fathom.mapper'+import { PlausibleMapper } from './plausible.mapper'export const SUPPORTED_PROVIDERS = ['umami','simple-analytics','fathom',+ 'plausible',] as constconst mappers: Record<string, ImportMapper> = {umami: new UmamiMapper(),'simple-analytics': new SimpleAnalyticsMapper(),fathom: new FathomMapper(),+ plausible: new PlausibleMapper(),}export function getMapper(provider: string): ImportMapper | undefined {diff --git a/backend/apps/community/src/data-import/mappers/mapper.interface.ts b/backend/apps/community/src/data-import/mappers/mapper.interface.tsindex 68cc5c3e8..b7bdc9bf0 100644--- a/backend/apps/community/src/data-import/mappers/mapper.interface.ts+++ b/backend/apps/community/src/data-import/mappers/mapper.interface.ts@@ -1,3 +1,10 @@+export class ImportError extends Error {+ constructor(message: string) {+ super(message)+ this.name = 'ImportError'+ }+}+export interface AnalyticsImportRow {table: 'analytics' | 'customEV'data: Record<string, unknown>diff --git a/backend/apps/community/src/data-import/mappers/plausible.mapper.ts b/backend/apps/community/src/data-import/mappers/plausible.mapper.tsnew file mode 100644index 000000000..99141bb58--- /dev/null+++ b/backend/apps/community/src/data-import/mappers/plausible.mapper.ts@@ -0,0 +1,954 @@+import * as fs from 'fs'+import * as path from 'path'+import * as crypto from 'crypto'+import { unzipSync, UnzipFileInfo } from 'fflate'+import { parse as parseSync } from 'csv-parse/sync'++import {+ ImportMapper,+ ImportError,+ AnalyticsImportRow,+} from './mapper.interface'+import {+ normalizeNull,+ truncate,+ sessionIdToPsid,+ MOBILE_BROWSER_VARIANTS,+} from './mapper.utils'++const MAX_PLAUSIBLE_ZIP_BYTES = 100 * 1024 * 1024+const MAX_PLAUSIBLE_UNCOMPRESSED_BYTES = 500 * 1024 * 1024+const MAX_CSV_BYTES = 50 * 1024 * 1024+const MIN_PAGE_GAP_SEC = 5+const MAX_PAGE_GAP_SEC = 30 * 60+const DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/++const MAX_SESSIONS_PER_DAY = 1_000_000+const MAX_PAGEVIEWS_PER_SESSION = 1_000+const MAX_EVENTS_PER_DAY = 1_000_000+const MAX_GENERATED_ROWS_PER_IMPORT = 100_000_000+const MAX_SAFE_COUNT = Number.MAX_SAFE_INTEGER++const FILE_PATTERNS: Record<string, RegExp> = {+ visitors: /(^|\/)imported_visitors[^/]*\.csv$/i,+ pages: /(^|\/)imported_pages[^/]*\.csv$/i,+ browsers: /(^|\/)imported_browsers[^/]*\.csv$/i,+ devices: /(^|\/)imported_devices[^/]*\.csv$/i,+ operatingSystems: /(^|\/)imported_operating_systems[^/]*\.csv$/i,+ locations: /(^|\/)imported_locations[^/]*\.csv$/i,+ sources: /(^|\/)imported_sources[^/]*\.csv$/i,+ entryPages: /(^|\/)imported_entry_pages[^/]*\.csv$/i,+ exitPages: /(^|\/)imported_exit_pages[^/]*\.csv$/i,+ customEvents: /(^|\/)imported_custom_events[^/]*\.csv$/i,+}++const OS_MAP: Record<string, string> = {+ Mac: 'macOS',+ GNU: 'Linux',+ Ubuntu: 'Linux',+ iOS: 'iOS',+ Android: 'Android',+ Windows: 'Windows',+ 'Chrome OS': 'Chrome OS',+}++const DEVICE_MAP: Record<string, string> = {+ Desktop: 'desktop',+ Laptop: 'desktop',+ Mobile: 'mobile',+ Tablet: 'tablet',+}++interface VisitorRow {+ date: string+ visitors: number+ pageviews: number+ visits: number+ bounces: number+ visit_duration: number+}++interface BrowserRow {+ browser: string | null+ browser_version: string | null+ visits: number+}++interface DeviceRow {+ device: string | null+ visits: number+}++interface OsRow {+ operating_system: string | null+ operating_system_version: string | null+ visits: number+}++interface LocationRow {+ country: string | null+ region: string | null+ visits: number+}++interface SourceRow {+ source: string | null+ referrer: string | null+ utm_source: string | null+ utm_medium: string | null+ utm_campaign: string | null+ utm_content: string | null+ utm_term: string | null+ visits: number+}++interface PageRow {+ hostname: string | null+ page: string | null+ pageviews: number+}++interface EntryPageRow {+ entry_page: string | null+ entrances: number+}++interface ExitPageRow {+ exit_page: string | null+ exits: number+}++interface CustomEventRow {+ name: string+ events: number+}++interface DailyData {+ visitors: VisitorRow+ browsers: BrowserRow[]+ devices: DeviceRow[]+ os: OsRow[]+ locations: LocationRow[]+ sources: SourceRow[]+ pages: PageRow[]+ entryPages: EntryPageRow[]+ exitPages: ExitPageRow[]+ customEvents: CustomEventRow[]+}++function seededPrng(seed: number): () => number {+ let s = seed >>> 0+ return () => {+ s = (s + 0x6d2b79f5) >>> 0+ let t = s+ t = Math.imul(t ^ (t >>> 15), t | 1)+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61)+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296+ }+}++function seedFromString(s: string): number {+ return crypto.createHash('sha256').update(s).digest().readUInt32BE(0)+}++function toInt(value: string | undefined, fieldName = 'value'): number {+ if (value === undefined || value === null || value === '') return 0+ const n = parseInt(value, 10)+ if (!Number.isFinite(n) || Number.isNaN(n) || !Number.isSafeInteger(n)) {+ throw new ImportError(+ `Plausible export contains an invalid numeric ${fieldName}: ${value}`,+ )+ }+ if (n < 0) {+ throw new ImportError(+ `Plausible export contains a negative numeric ${fieldName}: ${value}`,+ )+ }+ return Math.min(n, MAX_SAFE_COUNT)+}++function parseCsv(bytes: Uint8Array): Record<string, string>[] {+ if (bytes.length > MAX_CSV_BYTES) {+ throw new ImportError(+ `Plausible export contains a CSV larger than ${MAX_CSV_BYTES} bytes.`,+ )+ }+ return parseSync(Buffer.from(bytes), {+ bom: true,+ columns: true,+ skip_empty_lines: true,+ trim: true,+ relax_quotes: true,+ relax_column_count: true,+ }) as Record<string, string>[]+}++function mapBrowser(raw: string | null, device: string | null): string | null {+ if (!raw) return null+ const isMobile = device === 'mobile' || device === 'tablet'+ if (isMobile && MOBILE_BROWSER_VARIANTS[raw]) {+ return MOBILE_BROWSER_VARIANTS[raw]+ }+ return raw+}++function mapOS(raw: string | null): string | null {+ if (!raw) return null+ return OS_MAP[raw] ?? raw+}++function mapDevice(raw: string | null): string {+ if (!raw) return 'desktop'+ return DEVICE_MAP[raw] ?? raw.toLowerCase()+}++function parseRegion(raw: string | null): string | null {+ if (!raw) return null+ const dash = raw.indexOf('-')+ if (dash < 0) return raw.slice(0, 10)+ return raw.slice(dash + 1).slice(0, 10) || null+}++function buildReferrer(+ referrer: string | null,+ source: string | null,+ hostname: string | null,+): string | null {+ const candidate = referrer || source+ if (!candidate || candidate.toLowerCase() === 'direct') return null++ let url: string+ if (candidate.includes('://')) {+ url = candidate+ } else if (candidate.includes('.')) {+ url = `https://${candidate}`+ } else {+ return null+ }++ if (hostname) {+ try {+ const parsed = new URL(url)+ const cleanRef = parsed.hostname.replace(/^www\./, '')+ const cleanHost = hostname.replace(/^www\./, '')+ if (cleanRef === cleanHost) return null+ } catch {+ // ignore+ }+ }++ return url+}++function pickSiteHostname(pages: PageRow[]): string | null {+ if (pages.length === 0) return null+ const counts = new Map<string, number>()+ for (const p of pages) {+ if (!p.hostname) continue+ counts.set(p.hostname, (counts.get(p.hostname) ?? 0) + p.pageviews)+ }+ let best: string | null = null+ let bestCount = -1+ for (const [host, count] of counts) {+ if (count > bestCount) {+ best = host+ bestCount = count+ }+ }+ return best+}++const MAX_POOL_SIZE = 2_000_000++function buildShuffledPool<T>(+ items: T[],+ counts: number[],+ prng: () => number,+): T[] {+ if (items.length === 0) return []++ const safeCounts: number[] = new Array(items.length)+ let total = 0+ for (let i = 0; i < items.length; i++) {+ const c = counts[i]+ const safe = c > 0 ? c : 0+ safeCounts[i] = safe+ total += safe+ }+ if (total <= 0) return []++ // Allocate per-item slots, scaling proportionally if the total would+ // exceed MAX_POOL_SIZE. Largest-remainder method keeps the assigned+ // counts as close to the original ratios as possible while preserving+ // the exact target total.+ let allocations: number[]+ let poolSize: number+ if (total > MAX_POOL_SIZE) {+ allocations = new Array(items.length).fill(0)+ const fractions: { idx: number; rem: number }[] = []+ let assigned = 0+ for (let i = 0; i < items.length; i++) {+ if (safeCounts[i] === 0) continue+ const scaled = (safeCounts[i] * MAX_POOL_SIZE) / total+ const floor = Math.floor(scaled)+ allocations[i] = floor+ assigned += floor+ fractions.push({ idx: i, rem: scaled - floor })+ }+ fractions.sort((a, b) => b.rem - a.rem || a.idx - b.idx)+ let remaining = MAX_POOL_SIZE - assigned+ for (let i = 0; i < fractions.length && remaining > 0; i++) {+ allocations[fractions[i].idx] += 1+ remaining -= 1+ }+ poolSize = MAX_POOL_SIZE+ } else {+ allocations = safeCounts+ poolSize = total+ }++ const pool: T[] = new Array(poolSize)+ let p = 0+ for (let i = 0; i < items.length; i++) {+ const c = allocations[i]+ for (let j = 0; j < c; j++) {+ pool[p++] = items[i]+ }+ }++ for (let i = pool.length - 1; i > 0; i--) {+ const j = Math.floor(prng() * (i + 1))+ const tmp = pool[i]+ pool[i] = pool[j]+ pool[j] = tmp+ }++ return pool+}++function pickFromPool<T>(pool: T[], idx: number): T | null {+ if (pool.length === 0) return null+ return pool[idx % pool.length]+}++interface PoolBundle {+ browsers: BrowserRow[]+ devices: DeviceRow[]+ os: OsRow[]+ locations: LocationRow[]+ sources: SourceRow[]+ pages: PageRow[]+ entryPages: EntryPageRow[]+ exitPages: ExitPageRow[]+}++function buildPools(+ daily: DailyData,+ importID: number,+ date: string,+): PoolBundle {+ const seedFor = (label: string) =>+ seededPrng(seedFromString(`${importID}|${date}|pool|${label}`))++ return {+ browsers: buildShuffledPool(+ daily.browsers,+ daily.browsers.map((r) => r.visits),+ seedFor('browsers'),+ ),+ devices: buildShuffledPool(+ daily.devices,+ daily.devices.map((r) => r.visits),+ seedFor('devices'),+ ),+ os: buildShuffledPool(+ daily.os,+ daily.os.map((r) => r.visits),+ seedFor('os'),+ ),+ locations: buildShuffledPool(+ daily.locations,+ daily.locations.map((r) => r.visits),+ seedFor('locations'),+ ),+ sources: buildShuffledPool(+ daily.sources,+ daily.sources.map((r) => r.visits),+ seedFor('sources'),+ ),+ pages: buildShuffledPool(+ daily.pages,+ daily.pages.map((r) => r.pageviews),+ seedFor('pages'),+ ),+ entryPages: buildShuffledPool(+ daily.entryPages,+ daily.entryPages.map((r) => r.entrances),+ seedFor('entryPages'),+ ),+ exitPages: buildShuffledPool(+ daily.exitPages,+ daily.exitPages.map((r) => r.exits),+ seedFor('exitPages'),+ ),+ }+}++function formatDateTime(epochSec: number): string {+ const d = new Date(epochSec * 1000)+ const yyyy = d.getUTCFullYear()+ const mm = String(d.getUTCMonth() + 1).padStart(2, '0')+ const dd = String(d.getUTCDate()).padStart(2, '0')+ const hh = String(d.getUTCHours()).padStart(2, '0')+ const mi = String(d.getUTCMinutes()).padStart(2, '0')+ const ss = String(d.getUTCSeconds()).padStart(2, '0')+ return `${yyyy}-${mm}-${dd} ${hh}:${mi}:${ss}`+}++function dateToEpochSec(date: string): number {+ return Math.floor(new Date(`${date}T00:00:00Z`).getTime() / 1000)+}++export class PlausibleMapper implements ImportMapper {+ readonly provider = 'plausible'+ readonly expectedFileExtension = '.zip'++ private extractCsvs(zipPath: string): Map<string, Uint8Array> {+ const stat = fs.statSync(zipPath)+ if (stat.size > MAX_PLAUSIBLE_ZIP_BYTES) {+ throw new ImportError(+ `Plausible ZIP exceeds the ${MAX_PLAUSIBLE_ZIP_BYTES} byte limit.`,+ )+ }++ const buf = fs.readFileSync(zipPath)++ const matchedKeys = new Set<string>()+ const nameToKey = new Map<string, string>()+ let totalUncompressed = 0++ const filter = (file: UnzipFileInfo): boolean => {+ const base = path.basename(file.name).toLowerCase()+ if (!base.endsWith('.csv')) return false+ for (const [key, pattern] of Object.entries(FILE_PATTERNS)) {+ if (matchedKeys.has(key)) continue+ if (!pattern.test(file.name)) continue++ const declaredSize = Number.isSafeInteger(file.originalSize)+ ? file.originalSize+ : -1+ if (declaredSize < 0) {+ throw new ImportError(+ `Plausible ZIP entry ${file.name} reports an invalid uncompressed size.`,+ )+ }+ if (declaredSize > MAX_CSV_BYTES) {+ throw new ImportError(+ `Plausible ZIP entry ${file.name} exceeds the ${MAX_CSV_BYTES} byte CSV limit (declared ${declaredSize}).`,+ )+ }+ if (+ totalUncompressed + declaredSize >+ MAX_PLAUSIBLE_UNCOMPRESSED_BYTES+ ) {+ throw new ImportError(+ `Plausible ZIP uncompressed size exceeds the ${MAX_PLAUSIBLE_UNCOMPRESSED_BYTES} byte limit.`,+ )+ }+ totalUncompressed += declaredSize+ matchedKeys.add(key)+ nameToKey.set(file.name, key)+ return true+ }+ return false+ }++ let entries: Record<string, Uint8Array>+ try {+ entries = unzipSync(+ new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength),+ { filter },+ )+ } catch (err) {+ if (err instanceof ImportError) throw err+ throw new ImportError(+ 'Could not read the uploaded file as a ZIP archive. Please upload the export ZIP from Plausible.',+ )+ }++ const found = new Map<string, Uint8Array>()+ for (const [name, data] of Object.entries(entries)) {+ const key = nameToKey.get(name)+ if (!key || found.has(key)) continue+ if (data.byteLength > MAX_CSV_BYTES) {+ throw new ImportError(+ `Plausible ZIP entry ${name} exceeds the ${MAX_CSV_BYTES} byte CSV limit after decompression.`,+ )+ }+ found.set(key, data)+ }++ return found+ }++ private buildDailyData(+ csvs: Map<string, Uint8Array>,+ ): Map<string, DailyData> {+ const visitorsBytes = csvs.get('visitors')+ if (!visitorsBytes) {+ throw new ImportError(+ 'ZIP does not contain imported_visitors_*.csv. Please upload the full export ZIP from Plausible.',+ )+ }++ const days = new Map<string, DailyData>()++ const ensureDay = (date: string): DailyData => {+ let d = days.get(date)+ if (!d) {+ d = {+ visitors: {+ date,+ visitors: 0,+ pageviews: 0,+ visits: 0,+ bounces: 0,+ visit_duration: 0,+ },+ browsers: [],+ devices: [],+ os: [],+ locations: [],+ sources: [],+ pages: [],+ entryPages: [],+ exitPages: [],+ customEvents: [],+ }+ days.set(date, d)+ }+ return d+ }++ for (const row of parseCsv(visitorsBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !DATE_REGEX.test(date)) continue+ const visits = toInt(row.visits, 'visits')+ const pageviews = toInt(row.pageviews, 'pageviews')+ if (visits <= 0 && pageviews <= 0) continue+ const day = ensureDay(date)+ day.visitors = {+ date,+ visitors: toInt(row.visitors, 'visitors'),+ pageviews,+ visits,+ bounces: toInt(row.bounces, 'bounces'),+ visit_duration: toInt(row.visit_duration, 'visit_duration'),+ }+ }++ if (days.size === 0) {+ throw new ImportError(+ 'imported_visitors_*.csv contains no valid daily rows.',+ )+ }++ const pagesBytes = csvs.get('pages')+ if (pagesBytes) {+ for (const row of parseCsv(pagesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const pageviews = toInt(row.pageviews)+ if (pageviews <= 0) continue+ days.get(date)!.pages.push({+ hostname: normalizeNull(row.hostname),+ page: normalizeNull(row.page),+ pageviews,+ })+ }+ }++ const browsersBytes = csvs.get('browsers')+ if (browsersBytes) {+ for (const row of parseCsv(browsersBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.browsers.push({+ browser: normalizeNull(row.browser),+ browser_version: normalizeNull(row.browser_version),+ visits,+ })+ }+ }++ const devicesBytes = csvs.get('devices')+ if (devicesBytes) {+ for (const row of parseCsv(devicesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.devices.push({+ device: normalizeNull(row.device),+ visits,+ })+ }+ }++ const osBytes = csvs.get('operatingSystems')+ if (osBytes) {+ for (const row of parseCsv(osBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.os.push({+ operating_system: normalizeNull(row.operating_system),+ operating_system_version: normalizeNull(row.operating_system_version),+ visits,+ })+ }+ }++ const locationsBytes = csvs.get('locations')+ if (locationsBytes) {+ for (const row of parseCsv(locationsBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.locations.push({+ country: normalizeNull(row.country),+ region: normalizeNull(row.region),+ visits,+ })+ }+ }++ const sourcesBytes = csvs.get('sources')+ if (sourcesBytes) {+ for (const row of parseCsv(sourcesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const visits = toInt(row.visits)+ if (visits <= 0) continue+ days.get(date)!.sources.push({+ source: normalizeNull(row.source),+ referrer: normalizeNull(row.referrer),+ utm_source: normalizeNull(row.utm_source),+ utm_medium: normalizeNull(row.utm_medium),+ utm_campaign: normalizeNull(row.utm_campaign),+ utm_content: normalizeNull(row.utm_content),+ utm_term: normalizeNull(row.utm_term),+ visits,+ })+ }+ }++ const entryPagesBytes = csvs.get('entryPages')+ if (entryPagesBytes) {+ for (const row of parseCsv(entryPagesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const entrances = toInt(row.entrances)+ if (entrances <= 0) continue+ days.get(date)!.entryPages.push({+ entry_page: normalizeNull(row.entry_page),+ entrances,+ })+ }+ }++ const exitPagesBytes = csvs.get('exitPages')+ if (exitPagesBytes) {+ for (const row of parseCsv(exitPagesBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const exits = toInt(row.exits)+ if (exits <= 0) continue+ days.get(date)!.exitPages.push({+ exit_page: normalizeNull(row.exit_page),+ exits,+ })+ }+ }++ const customEventsBytes = csvs.get('customEvents')+ if (customEventsBytes) {+ for (const row of parseCsv(customEventsBytes)) {+ const date = normalizeNull(row.date)+ if (!date || !days.has(date)) continue+ const name = normalizeNull(row.name)+ const events = toInt(row.events, 'events')+ if (!name || events <= 0) continue+ days.get(date)!.customEvents.push({ name, events })+ }+ }++ return days+ }++ async *createRowStream(+ filePath: string,+ pid: string,+ importID: number,+ ): AsyncIterable<AnalyticsImportRow> {+ const csvs = this.extractCsvs(filePath)+ const days = this.buildDailyData(csvs)+ const sortedDates = Array.from(days.keys()).sort()++ let yielded = 0+ for (const date of sortedDates) {+ const daily = days.get(date)!+ for (const row of this.synthesizeDay(daily, pid, importID)) {+ yielded += 1+ if (yielded > MAX_GENERATED_ROWS_PER_IMPORT) {+ throw new ImportError(+ `Plausible export would generate more than ${MAX_GENERATED_ROWS_PER_IMPORT} rows. Please split the export into smaller archives and re-import.`,+ )+ }+ yield row+ }+ }+ }++ private *synthesizeDay(+ daily: DailyData,+ pid: string,+ importID: number,+ ): Iterable<AnalyticsImportRow> {+ const { date } = daily.visitors+ const visits = Math.min(+ Math.max(daily.visitors.visits, 0),+ MAX_SESSIONS_PER_DAY,+ )+ const pageviews = Math.max(daily.visitors.pageviews, 0)++ if (pageviews === 0 && daily.customEvents.length === 0) return++ const sessionCount = visits > 0 ? visits : pageviews > 0 ? 1 : 0+ if (sessionCount === 0) return++ const pools = buildPools(daily, importID, date)+ const fallbackHost = pickSiteHostname(daily.pages)+ const dayStartSec = dateToEpochSec(date)+ const dayEndSec = dayStartSec + 86399+ const sessionSpacingSec =+ sessionCount > 1 ? Math.floor(86400 / sessionCount) : 86400++ const cappedPageviews = Math.min(+ pageviews,+ sessionCount * MAX_PAGEVIEWS_PER_SESSION,+ )+ const basePerSession = Math.min(+ Math.floor(cappedPageviews / sessionCount),+ MAX_PAGEVIEWS_PER_SESSION,+ )+ const remainder = cappedPageviews % sessionCount++ const avgVisitDuration =+ sessionCount > 0 ? daily.visitors.visit_duration / sessionCount : 0++ interface SessionInfo {+ psid: string+ browser: BrowserRow | null+ device: DeviceRow | null+ os: OsRow | null+ location: LocationRow | null+ source: SourceRow | null+ host: string | null+ startSec: number+ }++ const sessions: SessionInfo[] = []++ for (let i = 0; i < sessionCount; i++) {+ const psid = sessionIdToPsid(`${importID}|${date}|${i}`)++ const browser = pickFromPool(pools.browsers, i)+ const device = pickFromPool(pools.devices, i)+ const os = pickFromPool(pools.os, i)+ const location = pickFromPool(pools.locations, i)+ const source = pickFromPool(pools.sources, i)++ const startSec = dayStartSec + i * sessionSpacingSec++ sessions.push({+ psid,+ browser,+ device,+ os,+ location,+ source,+ host: fallbackHost,+ startSec,+ })+ }++ let middlePageIdx = 0++ for (let i = 0; i < sessions.length; i++) {+ const session = sessions[i]+ const pvCount = basePerSession + (i < remainder ? 1 : 0)+ if (pvCount <= 0) continue++ const entryPage = pickFromPool(pools.entryPages, i)+ const exitPage = pickFromPool(pools.exitPages, i)++ const pages: PageRow[] = []+ const entryPagePath = entryPage?.entry_page ?? null+ const exitPagePath = exitPage?.exit_page ?? null++ for (let j = 0; j < pvCount; j++) {+ if (j === 0 && entryPagePath) {+ pages.push({+ hostname: session.host,+ page: entryPagePath,+ pageviews: 1,+ })+ continue+ }+ if (j === pvCount - 1 && pvCount > 1 && exitPagePath) {+ pages.push({+ hostname: session.host,+ page: exitPagePath,+ pageviews: 1,+ })+ continue+ }+ const sampled = pickFromPool(pools.pages, middlePageIdx++)+ if (sampled) {+ pages.push(sampled)+ } else if (entryPagePath || exitPagePath) {+ pages.push({+ hostname: session.host,+ page: entryPagePath ?? exitPagePath,+ pageviews: 1,+ })+ } else {+ pages.push({ hostname: session.host, page: '/', pageviews: 1 })+ }+ }++ let pageGapSec = MIN_PAGE_GAP_SEC+ if (pvCount > 1) {+ pageGapSec = Math.round(avgVisitDuration / Math.max(pvCount - 1, 1))+ if (pageGapSec < MIN_PAGE_GAP_SEC) pageGapSec = MIN_PAGE_GAP_SEC+ if (pageGapSec > MAX_PAGE_GAP_SEC) pageGapSec = MAX_PAGE_GAP_SEC+ }++ for (let j = 0; j < pages.length; j++) {+ const page = pages[j]+ const rawTsSec = session.startSec + j * pageGapSec+ const tsSec = rawTsSec > dayEndSec ? dayEndSec : rawTsSec+ const created = formatDateTime(tsSec)++ const data = this.buildEventData({+ pid,+ importID,+ psid: session.psid,+ browser: session.browser,+ device: session.device,+ os: session.os,+ location: session.location,+ source: session.source,+ host: page.hostname ?? session.host,+ page: page.page,+ created,+ })++ yield { table: 'analytics', data }+ }+ }++ if (daily.customEvents.length > 0 && sessions.length > 0) {+ for (const ev of daily.customEvents) {+ const eventSeed = seedFromString(`${importID}|${date}|ev|${ev.name}`)+ const evPrng = seededPrng(eventSeed)+ const eventCount = Math.min(Math.max(ev.events, 0), MAX_EVENTS_PER_DAY)++ for (let k = 0; k < eventCount; k++) {+ const sessionIdx = Math.floor(evPrng() * sessions.length)+ const session = sessions[Math.min(sessionIdx, sessions.length - 1)]+ const tsSec =+ session.startSec + Math.floor(evPrng() * sessionSpacingSec)+ const created = formatDateTime(tsSec)++ const data = this.buildEventData({+ pid,+ importID,+ psid: session.psid,+ browser: session.browser,+ device: session.device,+ os: session.os,+ location: session.location,+ source: session.source,+ host: session.host,+ page: null,+ created,+ })+ data.ev = truncate(ev.name, 256) || ''+ yield { table: 'customEV', data }+ }+ }+ }+ }++ private buildEventData(args: {+ pid: string+ importID: number+ psid: string+ browser: BrowserRow | null+ device: DeviceRow | null+ os: OsRow | null+ location: LocationRow | null+ source: SourceRow | null+ host: string | null+ page: string | null+ created: string+ }): Record<string, unknown> {+ const device = mapDevice(args.device?.device ?? null)+ const browser = mapBrowser(args.browser?.browser ?? null, device)+ const os = mapOS(args.os?.operating_system ?? null)++ const cc = args.location?.country+ const validCC = cc && /^[A-Z]{2}$/.test(cc) ? cc : null+ const rgc = parseRegion(args.location?.region ?? null)++ const ref = buildReferrer(+ args.source?.referrer ?? null,+ args.source?.source ?? null,+ args.host,+ )++ return {+ psid: args.psid,+ profileId: null,+ pid: args.pid,+ host: truncate(args.host, 253),+ pg: truncate(args.page, 2048),+ dv: device,+ br: truncate(browser, 30),+ brv: truncate(args.browser?.browser_version ?? null, 20),+ os: truncate(os, 25),+ osv: truncate(args.os?.operating_system_version ?? null, 20),+ lc: null,+ ref: truncate(ref, 2048),+ so: truncate(args.source?.utm_source ?? null, 256),+ me: truncate(args.source?.utm_medium ?? null, 256),+ ca: truncate(args.source?.utm_campaign ?? null, 256),+ te: truncate(args.source?.utm_term ?? null, 256),+ co: truncate(args.source?.utm_content ?? null, 256),+ cc: validCC,+ rg: null,+ rgc,+ ct: null,+ 'meta.key': [],+ 'meta.value': [],+ importID: args.importID,+ created: args.created,+ }+ }+}diff --git a/docs/components/provider-icons.tsx b/docs/components/provider-icons.tsxindex 043b47d0e..729d6d93e 100644--- a/docs/components/provider-icons.tsx+++ b/docs/components/provider-icons.tsx@@ -40,6 +40,43 @@ export const SimpleAnalyticsIcon = ({ className }: { className?: string }) => (</svg>);+export const PlausibleIcon = ({ className }: { className?: string }) => (+ <svg className={className} viewBox="0 0 47 60" fill="none" width="16" height="16">+ <defs>+ <linearGradient+ id="plausibleDocsGradient1"+ x1="14.8413403"+ y1="22.5436904"+ x2="27.4731407"+ y2="44.6493411"+ gradientUnits="userSpaceOnUse"+ >+ <stop offset="0" stopColor="#909cf7" />+ <stop offset="1" stopColor="#4b38d8" />+ </linearGradient>+ <linearGradient+ id="plausibleDocsGradient2"+ x1="7.9837957"+ y1="-1.3582919"+ x2="21.0009873"+ y2="21.4217935"+ gradientUnits="userSpaceOnUse"+ >+ <stop offset="0" stopColor="#909cf7" />+ <stop offset="1" stopColor="#4b38d8" />+ </linearGradient>+ </defs>+ <path+ fill="url(#plausibleDocsGradient1)"+ d="M45.2456059,22.6027536c-1.0911024,10.4557623-10.2327486,18.2272825-20.7452872,18.2272807h-4.047804v9.570007c0,5.3019285-4.2980623,9.5999908-9.5999908,9.5999908H3.3599854c-1.8556687,0-3.3599854-1.5043167-3.3599854-3.3599854v-19.7025146l5.0380685-7.0686343c.9118097-1.2793096,2.587965-1.7566996,4.0369945-1.1497867l2.8657142,1.2002785c1.4444817.6050081,3.1153774.12945,4.0247968-1.1455083l6.7172007-9.417163c.9071158-1.2717288,2.5743943-1.7450816,4.0144283-1.1397262l5.5198678,2.3204187c1.4430268.6066135,3.1137697.1319561,4.0223175-1.1427389l6.4594145-9.0625757c2.0248091,3.5597961,3.0145069,7.7887694,2.5468032,12.2706573Z"+ />+ <path+ fill="url(#plausibleDocsGradient2)"+ d="M3.2920959,28.8726296c.82329-1.1551271,2.0209115-2.0434967,3.4138697-2.3114381,1.0861554-.2089265,2.156905-.0992829,3.1472499.3155174l2.8649902,1.1999512c.1651001.0691528.3388672.104187.5164795.104187.4365845,0,.8488159-.2124634,1.1026611-.5683594l6.5942097-9.2447929c.8231505-1.154021,2.0204067-2.0410099,3.4124878-2.3083136,1.0821376-.2077892,2.1463585-.0989034,3.1282512.3138487l5.5198364,2.3204346c.1665649.0700684.3417969.1055298.5206909.1055298.4351807,0,.8456421-.2113647,1.0979614-.5653687l6.9192505-9.7077637C37.8272145,3.3644409,31.7802174,0,24.9450124,0H3.3599904C1.5043217,0,.000005,1.5043167.000005,3.3599854v30.1316528l3.2920909-4.6190085Z"+ />+ </svg>+);+export const FathomIcon = ({ className }: { className?: string }) => (<svg className={className} viewBox="0 0 67.851 50" width="16" height="16"><g transform="translate(11882.544 12524.362)">diff --git a/docs/content/docs/data-import.mdx b/docs/content/docs/data-import.mdxindex 4acfa004c..5ffba3864 100644--- a/docs/content/docs/data-import.mdx+++ b/docs/content/docs/data-import.mdx@@ -17,6 +17,7 @@ Select your analytics provider below to see the step-by-step import guide.<TabsTrigger value="umami"><UmamiIcon /> Umami</TabsTrigger><TabsTrigger value="simple"><SimpleAnalyticsIcon /> Simple Analytics</TabsTrigger><TabsTrigger value="fathom"><FathomIcon /> Fathom Analytics</TabsTrigger>+ <TabsTrigger value="plausible"><PlausibleIcon /> Plausible Analytics</TabsTrigger></TabsList><TabsContent value="ga4">@@ -272,6 +273,80 @@ The page auto-refreshes while an import is processing. You can navigate away and</Step></Steps>+</TabsContent>+<TabsContent value="plausible">++<Callout type="warn">+ Plausible only allows exporting daily aggregated data — there is no raw event export. Swetrix+ reconstructs synthetic per-event rows from your aggregates so you can browse the data in+ dashboards. Because the mapper samples each dimension's daily distribution independently with+ replacement, single-dimension breakdowns (e.g. top browsers or top pages) are deterministic+ approximations rather than guaranteed exact reproductions of Plausible's report. Only per-day+ totals and the top-level generated counts (sessions, pageviews, custom events) are preserved+ exactly.+</Callout>++<Steps>+<Step>+<h3>Export Your Data from Plausible</h3>++1. Log in to your [Plausible Analytics](https://plausible.io) dashboard+2. Open the site you want to export from+3. Go to **Site Settings** → **Imports & Exports**+4. Click **Export** in the **CSV export** section to download a `.zip` archive++The archive contains one CSV per dimension (`imported_visitors_*.csv`, `imported_pages_*.csv`, `imported_browsers_*.csv`, `imported_devices_*.csv`, `imported_operating_systems_*.csv`, `imported_locations_*.csv`, `imported_sources_*.csv`, `imported_entry_pages_*.csv`, `imported_exit_pages_*.csv`, `imported_custom_events_*.csv`, `imported_custom_props_*.csv`).++You can learn more on how to export your data from Plausible on their [export documentation](https://plausible.io/docs/export-stats).++</Step>+<Step>+<h3>Import into Swetrix</h3>++1. Go to your project's **Settings** page in Swetrix+2. Click the **Import data** tab+3. Click the **Plausible Analytics** provider card+4. In the upload modal, either drag and drop the `.zip` file or click to browse+5. Wait for the upload and processing to complete++<Callout type="warn">+ Upload the `.zip` file from Plausible directly — do not extract it first.+</Callout>++</Step>+<Step>+<h3>Monitor Progress</h3>++After uploading, the import will appear in the **Import history** table below the provider cards. You can see:++- **Status** — Pending, Processing, Completed, or Failed+- **Date range** — The time span of the imported data+- **Rows** — How many synthetic events were generated++The page auto-refreshes while an import is processing.++</Step>+</Steps>++<h3>How the approximation works</h3>++For each day in the export, Swetrix:++1. Reads `imported_visitors_*.csv` to get the day's `visits` (sessions) and `pageviews` totals+2. Builds a probability distribution for each dimension (browser, OS, device, country/region, source/UTM, entry page, exit page, page) weighted by the visits/entrances/exits in the corresponding CSV+3. Generates exactly `visits` synthetic sessions, sampling one value from each dimension's distribution independently with a deterministic PRNG seeded by the import ID and date+4. Distributes the day's `pageviews` across sessions (first page = a sampled entry page, last page = a sampled exit page, middle pages sampled from the pages distribution)+5. Spreads session start times evenly across the 24h window and pageview gaps within a session based on the average `visit_duration` per session++This is deterministic — re-importing the same export produces identical rows.++<h3>What's not imported?</h3>++- **Custom event properties** (`imported_custom_props_*.csv`): Plausible reports property values aggregated separately from event occurrences with no way to attribute a value to a specific event, so these are skipped+- **Cities**: Plausible exports only Geonames numeric city IDs without names, so the city field is left blank+- **Exact session duration / bounce rate per session**: only daily averages are preserved+- **Exact breakdowns**: each dimension is sampled independently with replacement per session, so single-dimension breakdowns are deterministic approximations rather than exact reproductions of Plausible's per-day report, and cross-dimension joints (e.g. "Firefox on macOS in GB") are sampled under an independence assumption and do not match Plausible's joint distributions+</TabsContent></Tabs>diff --git a/docs/mdx-components.tsx b/docs/mdx-components.tsxindex b011c613f..20e114519 100644--- a/docs/mdx-components.tsx+++ b/docs/mdx-components.tsx@@ -7,6 +7,7 @@ import {UmamiIcon,SimpleAnalyticsIcon,FathomIcon,+ PlausibleIcon,} from "@/components/provider-icons";import { Accordion, Accordions } from "fumadocs-ui/components/accordion";import { File, Folder, Files } from "fumadocs-ui/components/files";@@ -27,6 +28,7 @@ export function getMDXComponents(components?: MDXComponents): MDXComponents {UmamiIcon,SimpleAnalyticsIcon,FathomIcon,+ PlausibleIcon,Accordion,Accordions,File,diff --git a/web/app/lib/models/Project.ts b/web/app/lib/models/Project.tsindex 40290ee96..d1d8ff40f 100644--- a/web/app/lib/models/Project.ts+++ b/web/app/lib/models/Project.ts@@ -180,10 +180,12 @@ export type Provider =| 'simple-analytics'| 'fathom'| 'google-analytics'+ | 'plausible'export const IMPORT_PROVIDERS: Provider[] = ['fathom',isSelfhosted ? null : 'google-analytics',+ 'plausible','simple-analytics','umami',].filter((x): x is Provider => !!x)diff --git a/web/app/pages/Project/Settings/components/DataImportTab.tsx b/web/app/pages/Project/Settings/components/DataImportTab.tsxindex 5cd3ee67c..1f3118500 100644--- a/web/app/pages/Project/Settings/components/DataImportTab.tsx+++ b/web/app/pages/Project/Settings/components/DataImportTab.tsx@@ -30,6 +30,7 @@ import UmamiSVG from '~/ui/icons/Umami'import SimpleAnalyticsSVG from '~/ui/icons/SimpleAnalytics'import FathomSVG from '~/ui/icons/Fathom'import GoogleAnalyticsSVG from '~/ui/icons/GoogleAnalytics'+import PlausibleSVG from '~/ui/icons/Plausible'const PROVIDER_ICONS: Record<string,@@ -39,6 +40,7 @@ const PROVIDER_ICONS: Record<'simple-analytics': SimpleAnalyticsSVG,fathom: FathomSVG,'google-analytics': GoogleAnalyticsSVG,+ plausible: PlausibleSVG,}const PROVIDER_DISPLAY_NAMES: Record<string, string> = {@@ -46,14 +48,21 @@ const PROVIDER_DISPLAY_NAMES: Record<string, string> = {'simple-analytics': 'Simple Analytics',fathom: 'Fathom Analytics','google-analytics': 'Google Analytics 4',+ plausible: 'Plausible Analytics',}-const FILE_BASED_PROVIDERS = new Set(['umami', 'simple-analytics', 'fathom'])+const FILE_BASED_PROVIDERS = new Set([+ 'umami',+ 'simple-analytics',+ 'fathom',+ 'plausible',+])const PROVIDER_FILE_TYPES: Record<string, string> = {umami: '.zip','simple-analytics': '.csv',fathom: '.csv',+ plausible: '.zip',}const STATUS_ICONS = {diff --git a/web/app/ui/icons/Plausible.tsx b/web/app/ui/icons/Plausible.tsxnew file mode 100644index 000000000..b0396ca4a--- /dev/null+++ b/web/app/ui/icons/Plausible.tsx@@ -0,0 +1,38 @@+const PlausibleSVG = ({ className }: { className?: string }) => (+ <svg className={className} viewBox='0 0 47 60' fill='none'>+ <defs>+ <linearGradient+ id='plausibleGradient1'+ x1='14.8413403'+ y1='22.5436904'+ x2='27.4731407'+ y2='44.6493411'+ gradientUnits='userSpaceOnUse'+ >+ <stop offset='0' stopColor='#909cf7' />+ <stop offset='1' stopColor='#4b38d8' />+ </linearGradient>+ <linearGradient+ id='plausibleGradient2'+ x1='7.9837957'+ y1='-1.3582919'+ x2='21.0009873'+ y2='21.4217935'+ gradientUnits='userSpaceOnUse'+ >+ <stop offset='0' stopColor='#909cf7' />+ <stop offset='1' stopColor='#4b38d8' />+ </linearGradient>+ </defs>+ <path+ fill='url(#plausibleGradient1)'+ d='M45.2456059,22.6027536c-1.0911024,10.4557623-10.2327486,18.2272825-20.7452872,18.2272807h-4.047804v9.570007c0,5.3019285-4.2980623,9.5999908-9.5999908,9.5999908H3.3599854c-1.8556687,0-3.3599854-1.5043167-3.3599854-3.3599854v-19.7025146l5.0380685-7.0686343c.9118097-1.2793096,2.587965-1.7566996,4.0369945-1.1497867l2.8657142,1.2002785c1.4444817.6050081,3.1153774.12945,4.0247968-1.1455083l6.7172007-9.417163c.9071158-1.2717288,2.5743943-1.7450816,4.0144283-1.1397262l5.5198678,2.3204187c1.4430268.6066135,3.1137697.1319561,4.0223175-1.1427389l6.4594145-9.0625757c2.0248091,3.5597961,3.0145069,7.7887694,2.5468032,12.2706573Z'+ />+ <path+ fill='url(#plausibleGradient2)'+ d='M3.2920959,28.8726296c.82329-1.1551271,2.0209115-2.0434967,3.4138697-2.3114381,1.0861554-.2089265,2.156905-.0992829,3.1472499.3155174l2.8649902,1.1999512c.1651001.0691528.3388672.104187.5164795.104187.4365845,0,.8488159-.2124634,1.1026611-.5683594l6.5942097-9.2447929c.8231505-1.154021,2.0204067-2.0410099,3.4124878-2.3083136,1.0821376-.2077892,2.1463585-.0989034,3.1282512.3138487l5.5198364,2.3204346c.1665649.0700684.3417969.1055298.5206909.1055298.4351807,0,.8456421-.2113647,1.0979614-.5653687l6.9192505-9.7077637C37.8272145,3.3644409,31.7802174,0,24.9450124,0H3.3599904C1.5043217,0,.000005,1.5043167.000005,3.3599854v30.1316528l3.2920909-4.6190085Z'+ />+ </svg>+)++export default PlausibleSVGdiff --git a/web/public/locales/de.json b/web/public/locales/de.jsonindex d5e60f9bc..5e8914b10 100644--- a/web/public/locales/de.json+++ b/web/public/locales/de.json@@ -1853,6 +1853,9 @@"fathom": {"description": "Seitenaufrufe und Ereignisse aus Fathom Analytics-Export importieren"},+ "plausible": {+ "description": "Historische aggregierte Daten aus Plausible Analytics ZIP-Export importieren (approximiert)"+ },"google-analytics": {"description": "Seitenaufrufe und Ereignisse aus Google Analytics 4 importieren","fileType": "Google OAuth",diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex 21a866373..fee1aae7f 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -1853,6 +1853,9 @@"fathom": {"description": "Import pageviews and events from Fathom Analytics export"},+ "plausible": {+ "description": "Import historical aggregates from Plausible Analytics ZIP export (approximated)"+ },"google-analytics": {"description": "Import pageviews and events from Google Analytics 4","fileType": "Google OAuth",diff --git a/web/public/locales/fr.json b/web/public/locales/fr.jsonindex 0496bc2cb..c4b1e37bf 100644--- a/web/public/locales/fr.json+++ b/web/public/locales/fr.json@@ -1853,6 +1853,9 @@"fathom": {"description": "Importer les pages vues et les événements depuis l'exportation Fathom Analytics"},+ "plausible": {+ "description": "Importer les données agrégées historiques depuis l'export ZIP de Plausible Analytics (approximatives)"+ },"google-analytics": {"description": "Importer les pages vues et les événements depuis Google Analytics 4","fileType": "Google OAuth",diff --git a/web/public/locales/pl.json b/web/public/locales/pl.jsonindex 334df5d47..a8cb5995c 100644--- a/web/public/locales/pl.json+++ b/web/public/locales/pl.json@@ -1853,6 +1853,9 @@"fathom": {"description": "Importuj odsłony i zdarzenia z eksportu Fathom Analytics"},+ "plausible": {+ "description": "Importuj historyczne dane zagregowane z eksportu ZIP Plausible Analytics (przybliżone)"+ },"google-analytics": {"description": "Importuj odsłony i zdarzenia z Google Analytics 4","fileType": "Google OAuth",diff --git a/web/public/locales/uk.json b/web/public/locales/uk.jsonindex 9cb34c771..c897305a9 100644--- a/web/public/locales/uk.json+++ b/web/public/locales/uk.json@@ -1853,6 +1853,9 @@"fathom": {"description": "Імпорт переглядів сторінок та подій з експорту Fathom Analytics"},+ "plausible": {+ "description": "Імпортувати історичні агреговані дані з ZIP-експорту Plausible Analytics (наближені)"+ },"google-analytics": {"description": "Імпортувати перегляди сторінок та події з Google Analytics 4","fileType": "Google OAuth",