@fullstory/browser 1.7.1 → 2.0.0-beta.3
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 +2 -0
- package/dist/index.d.ts +38 -46
- package/dist/index.esm.js +144 -147
- package/dist/index.js +144 -158
- package/package.json +15 -10
- package/src/index.test.ts +172 -0
- package/src/index.ts +201 -0
- package/CHANGELOG.md +0 -107
- package/src/index.d.ts +0 -65
- package/src/index.js +0 -102
package/README.md
CHANGED
|
@@ -35,6 +35,8 @@ The only required option is `orgId`, all others are optional.
|
|
|
35
35
|
* `recordCrossDomainIFrames` - Defaults to `false`. FullStory can record cross-domain iFrames if: 1. The FullStory Browser SDK is running in the cross-domain iFrame and 2. `recordCrossDomainIFrames` is set to `true` in the cross-domain iFrame and 3. The FullStory Browser SDK is running in the parent page of the cross-domain iFrame. Click [here](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) for a detailed explanation of what "cross-domain" means. Before using, you should understand the security implications, and configure your [Content Security Policy](https://www.html5rocks.com/en/tutorials/security/content-security-policy/) (CSP) HTTP headers accordingly - specifically the frame-ancestors directive. Failure to configure your CSP headers while using this setting can bypass IFrames security protections that are included in modern browsers. More information about cross-domain iFrame recording can be found on our [Knowledge Base](https://help.fullstory.com/hc/en-us/articles/360020622514-Can-FullStory-capture-content-that-is-presented-in-iframes-#2-the-outer-page-is-running-fullstory-and-you-have-iframes-runni). Note: the `recordCrossDomainIFrames` parameter is the same as the `window['_fs_run_in_iframe']` referenced in the KB article.
|
|
36
36
|
* `recordOnlyThisIFrame` - When set to `true`, this tells FullStory that the IFrame is the "root" of the recording and should be its own session; defaults to `false`. Use this when your app is embedded in an IFrame on a site not running FullStory or when the site *is* running FullStory, but you want your content sent to a different FullStory org.
|
|
37
37
|
* `devMode` - Set to `true` if you want to deactivate FullStory in your development environment. When set to `true`, FullStory will shutdown recording and all subsequent SDK method calls will be no-ops. At the time `init` is called with `devMode: true`, a single `event` call will be sent to FullStory to indicate that the SDK is in `devMode`; this is to help trouble-shoot the case that the SDK was accidentally set to `devMode: true` in a production environment. Additionally, any calls to SDK methods will `console.warn` that FullStory is in `devMode`. Defaults to `false`.
|
|
38
|
+
* `startCaptureManually` - Set to `true` if you want to start capture manually using `FS('start')`. FullStory will load but wait for a call to `FS('start')` to begin capturing. See [Manually Delay Data Capture](https://developer.fullstory.com/browser/v2/auto-capture/capture-data/#manually-delay-data-capture) for more information. Defaults to `false`.
|
|
39
|
+
* `assetMapId` - Use this to set the current asset map id. See [Asset Uploading for Web](https://help.fullstory.com/hc/en-us/articles/4404129191575-Asset-Uploading-for-Web) for more information.
|
|
38
40
|
|
|
39
41
|
### Ready Callback
|
|
40
42
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FSApi } from '@fullstory/snippet';
|
|
1
2
|
/**
|
|
2
3
|
* FullStory Client SDK snippet options.
|
|
3
4
|
*
|
|
@@ -11,55 +12,46 @@
|
|
|
11
12
|
* - recordOnlyThisIFrame: FullStory can record the iFrame as its own unique session. Defaults to `false`. Additional conditions apply and can be found [here](https://help.fullstory.com/hc/en-us/articles/360020622514-Can-FullStory-capture-content-that-is-presented-in-iframes-#h_01F1G33B40Q2TPQA8MA7SF8Y5P).
|
|
12
13
|
* - devMode: In dev mode FullStory won't record sessions. Any calls to SDK methods will `console.warn` that FullStory is in `devMode`. Defaults to `false`.
|
|
13
14
|
*/
|
|
14
|
-
interface SnippetOptions {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
export interface SnippetOptions {
|
|
16
|
+
orgId: string;
|
|
17
|
+
assetMapId?: string;
|
|
18
|
+
cookieDomain?: string;
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
devMode?: boolean;
|
|
21
|
+
host?: string;
|
|
22
|
+
namespace?: string;
|
|
23
|
+
recordCrossDomainIFrames?: boolean;
|
|
24
|
+
recordOnlyThisIFrame?: boolean;
|
|
25
|
+
script?: string;
|
|
26
|
+
startCaptureManually?: boolean;
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
interface UserVars {
|
|
27
|
-
displayName?: string;
|
|
28
|
-
email?: string;
|
|
29
|
-
[key: string]: any;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type LogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
|
|
33
|
-
|
|
34
|
-
type VarScope = 'page';
|
|
35
|
-
|
|
36
28
|
/**
|
|
37
29
|
* A callback that will be invoked when FullStory has begun a session.
|
|
38
30
|
*
|
|
39
31
|
* `sessionUrl` contains the URL to the current session.
|
|
32
|
+
* `settings` contains the org settings for the current session.
|
|
40
33
|
*/
|
|
41
|
-
type ReadyCallback = (data: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export function getCurrentSessionURL(now?: boolean): string | null;
|
|
34
|
+
type ReadyCallback = (data: {
|
|
35
|
+
sessionUrl: string;
|
|
36
|
+
settings: Readonly<object>;
|
|
37
|
+
}) => void;
|
|
38
|
+
declare global {
|
|
39
|
+
interface Window {
|
|
40
|
+
_fs_asset_map_id?: string;
|
|
41
|
+
_fs_capture_on_startup?: boolean;
|
|
42
|
+
_fs_cookie_domain?: string;
|
|
43
|
+
_fs_debug?: boolean;
|
|
44
|
+
_fs_dev_mode?: boolean;
|
|
45
|
+
_fs_host?: string;
|
|
46
|
+
_fs_initialized?: boolean;
|
|
47
|
+
_fs_is_outer_script?: boolean;
|
|
48
|
+
_fs_namespace?: string;
|
|
49
|
+
_fs_org?: string;
|
|
50
|
+
_fs_run_in_iframe?: boolean;
|
|
51
|
+
_fs_script?: string;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export declare const init: (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => void;
|
|
55
|
+
export declare const isInitialized: () => boolean;
|
|
56
|
+
export declare const FullStory: FSApi;
|
|
57
|
+
export {};
|
package/dist/index.esm.js
CHANGED
|
@@ -1,163 +1,160 @@
|
|
|
1
1
|
import { initFS } from '@fullstory/snippet';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _defineProperty(obj, key, value) {
|
|
30
|
-
if (key in obj) {
|
|
31
|
-
Object.defineProperty(obj, key, {
|
|
32
|
-
value: value,
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true
|
|
36
|
-
});
|
|
37
|
-
} else {
|
|
38
|
-
obj[key] = value;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return obj;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var fs = function fs() {
|
|
45
|
-
return window[window._fs_namespace];
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
|
|
18
|
+
var __assign = function() {
|
|
19
|
+
__assign = Object.assign || function __assign(t) {
|
|
20
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
21
|
+
s = arguments[i];
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
46
27
|
};
|
|
47
28
|
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
29
|
+
var getFullStory = function () {
|
|
30
|
+
if (window._fs_namespace) {
|
|
31
|
+
return window[window._fs_namespace];
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
54
34
|
};
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return testNames.every(function (current) {
|
|
64
|
-
return fs()[current];
|
|
65
|
-
});
|
|
35
|
+
var ensureSnippetLoaded = function () {
|
|
36
|
+
var fs = getFullStory();
|
|
37
|
+
if (!fs) {
|
|
38
|
+
throw Error('FullStory is not loaded, please ensure the init function is invoked before calling FullStory API functions');
|
|
39
|
+
}
|
|
40
|
+
return fs;
|
|
66
41
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return message;
|
|
42
|
+
var _init = function (inputOptions, readyCallback) {
|
|
43
|
+
// Make a copy so we can modify `options` if desired.
|
|
44
|
+
var options = __assign({}, inputOptions);
|
|
45
|
+
if (getFullStory()) {
|
|
46
|
+
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
|
|
47
|
+
return;
|
|
74
48
|
}
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return (_fs = fs())[name].apply(_fs, arguments);
|
|
49
|
+
// see README for details on the recordCrossDomainIFrames option
|
|
50
|
+
if (options.recordCrossDomainIFrames) {
|
|
51
|
+
window._fs_run_in_iframe = true;
|
|
80
52
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
53
|
+
if (options.assetMapId) {
|
|
54
|
+
window._fs_asset_map_id = options.assetMapId;
|
|
55
|
+
}
|
|
56
|
+
if (options.startCaptureManually) {
|
|
57
|
+
window._fs_capture_on_startup = false;
|
|
58
|
+
}
|
|
59
|
+
// record the contents of this iFrame when embedded in a parent site
|
|
60
|
+
if (options.recordOnlyThisIFrame) {
|
|
61
|
+
window._fs_is_outer_script = true;
|
|
62
|
+
}
|
|
63
|
+
// Set cookie domain if it was specified.
|
|
64
|
+
if (options.cookieDomain) {
|
|
65
|
+
window._fs_cookie_domain = options.cookieDomain;
|
|
66
|
+
}
|
|
67
|
+
if (options.debug === true) {
|
|
68
|
+
if (!options.script) {
|
|
69
|
+
options.script = 'edge.fullstory.com/s/fs-debug.js';
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.warn('Ignoring `debug = true` because `script` is set');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
initFS(options);
|
|
76
|
+
var fs = getFullStory();
|
|
77
|
+
if (!fs) {
|
|
78
|
+
console.warn('Failed to initialize FS snippet');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (readyCallback) {
|
|
82
|
+
fs('observe', { type: 'start', callback: readyCallback });
|
|
83
|
+
}
|
|
84
|
+
if (options.devMode === true) {
|
|
85
|
+
var message = 'FullStory was initialized in devMode and will stop recording';
|
|
86
|
+
fs('trackEvent', {
|
|
87
|
+
name: 'FullStory Dev Mode',
|
|
88
|
+
properties: {
|
|
89
|
+
message_str: message,
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
fs('shutdown');
|
|
93
|
+
window._fs_dev_mode = true;
|
|
94
|
+
console.warn(message);
|
|
123
95
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
initFS(options);
|
|
127
|
-
|
|
128
|
-
if (readyCallback) {
|
|
129
|
-
fs()('observe', {
|
|
130
|
-
type: 'start',
|
|
131
|
-
callback: readyCallback
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (options.devMode === true) {
|
|
136
|
-
var message = 'FullStory was initialized in devMode and will stop recording';
|
|
137
|
-
event('FullStory Dev Mode', {
|
|
138
|
-
message_str: message
|
|
139
|
-
});
|
|
140
|
-
shutdown();
|
|
141
|
-
window._fs_dev_mode = true;
|
|
142
|
-
console.warn(message);
|
|
143
|
-
}
|
|
144
96
|
};
|
|
145
|
-
|
|
146
|
-
var initOnce = function initOnce(fn, message) {
|
|
147
|
-
return function () {
|
|
97
|
+
var initOnce = function (message) { return function (inputOptions, readyCallback) {
|
|
148
98
|
if (window._fs_initialized) {
|
|
149
|
-
|
|
150
|
-
|
|
99
|
+
if (message)
|
|
100
|
+
console.warn(message);
|
|
101
|
+
return;
|
|
151
102
|
}
|
|
152
|
-
|
|
153
|
-
fn.apply(void 0, arguments);
|
|
103
|
+
_init(inputOptions, readyCallback);
|
|
154
104
|
window._fs_initialized = true;
|
|
155
|
-
|
|
105
|
+
}; };
|
|
106
|
+
var init = initOnce('FullStory init has already been called once, additional invocations are ignored');
|
|
107
|
+
// normalize undefined into boolean
|
|
108
|
+
var isInitialized = function () { return !!window._fs_initialized; };
|
|
109
|
+
var hasFullStoryWithFunction = function () {
|
|
110
|
+
var testNames = [];
|
|
111
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
112
|
+
testNames[_i] = arguments[_i];
|
|
113
|
+
}
|
|
114
|
+
var fs = ensureSnippetLoaded();
|
|
115
|
+
return testNames.every(function (current) { return fs[current]; });
|
|
156
116
|
};
|
|
157
|
-
|
|
158
|
-
var
|
|
159
|
-
var
|
|
160
|
-
|
|
117
|
+
var guard = function (name) { return function () {
|
|
118
|
+
var args = [];
|
|
119
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
120
|
+
args[_i] = arguments[_i];
|
|
121
|
+
}
|
|
122
|
+
if (window._fs_dev_mode) {
|
|
123
|
+
var message = "FullStory is in dev mode and is not recording: ".concat(name, " method not executed");
|
|
124
|
+
console.warn(message);
|
|
125
|
+
return message;
|
|
126
|
+
}
|
|
127
|
+
var fs = getFullStory();
|
|
128
|
+
if (hasFullStoryWithFunction(name) && fs) {
|
|
129
|
+
return fs[name].apply(fs, args);
|
|
130
|
+
}
|
|
131
|
+
console.warn("FS.".concat(name, " not ready"));
|
|
132
|
+
return null;
|
|
133
|
+
}; };
|
|
134
|
+
var buildFullStoryShim = function () {
|
|
135
|
+
var FS = function (operation, options, source) {
|
|
136
|
+
var fs = ensureSnippetLoaded();
|
|
137
|
+
if (window._fs_dev_mode) {
|
|
138
|
+
var message = 'FullStory is in dev mode and is not recording: method not executed';
|
|
139
|
+
console.warn(message);
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
return fs(operation, options, source);
|
|
143
|
+
};
|
|
144
|
+
FS.anonymize = guard('anonymize');
|
|
145
|
+
FS.consent = guard('consent');
|
|
146
|
+
FS.disableConsole = guard('disableConsole');
|
|
147
|
+
FS.enableConsole = guard('enableConsole');
|
|
148
|
+
FS.event = guard('event');
|
|
149
|
+
FS.getCurrentSessionURL = guard('getCurrentSessionURL');
|
|
150
|
+
FS.identify = guard('identify');
|
|
151
|
+
FS.log = guard('log');
|
|
152
|
+
FS.restart = guard('restart');
|
|
153
|
+
FS.setUserVars = guard('setUserVars');
|
|
154
|
+
FS.setVars = guard('setVars');
|
|
155
|
+
FS.shutdown = guard('shutdown');
|
|
156
|
+
return FS;
|
|
161
157
|
};
|
|
158
|
+
var FullStory = buildFullStoryShim();
|
|
162
159
|
|
|
163
|
-
export {
|
|
160
|
+
export { FullStory, init, isInitialized };
|