Skip to content

[ms-bing-ads-audiences] Add temporary debug logging of API responses#3877

Open
harsh-joshi99 wants to merge 4 commits into
mainfrom
slim/ms-bing-ads-audiences-debug-logging
Open

[ms-bing-ads-audiences] Add temporary debug logging of API responses#3877
harsh-joshi99 wants to merge 4 commits into
mainfrom
slim/ms-bing-ads-audiences-debug-logging

Conversation

@harsh-joshi99

Copy link
Copy Markdown
Contributor

Summary

Non-bulk destinations don't persist the responses received from the destination, which makes debugging the MS Bing Ads Audiences sync difficult — in particular, getting Microsoft's tracking/request id needed to raise Bing Ads support tickets.

This PR adds temporary debug logging, gated behind the actions-ms-bing-ads-audiences-debug-logging feature flag (off by default). It logs only successful responses from each CustomerListUserData/Apply call:

  • Microsoft's tracking id (from the TrackingId / x-ms-trackingid response header, or a top-level body TrackingId) — for quoting to Bing Ads support
  • non-sensitive request metadata: action (Add/Remove), audience id, identifier type, item count — not the CustomerListItems
  • a redacted PartialErrors summary (ErrorCode / Code / Index / Type only)

This is a deliberately lean alternative to #3836.

Safety

  • No PII. CustomerListItems (hashed emails / unhashed CRM ids) are never logged, and the PartialError free-text fields (Message / Details / FieldPath) — which can echo back an identifier — are dropped.
  • No behavior change. Logging is a no-op unless the flag is enabled; the error path (auth, 5xx) flows through handleHttpError unchanged. The whole log line is capped at 4096 chars.

Intended to be removed once debugging is complete — every added block is marked // TEMPORARY.

Flagon: https://flagon.segment.com/families/centrifuge-destinations/gates/actions-ms-bing-ads-audiences-debug-logging

Testing

  • Unit tests pass (npx jest src/destinations/ms-bing-ads-audiences)
  • Typechecks and lints clean
  • Added tests: flag on/off, tracking id from header + body, PII redaction, error path logs nothing

Security Review

  • Reviewed all field definitions for sensitive data — no field definitions changed.

🤖 Generated with Claude Code

Non-bulk destinations don't persist responses from the destination, which
makes debugging the MS Bing Ads Audiences sync difficult — in particular
getting Microsoft's tracking id needed to raise Bing Ads support tickets.

Adds temporary debug logging gated behind the
'actions-ms-bing-ads-audiences-debug-logging' feature flag (off by default).
Logs only successful responses: Microsoft's tracking id (from response header
or body), non-sensitive request metadata (action, audience id, identifier
type, item count) and a redacted PartialErrors summary (codes/index only).

No PII: CustomerListItems (hashed emails / unhashed CRM ids) and the
PartialError free-text fields (Message/Details/FieldPath) are never logged.
No behavior change: logging is a no-op unless the flag is on, and the error
path flows through handleHttpError unchanged. Marked TEMPORARY for removal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@harsh-joshi99
harsh-joshi99 requested a review from a team as a code owner July 14, 2026 08:57
Copilot AI review requested due to automatic review settings July 14, 2026 08:57

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

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds feature-flagged, temporary debug logging for MS Bing Ads Audiences CustomerListUserData/Apply responses to help capture Microsoft tracking/request IDs for support/debugging without logging PII.

Changes:

  • Gate debug logging behind actions-ms-bing-ads-audiences-debug-logging and include trackingId, request metadata, and redacted PartialErrors summary.
  • Thread features + logger through perform/performBatch into syncUser to enable conditional logging.
  • Add unit tests covering flag on/off, tracking id extraction (header/body), redaction, and no logging on error path.

Reviewed changes

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

File Description
packages/destination-actions/src/destinations/ms-bing-ads-audiences/syncAudiences/index.ts Adds gated debug logging utilities and emits redacted logs on successful Apply calls.
packages/destination-actions/src/destinations/ms-bing-ads-audiences/syncAudiences/tests/index.test.ts Adds test coverage for the new debug logging behavior and safety constraints.

harsh-joshi99 and others added 2 commits July 14, 2026 15:55
logBingAdsResponse runs inside syncUser's try/catch after Bing has already
accepted the records. A throwing or partial logger would be caught and
rethrown — failing an otherwise-successful (batch) delivery and triggering a
duplicate re-send on retry. Wrap the log body in its own try/catch so
best-effort debug logging can never alter delivery semantics. Adds a test
asserting a throwing logger.info still returns 200.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 14, 2026 12:53

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 on lines +73 to +80
const logBingAdsResponse = (
logger: Logger | undefined,
debugLogging: boolean,
action: string,
audienceId: string,
sentPayload: SyncAudiencePayload,
response: ModifiedResponse
): void => {
Comment on lines +86 to +91
const { CustomerListItemSubType, CustomerListItems } = sentPayload.CustomerListUserData
const partialErrors = (response.data as { PartialErrors?: PartialError[] } | undefined)?.PartialErrors
const line =
`[ms-bing-ads-audiences][DEBUG] ${action} audienceId=${audienceId} status=${response.status} ` +
`trackingId=${extractTrackingId(response)} identifierType=${CustomerListItemSubType} ` +
`itemCount=${CustomerListItems.length} partialErrors=${summarizeErrors(partialErrors)}`
…Grafana

The delivery runtime's logger filters out info-level lines, so logger.info
was accepted but never shipped to the log pipeline — the debug output never
appeared in Grafana despite the flag being on and performBatch running.
Switch to logger?.warn?.() (warn is the lowest level that reliably ships,
matching hubspot/aws-kinesis) and use the optional-call idiom so a partial
logger no-ops rather than throwing. Tests updated to assert on warn.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 15, 2026 18:29

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 on lines +60 to +65
const extractTrackingId = (response: ModifiedResponse): string => {
const header = response.headers?.get('trackingid') || response.headers?.get('x-ms-trackingid')
if (header) return header
const body = response.data as { TrackingId?: string } | undefined
return body?.TrackingId || 'none'
}
Comment on lines +73 to +80
const logBingAdsResponse = (
logger: Logger | undefined,
debugLogging: boolean,
action: string,
audienceId: string,
sentPayload: SyncAudiencePayload,
response: ModifiedResponse
): void => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants