Skip to content

πŸ“ˆ 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!

feat: Simple Analytics importer

Blue Mouse56dd7840492d
diff --git a/backend/apps/cloud/src/data-import/mappers/index.ts b/backend/apps/cloud/src/data-import/mappers/index.ts
index 5302f3e7c..5bece673a 100644
--- a/backend/apps/cloud/src/data-import/mappers/index.ts
+++ b/backend/apps/cloud/src/data-import/mappers/index.ts
@@ -1,10 +1,12 @@
import { ImportMapper } from './mapper.interface'
import { UmamiMapper } from './umami.mapper'
+import { SimpleAnalyticsMapper } from './simple-analytics.mapper'
-export const SUPPORTED_PROVIDERS = ['umami'] as const
+export const SUPPORTED_PROVIDERS = ['umami', 'simple-analytics'] as const
const mappers: Record<string, ImportMapper> = {
umami: new UmamiMapper(),
+ 'simple-analytics': new SimpleAnalyticsMapper(),
}
export function getMapper(provider: string): ImportMapper | undefined {
diff --git a/backend/apps/cloud/src/data-import/mappers/mapper.utils.ts b/backend/apps/cloud/src/data-import/mappers/mapper.utils.ts
new file mode 100644
index 000000000..f615dc1d0
--- /dev/null
+++ b/backend/apps/cloud/src/data-import/mappers/mapper.utils.ts
@@ -0,0 +1,26 @@
+import * as crypto from 'crypto'
+
+export const MOBILE_BROWSER_VARIANTS: Record<string, string> = {
+ Chrome: 'Mobile Chrome',
+ Firefox: 'Mobile Firefox',
+ Safari: 'Mobile Safari',
+}
+
+export function normalizeNull(value: string | undefined): string | null {
+ if (!value || value === '' || value === '\\N') return null
+ return value
+}
+
+export function truncate(value: string | null, maxLen: number): string | null {
+ if (!value) return null
+ return value.length > maxLen ? value.slice(0, maxLen) : value
+}
+
+export function sessionIdToPsid(sessionId: string): string {
+ return crypto
+ .createHash('sha256')
+ .update(sessionId)
+ .digest()
+ .readBigUInt64BE(0)
+ .toString()
+}
diff --git a/backend/apps/cloud/src/data-import/mappers/simple-analytics.mapper.ts b/backend/apps/cloud/src/data-import/mappers/simple-analytics.mapper.ts
new file mode 100644
index 000000000..f2788b3e9
--- /dev/null
+++ b/backend/apps/cloud/src/data-import/mappers/simple-analytics.mapper.ts
@@ -0,0 +1,178 @@
+import * as fs from 'fs'
+import { parse } from 'csv-parse'
+
+import {
+ ImportMapper,
+ ImportError,
+ AnalyticsImportRow,
+} from './mapper.interface'
+import {
+ normalizeNull,
+ truncate,
+ sessionIdToPsid,
+ MOBILE_BROWSER_VARIANTS,
+} from './mapper.utils'
+
+const ISO_DATE_REGEX =
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})$/
+
+function isoToClickHouseDateTime(iso: string): string {
+ const d = new Date(iso)
+ if (Number.isNaN(d.getTime())) return ''
+
+ 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 mapBrowserForDevice(
+ browser: string | null,
+ device: string | null,
+): string | null {
+ if (!browser) return null
+
+ const isMobile = device === 'mobile' || device === 'tablet'
+ if (isMobile && MOBILE_BROWSER_VARIANTS[browser]) {
+ return MOBILE_BROWSER_VARIANTS[browser]
+ }
+
+ return browser
+}
+
+function filterSelfReferrer(
+ referrer: string | null,
+ hostname: string | null,
+): string | null {
+ if (!referrer) return null
+
+ try {
+ const url = new URL(referrer)
+ if (hostname) {
+ const cleanRef = url.hostname.replace(/^www\./, '')
+ const cleanHost = hostname.replace(/^www\./, '')
+ if (cleanRef === cleanHost) return null
+ }
+ return referrer
+ } catch {
+ return referrer
+ }
+}
+
+function buildLocale(
+ lang: string | null,
+ region: string | null,
+): string | null {
+ if (!lang) return null
+ if (region) return `${lang}-${region.toUpperCase()}`
+ return lang
+}
+
+export class SimpleAnalyticsMapper implements ImportMapper {
+ readonly provider = 'simple-analytics'
+ readonly expectedFileExtension = '.csv'
+
+ async *createRowStream(
+ filePath: string,
+ pid: string,
+ importID: number,
+ ): AsyncIterable<AnalyticsImportRow> {
+ const parser = fs.createReadStream(filePath).pipe(
+ parse({
+ columns: true,
+ skip_empty_lines: true,
+ trim: true,
+ relax_quotes: true,
+ relax_column_count: true,
+ }),
+ )
+
+ let headerChecked = false
+
+ for await (const row of parser) {
+ if (!headerChecked) {
+ headerChecked = true
+
+ if (!('added_iso' in row) || !('datapoint' in row)) {
+ throw new ImportError(
+ 'CSV does not appear to be a Simple Analytics export. Expected columns like "added_iso" and "datapoint".',
+ )
+ }
+ }
+
+ if (row.is_robot === 'true') continue
+
+ const addedIso = normalizeNull(row.added_iso)
+ if (!addedIso || !ISO_DATE_REGEX.test(addedIso)) continue
+
+ const created = isoToClickHouseDateTime(addedIso)
+ if (!created) continue
+
+ const sessionId = normalizeNull(row.session_id)
+ if (!sessionId) continue
+
+ const psid = sessionIdToPsid(sessionId)
+ const device = normalizeNull(row.device_type) || 'desktop'
+ const hostname = truncate(normalizeNull(row.hostname), 253)
+ const browser = mapBrowserForDevice(
+ normalizeNull(row.browser_name),
+ device,
+ )
+ const ref = filterSelfReferrer(
+ normalizeNull(row.document_referrer),
+ hostname,
+ )
+
+ const cc = normalizeNull(row.country_code)
+ const validCC = cc && /^[A-Z]{2}$/.test(cc) ? cc : null
+
+ const locale = buildLocale(
+ normalizeNull(row.lang_language),
+ normalizeNull(row.lang_region),
+ )
+
+ const baseData: Record<string, unknown> = {
+ psid,
+ profileId: null,
+ pid,
+ host: hostname,
+ pg: truncate(normalizeNull(row.path), 2048),
+ dv: device,
+ br: truncate(browser, 30),
+ brv: truncate(normalizeNull(row.browser_version), 20),
+ os: truncate(normalizeNull(row.os_name), 25),
+ osv: truncate(normalizeNull(row.os_version), 20),
+ lc: truncate(locale, 35),
+ ref: truncate(ref, 2048),
+ so: truncate(normalizeNull(row.utm_source), 256),
+ me: truncate(normalizeNull(row.utm_medium), 256),
+ ca: truncate(normalizeNull(row.utm_campaign), 256),
+ te: truncate(normalizeNull(row.utm_term), 256),
+ co: truncate(normalizeNull(row.utm_content), 256),
+ cc: validCC,
+ rg: null,
+ rgc: null,
+ ct: null,
+ 'meta.key': [],
+ 'meta.value': [],
+ importID,
+ created,
+ }
+
+ const datapoint = normalizeNull(row.datapoint)
+
+ if (!datapoint || datapoint === 'pageview') {
+ yield { table: 'analytics', data: baseData }
+ } else {
+ yield {
+ table: 'customEV',
+ data: { ...baseData, ev: truncate(datapoint, 256) || '' },
+ }
+ }
+ }
+ }
+}
diff --git a/backend/apps/cloud/src/data-import/mappers/umami.mapper.ts b/backend/apps/cloud/src/data-import/mappers/umami.mapper.ts
index 038ce257f..192a9638b 100644
--- a/backend/apps/cloud/src/data-import/mappers/umami.mapper.ts
+++ b/backend/apps/cloud/src/data-import/mappers/umami.mapper.ts
@@ -1,7 +1,6 @@
import * as fs from 'fs'
import * as path from 'path'
import * as os from 'os'
-import * as crypto from 'crypto'
import { Unzip, UnzipInflate } from 'fflate'
import { parse } from 'csv-parse'
@@ -10,6 +9,12 @@ import {
ImportError,
AnalyticsImportRow,
} from './mapper.interface'
+import {
+ normalizeNull,
+ truncate,
+ sessionIdToPsid,
+ MOBILE_BROWSER_VARIANTS,
+} from './mapper.utils'
const WEBSITE_EVENT_CSV = 'website_event.csv'
const MAX_UMAMI_CSV_BYTES = 512 * 1024 * 1024
@@ -32,12 +37,6 @@ const BROWSER_MAP: Record<string, string> = {
edge: 'Edge',
}
-const MOBILE_BROWSER_VARIANTS: Record<string, string> = {
- Chrome: 'Mobile Chrome',
- Firefox: 'Mobile Firefox',
- Safari: 'Mobile Safari',
-}
-
const OS_MAP: Record<string, string> = {
'mac os': 'macOS',
'windows 10': 'Windows',
@@ -59,16 +58,6 @@ const DEVICE_MAP: Record<string, string> = {
tablet: 'tablet',
}
-function normalizeNull(value: string | undefined): string | null {
- if (!value || value === '' || value === '\\N') return null
- return value
-}
-
-function truncate(value: string | null, maxLen: number): string | null {
- if (!value) return null
- return value.length > maxLen ? value.slice(0, maxLen) : value
-}
-
function mapBrowser(raw: string | null, device: string | null): string | null {
if (!raw) return null
@@ -127,15 +116,6 @@ function isValidTimestamp(ts: string): boolean {
return DATE_REGEX.test(ts)
}
-function sessionIdToPsid(sessionId: string): string {
- return crypto
- .createHash('sha256')
- .update(sessionId)
- .digest()
- .readBigUInt64BE(0)
- .toString()
-}
-
export class UmamiMapper implements ImportMapper {
readonly provider = 'umami'
readonly expectedFileExtension = '.zip'
diff --git a/backend/apps/community/src/data-import/mappers/index.ts b/backend/apps/community/src/data-import/mappers/index.ts
index 5302f3e7c..5bece673a 100644
--- a/backend/apps/community/src/data-import/mappers/index.ts
+++ b/backend/apps/community/src/data-import/mappers/index.ts
@@ -1,10 +1,12 @@
import { ImportMapper } from './mapper.interface'
import { UmamiMapper } from './umami.mapper'
+import { SimpleAnalyticsMapper } from './simple-analytics.mapper'
-export const SUPPORTED_PROVIDERS = ['umami'] as const
+export const SUPPORTED_PROVIDERS = ['umami', 'simple-analytics'] as const
const mappers: Record<string, ImportMapper> = {
umami: new UmamiMapper(),
+ 'simple-analytics': new SimpleAnalyticsMapper(),
}
export function getMapper(provider: string): ImportMapper | undefined {
diff --git a/backend/apps/community/src/data-import/mappers/mapper.utils.ts b/backend/apps/community/src/data-import/mappers/mapper.utils.ts
new file mode 100644
index 000000000..f615dc1d0
--- /dev/null
+++ b/backend/apps/community/src/data-import/mappers/mapper.utils.ts
@@ -0,0 +1,26 @@
+import * as crypto from 'crypto'
+
+export const MOBILE_BROWSER_VARIANTS: Record<string, string> = {
+ Chrome: 'Mobile Chrome',
+ Firefox: 'Mobile Firefox',
+ Safari: 'Mobile Safari',
+}
+
+export function normalizeNull(value: string | undefined): string | null {
+ if (!value || value === '' || value === '\\N') return null
+ return value
+}
+
+export function truncate(value: string | null, maxLen: number): string | null {
+ if (!value) return null
+ return value.length > maxLen ? value.slice(0, maxLen) : value
+}
+
+export function sessionIdToPsid(sessionId: string): string {
+ return crypto
+ .createHash('sha256')
+ .update(sessionId)
+ .digest()
+ .readBigUInt64BE(0)
+ .toString()
+}
diff --git a/backend/apps/community/src/data-import/mappers/simple-analytics.mapper.ts b/backend/apps/community/src/data-import/mappers/simple-analytics.mapper.ts
new file mode 100644
index 000000000..d177221c3
--- /dev/null
+++ b/backend/apps/community/src/data-import/mappers/simple-analytics.mapper.ts
@@ -0,0 +1,174 @@
+import * as fs from 'fs'
+import { parse } from 'csv-parse'
+
+import { ImportMapper, AnalyticsImportRow } from './mapper.interface'
+import {
+ normalizeNull,
+ truncate,
+ sessionIdToPsid,
+ MOBILE_BROWSER_VARIANTS,
+} from './mapper.utils'
+
+const ISO_DATE_REGEX =
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})$/
+
+function isoToClickHouseDateTime(iso: string): string {
+ const d = new Date(iso)
+ if (Number.isNaN(d.getTime())) return ''
+
+ 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 mapBrowserForDevice(
+ browser: string | null,
+ device: string | null,
+): string | null {
+ if (!browser) return null
+
+ const isMobile = device === 'mobile' || device === 'tablet'
+ if (isMobile && MOBILE_BROWSER_VARIANTS[browser]) {
+ return MOBILE_BROWSER_VARIANTS[browser]
+ }
+
+ return browser
+}
+
+function filterSelfReferrer(
+ referrer: string | null,
+ hostname: string | null,
+): string | null {
+ if (!referrer) return null
+
+ try {
+ const url = new URL(referrer)
+ if (hostname) {
+ const cleanRef = url.hostname.replace(/^www\./, '')
+ const cleanHost = hostname.replace(/^www\./, '')
+ if (cleanRef === cleanHost) return null
+ }
+ return referrer
+ } catch {
+ return referrer
+ }
+}
+
+function buildLocale(
+ lang: string | null,
+ region: string | null,
+): string | null {
+ if (!lang) return null
+ if (region) return `${lang}-${region.toUpperCase()}`
+ return lang
+}
+
+export class SimpleAnalyticsMapper implements ImportMapper {
+ readonly provider = 'simple-analytics'
+ readonly expectedFileExtension = '.csv'
+
+ async *createRowStream(
+ filePath: string,
+ pid: string,
+ importID: number,
+ ): AsyncIterable<AnalyticsImportRow> {
+ const parser = fs.createReadStream(filePath).pipe(
+ parse({
+ columns: true,
+ skip_empty_lines: true,
+ trim: true,
+ relax_quotes: true,
+ relax_column_count: true,
+ }),
+ )
+
+ let headerChecked = false
+
+ for await (const row of parser) {
+ if (!headerChecked) {
+ headerChecked = true
+
+ if (!('added_iso' in row) || !('datapoint' in row)) {
+ throw new Error(
+ 'CSV does not appear to be a Simple Analytics export. Expected columns like "added_iso" and "datapoint".',
+ )
+ }
+ }
+
+ if (row.is_robot === 'true') continue
+
+ const addedIso = normalizeNull(row.added_iso)
+ if (!addedIso || !ISO_DATE_REGEX.test(addedIso)) continue
+
+ const created = isoToClickHouseDateTime(addedIso)
+ if (!created) continue
+
+ const sessionId = normalizeNull(row.session_id)
+ if (!sessionId) continue
+
+ const psid = sessionIdToPsid(sessionId)
+ const device = normalizeNull(row.device_type) || 'desktop'
+ const hostname = truncate(normalizeNull(row.hostname), 253)
+ const browser = mapBrowserForDevice(
+ normalizeNull(row.browser_name),
+ device,
+ )
+ const ref = filterSelfReferrer(
+ normalizeNull(row.document_referrer),
+ hostname,
+ )
+
+ const cc = normalizeNull(row.country_code)
+ const validCC = cc && /^[A-Z]{2}$/.test(cc) ? cc : null
+
+ const locale = buildLocale(
+ normalizeNull(row.lang_language),
+ normalizeNull(row.lang_region),
+ )
+
+ const baseData: Record<string, unknown> = {
+ psid,
+ profileId: null,
+ pid,
+ host: hostname,
+ pg: truncate(normalizeNull(row.path), 2048),
+ dv: device,
+ br: truncate(browser, 30),
+ brv: truncate(normalizeNull(row.browser_version), 20),
+ os: truncate(normalizeNull(row.os_name), 25),
+ osv: truncate(normalizeNull(row.os_version), 20),
+ lc: truncate(locale, 35),
+ ref: truncate(ref, 2048),
+ so: truncate(normalizeNull(row.utm_source), 256),
+ me: truncate(normalizeNull(row.utm_medium), 256),
+ ca: truncate(normalizeNull(row.utm_campaign), 256),
+ te: truncate(normalizeNull(row.utm_term), 256),
+ co: truncate(normalizeNull(row.utm_content), 256),
+ cc: validCC,
+ rg: null,
+ rgc: null,
+ ct: null,
+ 'meta.key': [],
+ 'meta.value': [],
+ importID,
+ created,
+ }
+
+ const datapoint = normalizeNull(row.datapoint)
+
+ if (!datapoint || datapoint === 'pageview') {
+ yield { table: 'analytics', data: baseData }
+ } else {
+ yield {
+ table: 'customEV',
+ data: { ...baseData, ev: truncate(datapoint, 256) || '' },
+ }
+ }
+ }
+ }
+}
diff --git a/backend/apps/community/src/data-import/mappers/umami.mapper.ts b/backend/apps/community/src/data-import/mappers/umami.mapper.ts
index aa152e8aa..a1514ae46 100644
--- a/backend/apps/community/src/data-import/mappers/umami.mapper.ts
+++ b/backend/apps/community/src/data-import/mappers/umami.mapper.ts
@@ -1,11 +1,16 @@
import * as fs from 'fs'
import * as path from 'path'
import * as os from 'os'
-import * as crypto from 'crypto'
import { Unzip, UnzipInflate } from 'fflate'
import { parse } from 'csv-parse'
import { ImportMapper, AnalyticsImportRow } from './mapper.interface'
+import {
+ normalizeNull,
+ truncate,
+ sessionIdToPsid,
+ MOBILE_BROWSER_VARIANTS,
+} from './mapper.utils'
const WEBSITE_EVENT_CSV = 'website_event.csv'
const MAX_UMAMI_CSV_BYTES = 512 * 1024 * 1024
@@ -28,12 +33,6 @@ const BROWSER_MAP: Record<string, string> = {
edge: 'Edge',
}
-const MOBILE_BROWSER_VARIANTS: Record<string, string> = {
- Chrome: 'Mobile Chrome',
- Firefox: 'Mobile Firefox',
- Safari: 'Mobile Safari',
-}
-
const OS_MAP: Record<string, string> = {
'mac os': 'macOS',
'windows 10': 'Windows',
@@ -55,16 +54,6 @@ const DEVICE_MAP: Record<string, string> = {
tablet: 'tablet',
}
-function normalizeNull(value: string | undefined): string | null {
- if (!value || value === '' || value === '\\N') return null
- return value
-}
-
-function truncate(value: string | null, maxLen: number): string | null {
- if (!value) return null
- return value.length > maxLen ? value.slice(0, maxLen) : value
-}
-
function mapBrowser(raw: string | null, device: string | null): string | null {
if (!raw) return null
@@ -123,15 +112,6 @@ function isValidTimestamp(ts: string): boolean {
return DATE_REGEX.test(ts)
}
-function sessionIdToPsid(sessionId: string): string {
- return crypto
- .createHash('sha256')
- .update(sessionId)
- .digest()
- .readBigUInt64BE(0)
- .toString()
-}
-
export class UmamiMapper implements ImportMapper {
readonly provider = 'umami'
readonly expectedFileExtension = '.zip'
diff --git a/docs/content/docs/data-import.mdx b/docs/content/docs/data-import.mdx
index cce446950..7bdd4d1d1 100644
--- a/docs/content/docs/data-import.mdx
+++ b/docs/content/docs/data-import.mdx
@@ -10,6 +10,7 @@ Swetrix allows you to import historical analytics data from other platforms so y
## Supported Providers
- Umami
+- Simple Analytics
## Importing from Umami
@@ -65,6 +66,61 @@ The page auto-refreshes while an import is processing. You can navigate away and
</Step>
</Steps>
+## Importing from Simple Analytics
+
+<Steps>
+<Step>
+### Export Your Data from Simple Analytics
+
+1. Log in to your Simple Analytics dashboard and go to their [Export data](https://dashboard.simpleanalytics.com/select-website/export) page
+2. Under the **Select the raw data you want to download** section, select **All** option to include both pageviews and events and the export time period. For type, choose **CSV**.
+3. Under the **Select fields** section, choose the **select all** option to include all fields.
+4. Click the **Export** button to download a `.csv` file
+
+<img
+ alt="Simple Analytics export data page"
+ src="/docs/img/sitesettings/data-import/simple-analytics-export-data.png"
+/>
+
+You can learn more on how to export your data from Simple Analytics on their [export documentation](https://docs.simpleanalytics.com/export-data).
+
+</Step>
+<Step>
+### Import into Swetrix
+
+1. Go to your project's **Settings** page in Swetrix
+2. Click the **Import data** tab
+
+<img
+ alt="Swetrix import data tab"
+ src="/docs/img/sitesettings/data-import/swetrix-import-data-tab.png"
+/>
+
+3. Click the **Simple Analytics** provider card
+
+<img
+ alt="Swetrix import data tab with provider cards"
+ src="/docs/img/sitesettings/data-import/swetrix-simple-analytics-upload-modal.png"
+/>
+
+4. In the upload modal, either drag and drop the `.csv` file or click to browse
+5. Wait for the upload and processing to complete
+
+</Step>
+<Step>
+### Monitor Progress
+
+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 analytics events were imported
+
+The page auto-refreshes while an import is processing. You can navigate away and come back later.
+
+</Step>
+</Steps>
+
## Viewing Imported Data
Once an import completes, the data is immediately available in your analytics dashboard. When you select a date range that includes imported data, a small **"Imported"** badge appears near the period selector to let you know.
@@ -103,7 +159,7 @@ Only one import can run at a time per project. Wait for the current import to co
### Invalid file type error
-Make sure you're uploading the correct file format for your provider. For Umami, upload the `.zip` file from the export directly - do not extract it first.
+Make sure you're uploading the correct file format for your provider. For Umami, upload the `.zip` file directly - do not extract it first. For Simple Analytics, upload the `.csv` export file.
### Data not appearing in charts
diff --git a/docs/public/img/sitesettings/data-import/simple-analytics-export-data.png b/docs/public/img/sitesettings/data-import/simple-analytics-export-data.png
new file mode 100644
index 000000000..ed9def485
Binary files /dev/null and b/docs/public/img/sitesettings/data-import/simple-analytics-export-data.png differ
diff --git a/docs/public/img/sitesettings/data-import/swetrix-import-data-tab.png b/docs/public/img/sitesettings/data-import/swetrix-import-data-tab.png
index a90fbcc5a..fb693876c 100644
Binary files a/docs/public/img/sitesettings/data-import/swetrix-import-data-tab.png and b/docs/public/img/sitesettings/data-import/swetrix-import-data-tab.png differ
diff --git a/docs/public/img/sitesettings/data-import/swetrix-simple-analytics-upload-modal.png b/docs/public/img/sitesettings/data-import/swetrix-simple-analytics-upload-modal.png
new file mode 100644
index 000000000..b698af86e
Binary files /dev/null and b/docs/public/img/sitesettings/data-import/swetrix-simple-analytics-upload-modal.png differ
diff --git a/web/app/pages/Project/Settings/components/DataImportTab.tsx b/web/app/pages/Project/Settings/components/DataImportTab.tsx
index 8367ebb02..f849866df 100644
--- a/web/app/pages/Project/Settings/components/DataImportTab.tsx
+++ b/web/app/pages/Project/Settings/components/DataImportTab.tsx
@@ -21,8 +21,22 @@ import Loader from '~/ui/Loader'
import FileUpload from '~/ui/FileUpload'
import { Text } from '~/ui/Text'
import UmamiSVG from '~/ui/icons/Umami'
+import SimpleAnalyticsSVG from '~/ui/icons/SimpleAnalytics'
-const PROVIDERS = ['umami'] as const
+const PROVIDERS = ['umami', 'simple-analytics'] as const
+
+const PROVIDER_ICONS: Record<
+ string,
+ React.ComponentType<{ className?: string }>
+> = {
+ umami: UmamiSVG,
+ 'simple-analytics': SimpleAnalyticsSVG,
+}
+
+const PROVIDER_DISPLAY_NAMES: Record<string, string> = {
+ umami: 'Umami',
+ 'simple-analytics': 'Simple Analytics',
+}
const STATUS_ICONS = {
pending: ClockIcon,
@@ -225,12 +239,11 @@ export default function DataImportTab({ projectId }: DataImportTabProps) {
<div className='mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3'>
{PROVIDERS.map((providerId) => {
- const Icon = providerId === 'umami' ? UmamiSVG : FileTextIcon
+ const Icon = PROVIDER_ICONS[providerId] || FileTextIcon
const hasActive = imports.some(
(i) => i.status === 'pending' || i.status === 'processing',
)
- const name =
- providerId.charAt(0).toUpperCase() + providerId.slice(1)
+ const name = PROVIDER_DISPLAY_NAMES[providerId] || providerId
const fileType = t(
`project.settings.dataImport.${providerId}.fileType`,
)
@@ -346,7 +359,7 @@ export default function DataImportTab({ projectId }: DataImportTabProps) {
className='bg-white hover:bg-gray-50 dark:bg-slate-950 dark:hover:bg-slate-900/50'
>
<td className='px-4 py-3 text-sm font-medium whitespace-nowrap text-gray-900 capitalize dark:text-gray-100'>
- {imp.provider}
+ {PROVIDER_DISPLAY_NAMES[imp.provider] || imp.provider}
</td>
<td className='px-4 py-3'>
<StatusBadge
@@ -415,8 +428,7 @@ export default function DataImportTab({ projectId }: DataImportTabProps) {
}}
title={t('project.settings.dataImport.importFromProvider', {
provider: selectedProvider
- ? selectedProvider.charAt(0).toUpperCase() +
- selectedProvider.slice(1)
+ ? PROVIDER_DISPLAY_NAMES[selectedProvider] || selectedProvider
: '',
})}
size='medium'
diff --git a/web/app/ui/icons/SimpleAnalytics.tsx b/web/app/ui/icons/SimpleAnalytics.tsx
new file mode 100644
index 000000000..d24a33ea1
--- /dev/null
+++ b/web/app/ui/icons/SimpleAnalytics.tsx
@@ -0,0 +1,10 @@
+const SimpleAnalyticsSVG = ({ className }: { className?: string }) => (
+ <svg className={className} viewBox='0 0 400 400' fill='none'>
+ <rect width='400' height='400' rx='90' fill='#FF4F64' />
+ <path d='M132.414 201.448H100V298.69H132.414V201.448Z' fill='white' />
+ <path d='M210.206 143.103H177.793V298.69H210.206V143.103Z' fill='white' />
+ <path d='M288 88H255.586V298.69H288V88Z' fill='white' />
+ </svg>
+)
+
+export default SimpleAnalyticsSVG
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index af8e90e00..e20ff2d16 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -1768,6 +1768,10 @@
"umami": {
"description": "Import pageviews and custom events from Umami export",
"fileType": ".zip"
+ },
+ "simple-analytics": {
+ "description": "Import pageviews and events from Simple Analytics export",
+ "fileType": ".csv"
}
},
"captcha": {