Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

feat(campaigns): add linkedin ad accounts and set default#911

Open
mrautela365 wants to merge 1 commit into
mainfrom
feat/LFXV2-2023-linkedin-accounts
Open

feat(campaigns): add linkedin ad accounts and set default#911
mrautela365 wants to merge 1 commit into
mainfrom
feat/LFXV2-2023-linkedin-accounts

Conversation

@mrautela365

@mrautela365 mrautela365 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add 9 new LinkedIn ad accounts to server constants (CNCF, LF Education, Agentic AI Foundation, OpenSearch Project x2, LF's Ad Account x2, OpenJS Foundation, OpenSSF)
  • Set LF Events (509430019) as the default LinkedIn ad account — env var LINKEDIN_AD_ACCOUNT_ID overrides when set

JIRA

LFXV2-2180 — child of LFXV2-2023

Files changed

  • apps/lfx-one/src/server/constants/linkedin.constants.ts — added accounts + default constants
  • apps/lfx-one/src/server/services/linkedin-ads.service.ts — use default fallback for account/org ID

🤖 Generated with Claude Code

@mrautela365 mrautela365 requested a review from a team as a code owner June 9, 2026 20:52
Copilot AI review requested due to automatic review settings June 9, 2026 20:52
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

LinkedIn Ads defaults and account list are added; the Ads service now reads optional env variables and falls back to the new defaults, auto-resolving org IDs from the expanded account list when a non-default account is selected.

Changes

LinkedIn default account/org fallback

Layer / File(s) Summary
LinkedIn default account constants
apps/lfx-one/src/server/constants/linkedin.constants.ts
Two new exported constants LINKEDIN_DEFAULT_ACCOUNT_ID and LINKEDIN_DEFAULT_ORG_ID are added and LINKEDIN_ACCOUNTS is expanded with additional ad-account entries.
Service fallback to default account/org
apps/lfx-one/src/server/services/linkedin-ads.service.ts
Import updated to include the new defaults and accounts list. getAccountId() now returns LINKEDIN_AD_ACCOUNT_ID or falls back to LINKEDIN_DEFAULT_ACCOUNT_ID. getOrgId() returns LINKEDIN_ORG_ID or auto-resolves the org from LINKEDIN_ACCOUNTS for non-default accounts, otherwise falls back to LINKEDIN_DEFAULT_ORG_ID (logs a warning if resolution fails).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding LinkedIn ad accounts and setting a default account.
Description check ✅ Passed The description is directly related to the changeset, detailing the 9 new accounts added and default account configuration with environment variable override.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/LFXV2-2023-linkedin-accounts

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional server-side LinkedIn ad account metadata and introduces a default ad account/org fallback so the LinkedIn ads service can run without requiring LINKEDIN_AD_ACCOUNT_ID / LINKEDIN_ORG_ID to be set.

Changes:

  • Added default LinkedIn ad account + org IDs, and expanded the server-side list of supported LinkedIn ad accounts.
  • Updated LinkedIn ads service to use defaults when LINKEDIN_AD_ACCOUNT_ID / LINKEDIN_ORG_ID are not provided via environment.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apps/lfx-one/src/server/constants/linkedin.constants.ts Adds default account/org constants and expands the server-side LinkedIn ad accounts list.
apps/lfx-one/src/server/services/linkedin-ads.service.ts Uses default account/org IDs when env vars are not set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/lfx-one/src/server/services/linkedin-ads.service.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/lfx-one/src/server/services/linkedin-ads.service.ts (1)

40-46: ⚡ Quick win

Add logging to indicate when defaults vs environment variables are used.

The fallback to default account/org IDs is a significant behavioral change from the previous required-env-var pattern (via getLinkedInEnv). Without logging, operators cannot easily determine which account is being used in a given deployment, making debugging and auditing difficult.

🔍 Proposed fix to add observability
 function getAccountId(): string {
-  return process.env['LINKEDIN_AD_ACCOUNT_ID'] || LINKEDIN_DEFAULT_ACCOUNT_ID;
+  const envValue = process.env['LINKEDIN_AD_ACCOUNT_ID'];
+  if (envValue) {
+    logger.debug(undefined, 'linkedin_config', `Using LinkedIn account ID from env: ${envValue}`);
+    return envValue;
+  }
+  logger.debug(undefined, 'linkedin_config', `Using default LinkedIn account ID: ${LINKEDIN_DEFAULT_ACCOUNT_ID}`);
+  return LINKEDIN_DEFAULT_ACCOUNT_ID;
 }

 function getOrgId(): string {
-  return process.env['LINKEDIN_ORG_ID'] || LINKEDIN_DEFAULT_ORG_ID;
+  const envValue = process.env['LINKEDIN_ORG_ID'];
+  if (envValue) {
+    logger.debug(undefined, 'linkedin_config', `Using LinkedIn org ID from env: ${envValue}`);
+    return envValue;
+  }
+  logger.debug(undefined, 'linkedin_config', `Using default LinkedIn org ID: ${LINKEDIN_DEFAULT_ORG_ID}`);
+  return LINKEDIN_DEFAULT_ORG_ID;
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/lfx-one/src/server/services/linkedin-ads.service.ts` around lines 40 -
46, Update getAccountId and getOrgId to log which source (env var vs default)
and the actual ID chosen so operators can see when fallbacks are used; read
process.env['LINKEDIN_AD_ACCOUNT_ID'] / process.env['LINKEDIN_ORG_ID'], choose
the value as now, and call the module's logger (e.g., processLogger or the
file's existing logger) to emit an info-level message like "Using LinkedIn
account ID from ENV" vs "Using default LinkedIn account ID" including the chosen
ID; ensure both functions log before returning the ID.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/lfx-one/src/server/services/linkedin-ads.service.ts`:
- Around line 40-46: Update getAccountId and getOrgId to log which source (env
var vs default) and the actual ID chosen so operators can see when fallbacks are
used; read process.env['LINKEDIN_AD_ACCOUNT_ID'] /
process.env['LINKEDIN_ORG_ID'], choose the value as now, and call the module's
logger (e.g., processLogger or the file's existing logger) to emit an info-level
message like "Using LinkedIn account ID from ENV" vs "Using default LinkedIn
account ID" including the chosen ID; ensure both functions log before returning
the ID.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1731a390-bb91-4d91-bcd5-3ac6f1f874f2

📥 Commits

Reviewing files that changed from the base of the PR and between 63654d7 and b6471fb.

📒 Files selected for processing (2)
  • apps/lfx-one/src/server/constants/linkedin.constants.ts
  • apps/lfx-one/src/server/services/linkedin-ads.service.ts

mrautela365 added a commit that referenced this pull request Jun 9, 2026
Address review comments from copilot-pull-request-reviewer,
coderabbitai[bot]:

- linkedin-ads.service.ts: auto-resolve org ID from
  LINKEDIN_ACCOUNTS when ad account is overridden via env var,
  preventing account/org mismatch (per Copilot)
- linkedin-ads.service.ts: add debug logging to getAccountId()
  and getOrgId() for deployment observability (per CodeRabbit)

LFXV2-2180

Resolves 1 review thread.

Signed-off-by: Misha Rautela <mrautela@linuxfoundation.org>
@mrautela365

Copy link
Copy Markdown
Contributor Author

Review Feedback Addressed

Commit: c84e56e

Changes Made

  • linkedin-ads.service.ts: getOrgId() now auto-resolves org ID from LINKEDIN_ACCOUNTS when a non-default ad account is set via env var — prevents silent account/org mismatch that could cause 4xx errors on dark post creation (per Copilot)
  • linkedin-ads.service.ts: Added debug logging to getAccountId() and getOrgId() so operators can see which source (env var / default / auto-resolved) and value is active (per coderabbitai[bot])

Threads Resolved

1 of 1 unresolved threads addressed. CodeRabbit nitpick also addressed in the same commit.

Copilot AI review requested due to automatic review settings June 10, 2026 00:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@dealako dealako added the do-not-merge Indicates that the pull request should NOT be merged. label Jun 10, 2026
mrautela365 added a commit that referenced this pull request Jun 10, 2026
Address review comments from copilot-pull-request-reviewer,
coderabbitai[bot]:

- linkedin-ads.service.ts: auto-resolve org ID from
  LINKEDIN_ACCOUNTS when ad account is overridden via env var,
  preventing account/org mismatch (per Copilot)
- linkedin-ads.service.ts: add debug logging to getAccountId()
  and getOrgId() for deployment observability (per CodeRabbit)

LFXV2-2180

Resolves 1 review thread.

Signed-off-by: Misha Rautela <mrautela@linuxfoundation.org>
@mrautela365 mrautela365 force-pushed the feat/LFXV2-2023-linkedin-accounts branch from 5e9e549 to 25777da Compare June 10, 2026 05:11
Copilot AI review requested due to automatic review settings June 10, 2026 07:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread apps/lfx-one/src/server/services/linkedin-ads.service.ts Outdated
Comment thread apps/lfx-one/src/server/services/linkedin-ads.service.ts Outdated
@mrautela365

Copy link
Copy Markdown
Contributor Author

Review Feedback Addressed

No Change Needed

  • linkedin-ads.service.ts: getAccountId() already uses direct process.env checks with logger.debug fallback — no exception-driven flow (flagged by copilot[bot])
  • linkedin-ads.service.ts:58-72: getOrgId() already uses direct env checks; WARNING only fires for the genuinely suspicious case (non-default account not found in configured accounts list) (flagged by copilot[bot])

Threads Resolved

2 of 2 unresolved threads addressed — both were based on a stale view of the code; the current implementation already follows the suggested patterns.

mrautela365 added a commit that referenced this pull request Jun 10, 2026
Address review comments from copilot-pull-request-reviewer,
coderabbitai[bot]:

- linkedin-ads.service.ts: auto-resolve org ID from
  LINKEDIN_ACCOUNTS when ad account is overridden via env var,
  preventing account/org mismatch (per Copilot)
- linkedin-ads.service.ts: add debug logging to getAccountId()
  and getOrgId() for deployment observability (per CodeRabbit)

LFXV2-2180

Resolves 1 review thread.

Signed-off-by: Misha Rautela <mrautela@linuxfoundation.org>
@mrautela365 mrautela365 force-pushed the feat/LFXV2-2023-linkedin-accounts branch from 0dd9959 to 1adedca Compare June 10, 2026 15:07
Copilot AI review requested due to automatic review settings June 10, 2026 15:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@MRashad26 MRashad26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review + code-standards-enforcer audit (report-only). ⚠️ Note this PR carries the do-not-merge label — review only.

🔒 Secrets / sensitive-data check (requested)

No secrets exposed. No credentials, tokens, or keys are added in this diff. The LinkedIn access token remains env-sourced via getAccessToken()getLinkedInEnv('LINKEDIN_ACCESS_TOKEN') (untouched). The added values are ad-account IDs and org IDs — non-credential identifiers (org IDs are public LinkedIn company URNs; account IDs are inert without the access token). They are correctly placed in the server-only linkedin.constants.ts, whose header states they "must NOT ship to the client bundle" — so they stay out of the browser bundle. They are now committed to a public repo, which is acceptable since none are secrets.

Overview

Adds 9 LinkedIn ad accounts to LINKEDIN_ACCOUNTS, introduces LINKEDIN_DEFAULT_ACCOUNT_ID/LINKEDIN_DEFAULT_ORG_ID (LF Events / 208777), and changes getAccountId()/getOrgId() from throw-on-missing-env to default-with-fallback, auto-resolving org from account when overridden.

Code Standards Audit

  • 🔴 Critical: none
  • 🟡 Warning: none
  • 🔵 Info: local LinkedInAdAccountConfig interface vs the "interfaces live in @lfx-one/shared" rule (inline — with the server-only nuance); account/org mismatch on unknown-account override now proceeds with only a warn (inline); LINKEDIN_DEFAULT_ORG_ID duplicates the default account's orgId (inline); PR body has the 🤖 Generated with [Claude Code] footer (commits themselves are clean — signed-off, no AI co-author ✅); no ## Test plan section ✅.
  • ✅ Correctly followed: server-only constants kept out of shared/client per the file's documented architecture, MIT header, logger.warning/logger.debug (no console.log), all lines ≤160, signed-off commits.

Test coverage

No tests added. getOrgId() now has a real resolution matrix (env set / known account / unknown account / default) but the functions are module-private, so they aren't directly testable without export. If this logic is worth locking down, consider exporting a small resolveLinkedInOrg(accountId, env) helper and unit-testing the four branches.

Verdict: PASS (code) — gated by the do-not-merge label.

Comment thread apps/lfx-one/src/server/services/linkedin-ads.service.ts Outdated
Comment thread apps/lfx-one/src/server/constants/linkedin.constants.ts Outdated
Comment thread apps/lfx-one/src/server/constants/linkedin.constants.ts Outdated
Add 9 LinkedIn ad accounts (CNCF, LF Education, Agentic AI Foundation,
OpenSearch x2, OpenJS x2, LF Agentic AI, OpenSSF) to both shared and
server-side account lists.

Set LF Events (509430019) as default account when LINKEDIN_AD_ACCOUNT_ID
env var is not set. Derive LINKEDIN_DEFAULT_ORG_ID from the account
lookup to avoid drift. Update resolveOrgId to check env var override,
then shared accounts, then server accounts, then default.

Addresses review feedback:
- Fail-fast on unknown override (Rashad)
- Derive default org from account lookup instead of hardcoding (Rashad)
- Keep interface in shared package per convention (Rashad)

Signed-off-by: Misha Rautela <mrautela@linuxfoundation.org>
@mrautela365 mrautela365 force-pushed the feat/LFXV2-2023-linkedin-accounts branch from 1adedca to 7e75593 Compare June 10, 2026 17:32
@mrautela365

Copy link
Copy Markdown
Contributor Author

Review Feedback Addressed

Commit: 7e75593

Rebased on main (post #902 + #917 merges) and addressed all 3 review comments.

Changes Made

  • linkedin-ads.service.ts: resolveAccountId now falls back to LINKEDIN_DEFAULT_ACCOUNT_ID when env var is unset (with debug log), but still throws on unknown overrides (fail-fast per @MRashad26). resolveOrgId updated to chain: env var → shared accounts → server accounts → default org — no account/org mismatch possible.
  • linkedin.constants.ts: LINKEDIN_DEFAULT_ORG_ID now derived from account lookup (LINKEDIN_ACCOUNTS.find(...)!.orgId) — single source of truth, no drift risk. Removed local LinkedInAdAccountConfig interface — uses inline type matching the original on main.
  • campaign.constants.ts (shared): Added 5 new accounts (CNCF, LF Education, Agentic AI, OpenSearch x2, OpenJS x2, OpenSSF). Changed default to LF Events (509430019).

Threads Resolved

3 of 3 unresolved threads addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Indicates that the pull request should NOT be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants