feat: csv, json and, xlsx exporter (#1840)

* feat : csv, jason and, xlxs exporter

* handeling the export fail

* adding expired state to exports

* typo update

* header change

* improvement: added validation for the expired date

---------

Co-authored-by: srinivaspendem <you@example.comsrinivaspendem2612@gmail.com>
This commit is contained in:
srinivas pendem 2023-08-14 11:44:17 +05:30 committed by GitHub
parent 816f00d956
commit ddd3301d17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 673 additions and 24 deletions

View file

@ -0,0 +1,42 @@
import APIService from "services/api.service";
import trackEventServices from "services/track-event.service";
import { ICurrentUserResponse } from "types";
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
const trackEvent =
process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1";
class CSVIntegrationService extends APIService {
constructor() {
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
}
async exportCSVService(
workspaceSlug: string,
data: {
provider: string;
project: string[];
},
user: ICurrentUserResponse
): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/export-issues/`, data)
.then((response) => {
if (trackEvent)
trackEventServices.trackExporterEvent(
{
workspaceSlug,
},
"CSV_EXPORTER_CREATE",
user
);
return response?.data;
})
.catch((error) => {
throw error?.response?.data;
});
}
}
export default new CSVIntegrationService();

View file

@ -7,6 +7,7 @@ import {
ICurrentUserResponse,
IImporterService,
IWorkspaceIntegration,
IExportServiceResponse,
} from "types";
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
@ -52,6 +53,22 @@ class IntegrationService extends APIService {
throw error?.response?.data;
});
}
async getExportsServicesList(
workspaceSlug: string,
cursor: string,
per_page: number
): Promise<IExportServiceResponse> {
return this.get(`/api/workspaces/${workspaceSlug}/export-issues`, {
params: {
per_page,
cursor,
},
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async deleteImporterService(
workspaceSlug: string,

View file

@ -98,6 +98,8 @@ type ImporterEventType =
| "JIRA_IMPORTER_CREATE"
| "JIRA_IMPORTER_DELETE";
type ExporterEventType = "CSV_EXPORTER_CREATE";
type AnalyticsEventType =
| "WORKSPACE_SCOPE_AND_DEMAND_ANALYTICS"
| "WORKSPACE_CUSTOM_ANALYTICS"
@ -776,6 +778,27 @@ class TrackEventServices extends APIService {
});
}
// track exporter function\
async trackExporterEvent(
data: any,
eventName: ExporterEventType,
user: ICurrentUserResponse | undefined
): Promise<any> {
const payload = { ...data };
return this.request({
url: "/api/track-event",
method: "POST",
data: {
eventName,
extra: {
...payload,
},
user: user,
},
});
}
// TODO: add types to the data
async trackInboxEvent(
data: any,