-
Notifications
You must be signed in to change notification settings - Fork 425
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
72b4d8a
to
7a0c6cb
Compare
7a0c6cb
to
c9e2733
Compare
c9e2733
to
41c1f91
Compare
41c1f91
to
7ccc728
Compare
There was a problem hiding this 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
pages/api/conversations/export.ts
Outdated
req: AppNextApiRequest, | ||
res: NextApiResponse | ||
) { | ||
const conversationIds = req.body.ids as string[]; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
pages/api/conversations/export.ts
Outdated
return zip.generateAsync({ type: "nodebuffer" }); | ||
} | ||
|
||
export default async function wrapper( |
There was a problem hiding this comment.
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
pages/logs/index.tsx
Outdated
@@ -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'; |
There was a problem hiding this comment.
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..) ?
pages/api/conversations/export.ts
Outdated
methods: ["POST", "HEAD"], | ||
}); | ||
|
||
async function exportConversation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to exportConversations
pages/api/conversations/export.ts
Outdated
}) | ||
); | ||
|
||
async function exportConversations(conversations: ConversationWithMessages[]) { |
There was a problem hiding this comment.
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)
pages/api/conversations/export.ts
Outdated
const zip = new JSZip(); | ||
|
||
const header = [ | ||
"conversation__id", |
There was a problem hiding this comment.
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?
7ccc728
to
752872c
Compare
752872c
to
e8f92e1
Compare
e8f92e1
to
63eeb85
Compare
63eeb85
to
4193f3c
Compare
feat: 🎸 export conversations into csv ✅ Closes: #89
4193f3c
to
3eea4cb
Compare
BREAKING CHANGE: 🧨 n
export conversations into csv files and download a zip file.
✅ Closes: #89