Skip to content

Conversation

@daniel-graham-amplitude
Copy link
Collaborator

@daniel-graham-amplitude daniel-graham-amplitude commented Dec 23, 2025

Summary

(if you exclude lockfiles, the lines of code difference is about +300 and -200)

  • Replace "yarn" with "pnpm" for building and package management
  • Replaces "yarn" scripts with "pnpm" scripts in the root and updates all CI workflows to use pnpm

Still to do:

  • Still need to replace other references of yarn with pnpm
  • Still need to upgrade the publish workflow

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No

Note

Migrates the monorepo to pnpm and aligns internal dependencies and typings.

  • CI: update actions to setup-node@v4, add pnpm/action-setup, enable cache: 'pnpm', and swap all yarn commands for pnpm in ci.yml, ci-nx.yml, e2e.yml, docs.yml, and the composite Build and Test action
  • Repo/scripts: replace yarn with pnpm in package scripts and Husky hooks; root packageManager set to pnpm
  • Dependencies: convert many internal package dependencies to workspace:* (e.g., analytics-browser, plugins, node/react-native test pkgs) to ensure consistent linking
  • Typings consolidation: move imports from @amplitude/analytics-types/analytics-client-common to @amplitude/analytics-core; core now exports InstanceProxy; update browser snippet typings and plugin/tests accordingly
  • React Native tests: add transformIgnorePatterns for pnpm hoisting and per-package test tsconfig.json
  • Session Replay: coerce string sessionId to number in targeting evaluation and add tests; type tweak on getDebugConfig; add @amplitude/experiment-core and rrweb-related deps
  • Unified client: export typed setTransport and import TransportTypeOrOptions
  • Misc: add pnpm setup in docs workflow; update GTM/unified packages to include @amplitude/rrweb

Written by Cursor Bugbot for commit add4784. This will update automatically on new commits. Configure here.

Comment on lines 42 to 48
const targetingResult = await evaluateTargetingPackage({
...targetingParams,
flag: targetingConfig,
sessionId: sessionId,
sessionId: typeof sessionId === 'string' ? parseInt(sessionId, 10) : sessionId,
apiKey: apiKey,
loggerProvider: loggerProvider,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

sessionId can become NaN when the input string is non‑numeric, and that NaN is passed to evaluateTargetingPackage. Consider guarding the parse and omit or handle sessionId when it cannot be parsed to avoid evaluating with NaN.

-    const targetingResult = await evaluateTargetingPackage({
-      ...targetingParams,
-      flag: targetingConfig,
-      sessionId: typeof sessionId === 'string' ? parseInt(sessionId, 10) : sessionId,
-      apiKey: apiKey,
-      loggerProvider: loggerProvider,
-    });
+    const parsedSessionId = typeof sessionId === 'string' ? parseInt(sessionId, 10) : sessionId;
+    const targetingResult = await evaluateTargetingPackage({
+      ...targetingParams,
+      flag: targetingConfig,
+      ...(typeof parsedSessionId === 'number' && !Number.isNaN(parsedSessionId) ? { sessionId: parsedSessionId } : {}),
+      apiKey: apiKey,
+      loggerProvider: loggerProvider,
+    });

🚀 Reply to ask Macroscope to explain or update this suggestion.

👍 Helpful? React to give us feedback.

@macroscopeapp
Copy link
Contributor

macroscopeapp bot commented Dec 23, 2025

Migrate repo tooling and CI from Yarn to PNPM and fix SessionReplayTargetingManager.evaluateTargetingAndStore to pass numeric sessionId

Switch all workflows, hooks, and package scripts to pnpm, add pnpm-workspace.yaml and pnpm-lock.yaml, update workspace dependencies to workspace:*, export InstanceProxy from analytics-core, and adjust Jest configs for pnpm module layout; also normalize sessionId to a number in session-replay-browser targeting logic with tests.

🖇️ Linked Issues

This pull request addresses AMP-145286 under the AMP-145285 epic by migrating the repository to PNPM for package management.

📍Where to Start

Start with CI and workspace setup in .github/workflows/ci.yml and workspace config in pnpm-workspace.yaml, then review the targeting fix in packages/session-replay-browser/src/targeting/targeting-manager.ts and its test in packages/session-replay-browser/test/targeting/targeting-manager.test.ts.

Changes since #1443 opened

  • Added pnpm-lock.yaml lockfile for dependency management with PNPM [339b28d]
  • Added actions/cache@v3 caching for **/node_modules directories using **/pnpm-lock.yaml hash as cache key [62e3d69]
  • Upgraded actions/setup-node from v3 to v4 [62e3d69]
  • Added --frozen-lockfile flag to all pnpm install commands across GitHub Actions workflows and composite actions [5b52a7d]
  • Removed explicit node_modules caching steps using actions/cache from GitHub Actions workflows and composite actions, consolidating to use built-in pnpm caching via the cache parameter in actions/setup-node [0c4d0d3]
  • Separated TypeScript configuration in session-replay-browser package by creating a dedicated test configuration and updating the main configuration [70d1782]
  • Changed the nuke script in plugin-session-replay-react-native example to use yarn commands [d041513]
  • Added pnpm-workspace.yaml configuration with security documentation for onlyBuiltDependencies and generated pnpm-lock.yaml [b9de0da]
  • Separated test TypeScript configuration from source configuration in targeting package [b9de0da]
  • Consolidated multiple import statements from @amplitude/analytics-core into a single named import [cdd7000]
  • Added pnpm-lock.yaml as part of migrating the project's package manager from yarn to pnpm [bc5b28f]
  • Updated TypeScript compiler configuration library settings [78400ed]
  • Added explicit type annotations for setTransport using TransportTypeOrOptions from @amplitude/analytics-core in the @amplitude/unified package [a44ab61]
  • Removed idb from the types compiler option across all TypeScript configuration files [a44ab61]
  • Modified npm scripts in the analytics-browser playground React SPA to use yarn commands instead of pnpm commands [add4784]
  • Removed explicit lib configuration from the tsconfig.es5.json TypeScript configuration in session-replay-browser [add4784]
  • Updated TypeScript configuration in session-replay-browser to include test files and restrict library to DOM only [add4784]

Macroscope summarized a552c71.

Copy link
Contributor

@Mercy811 Mercy811 left a comment

Choose a reason for hiding this comment

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

Thanks @daniel-graham-amplitude. LGTM! Merging to a feature branch is a good idea

@daniel-graham-amplitude daniel-graham-amplitude changed the title Amp 145286 use pnpm chore: start migration from Yarn -> PNPM Dec 24, 2025
@daniel-graham-amplitude daniel-graham-amplitude merged commit 4a01050 into pnpm-migration Dec 29, 2025
15 of 18 checks passed
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.

3 participants