chore:little fixes and formating and linting and patches

This commit is contained in:
2026-03-31 15:50:54 +02:00
parent a1ce71ffb6
commit 9b197abcfa
815 changed files with 22960 additions and 8982 deletions

View File

@@ -12,7 +12,7 @@ export abstract class BaseImportProvider<
* This should be implemented as an async generator to handle large files efficiently
*/
abstract parseSource(
overrideFrom?: string,
overrideFrom?: string
): AsyncGenerator<TRawEvent, void, unknown>;
/**
@@ -80,7 +80,7 @@ export abstract class BaseImportProvider<
to: string,
options?: {
chunkSizeDays?: number;
},
}
): Array<[string, string]> {
const chunks: Array<[string, string]> = [];
@@ -113,7 +113,9 @@ export abstract class BaseImportProvider<
// Move cursor to the next chunk start (after the current chunk)
cursor.setDate(cursor.getDate() + chunkSizeDays);
if (cursor > endDate) break;
if (cursor > endDate) {
break;
}
}
return chunks;

View File

@@ -1,13 +1,13 @@
export { UmamiProvider } from './providers/umami';
export { MixpanelProvider } from './providers/mixpanel';
export { UmamiProvider } from './providers/umami';
export type {
ImportConfig,
ImportProgress,
ImportResult,
BatchResult,
BaseRawEvent,
BatchResult,
ErrorContext,
EventProperties,
ImportConfig,
ImportJobMetadata,
ImportProgress,
ImportResult,
ImportStageResult,
} from './types';

View File

@@ -6,8 +6,8 @@ import {
parseUserAgent,
type UserAgentInfo,
} from '@openpanel/common/server';
import { formatClickhouseDate, type IClickhouseEvent } from '@openpanel/db';
import type { IClickhouseProfile } from '@openpanel/db';
import { formatClickhouseDate, type IClickhouseEvent } from '@openpanel/db';
import type { ILogger } from '@openpanel/logger';
import type { IMixpanelImportConfig } from '@openpanel/validation';
import { z } from 'zod';
@@ -342,7 +342,10 @@ export class MixpanelProvider extends BaseImportProvider<MixpanelRawEvent> {
}
const data = (await response.json()) as {
results?: Array<{ $distinct_id: string | number; $properties?: Record<string, unknown> }>;
results?: Array<{
$distinct_id: string | number;
$properties?: Record<string, unknown>;
}>;
page?: number;
total?: number;
};
@@ -381,9 +384,14 @@ export class MixpanelProvider extends BaseImportProvider<MixpanelRawEvent> {
const properties: Record<string, string> = {};
const stripPrefix = /^\$/;
for (const [key, value] of Object.entries(props)) {
if (stripPrefix.test(key)) continue;
if (value == null) continue;
properties[key] = typeof value === 'object' ? JSON.stringify(value) : String(value);
if (stripPrefix.test(key)) {
continue;
}
if (value == null) {
continue;
}
properties[key] =
typeof value === 'object' ? JSON.stringify(value) : String(value);
}
return {
@@ -522,7 +530,8 @@ export class MixpanelProvider extends BaseImportProvider<MixpanelRawEvent> {
os: uaInfo.os || props.$os,
os_version: uaInfo.osVersion || props.$osVersion,
browser: uaInfo.browser || props.$browser,
browser_version: uaInfo.browserVersion || String(props.$browser_version ?? ''),
browser_version:
uaInfo.browserVersion || String(props.$browser_version ?? ''),
device: this.getDeviceType(props.mp_lib, uaInfo, props),
brand: uaInfo.brand || '',
model: uaInfo.model || '',

View File

@@ -114,7 +114,9 @@ export class UmamiProvider extends BaseImportProvider<UmamiRawEvent> {
contentType
)
) {
this.logger?.warn(`Warning: Content-Type is ${contentType}, expected CSV-ish`);
this.logger?.warn(
`Warning: Content-Type is ${contentType}, expected CSV-ish`
);
}
if (maxBytes && contentLen && contentLen > maxBytes) {

View File

@@ -1,8 +1,4 @@
import type {
IImportedEvent,
IServiceCreateEventPayload,
IServiceImportedEventPayload,
} from '@openpanel/db';
import type { IServiceImportedEventPayload } from '@openpanel/db';
export interface ImportConfig {
projectId: string;