@memberjunction/actions-bizapps-social 2.112.0 → 2.113.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/base/base-social.action.d.ts.map +1 -1
- package/dist/base/base-social.action.js +24 -18
- package/dist/base/base-social.action.js.map +1 -1
- package/dist/providers/buffer/buffer-base.action.d.ts.map +1 -1
- package/dist/providers/buffer/buffer-base.action.js +34 -35
- package/dist/providers/buffer/buffer-base.action.js.map +1 -1
- package/dist/providers/facebook/actions/boost-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/boost-post.action.js +33 -33
- package/dist/providers/facebook/actions/boost-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/create-album.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/create-album.action.js +36 -34
- package/dist/providers/facebook/actions/create-album.action.js.map +1 -1
- package/dist/providers/facebook/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/create-post.action.js +20 -20
- package/dist/providers/facebook/actions/create-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-page-insights.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-page-insights.action.js +27 -25
- package/dist/providers/facebook/actions/get-page-insights.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-page-posts.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-page-posts.action.js +23 -19
- package/dist/providers/facebook/actions/get-page-posts.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-post-insights.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-post-insights.action.js +32 -28
- package/dist/providers/facebook/actions/get-post-insights.action.js.map +1 -1
- package/dist/providers/facebook/actions/respond-to-comments.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/respond-to-comments.action.js +44 -42
- package/dist/providers/facebook/actions/respond-to-comments.action.js.map +1 -1
- package/dist/providers/facebook/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/schedule-post.action.js +29 -29
- package/dist/providers/facebook/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/search-posts.action.js +39 -37
- package/dist/providers/facebook/actions/search-posts.action.js.map +1 -1
- package/dist/providers/facebook/facebook-base.action.d.ts.map +1 -1
- package/dist/providers/facebook/facebook-base.action.js +59 -44
- package/dist/providers/facebook/facebook-base.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js +31 -33
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.js +32 -28
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js +19 -19
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-analytics.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-analytics.action.js +26 -24
- package/dist/providers/hootsuite/actions/get-analytics.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js +22 -22
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-social-profiles.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-social-profiles.action.js +34 -32
- package/dist/providers/hootsuite/actions/get-social-profiles.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/search-posts.action.js +52 -43
- package/dist/providers/hootsuite/actions/search-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.js +28 -30
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/hootsuite-base.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/hootsuite-base.action.js +20 -18
- package/dist/providers/hootsuite/hootsuite-base.action.js.map +1 -1
- package/dist/providers/instagram/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/create-post.action.js +26 -27
- package/dist/providers/instagram/actions/create-post.action.js.map +1 -1
- package/dist/providers/instagram/actions/create-story.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/create-story.action.js +35 -35
- package/dist/providers/instagram/actions/create-story.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-account-insights.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-account-insights.action.js +59 -38
- package/dist/providers/instagram/actions/get-account-insights.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-business-posts.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-business-posts.action.js +29 -29
- package/dist/providers/instagram/actions/get-business-posts.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-comments.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-comments.action.js +36 -36
- package/dist/providers/instagram/actions/get-comments.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-post-insights.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-post-insights.action.js +25 -23
- package/dist/providers/instagram/actions/get-post-insights.action.js.map +1 -1
- package/dist/providers/instagram/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/schedule-post.action.js +25 -25
- package/dist/providers/instagram/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/instagram/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/search-posts.action.js +60 -56
- package/dist/providers/instagram/actions/search-posts.action.js.map +1 -1
- package/dist/providers/instagram/instagram-base.action.d.ts.map +1 -1
- package/dist/providers/instagram/instagram-base.action.js +27 -25
- package/dist/providers/instagram/instagram-base.action.js.map +1 -1
- package/dist/providers/linkedin/actions/create-article.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/create-article.action.js +45 -55
- package/dist/providers/linkedin/actions/create-article.action.js.map +1 -1
- package/dist/providers/linkedin/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/create-post.action.js +29 -31
- package/dist/providers/linkedin/actions/create-post.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-followers.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-followers.action.js +28 -28
- package/dist/providers/linkedin/actions/get-followers.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-organization-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-organization-posts.action.js +20 -20
- package/dist/providers/linkedin/actions/get-organization-posts.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-personal-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-personal-posts.action.js +19 -19
- package/dist/providers/linkedin/actions/get-personal-posts.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-post-analytics.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-post-analytics.action.js +23 -25
- package/dist/providers/linkedin/actions/get-post-analytics.action.js.map +1 -1
- package/dist/providers/linkedin/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/schedule-post.action.js +30 -32
- package/dist/providers/linkedin/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/linkedin/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/search-posts.action.js +30 -28
- package/dist/providers/linkedin/actions/search-posts.action.js.map +1 -1
- package/dist/providers/linkedin/linkedin-base.action.d.ts.map +1 -1
- package/dist/providers/linkedin/linkedin-base.action.js +38 -33
- package/dist/providers/linkedin/linkedin-base.action.js.map +1 -1
- package/dist/providers/tiktok/tiktok-base.action.d.ts.map +1 -1
- package/dist/providers/tiktok/tiktok-base.action.js +26 -25
- package/dist/providers/tiktok/tiktok-base.action.js.map +1 -1
- package/dist/providers/twitter/actions/create-thread.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/create-thread.action.js +29 -25
- package/dist/providers/twitter/actions/create-thread.action.js.map +1 -1
- package/dist/providers/twitter/actions/create-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/create-tweet.action.js +23 -23
- package/dist/providers/twitter/actions/create-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/delete-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/delete-tweet.action.js +19 -19
- package/dist/providers/twitter/actions/delete-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-analytics.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-analytics.action.js +47 -40
- package/dist/providers/twitter/actions/get-analytics.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-mentions.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-mentions.action.js +31 -30
- package/dist/providers/twitter/actions/get-mentions.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-timeline.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-timeline.action.js +29 -29
- package/dist/providers/twitter/actions/get-timeline.action.js.map +1 -1
- package/dist/providers/twitter/actions/schedule-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/schedule-tweet.action.js +26 -26
- package/dist/providers/twitter/actions/schedule-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/search-tweets.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/search-tweets.action.js +58 -56
- package/dist/providers/twitter/actions/search-tweets.action.js.map +1 -1
- package/dist/providers/twitter/twitter-base.action.d.ts.map +1 -1
- package/dist/providers/twitter/twitter-base.action.js +68 -58
- package/dist/providers/twitter/twitter-base.action.js.map +1 -1
- package/dist/providers/youtube/youtube-base.action.d.ts +1 -1
- package/dist/providers/youtube/youtube-base.action.d.ts.map +1 -1
- package/dist/providers/youtube/youtube-base.action.js +25 -22
- package/dist/providers/youtube/youtube-base.action.js.map +1 -1
- package/package.json +6 -5
- package/src/base/base-social.action.ts +224 -217
- package/src/providers/buffer/buffer-base.action.ts +441 -435
- package/src/providers/facebook/actions/boost-post.action.ts +386 -350
- package/src/providers/facebook/actions/create-album.action.ts +307 -291
- package/src/providers/facebook/actions/create-post.action.ts +227 -224
- package/src/providers/facebook/actions/get-page-insights.action.ts +403 -383
- package/src/providers/facebook/actions/get-page-posts.action.ts +225 -214
- package/src/providers/facebook/actions/get-post-insights.action.ts +316 -300
- package/src/providers/facebook/actions/respond-to-comments.action.ts +336 -319
- package/src/providers/facebook/actions/schedule-post.action.ts +292 -289
- package/src/providers/facebook/actions/search-posts.action.ts +413 -399
- package/src/providers/facebook/facebook-base.action.ts +670 -653
- package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
- package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +189 -184
- package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +161 -160
- package/src/providers/hootsuite/actions/get-analytics.action.ts +254 -249
- package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +207 -206
- package/src/providers/hootsuite/actions/get-social-profiles.action.ts +205 -206
- package/src/providers/hootsuite/actions/search-posts.action.ts +369 -351
- package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +209 -211
- package/src/providers/hootsuite/hootsuite-base.action.ts +307 -301
- package/src/providers/instagram/actions/create-post.action.ts +296 -276
- package/src/providers/instagram/actions/create-story.action.ts +394 -378
- package/src/providers/instagram/actions/get-account-insights.action.ts +420 -384
- package/src/providers/instagram/actions/get-business-posts.action.ts +242 -233
- package/src/providers/instagram/actions/get-comments.action.ts +377 -365
- package/src/providers/instagram/actions/get-post-insights.action.ts +273 -265
- package/src/providers/instagram/actions/schedule-post.action.ts +235 -233
- package/src/providers/instagram/actions/search-posts.action.ts +538 -512
- package/src/providers/instagram/instagram-base.action.ts +393 -368
- package/src/providers/linkedin/actions/create-article.action.ts +266 -275
- package/src/providers/linkedin/actions/create-post.action.ts +177 -179
- package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
- package/src/providers/linkedin/actions/get-organization-posts.action.ts +147 -146
- package/src/providers/linkedin/actions/get-personal-posts.action.ts +139 -138
- package/src/providers/linkedin/actions/get-post-analytics.action.ts +189 -190
- package/src/providers/linkedin/actions/schedule-post.action.ts +189 -191
- package/src/providers/linkedin/actions/search-posts.action.ts +283 -275
- package/src/providers/linkedin/linkedin-base.action.ts +421 -407
- package/src/providers/tiktok/tiktok-base.action.ts +320 -305
- package/src/providers/twitter/actions/create-thread.action.ts +207 -203
- package/src/providers/twitter/actions/create-tweet.action.ts +188 -187
- package/src/providers/twitter/actions/delete-tweet.action.ts +129 -128
- package/src/providers/twitter/actions/get-analytics.action.ts +411 -402
- package/src/providers/twitter/actions/get-mentions.action.ts +219 -218
- package/src/providers/twitter/actions/get-timeline.action.ts +233 -232
- package/src/providers/twitter/actions/schedule-tweet.action.ts +222 -221
- package/src/providers/twitter/actions/search-tweets.action.ts +543 -540
- package/src/providers/twitter/twitter-base.action.ts +560 -541
- package/src/providers/youtube/youtube-base.action.ts +333 -320
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RegisterClass } from '@memberjunction/global';
|
|
2
2
|
import { HootSuiteBaseAction, HootSuiteAnalytics } from '../hootsuite-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
4
|
+
import { LogStatus, LogError } from '@memberjunction/core';
|
|
5
5
|
import { SocialAnalytics } from '../../../base/base-social.action';
|
|
6
6
|
import { BaseAction } from '@memberjunction/actions';
|
|
7
7
|
|
|
@@ -10,268 +10,273 @@ import { BaseAction } from '@memberjunction/actions';
|
|
|
10
10
|
*/
|
|
11
11
|
@RegisterClass(BaseAction, 'HootSuiteGetAnalyticsAction')
|
|
12
12
|
export class HootSuiteGetAnalyticsAction extends HootSuiteBaseAction {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Get analytics data from HootSuite
|
|
15
|
+
*/
|
|
16
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
17
|
+
const { Params, ContextUser } = params;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
// Initialize OAuth
|
|
21
|
+
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
22
|
+
if (!await this.initializeOAuth(companyIntegrationId)) {
|
|
23
|
+
throw new Error('Failed to initialize OAuth connection');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Extract parameters
|
|
27
|
+
const postId = this.getParamValue(Params, 'PostID');
|
|
28
|
+
const profileId = this.getParamValue(Params, 'ProfileID');
|
|
29
|
+
const startDate = this.getParamValue(Params, 'StartDate');
|
|
30
|
+
const endDate = this.getParamValue(Params, 'EndDate');
|
|
31
|
+
const metricsType = this.getParamValue(Params, 'MetricsType') || 'all';
|
|
32
|
+
const aggregateByProfile = this.getParamValue(Params, 'AggregateByProfile') || false;
|
|
33
|
+
|
|
34
|
+
// Determine what analytics to fetch
|
|
35
|
+
let analyticsData: any;
|
|
36
|
+
|
|
37
|
+
if (postId) {
|
|
38
|
+
// Get analytics for specific post
|
|
39
|
+
analyticsData = await this.getPostAnalytics(postId, startDate, endDate);
|
|
40
|
+
} else if (profileId) {
|
|
41
|
+
// Get analytics for specific profile
|
|
42
|
+
analyticsData = await this.getProfileAnalytics(profileId, startDate, endDate, metricsType);
|
|
43
|
+
} else {
|
|
44
|
+
// Get analytics for all profiles
|
|
45
|
+
analyticsData = await this.getAllProfilesAnalytics(startDate, endDate, metricsType, aggregateByProfile);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Normalize analytics
|
|
49
|
+
const normalizedAnalytics = this.processAnalyticsData(analyticsData, metricsType);
|
|
50
|
+
|
|
51
|
+
// Create summary
|
|
52
|
+
const summary = {
|
|
53
|
+
period: {
|
|
54
|
+
start: startDate || 'Not specified',
|
|
55
|
+
end: endDate || 'Not specified'
|
|
56
|
+
},
|
|
57
|
+
metricsType: metricsType,
|
|
58
|
+
totalMetrics: this.calculateTotalMetrics(normalizedAnalytics),
|
|
59
|
+
topPerformingPosts: this.getTopPerformingPosts(normalizedAnalytics),
|
|
60
|
+
engagementRate: this.calculateEngagementRate(normalizedAnalytics)
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Update output parameters
|
|
64
|
+
const outputParams = [...Params];
|
|
65
|
+
const analyticsParam = outputParams.find(p => p.Name === 'Analytics');
|
|
66
|
+
if (analyticsParam) analyticsParam.Value = normalizedAnalytics;
|
|
67
|
+
const summaryParam = outputParams.find(p => p.Name === 'Summary');
|
|
68
|
+
if (summaryParam) summaryParam.Value = summary;
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
Success: true,
|
|
72
|
+
ResultCode: 'SUCCESS',
|
|
73
|
+
Message: 'Successfully retrieved analytics data',
|
|
74
|
+
Params: outputParams
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} catch (error) {
|
|
78
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
Success: false,
|
|
82
|
+
ResultCode: 'ERROR',
|
|
83
|
+
Message: `Failed to get analytics: ${errorMessage}`,
|
|
84
|
+
Params
|
|
85
|
+
};
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Get analytics for a specific post
|
|
90
|
-
*/
|
|
91
|
-
private async getPostAnalytics(postId: string, startDate?: string, endDate?: string): Promise<HootSuiteAnalytics> {
|
|
92
|
-
const params: any = {};
|
|
93
|
-
if (startDate) params.startTime = this.formatHootSuiteDate(startDate);
|
|
94
|
-
if (endDate) params.endTime = this.formatHootSuiteDate(endDate);
|
|
95
|
-
|
|
96
|
-
const response = await this.axiosInstance.get(`/analytics/posts/${postId}`, { params });
|
|
97
|
-
return response.data;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Get analytics for a specific profile
|
|
102
|
-
*/
|
|
103
|
-
private async getProfileAnalytics(profileId: string, startDate?: string, endDate?: string, metricsType?: string): Promise<any> {
|
|
104
|
-
const params: any = {
|
|
105
|
-
socialProfileIds: profileId,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
if (startDate) params.startTime = this.formatHootSuiteDate(startDate);
|
|
109
|
-
if (endDate) params.endTime = this.formatHootSuiteDate(endDate);
|
|
110
|
-
if (metricsType && metricsType !== 'all') params.metrics = this.getMetricsList(metricsType);
|
|
111
88
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Get analytics for a specific post
|
|
91
|
+
*/
|
|
92
|
+
private async getPostAnalytics(postId: string, startDate?: string, endDate?: string): Promise<HootSuiteAnalytics> {
|
|
93
|
+
const params: any = {};
|
|
94
|
+
if (startDate) params.startTime = this.formatHootSuiteDate(startDate);
|
|
95
|
+
if (endDate) params.endTime = this.formatHootSuiteDate(endDate);
|
|
115
96
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*/
|
|
119
|
-
private async getAllProfilesAnalytics(
|
|
120
|
-
startDate?: string,
|
|
121
|
-
endDate?: string,
|
|
122
|
-
metricsType?: string,
|
|
123
|
-
aggregateByProfile?: boolean
|
|
124
|
-
): Promise<any> {
|
|
125
|
-
// First get all profiles
|
|
126
|
-
const profiles = await this.getSocialProfiles();
|
|
127
|
-
|
|
128
|
-
if (profiles.length === 0) {
|
|
129
|
-
return { data: [] };
|
|
97
|
+
const response = await this.axiosInstance.get(`/analytics/posts/${postId}`, { params });
|
|
98
|
+
return response.data;
|
|
130
99
|
}
|
|
131
100
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Get analytics for a specific profile
|
|
103
|
+
*/
|
|
104
|
+
private async getProfileAnalytics(
|
|
105
|
+
profileId: string,
|
|
106
|
+
startDate?: string,
|
|
107
|
+
endDate?: string,
|
|
108
|
+
metricsType?: string
|
|
109
|
+
): Promise<any> {
|
|
110
|
+
const params: any = {
|
|
111
|
+
socialProfileIds: profileId
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (startDate) params.startTime = this.formatHootSuiteDate(startDate);
|
|
115
|
+
if (endDate) params.endTime = this.formatHootSuiteDate(endDate);
|
|
116
|
+
if (metricsType && metricsType !== 'all') params.metrics = this.getMetricsList(metricsType);
|
|
117
|
+
|
|
118
|
+
const response = await this.axiosInstance.get('/analytics/profiles', { params });
|
|
119
|
+
return response.data;
|
|
120
|
+
}
|
|
140
121
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Get analytics for all profiles
|
|
124
|
+
*/
|
|
125
|
+
private async getAllProfilesAnalytics(
|
|
126
|
+
startDate?: string,
|
|
127
|
+
endDate?: string,
|
|
128
|
+
metricsType?: string,
|
|
129
|
+
aggregateByProfile?: boolean
|
|
130
|
+
): Promise<any> {
|
|
131
|
+
// First get all profiles
|
|
132
|
+
const profiles = await this.getSocialProfiles();
|
|
133
|
+
|
|
134
|
+
if (profiles.length === 0) {
|
|
135
|
+
return { data: [] };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const params: any = {
|
|
139
|
+
socialProfileIds: profiles.map(p => p.id).join(',')
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
if (startDate) params.startTime = this.formatHootSuiteDate(startDate);
|
|
143
|
+
if (endDate) params.endTime = this.formatHootSuiteDate(endDate);
|
|
144
|
+
if (metricsType && metricsType !== 'all') params.metrics = this.getMetricsList(metricsType);
|
|
145
|
+
if (aggregateByProfile) params.groupBy = 'socialProfile';
|
|
146
|
+
|
|
147
|
+
const response = await this.axiosInstance.get('/analytics/profiles', { params });
|
|
148
|
+
return response.data;
|
|
149
|
+
}
|
|
144
150
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Get list of metrics based on type
|
|
153
|
+
*/
|
|
154
|
+
private getMetricsList(metricsType: string): string {
|
|
155
|
+
const metricsMap: Record<string, string[]> = {
|
|
156
|
+
'engagement': ['likes', 'comments', 'shares', 'engagements'],
|
|
157
|
+
'reach': ['impressions', 'reach'],
|
|
158
|
+
'clicks': ['clicks', 'linkClicks'],
|
|
159
|
+
'all': ['likes', 'comments', 'shares', 'clicks', 'impressions', 'engagements', 'reach']
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return (metricsMap[metricsType] || metricsMap['all']).join(',');
|
|
163
|
+
}
|
|
155
164
|
|
|
156
|
-
|
|
157
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Process and normalize analytics data
|
|
167
|
+
*/
|
|
168
|
+
private processAnalyticsData(data: any, metricsType: string): SocialAnalytics[] {
|
|
169
|
+
if (!data || !data.data) return [];
|
|
158
170
|
|
|
159
|
-
|
|
160
|
-
* Process and normalize analytics data
|
|
161
|
-
*/
|
|
162
|
-
private processAnalyticsData(data: any, metricsType: string): SocialAnalytics[] {
|
|
163
|
-
if (!data || !data.data) return [];
|
|
171
|
+
const results: SocialAnalytics[] = [];
|
|
164
172
|
|
|
165
|
-
|
|
173
|
+
if (Array.isArray(data.data)) {
|
|
174
|
+
data.data.forEach((item: any) => {
|
|
175
|
+
results.push(this.normalizeAnalytics(item.metrics));
|
|
176
|
+
});
|
|
177
|
+
} else if (data.metrics) {
|
|
178
|
+
results.push(this.normalizeAnalytics(data.metrics));
|
|
179
|
+
}
|
|
166
180
|
|
|
167
|
-
|
|
168
|
-
data.data.forEach((item: any) => {
|
|
169
|
-
results.push(this.normalizeAnalytics(item.metrics));
|
|
170
|
-
});
|
|
171
|
-
} else if (data.metrics) {
|
|
172
|
-
results.push(this.normalizeAnalytics(data.metrics));
|
|
181
|
+
return results;
|
|
173
182
|
}
|
|
174
183
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
saves: 0,
|
|
204
|
-
videoViews: 0,
|
|
205
|
-
platformMetrics: {},
|
|
206
|
-
}
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Get top performing posts based on engagement
|
|
212
|
-
*/
|
|
213
|
-
private getTopPerformingPosts(analytics: SocialAnalytics[]): SocialAnalytics[] {
|
|
214
|
-
return analytics.sort((a, b) => b.engagements - a.engagements).slice(0, 5);
|
|
215
|
-
}
|
|
184
|
+
/**
|
|
185
|
+
* Calculate total metrics across all data
|
|
186
|
+
*/
|
|
187
|
+
private calculateTotalMetrics(analytics: SocialAnalytics[]): SocialAnalytics {
|
|
188
|
+
return analytics.reduce((total, current) => ({
|
|
189
|
+
impressions: total.impressions + current.impressions,
|
|
190
|
+
engagements: total.engagements + current.engagements,
|
|
191
|
+
clicks: total.clicks + current.clicks,
|
|
192
|
+
shares: total.shares + current.shares,
|
|
193
|
+
comments: total.comments + current.comments,
|
|
194
|
+
likes: total.likes + current.likes,
|
|
195
|
+
reach: total.reach + current.reach,
|
|
196
|
+
saves: (total.saves || 0) + (current.saves || 0),
|
|
197
|
+
videoViews: (total.videoViews || 0) + (current.videoViews || 0),
|
|
198
|
+
platformMetrics: {}
|
|
199
|
+
}), {
|
|
200
|
+
impressions: 0,
|
|
201
|
+
engagements: 0,
|
|
202
|
+
clicks: 0,
|
|
203
|
+
shares: 0,
|
|
204
|
+
comments: 0,
|
|
205
|
+
likes: 0,
|
|
206
|
+
reach: 0,
|
|
207
|
+
saves: 0,
|
|
208
|
+
videoViews: 0,
|
|
209
|
+
platformMetrics: {}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
216
212
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Get top performing posts based on engagement
|
|
215
|
+
*/
|
|
216
|
+
private getTopPerformingPosts(analytics: SocialAnalytics[]): SocialAnalytics[] {
|
|
217
|
+
return analytics
|
|
218
|
+
.sort((a, b) => b.engagements - a.engagements)
|
|
219
|
+
.slice(0, 5);
|
|
220
|
+
}
|
|
223
221
|
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Calculate average engagement rate
|
|
224
|
+
*/
|
|
225
|
+
private calculateEngagementRate(analytics: SocialAnalytics[]): number {
|
|
226
|
+
const total = this.calculateTotalMetrics(analytics);
|
|
227
|
+
if (total.impressions === 0) return 0;
|
|
228
|
+
|
|
229
|
+
return (total.engagements / total.impressions) * 100;
|
|
230
|
+
}
|
|
226
231
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Define the parameters this action expects
|
|
234
|
+
*/
|
|
235
|
+
public get Params(): ActionParam[] {
|
|
236
|
+
return [
|
|
237
|
+
...this.commonSocialParams,
|
|
238
|
+
{
|
|
239
|
+
Name: 'PostID',
|
|
240
|
+
Type: 'Input',
|
|
241
|
+
Value: null
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
Name: 'StartDate',
|
|
245
|
+
Type: 'Input',
|
|
246
|
+
Value: null
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
Name: 'EndDate',
|
|
250
|
+
Type: 'Input',
|
|
251
|
+
Value: null
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
Name: 'MetricsType',
|
|
255
|
+
Type: 'Input',
|
|
256
|
+
Value: null
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
Name: 'AggregateByProfile',
|
|
260
|
+
Type: 'Input',
|
|
261
|
+
Value: null
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
Name: 'Analytics',
|
|
265
|
+
Type: 'Output',
|
|
266
|
+
Value: null
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
Name: 'Summary',
|
|
270
|
+
Type: 'Output',
|
|
271
|
+
Value: null
|
|
272
|
+
}
|
|
273
|
+
];
|
|
274
|
+
}
|
|
270
275
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
276
|
+
/**
|
|
277
|
+
* Get action description
|
|
278
|
+
*/
|
|
279
|
+
public get Description(): string {
|
|
280
|
+
return 'Retrieves analytics data from HootSuite for posts, profiles, or overall account performance';
|
|
281
|
+
}
|
|
282
|
+
}
|