@amplitude/plugin-autocapture-browser 0.11.0 → 1.0.0-beta.1
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/constants.d.ts +1 -1
- package/lib/cjs/constants.d.ts.map +1 -1
- package/lib/cjs/constants.js +1 -1
- package/lib/cjs/constants.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/constants.d.ts +1 -1
- package/lib/esm/constants.d.ts.map +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/constants.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.umd.js +1 -1
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/constants.d.ts +1 -1
- package/lib/scripts/constants.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 +2 -2
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -25,6 +25,6 @@ export declare const AMPLITUDE_ORIGINS_MAP: {
|
|
|
25
25
|
EU: string;
|
|
26
26
|
STAGING: string;
|
|
27
27
|
};
|
|
28
|
-
export declare const AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = "https://cdn.amplitude.com/libs/visual-tagging-selector-0.
|
|
28
|
+
export declare const AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = "https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz";
|
|
29
29
|
export declare const AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = "amp-visual-tagging-selector-highlight";
|
|
30
30
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,0CAA0C,CAAC;AAEnE,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAC7E,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAE7E,eAAO,MAAM,+BAA+B,2BAA2B,CAAC;AACxE,eAAO,MAAM,kCAAkC,8BAA8B,CAAC;AAC9E,eAAO,MAAM,gCAAgC,4BAA4B,CAAC;AAC1E,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAC5E,eAAO,MAAM,sCAAsC,kCAAkC,CAAC;AACtF,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAC5E,eAAO,MAAM,0CAA0C,sCAAsC,CAAC;AAC9F,eAAO,MAAM,yCAAyC,qCAAqC,CAAC;AAC5F,eAAO,MAAM,uCAAuC,mCAAmC,CAAC;AACxF,eAAO,MAAM,uCAAuC,mCAAmC,CAAC;AAExF,eAAO,MAAM,qCAAqC,iCAAiC,CAAC;AAEpF,eAAO,MAAM,yCAAyC,qCAAqC,CAAC;AAC5F,eAAO,MAAM,6BAA6B,yBAAyB,CAAC;AACpE,eAAO,MAAM,+BAA+B,2BAA2B,CAAC;AACxE,eAAO,MAAM,oCAAoC,gCAAgC,CAAC;AAClF,eAAO,MAAM,mCAAmC,+BAA+B,CAAC;AAGhF,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAC5D,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAClE,eAAO,MAAM,wBAAwB,qCAAqC,CAAC;AAC3E,eAAO,MAAM,qBAAqB;;;;CAIjC,CAAC;AAEF,eAAO,MAAM,4CAA4C,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,0CAA0C,CA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ING_SELECTOR_SCRIPT_URL = 'https://cdn.amplitude.com/libs/visual-tagging-selector-0.
|
|
32
|
+
exports.AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = 'https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz';
|
|
33
33
|
// This is the class name used by the visual tagging selector to highlight the selected element.
|
|
34
34
|
// Should not use this class in the selector.
|
|
35
35
|
exports.AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = 'amp-visual-tagging-selector-highlight';
|
package/lib/cjs/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;AAAa,QAAA,WAAW,GAAG,uCAAuC,CAAC;AAEtD,QAAA,+BAA+B,GAAG,6BAA6B,CAAC;AAChE,QAAA,+BAA+B,GAAG,6BAA6B,CAAC;AAEhE,QAAA,+BAA+B,GAAG,wBAAwB,CAAC;AAC3D,QAAA,kCAAkC,GAAG,2BAA2B,CAAC;AACjE,QAAA,gCAAgC,GAAG,yBAAyB,CAAC;AAC7D,QAAA,iCAAiC,GAAG,0BAA0B,CAAC;AAC/D,QAAA,sCAAsC,GAAG,+BAA+B,CAAC;AACzE,QAAA,iCAAiC,GAAG,0BAA0B,CAAC;AAC/D,QAAA,0CAA0C,GAAG,mCAAmC,CAAC;AACjF,QAAA,yCAAyC,GAAG,kCAAkC,CAAC;AAC/E,QAAA,uCAAuC,GAAG,gCAAgC,CAAC;AAC3E,QAAA,uCAAuC,GAAG,gCAAgC,CAAC;AACxF,sGAAsG;AACzF,QAAA,qCAAqC,GAAG,8BAA8B,CAAC;AAEvE,QAAA,yCAAyC,GAAG,kCAAkC,CAAC;AAC/E,QAAA,6BAA6B,GAAG,sBAAsB,CAAC;AACvD,QAAA,+BAA+B,GAAG,wBAAwB,CAAC;AAC3D,QAAA,oCAAoC,GAAG,6BAA6B,CAAC;AACrE,QAAA,mCAAmC,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,CAAC;AAC/C,QAAA,mBAAmB,GAAG,8BAA8B,CAAC;AACrD,QAAA,wBAAwB,GAAG,kCAAkC,CAAC;AAC9D,QAAA,qBAAqB,GAAG;IACnC,EAAE,EAAE,wBAAgB;IACpB,EAAE,EAAE,2BAAmB;IACvB,OAAO,EAAE,gCAAwB;CAClC,CAAC;AAEW,QAAA,4CAA4C,GACvD,0EAA0E,CAAC;AAC7E,gGAAgG;AAChG,6CAA6C;AAChC,QAAA,wCAAwC,GAAG,uCAAuC,CAAC","sourcesContent":["export const PLUGIN_NAME = '@amplitude/plugin-autocapture-browser';\n\nexport const AMPLITUDE_ELEMENT_CLICKED_EVENT = '[Amplitude] Element Clicked';\nexport const AMPLITUDE_ELEMENT_CHANGED_EVENT = '[Amplitude] Element Changed';\n\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_ID = '[Amplitude] Element ID';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_CLASS = '[Amplitude] Element Class';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_TAG = '[Amplitude] Element Tag';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_TEXT = '[Amplitude] Element Text';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_HIERARCHY = '[Amplitude] Element Hierarchy';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_HREF = '[Amplitude] Element Href';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_POSITION_LEFT = '[Amplitude] Element Position Left';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_POSITION_TOP = '[Amplitude] Element Position Top';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_ARIA_LABEL = '[Amplitude] Element Aria Label';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_ATTRIBUTES = '[Amplitude] Element Attributes';\n// Deprecated in favor of AMPLITUDE_EVENT_PROP_ELEMENT_HIERARCHY. Keeping for backwards compatibility.\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_SELECTOR = '[Amplitude] Element Selector';\n\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_PARENT_LABEL = '[Amplitude] Element Parent Label';\nexport const AMPLITUDE_EVENT_PROP_PAGE_URL = '[Amplitude] Page URL';\nexport const AMPLITUDE_EVENT_PROP_PAGE_TITLE = '[Amplitude] Page Title';\nexport const AMPLITUDE_EVENT_PROP_VIEWPORT_HEIGHT = '[Amplitude] Viewport Height';\nexport const AMPLITUDE_EVENT_PROP_VIEWPORT_WIDTH = '[Amplitude] Viewport Width';\n\n// Visual Tagging related constants\nexport const AMPLITUDE_ORIGIN = 'https://app.amplitude.com';\nexport const AMPLITUDE_ORIGIN_EU = 'https://app.eu.amplitude.com';\nexport const AMPLITUDE_ORIGIN_STAGING = 'https://apps.stag2.amplitude.com';\nexport const AMPLITUDE_ORIGINS_MAP = {\n US: AMPLITUDE_ORIGIN,\n EU: AMPLITUDE_ORIGIN_EU,\n STAGING: AMPLITUDE_ORIGIN_STAGING,\n};\n\nexport const AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL =\n 'https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz';\n// This is the class name used by the visual tagging selector to highlight the selected element.\n// Should not use this class in the selector.\nexport const AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = 'amp-visual-tagging-selector-highlight';\n"]}
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "1.0.0-beta.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,iBAAiB,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,cAAc,CAAC","sourcesContent":["export const VERSION = '1.0.0-beta.0';\n"]}
|
package/lib/esm/constants.d.ts
CHANGED
|
@@ -25,6 +25,6 @@ export declare const AMPLITUDE_ORIGINS_MAP: {
|
|
|
25
25
|
EU: string;
|
|
26
26
|
STAGING: string;
|
|
27
27
|
};
|
|
28
|
-
export declare const AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = "https://cdn.amplitude.com/libs/visual-tagging-selector-0.
|
|
28
|
+
export declare const AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = "https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz";
|
|
29
29
|
export declare const AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = "amp-visual-tagging-selector-highlight";
|
|
30
30
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,0CAA0C,CAAC;AAEnE,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAC7E,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAE7E,eAAO,MAAM,+BAA+B,2BAA2B,CAAC;AACxE,eAAO,MAAM,kCAAkC,8BAA8B,CAAC;AAC9E,eAAO,MAAM,gCAAgC,4BAA4B,CAAC;AAC1E,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAC5E,eAAO,MAAM,sCAAsC,kCAAkC,CAAC;AACtF,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O,MAAM,uCAAuC,mCAAmC,CAAC;AAExF,eAAO,MAAM,qCAAqC,iCAAiC,CAAC;AAEpF,eAAO,MAAM,yCAAyC,qCAAqC,CAAC;AAC5F,eAAO,MAAM,6BAA6B,yBAAyB,CAAC;AACpE,eAAO,MAAM,+BAA+B,2BAA2B,CAAC;AACxE,eAAO,MAAM,oCAAoC,gCAAgC,CAAC;AAClF,eAAO,MAAM,mCAAmC,+BAA+B,CAAC;AAGhF,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAC5D,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAClE,eAAO,MAAM,wBAAwB,qCAAqC,CAAC;AAC3E,eAAO,MAAM,qBAAqB;;;;CAIjC,CAAC;AAEF,eAAO,MAAM,4CAA4C,6EACmB,CAAC;AAG7E,eAAO,MAAM,wCAAwC,0CAA0C,CAAC"}
|
package/lib/esm/constants.js
CHANGED
|
@@ -27,7 +27,7 @@ export var AMPLITUDE_ORIGINS_MAP = {
|
|
|
27
27
|
EU: AMPLITUDE_ORIGIN_EU,
|
|
28
28
|
STAGING: AMPLITUDE_ORIGIN_STAGING,
|
|
29
29
|
};
|
|
30
|
-
export var AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = 'https://cdn.amplitude.com/libs/visual-tagging-selector-0.
|
|
30
|
+
export var AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = 'https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz';
|
|
31
31
|
// This is the class name used by the visual tagging selector to highlight the selected element.
|
|
32
32
|
// Should not use this class in the selector.
|
|
33
33
|
export var AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = 'amp-visual-tagging-selector-highlight';
|
package/lib/esm/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,WAAW,GAAG,uCA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AAM,CAAC,IAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAC5D,MAAM,CAAC,IAAM,mBAAmB,GAAG,8BAA8B,CAAC;AAClE,MAAM,CAAC,IAAM,wBAAwB,GAAG,kCAAkC,CAAC;AAC3E,MAAM,CAAC,IAAM,qBAAqB,GAAG;IACnC,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,mBAAmB;IACvB,OAAO,EAAE,wBAAwB;CAClC,CAAC;AAEF,MAAM,CAAC,IAAM,4CAA4C,GACvD,0EAA0E,CAAC;AAC7E,gGAAgG;AAChG,6CAA6C;AAC7C,MAAM,CAAC,IAAM,wCAAwC,GAAG,uCAAuC,CAAC","sourcesContent":["export const PLUGIN_NAME = '@amplitude/plugin-autocapture-browser';\n\nexport const AMPLITUDE_ELEMENT_CLICKED_EVENT = '[Amplitude] Element Clicked';\nexport const AMPLITUDE_ELEMENT_CHANGED_EVENT = '[Amplitude] Element Changed';\n\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_ID = '[Amplitude] Element ID';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_CLASS = '[Amplitude] Element Class';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_TAG = '[Amplitude] Element Tag';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_TEXT = '[Amplitude] Element Text';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_HIERARCHY = '[Amplitude] Element Hierarchy';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_HREF = '[Amplitude] Element Href';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_POSITION_LEFT = '[Amplitude] Element Position Left';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_POSITION_TOP = '[Amplitude] Element Position Top';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_ARIA_LABEL = '[Amplitude] Element Aria Label';\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_ATTRIBUTES = '[Amplitude] Element Attributes';\n// Deprecated in favor of AMPLITUDE_EVENT_PROP_ELEMENT_HIERARCHY. Keeping for backwards compatibility.\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_SELECTOR = '[Amplitude] Element Selector';\n\nexport const AMPLITUDE_EVENT_PROP_ELEMENT_PARENT_LABEL = '[Amplitude] Element Parent Label';\nexport const AMPLITUDE_EVENT_PROP_PAGE_URL = '[Amplitude] Page URL';\nexport const AMPLITUDE_EVENT_PROP_PAGE_TITLE = '[Amplitude] Page Title';\nexport const AMPLITUDE_EVENT_PROP_VIEWPORT_HEIGHT = '[Amplitude] Viewport Height';\nexport const AMPLITUDE_EVENT_PROP_VIEWPORT_WIDTH = '[Amplitude] Viewport Width';\n\n// Visual Tagging related constants\nexport const AMPLITUDE_ORIGIN = 'https://app.amplitude.com';\nexport const AMPLITUDE_ORIGIN_EU = 'https://app.eu.amplitude.com';\nexport const AMPLITUDE_ORIGIN_STAGING = 'https://apps.stag2.amplitude.com';\nexport const AMPLITUDE_ORIGINS_MAP = {\n US: AMPLITUDE_ORIGIN,\n EU: AMPLITUDE_ORIGIN_EU,\n STAGING: AMPLITUDE_ORIGIN_STAGING,\n};\n\nexport const AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL =\n 'https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz';\n// This is the class name used by the visual tagging selector to highlight the selected element.\n// Should not use this class in the selector.\nexport const AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = 'amp-visual-tagging-selector-highlight';\n"]}
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "1.0.0-beta.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/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,iBAAiB,CAAC"}
|
package/lib/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var VERSION = '0.
|
|
1
|
+
export var VERSION = '1.0.0-beta.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/lib/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,cAAc,CAAC","sourcesContent":["export const VERSION = '1.0.0-beta.0';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var amplitudeAutocapturePlugin=function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(o,i){function l(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,a)}u((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,o,i,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=l.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)l.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return l}function l(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var a,u,c="[Amplitude] Element Tag",d="[Amplitude] Element Text",s="[Amplitude] Element Selector",f="[Amplitude] Page URL",v="https://app.amplitude.com",p={US:v,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},g="amp-visual-tagging-selector-highlight";function h(e,n){if(e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var r={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};a=t(t({},r),n),u=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(a.root,r);var o=m(e,"all",(function(){return m(e,"two",(function(){return m(e,"one",(function(){return m(e,"none")}))}))}));if(o){var i=C(L(o,e));return i.length>0&&(o=i[0]),w(o)}throw new Error("Selector was not found.")}function m(e,t,n){for(var r=null,u=[],c=e,d=0,s=function(){var e,s,f=k(function(e){var t=e.getAttribute("id");if(t&&a.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(c))||k.apply(void 0,l([],i(function(e){var t=Array.from(e.attributes).filter((function(e){return a.attr(e.name,e.value)}));return t.map((function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}}))}(c)),!1))||k.apply(void 0,l([],i(function(e){var t=Array.from(e.classList).filter(a.className);return t.map((function(e){return{name:"."+CSS.escape(e),penalty:1}}))}(c)),!1))||k(function(e){var t=e.tagName.toLowerCase();if(a.tagName(t))return{name:t,penalty:2};return null}(c))||[{name:"*",penalty:3}],v=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;var r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(c);if("all"==t)v&&(f=f.concat(f.filter(A).map((function(e){return S(e,v)}))));else if("two"==t)f=f.slice(0,1),v&&(f=f.concat(f.filter(A).map((function(e){return S(e,v)}))));else if("one"==t){var p=i(f=f.slice(0,1),1)[0];v&&A(p)&&(f=[S(p,v)])}else"none"==t&&(f=[{name:"*",penalty:3}],v&&(f=[S(f[0],v)]));try{for(var g=(e=void 0,o(f)),h=g.next();!h.done;h=g.next()){(p=h.value).level=d}}catch(t){e={error:t}}finally{try{h&&!h.done&&(s=g.return)&&s.call(g)}finally{if(e)throw e.error}}if(u.push(f),u.length>=a.seedMinLength&&(r=y(u,n)))return"break";c=c.parentElement,d++};c;){if("break"===s())break}return r||(r=y(u,n)),!r&&n?n():r}function y(e,t){var n,r,i=C(T(e));if(i.length>a.threshold)return t?t():null;try{for(var l=o(i),u=l.next();!u.done;u=l.next()){var c=u.value;if(E(c))return c}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return null}function w(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var o=e[r].level||0;n=t.level===o-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function b(e){return e.map((function(e){return e.penalty})).reduce((function(e,t){return e+t}),0)}function E(e){var t=w(e);switch(u.querySelectorAll(t).length){case 0:throw new Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function S(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function A(e){return"html"!==e.name&&!e.name.startsWith("#")}function k(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(N);return n.length>0?n:null}function N(e){return null!=e}function T(e,t){var n,i,l,a,u,c;return void 0===t&&(t=[]),r(this,(function(r){switch(r.label){case 0:if(!(e.length>0))return[3,9];r.label=1;case 1:r.trys.push([1,6,7,8]),n=o(e[0]),i=n.next(),r.label=2;case 2:return i.done?[3,5]:(l=i.value,[5,o(T(e.slice(1,e.length),t.concat(l)))]);case 3:r.sent(),r.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return a=r.sent(),u={error:a},[3,8];case 7:try{i&&!i.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:r.sent(),r.label=11;case 11:return[2]}}))}function C(e){return l([],i(e),!1).sort((function(e,t){return b(e)-b(t)}))}function L(e,t,n){var c,d,s;return void 0===n&&(n={counter:0,visited:new Map}),r(this,(function(r){switch(r.label){case 0:if(!(e.length>2&&e.length>a.optimizedMinLength))return[3,5];c=1,r.label=1;case 1:return c<e.length-1?n.counter>a.maxNumberOfTries?[2]:(n.counter+=1,(d=l([],i(e),!1)).splice(c,1),s=w(d),n.visited.has(s)?[2]:E(d)&&function(e,t){return u.querySelector(w(e))===t}(d,t)?[4,d]:[3,4]):[3,5];case 2:return r.sent(),n.visited.set(s,!0),[5,o(L(d,t,n))];case 3:r.sent(),r.label=4;case 4:return c++,[3,1];case 5:return[2]}}))}var x=["input","select","textarea"],O=function(e){if(null==e)return!1;if("string"==typeof e){if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0},M=function(e){var t,n,r=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o="true"===e.getAttribute("contenteditable");return!x.includes(r)&&!o},P=function(e){var t="";return M(e)&&e.childNodes&&e.childNodes.length&&e.childNodes.forEach((function(e){var n,r="";(n=e)&&3===n.nodeType?e.textContent&&(r=e.textContent):r=P(e),t+=r.split(/(\s+)/).filter(O).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)})),t},q=function(e,t){var n,r,o="";try{return o=h(e,{className:function(e){return e!==g}})}catch(e){if(t){var i=e;t.warn("Failed to get selector with finder, use fallback strategy instead: ".concat(i.toString()))}}var l=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n);if(l&&(o=l),e.id)o="#".concat(e.id);else if(e.className){var a=e.className.split(" ").filter((function(e){return e!==g})).join(".");a&&(o="".concat(o,".").concat(a))}return o},j=function(e){return Object.keys(e).reduce((function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t}),{})},R=function(e){var t=e.parentElement;if(!t)return"";var n=t.querySelector(":scope>span,h1,h2,h3,h4,h5,h6");if(n){var r=n.textContent||"";return O(r)?r:""}return R(t)},D=function(e,t){if(e&&"querySelectorAll"in e&&"function"==typeof e.querySelectorAll){var n=t.reduce((function(t,n){n&&Array.from(e.querySelectorAll(n)).forEach((function(e){t.add(e)}));return t}),new Set);return Array.from(n)}return[]},_=function(e,t){return e?t.some((function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))?e:_(null==e?void 0:e.parentElement,t):null},U=function(e,t){var n,r,o;if(!e)return{};var i=null===(o=null===(r=null==e?void 0:e.tagName)||void 0===r?void 0:r.toLowerCase)||void 0===o?void 0:o.call(r),l=q(e,t),a=((n={})[c]=i,n[d]=P(e),n[s]=l,n[f]=window.location.href.split("?")[0],n);return j(a)};var H=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?v:t,r=this;this.endpoint=v,this.requestCallbacks={},this.onSelect=function(e){r.notify({action:"element-selected",data:e})},this.onTrack=function(e,t){"selector-mode-changed"===e?r.notify({action:"track-selector-mode-changed",data:t}):"selector-moved"===e&&r.notify({action:"track-selector-moved",data:t})},this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,o;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(o=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===o||o.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var o="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),i={id:o,action:e,args:t};return new Promise((function(t,l){r.requestCallbacks[o]={resolve:t,reject:l},r.notify(i),(null==n?void 0:n.timeout)>0&&setTimeout((function(){l(new Error("".concat(e," timed out (id: ").concat(o,")"))),delete r.requestCallbacks[o]}),n.timeout)}))},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.setup=function(e){var t=this,n=void 0===e?{}:e,r=n.logger,o=n.endpoint,i=n.isElementSelectable;this.logger=r,o&&this.endpoint===v&&(this.endpoint=o);var l=null;window.addEventListener("message",(function(e){var n,r,o,a,u;if(null===(r=null===(n=t.logger)||void 0===n?void 0:n.debug)||void 0===r||r.call(n,"Message received: ",JSON.stringify(e)),t.endpoint===e.origin){var c,d=null==e?void 0:e.data,s=null==d?void 0:d.action;if(s)if("id"in d)null===(a=null===(o=t.logger)||void 0===o?void 0:o.debug)||void 0===a||a.call(o,"Received Response to previous request: ",JSON.stringify(e)),t.handleResponse(d);else if("ping"===s)t.notify({action:"pong"});else if("initialize-visual-tagging-selector"===s){var f=null==d?void 0:d.data;(c="https://cdn.amplitude.com/libs/visual-tagging-selector-0.2.2.js.gz",new Promise((function(e,t){var n;try{var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=c,r.addEventListener("load",(function(){e({status:!0})}),{once:!0}),r.addEventListener("error",(function(){t({status:!1,message:"Failed to load the script ".concat(c)})})),null===(n=document.head)||void 0===n||n.appendChild(r)}catch(e){t(e)}}))).then((function(){var e;l=null===(e=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===e?void 0:e.call(window,{getEventTagProps:U,isElementSelectable:function(e){return!i||i((null==f?void 0:f.actionType)||"click",e)},onTrack:t.onTrack,onSelect:t.onSelect,visualHighlightClass:g,messenger:t}),t.notify({action:"selector-loaded"})})).catch((function(){var e;null===(e=t.logger)||void 0===e||e.warn("Failed to initialize visual tagging selector")}))}else"close-visual-tagging-selector"===s&&(null===(u=null==l?void 0:l.close)||void 0===u||u.call(l))}})),this.notify({action:"page-loaded"})},e}(),F=["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot"],W=["type"],z=["svg","path","g"],I=["password","hidden"];function J(e){var t,n,r,i,l,a;if(null===e)return null;var u=e.tagName.toLowerCase(),c={tag:u},d=Array.from(null!==(i=null===(r=e.parentElement)||void 0===r?void 0:r.children)&&void 0!==i?i:[]);d.length&&(c.index=d.indexOf(e),c.indexOfType=d.filter((function(t){return t.tagName===e.tagName})).indexOf(e));var s=null===(a=null===(l=e.previousElementSibling)||void 0===l?void 0:l.tagName)||void 0===a?void 0:a.toLowerCase();s&&(c.prevSib=s);var f=e.id;f&&(c.id=f);var v=Array.from(e.classList);v.length&&(c.classes=v);var p={},g=Array.from(e.attributes).filter((function(e){return!F.includes(e.name)})),h=!M(e);if(!I.includes(e.type)&&!z.includes(u))try{for(var m=o(g),y=m.next();!y.done;y=m.next()){var w=y.value;h&&!W.includes(w.name)||(p[w.name]=String(w.value).substring(0,128))}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}return Object.keys(p).length&&(c.attrs=p),c}var V=["a","button","input","select","textarea","label","[data-amp-default-track]",".amp-default-track"],B="data-amp-track-",G=function(e){void 0===e&&(e={});var o,i=e.cssSelectorAllowlist,l=void 0===i?V:i,a=e.pageUrlAllowlist,u=e.shouldTrackEventResolver,v=e.dataAttributePrefix,g=void 0===v?B:v,h=e.visualTaggingOptions,m=void 0===h?{enabled:!0,messenger:new H}:h,y="@amplitude/plugin-autocapture-browser",w=[],b=void 0,E=function(e,t,n){e.addEventListener(t,n),w.push({element:e,type:t,handler:n})},S=function(e,t){var n,r,o;if(!t)return!1;var i=null===(r=null===(n=null==t?void 0:t.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n);if(!i)return!1;if(u)return u(e,t);if(!function(e,t){return!t||!t.length||t.some((function(t){return"string"==typeof t?e===t:e.match(t)}))}(window.location.href,a))return!1;var c=(null==t?void 0:t.type)||"";if("string"==typeof c)switch(c.toLowerCase()){case"hidden":case"password":return!1}if(l){var d=l.some((function(e){var n;return!!(null===(n=null==t?void 0:t.matches)||void 0===n?void 0:n.call(t,e))}));if(!d)return!1}switch(i){case"input":case"select":case"textarea":return"change"===e||"click"===e;default:var s=null===(o=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===o?void 0:o.call(window,t);return!(!s||"pointer"!==s.getPropertyValue("cursor")||"click"!==e)||"click"===e}},A=function(e,t){var n,r,o,i=null===(o=null===(r=null==t?void 0:t.tagName)||void 0===r?void 0:r.toLowerCase)||void 0===o?void 0:o.call(r),l="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},a=t.getAttribute("aria-label"),u=function(e,t){return e.getAttributeNames().reduce((function(n,r){if(r.startsWith(t)){var o=r.replace(t,""),i=e.getAttribute(r);o&&(n[o]=i||"")}return n}),{})}(t,g),v=R(t),p=q(t,b),h=((n={})["[Amplitude] Element ID"]=t.id,n["[Amplitude] Element Class"]=t.className,n["[Amplitude] Element Hierarchy"]=function(e){var t=2,n=[];if(!e)return n;for(var r=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),o=0;o<r.length;o++){var i=J(r[o]),l=JSON.stringify(i).length,a=o>0?1:0;if(t+l+a>1024)break;t+=l+a,n.unshift(i)}return n}(t),n[c]=i,n[d]=P(t),n["[Amplitude] Element Position Left"]=null==l.left?null:Math.round(l.left),n["[Amplitude] Element Position Top"]=null==l.top?null:Math.round(l.top),n["[Amplitude] Element Aria Label"]=a,n["[Amplitude] Element Attributes"]=u,n[s]=p,n["[Amplitude] Element Parent Label"]=v,n[f]=window.location.href.split("?")[0],n["[Amplitude] Page Title"]="undefined"!=typeof document&&document.title||"",n["[Amplitude] Viewport Height"]=window.innerHeight,n["[Amplitude] Viewport Width"]=window.innerWidth,n);return"a"===i&&"click"===e&&t instanceof HTMLAnchorElement&&(h["[Amplitude] Element Href"]=t.href),j(h)};return{name:y,type:"enrichment",setup:function(e,i){return n(void 0,void 0,void 0,(function(){var n,a,u,c,d;return r(this,(function(r){return i?(b=e.loggerProvider,"undefined"==typeof document||(n=function(e){S("click",e)&&E(e,"click",(function(t){(null==t?void 0:t.target)!=(null==t?void 0:t.currentTarget)&&_(null==t?void 0:t.target,l)!=(null==t?void 0:t.currentTarget)||null==i||i.track("[Amplitude] Element Clicked",A("click",e))})),S("change",e)&&E(e,"change",(function(t){(null==t?void 0:t.target)!=(null==t?void 0:t.currentTarget)&&_(null==t?void 0:t.target,l)!=(null==t?void 0:t.currentTarget)||null==i||i.track("[Amplitude] Element Changed",A("change",e))}))},"undefined"!=typeof MutationObserver&&(o=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){n(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&D(e,l).map(n)}))}))}))),a=function(){D(document.body,l).forEach(n),null==o||o.observe(document.body,{subtree:!0,childList:!0})},document.body?a():window.addEventListener("load",a),null===(c=null==e?void 0:e.loggerProvider)||void 0===c||c.log("".concat(y," has been successfully added.")),window.opener&&m.enabled&&(null===(d=m.messenger)||void 0===d||d.setup(t(t({logger:null==e?void 0:e.loggerProvider},(null==e?void 0:e.serverZone)&&{endpoint:p[e.serverZone]}),{isElementSelectable:S})))),[2]):(null===(u=null==e?void 0:e.loggerProvider)||void 0===u||u.warn("".concat(y," plugin requires a later version of @amplitude/analytics-browser. Events are not tracked.")),[2])}))}))},execute:function(e){return n(void 0,void 0,void 0,(function(){return r(this,(function(t){return[2,e]}))}))},teardown:function(){return n(void 0,void 0,void 0,(function(){return r(this,(function(e){return o&&o.disconnect(),w.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),w=[],[2]}))}))}}};return e.DEFAULT_CSS_SELECTOR_ALLOWLIST=V,e.DEFAULT_DATA_ATTRIBUTE_PREFIX=B,e.WindowMessenger=H,e.autocapturePlugin=G,e.plugin=G,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
1
|
+
var amplitudeAutocapturePlugin=function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(o,i){function l(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,a)}u((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,o,i,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=l.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)l.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return l}function l(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var a,u,c="[Amplitude] Element Tag",d="[Amplitude] Element Text",s="[Amplitude] Element Selector",f="[Amplitude] Page URL",v="https://app.amplitude.com",p={US:v,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},g="amp-visual-tagging-selector-highlight";function h(e,n){if(e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var r={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};a=t(t({},r),n),u=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(a.root,r);var o=m(e,"all",(function(){return m(e,"two",(function(){return m(e,"one",(function(){return m(e,"none")}))}))}));if(o){var i=C(L(o,e));return i.length>0&&(o=i[0]),w(o)}throw new Error("Selector was not found.")}function m(e,t,n){for(var r=null,u=[],c=e,d=0,s=function(){var e,s,f=k(function(e){var t=e.getAttribute("id");if(t&&a.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(c))||k.apply(void 0,l([],i(function(e){var t=Array.from(e.attributes).filter((function(e){return a.attr(e.name,e.value)}));return t.map((function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}}))}(c)),!1))||k.apply(void 0,l([],i(function(e){var t=Array.from(e.classList).filter(a.className);return t.map((function(e){return{name:"."+CSS.escape(e),penalty:1}}))}(c)),!1))||k(function(e){var t=e.tagName.toLowerCase();if(a.tagName(t))return{name:t,penalty:2};return null}(c))||[{name:"*",penalty:3}],v=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;var r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(c);if("all"==t)v&&(f=f.concat(f.filter(A).map((function(e){return S(e,v)}))));else if("two"==t)f=f.slice(0,1),v&&(f=f.concat(f.filter(A).map((function(e){return S(e,v)}))));else if("one"==t){var p=i(f=f.slice(0,1),1)[0];v&&A(p)&&(f=[S(p,v)])}else"none"==t&&(f=[{name:"*",penalty:3}],v&&(f=[S(f[0],v)]));try{for(var g=(e=void 0,o(f)),h=g.next();!h.done;h=g.next()){(p=h.value).level=d}}catch(t){e={error:t}}finally{try{h&&!h.done&&(s=g.return)&&s.call(g)}finally{if(e)throw e.error}}if(u.push(f),u.length>=a.seedMinLength&&(r=y(u,n)))return"break";c=c.parentElement,d++};c;){if("break"===s())break}return r||(r=y(u,n)),!r&&n?n():r}function y(e,t){var n,r,i=C(T(e));if(i.length>a.threshold)return t?t():null;try{for(var l=o(i),u=l.next();!u.done;u=l.next()){var c=u.value;if(E(c))return c}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return null}function w(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var o=e[r].level||0;n=t.level===o-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function b(e){return e.map((function(e){return e.penalty})).reduce((function(e,t){return e+t}),0)}function E(e){var t=w(e);switch(u.querySelectorAll(t).length){case 0:throw new Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function S(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function A(e){return"html"!==e.name&&!e.name.startsWith("#")}function k(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(N);return n.length>0?n:null}function N(e){return null!=e}function T(e,t){var n,i,l,a,u,c;return void 0===t&&(t=[]),r(this,(function(r){switch(r.label){case 0:if(!(e.length>0))return[3,9];r.label=1;case 1:r.trys.push([1,6,7,8]),n=o(e[0]),i=n.next(),r.label=2;case 2:return i.done?[3,5]:(l=i.value,[5,o(T(e.slice(1,e.length),t.concat(l)))]);case 3:r.sent(),r.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return a=r.sent(),u={error:a},[3,8];case 7:try{i&&!i.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:r.sent(),r.label=11;case 11:return[2]}}))}function C(e){return l([],i(e),!1).sort((function(e,t){return b(e)-b(t)}))}function L(e,t,n){var c,d,s;return void 0===n&&(n={counter:0,visited:new Map}),r(this,(function(r){switch(r.label){case 0:if(!(e.length>2&&e.length>a.optimizedMinLength))return[3,5];c=1,r.label=1;case 1:return c<e.length-1?n.counter>a.maxNumberOfTries?[2]:(n.counter+=1,(d=l([],i(e),!1)).splice(c,1),s=w(d),n.visited.has(s)?[2]:E(d)&&function(e,t){return u.querySelector(w(e))===t}(d,t)?[4,d]:[3,4]):[3,5];case 2:return r.sent(),n.visited.set(s,!0),[5,o(L(d,t,n))];case 3:r.sent(),r.label=4;case 4:return c++,[3,1];case 5:return[2]}}))}var x=["input","select","textarea"],O=function(e){if(null==e)return!1;if("string"==typeof e){if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0},M=function(e){var t,n,r=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o="true"===e.getAttribute("contenteditable");return!x.includes(r)&&!o},P=function(e){var t="";return M(e)&&e.childNodes&&e.childNodes.length&&e.childNodes.forEach((function(e){var n,r="";(n=e)&&3===n.nodeType?e.textContent&&(r=e.textContent):r=P(e),t+=r.split(/(\s+)/).filter(O).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)})),t},q=function(e,t){var n,r,o="";try{return o=h(e,{className:function(e){return e!==g}})}catch(e){if(t){var i=e;t.warn("Failed to get selector with finder, use fallback strategy instead: ".concat(i.toString()))}}var l=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n);if(l&&(o=l),e.id)o="#".concat(e.id);else if(e.className){var a=e.className.split(" ").filter((function(e){return e!==g})).join(".");a&&(o="".concat(o,".").concat(a))}return o},j=function(e){return Object.keys(e).reduce((function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t}),{})},R=function(e){var t=e.parentElement;if(!t)return"";var n=t.querySelector(":scope>span,h1,h2,h3,h4,h5,h6");if(n){var r=n.textContent||"";return O(r)?r:""}return R(t)},D=function(e,t){if(e&&"querySelectorAll"in e&&"function"==typeof e.querySelectorAll){var n=t.reduce((function(t,n){n&&Array.from(e.querySelectorAll(n)).forEach((function(e){t.add(e)}));return t}),new Set);return Array.from(n)}return[]},_=function(e,t){return e?t.some((function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))?e:_(null==e?void 0:e.parentElement,t):null},U=function(e,t){var n,r,o;if(!e)return{};var i=null===(o=null===(r=null==e?void 0:e.tagName)||void 0===r?void 0:r.toLowerCase)||void 0===o?void 0:o.call(r),l=q(e,t),a=((n={})[c]=i,n[d]=P(e),n[s]=l,n[f]=window.location.href.split("?")[0],n);return j(a)};var H=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?v:t,r=this;this.endpoint=v,this.requestCallbacks={},this.onSelect=function(e){r.notify({action:"element-selected",data:e})},this.onTrack=function(e,t){"selector-mode-changed"===e?r.notify({action:"track-selector-mode-changed",data:t}):"selector-moved"===e&&r.notify({action:"track-selector-moved",data:t})},this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,o;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(o=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===o||o.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var o="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),i={id:o,action:e,args:t};return new Promise((function(t,l){r.requestCallbacks[o]={resolve:t,reject:l},r.notify(i),(null==n?void 0:n.timeout)>0&&setTimeout((function(){l(new Error("".concat(e," timed out (id: ").concat(o,")"))),delete r.requestCallbacks[o]}),n.timeout)}))},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.setup=function(e){var t=this,n=void 0===e?{}:e,r=n.logger,o=n.endpoint,i=n.isElementSelectable;this.logger=r,o&&this.endpoint===v&&(this.endpoint=o);var l=null;window.addEventListener("message",(function(e){var n,r,o,a,u;if(null===(r=null===(n=t.logger)||void 0===n?void 0:n.debug)||void 0===r||r.call(n,"Message received: ",JSON.stringify(e)),t.endpoint===e.origin){var c,d=null==e?void 0:e.data,s=null==d?void 0:d.action;if(s)if("id"in d)null===(a=null===(o=t.logger)||void 0===o?void 0:o.debug)||void 0===a||a.call(o,"Received Response to previous request: ",JSON.stringify(e)),t.handleResponse(d);else if("ping"===s)t.notify({action:"pong"});else if("initialize-visual-tagging-selector"===s){var f=null==d?void 0:d.data;(c="https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz",new Promise((function(e,t){var n;try{var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=c,r.addEventListener("load",(function(){e({status:!0})}),{once:!0}),r.addEventListener("error",(function(){t({status:!1,message:"Failed to load the script ".concat(c)})})),null===(n=document.head)||void 0===n||n.appendChild(r)}catch(e){t(e)}}))).then((function(){var e;l=null===(e=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===e?void 0:e.call(window,{getEventTagProps:U,isElementSelectable:function(e){return!i||i((null==f?void 0:f.actionType)||"click",e)},onTrack:t.onTrack,onSelect:t.onSelect,visualHighlightClass:g,messenger:t}),t.notify({action:"selector-loaded"})})).catch((function(){var e;null===(e=t.logger)||void 0===e||e.warn("Failed to initialize visual tagging selector")}))}else"close-visual-tagging-selector"===s&&(null===(u=null==l?void 0:l.close)||void 0===u||u.call(l))}})),this.notify({action:"page-loaded"})},e}(),F=["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot"],W=["type"],z=["svg","path","g"],I=["password","hidden"];function J(e){var t,n,r,i,l,a;if(null===e)return null;var u=e.tagName.toLowerCase(),c={tag:u},d=Array.from(null!==(i=null===(r=e.parentElement)||void 0===r?void 0:r.children)&&void 0!==i?i:[]);d.length&&(c.index=d.indexOf(e),c.indexOfType=d.filter((function(t){return t.tagName===e.tagName})).indexOf(e));var s=null===(a=null===(l=e.previousElementSibling)||void 0===l?void 0:l.tagName)||void 0===a?void 0:a.toLowerCase();s&&(c.prevSib=s);var f=e.id;f&&(c.id=f);var v=Array.from(e.classList);v.length&&(c.classes=v);var p={},g=Array.from(e.attributes).filter((function(e){return!F.includes(e.name)})),h=!M(e);if(!I.includes(e.type)&&!z.includes(u))try{for(var m=o(g),y=m.next();!y.done;y=m.next()){var w=y.value;h&&!W.includes(w.name)||(p[w.name]=String(w.value).substring(0,128))}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}return Object.keys(p).length&&(c.attrs=p),c}var V=["a","button","input","select","textarea","label","[data-amp-default-track]",".amp-default-track"],B="data-amp-track-",G=function(e){void 0===e&&(e={});var o,i=e.cssSelectorAllowlist,l=void 0===i?V:i,a=e.pageUrlAllowlist,u=e.shouldTrackEventResolver,v=e.dataAttributePrefix,g=void 0===v?B:v,h=e.visualTaggingOptions,m=void 0===h?{enabled:!0,messenger:new H}:h,y="@amplitude/plugin-autocapture-browser",w=[],b=void 0,E=function(e,t,n){e.addEventListener(t,n),w.push({element:e,type:t,handler:n})},S=function(e,t){var n,r,o;if(!t)return!1;var i=null===(r=null===(n=null==t?void 0:t.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n);if(!i)return!1;if(u)return u(e,t);if(!function(e,t){return!t||!t.length||t.some((function(t){return"string"==typeof t?e===t:e.match(t)}))}(window.location.href,a))return!1;var c=(null==t?void 0:t.type)||"";if("string"==typeof c)switch(c.toLowerCase()){case"hidden":case"password":return!1}if(l){var d=l.some((function(e){var n;return!!(null===(n=null==t?void 0:t.matches)||void 0===n?void 0:n.call(t,e))}));if(!d)return!1}switch(i){case"input":case"select":case"textarea":return"change"===e||"click"===e;default:var s=null===(o=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===o?void 0:o.call(window,t);return!(!s||"pointer"!==s.getPropertyValue("cursor")||"click"!==e)||"click"===e}},A=function(e,t){var n,r,o,i=null===(o=null===(r=null==t?void 0:t.tagName)||void 0===r?void 0:r.toLowerCase)||void 0===o?void 0:o.call(r),l="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},a=t.getAttribute("aria-label"),u=function(e,t){return e.getAttributeNames().reduce((function(n,r){if(r.startsWith(t)){var o=r.replace(t,""),i=e.getAttribute(r);o&&(n[o]=i||"")}return n}),{})}(t,g),v=R(t),p=q(t,b),h=((n={})["[Amplitude] Element ID"]=t.id,n["[Amplitude] Element Class"]=t.className,n["[Amplitude] Element Hierarchy"]=function(e){var t=2,n=[];if(!e)return n;for(var r=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),o=0;o<r.length;o++){var i=J(r[o]),l=JSON.stringify(i).length,a=o>0?1:0;if(t+l+a>1024)break;t+=l+a,n.unshift(i)}return n}(t),n[c]=i,n[d]=P(t),n["[Amplitude] Element Position Left"]=null==l.left?null:Math.round(l.left),n["[Amplitude] Element Position Top"]=null==l.top?null:Math.round(l.top),n["[Amplitude] Element Aria Label"]=a,n["[Amplitude] Element Attributes"]=u,n[s]=p,n["[Amplitude] Element Parent Label"]=v,n[f]=window.location.href.split("?")[0],n["[Amplitude] Page Title"]="undefined"!=typeof document&&document.title||"",n["[Amplitude] Viewport Height"]=window.innerHeight,n["[Amplitude] Viewport Width"]=window.innerWidth,n);return"a"===i&&"click"===e&&t instanceof HTMLAnchorElement&&(h["[Amplitude] Element Href"]=t.href),j(h)};return{name:y,type:"enrichment",setup:function(e,i){return n(void 0,void 0,void 0,(function(){var n,a,u,c,d;return r(this,(function(r){return i?(b=e.loggerProvider,"undefined"==typeof document||(n=function(e){S("click",e)&&E(e,"click",(function(t){(null==t?void 0:t.target)!=(null==t?void 0:t.currentTarget)&&_(null==t?void 0:t.target,l)!=(null==t?void 0:t.currentTarget)||null==i||i.track("[Amplitude] Element Clicked",A("click",e))})),S("change",e)&&E(e,"change",(function(t){(null==t?void 0:t.target)!=(null==t?void 0:t.currentTarget)&&_(null==t?void 0:t.target,l)!=(null==t?void 0:t.currentTarget)||null==i||i.track("[Amplitude] Element Changed",A("change",e))}))},"undefined"!=typeof MutationObserver&&(o=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){n(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&D(e,l).map(n)}))}))}))),a=function(){D(document.body,l).forEach(n),null==o||o.observe(document.body,{subtree:!0,childList:!0})},document.body?a():window.addEventListener("load",a),null===(c=null==e?void 0:e.loggerProvider)||void 0===c||c.log("".concat(y," has been successfully added.")),window.opener&&m.enabled&&(null===(d=m.messenger)||void 0===d||d.setup(t(t({logger:null==e?void 0:e.loggerProvider},(null==e?void 0:e.serverZone)&&{endpoint:p[e.serverZone]}),{isElementSelectable:S})))),[2]):(null===(u=null==e?void 0:e.loggerProvider)||void 0===u||u.warn("".concat(y," plugin requires a later version of @amplitude/analytics-browser. Events are not tracked.")),[2])}))}))},execute:function(e){return n(void 0,void 0,void 0,(function(){return r(this,(function(t){return[2,e]}))}))},teardown:function(){return n(void 0,void 0,void 0,(function(){return r(this,(function(e){return o&&o.disconnect(),w.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),w=[],[2]}))}))}}};return e.DEFAULT_CSS_SELECTOR_ALLOWLIST=V,e.DEFAULT_DATA_ATTRIBUTE_PREFIX=B,e.WindowMessenger=H,e.autocapturePlugin=G,e.plugin=G,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).amplitude={})}(this,(function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(o,i){function l(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,a)}u((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,o,i,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=l.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)l.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return l}function l(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var a,u,c="[Amplitude] Element Tag",d="[Amplitude] Element Text",s="[Amplitude] Element Selector",f="[Amplitude] Page URL",v="https://app.amplitude.com",p={US:v,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},g="amp-visual-tagging-selector-highlight";function h(e,n){if(e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var r={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};a=t(t({},r),n),u=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(a.root,r);var o=m(e,"all",(function(){return m(e,"two",(function(){return m(e,"one",(function(){return m(e,"none")}))}))}));if(o){var i=C(L(o,e));return i.length>0&&(o=i[0]),w(o)}throw new Error("Selector was not found.")}function m(e,t,n){for(var r=null,u=[],c=e,d=0,s=function(){var e,s,f=k(function(e){var t=e.getAttribute("id");if(t&&a.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(c))||k.apply(void 0,l([],i(function(e){var t=Array.from(e.attributes).filter((function(e){return a.attr(e.name,e.value)}));return t.map((function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}}))}(c)),!1))||k.apply(void 0,l([],i(function(e){var t=Array.from(e.classList).filter(a.className);return t.map((function(e){return{name:"."+CSS.escape(e),penalty:1}}))}(c)),!1))||k(function(e){var t=e.tagName.toLowerCase();if(a.tagName(t))return{name:t,penalty:2};return null}(c))||[{name:"*",penalty:3}],v=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;var r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(c);if("all"==t)v&&(f=f.concat(f.filter(A).map((function(e){return S(e,v)}))));else if("two"==t)f=f.slice(0,1),v&&(f=f.concat(f.filter(A).map((function(e){return S(e,v)}))));else if("one"==t){var p=i(f=f.slice(0,1),1)[0];v&&A(p)&&(f=[S(p,v)])}else"none"==t&&(f=[{name:"*",penalty:3}],v&&(f=[S(f[0],v)]));try{for(var g=(e=void 0,o(f)),h=g.next();!h.done;h=g.next()){(p=h.value).level=d}}catch(t){e={error:t}}finally{try{h&&!h.done&&(s=g.return)&&s.call(g)}finally{if(e)throw e.error}}if(u.push(f),u.length>=a.seedMinLength&&(r=y(u,n)))return"break";c=c.parentElement,d++};c;){if("break"===s())break}return r||(r=y(u,n)),!r&&n?n():r}function y(e,t){var n,r,i=C(T(e));if(i.length>a.threshold)return t?t():null;try{for(var l=o(i),u=l.next();!u.done;u=l.next()){var c=u.value;if(E(c))return c}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return null}function w(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var o=e[r].level||0;n=t.level===o-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function b(e){return e.map((function(e){return e.penalty})).reduce((function(e,t){return e+t}),0)}function E(e){var t=w(e);switch(u.querySelectorAll(t).length){case 0:throw new Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function S(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function A(e){return"html"!==e.name&&!e.name.startsWith("#")}function k(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(N);return n.length>0?n:null}function N(e){return null!=e}function T(e,t){var n,i,l,a,u,c;return void 0===t&&(t=[]),r(this,(function(r){switch(r.label){case 0:if(!(e.length>0))return[3,9];r.label=1;case 1:r.trys.push([1,6,7,8]),n=o(e[0]),i=n.next(),r.label=2;case 2:return i.done?[3,5]:(l=i.value,[5,o(T(e.slice(1,e.length),t.concat(l)))]);case 3:r.sent(),r.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return a=r.sent(),u={error:a},[3,8];case 7:try{i&&!i.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:r.sent(),r.label=11;case 11:return[2]}}))}function C(e){return l([],i(e),!1).sort((function(e,t){return b(e)-b(t)}))}function L(e,t,n){var c,d,s;return void 0===n&&(n={counter:0,visited:new Map}),r(this,(function(r){switch(r.label){case 0:if(!(e.length>2&&e.length>a.optimizedMinLength))return[3,5];c=1,r.label=1;case 1:return c<e.length-1?n.counter>a.maxNumberOfTries?[2]:(n.counter+=1,(d=l([],i(e),!1)).splice(c,1),s=w(d),n.visited.has(s)?[2]:E(d)&&function(e,t){return u.querySelector(w(e))===t}(d,t)?[4,d]:[3,4]):[3,5];case 2:return r.sent(),n.visited.set(s,!0),[5,o(L(d,t,n))];case 3:r.sent(),r.label=4;case 4:return c++,[3,1];case 5:return[2]}}))}var x=["input","select","textarea"],O=function(e){if(null==e)return!1;if("string"==typeof e){if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0},M=function(e){var t,n,r=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o="true"===e.getAttribute("contenteditable");return!x.includes(r)&&!o},P=function(e){var t="";return M(e)&&e.childNodes&&e.childNodes.length&&e.childNodes.forEach((function(e){var n,r="";(n=e)&&3===n.nodeType?e.textContent&&(r=e.textContent):r=P(e),t+=r.split(/(\s+)/).filter(O).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)})),t},q=function(e,t){var n,r,o="";try{return o=h(e,{className:function(e){return e!==g}})}catch(e){if(t){var i=e;t.warn("Failed to get selector with finder, use fallback strategy instead: ".concat(i.toString()))}}var l=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n);if(l&&(o=l),e.id)o="#".concat(e.id);else if(e.className){var a=e.className.split(" ").filter((function(e){return e!==g})).join(".");a&&(o="".concat(o,".").concat(a))}return o},j=function(e){return Object.keys(e).reduce((function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t}),{})},R=function(e){var t=e.parentElement;if(!t)return"";var n=t.querySelector(":scope>span,h1,h2,h3,h4,h5,h6");if(n){var r=n.textContent||"";return O(r)?r:""}return R(t)},D=function(e,t){if(e&&"querySelectorAll"in e&&"function"==typeof e.querySelectorAll){var n=t.reduce((function(t,n){n&&Array.from(e.querySelectorAll(n)).forEach((function(e){t.add(e)}));return t}),new Set);return Array.from(n)}return[]},_=function(e,t){return e?t.some((function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))?e:_(null==e?void 0:e.parentElement,t):null},U=function(e,t){var n,r,o;if(!e)return{};var i=null===(o=null===(r=null==e?void 0:e.tagName)||void 0===r?void 0:r.toLowerCase)||void 0===o?void 0:o.call(r),l=q(e,t),a=((n={})[c]=i,n[d]=P(e),n[s]=l,n[f]=window.location.href.split("?")[0],n);return j(a)};var H=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?v:t,r=this;this.endpoint=v,this.requestCallbacks={},this.onSelect=function(e){r.notify({action:"element-selected",data:e})},this.onTrack=function(e,t){"selector-mode-changed"===e?r.notify({action:"track-selector-mode-changed",data:t}):"selector-moved"===e&&r.notify({action:"track-selector-moved",data:t})},this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,o;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(o=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===o||o.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var o="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),i={id:o,action:e,args:t};return new Promise((function(t,l){r.requestCallbacks[o]={resolve:t,reject:l},r.notify(i),(null==n?void 0:n.timeout)>0&&setTimeout((function(){l(new Error("".concat(e," timed out (id: ").concat(o,")"))),delete r.requestCallbacks[o]}),n.timeout)}))},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.setup=function(e){var t=this,n=void 0===e?{}:e,r=n.logger,o=n.endpoint,i=n.isElementSelectable;this.logger=r,o&&this.endpoint===v&&(this.endpoint=o);var l=null;window.addEventListener("message",(function(e){var n,r,o,a,u;if(null===(r=null===(n=t.logger)||void 0===n?void 0:n.debug)||void 0===r||r.call(n,"Message received: ",JSON.stringify(e)),t.endpoint===e.origin){var c,d=null==e?void 0:e.data,s=null==d?void 0:d.action;if(s)if("id"in d)null===(a=null===(o=t.logger)||void 0===o?void 0:o.debug)||void 0===a||a.call(o,"Received Response to previous request: ",JSON.stringify(e)),t.handleResponse(d);else if("ping"===s)t.notify({action:"pong"});else if("initialize-visual-tagging-selector"===s){var f=null==d?void 0:d.data;(c="https://cdn.amplitude.com/libs/visual-tagging-selector-0.2.2.js.gz",new Promise((function(e,t){var n;try{var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=c,r.addEventListener("load",(function(){e({status:!0})}),{once:!0}),r.addEventListener("error",(function(){t({status:!1,message:"Failed to load the script ".concat(c)})})),null===(n=document.head)||void 0===n||n.appendChild(r)}catch(e){t(e)}}))).then((function(){var e;l=null===(e=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===e?void 0:e.call(window,{getEventTagProps:U,isElementSelectable:function(e){return!i||i((null==f?void 0:f.actionType)||"click",e)},onTrack:t.onTrack,onSelect:t.onSelect,visualHighlightClass:g,messenger:t}),t.notify({action:"selector-loaded"})})).catch((function(){var e;null===(e=t.logger)||void 0===e||e.warn("Failed to initialize visual tagging selector")}))}else"close-visual-tagging-selector"===s&&(null===(u=null==l?void 0:l.close)||void 0===u||u.call(l))}})),this.notify({action:"page-loaded"})},e}(),F=["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot"],W=["type"],z=["svg","path","g"],I=["password","hidden"];function J(e){var t,n,r,i,l,a;if(null===e)return null;var u=e.tagName.toLowerCase(),c={tag:u},d=Array.from(null!==(i=null===(r=e.parentElement)||void 0===r?void 0:r.children)&&void 0!==i?i:[]);d.length&&(c.index=d.indexOf(e),c.indexOfType=d.filter((function(t){return t.tagName===e.tagName})).indexOf(e));var s=null===(a=null===(l=e.previousElementSibling)||void 0===l?void 0:l.tagName)||void 0===a?void 0:a.toLowerCase();s&&(c.prevSib=s);var f=e.id;f&&(c.id=f);var v=Array.from(e.classList);v.length&&(c.classes=v);var p={},g=Array.from(e.attributes).filter((function(e){return!F.includes(e.name)})),h=!M(e);if(!I.includes(e.type)&&!z.includes(u))try{for(var m=o(g),y=m.next();!y.done;y=m.next()){var w=y.value;h&&!W.includes(w.name)||(p[w.name]=String(w.value).substring(0,128))}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}return Object.keys(p).length&&(c.attrs=p),c}var V=["a","button","input","select","textarea","label","[data-amp-default-track]",".amp-default-track"],B="data-amp-track-",G=function(e){void 0===e&&(e={});var o,i=e.cssSelectorAllowlist,l=void 0===i?V:i,a=e.pageUrlAllowlist,u=e.shouldTrackEventResolver,v=e.dataAttributePrefix,g=void 0===v?B:v,h=e.visualTaggingOptions,m=void 0===h?{enabled:!0,messenger:new H}:h,y="@amplitude/plugin-autocapture-browser",w=[],b=void 0,E=function(e,t,n){e.addEventListener(t,n),w.push({element:e,type:t,handler:n})},S=function(e,t){var n,r,o;if(!t)return!1;var i=null===(r=null===(n=null==t?void 0:t.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n);if(!i)return!1;if(u)return u(e,t);if(!function(e,t){return!t||!t.length||t.some((function(t){return"string"==typeof t?e===t:e.match(t)}))}(window.location.href,a))return!1;var c=(null==t?void 0:t.type)||"";if("string"==typeof c)switch(c.toLowerCase()){case"hidden":case"password":return!1}if(l){var d=l.some((function(e){var n;return!!(null===(n=null==t?void 0:t.matches)||void 0===n?void 0:n.call(t,e))}));if(!d)return!1}switch(i){case"input":case"select":case"textarea":return"change"===e||"click"===e;default:var s=null===(o=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===o?void 0:o.call(window,t);return!(!s||"pointer"!==s.getPropertyValue("cursor")||"click"!==e)||"click"===e}},A=function(e,t){var n,r,o,i=null===(o=null===(r=null==t?void 0:t.tagName)||void 0===r?void 0:r.toLowerCase)||void 0===o?void 0:o.call(r),l="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},a=t.getAttribute("aria-label"),u=function(e,t){return e.getAttributeNames().reduce((function(n,r){if(r.startsWith(t)){var o=r.replace(t,""),i=e.getAttribute(r);o&&(n[o]=i||"")}return n}),{})}(t,g),v=R(t),p=q(t,b),h=((n={})["[Amplitude] Element ID"]=t.id,n["[Amplitude] Element Class"]=t.className,n["[Amplitude] Element Hierarchy"]=function(e){var t=2,n=[];if(!e)return n;for(var r=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),o=0;o<r.length;o++){var i=J(r[o]),l=JSON.stringify(i).length,a=o>0?1:0;if(t+l+a>1024)break;t+=l+a,n.unshift(i)}return n}(t),n[c]=i,n[d]=P(t),n["[Amplitude] Element Position Left"]=null==l.left?null:Math.round(l.left),n["[Amplitude] Element Position Top"]=null==l.top?null:Math.round(l.top),n["[Amplitude] Element Aria Label"]=a,n["[Amplitude] Element Attributes"]=u,n[s]=p,n["[Amplitude] Element Parent Label"]=v,n[f]=window.location.href.split("?")[0],n["[Amplitude] Page Title"]="undefined"!=typeof document&&document.title||"",n["[Amplitude] Viewport Height"]=window.innerHeight,n["[Amplitude] Viewport Width"]=window.innerWidth,n);return"a"===i&&"click"===e&&t instanceof HTMLAnchorElement&&(h["[Amplitude] Element Href"]=t.href),j(h)};return{name:y,type:"enrichment",setup:function(e,i){return n(void 0,void 0,void 0,(function(){var n,a,u,c,d;return r(this,(function(r){return i?(b=e.loggerProvider,"undefined"==typeof document||(n=function(e){S("click",e)&&E(e,"click",(function(t){(null==t?void 0:t.target)!=(null==t?void 0:t.currentTarget)&&_(null==t?void 0:t.target,l)!=(null==t?void 0:t.currentTarget)||null==i||i.track("[Amplitude] Element Clicked",A("click",e))})),S("change",e)&&E(e,"change",(function(t){(null==t?void 0:t.target)!=(null==t?void 0:t.currentTarget)&&_(null==t?void 0:t.target,l)!=(null==t?void 0:t.currentTarget)||null==i||i.track("[Amplitude] Element Changed",A("change",e))}))},"undefined"!=typeof MutationObserver&&(o=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){n(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&D(e,l).map(n)}))}))}))),a=function(){D(document.body,l).forEach(n),null==o||o.observe(document.body,{subtree:!0,childList:!0})},document.body?a():window.addEventListener("load",a),null===(c=null==e?void 0:e.loggerProvider)||void 0===c||c.log("".concat(y," has been successfully added.")),window.opener&&m.enabled&&(null===(d=m.messenger)||void 0===d||d.setup(t(t({logger:null==e?void 0:e.loggerProvider},(null==e?void 0:e.serverZone)&&{endpoint:p[e.serverZone]}),{isElementSelectable:S})))),[2]):(null===(u=null==e?void 0:e.loggerProvider)||void 0===u||u.warn("".concat(y," plugin requires a later version of @amplitude/analytics-browser. Events are not tracked.")),[2])}))}))},execute:function(e){return n(void 0,void 0,void 0,(function(){return r(this,(function(t){return[2,e]}))}))},teardown:function(){return n(void 0,void 0,void 0,(function(){return r(this,(function(e){return o&&o.disconnect(),w.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),w=[],[2]}))}))}}};e.DEFAULT_CSS_SELECTOR_ALLOWLIST=V,e.DEFAULT_DATA_ATTRIBUTE_PREFIX=B,e.WindowMessenger=H,e.autocapturePlugin=G,e.plugin=G,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).amplitude={})}(this,(function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(o,i){function l(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(l,a)}u((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,o,i,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=l.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)l.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return l}function l(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var a,u,c="[Amplitude] Element Tag",d="[Amplitude] Element Text",s="[Amplitude] Element Selector",f="[Amplitude] Page URL",v="https://app.amplitude.com",p={US:v,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},g="amp-visual-tagging-selector-highlight";function h(e,n){if(e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var r={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4};a=t(t({},r),n),u=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(a.root,r);var o=m(e,"all",(function(){return m(e,"two",(function(){return m(e,"one",(function(){return m(e,"none")}))}))}));if(o){var i=C(L(o,e));return i.length>0&&(o=i[0]),w(o)}throw new Error("Selector was not found.")}function m(e,t,n){for(var r=null,u=[],c=e,d=0,s=function(){var e,s,f=k(function(e){var t=e.getAttribute("id");if(t&&a.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(c))||k.apply(void 0,l([],i(function(e){var t=Array.from(e.attributes).filter((function(e){return a.attr(e.name,e.value)}));return t.map((function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}}))}(c)),!1))||k.apply(void 0,l([],i(function(e){var t=Array.from(e.classList).filter(a.className);return t.map((function(e){return{name:"."+CSS.escape(e),penalty:1}}))}(c)),!1))||k(function(e){var t=e.tagName.toLowerCase();if(a.tagName(t))return{name:t,penalty:2};return null}(c))||[{name:"*",penalty:3}],v=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;var r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(c);if("all"==t)v&&(f=f.concat(f.filter(A).map((function(e){return S(e,v)}))));else if("two"==t)f=f.slice(0,1),v&&(f=f.concat(f.filter(A).map((function(e){return S(e,v)}))));else if("one"==t){var p=i(f=f.slice(0,1),1)[0];v&&A(p)&&(f=[S(p,v)])}else"none"==t&&(f=[{name:"*",penalty:3}],v&&(f=[S(f[0],v)]));try{for(var g=(e=void 0,o(f)),h=g.next();!h.done;h=g.next()){(p=h.value).level=d}}catch(t){e={error:t}}finally{try{h&&!h.done&&(s=g.return)&&s.call(g)}finally{if(e)throw e.error}}if(u.push(f),u.length>=a.seedMinLength&&(r=y(u,n)))return"break";c=c.parentElement,d++};c;){if("break"===s())break}return r||(r=y(u,n)),!r&&n?n():r}function y(e,t){var n,r,i=C(T(e));if(i.length>a.threshold)return t?t():null;try{for(var l=o(i),u=l.next();!u.done;u=l.next()){var c=u.value;if(E(c))return c}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return null}function w(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var o=e[r].level||0;n=t.level===o-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function b(e){return e.map((function(e){return e.penalty})).reduce((function(e,t){return e+t}),0)}function E(e){var t=w(e);switch(u.querySelectorAll(t).length){case 0:throw new Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function S(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function A(e){return"html"!==e.name&&!e.name.startsWith("#")}function k(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(N);return n.length>0?n:null}function N(e){return null!=e}function T(e,t){var n,i,l,a,u,c;return void 0===t&&(t=[]),r(this,(function(r){switch(r.label){case 0:if(!(e.length>0))return[3,9];r.label=1;case 1:r.trys.push([1,6,7,8]),n=o(e[0]),i=n.next(),r.label=2;case 2:return i.done?[3,5]:(l=i.value,[5,o(T(e.slice(1,e.length),t.concat(l)))]);case 3:r.sent(),r.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return a=r.sent(),u={error:a},[3,8];case 7:try{i&&!i.done&&(c=n.return)&&c.call(n)}finally{if(u)throw u.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:r.sent(),r.label=11;case 11:return[2]}}))}function C(e){return l([],i(e),!1).sort((function(e,t){return b(e)-b(t)}))}function L(e,t,n){var c,d,s;return void 0===n&&(n={counter:0,visited:new Map}),r(this,(function(r){switch(r.label){case 0:if(!(e.length>2&&e.length>a.optimizedMinLength))return[3,5];c=1,r.label=1;case 1:return c<e.length-1?n.counter>a.maxNumberOfTries?[2]:(n.counter+=1,(d=l([],i(e),!1)).splice(c,1),s=w(d),n.visited.has(s)?[2]:E(d)&&function(e,t){return u.querySelector(w(e))===t}(d,t)?[4,d]:[3,4]):[3,5];case 2:return r.sent(),n.visited.set(s,!0),[5,o(L(d,t,n))];case 3:r.sent(),r.label=4;case 4:return c++,[3,1];case 5:return[2]}}))}var x=["input","select","textarea"],O=function(e){if(null==e)return!1;if("string"==typeof e){if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0},M=function(e){var t,n,r=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o="true"===e.getAttribute("contenteditable");return!x.includes(r)&&!o},P=function(e){var t="";return M(e)&&e.childNodes&&e.childNodes.length&&e.childNodes.forEach((function(e){var n,r="";(n=e)&&3===n.nodeType?e.textContent&&(r=e.textContent):r=P(e),t+=r.split(/(\s+)/).filter(O).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)})),t},q=function(e,t){var n,r,o="";try{return o=h(e,{className:function(e){return e!==g}})}catch(e){if(t){var i=e;t.warn("Failed to get selector with finder, use fallback strategy instead: ".concat(i.toString()))}}var l=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n);if(l&&(o=l),e.id)o="#".concat(e.id);else if(e.className){var a=e.className.split(" ").filter((function(e){return e!==g})).join(".");a&&(o="".concat(o,".").concat(a))}return o},j=function(e){return Object.keys(e).reduce((function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t}),{})},R=function(e){var t=e.parentElement;if(!t)return"";var n=t.querySelector(":scope>span,h1,h2,h3,h4,h5,h6");if(n){var r=n.textContent||"";return O(r)?r:""}return R(t)},D=function(e,t){if(e&&"querySelectorAll"in e&&"function"==typeof e.querySelectorAll){var n=t.reduce((function(t,n){n&&Array.from(e.querySelectorAll(n)).forEach((function(e){t.add(e)}));return t}),new Set);return Array.from(n)}return[]},_=function(e,t){return e?t.some((function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))?e:_(null==e?void 0:e.parentElement,t):null},U=function(e,t){var n,r,o;if(!e)return{};var i=null===(o=null===(r=null==e?void 0:e.tagName)||void 0===r?void 0:r.toLowerCase)||void 0===o?void 0:o.call(r),l=q(e,t),a=((n={})[c]=i,n[d]=P(e),n[s]=l,n[f]=window.location.href.split("?")[0],n);return j(a)};var H=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?v:t,r=this;this.endpoint=v,this.requestCallbacks={},this.onSelect=function(e){r.notify({action:"element-selected",data:e})},this.onTrack=function(e,t){"selector-mode-changed"===e?r.notify({action:"track-selector-mode-changed",data:t}):"selector-moved"===e&&r.notify({action:"track-selector-moved",data:t})},this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,o;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(o=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===o||o.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var o="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),i={id:o,action:e,args:t};return new Promise((function(t,l){r.requestCallbacks[o]={resolve:t,reject:l},r.notify(i),(null==n?void 0:n.timeout)>0&&setTimeout((function(){l(new Error("".concat(e," timed out (id: ").concat(o,")"))),delete r.requestCallbacks[o]}),n.timeout)}))},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.setup=function(e){var t=this,n=void 0===e?{}:e,r=n.logger,o=n.endpoint,i=n.isElementSelectable;this.logger=r,o&&this.endpoint===v&&(this.endpoint=o);var l=null;window.addEventListener("message",(function(e){var n,r,o,a,u;if(null===(r=null===(n=t.logger)||void 0===n?void 0:n.debug)||void 0===r||r.call(n,"Message received: ",JSON.stringify(e)),t.endpoint===e.origin){var c,d=null==e?void 0:e.data,s=null==d?void 0:d.action;if(s)if("id"in d)null===(a=null===(o=t.logger)||void 0===o?void 0:o.debug)||void 0===a||a.call(o,"Received Response to previous request: ",JSON.stringify(e)),t.handleResponse(d);else if("ping"===s)t.notify({action:"pong"});else if("initialize-visual-tagging-selector"===s){var f=null==d?void 0:d.data;(c="https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz",new Promise((function(e,t){var n;try{var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src=c,r.addEventListener("load",(function(){e({status:!0})}),{once:!0}),r.addEventListener("error",(function(){t({status:!1,message:"Failed to load the script ".concat(c)})})),null===(n=document.head)||void 0===n||n.appendChild(r)}catch(e){t(e)}}))).then((function(){var e;l=null===(e=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===e?void 0:e.call(window,{getEventTagProps:U,isElementSelectable:function(e){return!i||i((null==f?void 0:f.actionType)||"click",e)},onTrack:t.onTrack,onSelect:t.onSelect,visualHighlightClass:g,messenger:t}),t.notify({action:"selector-loaded"})})).catch((function(){var e;null===(e=t.logger)||void 0===e||e.warn("Failed to initialize visual tagging selector")}))}else"close-visual-tagging-selector"===s&&(null===(u=null==l?void 0:l.close)||void 0===u||u.call(l))}})),this.notify({action:"page-loaded"})},e}(),F=["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot"],W=["type"],z=["svg","path","g"],I=["password","hidden"];function J(e){var t,n,r,i,l,a;if(null===e)return null;var u=e.tagName.toLowerCase(),c={tag:u},d=Array.from(null!==(i=null===(r=e.parentElement)||void 0===r?void 0:r.children)&&void 0!==i?i:[]);d.length&&(c.index=d.indexOf(e),c.indexOfType=d.filter((function(t){return t.tagName===e.tagName})).indexOf(e));var s=null===(a=null===(l=e.previousElementSibling)||void 0===l?void 0:l.tagName)||void 0===a?void 0:a.toLowerCase();s&&(c.prevSib=s);var f=e.id;f&&(c.id=f);var v=Array.from(e.classList);v.length&&(c.classes=v);var p={},g=Array.from(e.attributes).filter((function(e){return!F.includes(e.name)})),h=!M(e);if(!I.includes(e.type)&&!z.includes(u))try{for(var m=o(g),y=m.next();!y.done;y=m.next()){var w=y.value;h&&!W.includes(w.name)||(p[w.name]=String(w.value).substring(0,128))}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}return Object.keys(p).length&&(c.attrs=p),c}var V=["a","button","input","select","textarea","label","[data-amp-default-track]",".amp-default-track"],B="data-amp-track-",G=function(e){void 0===e&&(e={});var o,i=e.cssSelectorAllowlist,l=void 0===i?V:i,a=e.pageUrlAllowlist,u=e.shouldTrackEventResolver,v=e.dataAttributePrefix,g=void 0===v?B:v,h=e.visualTaggingOptions,m=void 0===h?{enabled:!0,messenger:new H}:h,y="@amplitude/plugin-autocapture-browser",w=[],b=void 0,E=function(e,t,n){e.addEventListener(t,n),w.push({element:e,type:t,handler:n})},S=function(e,t){var n,r,o;if(!t)return!1;var i=null===(r=null===(n=null==t?void 0:t.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n);if(!i)return!1;if(u)return u(e,t);if(!function(e,t){return!t||!t.length||t.some((function(t){return"string"==typeof t?e===t:e.match(t)}))}(window.location.href,a))return!1;var c=(null==t?void 0:t.type)||"";if("string"==typeof c)switch(c.toLowerCase()){case"hidden":case"password":return!1}if(l){var d=l.some((function(e){var n;return!!(null===(n=null==t?void 0:t.matches)||void 0===n?void 0:n.call(t,e))}));if(!d)return!1}switch(i){case"input":case"select":case"textarea":return"change"===e||"click"===e;default:var s=null===(o=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===o?void 0:o.call(window,t);return!(!s||"pointer"!==s.getPropertyValue("cursor")||"click"!==e)||"click"===e}},A=function(e,t){var n,r,o,i=null===(o=null===(r=null==t?void 0:t.tagName)||void 0===r?void 0:r.toLowerCase)||void 0===o?void 0:o.call(r),l="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},a=t.getAttribute("aria-label"),u=function(e,t){return e.getAttributeNames().reduce((function(n,r){if(r.startsWith(t)){var o=r.replace(t,""),i=e.getAttribute(r);o&&(n[o]=i||"")}return n}),{})}(t,g),v=R(t),p=q(t,b),h=((n={})["[Amplitude] Element ID"]=t.id,n["[Amplitude] Element Class"]=t.className,n["[Amplitude] Element Hierarchy"]=function(e){var t=2,n=[];if(!e)return n;for(var r=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),o=0;o<r.length;o++){var i=J(r[o]),l=JSON.stringify(i).length,a=o>0?1:0;if(t+l+a>1024)break;t+=l+a,n.unshift(i)}return n}(t),n[c]=i,n[d]=P(t),n["[Amplitude] Element Position Left"]=null==l.left?null:Math.round(l.left),n["[Amplitude] Element Position Top"]=null==l.top?null:Math.round(l.top),n["[Amplitude] Element Aria Label"]=a,n["[Amplitude] Element Attributes"]=u,n[s]=p,n["[Amplitude] Element Parent Label"]=v,n[f]=window.location.href.split("?")[0],n["[Amplitude] Page Title"]="undefined"!=typeof document&&document.title||"",n["[Amplitude] Viewport Height"]=window.innerHeight,n["[Amplitude] Viewport Width"]=window.innerWidth,n);return"a"===i&&"click"===e&&t instanceof HTMLAnchorElement&&(h["[Amplitude] Element Href"]=t.href),j(h)};return{name:y,type:"enrichment",setup:function(e,i){return n(void 0,void 0,void 0,(function(){var n,a,u,c,d;return r(this,(function(r){return i?(b=e.loggerProvider,"undefined"==typeof document||(n=function(e){S("click",e)&&E(e,"click",(function(t){(null==t?void 0:t.target)!=(null==t?void 0:t.currentTarget)&&_(null==t?void 0:t.target,l)!=(null==t?void 0:t.currentTarget)||null==i||i.track("[Amplitude] Element Clicked",A("click",e))})),S("change",e)&&E(e,"change",(function(t){(null==t?void 0:t.target)!=(null==t?void 0:t.currentTarget)&&_(null==t?void 0:t.target,l)!=(null==t?void 0:t.currentTarget)||null==i||i.track("[Amplitude] Element Changed",A("change",e))}))},"undefined"!=typeof MutationObserver&&(o=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){n(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&D(e,l).map(n)}))}))}))),a=function(){D(document.body,l).forEach(n),null==o||o.observe(document.body,{subtree:!0,childList:!0})},document.body?a():window.addEventListener("load",a),null===(c=null==e?void 0:e.loggerProvider)||void 0===c||c.log("".concat(y," has been successfully added.")),window.opener&&m.enabled&&(null===(d=m.messenger)||void 0===d||d.setup(t(t({logger:null==e?void 0:e.loggerProvider},(null==e?void 0:e.serverZone)&&{endpoint:p[e.serverZone]}),{isElementSelectable:S})))),[2]):(null===(u=null==e?void 0:e.loggerProvider)||void 0===u||u.warn("".concat(y," plugin requires a later version of @amplitude/analytics-browser. Events are not tracked.")),[2])}))}))},execute:function(e){return n(void 0,void 0,void 0,(function(){return r(this,(function(t){return[2,e]}))}))},teardown:function(){return n(void 0,void 0,void 0,(function(){return r(this,(function(e){return o&&o.disconnect(),w.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),w=[],[2]}))}))}}};e.DEFAULT_CSS_SELECTOR_ALLOWLIST=V,e.DEFAULT_DATA_ATTRIBUTE_PREFIX=B,e.WindowMessenger=H,e.autocapturePlugin=G,e.plugin=G,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
Binary file
|
|
@@ -25,6 +25,6 @@ export declare const AMPLITUDE_ORIGINS_MAP: {
|
|
|
25
25
|
EU: string;
|
|
26
26
|
STAGING: string;
|
|
27
27
|
};
|
|
28
|
-
export declare const AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = "https://cdn.amplitude.com/libs/visual-tagging-selector-0.
|
|
28
|
+
export declare const AMPLITUDE_VISUAL_TAGGING_SELECTOR_SCRIPT_URL = "https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz";
|
|
29
29
|
export declare const AMPLITUDE_VISUAL_TAGGING_HIGHLIGHT_CLASS = "amp-visual-tagging-selector-highlight";
|
|
30
30
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,0CAA0C,CAAC;AAEnE,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAC7E,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAE7E,eAAO,MAAM,+BAA+B,2BAA2B,CAAC;AACxE,eAAO,MAAM,kCAAkC,8BAA8B,CAAC;AAC9E,eAAO,MAAM,gCAAgC,4BAA4B,CAAC;AAC1E,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAC5E,eAAO,MAAM,sCAAsC,kCAAkC,CAAC;AACtF,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAC5E,eAAO,MAAM,0CAA0C,sCAAsC,CAAC;AAC9F,eAAO,MAAM,yCAAyC,qCAAqC,CAAC;AAC5F,eAAO,MAAM,uCAAuC,mCAAmC,CAAC;AACxF,eAAO,MAAM,uCAAuC,mCAAmC,CAAC;AAExF,eAAO,MAAM,qCAAqC,iCAAiC,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;AAClF,eAAO,MAAM,mCAAmC,+BAA+B,CAAC;AAGhF,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAC5D,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAClE,eAAO,MAAM,wBAAwB,qCAAqC,CAAC;AAC3E,eAAO,MAAM,qBAAqB;;;;CAIjC,CAAC;AAEF,eAAO,MAAM,4CAA4C,6EACmB,CAAC;AAG7E,eAAO,MAAM,wCAAwC,0CAA0C,CAAC"}
|
package/lib/scripts/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "1.0.0-beta.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -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,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/plugin-autocapture-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Amplitude Inc",
|
|
6
6
|
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"files": [
|
|
58
58
|
"lib"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "c06628a018b7b2062fc357147c8c832810b3a922"
|
|
61
61
|
}
|