feat(medusa): add analytics config (#2442)
**What** - Adds new entity AnalyticsConfig - Adds new service AnalyticsConfigService - Adds new repository AnalyticsConfigRepository - Adds new endpoints to get, create, update, and delete analytics configs **Why** As we begin gathering usage insights to help us improve Medusa, we want to give each individual users the ability to control what data they share with us, or not share any data with us at all. The AnalyticsConfig holds information that is used to check if the user wishes for their data to be anonymized or if they have opted out of sharing usage data. The entire feature can be disabled on a store level by setting the feature flag `MEDUSA_FF_ANALYTICS=false` in their environment variables, the feature is enabled by default. **Testing** Adds integration test for each of the new endpoints Resolves CORE-656, CORE-655, CORE-654 Also resolves CORE-574
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||
import AnalyticsFeatureFlag from "../loaders/feature-flags/analytics"
|
||||
|
||||
export const featureFlag = AnalyticsFeatureFlag.key
|
||||
|
||||
export class addAnalyticsConfig1666173221888 implements MigrationInterface {
|
||||
name = "addAnalyticsConfig1666173221888"
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "analytics_config" ("id" character varying NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deleted_at" TIMESTAMP WITH TIME ZONE, "user_id" character varying NOT NULL, "opt_out" boolean NOT NULL DEFAULT false, "anonymize" boolean NOT NULL DEFAULT false, CONSTRAINT "PK_93505647c5d7cb479becb810b0f" PRIMARY KEY ("id"))`
|
||||
)
|
||||
await queryRunner.query(
|
||||
`CREATE UNIQUE INDEX "IDX_379ca70338ce9991f3affdeedf" ON "analytics_config" ("id", "user_id") WHERE deleted_at IS NULL`
|
||||
)
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`DROP INDEX "public"."IDX_379ca70338ce9991f3affdeedf"`
|
||||
)
|
||||
await queryRunner.query(`DROP TABLE "analytics_config"`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user