-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ga4 endpoint to use analytics api. (#2765)
Update the analytics endpoint to consume the analytics api instead of cloud function. Endpoints : https://zesty-io.postman.co/workspace/0ccb3ba9-5e99-4e48-9730-505653f4da9a/documentation/23737451-ba1e4049-e456-4147-95f2-9bdccba29a51 Closes : #2760 --------- Co-authored-by: Nar -- <28705606+finnar-bin@users.noreply.github.com> Co-authored-by: Stuart Runyan <shrunyan@gmail.com> Co-authored-by: Andres Galindo <agalin920@gmail.com>
- Loading branch information
1 parent
fa740c1
commit ded9c19
Showing
15 changed files
with
109 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/apps/content-editor/src/app/views/Analytics/components/AnalyticsPropertySelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...itor/src/app/views/Analytics/views/AnalyticsDashboard/ItemsTable/GainersLosersWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...editor/src/app/views/Analytics/views/AnalyticsDashboard/ItemsTable/MostPopularWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; | ||
import { getResponseData, prepareHeaders } from "./util"; | ||
import instanceZUID from "../../utility/instanceZUID"; | ||
|
||
//Define service using a base URL and expected endpoints | ||
export const analyticsApi = createApi({ | ||
reducerPath: "analyticsApi", | ||
baseQuery: fetchBaseQuery({ | ||
// @ts-ignore | ||
baseUrl: `${__CONFIG__.API_ANALYTICS}`, | ||
prepareHeaders, | ||
}), | ||
endpoints: (builder) => ({ | ||
getAnalyticsPropertyDataByQuery: builder.query<any, any>({ | ||
query: (body) => { | ||
return { | ||
url: `ga4/reports`, | ||
method: "POST", | ||
body, | ||
params: { | ||
zuid: instanceZUID, | ||
}, | ||
}; | ||
}, | ||
}), | ||
getAnalyticsProperties: builder.query<any, void>({ | ||
query: () => { | ||
return { | ||
url: `ga4/properties`, | ||
method: "GET", | ||
params: { | ||
zuid: instanceZUID, | ||
}, | ||
}; | ||
}, | ||
}), | ||
getAnalyticsPagePathsByFilter: builder.query< | ||
string[], | ||
{ | ||
filter: "popular" | "gainer" | "loser"; | ||
startDate: string; | ||
endDate: string; | ||
propertyId: string; | ||
limit: number; | ||
order: "asc" | "desc"; | ||
} | ||
>({ | ||
query: ({ filter, startDate, endDate, propertyId, limit, order }) => { | ||
return { | ||
url: `ga4/page-paths`, | ||
method: "GET", | ||
params: { | ||
q: filter, | ||
date_start: startDate, | ||
date_end: endDate, | ||
property_id: propertyId, | ||
limit, | ||
order, | ||
zuid: instanceZUID, | ||
}, | ||
}; | ||
}, | ||
}), | ||
disconnectGoogleAnalytics: builder.mutation<void, void>({ | ||
query: () => { | ||
return { | ||
url: `ga4/auth/disconnect`, | ||
method: "DELETE", | ||
params: { | ||
zuid: instanceZUID, | ||
}, | ||
}; | ||
}, | ||
}), | ||
}), | ||
}); | ||
|
||
// Export hooks for usage in functional components, which are | ||
// auto-generated based on the defined endpoints | ||
export const { | ||
useGetAnalyticsPropertiesQuery, | ||
useGetAnalyticsPropertyDataByQueryQuery, | ||
useGetAnalyticsPagePathsByFilterQuery, | ||
useDisconnectGoogleAnalyticsMutation, | ||
} = analyticsApi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters