Skip to content

Commit

Permalink
feat: ✨ Change Add Origin Enum for manifest origin
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobiClark committed Aug 17, 2023
1 parent 65d6817 commit 998f26e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
29 changes: 11 additions & 18 deletions scripts/metadata-files/manifest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { platform } = require("os");
const { copyFile, readdir } = require("fs").promises;
const { join } = require("path");
const { kombuchaEnums } = require("../others/analytics/analytics-enums");
let openedEdit = false;

// opendropdown event listeners
Expand Down Expand Up @@ -798,12 +799,16 @@ const convertJSONToXlsx = (jsondata, excelfile) => {
wb.write(excelfile);
};

const determineStandaloneManifestGeneratorOrigin = () => {
const selectedCardCreateManifest = $('input[name="generate-manifest-1"]:checked').prop("id");
return selectedCardCreateManifest === "generate-manifest-from-Penn" ? "bf" : "Local";
};

var localDatasetFolderPath = "";
var finalManifestGenerationPath = "";
let pennsievePreview = false;

const generateManifestPrecheck = async (manifestEditBoolean, ev) => {
let type = "local";
let continueProgressValidateDataset = true;
let titleTerm = "folder";
let localGenerationDifferentDestination = false;
Expand All @@ -815,10 +820,7 @@ const generateManifestPrecheck = async (manifestEditBoolean, ev) => {
pennsievePreview = false;

// check if manifest is being generated from Pennsieve
if (selectedCardCreateManifest === "generate-manifest-from-Penn") {
type = "bf";
}

const type = determineStandaloneManifestGeneratorOrigin();
exitCurate();
sodaJSONObj["starting-point"] = {};
sodaJSONObj["dataset-structure"] = {};
Expand Down Expand Up @@ -1334,19 +1336,10 @@ const initiate_generate_manifest_bf = async () => {
}

// Verify the origin of dataset for kombucha tracking
let origin = "";
if (document.getElementById("create_manifest-section").classList.contains("is-shown")) {
// If the standalone manifest generator tab is currently shown
origin = "standalone-manifest-generator";
} else if (sodaJSONObj?.["cuartion-mode"] === "guided") {
// If the special guided mode curation-mode key is found
origin = "guided-mode-manifest-generator";
} else {
// Otherwise the manifest files were generated in FFM
origin = "free-form-mode-manifest-gerator";
}

console.log("origin", origin);
const origin =
determineStandaloneManifestGeneratorOrigin() === "bf"
? kombuchaEnums.Origin.PENNSIEVE
: kombuchaEnums.Origin.LOCAL;

// log the manifest file creation to analytics
logMetadataForAnalytics(
Expand Down
6 changes: 6 additions & 0 deletions scripts/others/analytics/analytics-enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ const Status = {
FAIL: "fail",
};

const Origin = {
PENNSIEVE: "Pennsieve",
LOCAL: "Local",
};

const kombuchaEnums = {
Category,
Action,
Label,
Status,
Origin,
};

module.exports = { kombuchaEnums };

0 comments on commit 998f26e

Please sign in to comment.