Skip to content

Commit 2e9763c

Browse files
committed
Add event delegation for form tracking
- Global event listeners are now used instead of per-element listeners - Event listeners now use the capture phase instead of bubble - Forms added after the initial `enableFormTracking` call should automatically be tracked without needing additional calls - Field value transform functions can now return `null` for all events - Add unit tests for form tracking - The new `targets` parameter allows listening for forms in only a subset of the document tree, or across multiple same-origin documents (e.g. iframes)
1 parent d97797f commit 2e9763c

File tree

8 files changed

+568
-168
lines changed

8 files changed

+568
-168
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@snowplow/browser-plugin-form-tracking",
5+
"comment": "Add event delegation for link click tracking",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/browser-plugin-form-tracking"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@snowplow/javascript-tracker",
5+
"comment": "",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/javascript-tracker"
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
reporters: ['jest-standard-reporter'],
4+
setupFilesAfterEnv: ['../../setupTestGlobals.ts'],
5+
testEnvironment: 'jest-environment-jsdom-global',
6+
};

plugins/browser-plugin-form-tracking/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
"scripts": {
2121
"build": "rollup -c --silent --failAfterWarnings",
22-
"test": ""
22+
"test": "jest"
2323
},
2424
"dependencies": {
2525
"@snowplow/browser-tracker-core": "workspace:*",

0 commit comments

Comments
 (0)