@amplitude/plugin-autocapture-browser 1.27.4 → 1.28.0-featelement-selector-v1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/autocapture-plugin.d.ts.map +1 -1
- package/lib/cjs/autocapture-plugin.js +66 -2
- package/lib/cjs/autocapture-plugin.js.map +1 -1
- package/lib/cjs/data-extractor.d.ts +21 -0
- package/lib/cjs/data-extractor.d.ts.map +1 -1
- package/lib/cjs/data-extractor.js +26 -4
- package/lib/cjs/data-extractor.js.map +1 -1
- package/lib/cjs/libs/element-path.d.ts +23 -1
- package/lib/cjs/libs/element-path.d.ts.map +1 -1
- package/lib/cjs/libs/element-path.js +28 -173
- package/lib/cjs/libs/element-path.js.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.d.ts.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/autocapture-plugin.d.ts.map +1 -1
- package/lib/esm/autocapture-plugin.js +66 -2
- package/lib/esm/autocapture-plugin.js.map +1 -1
- package/lib/esm/data-extractor.d.ts +21 -0
- package/lib/esm/data-extractor.d.ts.map +1 -1
- package/lib/esm/data-extractor.js +26 -4
- package/lib/esm/data-extractor.js.map +1 -1
- package/lib/esm/libs/element-path.d.ts +23 -1
- package/lib/esm/libs/element-path.d.ts.map +1 -1
- package/lib/esm/libs/element-path.js +27 -172
- package/lib/esm/libs/element-path.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.d.ts.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/scripts/amplitude-min.js +1 -1
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.js.map +1 -1
- package/lib/scripts/amplitude-min.umd.js +1 -1
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/autocapture-plugin.d.ts.map +1 -1
- package/lib/scripts/data-extractor.d.ts +21 -0
- package/lib/scripts/data-extractor.d.ts.map +1 -1
- package/lib/scripts/libs/element-path.d.ts +23 -1
- package/lib/scripts/libs/element-path.d.ts.map +1 -1
- package/lib/scripts/version.d.ts +1 -1
- package/lib/scripts/version.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -1,177 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* istanbul ignore file
|
|
2
|
+
/* istanbul ignore file -- This file is a deprecated thin re-export with no
|
|
3
|
+
runtime behavior of its own. The `legacyCssPath` algorithm is covered
|
|
4
|
+
exhaustively by `@amplitude/element-selector`'s own suite; re-running
|
|
5
|
+
coverage against the re-export adds nothing. */
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.cssPath = void 0;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
30
|
-
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
31
|
-
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
32
|
-
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
33
|
-
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
34
|
-
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
35
|
-
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
36
|
-
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37
|
-
var Step = /** @class */ (function () {
|
|
38
|
-
function Step(value, optimized) {
|
|
39
|
-
this.value = value;
|
|
40
|
-
this.optimized = optimized;
|
|
41
|
-
}
|
|
42
|
-
Step.prototype.toString = function () {
|
|
43
|
-
return this.value;
|
|
44
|
-
};
|
|
45
|
-
return Step;
|
|
46
|
-
}());
|
|
47
|
-
var cssPath = function (node, optimized) {
|
|
48
|
-
// `node` is already an Element; this check is defensive.
|
|
49
|
-
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
50
|
-
return '';
|
|
51
|
-
}
|
|
52
|
-
var steps = [];
|
|
53
|
-
var contextNode = node;
|
|
54
|
-
while (contextNode) {
|
|
55
|
-
var step = cssPathStep(contextNode, Boolean(optimized), contextNode === node);
|
|
56
|
-
if (!step) {
|
|
57
|
-
break;
|
|
58
|
-
} // bail out early
|
|
59
|
-
steps.push(step);
|
|
60
|
-
if (step.optimized) {
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
contextNode = contextNode.parentElement;
|
|
64
|
-
}
|
|
65
|
-
steps.reverse();
|
|
66
|
-
return steps.join(' > ');
|
|
67
|
-
};
|
|
68
|
-
exports.cssPath = cssPath;
|
|
69
|
-
var cssPathStep = function (node, optimized, isTargetNode) {
|
|
70
|
-
var e_1, _a;
|
|
71
|
-
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
var id = node.getAttribute('id');
|
|
75
|
-
if (optimized) {
|
|
76
|
-
if (id) {
|
|
77
|
-
return new Step(idSelector(id), true);
|
|
78
|
-
}
|
|
79
|
-
var nodeNameLower = node.tagName.toLowerCase();
|
|
80
|
-
if (nodeNameLower === 'body' || nodeNameLower === 'head' || nodeNameLower === 'html') {
|
|
81
|
-
return new Step(nodeNameLower, true);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
var nodeName = node.tagName.toLowerCase();
|
|
85
|
-
if (id) {
|
|
86
|
-
return new Step(nodeName + idSelector(id), true);
|
|
87
|
-
}
|
|
88
|
-
var parent = node.parentNode;
|
|
89
|
-
if (!parent || parent.nodeType === Node.DOCUMENT_NODE) {
|
|
90
|
-
return new Step(nodeName, true);
|
|
91
|
-
}
|
|
92
|
-
function prefixedElementClassNames(el) {
|
|
93
|
-
var classAttribute = el.getAttribute('class');
|
|
94
|
-
if (!classAttribute) {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
return classAttribute
|
|
98
|
-
.split(/\s+/g)
|
|
99
|
-
.filter(Boolean)
|
|
100
|
-
.map(function (name) {
|
|
101
|
-
// The prefix is required to store "__proto__" in a object-based map.
|
|
102
|
-
return '$' + name;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function idSelector(id) {
|
|
106
|
-
return '#' + CSS.escape(id);
|
|
107
|
-
}
|
|
108
|
-
var prefixedOwnClassNamesArray = prefixedElementClassNames(node);
|
|
109
|
-
var needsClassNames = false;
|
|
110
|
-
var needsNthChild = false;
|
|
111
|
-
var ownIndex = -1;
|
|
112
|
-
var elementIndex = -1;
|
|
113
|
-
var siblings = parent.children;
|
|
114
|
-
for (var i = 0; siblings && (ownIndex === -1 || !needsNthChild) && i < siblings.length; ++i) {
|
|
115
|
-
var sibling = siblings[i];
|
|
116
|
-
if (sibling.nodeType !== Node.ELEMENT_NODE) {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
elementIndex += 1;
|
|
120
|
-
if (sibling === node) {
|
|
121
|
-
ownIndex = elementIndex;
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if (needsNthChild) {
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (sibling.tagName.toLowerCase() !== nodeName) {
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
needsClassNames = true;
|
|
131
|
-
var ownClassNames = new Set(prefixedOwnClassNamesArray);
|
|
132
|
-
if (!ownClassNames.size) {
|
|
133
|
-
needsNthChild = true;
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
var siblingClassNamesArray = prefixedElementClassNames(sibling);
|
|
137
|
-
for (var j = 0; j < siblingClassNamesArray.length; ++j) {
|
|
138
|
-
var siblingClass = siblingClassNamesArray[j];
|
|
139
|
-
if (!ownClassNames.has(siblingClass)) {
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
ownClassNames.delete(siblingClass);
|
|
143
|
-
if (!ownClassNames.size) {
|
|
144
|
-
needsNthChild = true;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
var result = nodeName;
|
|
150
|
-
if (isTargetNode &&
|
|
151
|
-
nodeName.toLowerCase() === 'input' &&
|
|
152
|
-
node.getAttribute('type') &&
|
|
153
|
-
!node.getAttribute('id') &&
|
|
154
|
-
!node.getAttribute('class')) {
|
|
155
|
-
result += '[type=' + CSS.escape(node.getAttribute('type') || '') + ']';
|
|
156
|
-
}
|
|
157
|
-
if (needsNthChild) {
|
|
158
|
-
result += ':nth-child(' + String(ownIndex + 1) + ')';
|
|
159
|
-
}
|
|
160
|
-
else if (needsClassNames) {
|
|
161
|
-
try {
|
|
162
|
-
for (var prefixedOwnClassNamesArray_1 = tslib_1.__values(prefixedOwnClassNamesArray), prefixedOwnClassNamesArray_1_1 = prefixedOwnClassNamesArray_1.next(); !prefixedOwnClassNamesArray_1_1.done; prefixedOwnClassNamesArray_1_1 = prefixedOwnClassNamesArray_1.next()) {
|
|
163
|
-
var prefixedName = prefixedOwnClassNamesArray_1_1.value;
|
|
164
|
-
result += '.' + CSS.escape(prefixedName.slice(1));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
168
|
-
finally {
|
|
169
|
-
try {
|
|
170
|
-
if (prefixedOwnClassNamesArray_1_1 && !prefixedOwnClassNamesArray_1_1.done && (_a = prefixedOwnClassNamesArray_1.return)) _a.call(prefixedOwnClassNamesArray_1);
|
|
171
|
-
}
|
|
172
|
-
finally { if (e_1) throw e_1.error; }
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return new Step(result, false);
|
|
176
|
-
};
|
|
8
|
+
/**
|
|
9
|
+
* Backward-compat re-export.
|
|
10
|
+
*
|
|
11
|
+
* The Chromium-DevTools-derived `cssPath` walker that lived here for years
|
|
12
|
+
* has moved to `@amplitude/element-selector` as `legacyCssPath`. That's now
|
|
13
|
+
* the canonical home — the SDK and the dashboard both import from there,
|
|
14
|
+
* so the two can never drift again.
|
|
15
|
+
*
|
|
16
|
+
* This file stays around as a thin re-export so:
|
|
17
|
+
*
|
|
18
|
+
* - any third-party consumer that historically deep-imported `cssPath` from
|
|
19
|
+
* `@amplitude/plugin-autocapture-browser/src/libs/element-path` continues
|
|
20
|
+
* to work without code changes;
|
|
21
|
+
* - the autocapture plugin's own internals don't have to special-case the
|
|
22
|
+
* rename mid-PR (although `data-extractor` no longer uses it — all
|
|
23
|
+
* routing happens via `generateSelector` from the package).
|
|
24
|
+
*
|
|
25
|
+
* Slated for deletion in a future major once we've audited and confirmed no
|
|
26
|
+
* external imports remain.
|
|
27
|
+
*
|
|
28
|
+
* @deprecated Import `legacyCssPath` from `@amplitude/element-selector` directly.
|
|
29
|
+
*/
|
|
30
|
+
var element_selector_1 = require("@amplitude/element-selector");
|
|
31
|
+
Object.defineProperty(exports, "cssPath", { enumerable: true, get: function () { return element_selector_1.legacyCssPath; } });
|
|
177
32
|
//# sourceMappingURL=element-path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-path.js","sourceRoot":"","sources":["../../../src/libs/element-path.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;;AAE1B,6CAA6C;AAC7C,iHAAiH;AACjH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AM,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC,CAAC","sourcesContent":["/* istanbul ignore file */\n\n// Code is adapted from The Chromium Authors.\n// Source: https://github.com/ChromeDevTools/devtools-frontend/blob/main/front_end/panels/elements/DOMPath.ts#L14\n// License: BSD-style license\n//\n// Copyright 2014 The Chromium Authors\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n// * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n// * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n// * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nclass Step {\n constructor(public value: string, public optimized: boolean) {}\n toString() {\n return this.value;\n }\n}\n\nexport const cssPath = function (node: Element, optimized?: boolean): string {\n // `node` is already an Element; this check is defensive.\n if (node.nodeType !== Node.ELEMENT_NODE) {\n return '';\n }\n\n const steps: Step[] = [];\n let contextNode: Element | null = node;\n\n while (contextNode) {\n const step = cssPathStep(contextNode, Boolean(optimized), contextNode === node);\n if (!step) {\n break;\n } // bail out early\n steps.push(step);\n if (step.optimized) {\n break;\n }\n contextNode = contextNode.parentElement;\n }\n\n steps.reverse();\n return steps.join(' > ');\n};\n\nconst cssPathStep = function (node: Element, optimized: boolean, isTargetNode: boolean): Step | null {\n if (node.nodeType !== Node.ELEMENT_NODE) {\n return null;\n }\n\n const id = node.getAttribute('id');\n if (optimized) {\n if (id) {\n return new Step(idSelector(id), true);\n }\n\n const nodeNameLower = node.tagName.toLowerCase();\n if (nodeNameLower === 'body' || nodeNameLower === 'head' || nodeNameLower === 'html') {\n return new Step(nodeNameLower, true);\n }\n }\n\n const nodeName = node.tagName.toLowerCase();\n\n if (id) {\n return new Step(nodeName + idSelector(id), true);\n }\n\n const parent = node.parentNode;\n if (!parent || parent.nodeType === Node.DOCUMENT_NODE) {\n return new Step(nodeName, true);\n }\n\n function prefixedElementClassNames(el: Element): string[] {\n const classAttribute = el.getAttribute('class');\n if (!classAttribute) {\n return [];\n }\n return classAttribute\n .split(/\\s+/g)\n .filter(Boolean)\n .map(function (name) {\n // The prefix is required to store \"__proto__\" in a object-based map.\n return '$' + name;\n });\n }\n\n function idSelector(id: string): string {\n return '#' + CSS.escape(id);\n }\n\n const prefixedOwnClassNamesArray = prefixedElementClassNames(node);\n let needsClassNames = false;\n let needsNthChild = false;\n let ownIndex = -1;\n let elementIndex = -1;\n\n const siblings: HTMLCollectionOf<Element> = parent.children;\n\n for (let i = 0; siblings && (ownIndex === -1 || !needsNthChild) && i < siblings.length; ++i) {\n const sibling = siblings[i];\n if (sibling.nodeType !== Node.ELEMENT_NODE) {\n continue;\n }\n\n elementIndex += 1;\n if (sibling === node) {\n ownIndex = elementIndex;\n continue;\n }\n if (needsNthChild) {\n continue;\n }\n\n if (sibling.tagName.toLowerCase() !== nodeName) {\n continue;\n }\n\n needsClassNames = true;\n const ownClassNames = new Set<string>(prefixedOwnClassNamesArray);\n if (!ownClassNames.size) {\n needsNthChild = true;\n continue;\n }\n\n const siblingClassNamesArray = prefixedElementClassNames(sibling);\n for (let j = 0; j < siblingClassNamesArray.length; ++j) {\n const siblingClass = siblingClassNamesArray[j];\n if (!ownClassNames.has(siblingClass)) {\n continue;\n }\n ownClassNames.delete(siblingClass);\n if (!ownClassNames.size) {\n needsNthChild = true;\n break;\n }\n }\n }\n\n let result = nodeName;\n if (\n isTargetNode &&\n nodeName.toLowerCase() === 'input' &&\n node.getAttribute('type') &&\n !node.getAttribute('id') &&\n !node.getAttribute('class')\n ) {\n result += '[type=' + CSS.escape(node.getAttribute('type') || '') + ']';\n }\n if (needsNthChild) {\n result += ':nth-child(' + String(ownIndex + 1) + ')';\n } else if (needsClassNames) {\n for (const prefixedName of prefixedOwnClassNamesArray) {\n result += '.' + CSS.escape(prefixedName.slice(1));\n }\n }\n\n return new Step(result, false);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"element-path.js","sourceRoot":"","sources":["../../../src/libs/element-path.ts"],"names":[],"mappings":";AAAA;;;kDAGkD;;;AAElD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,gEAAuE;AAA9D,2GAAA,aAAa,OAAW","sourcesContent":["/* istanbul ignore file -- This file is a deprecated thin re-export with no\n runtime behavior of its own. The `legacyCssPath` algorithm is covered\n exhaustively by `@amplitude/element-selector`'s own suite; re-running\n coverage against the re-export adds nothing. */\n\n/**\n * Backward-compat re-export.\n *\n * The Chromium-DevTools-derived `cssPath` walker that lived here for years\n * has moved to `@amplitude/element-selector` as `legacyCssPath`. That's now\n * the canonical home — the SDK and the dashboard both import from there,\n * so the two can never drift again.\n *\n * This file stays around as a thin re-export so:\n *\n * - any third-party consumer that historically deep-imported `cssPath` from\n * `@amplitude/plugin-autocapture-browser/src/libs/element-path` continues\n * to work without code changes;\n * - the autocapture plugin's own internals don't have to special-case the\n * rename mid-PR (although `data-extractor` no longer uses it — all\n * routing happens via `generateSelector` from the package).\n *\n * Slated for deletion in a future major once we've audited and confirmed no\n * external imports remain.\n *\n * @deprecated Import `legacyCssPath` from `@amplitude/element-selector` directly.\n */\n\nexport { legacyCssPath as cssPath } from '@amplitude/element-selector';\n"]}
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.28.0-featelement-selector-v1.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/cjs/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,qCAAqC,CAAC"}
|
package/lib/cjs/version.js
CHANGED
package/lib/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,kCAAkC,CAAC","sourcesContent":["export const VERSION = '1.28.0-featelement-selector-v1.0';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocapture-plugin.d.ts","sourceRoot":"","sources":["../../src/autocapture-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAK/B,kBAAkB,EAKnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAEL,K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mB,wBAAwB;CAC5C;AAED,MAAM,WAAW,oBAAoB;IACnC,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpF,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC,4BAA4B,CAAC,UAAU,CAAC,CAAC,CAAC;IACxF,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC;IACnF,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC,eAAe,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED,eAAO,MAAM,iBAAiB,aACnB,0BAA0B,YACzB;IAAE,iBAAiB,EAAE,kBAAkB,CAAA;CAAE,KAClD,uBAyYF,CAAC"}
|
|
@@ -13,8 +13,68 @@ import { createClickObservable, createScrollObservable, createExposureObservable
|
|
|
13
13
|
import { createLabeledEventToTriggerMap, createTriggerEvaluator, groupLabeledEventIdsByEventType, } from './pageActions/triggers';
|
|
14
14
|
import { DataExtractor } from './data-extractor';
|
|
15
15
|
import { Observable } from '@amplitude/analytics-core';
|
|
16
|
+
import { createSelectorEngine, resolveSelectorConfig, } from '@amplitude/element-selector';
|
|
16
17
|
import { trackExposure } from './autocapture/track-exposure';
|
|
17
18
|
import { fireViewportContentUpdated, onExposure } from './autocapture/track-viewport-content-updated';
|
|
19
|
+
var subscribeRemoteConfig = function (config, key, callback) {
|
|
20
|
+
var remoteConfigClient = config.remoteConfigClient;
|
|
21
|
+
if (!remoteConfigClient) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
var subscriptionId = remoteConfigClient.subscribe(key, 'all', callback);
|
|
25
|
+
return {
|
|
26
|
+
unsubscribe: function () {
|
|
27
|
+
remoteConfigClient.unsubscribe(subscriptionId);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
var attachElementSelectorSurface = function (amplitude, selectorEngine) {
|
|
32
|
+
// Expose a narrowed, read-only surface of the engine on the customer's
|
|
33
|
+
// BrowserClient instance so downstream consumers can use the same engine the
|
|
34
|
+
// SDK is running. Attach to the instance, not window.amplitude, so custom
|
|
35
|
+
// global names and multiple SDK instances do not clobber each other.
|
|
36
|
+
var elementSelectorClient = amplitude;
|
|
37
|
+
var hadPreviousElementSelector = Object.prototype.hasOwnProperty.call(elementSelectorClient, 'elementSelector');
|
|
38
|
+
var previousElementSelector = elementSelectorClient.elementSelector;
|
|
39
|
+
var elementSelectorSurface = {
|
|
40
|
+
generate: function (el) { return selectorEngine.generate(el); },
|
|
41
|
+
getConfig: function () { return selectorEngine.getConfig(); },
|
|
42
|
+
onConfigChange: function (cb) { return selectorEngine.onConfigChange(cb); },
|
|
43
|
+
};
|
|
44
|
+
/* istanbul ignore next */
|
|
45
|
+
elementSelectorClient.elementSelector = elementSelectorSurface;
|
|
46
|
+
return {
|
|
47
|
+
unsubscribe: function () {
|
|
48
|
+
if (hadPreviousElementSelector) {
|
|
49
|
+
elementSelectorClient.elementSelector = previousElementSelector;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
delete elementSelectorClient.elementSelector;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
var setupElementSelector = function (config, amplitude, dataExtractor) {
|
|
58
|
+
var subscriptions = [];
|
|
59
|
+
// Construct the engine eagerly with defaults so `dataExtractor.getElementPath`
|
|
60
|
+
// can route through it from the first emission. When `enabled` is false in
|
|
61
|
+
// the resolved config (the default), `getElementPath` falls back to the
|
|
62
|
+
// legacy `cssPath` algorithm.
|
|
63
|
+
var initialSelectorConfig = resolveSelectorConfig(undefined, config.loggerProvider);
|
|
64
|
+
var selectorEngine = createSelectorEngine(initialSelectorConfig, { logger: config.loggerProvider });
|
|
65
|
+
dataExtractor.setSelectorEngine(selectorEngine);
|
|
66
|
+
subscriptions.push(attachElementSelectorSurface(amplitude, selectorEngine));
|
|
67
|
+
if (config.fetchRemoteConfig) {
|
|
68
|
+
var elementSelectorSubscription = subscribeRemoteConfig(config, 'configs.analyticsSDK.autocapture.elementSelector', function (remoteSelectorConfig) {
|
|
69
|
+
var nextResolved = resolveSelectorConfig(remoteSelectorConfig, config.loggerProvider);
|
|
70
|
+
selectorEngine.updateConfig(nextResolved);
|
|
71
|
+
});
|
|
72
|
+
if (elementSelectorSubscription) {
|
|
73
|
+
subscriptions.push(elementSelectorSubscription);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return subscriptions;
|
|
77
|
+
};
|
|
18
78
|
export var ObservablesEnum;
|
|
19
79
|
(function (ObservablesEnum) {
|
|
20
80
|
ObservablesEnum["ClickObservable"] = "clickObservable";
|
|
@@ -135,7 +195,7 @@ export var autocapturePlugin = function (options, context) {
|
|
|
135
195
|
}
|
|
136
196
|
};
|
|
137
197
|
var setup = function (config, amplitude) { return __awaiter(void 0, void 0, void 0, function () {
|
|
138
|
-
var pageViewEndFired, lastScroll, shouldTrackEvent, shouldTrackActionClick, allObservables, clickTrackingSubscription, changeSubscription, actionClickSubscription, scrollTracker, trackers, globalScope, handleViewportContentUpdated, handleExposure, beforeUnloadHandler_1, navigateObservable, popstateHandler_1, originalPushState_1, allowlist, actionClickAllowlist, messenger;
|
|
198
|
+
var pageViewEndFired, lastScroll, pageActionsSubscription, shouldTrackEvent, shouldTrackActionClick, allObservables, clickTrackingSubscription, changeSubscription, actionClickSubscription, scrollTracker, trackers, globalScope, handleViewportContentUpdated, handleExposure, beforeUnloadHandler_1, navigateObservable, popstateHandler_1, originalPushState_1, allowlist, actionClickAllowlist, messenger;
|
|
139
199
|
var _a;
|
|
140
200
|
return __generator(this, function (_b) {
|
|
141
201
|
/* istanbul ignore if */
|
|
@@ -151,11 +211,15 @@ export var autocapturePlugin = function (options, context) {
|
|
|
151
211
|
config.loggerProvider.debug('Remote config client is not provided, skipping remote config fetch');
|
|
152
212
|
}
|
|
153
213
|
else {
|
|
154
|
-
config
|
|
214
|
+
pageActionsSubscription = subscribeRemoteConfig(config, 'configs.analyticsSDK.pageActions', function (remoteConfig) {
|
|
155
215
|
recomputePageActionsData(remoteConfig);
|
|
156
216
|
});
|
|
217
|
+
if (pageActionsSubscription) {
|
|
218
|
+
subscriptions.push(pageActionsSubscription);
|
|
219
|
+
}
|
|
157
220
|
}
|
|
158
221
|
}
|
|
222
|
+
subscriptions.push.apply(subscriptions, __spreadArray([], __read(setupElementSelector(config, amplitude, dataExtractor)), false));
|
|
159
223
|
shouldTrackEvent = createShouldTrackEvent(options, options.cssSelectorAllowlist);
|
|
160
224
|
shouldTrackActionClick = createShouldTrackEvent(options, options.actionClickAllowlist);
|
|
161
225
|
allObservables = createObservables();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocapture-plugin.js","sourceRoot":"","sources":["../../src/autocapture-plugin.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,OAAO,EAKL,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,6BAA6B,EAE7B,cAAc,EACd,0BAA0B,EAC1B,uBAAuB,EACvB,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,sBAAsB,GAIvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B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SAAS;oBAC/B,oBAAoB,sBAAA;iBACrB,CAAC,CAAC;gBACH,uBAAuB,CAAC,SAAS,CAAC,CAAC;gBACnC,0BAA0B;gBAC1B,SAAS,CAAC,KAAK,YACb,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,IAC3B,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,KAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,EAC3F,CAAC;aACJ;;;SACF,CAAC;IAEF,IAAM,OAAO,GAAuC,UAAO,KAAK;;YAC9D,sBAAO,KAAK,EAAC;;SACd,CAAC;IAEF,IAAM,QAAQ,GAAG;;;;;gBACf,KAA2B,kBAAA,SAAA,aAAa,CAAA,mHAAE;oBAA/B,YAAY;oBACrB,YAAY,CAAC,WAAW,EAAE,CAAC;iBAC5B;;;;;;;;;;;SACF,CAAC;IAEF,OAAO;QACL,IAAI,MAAA;QACJ,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,OAAO,SAAA;QACP,QAAQ,UAAA;KACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable no-restricted-globals */\nimport {\n type BrowserClient,\n type BrowserConfig,\n type EnrichmentPlugin,\n type ElementInteractionsOptions,\n DEFAULT_EXPOSURE_DURATION,\n DEFAULT_CSS_SELECTOR_ALLOWLIST,\n DEFAULT_ACTION_CLICK_ALLOWLIST,\n DEFAULT_DATA_ATTRIBUTE_PREFIX,\n IDiagnosticsClient,\n getGlobalScope,\n getOrCreateWindowMessenger,\n enableBackgroundCapture,\n multicast,\n} from '@amplitude/analytics-core';\nimport { VERSION } from './version';\nimport * as constants from './constants';\nimport {\n createShouldTrackEvent,\n type ElementBasedTimestampedEvent,\n type TimestampedEvent,\n type NavigateEvent,\n} from './helpers';\nimport { enableVisualTagging } from './libs/messenger';\nimport { trackClicks } from './autocapture/track-click';\nimport { trackChange } from './autocapture/track-change';\nimport { trackActionClick } from './autocapture/track-action-click';\nimport { trackScroll } from './autocapture/track-scroll';\n\nimport {\n createClickObservable,\n createScrollObservable,\n createExposureObservable,\n createMutationObservable,\n} from './observables';\n\nimport {\n createLabeledEventToTriggerMap,\n createTriggerEvaluator,\n groupLabeledEventIdsByEventType,\n} from './pageActions/triggers';\nimport { DataExtractor } from './data-extractor';\nimport { Observable, Unsubscribable } from '@amplitude/analytics-core';\nimport { trackExposure } from './autocapture/track-exposure';\nimport { fireViewportContentUpdated, onExposure, ExposureTracker } from './autocapture/track-viewport-content-updated';\n\ntype NavigationType = {\n addEventListener: (type: string, listener: EventListenerOrEventListenerObject) => void;\n removeEventListener: (type: string, listener: EventListenerOrEventListenerObject) => void;\n};\n\ndeclare global {\n interface Window {\n navigation: NavigationType;\n }\n}\n\ntype BrowserEnrichmentPlugin = EnrichmentPlugin<BrowserClient, BrowserConfig>;\n\nexport type AutoCaptureOptionsWithDefaults = Required<\n Pick<ElementInteractionsOptions, 'debounceTime' | 'cssSelectorAllowlist' | 'actionClickAllowlist'>\n> &\n ElementInteractionsOptions;\n\nexport enum ObservablesEnum {\n ClickObservable = 'clickObservable',\n ChangeObservable = 'changeObservable',\n NavigateObservable = 'navigateObservable',\n MutationObservable = 'mutationObservable',\n ScrollObservable = 'scrollObservable',\n ExposureObservable = 'exposureObservable',\n BrowserErrorObservable = 'browserErrorObservable',\n SelectionObservable = 'selectionObservable',\n MouseMoveObservable = 'mouseMoveObservable',\n}\n\nexport interface AllWindowObservables {\n [ObservablesEnum.ChangeObservable]: Observable<ElementBasedTimestampedEvent<Event>>;\n // [ObservablesEnum.ErrorObservable]: Observable<TimestampedEvent<ErrorEvent>>;\n [ObservablesEnum.ClickObservable]: Observable<ElementBasedTimestampedEvent<MouseEvent>>;\n [ObservablesEnum.MutationObservable]: Observable<TimestampedEvent<MutationRecord[]>>;\n [ObservablesEnum.NavigateObservable]?: Observable<TimestampedEvent<NavigateEvent>>;\n [ObservablesEnum.ScrollObservable]: Observable<Event>; // TODO: add type for scroll event\n [ObservablesEnum.ExposureObservable]: Observable<Event>;\n [ObservablesEnum.SelectionObservable]?: Observable<void>;\n}\n\nexport const autocapturePlugin = (\n options: ElementInteractionsOptions = {},\n context?: { diagnosticsClient: IDiagnosticsClient },\n): BrowserEnrichmentPlugin => {\n // Set the plugin version tag\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n context?.diagnosticsClient.setTag('plugin.autocapture.version', VERSION);\n\n const {\n dataAttributePrefix = DEFAULT_DATA_ATTRIBUTE_PREFIX,\n visualTaggingOptions = {\n enabled: true,\n },\n } = options;\n\n options.cssSelectorAllowlist = options.cssSelectorAllowlist ?? DEFAULT_CSS_SELECTOR_ALLOWLIST;\n options.actionClickAllowlist = options.actionClickAllowlist ?? DEFAULT_ACTION_CLICK_ALLOWLIST;\n options.debounceTime = options.debounceTime ?? 0;\n const isViewportContentUpdatedEnabled = options.viewportContentUpdated?.enabled !== false;\n const resolvedExposureDuration =\n options.viewportContentUpdated?.exposureDuration ?? options.exposureDuration ?? DEFAULT_EXPOSURE_DURATION;\n options.viewportContentUpdated = {\n ...options.viewportContentUpdated,\n exposureDuration: resolvedExposureDuration,\n };\n\n options.pageUrlExcludelist = options.pageUrlExcludelist?.reduce(\n (acc: (string | RegExp | { pattern: string })[], excludePattern) => {\n if (typeof excludePattern === 'string') {\n acc.push(excludePattern);\n }\n if (excludePattern instanceof RegExp) {\n acc.push(excludePattern);\n }\n if (typeof excludePattern === 'object' && excludePattern !== null && 'pattern' in excludePattern) {\n try {\n acc.push(new RegExp(excludePattern.pattern));\n } catch (regexError) {\n console.warn(`Invalid regex pattern: ${excludePattern.pattern}`, regexError);\n return acc;\n }\n }\n return acc;\n },\n [],\n );\n\n const name = constants.PLUGIN_NAME;\n const type = 'enrichment';\n\n const subscriptions: Unsubscribable[] = [];\n\n const dataExtractor = new DataExtractor(options, context);\n\n // Page-level state shared across trackers, emitted in a single Page View End event on beforeunload\n // elementExposedForPage holds the total set of elements seen during the entire page view lifetime\n const elementExposedForPage = new Set<string>();\n // currentElementExposed only holds the set of elements that will be flushed during the next [Amplitude] Viewport Content Updated event\n const currentElementExposed = new Set<string>();\n\n let beforeUnloadCleanup: () => void;\n\n const createObservables = (): AllWindowObservables => {\n const clickObservable = multicast(\n createClickObservable().map(\n (click) =>\n dataExtractor.addAdditionalEventProperties(\n click,\n 'click',\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n dataAttributePrefix,\n ) as ElementBasedTimestampedEvent<MouseEvent>,\n ),\n );\n\n const changeObservable = multicast(\n new Observable<ElementBasedTimestampedEvent<Event>>((observer) => {\n const handler = (changeEvent: Event) => {\n const enrichedChangeEvent = dataExtractor.addAdditionalEventProperties(\n changeEvent,\n 'change',\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n dataAttributePrefix,\n ) as ElementBasedTimestampedEvent<Event>;\n observer.next(enrichedChangeEvent);\n };\n /* istanbul ignore next */\n getGlobalScope()?.document.addEventListener('change', handler, { capture: true });\n /* istanbul ignore next */\n return () => getGlobalScope()?.document.removeEventListener('change', handler);\n }),\n );\n\n // Create observable for URL changes\n let navigateObservable: Observable<TimestampedEvent<NavigateEvent>> | undefined;\n\n /* istanbul ignore next */\n if (window.navigation) {\n navigateObservable = multicast(\n new Observable<TimestampedEvent<NavigateEvent>>((observer) => {\n const handler = (navigateEvent: NavigateEvent) => {\n const enrichedNavigateEvent = dataExtractor.addAdditionalEventProperties(\n navigateEvent,\n 'navigate',\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n dataAttributePrefix,\n );\n observer.next(enrichedNavigateEvent);\n };\n window.navigation.addEventListener('navigate', handler as EventListener);\n return () => {\n window.navigation.removeEventListener('navigate', handler as EventListener);\n };\n }),\n );\n }\n\n const mutationObservable = multicast(\n createMutationObservable().map((mutation) =>\n dataExtractor.addAdditionalEventProperties(\n mutation,\n 'mutation',\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n dataAttributePrefix,\n ),\n ),\n );\n\n const scrollObservable = createScrollObservable();\n\n const exposureObservable = createExposureObservable(\n mutationObservable,\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n );\n\n return {\n [ObservablesEnum.ChangeObservable]: changeObservable,\n // [ObservablesEnum.ErrorObservable]: errorObservable,\n [ObservablesEnum.ClickObservable]: clickObservable,\n [ObservablesEnum.MutationObservable]: mutationObservable,\n [ObservablesEnum.NavigateObservable]: navigateObservable,\n [ObservablesEnum.ScrollObservable]: scrollObservable,\n [ObservablesEnum.ExposureObservable]: exposureObservable,\n };\n };\n\n // Group labeled events by event type (eg. click, change)\n let groupedLabeledEvents = groupLabeledEventIdsByEventType(Object.values(options.pageActions?.labeledEvents ?? {}));\n\n let labeledEventToTriggerMap = createLabeledEventToTriggerMap(options.pageActions?.triggers ?? []);\n\n // Evaluate triggers for the given event by running the actions associated with the matching triggers\n const evaluateTriggers = createTriggerEvaluator(\n groupedLabeledEvents,\n labeledEventToTriggerMap,\n dataExtractor,\n options,\n );\n\n // Function to recalculate internal variables when remote config is updated\n const recomputePageActionsData = (remotePageActions: ElementInteractionsOptions['pageActions']) => {\n if (remotePageActions) {\n // Merge remote config with local options\n options.pageActions = {\n ...options.pageActions,\n ...remotePageActions,\n };\n\n // Recalculate internal variables\n groupedLabeledEvents = groupLabeledEventIdsByEventType(Object.values(options.pageActions.labeledEvents ?? {}));\n labeledEventToTriggerMap = createLabeledEventToTriggerMap(options.pageActions.triggers ?? []);\n\n // Update evaluateTriggers function\n evaluateTriggers.update(groupedLabeledEvents, labeledEventToTriggerMap, options);\n }\n };\n\n const setup: BrowserEnrichmentPlugin['setup'] = async (config, amplitude) => {\n /* istanbul ignore if */\n if (typeof document === 'undefined') {\n return;\n }\n\n let pageViewEndFired = false;\n const lastScroll: { maxX: undefined | number; maxY: undefined | number } = { maxX: undefined, maxY: undefined };\n\n // Fetch remote config for pageActions in a non-blocking manner\n if (config.fetchRemoteConfig) {\n if (!config.remoteConfigClient) {\n // TODO(xinyi): Diagnostics.recordEvent\n config.loggerProvider.debug('Remote config client is not provided, skipping remote config fetch');\n } else {\n config.remoteConfigClient.subscribe('configs.analyticsSDK.pageActions', 'all', (remoteConfig) => {\n recomputePageActionsData(remoteConfig as ElementInteractionsOptions['pageActions']);\n });\n }\n }\n\n // Create should track event functions the different allowlists\n const shouldTrackEvent = createShouldTrackEvent(\n options,\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n );\n const shouldTrackActionClick = createShouldTrackEvent(\n options,\n (options as AutoCaptureOptionsWithDefaults).actionClickAllowlist,\n );\n\n // Create observables for events on the window\n const allObservables = createObservables();\n\n // Create subscriptions\n const clickTrackingSubscription = trackClicks({\n allObservables,\n amplitude,\n shouldTrackEvent: shouldTrackEvent,\n evaluateTriggers: evaluateTriggers.evaluate.bind(evaluateTriggers),\n });\n\n subscriptions.push(clickTrackingSubscription);\n\n const changeSubscription = trackChange({\n allObservables,\n getEventProperties: (...args) => dataExtractor.getEventProperties(...args, dataAttributePrefix),\n amplitude,\n shouldTrackEvent: shouldTrackEvent,\n evaluateTriggers: evaluateTriggers.evaluate.bind(evaluateTriggers),\n });\n subscriptions.push(changeSubscription);\n\n const actionClickSubscription = trackActionClick({\n allObservables,\n options: options as AutoCaptureOptionsWithDefaults,\n getEventProperties: (...args) => dataExtractor.getEventProperties(...args, dataAttributePrefix),\n amplitude,\n shouldTrackEvent,\n shouldTrackActionClick: shouldTrackActionClick,\n });\n if (actionClickSubscription) {\n subscriptions.push(actionClickSubscription);\n }\n\n const scrollTracker = trackScroll({\n allObservables,\n amplitude,\n });\n subscriptions.push(scrollTracker);\n\n const trackers: { exposure?: ExposureTracker & Unsubscribable } = {};\n\n const globalScope = getGlobalScope();\n\n const handleViewportContentUpdated = (isPageEnd: boolean) => {\n if (isPageEnd && pageViewEndFired) {\n return;\n }\n setTimeout(() => {\n pageViewEndFired = false;\n }, 100);\n\n pageViewEndFired = true;\n fireViewportContentUpdated({\n amplitude,\n scrollTracker,\n currentElementExposed,\n elementExposedForPage,\n exposureTracker: trackers.exposure,\n isPageEnd,\n lastScroll,\n });\n };\n\n const handleExposure = (elementPath: string) => {\n onExposure(elementPath, elementExposedForPage, currentElementExposed, handleViewportContentUpdated);\n };\n\n if (isViewportContentUpdatedEnabled) {\n trackers.exposure = trackExposure({\n allObservables,\n onExposure: handleExposure,\n dataExtractor,\n exposureDuration: resolvedExposureDuration,\n });\n if (trackers.exposure) {\n subscriptions.push(trackers.exposure);\n }\n\n const beforeUnloadHandler = () => {\n handleViewportContentUpdated(true);\n };\n /* istanbul ignore next */\n globalScope?.addEventListener('beforeunload', beforeUnloadHandler);\n beforeUnloadCleanup = () => {\n /* istanbul ignore next */\n globalScope?.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n // Ensure cleanup on teardown as well\n subscriptions.push({ unsubscribe: () => beforeUnloadCleanup() });\n\n // Also track on navigation (SPA)\n const navigateObservable = allObservables[ObservablesEnum.NavigateObservable];\n if (navigateObservable) {\n subscriptions.push(\n navigateObservable.subscribe(() => {\n handleViewportContentUpdated(true);\n }),\n );\n } else if (globalScope) {\n const popstateHandler = () => {\n handleViewportContentUpdated(true);\n };\n /* istanbul ignore next */\n // Fallback for SPA tracking when Navigation API is not available\n globalScope.addEventListener('popstate', popstateHandler);\n\n /* istanbul ignore next */\n // There is no global browser listener for changes to history, so we have\n // to modify pushState directly.\n // https://stackoverflow.com/a/64927639\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalPushState = globalScope.history.pushState;\n if (globalScope.history && originalPushState) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n globalScope.history.pushState = new Proxy(originalPushState, {\n apply: (target, thisArg, [state, unused, url]) => {\n target.apply(thisArg, [state, unused, url]);\n handleViewportContentUpdated(true);\n },\n });\n }\n\n subscriptions.push({\n unsubscribe: () => {\n /* istanbul ignore next */\n globalScope.removeEventListener('popstate', popstateHandler);\n /* istanbul ignore next */\n if (globalScope.history && originalPushState) {\n globalScope.history.pushState = originalPushState;\n }\n },\n });\n }\n }\n\n /* istanbul ignore next */\n config?.loggerProvider?.log(`${name} has been successfully added.`);\n\n // Setup visual tagging and background capture on the shared messenger singleton.\n // Using the singleton ensures a single message listener per page, even when\n // session-replay is also loaded.\n if (window.opener && visualTaggingOptions.enabled) {\n const allowlist = (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist;\n const actionClickAllowlist = (options as AutoCaptureOptionsWithDefaults).actionClickAllowlist;\n\n const messenger = getOrCreateWindowMessenger();\n enableVisualTagging(messenger, {\n dataExtractor,\n isElementSelectable: createShouldTrackEvent(options, [...allowlist, ...actionClickAllowlist]),\n cssSelectorAllowlist: allowlist,\n actionClickAllowlist,\n });\n enableBackgroundCapture(messenger);\n /* istanbul ignore next */\n messenger.setup({\n logger: config?.loggerProvider,\n ...(config?.serverZone && { endpoint: constants.AMPLITUDE_ORIGINS_MAP[config.serverZone] }),\n });\n }\n };\n\n const execute: BrowserEnrichmentPlugin['execute'] = async (event) => {\n return event;\n };\n\n const teardown = async () => {\n for (const subscription of subscriptions) {\n subscription.unsubscribe();\n }\n };\n\n return {\n name,\n type,\n setup,\n execute,\n teardown,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"autocapture-plugin.js","sourceRoot":"","sources":["../../src/autocapture-plugin.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,OAAO,EAKL,yBAAyB,EACzB,8BAA8B,EAC9B,8BAA8B,EAC9B,6BAA6B,EAE7B,cAAc,EACd,0BAA0B,EAC1B,uBAAuB,EACvB,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,sBAAsB,GAIvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW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;iBACrB,CAAC,CAAC;gBACH,uBAAuB,CAAC,SAAS,CAAC,CAAC;gBACnC,0BAA0B;gBAC1B,SAAS,CAAC,KAAK,YACb,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,IAC3B,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,KAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,EAC3F,CAAC;aACJ;;;SACF,CAAC;IAEF,IAAM,OAAO,GAAuC,UAAO,KAAK;;YAC9D,sBAAO,KAAK,EAAC;;SACd,CAAC;IAEF,IAAM,QAAQ,GAAG;;;;;gBACf,KAA2B,kBAAA,SAAA,aAAa,CAAA,mHAAE;oBAA/B,YAAY;oBACrB,YAAY,CAAC,WAAW,EAAE,CAAC;iBAC5B;;;;;;;;;;;SACF,CAAC;IAEF,OAAO;QACL,IAAI,MAAA;QACJ,IAAI,MAAA;QACJ,KAAK,OAAA;QACL,OAAO,SAAA;QACP,QAAQ,UAAA;KACT,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable no-restricted-globals */\nimport {\n type BrowserClient,\n type BrowserConfig,\n type EnrichmentPlugin,\n type ElementInteractionsOptions,\n DEFAULT_EXPOSURE_DURATION,\n DEFAULT_CSS_SELECTOR_ALLOWLIST,\n DEFAULT_ACTION_CLICK_ALLOWLIST,\n DEFAULT_DATA_ATTRIBUTE_PREFIX,\n IDiagnosticsClient,\n getGlobalScope,\n getOrCreateWindowMessenger,\n enableBackgroundCapture,\n multicast,\n} from '@amplitude/analytics-core';\nimport { VERSION } from './version';\nimport * as constants from './constants';\nimport {\n createShouldTrackEvent,\n type ElementBasedTimestampedEvent,\n type TimestampedEvent,\n type NavigateEvent,\n} from './helpers';\nimport { enableVisualTagging } from './libs/messenger';\nimport { trackClicks } from './autocapture/track-click';\nimport { trackChange } from './autocapture/track-change';\nimport { trackActionClick } from './autocapture/track-action-click';\nimport { trackScroll } from './autocapture/track-scroll';\n\nimport {\n createClickObservable,\n createScrollObservable,\n createExposureObservable,\n createMutationObservable,\n} from './observables';\n\nimport {\n createLabeledEventToTriggerMap,\n createTriggerEvaluator,\n groupLabeledEventIdsByEventType,\n} from './pageActions/triggers';\nimport { DataExtractor } from './data-extractor';\nimport { Observable, Unsubscribable } from '@amplitude/analytics-core';\nimport {\n createSelectorEngine,\n resolveSelectorConfig,\n type ElementSelectorRemoteConfig,\n type ResolvedSelectorConfig,\n type SelectorEngine,\n} from '@amplitude/element-selector';\nimport { trackExposure } from './autocapture/track-exposure';\nimport { fireViewportContentUpdated, onExposure, ExposureTracker } from './autocapture/track-viewport-content-updated';\n\ntype NavigationType = {\n addEventListener: (type: string, listener: EventListenerOrEventListenerObject) => void;\n removeEventListener: (type: string, listener: EventListenerOrEventListenerObject) => void;\n};\n\ndeclare global {\n interface Window {\n navigation: NavigationType;\n }\n}\n\ntype BrowserEnrichmentPlugin = EnrichmentPlugin<BrowserClient, BrowserConfig>;\ntype ElementSelectorPublicSurface = {\n generate: (el: Element) => string;\n getConfig: () => Readonly<ResolvedSelectorConfig>;\n onConfigChange: (cb: (config: ResolvedSelectorConfig) => void) => () => void;\n};\ntype BrowserClientWithElementSelector = BrowserClient & { elementSelector?: unknown };\ntype RemoteConfigCallback = Parameters<NonNullable<BrowserConfig['remoteConfigClient']>['subscribe']>[2];\n\nconst subscribeRemoteConfig = (\n config: BrowserConfig,\n key: string,\n callback: RemoteConfigCallback,\n): Unsubscribable | undefined => {\n const remoteConfigClient = config.remoteConfigClient;\n if (!remoteConfigClient) {\n return undefined;\n }\n const subscriptionId = remoteConfigClient.subscribe(key, 'all', callback);\n return {\n unsubscribe: () => {\n remoteConfigClient.unsubscribe(subscriptionId);\n },\n };\n};\n\nconst attachElementSelectorSurface = (amplitude: BrowserClient, selectorEngine: SelectorEngine): Unsubscribable => {\n // Expose a narrowed, read-only surface of the engine on the customer's\n // BrowserClient instance so downstream consumers can use the same engine the\n // SDK is running. Attach to the instance, not window.amplitude, so custom\n // global names and multiple SDK instances do not clobber each other.\n const elementSelectorClient = amplitude as BrowserClientWithElementSelector;\n const hadPreviousElementSelector = Object.prototype.hasOwnProperty.call(elementSelectorClient, 'elementSelector');\n const previousElementSelector = elementSelectorClient.elementSelector;\n const elementSelectorSurface: ElementSelectorPublicSurface = {\n generate: (el: Element): string => selectorEngine.generate(el),\n getConfig: () => selectorEngine.getConfig(),\n onConfigChange: (cb: (config: ResolvedSelectorConfig) => void): (() => void) => selectorEngine.onConfigChange(cb),\n };\n /* istanbul ignore next */\n elementSelectorClient.elementSelector = elementSelectorSurface;\n\n return {\n unsubscribe: () => {\n if (hadPreviousElementSelector) {\n elementSelectorClient.elementSelector = previousElementSelector;\n } else {\n delete elementSelectorClient.elementSelector;\n }\n },\n };\n};\n\nconst setupElementSelector = (\n config: BrowserConfig,\n amplitude: BrowserClient,\n dataExtractor: DataExtractor,\n): Unsubscribable[] => {\n const subscriptions: Unsubscribable[] = [];\n\n // Construct the engine eagerly with defaults so `dataExtractor.getElementPath`\n // can route through it from the first emission. When `enabled` is false in\n // the resolved config (the default), `getElementPath` falls back to the\n // legacy `cssPath` algorithm.\n const initialSelectorConfig = resolveSelectorConfig(undefined, config.loggerProvider);\n const selectorEngine = createSelectorEngine(initialSelectorConfig, { logger: config.loggerProvider });\n dataExtractor.setSelectorEngine(selectorEngine);\n\n subscriptions.push(attachElementSelectorSurface(amplitude, selectorEngine));\n\n if (config.fetchRemoteConfig) {\n const elementSelectorSubscription = subscribeRemoteConfig(\n config,\n 'configs.analyticsSDK.autocapture.elementSelector',\n (remoteSelectorConfig) => {\n const nextResolved = resolveSelectorConfig(\n remoteSelectorConfig as ElementSelectorRemoteConfig | undefined,\n config.loggerProvider,\n );\n selectorEngine.updateConfig(nextResolved);\n },\n );\n if (elementSelectorSubscription) {\n subscriptions.push(elementSelectorSubscription);\n }\n }\n\n return subscriptions;\n};\n\nexport type AutoCaptureOptionsWithDefaults = Required<\n Pick<ElementInteractionsOptions, 'debounceTime' | 'cssSelectorAllowlist' | 'actionClickAllowlist'>\n> &\n ElementInteractionsOptions;\n\nexport enum ObservablesEnum {\n ClickObservable = 'clickObservable',\n ChangeObservable = 'changeObservable',\n NavigateObservable = 'navigateObservable',\n MutationObservable = 'mutationObservable',\n ScrollObservable = 'scrollObservable',\n ExposureObservable = 'exposureObservable',\n BrowserErrorObservable = 'browserErrorObservable',\n SelectionObservable = 'selectionObservable',\n MouseMoveObservable = 'mouseMoveObservable',\n}\n\nexport interface AllWindowObservables {\n [ObservablesEnum.ChangeObservable]: Observable<ElementBasedTimestampedEvent<Event>>;\n // [ObservablesEnum.ErrorObservable]: Observable<TimestampedEvent<ErrorEvent>>;\n [ObservablesEnum.ClickObservable]: Observable<ElementBasedTimestampedEvent<MouseEvent>>;\n [ObservablesEnum.MutationObservable]: Observable<TimestampedEvent<MutationRecord[]>>;\n [ObservablesEnum.NavigateObservable]?: Observable<TimestampedEvent<NavigateEvent>>;\n [ObservablesEnum.ScrollObservable]: Observable<Event>; // TODO: add type for scroll event\n [ObservablesEnum.ExposureObservable]: Observable<Event>;\n [ObservablesEnum.SelectionObservable]?: Observable<void>;\n}\n\nexport const autocapturePlugin = (\n options: ElementInteractionsOptions = {},\n context?: { diagnosticsClient: IDiagnosticsClient },\n): BrowserEnrichmentPlugin => {\n // Set the plugin version tag\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n context?.diagnosticsClient.setTag('plugin.autocapture.version', VERSION);\n\n const {\n dataAttributePrefix = DEFAULT_DATA_ATTRIBUTE_PREFIX,\n visualTaggingOptions = {\n enabled: true,\n },\n } = options;\n\n options.cssSelectorAllowlist = options.cssSelectorAllowlist ?? DEFAULT_CSS_SELECTOR_ALLOWLIST;\n options.actionClickAllowlist = options.actionClickAllowlist ?? DEFAULT_ACTION_CLICK_ALLOWLIST;\n options.debounceTime = options.debounceTime ?? 0;\n const isViewportContentUpdatedEnabled = options.viewportContentUpdated?.enabled !== false;\n const resolvedExposureDuration =\n options.viewportContentUpdated?.exposureDuration ?? options.exposureDuration ?? DEFAULT_EXPOSURE_DURATION;\n options.viewportContentUpdated = {\n ...options.viewportContentUpdated,\n exposureDuration: resolvedExposureDuration,\n };\n\n options.pageUrlExcludelist = options.pageUrlExcludelist?.reduce(\n (acc: (string | RegExp | { pattern: string })[], excludePattern) => {\n if (typeof excludePattern === 'string') {\n acc.push(excludePattern);\n }\n if (excludePattern instanceof RegExp) {\n acc.push(excludePattern);\n }\n if (typeof excludePattern === 'object' && excludePattern !== null && 'pattern' in excludePattern) {\n try {\n acc.push(new RegExp(excludePattern.pattern));\n } catch (regexError) {\n console.warn(`Invalid regex pattern: ${excludePattern.pattern}`, regexError);\n return acc;\n }\n }\n return acc;\n },\n [],\n );\n\n const name = constants.PLUGIN_NAME;\n const type = 'enrichment';\n\n const subscriptions: Unsubscribable[] = [];\n\n const dataExtractor = new DataExtractor(options, context);\n\n // Page-level state shared across trackers, emitted in a single Page View End event on beforeunload\n // elementExposedForPage holds the total set of elements seen during the entire page view lifetime\n const elementExposedForPage = new Set<string>();\n // currentElementExposed only holds the set of elements that will be flushed during the next [Amplitude] Viewport Content Updated event\n const currentElementExposed = new Set<string>();\n\n let beforeUnloadCleanup: () => void;\n\n const createObservables = (): AllWindowObservables => {\n const clickObservable = multicast(\n createClickObservable().map(\n (click) =>\n dataExtractor.addAdditionalEventProperties(\n click,\n 'click',\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n dataAttributePrefix,\n ) as ElementBasedTimestampedEvent<MouseEvent>,\n ),\n );\n\n const changeObservable = multicast(\n new Observable<ElementBasedTimestampedEvent<Event>>((observer) => {\n const handler = (changeEvent: Event) => {\n const enrichedChangeEvent = dataExtractor.addAdditionalEventProperties(\n changeEvent,\n 'change',\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n dataAttributePrefix,\n ) as ElementBasedTimestampedEvent<Event>;\n observer.next(enrichedChangeEvent);\n };\n /* istanbul ignore next */\n getGlobalScope()?.document.addEventListener('change', handler, { capture: true });\n /* istanbul ignore next */\n return () => getGlobalScope()?.document.removeEventListener('change', handler);\n }),\n );\n\n // Create observable for URL changes\n let navigateObservable: Observable<TimestampedEvent<NavigateEvent>> | undefined;\n\n /* istanbul ignore next */\n if (window.navigation) {\n navigateObservable = multicast(\n new Observable<TimestampedEvent<NavigateEvent>>((observer) => {\n const handler = (navigateEvent: NavigateEvent) => {\n const enrichedNavigateEvent = dataExtractor.addAdditionalEventProperties(\n navigateEvent,\n 'navigate',\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n dataAttributePrefix,\n );\n observer.next(enrichedNavigateEvent);\n };\n window.navigation.addEventListener('navigate', handler as EventListener);\n return () => {\n window.navigation.removeEventListener('navigate', handler as EventListener);\n };\n }),\n );\n }\n\n const mutationObservable = multicast(\n createMutationObservable().map((mutation) =>\n dataExtractor.addAdditionalEventProperties(\n mutation,\n 'mutation',\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n dataAttributePrefix,\n ),\n ),\n );\n\n const scrollObservable = createScrollObservable();\n\n const exposureObservable = createExposureObservable(\n mutationObservable,\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n );\n\n return {\n [ObservablesEnum.ChangeObservable]: changeObservable,\n // [ObservablesEnum.ErrorObservable]: errorObservable,\n [ObservablesEnum.ClickObservable]: clickObservable,\n [ObservablesEnum.MutationObservable]: mutationObservable,\n [ObservablesEnum.NavigateObservable]: navigateObservable,\n [ObservablesEnum.ScrollObservable]: scrollObservable,\n [ObservablesEnum.ExposureObservable]: exposureObservable,\n };\n };\n\n // Group labeled events by event type (eg. click, change)\n let groupedLabeledEvents = groupLabeledEventIdsByEventType(Object.values(options.pageActions?.labeledEvents ?? {}));\n\n let labeledEventToTriggerMap = createLabeledEventToTriggerMap(options.pageActions?.triggers ?? []);\n\n // Evaluate triggers for the given event by running the actions associated with the matching triggers\n const evaluateTriggers = createTriggerEvaluator(\n groupedLabeledEvents,\n labeledEventToTriggerMap,\n dataExtractor,\n options,\n );\n\n // Function to recalculate internal variables when remote config is updated\n const recomputePageActionsData = (remotePageActions: ElementInteractionsOptions['pageActions']) => {\n if (remotePageActions) {\n // Merge remote config with local options\n options.pageActions = {\n ...options.pageActions,\n ...remotePageActions,\n };\n\n // Recalculate internal variables\n groupedLabeledEvents = groupLabeledEventIdsByEventType(Object.values(options.pageActions.labeledEvents ?? {}));\n labeledEventToTriggerMap = createLabeledEventToTriggerMap(options.pageActions.triggers ?? []);\n\n // Update evaluateTriggers function\n evaluateTriggers.update(groupedLabeledEvents, labeledEventToTriggerMap, options);\n }\n };\n\n const setup: BrowserEnrichmentPlugin['setup'] = async (config, amplitude) => {\n /* istanbul ignore if */\n if (typeof document === 'undefined') {\n return;\n }\n\n let pageViewEndFired = false;\n const lastScroll: { maxX: undefined | number; maxY: undefined | number } = { maxX: undefined, maxY: undefined };\n\n // Fetch remote config for pageActions in a non-blocking manner\n if (config.fetchRemoteConfig) {\n if (!config.remoteConfigClient) {\n // TODO(xinyi): Diagnostics.recordEvent\n config.loggerProvider.debug('Remote config client is not provided, skipping remote config fetch');\n } else {\n const pageActionsSubscription = subscribeRemoteConfig(\n config,\n 'configs.analyticsSDK.pageActions',\n (remoteConfig) => {\n recomputePageActionsData(remoteConfig as ElementInteractionsOptions['pageActions']);\n },\n );\n if (pageActionsSubscription) {\n subscriptions.push(pageActionsSubscription);\n }\n }\n }\n\n subscriptions.push(...setupElementSelector(config, amplitude, dataExtractor));\n\n // Create should track event functions the different allowlists\n const shouldTrackEvent = createShouldTrackEvent(\n options,\n (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist,\n );\n const shouldTrackActionClick = createShouldTrackEvent(\n options,\n (options as AutoCaptureOptionsWithDefaults).actionClickAllowlist,\n );\n\n // Create observables for events on the window\n const allObservables = createObservables();\n\n // Create subscriptions\n const clickTrackingSubscription = trackClicks({\n allObservables,\n amplitude,\n shouldTrackEvent: shouldTrackEvent,\n evaluateTriggers: evaluateTriggers.evaluate.bind(evaluateTriggers),\n });\n\n subscriptions.push(clickTrackingSubscription);\n\n const changeSubscription = trackChange({\n allObservables,\n getEventProperties: (...args) => dataExtractor.getEventProperties(...args, dataAttributePrefix),\n amplitude,\n shouldTrackEvent: shouldTrackEvent,\n evaluateTriggers: evaluateTriggers.evaluate.bind(evaluateTriggers),\n });\n subscriptions.push(changeSubscription);\n\n const actionClickSubscription = trackActionClick({\n allObservables,\n options: options as AutoCaptureOptionsWithDefaults,\n getEventProperties: (...args) => dataExtractor.getEventProperties(...args, dataAttributePrefix),\n amplitude,\n shouldTrackEvent,\n shouldTrackActionClick: shouldTrackActionClick,\n });\n if (actionClickSubscription) {\n subscriptions.push(actionClickSubscription);\n }\n\n const scrollTracker = trackScroll({\n allObservables,\n amplitude,\n });\n subscriptions.push(scrollTracker);\n\n const trackers: { exposure?: ExposureTracker & Unsubscribable } = {};\n\n const globalScope = getGlobalScope();\n\n const handleViewportContentUpdated = (isPageEnd: boolean) => {\n if (isPageEnd && pageViewEndFired) {\n return;\n }\n setTimeout(() => {\n pageViewEndFired = false;\n }, 100);\n\n pageViewEndFired = true;\n fireViewportContentUpdated({\n amplitude,\n scrollTracker,\n currentElementExposed,\n elementExposedForPage,\n exposureTracker: trackers.exposure,\n isPageEnd,\n lastScroll,\n });\n };\n\n const handleExposure = (elementPath: string) => {\n onExposure(elementPath, elementExposedForPage, currentElementExposed, handleViewportContentUpdated);\n };\n\n if (isViewportContentUpdatedEnabled) {\n trackers.exposure = trackExposure({\n allObservables,\n onExposure: handleExposure,\n dataExtractor,\n exposureDuration: resolvedExposureDuration,\n });\n if (trackers.exposure) {\n subscriptions.push(trackers.exposure);\n }\n\n const beforeUnloadHandler = () => {\n handleViewportContentUpdated(true);\n };\n /* istanbul ignore next */\n globalScope?.addEventListener('beforeunload', beforeUnloadHandler);\n beforeUnloadCleanup = () => {\n /* istanbul ignore next */\n globalScope?.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n // Ensure cleanup on teardown as well\n subscriptions.push({ unsubscribe: () => beforeUnloadCleanup() });\n\n // Also track on navigation (SPA)\n const navigateObservable = allObservables[ObservablesEnum.NavigateObservable];\n if (navigateObservable) {\n subscriptions.push(\n navigateObservable.subscribe(() => {\n handleViewportContentUpdated(true);\n }),\n );\n } else if (globalScope) {\n const popstateHandler = () => {\n handleViewportContentUpdated(true);\n };\n /* istanbul ignore next */\n // Fallback for SPA tracking when Navigation API is not available\n globalScope.addEventListener('popstate', popstateHandler);\n\n /* istanbul ignore next */\n // There is no global browser listener for changes to history, so we have\n // to modify pushState directly.\n // https://stackoverflow.com/a/64927639\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalPushState = globalScope.history.pushState;\n if (globalScope.history && originalPushState) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n globalScope.history.pushState = new Proxy(originalPushState, {\n apply: (target, thisArg, [state, unused, url]) => {\n target.apply(thisArg, [state, unused, url]);\n handleViewportContentUpdated(true);\n },\n });\n }\n\n subscriptions.push({\n unsubscribe: () => {\n /* istanbul ignore next */\n globalScope.removeEventListener('popstate', popstateHandler);\n /* istanbul ignore next */\n if (globalScope.history && originalPushState) {\n globalScope.history.pushState = originalPushState;\n }\n },\n });\n }\n }\n\n /* istanbul ignore next */\n config?.loggerProvider?.log(`${name} has been successfully added.`);\n\n // Setup visual tagging and background capture on the shared messenger singleton.\n // Using the singleton ensures a single message listener per page, even when\n // session-replay is also loaded.\n if (window.opener && visualTaggingOptions.enabled) {\n const allowlist = (options as AutoCaptureOptionsWithDefaults).cssSelectorAllowlist;\n const actionClickAllowlist = (options as AutoCaptureOptionsWithDefaults).actionClickAllowlist;\n\n const messenger = getOrCreateWindowMessenger();\n enableVisualTagging(messenger, {\n dataExtractor,\n isElementSelectable: createShouldTrackEvent(options, [...allowlist, ...actionClickAllowlist]),\n cssSelectorAllowlist: allowlist,\n actionClickAllowlist,\n });\n enableBackgroundCapture(messenger);\n /* istanbul ignore next */\n messenger.setup({\n logger: config?.loggerProvider,\n ...(config?.serverZone && { endpoint: constants.AMPLITUDE_ORIGINS_MAP[config.serverZone] }),\n });\n }\n };\n\n const execute: BrowserEnrichmentPlugin['execute'] = async (event) => {\n return event;\n };\n\n const teardown = async () => {\n for (const subscription of subscriptions) {\n subscription.unsubscribe();\n }\n };\n\n return {\n name,\n type,\n setup,\n execute,\n teardown,\n };\n};\n"]}
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { ElementInteractionsOptions, ActionType, IDiagnosticsClient } from '@amplitude/analytics-core';
|
|
2
2
|
import type { DataSource } from '@amplitude/analytics-core/lib/esm/types/element-interactions';
|
|
3
|
+
import type { SelectorEngine } from '@amplitude/element-selector';
|
|
3
4
|
import type { BaseTimestampedEvent, ElementBasedTimestampedEvent, TimestampedEvent, JSONValue } from './helpers';
|
|
4
5
|
import { Hierarchy } from './typings/autocapture';
|
|
5
6
|
export declare class DataExtractor {
|
|
6
7
|
private readonly additionalMaskTextPatterns;
|
|
7
8
|
diagnosticsClient?: IDiagnosticsClient;
|
|
9
|
+
/**
|
|
10
|
+
* Optional v1 selector engine. When set AND `engine.getConfig().enabled` is
|
|
11
|
+
* true, `getElementPath()` routes through the v1 engine instead of the
|
|
12
|
+
* legacy positional `cssPath`. When the engine is absent or its `enabled`
|
|
13
|
+
* flag is false, this is a no-op and selector emission is byte-identical to
|
|
14
|
+
* pre-integration behavior.
|
|
15
|
+
*
|
|
16
|
+
* The engine is set after construction (via `setSelectorEngine`) because
|
|
17
|
+
* it depends on `config.loggerProvider` and `config.remoteConfigClient`,
|
|
18
|
+
* which only become available in the plugin's async `setup()` flow.
|
|
19
|
+
*/
|
|
20
|
+
private selectorEngine?;
|
|
8
21
|
constructor(options: ElementInteractionsOptions, context?: {
|
|
9
22
|
diagnosticsClient: IDiagnosticsClient;
|
|
10
23
|
});
|
|
@@ -16,6 +29,14 @@ export declare class DataExtractor {
|
|
|
16
29
|
replaceSensitiveString: (text: string | null) => string;
|
|
17
30
|
getHierarchy: (element: Element | null) => Hierarchy;
|
|
18
31
|
getNearestLabel: (element: Element) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Attach (or replace) the v1 selector engine. Called by the autocapture
|
|
34
|
+
* plugin's `setup()` once `config.loggerProvider` / `remoteConfigClient`
|
|
35
|
+
* are available; the engine is shared (not copied) so subsequent
|
|
36
|
+
* `engine.updateConfig(...)` calls driven by remote config take effect on
|
|
37
|
+
* the very next selector emission with no additional plumbing.
|
|
38
|
+
*/
|
|
39
|
+
setSelectorEngine: (engine: SelectorEngine | undefined) => void;
|
|
19
40
|
getElementPath: (element: Element | null) => string;
|
|
20
41
|
getEventProperties: (actionType: ActionType, element: Element, dataAttributePrefix: string) => {
|
|
21
42
|
[key: string]: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-extractor.d.ts","sourceRoot":"","sources":["../../src/data-extractor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,UAAU,EAEV,kBAAkB,EAKnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;
|
|
1
|
+
{"version":3,"file":"data-extractor.d.ts","sourceRoot":"","sources":["../../src/data-extractor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,UAAU,EAEV,kBAAkB,EAKnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAC/F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAWlE,OAAO,KAAK,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGjH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAW;IACtD,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;IAEvC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,cAAc,CAAC,CAAiB;gBAE5B,OAAO,EAAE,0BAA0B,EAAE,OAAO,CAAC,EAAE;QAAE,iBAAiB,EAAE,kBAAkB,CAAA;KAAE;IAuBpG;;;;OAIG;IACH,sBAAsB,SAAU,MAAM,GAAG,IAAI,KAAG,MAAM,CAEpD;IAGF,YAAY,YAAa,OAAO,GAAG,IAAI,eA4CrC;IAEF,eAAe,YAAa,OAAO,KAAG,MAAM,CAiB1C;IAEF;;;;;;OAMG;IACH,iBAAiB,WAAY,cAAc,GAAG,SAAS,KAAG,IAAI,CAE5D;IAEF,cAAc,YAAa,OAAO,GAAG,IAAI,KAAG,MAAM,CAwBhD;IAGF,kBAAkB,eAAgB,UAAU,WAAW,OAAO,uBAAuB,MAAM;;MAmDzF;IAEF,mBAAmB,oJASjB;IAEF,4BAA4B,0GAGP,MAAM,EAAE,uBACN,MAAM,6DAmC3B;IAEF,yBAAyB,eAAgB,UAAU,kBAAkB,WAAW,+BAkB9E;IAIF,OAAO,CAAC,4BAA4B,CA2BlC;IAEF,OAAO,YAAa,OAAO,KAAG,MAAM,CAalC;IAGF,gBAAgB,YAAa,OAAO,KAAG,OAAO,MAAM,EAAE,SAAS,CAAC,CAa9D;CACH"}
|
|
@@ -5,7 +5,7 @@ import * as constants from './constants';
|
|
|
5
5
|
import { removeEmptyProperties, extractPrefixedAttributes, isElementPointerCursor, getClosestElement, isElementBasedEvent, parseAttributesToMask, getCurrentPageViewId, } from './helpers';
|
|
6
6
|
import { getAncestors, getElementProperties } from './hierarchy';
|
|
7
7
|
import { getDataSource } from './pageActions/actions';
|
|
8
|
-
import {
|
|
8
|
+
import { DEFAULT_RESOLVED_CONFIG, generateSelector } from '@amplitude/element-selector';
|
|
9
9
|
var DataExtractor = /** @class */ (function () {
|
|
10
10
|
function DataExtractor(options, context) {
|
|
11
11
|
var e_1, _a;
|
|
@@ -89,15 +89,37 @@ var DataExtractor = /** @class */ (function () {
|
|
|
89
89
|
}
|
|
90
90
|
return _this.getNearestLabel(parent);
|
|
91
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Attach (or replace) the v1 selector engine. Called by the autocapture
|
|
94
|
+
* plugin's `setup()` once `config.loggerProvider` / `remoteConfigClient`
|
|
95
|
+
* are available; the engine is shared (not copied) so subsequent
|
|
96
|
+
* `engine.updateConfig(...)` calls driven by remote config take effect on
|
|
97
|
+
* the very next selector emission with no additional plumbing.
|
|
98
|
+
*/
|
|
99
|
+
this.setSelectorEngine = function (engine) {
|
|
100
|
+
_this.selectorEngine = engine;
|
|
101
|
+
};
|
|
92
102
|
this.getElementPath = function (element) {
|
|
93
|
-
var _a;
|
|
103
|
+
var _a, _b;
|
|
94
104
|
if (!element) {
|
|
95
105
|
return '';
|
|
96
106
|
}
|
|
97
107
|
var startTime = performance.now();
|
|
98
|
-
|
|
108
|
+
// All routing — engine vs. legacy `cssPath`, plus the strategy-chain
|
|
109
|
+
// safety net — lives inside `@amplitude/element-selector` now. We pass
|
|
110
|
+
// the engine if we have one (any value of `getConfig().enabled`; the
|
|
111
|
+
// engine itself handles the kill switch internally) and `null` when
|
|
112
|
+
// we don't (frustration-plugin code path, pre-setup, remote-config
|
|
113
|
+
// never loaded). In the null branch, `generateSelector` calls
|
|
114
|
+
// `legacyCssPath` directly, byte-identical to the pre-integration
|
|
115
|
+
// behavior.
|
|
116
|
+
//
|
|
117
|
+
// The `DEFAULT_RESOLVED_CONFIG` passed here is only consulted on the
|
|
118
|
+
// null-engine branch where it functions as a placeholder; when the
|
|
119
|
+
// engine is present, the engine's own internal config wins.
|
|
120
|
+
var elementPath = generateSelector(element, (_a = _this.selectorEngine) !== null && _a !== void 0 ? _a : null, DEFAULT_RESOLVED_CONFIG);
|
|
99
121
|
var endTime = performance.now();
|
|
100
|
-
(
|
|
122
|
+
(_b = _this.diagnosticsClient) === null || _b === void 0 ? void 0 : _b.recordHistogram('autocapturePlugin.getElementPath', endTime - startTime);
|
|
101
123
|
return elementPath;
|
|
102
124
|
};
|
|
103
125
|
// Returns the Amplitude event properties for the given element.
|