Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: fix X

Nevo David60ffa4df2277
diff --git a/libraries/nestjs-libraries/src/integrations/social/linkedin.page.provider.ts b/libraries/nestjs-libraries/src/integrations/social/linkedin.page.provider.ts
index 03de1f9c7..36bbdce5b 100644
--- a/libraries/nestjs-libraries/src/integrations/social/linkedin.page.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/linkedin.page.provider.ts
@@ -446,13 +446,12 @@ export class LinkedinPageProvider
postId: string,
date: number
): Promise<AnalyticsData[]> {
- const endDate = dayjs().unix() * 1000;
- const startDate = dayjs().subtract(date, 'days').unix() * 1000;
-
- // Fetch share statistics for the specific post
+ // Fetch lifetime share statistics for the specific post.
+ // LinkedIn does not support time-bound statistics for specific share queries,
+ // so no timeIntervals is sent and elements come back without a timeRange.
const shareStatsUrl = `https://api.linkedin.com/v2/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=${encodeURIComponent(
`urn:li:organization:${integrationId}`
- )}&shares=List(${encodeURIComponent(postId)})&timeIntervals=(timeRange:(start:${startDate},end:${endDate}),timeGranularityType:DAY)`;
+ )}&shares=List(${encodeURIComponent(postId)})`;
const { elements: shareElements }: { elements: PostShareStatElement[] } =
await (
@@ -488,7 +487,7 @@ export class LinkedinPageProvider
const analytics = (shareElements || []).reduce(
(all, current) => {
if (typeof current?.totalShareStatistics !== 'undefined') {
- const dateStr = dayjs(current.timeRange.start).format('YYYY-MM-DD');
+ const dateStr = dayjs(current.timeRange?.start).format('YYYY-MM-DD');
all['Impressions'].push({
total: current.totalShareStatistics.impressionCount || 0,
@@ -927,7 +926,7 @@ export interface PostShareStatElement {
impressionCount: number;
commentCount: number;
};
- timeRange: TimeRange;
+ timeRange?: TimeRange;
}
export interface SocialActionsResponse {
diff --git a/libraries/nestjs-libraries/src/integrations/social/x.provider.ts b/libraries/nestjs-libraries/src/integrations/social/x.provider.ts
index 080262d86..51512fbdf 100644
--- a/libraries/nestjs-libraries/src/integrations/social/x.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/x.provider.ts
@@ -1405,9 +1405,11 @@ export class XProvider extends SocialAbstract implements SocialProvider {
...(token ? { pagination_token: token } : {}),
});
+ const list = tweets.data.data || [];
+
return [
- ...tweets.data.data,
- ...(tweets.data.data.length === 100
+ ...list,
+ ...(list.length === 100 && tweets.meta.next_token
? await this.loadAllTweets(
client,
id,