Skip to content

Commit d656d16

Browse files
feat(analytics-browser): remove custom enrichment plugin (#2190)
1 parent 336a81e commit d656d16

31 files changed

Lines changed: 66 additions & 2391 deletions

‎.github/workflows/check-custom-enrichment-imports.yml‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎.github/workflows/publish-custom-enrichment.yml‎

Lines changed: 0 additions & 130 deletions
This file was deleted.

‎.github/workflows/publish-v2.yml‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ jobs:
7474
- name: Verify packages exist on npm
7575
run: pnpm deploy:publish:check-packages
7676

77-
- name: Verify pinned custom enrichment version is already published
78-
run: |
79-
version=$(node -p "require('./packages/analytics-browser/package.json').dependencies['@amplitude/plugin-custom-enrichment-browser']")
80-
bash scripts/publish/verify-custom-enrichment.sh "$version"
81-
8277
e2e:
8378
name: E2E Tests
8479
runs-on: ubuntu-latest
@@ -275,7 +270,6 @@ jobs:
275270
276271
echo "✅ Successfully created release version"
277272
278-
# Custom enrichment is released independently; all SDK packages can go live together.
279273
- name: Publish SDK packages to NPM
280274
run: |
281275
GH_TOKEN=${{ steps.app-token.outputs.token }} pnpm deploy:publish

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ These steps must pass before you submit your PR.
3030

3131
## Publishing
3232

33-
Before preparing or running a release, read [Publishing NPM package for the first time](CONTRIBUTING.md#publishing-npm-package-for-the-first-time) for new package bootstrap, [Publishing SDK packages](CONTRIBUTING.md#publishing-sdk-packages) and, for custom enrichment, [Publishing the custom enrichment browser plugin](CONTRIBUTING.md#publishing-the-custom-enrichment-browser-plugin). These are the repository's maintainer runbooks. Browser must keep an exact published npm pin for custom enrichment; do not replace it with `workspace:*`. The runbook explains the source/version mismatch this prevents and the required Browser adoption PR.
33+
Before preparing or running a release, read [Publishing NPM package for the first time](CONTRIBUTING.md#publishing-npm-package-for-the-first-time) for new package bootstrap and [Publishing SDK packages](CONTRIBUTING.md#publishing-sdk-packages) for the SDK release process.

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -106,46 +106,7 @@ To publish a package for the first time (administrators only):
106106

107107
For a normal stable SDK release, open **GitHub Actions → Publish v2.x → Run workflow**, select `main` (or the intended `hotfix/*` branch), explicitly select `releaseType: release`, leave the optional `branch` input empty, and leave `skipLernaVersion` unchecked. The default release type is `prerelease`, so check this input before dispatching. The workflow requires repository write/admin permission and the configured release environments and credentials.
108108

109-
This workflow validates, versions, and publishes SDK packages. It excludes custom enrichment, which uses the separate procedure below. The first-time bootstrap procedure above is only for a package name that does not yet exist on npm. Do not use it for a new version of an existing package.
110-
111-
#### Publishing the custom enrichment browser plugin
112-
113-
This is the maintainer runbook for `@amplitude/plugin-custom-enrichment-browser`; no Linear ticket or external project document is needed to follow it. Use the existing [Publish custom enrichment workflow](.github/workflows/publish-custom-enrichment.yml), then a separate Browser adoption PR, then [Publish v2.x](.github/workflows/publish-v2.yml).
114-
115-
The plugin's repository manifest is private so Lerna skips its version and dependency updates. Recursive SDK publishing explicitly excludes it. Only the temporary staged artifact has `private` removed. Do not remove `private` from the source manifest or use the generic single-package publisher to bypass this release path.
116-
117-
**One-time prerequisites:** the plugin is declared as dual-use, and its npm Trusted Publisher must use `.github/workflows/publish-custom-enrichment.yml`, **stage-only** permission, and the `npm-release` environment. The workflow uses the existing release GitHub App in `npm-release` for protected-branch writes. An npm maintainer with 2FA must approve each new staged version. These settings require the appropriate npm/GitHub permissions; local build success does not establish that they are configured.
118-
119-
1. **Prepare and merge the plugin changes.** Update the plugin source and tests, and optionally add reviewed changelog notes for the intended stable version in `packages/plugin-custom-enrichment-browser/CHANGELOG.md`. Merge to `main` or the intended `hotfix/*` branch. Keep Browser's plugin dependency at its previous published version. The plugin's version is not bumped by routine Lerna releases; the independent workflow sets it in step 2. Review any changes to its `analytics-core` peer range rather than automatically widening it.
120-
121-
2. **Release, stage, approve, and verify the plugin.** In GitHub Actions, run **Publish custom enrichment** from that branch and enter the exact stable version to release. The workflow updates only the plugin version and changelog, preserving reviewed notes for that version or generating notes from plugin commits. It builds, tests, and lints the plugin and its workspace dependencies using pnpm 11 on Node 24, pushes a `chore(release): publish` commit and package-specific tag together, stages the plugin, and creates a GitHub Release using those changelog notes. Follow the workflow summary to npmjs.com's **Staged Packages** tab, where an npm maintainer reviews the staged package and approves it with 2FA. No further GitHub Actions confirmation is required. Confirm the version is live on the npm package page linked in the summary, or with `pnpm view @amplitude/plugin-custom-enrichment-browser@<version> version`, replacing `<version>` with the intended version. Staging success is not publication success; continue only when npm returns the intended version.
122-
123-
3. **Manually create and merge the Browser adoption PR.** After npm publication, update `dependencies["@amplitude/plugin-custom-enrichment-browser"]` in `packages/analytics-browser/package.json` to that exact published version, for example `"1.0.0"`. Do not use `workspace:*`, `^1.0.0`, or `~1.0.0`. Run `pnpm install` from the repository root, review and commit `pnpm-lock.yaml`, and verify a frozen-lockfile install succeeds. Replace any plugin changelog `pending publication` label with the actual npm publication date. Validate Browser-only installation, direct-plugin installation with compatible core, TypeScript resolution, and the repository checks before merging. This PR changes Browser's dependency on the plugin; it does not manually bump Browser's own version. Repeat this adoption step whenever Browser should consume a newer plugin release.
124-
125-
4. **Publish Browser with Publish v2.x.** After the adoption PR merges, follow the normal stable SDK release instructions above. Publish v2 checks that Browser's pinned plugin version exists on npm, then versions and publishes SDK packages while excluding custom enrichment. Verify that the resulting Browser package declares the intended exact plugin dependency. If the plugin is still staged, finish npm approval and verification before retrying; do not bypass the check. Publishing Browser first can make consumer installations fail because its dependency is unavailable.
126-
127-
Browser may continue releasing with its previous published plugin pin while a newer plugin version is pending. Publishing a plugin and adopting it in Browser are separate decisions; a plugin release does not automatically update Browser.
128-
129-
##### Why Browser uses an exact npm pin instead of `workspace:*`
130-
131-
The manual adoption PR is an intentional boundary between published plugin code and ongoing plugin development. Consider this example:
132-
133-
- Plugin `1.0.0` containing **code A** is published on npm.
134-
- Someone changes the repository's plugin source to **code B**, but its package.json still says `1.0.0`.
135-
- With `workspace:*`, Browser builds against the local workspace plugin, so code B can enter its browser bundle.
136-
- pnpm converts `workspace:*` to the local version number when packing Browser. The published manifest would still declare `1.0.0`, which resolves to code A on npm, even though the bundle may contain code B.
137-
138-
Checking that npm has `1.0.0` does not catch this mismatch: it checks availability, not equality between workspace source and the published artifact. Approving a staged package later does not repair a Browser bundle that has already shipped.
139-
140-
With an exact npm pin and the committed lockfile, the repository's normal dependency installation resolves Browser's plugin from the published npm artifact. Unreleased workspace plugin edits do not automatically become Browser's dependency. The follow-up PR selects the published version and provides a review and compatibility check before Browser adopts it. Do not replace this pin with a workspace dependency as a convenience refactor, or use local links/overrides in release validation that bypass it. This restriction concerns Browser's dependency on the plugin; the plugin may still use workspace core as a development dependency.
141-
142-
##### Compatibility, release records, and retries
143-
144-
Plugin 1.0.0 was published on 2026-10-21. It deliberately introduced a breaking dependency change for direct plugin consumers: they must declare compatible `@amplitude/analytics-core` themselves. Browser-only consumers do not need a separate core declaration because Browser supplies it. The stable peer range `^2.61.0` does not cover arbitrary core prereleases; review those separately before an SDK prerelease. See the [plugin README](packages/plugin-custom-enrichment-browser/README.md) for consumer installation instructions.
145-
146-
The independent workflow currently releases stable versions only. It creates the plugin's version/changelog update, release commit, package-specific Git tag, and GitHub Release without running Lerna or publishing other SDK packages. Plugin 1.0.0 predates this automation: it was published from `e0866041ef2ff19209d619c1a43116c27eaa6fc6`, and its publication date is recorded in the plugin changelog. Any separate historical tag or GitHub Release for 1.0.0 must reference that actual published source commit.
147-
148-
Retry with the same version to reuse the workflow-created release commit and tag; a completed release is not recreated. If only the GitHub Release job fails, use **Re-run failed jobs** to retry it without staging again. If staging succeeded but its result was interrupted, approve the existing stage on npm before retrying the same version. A version already on npm without a matching workflow-created tag is rejected rather than attaching it to unrelated source. A concurrent branch update stops the push without overwriting other work. For changed plugin code, prepare a new version; rerunning an already-published version does not publish those changes. Keep the type-only core import CI guard: this peer-dependency arrangement does not itself reduce the bundle or guarantee one core instance across every application dependency graph.
109+
This workflow validates, versions, and publishes SDK packages. The first-time bootstrap procedure above is only for a package name that does not yet exist on npm. Do not use it for a new version of an existing package.
149110

150111
#### Recovering a partial `publish-v2` workflow run
151112

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"clean": "lerna run clean --stream && rimraf node_modules docs",
1313
"deploy:version": "lerna version",
1414
"deploy:version:dry-run": "DRY_RUN=true lerna version --no-push --no-git-tag-version --allow-branch \"$(git rev-parse --abbrev-ref HEAD)\" --conventional-prerelease --no-changelog --no-push --no-git-tag-version",
15-
"deploy:publish": "pnpm -r --filter \"./packages/**\" --filter \"!@amplitude/plugin-custom-enrichment-browser\" publish --no-git-checks",
15+
"deploy:publish": "pnpm -r --filter \"./packages/**\" publish --no-git-checks",
1616
"deploy:publish:check-packages": "node ./scripts/publish/check-npm-packages-published.js",
17-
"deploy:publish:dry-run": "DRY_RUN=true pnpm -r --filter \"./packages/**\" --filter \"!@amplitude/plugin-custom-enrichment-browser\" publish --dry-run --no-git-checks",
17+
"deploy:publish:dry-run": "DRY_RUN=true pnpm -r --filter \"./packages/**\" publish --dry-run --no-git-checks",
1818
"deploy:pack": "DRY_RUN=true pnpm -r --filter \"./packages/**\" pack",
1919
"deploy:publish:bootstrap": "bash ./scripts/publish/bootstrap-npm-package.sh",
2020
"dev": "concurrently \"pnpm run watch\" \"vite dev --open\"",

‎packages/analytics-browser/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
"dependencies": {
7373
"@amplitude/analytics-core": "workspace:*",
7474
"@amplitude/plugin-autocapture-browser": "workspace:*",
75-
"@amplitude/plugin-custom-enrichment-browser": "1.0.0",
7675
"@amplitude/plugin-event-property-attribution-browser": "workspace:*",
7776
"@amplitude/plugin-network-capture-browser": "workspace:*",
7877
"@amplitude/plugin-page-url-enrichment-browser": "workspace:*",

‎packages/analytics-browser/src/browser-client.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import { eventPropertyTrackingPlugin } from '@amplitude/plugin-event-property-at
4747
import { LIBPREFIX } from './lib-prefix';
4848
import { VERSION } from './version';
4949
import { pageUrlEnrichmentPlugin } from '@amplitude/plugin-page-url-enrichment-browser';
50-
import { customEnrichmentPlugin } from '@amplitude/plugin-custom-enrichment-browser';
5150
import { isEventPropertyAttributionEnabled, isUserPropertyAttributionEnabled } from './attribution/tracking-methods';
5251
import { AmplitudeBrowserLite, AutocaptureAdapter } from './browser-client-lite';
5352

@@ -148,8 +147,9 @@ export class AmplitudeBrowser extends AmplitudeBrowserLite implements BrowserCli
148147
}
149148

150149
if (isCustomEnrichmentEnabled(this.config.customEnrichment)) {
151-
this.config.loggerProvider.debug('Adding custom enrichment plugin');
152-
await this.add(customEnrichmentPlugin()).promise;
150+
this.config.loggerProvider.warn(
151+
'The custom enrichment plugin has been removed from the Amplitude Browser SDK. The "customEnrichment" option will take no effect.',
152+
);
153153
}
154154
},
155155

0 commit comments

Comments
 (0)