Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
wrongsahil committed May 16, 2024
2 parents 00e3504 + 2ee1203 commit 59e0e2e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@requestly/app",
"version": "24.5.14-18.18",
"version": "24.5.16-12.26",
"private": true,
"description": "Requestly - Lightweight Proxy to Intercept & Modify HTTP(s) requests",
"main": "index.js",
Expand Down
16 changes: 14 additions & 2 deletions app/src/modules/analytics/events/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ export const trackMv3MigrationStarted = (total_count: number) => {
trackEvent("mv3_migration_started", { total_count });
};

export const trackMv3MigrationRulesMigrated = (total_count: number, migrated_count: number) => {
trackEvent("mv3_migration_rules_migrated", { total_count, migrated_count });
export const trackMv3MigrationRulesMigrated = (
total_count: number,
migrated_count: number,
impacted_count: number,
path_impacted_count: number,
page_url_impacted_count: number
) => {
trackEvent("mv3_migration_rules_migrated", {
total_count,
migrated_count,
impacted_count,
path_impacted_count,
page_url_impacted_count,
});
};

export const trackMv3MigrationCompleted = (total_count: number, migrated_count: number) => {
Expand Down
36 changes: 33 additions & 3 deletions app/src/modules/extension/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,21 @@ export const migrateAllRulesToMV3 = (rules: Rule[], currentWorkspaceId: string):
const urlParams = new URLSearchParams(window.location.search);
const forceMigrate = urlParams.get("updatedToMv3") != null;

let pathImpactedRulesCount = 0;
let pageUrlImpactedRulesCount = 0;

const finalRules = rules.map((rule) => {
const { rule: migratedRule, ruleMigrationLogs, isMigrated } = migrateRuleToMV3(rule, forceMigrate);
const {
rule: migratedRule,
ruleMigrationLogs,
isMigrated,
isPathImpactedRule,
isPageUrlImpactedRule,
} = migrateRuleToMV3(rule, forceMigrate);
if (ruleMigrationLogs) {
rulesMigrationLogs[migratedRule.id] = ruleMigrationLogs;
pathImpactedRulesCount += isPathImpactedRule ? 1 : 0;
pageUrlImpactedRulesCount += isPageUrlImpactedRule ? 1 : 0;
}

if (isMigrated) {
Expand All @@ -63,7 +74,13 @@ export const migrateAllRulesToMV3 = (rules: Rule[], currentWorkspaceId: string):
},
});
Logger.log("[Debug][MV3.migrateAllRulesToMV3] Rules Migrated Successfully", { migratedRules });
trackMv3MigrationRulesMigrated(rules.length, migratedRules.length);
trackMv3MigrationRulesMigrated(
rules.length,
migratedRules.length,
rulesMigrationLogs ? Object.keys(rulesMigrationLogs).length : 0,
pathImpactedRulesCount,
pageUrlImpactedRulesCount
);
});
}

Expand All @@ -81,7 +98,13 @@ export const migrateAllRulesToMV3 = (rules: Rule[], currentWorkspaceId: string):
export const migrateRuleToMV3 = (
rule: Rule,
forceMigrate = false
): { isMigrated: boolean; rule: Rule; ruleMigrationLogs: any } => {
): {
isMigrated: boolean;
rule: Rule;
ruleMigrationLogs: any;
isPathImpactedRule?: boolean;
isPageUrlImpactedRule?: boolean;
} => {
if (rule?.schemaVersion === "3.0.0" && !forceMigrate) {
return {
isMigrated: false,
Expand All @@ -93,15 +116,20 @@ export const migrateRuleToMV3 = (
const ruleMigrationLogs: Record<string, any>[] = [];
Logger.log("[Debug][MV3.migrateRuleToMV3] Rule Migration Started", { rule, forceMigrate });

let isPathImpactedRule = false;
let isPageUrlImpactedRule = false;

rule.pairs.forEach((pair) => {
const pathMigrationStatus = migratePathOperator(pair.source);
if (pathMigrationStatus) {
ruleMigrationLogs.push(pathMigrationStatus);
isPathImpactedRule = true;
}

const pageUrlMigrationStatus = migratePageURLtoPageDomain(pair.source);
if (pageUrlMigrationStatus) {
ruleMigrationLogs.push(pageUrlMigrationStatus);
isPageUrlImpactedRule = true;
}
});

Expand All @@ -117,6 +145,8 @@ export const migrateRuleToMV3 = (
isMigrated: true,
rule: finalRule,
ruleMigrationLogs: ruleMigrationLogs.length ? ruleMigrationLogs : null,
isPathImpactedRule: isPathImpactedRule,
isPageUrlImpactedRule: isPageUrlImpactedRule,
};
};

Expand Down

0 comments on commit 59e0e2e

Please sign in to comment.