Merge pull request #754 from gitroomhq/feat/instagram-standalone-insights
Instagram standalone insights
This commit is contained in:
commit
1e1834dc67
|
|
@ -16,6 +16,7 @@ import { useToaster } from '@gitroom/react/toaster/toaster';
|
|||
const allowedIntegrations = [
|
||||
'facebook',
|
||||
'instagram',
|
||||
'instagram-standalone',
|
||||
'linkedin-page',
|
||||
// 'tiktok',
|
||||
'youtube',
|
||||
|
|
@ -60,6 +61,7 @@ export const PlatformAnalytics = () => {
|
|||
[
|
||||
'facebook',
|
||||
'instagram',
|
||||
'instagram-standalone',
|
||||
'linkedin-page',
|
||||
'pinterest',
|
||||
'youtube',
|
||||
|
|
@ -76,6 +78,7 @@ export const PlatformAnalytics = () => {
|
|||
[
|
||||
'facebook',
|
||||
'instagram',
|
||||
'instagram-standalone',
|
||||
'linkedin-page',
|
||||
'pinterest',
|
||||
'youtube',
|
||||
|
|
|
|||
|
|
@ -377,20 +377,21 @@ export class InstagramProvider
|
|||
async analytics(
|
||||
id: string,
|
||||
accessToken: string,
|
||||
date: number
|
||||
date: number,
|
||||
type = 'graph.facebook.com'
|
||||
): Promise<AnalyticsData[]> {
|
||||
const until = dayjs().endOf('day').unix();
|
||||
const since = dayjs().subtract(date, 'day').unix();
|
||||
|
||||
const { data, ...all } = await (
|
||||
await this.fetch(
|
||||
`https://graph.facebook.com/v20.0/${id}/insights?metric=follower_count,reach&access_token=${accessToken}&period=day&since=${since}&until=${until}`
|
||||
`https://${type}/v21.0/${id}/insights?metric=follower_count,reach&access_token=${accessToken}&period=day&since=${since}&until=${until}`
|
||||
)
|
||||
).json();
|
||||
|
||||
const { data: data2, ...all2 } = await (
|
||||
await this.fetch(
|
||||
`https://graph.facebook.com/v20.0/${id}/insights?metric_type=total_value&metric=likes,views,comments,shares,saves,replies&access_token=${accessToken}&period=day&since=${since}&until=${until}`
|
||||
`https://${type}/v21.0/${id}/insights?metric_type=total_value&metric=likes,views,comments,shares,saves,replies&access_token=${accessToken}&period=day&since=${since}&until=${until}`
|
||||
)
|
||||
).json();
|
||||
const analytics = [];
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ export class InstagramStandaloneProvider
|
|||
'instagram_business_basic',
|
||||
'instagram_business_content_publish',
|
||||
'instagram_business_manage_comments',
|
||||
'instagram_business_manage_insights',
|
||||
];
|
||||
toolTip = 'Standalone does not support insights or tagging';
|
||||
|
||||
async refreshToken(refresh_token: string): Promise<AuthTokenDetails> {
|
||||
return {
|
||||
|
|
@ -97,12 +97,7 @@ export class InstagramStandaloneProvider
|
|||
|
||||
this.checkScopes(this.scopes, getAccessToken.permissions);
|
||||
|
||||
const {
|
||||
user_id,
|
||||
name,
|
||||
username,
|
||||
profile_picture_url,
|
||||
} = await (
|
||||
const { user_id, name, username, profile_picture_url } = await (
|
||||
await this.fetch(
|
||||
`https://graph.instagram.com/v21.0/me?fields=user_id,username,name,profile_picture_url&access_token=${access_token}`
|
||||
)
|
||||
|
|
@ -125,6 +120,21 @@ export class InstagramStandaloneProvider
|
|||
postDetails: PostDetails<InstagramDto>[],
|
||||
integration: Integration
|
||||
): Promise<PostResponse[]> {
|
||||
return instagramProvider.post(id, accessToken, postDetails, integration, 'graph.instagram.com');
|
||||
return instagramProvider.post(
|
||||
id,
|
||||
accessToken,
|
||||
postDetails,
|
||||
integration,
|
||||
'graph.instagram.com'
|
||||
);
|
||||
}
|
||||
|
||||
async analytics(id: string, accessToken: string, date: number) {
|
||||
return instagramProvider.analytics(
|
||||
id,
|
||||
accessToken,
|
||||
date,
|
||||
'graph.instagram.com'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue