rename mixan to OPENPANEL!

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-03-11 13:40:46 +01:00
parent 6d4f9010d4
commit e6c0bc2ec8
201 changed files with 1193 additions and 1047 deletions

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/common",
"name": "@openpanel/common",
"version": "0.0.1",
"main": "index.ts",
"scripts": {
@@ -12,9 +12,9 @@
"unique-names-generator": "^4.7.1"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"@types/node": "^18.16.0",
"@types/ramda": "^0.29.6",
"eslint": "^8.48.0",
@@ -25,8 +25,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/base.json",
"extends": "@openpanel/tsconfig/base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/constants",
"name": "@openpanel/constants",
"version": "0.0.1",
"main": "index.ts",
"scripts": {
@@ -8,9 +8,9 @@
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"date-fns": "^3.3.1",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
@@ -20,8 +20,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/base.json",
"extends": "@openpanel/tsconfig/base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/db",
"name": "@openpanel/db",
"version": "0.0.1",
"main": "index.ts",
"scripts": {
@@ -14,18 +14,18 @@
"dependencies": {
"@clerk/nextjs": "^4.29.7",
"@clickhouse/client": "^0.2.9",
"@mixan/common": "workspace:*",
"@mixan/constants": "workspace:*",
"@mixan/redis": "workspace:*",
"@mixan/validation": "workspace:*",
"@openpanel/common": "workspace:*",
"@openpanel/constants": "workspace:*",
"@openpanel/redis": "workspace:*",
"@openpanel/validation": "workspace:*",
"@prisma/client": "^5.1.1",
"ramda": "^0.29.1",
"uuid": "^9.0.1"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"@types/node": "^18.16.0",
"@types/ramda": "^0.29.6",
"@types/uuid": "^9.0.8",
@@ -37,8 +37,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -40,8 +40,8 @@ async function push(event: Event) {
'Content-Type': 'application/json',
'User-Agent': event.properties.ua,
'X-Forwarded-For': event.properties.ip,
'mixan-client-id': 'c8b4962e-bc3d-4b23-8ea4-505c8fbdf09e',
origin: 'https://mixan.kiddo.se',
'openpanel-client-id': 'c8b4962e-bc3d-4b23-8ea4-505c8fbdf09e',
origin: 'https://openpanel.kiddo.se',
},
}).catch(() => {});
}
@@ -93,7 +93,7 @@ async function main() {
const projectId = event.project_id;
const path = event.properties.path as string;
const ip = event.properties.ip as string;
const origin = 'https://mixan.kiddo.se';
const origin = 'https://openpanel.kiddo.se';
const ua = event.properties.ua as string;
const uaInfo = parseUserAgent(ua);
const salts = await getSalts();

View File

@@ -1,4 +1,4 @@
import type { IChartEventFilter, IGetChartDataInput } from '@mixan/validation';
import type { IChartEventFilter, IGetChartDataInput } from '@openpanel/validation';
import { formatClickhouseDate } from '../clickhouse-client';
import type { SqlBuilderObject } from '../sql-builder';

View File

@@ -1,22 +1,22 @@
import { omit, uniq } from 'ramda';
import { v4 as uuid } from 'uuid';
import { omit, uniq } from "ramda";
import { v4 as uuid } from "uuid";
import { randomSplitName, toDots } from '@mixan/common';
import { redis, redisPub } from '@mixan/redis';
import type { IChartEventFilter } from '@mixan/validation';
import { randomSplitName, toDots } from "@openpanel/common";
import { redis, redisPub } from "@openpanel/redis";
import type { IChartEventFilter } from "@openpanel/validation";
import {
ch,
chQuery,
convertClickhouseDateToJs,
formatClickhouseDate,
} from '../clickhouse-client';
import type { EventMeta, Prisma } from '../prisma-client';
import { db } from '../prisma-client';
import { createSqlBuilder } from '../sql-builder';
import { getEventFiltersWhereClause } from './chart.service';
import { getProfileById, getProfiles, upsertProfile } from './profile.service';
import type { IServiceProfile } from './profile.service';
} from "../clickhouse-client";
import type { EventMeta, Prisma } from "../prisma-client";
import { db } from "../prisma-client";
import { createSqlBuilder } from "../sql-builder";
import { getEventFiltersWhereClause } from "./chart.service";
import { getProfileById, getProfiles, upsertProfile } from "./profile.service";
import type { IServiceProfile } from "./profile.service";
export interface IClickhouseEvent {
id: string;
@@ -49,7 +49,7 @@ export interface IClickhouseEvent {
}
export function transformEvent(
event: IClickhouseEvent
event: IClickhouseEvent,
): IServiceCreateEventPayload {
return {
id: event.id,
@@ -124,7 +124,7 @@ export async function getLiveVisitors(projectId: string) {
export async function getEvents(
sql: string,
options: GetEventsOptions = {}
options: GetEventsOptions = {},
): Promise<IServiceCreateEventPayload[]> {
const events = await chQuery<IClickhouseEvent>(sql);
if (options.profile) {
@@ -155,17 +155,17 @@ export async function getEvents(
}
export async function createEvent(
payload: Omit<IServiceCreateEventPayload, 'id'>
payload: Omit<IServiceCreateEventPayload, "id">,
) {
if (!payload.profileId) {
payload.profileId = payload.deviceId;
}
console.log(
`create event ${payload.name} for deviceId: ${payload.deviceId} profileId ${payload.profileId}`
`create event ${payload.name} for deviceId: ${payload.deviceId} profileId ${payload.profileId}`,
);
const exists = await getProfileById(payload.profileId);
if (!exists && payload.profileId !== '') {
if (!exists && payload.profileId !== "") {
const { firstName, lastName } = randomSplitName();
await upsertProfile({
id: payload.profileId,
@@ -198,40 +198,40 @@ export async function createEvent(
profile_id: payload.profileId,
project_id: payload.projectId,
session_id: payload.sessionId,
properties: toDots(omit(['_path'], payload.properties)),
path: payload.path ?? '',
properties: toDots(omit(["_path"], payload.properties)),
path: payload.path ?? "",
created_at: formatClickhouseDate(payload.createdAt),
country: payload.country ?? '',
city: payload.city ?? '',
region: payload.region ?? '',
os: payload.os ?? '',
os_version: payload.osVersion ?? '',
browser: payload.browser ?? '',
browser_version: payload.browserVersion ?? '',
device: payload.device ?? '',
brand: payload.brand ?? '',
model: payload.model ?? '',
country: payload.country ?? "",
city: payload.city ?? "",
region: payload.region ?? "",
os: payload.os ?? "",
os_version: payload.osVersion ?? "",
browser: payload.browser ?? "",
browser_version: payload.browserVersion ?? "",
device: payload.device ?? "",
brand: payload.brand ?? "",
model: payload.model ?? "",
duration: payload.duration,
referrer: payload.referrer ?? '',
referrer_name: payload.referrerName ?? '',
referrer_type: payload.referrerType ?? '',
referrer: payload.referrer ?? "",
referrer_name: payload.referrerName ?? "",
referrer_type: payload.referrerType ?? "",
};
const res = await ch.insert({
table: 'events',
table: "events",
values: [event],
format: 'JSONEachRow',
format: "JSONEachRow",
clickhouse_settings: {
date_time_input_format: 'best_effort',
date_time_input_format: "best_effort",
},
});
redisPub.publish('event', JSON.stringify(transformEvent(event)));
redisPub.publish("event", JSON.stringify(transformEvent(event)));
redis.set(
`live:event:${event.project_id}:${event.profile_id}`,
'',
'EX',
60 * 5
"",
"EX",
60 * 5,
);
return {
@@ -270,7 +270,7 @@ export async function getEventList({
if (events && events.length > 0) {
sb.where.events = `name IN (${join(
events.map((n) => `'${n}'`),
','
",",
)})`;
}
@@ -285,7 +285,7 @@ export async function getEventList({
// sb.where.cursor = `created_at <= '${formatClickhouseDate(cursor)}'`;
// }
sb.orderBy.created_at = 'created_at DESC';
sb.orderBy.created_at = "created_at DESC";
return getEvents(getSql(), { profile: true, meta: true });
}
@@ -295,7 +295,7 @@ export async function getEventsCount({
profileId,
events,
filters,
}: Omit<GetEventListOptions, 'cursor' | 'take'>) {
}: Omit<GetEventListOptions, "cursor" | "take">) {
const { sb, getSql, join } = createSqlBuilder();
sb.where.projectId = `project_id = '${projectId}'`;
if (profileId) {
@@ -305,7 +305,7 @@ export async function getEventsCount({
if (events && events.length > 0) {
sb.where.events = `name IN (${join(
events.map((n) => `'${n}'`),
','
",",
)})`;
}
@@ -317,7 +317,7 @@ export async function getEventsCount({
}
const res = await chQuery<{ count: number }>(
getSql().replace('*', 'count(*) as count')
getSql().replace("*", "count(*) as count"),
);
return res[0]?.count ?? 0;
@@ -339,8 +339,8 @@ export function createBotEvent({
path,
}: CreateBotEventPayload) {
return ch.insert({
table: 'events_bots',
format: 'JSONEachRow',
table: "events_bots",
format: "JSONEachRow",
values: [
{
name,

View File

@@ -1,17 +1,17 @@
import { toDots, toObject } from '@mixan/common';
import type { IChartEventFilter } from '@mixan/validation';
import { toDots, toObject } from "@openpanel/common";
import type { IChartEventFilter } from "@openpanel/validation";
import { ch, chQuery } from '../clickhouse-client';
import { createSqlBuilder } from '../sql-builder';
import { getEventFiltersWhereClause } from './chart.service';
import { ch, chQuery } from "../clickhouse-client";
import { createSqlBuilder } from "../sql-builder";
import { getEventFiltersWhereClause } from "./chart.service";
export async function getProfileById(id: string) {
if (id === '') {
if (id === "") {
return null;
}
const [profile] = await chQuery<IClickhouseProfile>(
`SELECT * FROM profiles WHERE id = '${id}' ORDER BY created_at DESC LIMIT 1`
`SELECT * FROM profiles WHERE id = '${id}' ORDER BY created_at DESC LIMIT 1`,
);
if (!profile) {
@@ -30,15 +30,15 @@ interface GetProfileListOptions {
function getProfileSelectFields() {
return [
'id',
'argMax(first_name, created_at) as first_name',
'argMax(last_name, created_at) as last_name',
'argMax(email, created_at) as email',
'argMax(avatar, created_at) as avatar',
'argMax(properties, created_at) as properties',
'argMax(project_id, created_at) as project_id',
'max(created_at) as max_created_at',
].join(', ');
"id",
"argMax(first_name, created_at) as first_name",
"argMax(last_name, created_at) as last_name",
"argMax(email, created_at) as email",
"argMax(avatar, created_at) as avatar",
"argMax(properties, created_at) as properties",
"argMax(project_id, created_at) as project_id",
"max(created_at) as max_created_at",
].join(", ");
}
interface GetProfilesOptions {
@@ -53,9 +53,9 @@ export async function getProfiles({ ids }: GetProfilesOptions) {
`SELECT
${getProfileSelectFields()}
FROM profiles
WHERE id IN (${ids.map((id) => `'${id}'`).join(',')})
WHERE id IN (${ids.map((id) => `'${id}'`).join(",")})
GROUP BY id
`
`,
);
return data.map(transformProfile);
@@ -85,7 +85,7 @@ export async function getProfileList({
}
sb.limit = take;
sb.offset = (cursor ?? 0) * take;
sb.orderBy.created_at = 'max_created_at DESC';
sb.orderBy.created_at = "max_created_at DESC";
const data = await chQuery<IClickhouseProfile>(getSql());
return data.map(transformProfile);
}
@@ -93,9 +93,9 @@ export async function getProfileList({
export async function getProfileListCount({
projectId,
filters,
}: Omit<GetProfileListOptions, 'cursor' | 'take'>) {
}: Omit<GetProfileListOptions, "cursor" | "take">) {
const { sb, getSql } = createSqlBuilder();
sb.select.count = 'count(id) as count';
sb.select.count = "count(id) as count";
sb.from = getProfileInnerSelect(projectId);
if (filters) {
sb.where = {
@@ -109,7 +109,7 @@ export async function getProfileListCount({
export async function getProfilesByExternalId(
externalId: string | null,
projectId: string
projectId: string,
) {
if (externalId === null) {
return [];
@@ -121,7 +121,7 @@ export async function getProfilesByExternalId(
FROM profiles
GROUP BY id
HAVING project_id = '${projectId}' AND external_id = '${externalId}'
`
`,
);
return data.map(transformProfile);
@@ -129,7 +129,7 @@ export async function getProfilesByExternalId(
export type IServiceProfile = Omit<
IClickhouseProfile,
'max_created_at' | 'properties'
"max_created_at" | "properties"
> & {
createdAt: Date;
properties: Record<string, unknown>;
@@ -177,27 +177,27 @@ export async function upsertProfile({
projectId,
}: IServiceUpsertProfile) {
const [profile] = await chQuery<IClickhouseProfile>(
`SELECT * FROM profiles WHERE id = '${id}' AND project_id = '${projectId}' ORDER BY created_at DESC LIMIT 1`
`SELECT * FROM profiles WHERE id = '${id}' AND project_id = '${projectId}' ORDER BY created_at DESC LIMIT 1`,
);
await ch.insert({
table: 'profiles',
format: 'JSONEachRow',
table: "profiles",
format: "JSONEachRow",
clickhouse_settings: {
date_time_input_format: 'best_effort',
date_time_input_format: "best_effort",
},
values: [
{
id,
first_name: firstName ?? profile?.first_name ?? '',
last_name: lastName ?? profile?.last_name ?? '',
email: email ?? profile?.email ?? '',
avatar: avatar ?? profile?.avatar ?? '',
first_name: firstName ?? profile?.first_name ?? "",
last_name: lastName ?? profile?.last_name ?? "",
email: email ?? profile?.email ?? "",
avatar: avatar ?? profile?.avatar ?? "",
properties: toDots({
...(profile?.properties ?? {}),
...(properties ?? {}),
}),
project_id: projectId ?? profile?.project_id ?? '',
project_id: projectId ?? profile?.project_id ?? "",
created_at: new Date(),
},
],

View File

@@ -1,4 +1,4 @@
import { alphabetIds, lineTypes, timeRanges } from '@mixan/constants';
import { alphabetIds, lineTypes, timeRanges } from "@openpanel/constants";
import type {
IChartBreakdown,
IChartEvent,
@@ -6,42 +6,42 @@ import type {
IChartInput,
IChartLineType,
IChartRange,
} from '@mixan/validation';
} from "@openpanel/validation";
import { db } from '../prisma-client';
import type { Report as DbReport } from '../prisma-client';
import { db } from "../prisma-client";
import type { Report as DbReport } from "../prisma-client";
export type IServiceReport = Awaited<ReturnType<typeof getReportById>>;
export function transformFilter(
filter: Partial<IChartEventFilter>,
index: number
index: number,
): IChartEventFilter {
return {
id: filter.id ?? alphabetIds[index] ?? 'A',
name: filter.name ?? 'Unknown Filter',
operator: filter.operator ?? 'is',
id: filter.id ?? alphabetIds[index] ?? "A",
name: filter.name ?? "Unknown Filter",
operator: filter.operator ?? "is",
value:
typeof filter.value === 'string' ? [filter.value] : filter.value ?? [],
typeof filter.value === "string" ? [filter.value] : filter.value ?? [],
};
}
export function transformReportEvent(
event: Partial<IChartEvent>,
index: number
index: number,
): IChartEvent {
return {
segment: event.segment ?? 'event',
segment: event.segment ?? "event",
filters: (event.filters ?? []).map(transformFilter),
id: event.id ?? alphabetIds[index]!,
name: event.name || 'unknown_event',
name: event.name || "unknown_event",
displayName: event.displayName,
property: event.property,
};
}
export function transformReport(
report: DbReport
report: DbReport,
): IChartInput & { id: string } {
return {
id: report.id,
@@ -51,11 +51,11 @@ export function transformReport(
chartType: report.chart_type,
lineType: (report.line_type as IChartLineType) ?? lineTypes.monotone,
interval: report.interval,
name: report.name || 'Untitled',
range: (report.range as IChartRange) ?? timeRanges['1m'],
name: report.name || "Untitled",
range: (report.range as IChartRange) ?? timeRanges["1m"],
previous: report.previous ?? false,
formula: report.formula ?? undefined,
metric: report.metric ?? 'sum',
metric: report.metric ?? "sum",
unit: report.unit ?? undefined,
};
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/base.json",
"extends": "@openpanel/tsconfig/base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/queue",
"name": "@openpanel/queue",
"version": "0.0.1",
"main": "index.ts",
"scripts": {
@@ -8,13 +8,13 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@mixan/db": "workspace:*",
"@openpanel/db": "workspace:*",
"bullmq": "^5.1.1"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"@types/node": "^18.16.0",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
@@ -23,8 +23,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -1,6 +1,6 @@
import { Queue } from 'bullmq';
import type { IServiceCreateEventPayload } from '@mixan/db';
import type { IServiceCreateEventPayload } from '@openpanel/db';
import { connection } from './connection';

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/base.json",
"extends": "@openpanel/tsconfig/base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/redis",
"name": "@openpanel/redis",
"version": "0.0.1",
"main": "index.ts",
"scripts": {
@@ -12,9 +12,9 @@
"ioredis": "^5.3.2"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"@types/node": "^18.16.0",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
@@ -24,8 +24,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/base.json",
"extends": "@openpanel/tsconfig/base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {

View File

@@ -1,11 +1,11 @@
import Script from 'next/script';
import type {
MixanEventOptions,
MixanWebOptions,
OpenpanelEventOptions,
OpenpanelWebOptions,
PostEventPayload,
UpdateProfilePayload,
} from '@mixan/web';
} from '@openpanel/web';
const CDN_URL = 'http://localhost:3002/op.js';
@@ -27,7 +27,7 @@ declare global {
}
}
type OpenpanelProviderProps = MixanWebOptions & {
type OpenpanelProviderProps = OpenpanelWebOptions & {
profileId?: string;
cdnUrl?: string;
};
@@ -98,7 +98,7 @@ export function setProfileId(profileId: string) {
export function increment(
property: string,
value: number,
options?: MixanEventOptions
options?: OpenpanelEventOptions
) {
window.op('increment', property, value, options);
}
@@ -106,7 +106,7 @@ export function increment(
export function decrement(
property: string,
value: number,
options?: MixanEventOptions
options?: OpenpanelEventOptions
) {
window.op('decrement', property, value, options);
}

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/nextjs",
"name": "@openpanel/nextjs",
"version": "0.0.1",
"module": "index.ts",
"scripts": {
@@ -10,16 +10,16 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@mixan/sdk": "workspace:*",
"@mixan/web": "workspace:*"
"@openpanel/sdk": "workspace:*",
"@openpanel/web": "workspace:*"
},
"peerDependencies": {
"next": "^13.0.0"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",
@@ -28,8 +28,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/base.json",
"extends": "@openpanel/tsconfig/base.json",
"compilerOptions": {
"outDir": "dist"
}

View File

@@ -1,6 +1,6 @@
import { defineConfig } from 'tsup';
import config from '@mixan/tsconfig/tsup.config.json' assert { type: 'json' };
import config from '@openpanel/tsconfig/tsup.config.json' assert { type: 'json' };
export default defineConfig({
...(config as any),

View File

@@ -2,13 +2,13 @@ import { AppState, Platform } from 'react-native';
import * as Application from 'expo-application';
import Constants from 'expo-constants';
import type { MixanOptions, PostEventPayload } from '@mixan/sdk';
import { Mixan } from '@mixan/sdk';
import type { OpenpanelOptions, PostEventPayload } from '@openpanel/sdk';
import { Openpanel } from '@openpanel/sdk';
type MixanNativeOptions = MixanOptions;
type OpenpanelNativeOptions = OpenpanelOptions;
export class MixanNative extends Mixan<MixanNativeOptions> {
constructor(options: MixanNativeOptions) {
export class OpenpanelNative extends Openpanel<OpenpanelNativeOptions> {
constructor(options: OpenpanelNativeOptions) {
super(options);
this.api.headers['User-Agent'] = Constants.getWebViewUserAgentAsync();

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/react-native",
"name": "@openpanel/react-native",
"version": "0.0.1",
"module": "index.ts",
"scripts": {
@@ -9,12 +9,12 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@mixan/sdk": "workspace:*"
"@openpanel/sdk": "workspace:*"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",
@@ -28,8 +28,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/sdk.json",
"extends": "@openpanel/tsconfig/sdk.json",
"compilerOptions": {
"outDir": "dist"
}

View File

@@ -1,6 +1,6 @@
import { defineConfig } from 'tsup';
import config from '@mixan/tsconfig/tsup.config.json' assert { type: 'json' };
import config from '@openpanel/tsconfig/tsup.config.json' assert { type: 'json' };
export default defineConfig({
...(config as any),

View File

@@ -1,6 +1,6 @@
// NEW
export interface MixanEventOptions {
export interface OpenpanelEventOptions {
profileId?: string;
}
@@ -9,7 +9,7 @@ export interface PostEventPayload {
timestamp: string;
deviceId?: string;
profileId?: string;
properties?: Record<string, unknown> & MixanEventOptions;
properties?: Record<string, unknown> & OpenpanelEventOptions;
}
export interface UpdateProfilePayload {
@@ -33,7 +33,7 @@ export interface DecrementProfilePayload {
value: number;
}
export interface MixanOptions {
export interface OpenpanelOptions {
url: string;
clientId: string;
clientSecret?: string;
@@ -43,7 +43,7 @@ export interface MixanOptions {
removeDeviceId?: () => void;
}
export interface MixanState {
export interface OpenpanelState {
deviceId?: string;
profileId?: string;
properties: Record<string, unknown>;
@@ -127,19 +127,19 @@ function createApi(_url: string) {
};
}
export class Mixan<Options extends MixanOptions = MixanOptions> {
export class Openpanel<Options extends OpenpanelOptions = OpenpanelOptions> {
public options: Options;
public api: ReturnType<typeof createApi>;
private state: MixanState = {
private state: OpenpanelState = {
properties: {},
};
constructor(options: Options) {
this.options = options;
this.api = createApi(options.url);
this.api.headers['mixan-client-id'] = options.clientId;
this.api.headers['openpanel-client-id'] = options.clientId;
if (this.options.clientSecret) {
this.api.headers['mixan-client-secret'] = this.options.clientSecret;
this.api.headers['openpanel-client-secret'] = this.options.clientSecret;
}
}
@@ -163,7 +163,7 @@ export class Mixan<Options extends MixanOptions = MixanOptions> {
public increment(
property: string,
value: number,
options?: MixanEventOptions
options?: OpenpanelEventOptions
) {
const profileId = options?.profileId ?? this.state.profileId;
if (!profileId) {
@@ -179,7 +179,7 @@ export class Mixan<Options extends MixanOptions = MixanOptions> {
public decrement(
property: string,
value: number,
options?: MixanEventOptions
options?: OpenpanelEventOptions
) {
const profileId = options?.profileId ?? this.state.profileId;
if (!profileId) {

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/sdk",
"name": "@openpanel/sdk",
"version": "0.0.1",
"module": "index.ts",
"scripts": {
@@ -10,9 +10,9 @@
},
"dependencies": {},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",
@@ -21,8 +21,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/sdk.json",
"extends": "@openpanel/tsconfig/sdk.json",
"compilerOptions": {
"outDir": "dist"
}

View File

@@ -1,6 +1,6 @@
import { defineConfig } from 'tsup';
import config from '@mixan/tsconfig/tsup.config.json' assert {
import config from '@openpanel/tsconfig/tsup.config.json' assert {
type: 'json'
}

View File

@@ -1,4 +1,4 @@
import { MixanWeb as Openpanel } from './index';
import { OpenpanelWeb as Openpanel } from './index';
declare global {
interface Window {

View File

@@ -1,9 +1,9 @@
import type { MixanOptions, PostEventPayload } from '@mixan/sdk';
import { Mixan } from '@mixan/sdk';
import type { OpenpanelOptions, PostEventPayload } from '@openpanel/sdk';
import { Openpanel } from '@openpanel/sdk';
export * from '@mixan/sdk';
export * from '@openpanel/sdk';
export type MixanWebOptions = MixanOptions & {
export type OpenpanelWebOptions = OpenpanelOptions & {
trackOutgoingLinks?: boolean;
trackScreenViews?: boolean;
trackAttributes?: boolean;
@@ -16,10 +16,10 @@ function toCamelCase(str: string) {
);
}
export class MixanWeb extends Mixan<MixanWebOptions> {
export class OpenpanelWeb extends Openpanel<OpenpanelWebOptions> {
private lastPath = '';
constructor(options: MixanWebOptions) {
constructor(options: OpenpanelWebOptions) {
super(options);
if (!this.isServer()) {

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/web",
"name": "@openpanel/web",
"version": "0.0.1",
"module": "index.ts",
"scripts": {
@@ -10,12 +10,12 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@mixan/sdk": "workspace:*"
"@openpanel/sdk": "workspace:*"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"tsup": "^7.2.0",
@@ -24,8 +24,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/sdk.json",
"extends": "@openpanel/tsconfig/sdk.json",
"compilerOptions": {
"outDir": "dist"
}

View File

@@ -1,6 +1,6 @@
import { defineConfig } from 'tsup';
import config from '@mixan/tsconfig/tsup.config.json' assert { type: 'json' };
import config from '@openpanel/tsconfig/tsup.config.json' assert { type: 'json' };
export default defineConfig({
...(config as any),

View File

@@ -1,5 +1,5 @@
{
"name": "@mixan/validation",
"name": "@openpanel/validation",
"version": "0.0.1",
"main": "index.ts",
"scripts": {
@@ -8,13 +8,13 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@mixan/constants": "workspace:*",
"@openpanel/constants": "workspace:*",
"zod": "^3.22.4"
},
"devDependencies": {
"@mixan/eslint-config": "workspace:*",
"@mixan/prettier-config": "workspace:*",
"@mixan/tsconfig": "workspace:*",
"@openpanel/eslint-config": "workspace:*",
"@openpanel/prettier-config": "workspace:*",
"@openpanel/tsconfig": "workspace:*",
"@types/node": "^18.16.0",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
@@ -24,8 +24,8 @@
"eslintConfig": {
"root": true,
"extends": [
"@mixan/eslint-config/base"
"@openpanel/eslint-config/base"
]
},
"prettier": "@mixan/prettier-config"
"prettier": "@openpanel/prettier-config"
}

View File

@@ -7,7 +7,7 @@ import {
metrics,
operators,
timeRanges,
} from '@mixan/constants';
} from '@openpanel/constants';
export function objectToZodEnums<K extends string>(
obj: Record<K, any>

View File

@@ -1,6 +1,6 @@
import type { z } from 'zod';
import type { timeRanges } from '@mixan/constants';
import type { timeRanges } from '@openpanel/constants';
import type {
zChartBreakdown,

View File

@@ -1,5 +1,5 @@
{
"extends": "@mixan/tsconfig/base.json",
"extends": "@openpanel/tsconfig/base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {