@pendo/agent 2.307.1 → 2.308.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/README.md +27 -27
- package/bin/cli.js +11 -8
- package/dist/dom.esm.js +80 -12
- package/dist/pendo.debugger.min.js +1 -1
- package/dist/pendo.module.js +273 -105
- package/dist/pendo.module.min.js +10 -10
- package/dist/pendo.preview.min.js +3 -3
- package/dist/servers.json +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Pendo
|
|
1
|
+
# Pendo Web SDK
|
|
2
2
|
|
|
3
|
-
This package is for Pendo customers who want to host the
|
|
3
|
+
This package is for Pendo customers who want to host the web SDK on their own infrastructure.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -12,14 +12,14 @@ npm install @pendo/agent
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
Import the package into your application code and create the
|
|
15
|
+
Import the package into your application code and create the web SDK using your own settings:
|
|
16
16
|
|
|
17
17
|
```javascript
|
|
18
18
|
import { initialize, TextCapture } from '@pendo/agent';
|
|
19
19
|
import pendoConfig from '../pendo.config.json';
|
|
20
20
|
|
|
21
21
|
const pendo = await initialize({
|
|
22
|
-
|
|
22
|
+
publicAppId: 'YOUR_PUBLIC_APP_ID',
|
|
23
23
|
env: 'YOUR_PENDO_ENVIRONMENT',
|
|
24
24
|
visitor: {
|
|
25
25
|
id: 'THE_VISITOR_ID'
|
|
@@ -38,20 +38,20 @@ const pendo = await initialize({
|
|
|
38
38
|
});
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
The object returned by calling `initialize` is the same as a snippet install of the
|
|
41
|
+
The object returned by calling `initialize` is the same as a snippet install of the web SDK and has access to all public functions found in the public function [documentation pages](https://agent.pendo.io/public/agent).
|
|
42
42
|
|
|
43
43
|
### Parameters
|
|
44
44
|
|
|
45
45
|
| key | required? | type | description |
|
|
46
46
|
| --- | --------- | ---- | ---------- |
|
|
47
|
-
|
|
|
47
|
+
| publicAppId | required | string | Your specific application `publicAppId` can be found by going to the application details page in the Pendo App for your application. It will be a 32-digit code that identifies that application and connects it to Pendo. |
|
|
48
48
|
| env | required | string | The environment that your Pendo subscription resides in. `io` is the default US environment and environments other than that can be found in the url that you use to access Pendo (e.g. app.`eu`.pendo.io). One of: ['io', 'eu', 'jpn', 'us1', 'au', 'gov']. |
|
|
49
49
|
| visitor | optional | object | The visitor information for the current user of your application. This includes the `id` and any other metadata you want attached to the visitor. If not provided the visitor will be treated as an anonymous visitor. |
|
|
50
50
|
| account | optional | object | The account information for the current user of your application if applicable. If not provided the visitor will not be assigned to an account. |
|
|
51
51
|
| globalKey | optional | string | The key where you would like the global `pendo` object to be stored after initialization. By default this will be stored on `window.pendo` but this allows it to change to a different name if desired. |
|
|
52
|
-
| plugins | optional | array | A list of imported plugins to enable additional features in the
|
|
53
|
-
| config | optional | object | An object that contains the entire server configuration for your application may be passed. By default, the
|
|
54
|
-
| assets | optional | object | Configuration for the host and path to support including
|
|
52
|
+
| plugins | optional | array | A list of imported plugins to enable additional features in the web SDK. More information can be found [below](#plugins). |
|
|
53
|
+
| config | optional | object | An object that contains the entire server configuration for your application may be passed. By default, the web SDK will download the latest configuration upon initialization if not passed in. More information can be found [below](#config). |
|
|
54
|
+
| assets | optional | object | Configuration for the host and path to support including the web SDK's static assets in your application code. More information can be found [below](#assets). |
|
|
55
55
|
|
|
56
56
|
> **Note**: In addition to the above parameters, any additional options that can normally be provided to `pendo.initialize` may be included. See [our documentation](https://agent.pendo.io/config/) for the full list of options that can be passed to `initialize`.
|
|
57
57
|
|
|
@@ -59,21 +59,21 @@ The object returned by calling `initialize` is the same as a snippet install of
|
|
|
59
59
|
|
|
60
60
|
#### Assets
|
|
61
61
|
|
|
62
|
-
During runtime, the
|
|
62
|
+
During runtime, the web SDK occassionally needs to download additional script files to provide functionality that is not bundled into the web SDK. This functionality is mostly meant for admins that need to design and preview guides as well as debug Pendo within their application. By default the web SDK in this package will download those assets from Pendo's CDN when needed. If you would prefer to include these scripts in your application code instead of downloading them from Pendo at runtime, you can provide a host and path to where these files can be loaded from. The host can be your own CDN, domain, extension runtime location, or can even be a relative url if the host is empty.
|
|
63
63
|
|
|
64
64
|
| name | type | description |
|
|
65
65
|
| ---- | ---- | ----------- |
|
|
66
66
|
| host | string | domain host for where your assets will be hosted, if this value is an empty string, the assets will be loaded using a relative url. |
|
|
67
67
|
| path | string | additional path to add to the url before the filename. Useful if your assets are served from a path of `public` or something similar. If left blank, no additional path will be added to the urls. |
|
|
68
|
-
| localOnly | boolean | serve all possible assets from the given asset host. This will prevent the use of things that are unable to be self served, like the Visual Design Studio and guide code blocks. To be able to use guide code blocks you will need to allow remote scripts. The designer will not launch at all and will print a log message instead if this is set to true. This option is useful when including the
|
|
68
|
+
| localOnly | boolean | serve all possible assets from the given asset host. This will prevent the use of things that are unable to be self served, like the Visual Design Studio and guide code blocks. To be able to use guide code blocks you will need to allow remote scripts. The designer will not launch at all and will print a log message instead if this is set to true. This option is useful when including the web SDK in things like browser extensions that have strict rules around remote code execution but will need to be disabled in local builds to utilize the designer. Defaults to false. |
|
|
69
69
|
|
|
70
70
|
The [CLI](#cli) can be used to copy these static files from this package to your application code.
|
|
71
71
|
|
|
72
|
-
> **Note**: If you are using the static assets in this manner, every time you upgrade
|
|
72
|
+
> **Note**: If you are using the static assets in this manner, every time you upgrade web SDK versions, you will need to make sure that you copy a fresh version of the static files to maintain version compatibility.
|
|
73
73
|
|
|
74
74
|
#### Config
|
|
75
75
|
|
|
76
|
-
By default, the
|
|
76
|
+
By default, the web SDK will use the provided publicAppId and environment to download the latest version of the configuration for that application. This includes what settings have been enabled/disabled as well as any configured historical metadata fields and feature event properties. This ensures that the latest configuration is always being used without you requiring to redeploy your application. If you would prefer to not download the latest configuration and instead use a local static version, you can pass the JSON object to the `config` property instead. This will mean however, that to take advantage of any changes made to settings in the Pendo UI or to your historical metadata fields and feature event properties you will need to download a new version of the config and redeploy your application.
|
|
77
77
|
|
|
78
78
|
The [CLI](#cli) can be used to easily download and save a new version of that configuration.
|
|
79
79
|
|
|
@@ -81,7 +81,7 @@ The [CLI](#cli) can be used to easily download and save a new version of that co
|
|
|
81
81
|
|
|
82
82
|
#### Plugins
|
|
83
83
|
|
|
84
|
-
Pendo has a subset of features that need to be manually enabled or are part of separate purchases. By default the functionality for these features is not included in the
|
|
84
|
+
Pendo has a subset of features that need to be manually enabled or are part of separate purchases. By default the functionality for these features is not included in the web SDK. When using this package when there is a need to enable these features requires passing in the desired plugins. These plugins are available to be imported just like the `initialize` function and can then be passed directly into an array using the `plugins` property. Any plugin that also requires an additional purchase or package can still be included but will not function without configuration inside of your subscription.
|
|
85
85
|
|
|
86
86
|
The current list of available plugins and their export names are:
|
|
87
87
|
|
|
@@ -95,9 +95,9 @@ The current list of available plugins and their export names are:
|
|
|
95
95
|
|
|
96
96
|
## Manifest V3 Extensions
|
|
97
97
|
|
|
98
|
-
Writing an extension that adheres to the strict requirements of Manifest V3 can sometimes be challenging. If you have a Manifest V3 extension that you would like to install
|
|
98
|
+
Writing an extension that adheres to the strict requirements of Manifest V3 can sometimes be challenging. If you have a Manifest V3 extension that you would like to install the web SDK into, in order to understand how your customers use your extension, you will need to follow a few steps to ensure that the web SDK does not fetch any remote code. Using this npm package is the most straightforward way to include all Pendo assets in your extension.
|
|
99
99
|
|
|
100
|
-
1. Use the [CLI](#cli) to copy the
|
|
100
|
+
1. Use the [CLI](#cli) to copy the web SDK's static files, using the `copy` command, into a folder that will be included in your packaged extension (ensure this is run each time you update your web SDK version).
|
|
101
101
|
1. Use the [CLI](#cli) to download copies of the designer plugin files, using the `designer` command, into your packaged extension (ensure this runs each time you rebuild your extension to ensure you have the latest designer code).
|
|
102
102
|
1. Update the `manifest.json` file to include those copied files in your "web_accessible_resources". The files copied are: "guide.css", "pendo.debugger.min.js", "debugger-plugin.min.js", "pendo.preview.min.js", "replay.worker.min.js" (the worker is only needed if using Pendo Session Replay)
|
|
103
103
|
1. Initialize Pendo on the desired page or pages with any desired options, making sure to use the [assets option](#assets).
|
|
@@ -109,12 +109,12 @@ We have created an [example extension](https://github.com/pendo-io/chrome-mv3-ex
|
|
|
109
109
|
|
|
110
110
|
## CLI
|
|
111
111
|
|
|
112
|
-
The Pendo package includes a CLI tool to be able to simplify a few actions providing greater control of the
|
|
112
|
+
The Pendo package includes a CLI tool to be able to simplify a few actions providing greater control of the web SDK in your application. Once you have installed `@pendo/agent` in your application, you will have access to the `pendo` script from your terminal (you can also use a tool like `npx` to make use of the `pendo` script without installing the package if desired by using `npx pendo`). The usage of this script can be found below or by typing `pendo` or `pendo help` into your terminal where the package is installed:
|
|
113
113
|
|
|
114
114
|
> **Note**: If the config, copy, or designer commands are being used by your application, you might want to use those as part of your regular build process to ensure that you always maintain up to date versions of your config and of the static assets. For example, you could add a script to your package.json like below that you then call as part of your build:
|
|
115
115
|
|
|
116
116
|
```json
|
|
117
|
-
"pendo-build": "pendo copy --dest=public && pendo config --
|
|
117
|
+
"pendo-build": "pendo copy --dest=public && pendo config --publicAppId={{PUBLICAPPID}} --env={{YOUR_ENV}} && pendo designer --dest=public --env={{YOUR_ENV}}",
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
### Help
|
|
@@ -122,34 +122,34 @@ The Pendo package includes a CLI tool to be able to simplify a few actions provi
|
|
|
122
122
|
```bash
|
|
123
123
|
Usage: pendo <command>
|
|
124
124
|
|
|
125
|
-
CLI for @pendo/agent to assist in integrating the
|
|
125
|
+
CLI for @pendo/agent to assist in integrating the web SDK into your application.
|
|
126
126
|
|
|
127
127
|
Commands:
|
|
128
|
-
pendo config download a new
|
|
129
|
-
pendo copy copy static assets for the
|
|
128
|
+
pendo config download a new web SDK configuration file for your application
|
|
129
|
+
pendo copy copy static assets for the web SDK to a static folder
|
|
130
130
|
pendo help provide help for how to use the Pendo CLI
|
|
131
131
|
pendo help <command> search for help on a specific <command>
|
|
132
|
-
pendo version show the current version of the
|
|
132
|
+
pendo version show the current version of the web SDK
|
|
133
133
|
|
|
134
|
-
Documentation for the Pendo
|
|
134
|
+
Documentation for the Pendo Web SDK can be found at:
|
|
135
135
|
https://agent.pendo.io
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
### Download Config
|
|
139
139
|
|
|
140
140
|
```bash
|
|
141
|
-
Usage: pendo config --
|
|
141
|
+
Usage: pendo config --publicAppId=<application_api_key> --env=<subscription_environment> [--output=<filename>]
|
|
142
142
|
|
|
143
143
|
Download a new configuration file for a specific application built from the most recent subscription and application settings.
|
|
144
144
|
|
|
145
145
|
Options:
|
|
146
|
-
--
|
|
146
|
+
--publicAppId required, the public app ID for your Pendo application, found in the application settings page in the Pendo app
|
|
147
147
|
--env required, the Pendo environment for your subscription, allowed environments: [${environments}]
|
|
148
148
|
--output optional, the name of where to save the config, defaults to "pendo.config.json"
|
|
149
149
|
|
|
150
150
|
Examples:
|
|
151
151
|
Download and save the configuration file from the default US environment
|
|
152
|
-
$ pendo config --
|
|
152
|
+
$ pendo config --publicAppId=dd753dfd-ac99-4c5c-48ad-6eb18190cf77 --env=io --output=pendo.config.json
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
### Copy Static Assets
|
|
@@ -157,7 +157,7 @@ Examples:
|
|
|
157
157
|
```bash
|
|
158
158
|
Usage: pendo copy --dest=<destination_folder> [--src=<node_module_folder>]
|
|
159
159
|
|
|
160
|
-
Copy static
|
|
160
|
+
Copy static web SDK files into a local folder for self hosting. Includes guide styles, scripts for the debugger and preview mode, and the worker file for Session Replay.
|
|
161
161
|
|
|
162
162
|
Options:
|
|
163
163
|
--dest required, the destination folder to copy the static files to, usually the "public" folder of your application
|
package/bin/cli.js
CHANGED
|
@@ -10,9 +10,12 @@ const options = minimist(process.argv.slice(2));
|
|
|
10
10
|
|
|
11
11
|
function config() {
|
|
12
12
|
const servers = JSON.parse(fs.readFileSync(new URL('../dist/servers.json', import.meta.url), 'utf8'));
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (options.apiKey && typeof options.apiKey === 'string') {
|
|
14
|
+
options.publicAppId = options.apiKey;
|
|
15
|
+
}
|
|
16
|
+
if (!options.publicAppId || typeof options.publicAppId !== 'string') {
|
|
17
|
+
console.error('Missing required option "publicAppId", please provide the api key for your application using the "--publicAppId=" parameter');
|
|
18
|
+
console.error('\nExample: $ pendo config --publicAppId=3d0ffbc4-bd4d-438f-69b5-354efd574672');
|
|
16
19
|
process.exit(1);
|
|
17
20
|
}
|
|
18
21
|
if (!options.env || !servers[options.env]) {
|
|
@@ -25,7 +28,7 @@ function config() {
|
|
|
25
28
|
options.output = 'pendo.config.json';
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
const url = new URL(`agent/static/${options.
|
|
31
|
+
const url = new URL(`agent/static/${options.publicAppId}/config.json`, `https://${servers[options.env].assetHost}`).toString();
|
|
29
32
|
try {
|
|
30
33
|
https.get(url, function(response) {
|
|
31
34
|
let data = '';
|
|
@@ -43,24 +46,24 @@ function config() {
|
|
|
43
46
|
});
|
|
44
47
|
});
|
|
45
48
|
} catch (err) {
|
|
46
|
-
console.error(`Unable to download new Pendo Agent config file, please confirm the
|
|
49
|
+
console.error(`Unable to download new Pendo Agent config file, please confirm the publicAppId and contentHost. publicAppId=${options.publicAppId}, contentHost=${options.contentHost}`, err);
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
function configHelp() {
|
|
51
54
|
const environments = Object.keys(JSON.parse(fs.readFileSync(new URL('../dist/servers.json', import.meta.url), 'utf8')));
|
|
52
|
-
console.log(`Usage: pendo config --
|
|
55
|
+
console.log(`Usage: pendo config --publicAppId=<application_api_key> --env=<subscription_environment> [--output=<filename>]
|
|
53
56
|
|
|
54
57
|
Download a new configuration file for a specific application built from the most recent subscription and application settings.
|
|
55
58
|
|
|
56
59
|
Options:
|
|
57
|
-
--
|
|
60
|
+
--publicAppId required, the api key for your Pendo application, found in the application settings page in the Pendo app
|
|
58
61
|
--env required, the Pendo environment for your subscription, allowed environments: [${environments}]
|
|
59
62
|
--output optional, the name of where to save the config, defaults to "pendo.config.json"
|
|
60
63
|
|
|
61
64
|
Examples:
|
|
62
65
|
Download and save the configuration file from the default US environment
|
|
63
|
-
$ pendo config --
|
|
66
|
+
$ pendo config --publicAppId=dd753dfd-ac99-4c5c-48ad-6eb18190cf77 --env=io --output=pendo.config.json`);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
function copy() {
|
package/dist/dom.esm.js
CHANGED
|
@@ -6197,19 +6197,21 @@ var ConfigReader = (function () {
|
|
|
6197
6197
|
function initializeOptions() {
|
|
6198
6198
|
// Core
|
|
6199
6199
|
/**
|
|
6200
|
-
* When included, all analytics events will be sent to each of the
|
|
6201
|
-
* only sent to the primary
|
|
6200
|
+
* Formerly `additionalApiKeys`. When included, all analytics events will be sent to each of the public app IDs in the list (guide events are
|
|
6201
|
+
* only sent to the primary public app ID). This will only function if there are no `additionalPublicAppIds` set on
|
|
6202
6202
|
* the configuration included in the downloaded Agent.
|
|
6203
6203
|
*
|
|
6204
6204
|
* @access public
|
|
6205
6205
|
* @category Config/Core
|
|
6206
|
-
* @name
|
|
6206
|
+
* @name additionalPublicAppIds
|
|
6207
6207
|
* @default []
|
|
6208
6208
|
* @type {string[]}
|
|
6209
6209
|
*/
|
|
6210
|
+
addOption('additionalPublicAppIds', [PENDO_CONFIG_SRC, SNIPPET_SRC]);
|
|
6210
6211
|
addOption('additionalApiKeys', [PENDO_CONFIG_SRC, SNIPPET_SRC]);
|
|
6211
6212
|
addOption('allowedOriginServers');
|
|
6212
6213
|
addOption('allowedOriginServerHashes');
|
|
6214
|
+
addOption('allowMixedApplicationFrames', [SNIPPET_SRC, PENDO_CONFIG_SRC], true);
|
|
6213
6215
|
addOption('allowMixedApiKeyFrames', [SNIPPET_SRC, PENDO_CONFIG_SRC], true);
|
|
6214
6216
|
/**
|
|
6215
6217
|
* A function that returns either an array of strings or an object to decorate the url for events.
|
|
@@ -6223,15 +6225,16 @@ var ConfigReader = (function () {
|
|
|
6223
6225
|
*/
|
|
6224
6226
|
addOption('annotateUrl', [SNIPPET_SRC]);
|
|
6225
6227
|
/**
|
|
6226
|
-
* A primary
|
|
6228
|
+
* Formerly `apiKey`. A primary public app ID to send data to from the Agent. This will only function if there is no `publicAppId` set
|
|
6227
6229
|
* on the configuration included in the downloaded Agent.
|
|
6228
6230
|
*
|
|
6229
6231
|
* @access public
|
|
6230
6232
|
* @category Config/Core
|
|
6231
|
-
* @name
|
|
6233
|
+
* @name publicAppId
|
|
6232
6234
|
* @default undefined
|
|
6233
6235
|
* @type {string}
|
|
6234
6236
|
*/
|
|
6237
|
+
addOption('publicAppId', [PENDO_CONFIG_SRC, SNIPPET_SRC]);
|
|
6235
6238
|
addOption('apiKey', [PENDO_CONFIG_SRC, SNIPPET_SRC]);
|
|
6236
6239
|
addOption('assetHost', [SNIPPET_SRC, PENDO_CONFIG_SRC]);
|
|
6237
6240
|
/**
|
|
@@ -6869,18 +6872,19 @@ var ConfigReader = (function () {
|
|
|
6869
6872
|
*/
|
|
6870
6873
|
addOption('inlineStyleNonce', [SNIPPET_SRC]);
|
|
6871
6874
|
/**
|
|
6872
|
-
* Specify a preferred
|
|
6873
|
-
* guide display. In installations with more than 2
|
|
6874
|
-
* list (e.g. `
|
|
6875
|
-
* or only one frame should specify the
|
|
6875
|
+
* Formerly `leaderKey` Specify a preferred publicAppId to lead the multi-application iframe installation to make decisions about automatic
|
|
6876
|
+
* guide display. In installations with more than 2 publicAppIds, the leaderApplication can be specified as a priority
|
|
6877
|
+
* list (e.g. `leaderApplication: ['key1', 'key2', ...]`). Either all frames must agree on the leaderApplication setting,
|
|
6878
|
+
* or only one frame should specify the leaderApplication. If neither of these conditions are met, the default leader
|
|
6876
6879
|
* determination logic (top frame or earliest to join) will be used.
|
|
6877
6880
|
*
|
|
6878
6881
|
* @access public
|
|
6879
6882
|
* @category Config/Guides
|
|
6880
|
-
* @name
|
|
6883
|
+
* @name leaderApplication
|
|
6881
6884
|
* @default []
|
|
6882
6885
|
* @type {string[]}
|
|
6883
6886
|
*/
|
|
6887
|
+
addOption('leaderApplication', [SNIPPET_SRC, PENDO_CONFIG_SRC], []);
|
|
6884
6888
|
addOption('leaderKey', [SNIPPET_SRC, PENDO_CONFIG_SRC], []);
|
|
6885
6889
|
/**
|
|
6886
6890
|
* If `true`, custom code blocks in building block guides will not be allowed to run. Also, classic guides
|
|
@@ -6941,6 +6945,8 @@ var ConfigReader = (function () {
|
|
|
6941
6945
|
addOption('designerAgentPluginsLoader', [PENDO_CONFIG_SRC, SNIPPET_SRC]);
|
|
6942
6946
|
addOption('guideContentLoader', [PENDO_CONFIG_SRC]);
|
|
6943
6947
|
addOption('trainingPartner');
|
|
6948
|
+
addOption('oemAccountId', [SNIPPET_SRC]);
|
|
6949
|
+
addOption('whiteLabelSettings', [PENDO_CONFIG_SRC]);
|
|
6944
6950
|
// Frustration
|
|
6945
6951
|
addOption('errorClickLogging', [PENDO_CONFIG_SRC], false);
|
|
6946
6952
|
// Embedded Guides
|
|
@@ -6949,6 +6955,7 @@ var ConfigReader = (function () {
|
|
|
6949
6955
|
addOption('formValidation', [PENDO_CONFIG_SRC], false);
|
|
6950
6956
|
// Performance Metrics
|
|
6951
6957
|
addOption('performanceMetricsEnabled', [SNIPPET_SRC, PENDO_CONFIG_SRC], true);
|
|
6958
|
+
addOption('performanceMetricsSampleRate', [SNIPPET_SRC, PENDO_CONFIG_SRC], 0);
|
|
6952
6959
|
}
|
|
6953
6960
|
initializeOptions();
|
|
6954
6961
|
var sourceGetters = {};
|
|
@@ -7313,6 +7320,11 @@ function getAbsolutePosition(element, parentElement, _win) {
|
|
|
7313
7320
|
var terminalParent = isOffsetParent(parentElement) ? parentElement : getOffsetParent(parentElement, _win);
|
|
7314
7321
|
var parentRect = terminalParent ? getScreenPosition(terminalParent) : { top: 0, left: 0 };
|
|
7315
7322
|
var elemRect = getScreenPosition(element);
|
|
7323
|
+
var invertedMatrix2d = calculateInverseTransformMatrix2d(terminalParent);
|
|
7324
|
+
if (invertedMatrix2d) {
|
|
7325
|
+
parentRect = applyMatrix2dRect(invertedMatrix2d, parentRect);
|
|
7326
|
+
elemRect = applyMatrix2dRect(invertedMatrix2d, elemRect);
|
|
7327
|
+
}
|
|
7316
7328
|
var elementPosition = {
|
|
7317
7329
|
top: elemRect.top - parentRect.top,
|
|
7318
7330
|
left: elemRect.left - parentRect.left,
|
|
@@ -7359,8 +7371,64 @@ function getScreenPosition(element) {
|
|
|
7359
7371
|
height: rect.height || Math.abs(rect.bottom - rect.top)
|
|
7360
7372
|
};
|
|
7361
7373
|
}
|
|
7374
|
+
function calculateInverseTransformMatrix2d(element) {
|
|
7375
|
+
if (!element)
|
|
7376
|
+
return;
|
|
7377
|
+
var computedStyle = getComputedStyle_safe(element);
|
|
7378
|
+
var matrix2d = parseCssMatrix(computedStyle.transform);
|
|
7379
|
+
if (matrix2d && /^0px\s+0px/.test(computedStyle.transformOrigin)) {
|
|
7380
|
+
// only consider 2D tranforms that have a computed origin of top left
|
|
7381
|
+
return invertMatrix2d(matrix2d);
|
|
7382
|
+
}
|
|
7383
|
+
}
|
|
7384
|
+
function parseCssMatrix(cssMatrix) {
|
|
7385
|
+
if (!/^matrix\(/.test(cssMatrix))
|
|
7386
|
+
return;
|
|
7387
|
+
return cssMatrix.split(/\(|,|\)/).slice(1, -1).map(function (v) { return parseFloat(v); });
|
|
7388
|
+
}
|
|
7389
|
+
function invertMatrix2d(_a) {
|
|
7390
|
+
var a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4], f = _a[5];
|
|
7391
|
+
var determinant = a * d - b * c;
|
|
7392
|
+
// Matrix is not invertible if determinant is 0
|
|
7393
|
+
if (determinant === 0) {
|
|
7394
|
+
return null;
|
|
7395
|
+
}
|
|
7396
|
+
// Invert the 2D matrix
|
|
7397
|
+
// | a c e |
|
|
7398
|
+
// | b d f |
|
|
7399
|
+
// | 0 0 1 |
|
|
7400
|
+
return [
|
|
7401
|
+
d / determinant,
|
|
7402
|
+
-b / determinant,
|
|
7403
|
+
-c / determinant,
|
|
7404
|
+
a / determinant,
|
|
7405
|
+
(c * f - d * e) / determinant,
|
|
7406
|
+
(b * e - a * f) / determinant
|
|
7407
|
+
];
|
|
7408
|
+
}
|
|
7409
|
+
function applyMatrix2d(_a, _b) {
|
|
7410
|
+
var a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4], f = _a[5];
|
|
7411
|
+
var x = _b[0], y = _b[1];
|
|
7412
|
+
return [
|
|
7413
|
+
a * x + c * y + e,
|
|
7414
|
+
b * x + d * y + f
|
|
7415
|
+
];
|
|
7416
|
+
}
|
|
7417
|
+
function applyMatrix2dRect(matrix2d, rect) {
|
|
7418
|
+
var topLeft = applyMatrix2d(matrix2d, [rect.left, rect.top]);
|
|
7419
|
+
var bottomRight = applyMatrix2d(matrix2d, [rect.right, rect.bottom]);
|
|
7420
|
+
var transformedRect = {
|
|
7421
|
+
top: topLeft[1],
|
|
7422
|
+
left: topLeft[0],
|
|
7423
|
+
bottom: bottomRight[1],
|
|
7424
|
+
right: bottomRight[0]
|
|
7425
|
+
};
|
|
7426
|
+
transformedRect.width = transformedRect.right - transformedRect.left;
|
|
7427
|
+
transformedRect.height = transformedRect.bottom - transformedRect.top;
|
|
7428
|
+
return transformedRect;
|
|
7429
|
+
}
|
|
7362
7430
|
|
|
7363
|
-
var VERSION = '2.
|
|
7431
|
+
var VERSION = '2.308.1_';
|
|
7364
7432
|
|
|
7365
7433
|
var decodeURIComponent = _.isFunction(window.decodeURIComponent) ? window.decodeURIComponent : _.identity;
|
|
7366
7434
|
|
|
@@ -9307,7 +9375,7 @@ function scrollIntoView(element) {
|
|
|
9307
9375
|
* @class DomQuery
|
|
9308
9376
|
* @type {Element[]}
|
|
9309
9377
|
* @classdesc
|
|
9310
|
-
* Sort of like a diet, caffeine-free jQuery. Wrapper for Sizzle library with additional methods for the Pendo
|
|
9378
|
+
* Sort of like a diet, caffeine-free jQuery. Wrapper for Sizzle library with additional methods for the Pendo Web SDK.
|
|
9311
9379
|
* Use pendo.Sizzle for customer-defined selectors. Augmented Element[] used to query and alter DOM nodes.
|
|
9312
9380
|
*
|
|
9313
9381
|
* @access public
|