Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

add data migration to convert funnel and goals reports to new structure

Francis Cao964651bad349
diff --git a/prisma/migrations/14_add_link_and_pixel/migration.sql b/prisma/migrations/14_add_link_and_pixel/migration.sql
index 45320b036..4e51bdb14 100644
--- a/prisma/migrations/14_add_link_and_pixel/migration.sql
+++ b/prisma/migrations/14_add_link_and_pixel/migration.sql
@@ -71,3 +71,29 @@ CREATE INDEX "pixel_team_id_idx" ON "pixel"("team_id");
-- CreateIndex
CREATE INDEX "pixel_created_at_idx" ON "pixel"("created_at");
+
+-- DataMigration
+UPDATE "report"
+SET parameters = parameters - 'websiteId' - 'dateRange'
+WHERE type = 'funnel';
+
+INSERT INTO "report" (report_id, user_id, website_id, type, name, description, parameters, created_at, updated_at)
+SELECT gen_random_uuid(),
+ user_id,
+ website_id,
+ 'goal',
+ concat(name, ' - ', elem ->> 'value'),
+ description,
+ jsonb_build_object(
+ 'type', CASE WHEN elem ->> 'type' = 'url' THEN 'path'
+ ELSE elem ->> 'type' END,
+ 'value', elem ->> 'value'
+ ) AS parameters,
+ created_at,
+ updated_at
+FROM "report"
+CROSS JOIN LATERAL jsonb_array_elements(parameters -> 'goals') elem
+WHERE elem ->> 'type' IN ('event', 'url')
+ and type = 'goal';
+
+DELETE FROM "report" WHERE parameters ? 'goals' and type = 'goal';
\ No newline at end of file
diff --git a/src/components/icons.ts b/src/components/icons.ts
index c96a27b67..287dc650c 100644
--- a/src/components/icons.ts
+++ b/src/components/icons.ts
@@ -59,6 +59,7 @@ export {
Funnel,
Lightbulb,
Lightning,
+ Location,
Magnet,
Money,
Network,