@memberjunction/actions-bizapps-social 2.111.0 → 2.112.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 +6 -6
- package/dist/base/base-social.action.d.ts.map +1 -1
- package/dist/base/base-social.action.js +18 -24
- 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 +35 -34
- 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 +34 -36
- 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 +25 -27
- 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 +19 -23
- 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 +28 -32
- 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 +42 -44
- 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 +37 -39
- 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 +44 -59
- 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 +33 -31
- 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 +28 -32
- 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 +24 -26
- 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 +32 -34
- 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 +43 -52
- 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 +30 -28
- 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 +18 -20
- 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 +27 -26
- 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 +38 -59
- 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 +23 -25
- 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 +56 -60
- 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 +25 -27
- 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 +55 -45
- 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 +31 -29
- 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 +25 -23
- 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 +32 -30
- 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 +28 -30
- 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 +33 -38
- 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 +25 -26
- 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 +25 -29
- 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 +40 -47
- 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 +30 -31
- 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 +56 -58
- 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 +58 -68
- 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 +22 -25
- package/dist/providers/youtube/youtube-base.action.js.map +1 -1
- package/package.json +5 -6
- package/src/base/base-social.action.ts +217 -224
- package/src/providers/buffer/buffer-base.action.ts +435 -441
- package/src/providers/facebook/actions/boost-post.action.ts +350 -386
- package/src/providers/facebook/actions/create-album.action.ts +291 -307
- package/src/providers/facebook/actions/create-post.action.ts +224 -227
- package/src/providers/facebook/actions/get-page-insights.action.ts +383 -403
- package/src/providers/facebook/actions/get-page-posts.action.ts +214 -225
- package/src/providers/facebook/actions/get-post-insights.action.ts +300 -316
- package/src/providers/facebook/actions/respond-to-comments.action.ts +319 -336
- package/src/providers/facebook/actions/schedule-post.action.ts +289 -292
- package/src/providers/facebook/actions/search-posts.action.ts +399 -413
- package/src/providers/facebook/facebook-base.action.ts +653 -670
- package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
- package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +184 -189
- package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +160 -161
- package/src/providers/hootsuite/actions/get-analytics.action.ts +249 -254
- package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +206 -207
- package/src/providers/hootsuite/actions/get-social-profiles.action.ts +206 -205
- package/src/providers/hootsuite/actions/search-posts.action.ts +351 -369
- package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +211 -209
- package/src/providers/hootsuite/hootsuite-base.action.ts +301 -307
- package/src/providers/instagram/actions/create-post.action.ts +276 -296
- package/src/providers/instagram/actions/create-story.action.ts +378 -394
- package/src/providers/instagram/actions/get-account-insights.action.ts +384 -420
- package/src/providers/instagram/actions/get-business-posts.action.ts +233 -242
- package/src/providers/instagram/actions/get-comments.action.ts +365 -377
- package/src/providers/instagram/actions/get-post-insights.action.ts +265 -273
- package/src/providers/instagram/actions/schedule-post.action.ts +233 -235
- package/src/providers/instagram/actions/search-posts.action.ts +512 -538
- package/src/providers/instagram/instagram-base.action.ts +368 -393
- package/src/providers/linkedin/actions/create-article.action.ts +275 -266
- package/src/providers/linkedin/actions/create-post.action.ts +179 -177
- package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
- package/src/providers/linkedin/actions/get-organization-posts.action.ts +146 -147
- package/src/providers/linkedin/actions/get-personal-posts.action.ts +138 -139
- package/src/providers/linkedin/actions/get-post-analytics.action.ts +190 -189
- package/src/providers/linkedin/actions/schedule-post.action.ts +191 -189
- package/src/providers/linkedin/actions/search-posts.action.ts +275 -283
- package/src/providers/linkedin/linkedin-base.action.ts +407 -421
- package/src/providers/tiktok/tiktok-base.action.ts +305 -320
- package/src/providers/twitter/actions/create-thread.action.ts +203 -207
- package/src/providers/twitter/actions/create-tweet.action.ts +187 -188
- package/src/providers/twitter/actions/delete-tweet.action.ts +128 -129
- package/src/providers/twitter/actions/get-analytics.action.ts +402 -411
- package/src/providers/twitter/actions/get-mentions.action.ts +218 -219
- package/src/providers/twitter/actions/get-timeline.action.ts +232 -233
- package/src/providers/twitter/actions/schedule-tweet.action.ts +221 -222
- package/src/providers/twitter/actions/search-tweets.action.ts +540 -543
- package/src/providers/twitter/twitter-base.action.ts +541 -560
- package/src/providers/youtube/youtube-base.action.ts +320 -333
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RegisterClass } from '@memberjunction/global';
|
|
2
2
|
import { TwitterBaseAction, Tweet } from '../twitter-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
4
|
+
import { LogStatus, LogError } from '@memberjunction/global';
|
|
5
5
|
import { SocialPost } from '../../../base/base-social.action';
|
|
6
6
|
import { BaseAction } from '@memberjunction/actions';
|
|
7
7
|
|
|
@@ -10,225 +10,224 @@ import { BaseAction } from '@memberjunction/actions';
|
|
|
10
10
|
*/
|
|
11
11
|
@RegisterClass(BaseAction, 'TwitterGetMentionsAction')
|
|
12
12
|
export class TwitterGetMentionsAction extends TwitterBaseAction {
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Calculate engagement statistics
|
|
102
|
-
const stats = {
|
|
103
|
-
totalMentions: normalizedPosts.length,
|
|
104
|
-
mentionTypes,
|
|
105
|
-
totalEngagement: 0,
|
|
106
|
-
averageEngagement: 0,
|
|
107
|
-
topMentions: [] as any[]
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// Calculate total engagement
|
|
111
|
-
normalizedPosts.forEach(post => {
|
|
112
|
-
if (post.analytics) {
|
|
113
|
-
stats.totalEngagement += post.analytics.engagements;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// Calculate average engagement
|
|
118
|
-
if (normalizedPosts.length > 0) {
|
|
119
|
-
stats.averageEngagement = Math.round(stats.totalEngagement / normalizedPosts.length);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Get top 5 mentions by engagement
|
|
123
|
-
stats.topMentions = normalizedPosts
|
|
124
|
-
.filter(post => post.analytics)
|
|
125
|
-
.sort((a, b) => (b.analytics?.engagements || 0) - (a.analytics?.engagements || 0))
|
|
126
|
-
.slice(0, 5)
|
|
127
|
-
.map(post => ({
|
|
128
|
-
id: post.id,
|
|
129
|
-
content: post.content.substring(0, 100) + (post.content.length > 100 ? '...' : ''),
|
|
130
|
-
engagement: post.analytics?.engagements,
|
|
131
|
-
author: filteredMentions.find(t => t.id === post.id)?.author_id
|
|
132
|
-
}));
|
|
133
|
-
|
|
134
|
-
// Update output parameters
|
|
135
|
-
const outputParams = [...Params];
|
|
136
|
-
const postsParam = outputParams.find(p => p.Name === 'Mentions');
|
|
137
|
-
if (postsParam) postsParam.Value = normalizedPosts;
|
|
138
|
-
const tweetsParam = outputParams.find(p => p.Name === 'Tweets');
|
|
139
|
-
if (tweetsParam) tweetsParam.Value = filteredMentions;
|
|
140
|
-
const statsParam = outputParams.find(p => p.Name === 'Statistics');
|
|
141
|
-
if (statsParam) statsParam.Value = stats;
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
Success: true,
|
|
145
|
-
ResultCode: 'SUCCESS',
|
|
146
|
-
Message: `Successfully retrieved ${normalizedPosts.length} mentions`,
|
|
147
|
-
Params: outputParams
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
} catch (error) {
|
|
151
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
Success: false,
|
|
155
|
-
ResultCode: this.getErrorCode(error),
|
|
156
|
-
Message: `Failed to get mentions: ${errorMessage}`,
|
|
157
|
-
Params
|
|
158
|
-
};
|
|
13
|
+
/**
|
|
14
|
+
* Get mentions from Twitter
|
|
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 maxResults = this.getParamValue(Params, 'MaxResults') || 100;
|
|
28
|
+
const startTime = this.getParamValue(Params, 'StartTime');
|
|
29
|
+
const endTime = this.getParamValue(Params, 'EndTime');
|
|
30
|
+
const sinceId = this.getParamValue(Params, 'SinceID');
|
|
31
|
+
const untilId = this.getParamValue(Params, 'UntilID');
|
|
32
|
+
const includeRetweets = this.getParamValue(Params, 'IncludeRetweets') !== false; // Default true
|
|
33
|
+
|
|
34
|
+
// Get current user info
|
|
35
|
+
const currentUser = await this.getCurrentUser();
|
|
36
|
+
|
|
37
|
+
// Build query parameters
|
|
38
|
+
const queryParams: Record<string, any> = {
|
|
39
|
+
'tweet.fields':
|
|
40
|
+
'id,text,created_at,author_id,conversation_id,public_metrics,attachments,entities,referenced_tweets,in_reply_to_user_id',
|
|
41
|
+
'user.fields': 'id,name,username,profile_image_url,description,created_at,verified',
|
|
42
|
+
'media.fields': 'url,preview_image_url,type,width,height',
|
|
43
|
+
expansions: 'author_id,attachments.media_keys,referenced_tweets.id,referenced_tweets.id.author_id,in_reply_to_user_id',
|
|
44
|
+
max_results: Math.min(maxResults, 100), // API limit per request
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Add time-based filters if provided
|
|
48
|
+
if (startTime) {
|
|
49
|
+
queryParams['start_time'] = this.formatTwitterDate(startTime);
|
|
50
|
+
}
|
|
51
|
+
if (endTime) {
|
|
52
|
+
queryParams['end_time'] = this.formatTwitterDate(endTime);
|
|
53
|
+
}
|
|
54
|
+
if (sinceId) {
|
|
55
|
+
queryParams['since_id'] = sinceId;
|
|
56
|
+
}
|
|
57
|
+
if (untilId) {
|
|
58
|
+
queryParams['until_id'] = untilId;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Get mentions using the mentions timeline endpoint
|
|
62
|
+
const endpoint = `/users/${currentUser.id}/mentions`;
|
|
63
|
+
|
|
64
|
+
LogStatus(`Getting mentions for @${currentUser.username}...`);
|
|
65
|
+
const mentions = await this.getPaginatedTweets(endpoint, queryParams, maxResults);
|
|
66
|
+
|
|
67
|
+
// Filter out retweets if requested
|
|
68
|
+
let filteredMentions = mentions;
|
|
69
|
+
if (!includeRetweets) {
|
|
70
|
+
filteredMentions = mentions.filter(
|
|
71
|
+
(tweet) => !tweet.referenced_tweets || !tweet.referenced_tweets.some((ref) => ref.type === 'retweeted')
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Convert to normalized format
|
|
76
|
+
const normalizedPosts: SocialPost[] = filteredMentions.map((tweet) => this.normalizePost(tweet));
|
|
77
|
+
|
|
78
|
+
// Group mentions by type
|
|
79
|
+
const mentionTypes = {
|
|
80
|
+
directMentions: 0,
|
|
81
|
+
replies: 0,
|
|
82
|
+
retweets: 0,
|
|
83
|
+
quotes: 0,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
filteredMentions.forEach((tweet) => {
|
|
87
|
+
if (tweet.referenced_tweets) {
|
|
88
|
+
const refTypes = tweet.referenced_tweets.map((ref) => ref.type);
|
|
89
|
+
if (refTypes.includes('replied_to')) {
|
|
90
|
+
mentionTypes.replies++;
|
|
91
|
+
} else if (refTypes.includes('retweeted')) {
|
|
92
|
+
mentionTypes.retweets++;
|
|
93
|
+
} else if (refTypes.includes('quoted')) {
|
|
94
|
+
mentionTypes.quotes++;
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
mentionTypes.directMentions++;
|
|
159
98
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Calculate engagement statistics
|
|
102
|
+
const stats = {
|
|
103
|
+
totalMentions: normalizedPosts.length,
|
|
104
|
+
mentionTypes,
|
|
105
|
+
totalEngagement: 0,
|
|
106
|
+
averageEngagement: 0,
|
|
107
|
+
topMentions: [] as any[],
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Calculate total engagement
|
|
111
|
+
normalizedPosts.forEach((post) => {
|
|
112
|
+
if (post.analytics) {
|
|
113
|
+
stats.totalEngagement += post.analytics.engagements;
|
|
170
114
|
}
|
|
171
|
-
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Calculate average engagement
|
|
118
|
+
if (normalizedPosts.length > 0) {
|
|
119
|
+
stats.averageEngagement = Math.round(stats.totalEngagement / normalizedPosts.length);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Get top 5 mentions by engagement
|
|
123
|
+
stats.topMentions = normalizedPosts
|
|
124
|
+
.filter((post) => post.analytics)
|
|
125
|
+
.sort((a, b) => (b.analytics?.engagements || 0) - (a.analytics?.engagements || 0))
|
|
126
|
+
.slice(0, 5)
|
|
127
|
+
.map((post) => ({
|
|
128
|
+
id: post.id,
|
|
129
|
+
content: post.content.substring(0, 100) + (post.content.length > 100 ? '...' : ''),
|
|
130
|
+
engagement: post.analytics?.engagements,
|
|
131
|
+
author: filteredMentions.find((t) => t.id === post.id)?.author_id,
|
|
132
|
+
}));
|
|
133
|
+
|
|
134
|
+
// Update output parameters
|
|
135
|
+
const outputParams = [...Params];
|
|
136
|
+
const postsParam = outputParams.find((p) => p.Name === 'Mentions');
|
|
137
|
+
if (postsParam) postsParam.Value = normalizedPosts;
|
|
138
|
+
const tweetsParam = outputParams.find((p) => p.Name === 'Tweets');
|
|
139
|
+
if (tweetsParam) tweetsParam.Value = filteredMentions;
|
|
140
|
+
const statsParam = outputParams.find((p) => p.Name === 'Statistics');
|
|
141
|
+
if (statsParam) statsParam.Value = stats;
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
Success: true,
|
|
145
|
+
ResultCode: 'SUCCESS',
|
|
146
|
+
Message: `Successfully retrieved ${normalizedPosts.length} mentions`,
|
|
147
|
+
Params: outputParams,
|
|
148
|
+
};
|
|
149
|
+
} catch (error) {
|
|
150
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
Success: false,
|
|
154
|
+
ResultCode: this.getErrorCode(error),
|
|
155
|
+
Message: `Failed to get mentions: ${errorMessage}`,
|
|
156
|
+
Params,
|
|
157
|
+
};
|
|
172
158
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
Value: 100
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
Name: 'StartTime',
|
|
187
|
-
Type: 'Input',
|
|
188
|
-
Value: null
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
Name: 'EndTime',
|
|
192
|
-
Type: 'Input',
|
|
193
|
-
Value: null
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
Name: 'SinceID',
|
|
197
|
-
Type: 'Input',
|
|
198
|
-
Value: null
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
Name: 'UntilID',
|
|
202
|
-
Type: 'Input',
|
|
203
|
-
Value: null
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
Name: 'IncludeRetweets',
|
|
207
|
-
Type: 'Input',
|
|
208
|
-
Value: true
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
Name: 'Mentions',
|
|
212
|
-
Type: 'Output',
|
|
213
|
-
Value: null
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
Name: 'Tweets',
|
|
217
|
-
Type: 'Output',
|
|
218
|
-
Value: null
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
Name: 'Statistics',
|
|
222
|
-
Type: 'Output',
|
|
223
|
-
Value: null
|
|
224
|
-
}
|
|
225
|
-
];
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Get action description
|
|
230
|
-
*/
|
|
231
|
-
public get Description(): string {
|
|
232
|
-
return 'Gets tweets that mention the authenticated user on Twitter/X with engagement statistics and filtering options';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get error code based on error type
|
|
163
|
+
*/
|
|
164
|
+
private getErrorCode(error: any): string {
|
|
165
|
+
if (error instanceof Error) {
|
|
166
|
+
if (error.message.includes('Rate Limit')) return 'RATE_LIMIT';
|
|
167
|
+
if (error.message.includes('Unauthorized')) return 'INVALID_TOKEN';
|
|
168
|
+
if (error.message.includes('Forbidden')) return 'INSUFFICIENT_PERMISSIONS';
|
|
233
169
|
}
|
|
234
|
-
|
|
170
|
+
return 'ERROR';
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Define the parameters this action expects
|
|
175
|
+
*/
|
|
176
|
+
public get Params(): ActionParam[] {
|
|
177
|
+
return [
|
|
178
|
+
...this.commonSocialParams,
|
|
179
|
+
{
|
|
180
|
+
Name: 'MaxResults',
|
|
181
|
+
Type: 'Input',
|
|
182
|
+
Value: 100,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
Name: 'StartTime',
|
|
186
|
+
Type: 'Input',
|
|
187
|
+
Value: null,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
Name: 'EndTime',
|
|
191
|
+
Type: 'Input',
|
|
192
|
+
Value: null,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
Name: 'SinceID',
|
|
196
|
+
Type: 'Input',
|
|
197
|
+
Value: null,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
Name: 'UntilID',
|
|
201
|
+
Type: 'Input',
|
|
202
|
+
Value: null,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
Name: 'IncludeRetweets',
|
|
206
|
+
Type: 'Input',
|
|
207
|
+
Value: true,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
Name: 'Mentions',
|
|
211
|
+
Type: 'Output',
|
|
212
|
+
Value: null,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
Name: 'Tweets',
|
|
216
|
+
Type: 'Output',
|
|
217
|
+
Value: null,
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
Name: 'Statistics',
|
|
221
|
+
Type: 'Output',
|
|
222
|
+
Value: null,
|
|
223
|
+
},
|
|
224
|
+
];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Get action description
|
|
229
|
+
*/
|
|
230
|
+
public get Description(): string {
|
|
231
|
+
return 'Gets tweets that mention the authenticated user on Twitter/X with engagement statistics and filtering options';
|
|
232
|
+
}
|
|
233
|
+
}
|