mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 15:05:22 +02:00
41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
import { computeDiD } from './services/experimentAnalysis';
|
|
import { CombinedKPIs, Experiment } from './types';
|
|
|
|
const salesData: CombinedKPIs[] = [
|
|
{
|
|
id: '1', marketplace: 'Amazon DE', customer: 'Amazon DE', month: 'Jan-24', week: 1, year: 2024,
|
|
asin: 'B0C123', title: 'Test', line: 'Test', sku: 'T-1',
|
|
salesTotal: 1000, unitsTotal: 100, salesAds: 500, unitsAds: 50, cost: 100,
|
|
clicks: 100, impressions: 1000, conversions: 5, salesOrganic: 500, unitsOrganic: 50,
|
|
paidSalesShare: 50, organicSalesShare: 50, acos: 20, tacos: 10, roas: 5, ctr: 10, cpc: 1, cvrUnits: 5, glanceViews: 1000
|
|
},
|
|
{
|
|
id: '2', marketplace: 'Amazon DE', customer: 'Amazon DE', month: 'Feb-24', week: 5, year: 2024,
|
|
asin: 'B0C123', title: 'Test', line: 'Test', sku: 'T-1',
|
|
salesTotal: 2000, unitsTotal: 200, salesAds: 2000, unitsAds: 200, cost: 200,
|
|
clicks: 200, impressions: 2000, conversions: 10, salesOrganic: 0, unitsOrganic: 0,
|
|
paidSalesShare: 100, organicSalesShare: 0, acos: 10, tacos: 10, roas: 10, ctr: 10, cpc: 1, cvrUnits: 5, glanceViews: 2000
|
|
}
|
|
];
|
|
|
|
const experiment: Experiment = {
|
|
id: 'exp1',
|
|
name: 'Test Exp',
|
|
type: 'advertising',
|
|
status: 'active',
|
|
asins: ['B0C123'],
|
|
control_asins: [],
|
|
marketplace: 'DE',
|
|
start_date: '2024-01-20',
|
|
end_date: '2024-02-28',
|
|
baseline_start_date: '2023-12-01',
|
|
baseline_end_date: '2024-01-19',
|
|
created_at: '',
|
|
updated_at: '',
|
|
primary_metric: 'acos',
|
|
changes: []
|
|
};
|
|
|
|
const result = computeDiD(experiment, salesData);
|
|
console.log(JSON.stringify(result.metrics, null, 2));
|