Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/analytics-browser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.33.2-SR-2360.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-browser@2.33.1...@amplitude/analytics-browser@2.33.2-SR-2360.0) (2026-01-21)


### Bug Fixes

* **deps:** bump node-forge from 1.3.1 to 1.3.3 in /packages/analytics-browser/playground/react-spa ([#1438](https://github.com/amplitude/Amplitude-TypeScript/issues/1438)) ([ffacc88](https://github.com/amplitude/Amplitude-TypeScript/commit/ffacc8888217249e6c8084ef7327872e1fa375ca))





## [2.33.1](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-browser@2.33.0...@amplitude/analytics-browser@2.33.1) (2025-12-30)

**Note:** Version bump only for package @amplitude/analytics-browser
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ This SDK is also available through CDN. Copy the script loader below and paste b
<!-- README_SNIPPET_BLOCK -->
```html
<script type="text/javascript">
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},i=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))};!function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})}(e,t,Array.prototype.slice.call(arguments))}},o=function(e){for(var t=0;t<y.length;t++)i(e,y[t],!1);for(var r=0;r<g.length;r++)i(e,g[r],!0)};r.invoked=!0;var a=t.createElement("script");a.type="text/javascript",a.integrity="sha384-93wfcGdaS7s0u7fd3kWnjfrrezg4Xsv/aFEphYSjRyw9ab/ip0w8IYib984l1GL9",a.crossOrigin="anonymous",a.async=!0,a.src="https://cdn.amplitude.com/libs/analytics-browser-2.33.1-min.js.gz",a.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var c=t.getElementsByTagName("script")[0];c.parentNode.insertBefore(a,c);for(var u=function(){return this._q=[],this},p=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],l=0;l<p.length;l++)n(u,p[l]);r.Identify=u;for(var d=function(){return this._q=[],this},f=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],v=0;v<f.length;v++)n(d,f[v]);r.Revenue=d;var y=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];o(r),r.createInstance=function(e){return r._iq[e]={_q:[]},o(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))};!function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})}(e,t,Array.prototype.slice.call(arguments))}},i=function(e){for(var t=0;t<y.length;t++)o(e,y[t],!1);for(var r=0;r<g.length;r++)o(e,g[r],!0)};r.invoked=!0;var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-LP79Rd++WB2A8B/9MCOPyl3HAqn7j1tMh6bHHcyoI3F3FwBXbJGvDGz63oSLg8kB",c.crossOrigin="anonymous",c.async=!0,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.33.2-SR-2360.0-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var a=t.getElementsByTagName("script")[0];a.parentNode.insertBefore(c,a);for(var u=function(){return this._q=[],this},l=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],p=0;p<l.length;p++)n(u,l[p]);r.Identify=u;for(var d=function(){return this._q=[],this},f=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],v=0;v<f.length;v++)n(d,f[v]);r.Revenue=d;var y=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];i(r),r.createInstance=function(e){return r._iq[e]={_q:[]},i(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();

amplitude.init("<YOUR_API_KEY>");
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
s.parentNode.insertBefore(autoTrackingPluginScript, s);
var as = document.createElement('script');
as.type = 'text/javascript';
as.integrity = 'sha384-93wfcGdaS7s0u7fd3kWnjfrrezg4Xsv/aFEphYSjRyw9ab/ip0w8IYib984l1GL9';
as.integrity = 'sha384-LP79Rd++WB2A8B/9MCOPyl3HAqn7j1tMh6bHHcyoI3F3FwBXbJGvDGz63oSLg8kB';
as.crossOrigin = 'anonymous';
as.async = false;
as.src = 'https://cdn.amplitude.com/libs/analytics-browser-2.33.1-min.js.gz';
as.src = 'https://cdn.amplitude.com/libs/analytics-browser-2.33.2-SR-2360.0-min.js.gz';
as.onload = function () {
if (!window.amplitude.runQueuedFunctions) {
console.log('[Amplitude] Error: could not load SDK');
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics-browser/generated/amplitude-gtm-snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
amplitude.invoked = true;
var as = document.createElement('script');
as.type = 'text/javascript';
as.integrity = 'sha384-Hx4CGnrt0yWsjYaDrMbyVdqRb16aMcAKbgcZRkFooF2m8Nhg53ezD2AT1tQWwPeB';
as.integrity = 'sha384-NmfdxU04dzFJSxobCVuuNKDyL23txwa8PPjEhILQQDGxa8ih3TtFY4F/qJtfMv93';
as.crossOrigin = 'anonymous';
as.async = true;
as.src = 'https://cdn.amplitude.com/libs/analytics-browser-gtm-2.33.1-min.js.gz';
as.src = 'https://cdn.amplitude.com/libs/analytics-browser-gtm-2.33.2-SR-2360.0-min.js.gz';
as.onload = function () {
if (!window.amplitudeGTM.runQueuedFunctions) {
console.log('[Amplitude] Error: could not load SDK');
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics-browser/generated/amplitude-snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
amplitude.invoked = true;
var as = document.createElement('script');
as.type = 'text/javascript';
as.integrity = 'sha384-93wfcGdaS7s0u7fd3kWnjfrrezg4Xsv/aFEphYSjRyw9ab/ip0w8IYib984l1GL9';
as.integrity = 'sha384-LP79Rd++WB2A8B/9MCOPyl3HAqn7j1tMh6bHHcyoI3F3FwBXbJGvDGz63oSLg8kB';
as.crossOrigin = 'anonymous';
as.async = true;
as.src = 'https://cdn.amplitude.com/libs/analytics-browser-2.33.1-min.js.gz';
as.src = 'https://cdn.amplitude.com/libs/analytics-browser-2.33.2-SR-2360.0-min.js.gz';
as.onload = function () {
if (!window.amplitude.runQueuedFunctions) {
console.log('[Amplitude] Error: could not load SDK');
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplitude/analytics-browser",
"version": "2.33.1",
"version": "2.33.2-SR-2360.0",
"description": "Official Amplitude SDK for Web",
"keywords": [
"analytics",
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-browser/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '2.33.1';
export const VERSION = '2.33.2-SR-2360.0';
8 changes: 8 additions & 0 deletions packages/analytics-client-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.4.20-SR-2360.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-client-common@2.4.19...@amplitude/analytics-client-common@2.4.20-SR-2360.0) (2026-01-21)

**Note:** Version bump only for package @amplitude/analytics-client-common





## [2.4.19](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-client-common@2.4.18...@amplitude/analytics-client-common@2.4.19) (2025-12-24)

**Note:** Version bump only for package @amplitude/analytics-client-common
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-client-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplitude/analytics-client-common",
"version": "2.4.19",
"version": "2.4.20-SR-2360.0",
"description": "",
"author": "Amplitude Inc",
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
Expand Down
11 changes: 11 additions & 0 deletions packages/analytics-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.36.0-SR-2360.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-core@2.35.0...@amplitude/analytics-core@2.36.0-SR-2360.0) (2026-01-21)


### Features

* **background-capture:** adding background capture injection to autocapture ([267218e](https://github.com/amplitude/Amplitude-TypeScript/commit/267218e960c9451a83e4e750921b77fd93f4f21a))





# [2.35.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-core@2.34.1...@amplitude/analytics-core@2.35.0) (2025-12-24)


Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplitude/analytics-core",
"version": "2.35.0",
"version": "2.36.0-SR-2360.0",
"description": "",
"author": "Amplitude Inc",
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
Expand Down
9 changes: 9 additions & 0 deletions packages/analytics-core/src/types/element-interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ export interface ElementInteractionsOptions {
messenger?: Messenger;
};

/**
* Options for integrating background capture features that rely on a Messenger
* to communicate with an external parent window.
*/
backgroundCaptureOptions?: {
enabled?: boolean;
messenger?: Messenger;
};

/**
* This has been deprecated in favor of rage clicks tracking
* via frustrationInteractions.
Expand Down
8 changes: 8 additions & 0 deletions packages/analytics-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.5.30-SR-2360.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-node@1.5.29...@amplitude/analytics-node@1.5.30-SR-2360.0) (2026-01-21)

**Note:** Version bump only for package @amplitude/analytics-node





## [1.5.29](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-node@1.5.28...@amplitude/analytics-node@1.5.29) (2025-12-24)

**Note:** Version bump only for package @amplitude/analytics-node
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplitude/analytics-node",
"version": "1.5.29",
"version": "1.5.30-SR-2360.0",
"description": "Official Amplitude SDK for NodeJS",
"author": "Amplitude Inc",
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-node/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '1.5.29';
export const VERSION = '1.5.30-SR-2360.0';
8 changes: 8 additions & 0 deletions packages/analytics-react-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.5.33-SR-2360.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-react-native@1.5.32...@amplitude/analytics-react-native@1.5.33-SR-2360.0) (2026-01-21)

**Note:** Version bump only for package @amplitude/analytics-react-native





## [1.5.32](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-react-native@1.5.31...@amplitude/analytics-react-native@1.5.32) (2025-12-24)

**Note:** Version bump only for package @amplitude/analytics-react-native
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplitude/analytics-react-native",
"version": "1.5.32",
"version": "1.5.33-SR-2360.0",
"description": "Official React Native SDK",
"keywords": [
"analytics",
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-react-native/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '1.5.32';
export const VERSION = '1.5.33-SR-2360.0';
11 changes: 11 additions & 0 deletions packages/analytics-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.12.0-SR-2360.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-types@2.11.0...@amplitude/analytics-types@2.12.0-SR-2360.0) (2026-01-21)


### Features

* **background-capture:** adding background capture injection to autocapture ([267218e](https://github.com/amplitude/Amplitude-TypeScript/commit/267218e960c9451a83e4e750921b77fd93f4f21a))





# [2.11.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/analytics-types@2.10.0...@amplitude/analytics-types@2.11.0) (2025-10-23)


Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplitude/analytics-types",
"version": "2.11.0",
"version": "2.12.0-SR-2360.0",
"description": "",
"author": "Amplitude Inc",
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
Expand Down
9 changes: 9 additions & 0 deletions packages/analytics-types/src/element-interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ export interface ElementInteractionsOptions {
messenger?: Messenger;
};

/**
* Options for integrating background capture features that rely on a Messenger
* to communicate with an external parent window.
*/
backgroundCaptureOptions?: {
enabled?: boolean;
messenger?: Messenger;
};

/**
* Debounce time in milliseconds for tracking events.
* This is used to detect rage clicks.
Expand Down
11 changes: 11 additions & 0 deletions packages/gtm-snippet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.33.2-SR-2360.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/gtm-snippet@2.33.1...@amplitude/gtm-snippet@2.33.2-SR-2360.0) (2026-01-21)


### Bug Fixes

* **deps:** bump node-forge from 1.3.1 to 1.3.3 in /packages/analytics-browser/playground/react-spa ([#1438](https://github.com/amplitude/Amplitude-TypeScript/issues/1438)) ([ffacc88](https://github.com/amplitude/Amplitude-TypeScript/commit/ffacc8888217249e6c8084ef7327872e1fa375ca))





## [2.33.1](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/gtm-snippet@2.32.3...@amplitude/gtm-snippet@2.33.1) (2025-12-30)

**Note:** Version bump only for package @amplitude/gtm-snippet
Expand Down
2 changes: 1 addition & 1 deletion packages/gtm-snippet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplitude/gtm-snippet",
"version": "2.33.1",
"version": "2.33.2-SR-2360.0",
"description": "Amplitude JS SDK Wrapper for use with Google Tag Manager",
"publishConfig": {
"access": "public",
Expand Down
17 changes: 17 additions & 0 deletions packages/plugin-autocapture-browser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.19.0-SR-2360.0](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/plugin-autocapture-browser@1.18.3...@amplitude/plugin-autocapture-browser@1.19.0-SR-2360.0) (2026-01-21)


### Bug Fixes

* **plugin-autocapture-browser:** apply rage clicks to window over viewport ([#1459](https://github.com/amplitude/Amplitude-TypeScript/issues/1459)) ([ee71e48](https://github.com/amplitude/Amplitude-TypeScript/commit/ee71e48b81a5c22f236df67ad6aa23c25ce0bffc))
* **plugin-autocapture-browser:** do not trigger rage click when text being highlighted ([#1471](https://github.com/amplitude/Amplitude-TypeScript/issues/1471)) ([7564033](https://github.com/amplitude/Amplitude-TypeScript/commit/7564033a7a4759c49015738fe3ea49ec1475dbe8))


### Features

* **background-capture:** adding background capture injection to autocapture ([267218e](https://github.com/amplitude/Amplitude-TypeScript/commit/267218e960c9451a83e4e750921b77fd93f4f21a))





## [1.18.3](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/plugin-autocapture-browser@1.18.2...@amplitude/plugin-autocapture-browser@1.18.3) (2025-12-24)

**Note:** Version bump only for package @amplitude/plugin-autocapture-browser
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-autocapture-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amplitude/plugin-autocapture-browser",
"version": "1.18.3",
"version": "1.19.0-SR-2360.0",
"description": "",
"author": "Amplitude Inc",
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
Expand Down Expand Up @@ -42,6 +42,7 @@
},
"dependencies": {
"@amplitude/analytics-core": "workspace:*",
"@amplitude/rrweb-snapshot": "2.0.0-alpha.35",
"rxjs": "^7.8.1",
"tslib": "^2.4.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-autocapture-browser/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ iife.output.name = 'amplitudeAutocapturePlugin';
if (process.env.NODE_ENV === 'development') {
iife.output.sourcemap = 'inline';
}
export default [umd, iife];
export default [umd, iife];
14 changes: 13 additions & 1 deletion packages/plugin-autocapture-browser/src/autocapture-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export const autocapturePlugin = (
enabled: true,
messenger: new WindowMessenger(),
},
backgroundCaptureOptions = {
enabled: true,
messenger: new WindowMessenger(),
},
} = options;

options.cssSelectorAllowlist = options.cssSelectorAllowlist ?? DEFAULT_CSS_SELECTOR_ALLOWLIST;
Expand Down Expand Up @@ -294,7 +298,6 @@ export const autocapturePlugin = (

/* istanbul ignore next */
config?.loggerProvider?.log(`${name} has been successfully added.`);

// Setup visual tagging selector
if (window.opener && visualTaggingOptions.enabled) {
const allowlist = (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist;
Expand All @@ -310,6 +313,15 @@ export const autocapturePlugin = (
actionClickAllowlist: actionClickAllowlist,
});
}

// Setup background capture messenger if it is not already setup for visual tagging selector
if (window.opener && backgroundCaptureOptions.enabled && !visualTaggingOptions.messenger) {
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.

backgroundCaptureOptions.messenger isn’t initialized when visualTagging is disabled because visualTaggingOptions.messenger always defaults to a value. Consider basing the check on !visualTaggingOptions.enabled (or whether the messengers differ) so background capture initializes when enabled.

Suggested change
if (window.opener && backgroundCaptureOptions.enabled && !visualTaggingOptions.messenger) {
if (window.opener && backgroundCaptureOptions.enabled && (!visualTaggingOptions.enabled || backgroundCaptureOptions.messenger !== visualTaggingOptions.messenger)) {

🚀 Want me to fix this? Reply ex: "fix it for me".

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.

WindowMessenger.setup adds a window message listener, but nothing removes it. If autocapturePlugin initializes more than once, duplicate listeners accumulate and leak memory. Consider adding a teardown/unsubscribe in WindowMessenger and invoking it from autocapturePlugin.teardown, or ensure the listener is added only once.

🚀 Want me to fix this? Reply ex: "fix it for me".

/* istanbul ignore next */
backgroundCaptureOptions.messenger?.setup({
dataExtractor: dataExtractor,
logger: config?.loggerProvider,
});
}
};

const execute: BrowserEnrichmentPlugin['execute'] = async (event) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-autocapture-browser/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export const AMPLITUDE_ORIGINS_MAP = {

export const AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL =
'https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz';
export const AMPLITUDE_BACKGROUND_CAPTURE_SCRIPT_URL =
'https://cdn.amplitude.com/libs/background-capture-1.0.0-alpha.0.js.gz';
// This is the class name used by the visual tagging selector to highlight the selected element.
// Should not use this class in the selector.
export const AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = 'amp-visual-tagging-selector-highlight';
Expand Down
Loading