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:
parent
816f00d956
commit
ddd3301d17
22 changed files with 673 additions and 24 deletions
42
apps/app/services/integration/csv.services.ts
Normal file
42
apps/app/services/integration/csv.services.ts
Normal 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();
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue