@fullstory/browser 1.7.0 → 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 +140 -250
- package/dist/index.js +140 -261
- package/package.json +18 -10
- package/src/index.test.ts +172 -0
- package/src/index.ts +189 -0
- package/CHANGELOG.md +0 -102
- package/src/index.d.ts +0 -65
- package/src/index.js +0 -102
- package/src/snippet.js +0 -40
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,264 +1,154 @@
|
|
|
1
|
-
|
|
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
|
-
function _defineProperty(obj, key, value) {
|
|
28
|
-
if (key in obj) {
|
|
29
|
-
Object.defineProperty(obj, key, {
|
|
30
|
-
value: value,
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true
|
|
34
|
-
});
|
|
35
|
-
} else {
|
|
36
|
-
obj[key] = value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return obj;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var snippet = function snippet(_ref) {
|
|
43
|
-
var orgId = _ref.orgId,
|
|
44
|
-
_ref$namespace = _ref.namespace,
|
|
45
|
-
namespace = _ref$namespace === void 0 ? 'FS' : _ref$namespace,
|
|
46
|
-
_ref$debug = _ref.debug,
|
|
47
|
-
_ref$host = _ref.host,
|
|
48
|
-
host = _ref$host === void 0 ? 'fullstory.com' : _ref$host,
|
|
49
|
-
_ref$script = _ref.script,
|
|
50
|
-
script = _ref$script === void 0 ? 'edge.fullstory.com/s/fs.js' : _ref$script;
|
|
51
|
-
|
|
52
|
-
if (!orgId) {
|
|
53
|
-
throw new Error('FullStory orgId is a required parameter');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
window['_fs_host'] = host;
|
|
57
|
-
window['_fs_script'] = script;
|
|
58
|
-
window['_fs_org'] = orgId;
|
|
59
|
-
window['_fs_namespace'] = namespace;
|
|
60
|
-
|
|
61
|
-
(function (m, n, e, t, l, o, g, y) {
|
|
62
|
-
if (e in m) {
|
|
63
|
-
if (m.console && m.console.log) {
|
|
64
|
-
m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
g = m[e] = function (a, b, s) {
|
|
71
|
-
g.q ? g.q.push([a, b, s]) : g._api(a, b, s);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
g.q = [];
|
|
75
|
-
o = n.createElement(t);
|
|
76
|
-
o.async = 1;
|
|
77
|
-
o.crossOrigin = 'anonymous';
|
|
78
|
-
o.src = 'https://' + _fs_script;
|
|
79
|
-
y = n.getElementsByTagName(t)[0];
|
|
80
|
-
y.parentNode.insertBefore(o, y);
|
|
81
|
-
|
|
82
|
-
g.identify = function (i, v, s) {
|
|
83
|
-
g(l, {
|
|
84
|
-
uid: i
|
|
85
|
-
}, s);
|
|
86
|
-
if (v) g(l, v, s);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
g.setUserVars = function (v, s) {
|
|
90
|
-
g(l, v, s);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
g.event = function (i, v, s) {
|
|
94
|
-
g('event', {
|
|
95
|
-
n: i,
|
|
96
|
-
p: v
|
|
97
|
-
}, s);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
g.anonymize = function () {
|
|
101
|
-
g.identify(!!0);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
g.shutdown = function () {
|
|
105
|
-
g("rec", !1);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
g.restart = function () {
|
|
109
|
-
g("rec", !0);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
g.log = function (a, b) {
|
|
113
|
-
g("log", [a, b]);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
g.consent = function (a) {
|
|
117
|
-
g("consent", !arguments.length || a);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
g.identifyAccount = function (i, v) {
|
|
121
|
-
o = 'account';
|
|
122
|
-
v = v || {};
|
|
123
|
-
v.acctId = i;
|
|
124
|
-
g(o, v);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
g.clearUserCookie = function () {};
|
|
128
|
-
|
|
129
|
-
g.setVars = function (n, p) {
|
|
130
|
-
g('setVars', [n, p]);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
g._w = {};
|
|
134
|
-
y = 'XMLHttpRequest';
|
|
135
|
-
g._w[y] = m[y];
|
|
136
|
-
y = 'fetch';
|
|
137
|
-
g._w[y] = m[y];
|
|
138
|
-
if (m[y]) m[y] = function () {
|
|
139
|
-
return g._w[y].apply(this, arguments);
|
|
140
|
-
};
|
|
141
|
-
g._v = "1.3.0";
|
|
142
|
-
})(window, document, window['_fs_namespace'], 'script', 'user');
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
var fs = function fs() {
|
|
146
|
-
return window[window._fs_namespace];
|
|
1
|
+
import { initFS } from '@fullstory/snippet';
|
|
2
|
+
|
|
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);
|
|
147
27
|
};
|
|
148
28
|
|
|
149
|
-
var
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
29
|
+
var getFullStory = function () {
|
|
30
|
+
if (window._fs_namespace) {
|
|
31
|
+
return window[window._fs_namespace];
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
155
34
|
};
|
|
156
|
-
|
|
157
|
-
var
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return testNames.every(function (current) {
|
|
165
|
-
return fs()[current];
|
|
166
|
-
});
|
|
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;
|
|
167
41
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
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;
|
|
175
48
|
}
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
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;
|
|
181
52
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
var
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (options.debug === true) {
|
|
220
|
-
if (!options.script) {
|
|
221
|
-
options.script = 'edge.fullstory.com/s/fs-debug.js';
|
|
222
|
-
} else {
|
|
223
|
-
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);
|
|
224
89
|
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
snippet(options);
|
|
228
|
-
|
|
229
|
-
if (readyCallback) {
|
|
230
|
-
fs()('observe', {
|
|
231
|
-
type: 'start',
|
|
232
|
-
callback: readyCallback
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (options.devMode === true) {
|
|
237
|
-
var message = 'FullStory was initialized in devMode and will stop recording';
|
|
238
|
-
event('FullStory Dev Mode', {
|
|
239
|
-
message_str: message
|
|
240
|
-
});
|
|
241
|
-
shutdown();
|
|
242
|
-
window._fs_dev_mode = true;
|
|
243
|
-
console.warn(message);
|
|
244
|
-
}
|
|
245
90
|
};
|
|
246
|
-
|
|
247
|
-
var initOnce = function initOnce(fn, message) {
|
|
248
|
-
return function () {
|
|
91
|
+
var initOnce = function (message) { return function (inputOptions, readyCallback) {
|
|
249
92
|
if (window._fs_initialized) {
|
|
250
|
-
|
|
251
|
-
|
|
93
|
+
if (message)
|
|
94
|
+
console.warn(message);
|
|
95
|
+
return;
|
|
252
96
|
}
|
|
253
|
-
|
|
254
|
-
fn.apply(void 0, arguments);
|
|
97
|
+
_init(inputOptions, readyCallback);
|
|
255
98
|
window._fs_initialized = true;
|
|
256
|
-
|
|
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]; });
|
|
257
110
|
};
|
|
258
|
-
|
|
259
|
-
var
|
|
260
|
-
var
|
|
261
|
-
|
|
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;
|
|
262
151
|
};
|
|
152
|
+
var FullStory = buildFullStoryShim();
|
|
263
153
|
|
|
264
|
-
export {
|
|
154
|
+
export { FullStory, init, isInitialized };
|