Skip to content

Add mParticle Data Subject Request (DSR) API Integration #2854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 117 commits into from
Jun 26, 2025

Conversation

andresilva-guardian
Copy link
Contributor

@andresilva-guardian andresilva-guardian commented May 28, 2025

What does this change?

Collecting workspace informationWhat does this change?

This PR introduces a new AWS Lambda function, written in TypeScript, that integrates with the mParticle Data Subject Request (DSR) API. The Lambda automates the submission, tracking, and processing of data subject requests (DSRs) to mParticle, supporting The Guardian’s compliance with privacy regulations such as GDPR and CCPA. This new development was made in the context of this Trello ticket. Key features include:

  • Submitting DSRs (access, portability, erasure) to mParticle in OpenDSR format.
  • Querying the status of DSRs by request ID.
  • Processing status callbacks from mParticle and emitting events as required.
  • Setting user attributes to control event forwarding and audience membership during erasure waiting periods.
  • Strong input validation using Zod.
  • Comprehensive unit tests for all endpoints and logic.

How to test

  • Install dependencies:
    Run pnpm install from the root of the repo.

  • Build:
    Run pnpm --filter mparticle-api build to build the Lambda.

  • Run locally:
    Use npm run run-local -- --file=path/to/request.json to invoke the Lambda locally with a test event.

  • Unit tests:
    Run pnpm --filter mparticle-api test to execute all tests for this Lambda.

  • Environment variables:
    Ensure mParticle API credentials and other secrets are available via AWS Secrets Manager in deployed environments, or via a .env file for local development.

  • Manual testing:
    Use example payloads from the runs/ directory and verify API responses for all endpoints.

How can we measure success?

  • All endpoints respond as documented and pass validation.
  • DSRs are successfully submitted to mParticle and can be tracked by request ID.
  • Status callbacks from mParticle are processed and logged correctly.
  • User attributes are set as expected for event forwarding control.
  • All unit and integration tests pass.
  • No validation or runtime errors are observed in logs.
  • The Lambda can be deployed and invoked in both local and AWS environments.

Have we considered potential risks?

  • Incorrect handling of DSRs could result in non-compliance with privacy regulations.
  • Failure to validate input or process callbacks securely could introduce security vulnerabilities.
  • Missing or misconfigured secrets could cause runtime failures.
  • Changes to the mParticle API or callback payloads may require updates to validation logic.
  • Incomplete test coverage could allow regressions to slip through.
  • Errors in setting user attributes could impact downstream event forwarding or audience membership.

All these risks are mitigated by strong input validation, comprehensive testing, and clear error logging as described in the README.

Images

N/A - This is a backend API integration with no visual components.

Accessibility

N/A - This change implements a backend API handler with no user-facing interface elements.

@andresilva-guardian andresilva-guardian changed the title First Draft of the mParticle API function Add mParticle Data Subject Request (DSR) API Integration May 28, 2025
Copilot

This comment was marked as outdated.

@andresilva-guardian andresilva-guardian changed the title Add mParticle Data Subject Request (DSR) API Integration Draft: Add mParticle Data Subject Request (DSR) API Integration May 29, 2025
@andresilva-guardian andresilva-guardian changed the title Draft: Add mParticle Data Subject Request (DSR) API Integration Add mParticle Data Subject Request (DSR) API Integration May 29, 2025
@andresilva-guardian andresilva-guardian marked this pull request as draft May 29, 2025 15:21
@andresilva-guardian andresilva-guardian merged commit 0736a59 into main Jun 26, 2025
53 checks passed
@andresilva-guardian andresilva-guardian deleted the afs-mparticle-api branch June 26, 2025 15:03
@johnduffell
Copy link
Member

this seems to have failed to deploy to PROD
https://riffraff.gutools.co.uk/deployment/view/d8f335a9-093d-4bab-acb2-dd5759628637

@johnduffell
Copy link
Member

the new lambda code needed to be copied to S3 before the CDK could be deployed. I did that and now it's all passed https://riffraff.gutools.co.uk/deployment/view/feffc250-fd05-49a7-a7aa-0a338e18aa59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants