Skip to content

Commit

Permalink
Merge pull request #958 from itsmdasifraza/feat/add-mixpanel-at-feedback
Browse files Browse the repository at this point in the history
Feat/add mixpanel at feedback
  • Loading branch information
gc-codes authored Jun 5, 2024
2 parents d922086 + 8d8c598 commit 1f71b54
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 11 deletions.
32 changes: 30 additions & 2 deletions src/packages/@app/pages/Collections/CollectionPage.ViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,9 @@ export default class CollectionsViewModel {
// );
this.tabRepository.createTab(request.getValue());
moveNavigation("right");
MixpanelEvent(Events.CREATE_REQUEST, {
source: "Collection list",
});
return;
} else {
this.collectionRepository.deleteRequestOrFolderInCollection(
Expand Down Expand Up @@ -1235,8 +1238,8 @@ export default class CollectionsViewModel {
this.tabRepository.createTab(sampleRequest.getValue());
// this.handleOpenRequest(workspaceId, collection, explorer, request);
moveNavigation("right");
MixpanelEvent(Events.ADD_NEW_API_REQUEST, {
source: "Side Panel Dropdown",
MixpanelEvent(Events.CREATE_REQUEST, {
source: "Collection list",
});
return;
} else {
Expand Down Expand Up @@ -1333,6 +1336,10 @@ export default class CollectionsViewModel {
folder.id,
folderObj,
);

MixpanelEvent(Events.CREATE_FOLDER, {
source: "Collection list",
});
} else {
// Show error notification and clean up by deleting the folder locally on failure.
notifications.error("Failed to create folder!");
Expand Down Expand Up @@ -1368,6 +1375,9 @@ export default class CollectionsViewModel {
this.updateTab(collection.id, {
name: newCollectionName,
});
MixpanelEvent(Events.RENAME_COLLECTION, {
source: "Collection list",
});
} else if (response.message === "Network Error") {
notifications.error(response.message);
} else {
Expand Down Expand Up @@ -1418,6 +1428,9 @@ export default class CollectionsViewModel {
this.updateTab(explorer.id, {
name: newFolderName,
});
MixpanelEvent(Events.RENAME_FOLDER, {
source: "Collection list",
});
}
}
};
Expand Down Expand Up @@ -1547,6 +1560,9 @@ export default class CollectionsViewModel {
this.updateTab(request.id, {
name: newRequestName,
});
MixpanelEvent(Events.RENAME_REQUEST, {
source: "Collection list",
});
}
} else if (collection.id && workspaceId && folder.id) {
let storage = request;
Expand Down Expand Up @@ -1576,6 +1592,9 @@ export default class CollectionsViewModel {
this.updateTab(request.id, {
name: newRequestName,
});
MixpanelEvent(Events.RENAME_REQUEST, {
source: "Collection list",
});
}
}
}
Expand Down Expand Up @@ -1639,6 +1658,9 @@ export default class CollectionsViewModel {
this.deleteCollectioninWorkspace(workspaceId, collection.id);
notifications.success(`"${collection.name}" Collection deleted.`);
this.removeMultipleTabs(deletedIds);
MixpanelEvent(Events.DELETE_COLLECTION, {
source: "Collection list",
});
} else {
notifications.error(
response.message ?? "Failed to delete the Collection.",
Expand Down Expand Up @@ -1684,6 +1706,9 @@ export default class CollectionsViewModel {

notifications.success(`"${explorer.name}" Folder deleted.`);
this.removeMultipleTabs(requestIds);
MixpanelEvent(Events.DELETE_FOLDER, {
source: "Collection list",
});
} else {
notifications.error("Failed to delete the Folder.");
}
Expand Down Expand Up @@ -1730,6 +1755,9 @@ export default class CollectionsViewModel {
if (response.isSuccessful) {
notifications.success(`"${request.name}" Request deleted.`);
this.removeMultipleTabs([request.id]);
MixpanelEvent(Events.DELETE_REQUEST, {
source: "Collection list",
});
return true;
} else {
notifications.error("Failed to delete the Request.");
Expand Down
30 changes: 30 additions & 0 deletions src/packages/@app/pages/Help/HelpPage.ViewModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Events } from "$lib/utils/enums";
import MixpanelEvent from "$lib/utils/mixpanel/MixpanelEvent";
import { FeedbackService } from "@app/services/feedback.service";
import { notifications } from "@library/ui/toast/Toast";
import { DiscordIDs } from "@support/common/constants/discord.constants";
import { open } from "@tauri-apps/plugin-shell";

class HelpPageViewModel {
// Private Services
Expand Down Expand Up @@ -38,8 +42,34 @@ class HelpPageViewModel {
} else {
notifications.error("Feedback submission failed. Please try again.");
}
MixpanelEvent(Events.USER_FEEDBACK, {
source: "Feedback",
});
return response;
};

/**
* Navigates to web flow to join discord
* @returns void
*/
public joinDiscord = async () => {
await open(DiscordIDs.SparrowDiscordURL);
MixpanelEvent(Events.JOIN_DISCORD, {
source: "Feedback",
});
return;
};

/**
* opens 'add feedback' modal to fill the form
* @returns void
*/
public addFeedback = async () => {
MixpanelEvent(Events.ADD_FEEDBACK, {
source: "Feedback",
});
return true;
};
}

export default HelpPageViewModel;
17 changes: 11 additions & 6 deletions src/packages/@app/pages/Help/HelpPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@
import DiscordPost from "@support/features/discord-post/layout/DiscordPost.svelte";
import HelpPageViewModel from "./HelpPage.ViewModel";
const _viewModel = new HelpPageViewModel();
document.addEventListener('contextmenu', event => event.preventDefault());
document.addEventListener("contextmenu", (event) => event.preventDefault());
</script>

<div class="w-100 d-flex jutify-content-center bg-secondary-900">
<div style="height:calc(100vh - 16px); width: calc(100% - 274px ); overflow-y:scroll">
<div class="w-100 d-flex jutify-content-center bg-secondary-900">
<div
style="height:calc(100vh - 16px); width: calc(100% - 274px ); overflow-y:scroll"
>
<FeedbackToast />
<DiscordPost />
</div>
<div style="width: 274px;" class="px-3 pt-5">
<div>
<AddFeedback onSendFeedback={_viewModel.sendFeedback} />
<AddFeedback
onAddFeedback={_viewModel.addFeedback}
onSendFeedback={_viewModel.sendFeedback}
/>
</div>
<div>
<DiscordCard />
<DiscordCard onJoin={_viewModel.joinDiscord} />
</div>
</div>
</div>
11 changes: 11 additions & 0 deletions src/packages/@deprecate/utils/enums/mixpanel-events.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ export enum Events {
USER_LOGIN = "User_Login",
USER_SIGNUP = "User_Signup",
CREATE_COLLECTION = "Create_Collection",
CREATE_FOLDER = "Create_Folder",
CREATE_REQUEST = "Create_Request",
RENAME_COLLECTION = "Rename_Collection",
RENAME_FOLDER = "Rename_Folder",
RENAME_REQUEST = "Rename_Request",
DELETE_COLLECTION = "Delete_Collection",
DELETE_FOLDER = "Delete_Folder",
DELETE_REQUEST = "Delete_Request",
ADD_NEW_API_REQUEST = "Add_New_API_Request",
IMPORT_COLLECTION = "Import_Collection",
GLOBAL_SEARCH = "Global_Search",
Expand All @@ -18,4 +26,7 @@ export enum Events {
CREATE_LOCAL_ENVIRONMENT = "Create_Local_Environment",
SAVE_LOCAL_ENVIRONMENT_VARIABLES = "Save_Local_Environment_Variables",
SEARCH_ENVIRONMENT_VARIABLES = "Search_Environment_Variables",
USER_FEEDBACK = "User_Feedback",
JOIN_DISCORD = "Join_Discord",
ADD_FEEDBACK = "Add_Feedback",
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { notifications } from "@library/ui/toast/Toast";
export let onSendFeedback;
export let onAddFeedback;
enum FeedbackType {
FEEDBACK = "Feedback",
BUG = "Bug",
Expand Down Expand Up @@ -101,7 +101,8 @@
<div class="pb-3 w-100">
<button
on:click={() => {
isExposeFeedbackForm = true;
const res = onAddFeedback();
isExposeFeedbackForm = res;
}}
class="add-feedback w-100 outline-none border-0 border-radius-4 text-fs-14 fw-normal"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import { Tooltip } from "@library/ui";
import { DiscordIDs } from "@support/common/constants/discord.constants";
import { open } from "@tauri-apps/plugin-shell";
export let onJoin;
</script>

<div
Expand Down Expand Up @@ -38,7 +40,7 @@
role="button"
style=" height:40px; background-color: var(--dropdown-button); border-radius:4px;"
on:click={async () => {
await open(DiscordIDs.SparrowDiscordURL);
onJoin();
}}
>
<div class="fw-normal" style="font-size: 14px; color:var(--white-color);">Join</div>
Expand Down

0 comments on commit 1f71b54

Please sign in to comment.