|
@@ -1,5 +1,6 @@
|
|
|
-import type { MedusaRequest, MedusaResponse } from "@medusajs/medusa";
|
|
|
+import { AnalyticsConfigService, type MedusaRequest, type MedusaResponse } from "@medusajs/medusa";
|
|
|
import { EntityManager } from "typeorm";
|
|
|
+import { track } from "medusa-telemetry"
|
|
|
|
|
|
import OnboardingService from "../../../services/onboarding";
|
|
|
|
|
@@ -23,5 +24,19 @@ export async function POST(req: MedusaRequest, res: MedusaResponse) {
|
|
|
.update(req.body);
|
|
|
});
|
|
|
|
|
|
+ const analyticsConfigService = req.scope.resolve<
|
|
|
+ AnalyticsConfigService
|
|
|
+ >("analyticsConfigService")
|
|
|
+
|
|
|
+ const userAnalytics = await analyticsConfigService.retrieve(req.user?.userId)
|
|
|
+
|
|
|
+ if (!userAnalytics.opt_out) {
|
|
|
+ track("CMA_ONBOARDING", {
|
|
|
+ userId: req.user.userId,
|
|
|
+ status: status.current_step,
|
|
|
+ complete: status.is_complete
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
res.status(200).json({ status });
|
|
|
}
|