Skip to content

Commit

Permalink
Merge pull request #441 from gitroomhq/fix/analytics
Browse files Browse the repository at this point in the history
Fix analytics to be end of day
  • Loading branch information
nevo-david authored Nov 20, 2024
2 parents f52dc78 + fbaa9d4 commit 33ae1d9
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 509 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
accessToken: string,
date: number
): Promise<AnalyticsData[]> {
const until = dayjs().format('YYYY-MM-DD');
const since = dayjs().subtract(date, 'day').format('YYYY-MM-DD');
const until = dayjs().endOf('day').unix()
const since = dayjs().subtract(date, 'day').unix();

const { data } = await (
await this.fetch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ export class InstagramProvider
accessToken: string,
date: number
): Promise<AnalyticsData[]> {
const until = dayjs().format('YYYY-MM-DD');
const since = dayjs().subtract(date, 'day').format('YYYY-MM-DD');
const until = dayjs().endOf('day').unix();
const since = dayjs().subtract(date, 'day').unix();

const { data, ...all } = await (
await fetch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,15 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider {
accessToken: string,
date: number
): Promise<AnalyticsData[]> {
const until = dayjs().format('YYYY-MM-DD');
const since = dayjs().subtract(date, 'day').format('YYYY-MM-DD');
const until = dayjs().endOf('day').unix();
const since = dayjs().subtract(date, 'day').unix();

const { data, ...all } = await (
await fetch(
`https://graph.threads.net/v1.0/${id}/threads_insights?metric=views,likes,replies,reposts,quotes&access_token=${accessToken}&period=day&since=${since}&until=${until}`
)
).json();

console.log(data);
return (
data?.map((d: any) => ({
label: capitalize(d.name),
Expand Down
Loading

0 comments on commit 33ae1d9

Please sign in to comment.