@fullstory/browser 1.7.1 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +34 -46
- package/dist/index.esm.js +138 -147
- package/dist/index.js +138 -158
- package/package.json +15 -10
- package/src/index.test.ts +172 -0
- package/src/index.ts +189 -0
- package/CHANGELOG.md +0 -107
- package/src/index.d.ts +0 -65
- package/src/index.js +0 -102
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,42 @@
|
|
|
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
|
+
namespace?: string;
|
|
18
|
+
debug?: boolean;
|
|
19
|
+
host?: string;
|
|
20
|
+
script?: string;
|
|
21
|
+
cookieDomain?: string;
|
|
22
|
+
recordCrossDomainIFrames?: boolean;
|
|
23
|
+
recordOnlyThisIFrame?: boolean;
|
|
24
|
+
devMode?: boolean;
|
|
24
25
|
}
|
|
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
26
|
/**
|
|
37
27
|
* A callback that will be invoked when FullStory has begun a session.
|
|
38
28
|
*
|
|
39
29
|
* `sessionUrl` contains the URL to the current session.
|
|
30
|
+
* `settings` contains the org settings for the current session.
|
|
40
31
|
*/
|
|
41
|
-
type ReadyCallback = (data: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
// API functions that are available after /rec/page returns.
|
|
64
|
-
// FullStory bootstrapping details: https://help.fullstory.com/hc/en-us/articles/360032975773
|
|
65
|
-
export function getCurrentSessionURL(now?: boolean): string | null;
|
|
32
|
+
type ReadyCallback = (data: {
|
|
33
|
+
sessionUrl: string;
|
|
34
|
+
settings: Readonly<object>;
|
|
35
|
+
}) => void;
|
|
36
|
+
declare global {
|
|
37
|
+
interface Window {
|
|
38
|
+
_fs_cookie_domain?: string;
|
|
39
|
+
_fs_debug?: boolean;
|
|
40
|
+
_fs_dev_mode?: boolean;
|
|
41
|
+
_fs_host?: string;
|
|
42
|
+
_fs_initialized?: boolean;
|
|
43
|
+
_fs_is_outer_script?: boolean;
|
|
44
|
+
_fs_namespace?: string;
|
|
45
|
+
_fs_org?: string;
|
|
46
|
+
_fs_run_in_iframe?: boolean;
|
|
47
|
+
_fs_script?: string;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export declare const init: (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => void;
|
|
51
|
+
export declare const isInitialized: () => boolean;
|
|
52
|
+
export declare const FullStory: FSApi;
|
|
53
|
+
export {};
|
package/dist/index.esm.js
CHANGED
|
@@ -1,163 +1,154 @@
|
|
|
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
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (options.debug === true) {
|
|
119
|
-
if (!options.script) {
|
|
120
|
-
options.script = 'edge.fullstory.com/s/fs-debug.js';
|
|
121
|
-
} else {
|
|
122
|
-
console.warn('Ignoring `debug = true` because `script` is set');
|
|
53
|
+
// record the contents of this iFrame when embedded in a parent site
|
|
54
|
+
if (options.recordOnlyThisIFrame) {
|
|
55
|
+
window._fs_is_outer_script = true;
|
|
56
|
+
}
|
|
57
|
+
// Set cookie domain if it was specified.
|
|
58
|
+
if (options.cookieDomain) {
|
|
59
|
+
window._fs_cookie_domain = options.cookieDomain;
|
|
60
|
+
}
|
|
61
|
+
if (options.debug === true) {
|
|
62
|
+
if (!options.script) {
|
|
63
|
+
options.script = 'edge.fullstory.com/s/fs-debug.js';
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.warn('Ignoring `debug = true` because `script` is set');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
initFS(options);
|
|
70
|
+
var fs = getFullStory();
|
|
71
|
+
if (!fs) {
|
|
72
|
+
console.warn('Failed to initialize FS snippet');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (readyCallback) {
|
|
76
|
+
fs('observe', { type: 'start', callback: readyCallback });
|
|
77
|
+
}
|
|
78
|
+
if (options.devMode === true) {
|
|
79
|
+
var message = 'FullStory was initialized in devMode and will stop recording';
|
|
80
|
+
fs('trackEvent', {
|
|
81
|
+
name: 'FullStory Dev Mode',
|
|
82
|
+
properties: {
|
|
83
|
+
message_str: message,
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
fs('shutdown');
|
|
87
|
+
window._fs_dev_mode = true;
|
|
88
|
+
console.warn(message);
|
|
123
89
|
}
|
|
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
90
|
};
|
|
145
|
-
|
|
146
|
-
var initOnce = function initOnce(fn, message) {
|
|
147
|
-
return function () {
|
|
91
|
+
var initOnce = function (message) { return function (inputOptions, readyCallback) {
|
|
148
92
|
if (window._fs_initialized) {
|
|
149
|
-
|
|
150
|
-
|
|
93
|
+
if (message)
|
|
94
|
+
console.warn(message);
|
|
95
|
+
return;
|
|
151
96
|
}
|
|
152
|
-
|
|
153
|
-
fn.apply(void 0, arguments);
|
|
97
|
+
_init(inputOptions, readyCallback);
|
|
154
98
|
window._fs_initialized = true;
|
|
155
|
-
|
|
99
|
+
}; };
|
|
100
|
+
var init = initOnce('FullStory init has already been called once, additional invocations are ignored');
|
|
101
|
+
// normalize undefined into boolean
|
|
102
|
+
var isInitialized = function () { return !!window._fs_initialized; };
|
|
103
|
+
var hasFullStoryWithFunction = function () {
|
|
104
|
+
var testNames = [];
|
|
105
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
106
|
+
testNames[_i] = arguments[_i];
|
|
107
|
+
}
|
|
108
|
+
var fs = ensureSnippetLoaded();
|
|
109
|
+
return testNames.every(function (current) { return fs[current]; });
|
|
156
110
|
};
|
|
157
|
-
|
|
158
|
-
var
|
|
159
|
-
var
|
|
160
|
-
|
|
111
|
+
var guard = function (name) { return function () {
|
|
112
|
+
var args = [];
|
|
113
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
114
|
+
args[_i] = arguments[_i];
|
|
115
|
+
}
|
|
116
|
+
if (window._fs_dev_mode) {
|
|
117
|
+
var message = "FullStory is in dev mode and is not recording: ".concat(name, " method not executed");
|
|
118
|
+
console.warn(message);
|
|
119
|
+
return message;
|
|
120
|
+
}
|
|
121
|
+
var fs = getFullStory();
|
|
122
|
+
if (hasFullStoryWithFunction(name) && fs) {
|
|
123
|
+
return fs[name].apply(fs, args);
|
|
124
|
+
}
|
|
125
|
+
console.warn("FS.".concat(name, " not ready"));
|
|
126
|
+
return null;
|
|
127
|
+
}; };
|
|
128
|
+
var buildFullStoryShim = function () {
|
|
129
|
+
var FS = function (operation, options, source) {
|
|
130
|
+
var fs = ensureSnippetLoaded();
|
|
131
|
+
if (window._fs_dev_mode) {
|
|
132
|
+
var message = 'FullStory is in dev mode and is not recording: method not executed';
|
|
133
|
+
console.warn(message);
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
return fs(operation, options, source);
|
|
137
|
+
};
|
|
138
|
+
FS.anonymize = guard('anonymize');
|
|
139
|
+
FS.consent = guard('consent');
|
|
140
|
+
FS.disableConsole = guard('disableConsole');
|
|
141
|
+
FS.enableConsole = guard('enableConsole');
|
|
142
|
+
FS.event = guard('event');
|
|
143
|
+
FS.getCurrentSessionURL = guard('getCurrentSessionURL');
|
|
144
|
+
FS.identify = guard('identify');
|
|
145
|
+
FS.log = guard('log');
|
|
146
|
+
FS.restart = guard('restart');
|
|
147
|
+
FS.setUserVars = guard('setUserVars');
|
|
148
|
+
FS.setVars = guard('setVars');
|
|
149
|
+
FS.shutdown = guard('shutdown');
|
|
150
|
+
return FS;
|
|
161
151
|
};
|
|
152
|
+
var FullStory = buildFullStoryShim();
|
|
162
153
|
|
|
163
|
-
export {
|
|
154
|
+
export { FullStory, init, isInitialized };
|