Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 export conversations into csv #142

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

OdapX
Copy link
Collaborator

@OdapX OdapX commented Sep 7, 2023

BREAKING CHANGE: 🧨 n
export conversations into csv files and download a zip file.
Closes: #89

@vercel
Copy link

vercel bot commented Sep 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 8, 2023 10:35am

Copy link
Owner

@gmpetrov gmpetrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ functional tests Great job!
Some minor adjustment before merging though

req: AppNextApiRequest,
res: NextApiResponse
) {
const conversationIds = req.body.ids as string[];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to fetch all conversations of the currently authenticated user instead of passing an array of IDs. Plus with the array of ids, you would need to check that the user is authorized to access the conversation. Also if conversation IDs are passed to the front, only conversation-loaded (there is pagination implemented on this page) will be exported.

So I think we should just fetch all conversations of the current user. Ok for you?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're absolutely right on it

return zip.generateAsync({ type: "nodebuffer" });
}

export default async function wrapper(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replace this code with "export default handler;"

This wrapper is only necessary for endpoints available through our official Chaindesk API (to authorize external domain to call the endpoint).

This endpoint is not meant to be available through the Chaindesk API

@@ -34,6 +35,7 @@ import relativeDate from '@app/utils/relative-date';
import { fetcher } from '@app/utils/swr-fetcher';
import { withAuth } from '@app/utils/withAuth';

import { ConversationExportAlert } from '../../components/ConversationExportAlert';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the path alias please (@app/utils/ etc..) ?

methods: ["POST", "HEAD"],
});

async function exportConversation(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to exportConversations

})
);

async function exportConversations(conversations: ConversationWithMessages[]) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to zipConversations (or something similar. Just name after what the function is meant to do)

const zip = new JSZip();

const header = [
"conversation__id",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the extra underscore necessary?

feat: 🎸 export conversations into csv

✅ Closes: #89
@gmpetrov gmpetrov force-pushed the feat/89-export-conversations branch from 4193f3c to 3eea4cb Compare September 8, 2023 10:31
@gmpetrov gmpetrov merged commit e1fa394 into main Sep 8, 2023
@gmpetrov gmpetrov deleted the feat/89-export-conversations branch June 11, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FR: Export chatbot conversations
2 participants