@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/src/index.ts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { initFS, FSApi } from '@fullstory/snippet';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* FullStory Client SDK snippet options.
|
|
5
|
+
*
|
|
6
|
+
* - orgId: Reference for your [Org Id](https://help.fullstory.com/hc/en-us/articles/360047075853) listed in FullStory.
|
|
7
|
+
* - namespace: Global object name that contains the FullStory browser API methods and properties. Defaults to `FS`.
|
|
8
|
+
* - debug: Debug mode with extra browser console logging.
|
|
9
|
+
* - host: The recording server host domain. Can be set to direct recorded events to a proxy that you host. Defaults to `fullstory.com`.
|
|
10
|
+
* - script: FullStory script host domain. FullStory hosts the `fs.js` recording script on a CDN, but you can choose to host a copy yourself. Defaults to `edge.fullstory.com`.
|
|
11
|
+
* - cookieDomain: Overrides the cookie domain. By default, cookies will be valid for all subdomains of your site; if you want to limit the cookies to a specific subdomain, you can set the domain value explicitly. More information can be found [here](https://help.fullstory.com/hc/en-us/articles/360020622874-Can-the-FullStory-cookie-be-associated-with-a-specific-subdomain-).
|
|
12
|
+
* - recordCrossDomainIFrames: FullStory can record cross-domain iFrames. Defaults to `false`. Certain limitations 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_01F1G333PYKPGZ4B42WDBV3YKV).
|
|
13
|
+
* - 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).
|
|
14
|
+
* - 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`.
|
|
15
|
+
*/
|
|
16
|
+
export interface SnippetOptions {
|
|
17
|
+
orgId: string;
|
|
18
|
+
assetMapId?: string;
|
|
19
|
+
cookieDomain?: string;
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
devMode?: boolean;
|
|
22
|
+
host?: string;
|
|
23
|
+
namespace?: string;
|
|
24
|
+
recordCrossDomainIFrames?: boolean;
|
|
25
|
+
recordOnlyThisIFrame?: boolean;
|
|
26
|
+
script?: string;
|
|
27
|
+
startCaptureManually?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A callback that will be invoked when FullStory has begun a session.
|
|
32
|
+
*
|
|
33
|
+
* `sessionUrl` contains the URL to the current session.
|
|
34
|
+
* `settings` contains the org settings for the current session.
|
|
35
|
+
*/
|
|
36
|
+
type ReadyCallback = (data: { sessionUrl: string, settings: Readonly<object> }) => void;
|
|
37
|
+
|
|
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
|
+
|
|
55
|
+
const getFullStory = (): FSApi | undefined => {
|
|
56
|
+
if (window._fs_namespace) {
|
|
57
|
+
return window[window._fs_namespace];
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const ensureSnippetLoaded = (): FSApi => {
|
|
63
|
+
const fs = getFullStory();
|
|
64
|
+
if (!fs) {
|
|
65
|
+
throw Error(
|
|
66
|
+
'FullStory is not loaded, please ensure the init function is invoked before calling FullStory API functions'
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return fs;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const _init = (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => {
|
|
74
|
+
// Make a copy so we can modify `options` if desired.
|
|
75
|
+
const options = { ...inputOptions };
|
|
76
|
+
if (getFullStory()) {
|
|
77
|
+
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// see README for details on the recordCrossDomainIFrames option
|
|
82
|
+
if (options.recordCrossDomainIFrames) {
|
|
83
|
+
window._fs_run_in_iframe = true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (options.assetMapId) {
|
|
87
|
+
window._fs_asset_map_id = options.assetMapId;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (options.startCaptureManually) {
|
|
91
|
+
window._fs_capture_on_startup = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// record the contents of this iFrame when embedded in a parent site
|
|
95
|
+
if (options.recordOnlyThisIFrame) {
|
|
96
|
+
window._fs_is_outer_script = true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Set cookie domain if it was specified.
|
|
100
|
+
if (options.cookieDomain) {
|
|
101
|
+
window._fs_cookie_domain = options.cookieDomain;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (options.debug === true) {
|
|
105
|
+
if (!options.script) {
|
|
106
|
+
options.script = 'edge.fullstory.com/s/fs-debug.js';
|
|
107
|
+
} else {
|
|
108
|
+
console.warn('Ignoring `debug = true` because `script` is set');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
initFS(options);
|
|
113
|
+
|
|
114
|
+
const fs = getFullStory();
|
|
115
|
+
|
|
116
|
+
if (!fs) {
|
|
117
|
+
console.warn('Failed to initialize FS snippet');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (readyCallback) {
|
|
122
|
+
fs('observe', { type: 'start', callback: readyCallback });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (options.devMode === true) {
|
|
126
|
+
const message = 'FullStory was initialized in devMode and will stop recording';
|
|
127
|
+
fs('trackEvent', {
|
|
128
|
+
name: 'FullStory Dev Mode',
|
|
129
|
+
properties: {
|
|
130
|
+
message_str: message,
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
fs('shutdown');
|
|
134
|
+
window._fs_dev_mode = true;
|
|
135
|
+
console.warn(message);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const initOnce = (message) => (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => {
|
|
140
|
+
if (window._fs_initialized) {
|
|
141
|
+
if (message) console.warn(message);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
_init(inputOptions, readyCallback);
|
|
145
|
+
window._fs_initialized = true;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const init = initOnce('FullStory init has already been called once, additional invocations are ignored');
|
|
149
|
+
|
|
150
|
+
// normalize undefined into boolean
|
|
151
|
+
export const isInitialized = () => !!window._fs_initialized;
|
|
152
|
+
|
|
153
|
+
const hasFullStoryWithFunction = (...testNames) => {
|
|
154
|
+
const fs = ensureSnippetLoaded();
|
|
155
|
+
return testNames.every((current) => fs[current]);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const guard = (name) => (...args) => {
|
|
159
|
+
if (window._fs_dev_mode) {
|
|
160
|
+
const message = `FullStory is in dev mode and is not recording: ${name} method not executed`;
|
|
161
|
+
console.warn(message);
|
|
162
|
+
return message;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const fs = getFullStory();
|
|
166
|
+
if (hasFullStoryWithFunction(name) && fs) {
|
|
167
|
+
return fs[name](...args);
|
|
168
|
+
}
|
|
169
|
+
console.warn(`FS.${name} not ready`);
|
|
170
|
+
return null;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const buildFullStoryShim = (): FSApi => {
|
|
174
|
+
const FS = (operation, options, source) => {
|
|
175
|
+
const fs = ensureSnippetLoaded();
|
|
176
|
+
|
|
177
|
+
if (window._fs_dev_mode) {
|
|
178
|
+
const message = 'FullStory is in dev mode and is not recording: method not executed';
|
|
179
|
+
console.warn(message);
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return fs(operation, options, source);
|
|
184
|
+
};
|
|
185
|
+
FS.anonymize = guard('anonymize');
|
|
186
|
+
FS.consent = guard('consent');
|
|
187
|
+
FS.disableConsole = guard('disableConsole');
|
|
188
|
+
FS.enableConsole = guard('enableConsole');
|
|
189
|
+
FS.event = guard('event');
|
|
190
|
+
FS.getCurrentSessionURL = guard('getCurrentSessionURL');
|
|
191
|
+
FS.identify = guard('identify');
|
|
192
|
+
FS.log = guard('log');
|
|
193
|
+
FS.restart = guard('restart');
|
|
194
|
+
FS.setUserVars = guard('setUserVars');
|
|
195
|
+
FS.setVars = guard('setVars');
|
|
196
|
+
FS.shutdown = guard('shutdown');
|
|
197
|
+
|
|
198
|
+
return FS;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const FullStory: FSApi = buildFullStoryShim();
|
package/CHANGELOG.md
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 1.7.1
|
|
4
|
-
|
|
5
|
-
- Changed FullStory Snippet to import from @fullstory/snippet
|
|
6
|
-
- Npm audit updates
|
|
7
|
-
|
|
8
|
-
## 1.7.0
|
|
9
|
-
|
|
10
|
-
- Add a `cookieDomain` option to the `init` function to support setting `_fs_cookie_domain`.
|
|
11
|
-
|
|
12
|
-
## 1.6.2
|
|
13
|
-
|
|
14
|
-
- Load `fs-debug.js` capture script when `debug = true` option is used to match [updated debug logging practices](https://help.fullstory.com/hc/en-us/articles/360020829233-What-is-fs-debug-).
|
|
15
|
-
|
|
16
|
-
## 1.6.1
|
|
17
|
-
|
|
18
|
-
- Fix a TypeScript type issue with the `readyCallback` API (#144)
|
|
19
|
-
- Add a RELEASING doc (#143)
|
|
20
|
-
## 1.6.0
|
|
21
|
-
|
|
22
|
-
- Add a `readyCallback` parameter to the `init` function (#140)
|
|
23
|
-
- Add an `isInitialized` API (#130)
|
|
24
|
-
- Automated dependency updates
|
|
25
|
-
|
|
26
|
-
## 1.5.1
|
|
27
|
-
|
|
28
|
-
- Updating README to include `host` and `script` configuration options
|
|
29
|
-
|
|
30
|
-
## 1.5.0
|
|
31
|
-
|
|
32
|
-
- Adding the `setVars` API function
|
|
33
|
-
|
|
34
|
-
## 1.4.10
|
|
35
|
-
|
|
36
|
-
- Adding docs to the types file (index.d.ts)
|
|
37
|
-
|
|
38
|
-
## 1.4.8
|
|
39
|
-
|
|
40
|
-
- Updating README to better describe the behavior of the `recordCrossDomainIFrames` option
|
|
41
|
-
|
|
42
|
-
## 1.4.7
|
|
43
|
-
- Updating README to include vue 3
|
|
44
|
-
- `npm audit fix` to clean up npm audit warnings
|
|
45
|
-
|
|
46
|
-
## 1.4.6
|
|
47
|
-
|
|
48
|
-
- Updating snippet.js to include the latest snippet version
|
|
49
|
-
|
|
50
|
-
## 1.4.5
|
|
51
|
-
|
|
52
|
-
- `npm audit fix` to clean up npm audit warnings
|
|
53
|
-
|
|
54
|
-
## 1.4.4
|
|
55
|
-
|
|
56
|
-
- Adding a Vue.js initialization example to the readme
|
|
57
|
-
|
|
58
|
-
## 1.4.3
|
|
59
|
-
|
|
60
|
-
- Updating README to include a link to instructions on how to find the FullStory Org Id
|
|
61
|
-
|
|
62
|
-
## 1.4.2
|
|
63
|
-
|
|
64
|
-
- Nothing to see here - bumping the version to fix a faulty CircleCI build
|
|
65
|
-
|
|
66
|
-
## 1.4.1
|
|
67
|
-
|
|
68
|
-
- Updated Angular sample to demo `devMode` configuration option
|
|
69
|
-
|
|
70
|
-
## 1.4.0
|
|
71
|
-
|
|
72
|
-
- Adding `devMode` configuration option
|
|
73
|
-
|
|
74
|
-
## 1.3.1
|
|
75
|
-
|
|
76
|
-
- Reformatting init() options doc in the README
|
|
77
|
-
|
|
78
|
-
## 1.3.0
|
|
79
|
-
|
|
80
|
-
* Added init() options that control IFrame recording
|
|
81
|
-
* Updated README to include option descriptions and usage
|
|
82
|
-
* Updated README with Angular example
|
|
83
|
-
|
|
84
|
-
## 1.2.3
|
|
85
|
-
|
|
86
|
-
* Incorporate FS.anonymize method now included in the core snippet
|
|
87
|
-
* Update minimist version for package dev package dependancies to fix npm audit alert
|
|
88
|
-
|
|
89
|
-
## 1.2.2
|
|
90
|
-
|
|
91
|
-
Update npm package dependancies on the acorn package to get a clean npm audit
|
|
92
|
-
|
|
93
|
-
## 1.2.1
|
|
94
|
-
|
|
95
|
-
Automatic snippet update from FullStory
|
|
96
|
-
|
|
97
|
-
## 1.2.0
|
|
98
|
-
|
|
99
|
-
Supporting CommonJS builds
|
|
100
|
-
|
|
101
|
-
## 1.1.0
|
|
102
|
-
|
|
103
|
-
Snippet updates for improving XHR and Fetch API recording fidelity
|
|
104
|
-
|
|
105
|
-
## 1.0.0
|
|
106
|
-
|
|
107
|
-
Initial Release
|
package/src/index.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FullStory Client SDK snippet options.
|
|
3
|
-
*
|
|
4
|
-
* - orgId: Reference for your [Org Id](https://help.fullstory.com/hc/en-us/articles/360047075853) listed in FullStory.
|
|
5
|
-
* - namespace: Global object name that contains the FullStory browser API methods and properties. Defaults to `FS`.
|
|
6
|
-
* - debug: Debug mode with extra browser console logging.
|
|
7
|
-
* - host: The recording server host domain. Can be set to direct recorded events to a proxy that you host. Defaults to `fullstory.com`.
|
|
8
|
-
* - script: FullStory script host domain. FullStory hosts the `fs.js` recording script on a CDN, but you can choose to host a copy yourself. Defaults to `edge.fullstory.com`.
|
|
9
|
-
* - cookieDomain: Overrides the cookie domain. By default, cookies will be valid for all subdomains of your site; if you want to limit the cookies to a specific subdomain, you can set the domain value explicitly. More information can be found [here](https://help.fullstory.com/hc/en-us/articles/360020622874-Can-the-FullStory-cookie-be-associated-with-a-specific-subdomain-).
|
|
10
|
-
* - recordCrossDomainIFrames: FullStory can record cross-domain iFrames. Defaults to `false`. Certain limitations 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_01F1G333PYKPGZ4B42WDBV3YKV).
|
|
11
|
-
* - 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
|
-
* - 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
|
-
interface SnippetOptions {
|
|
15
|
-
orgId: string;
|
|
16
|
-
namespace?: string;
|
|
17
|
-
debug?: boolean;
|
|
18
|
-
host?: string;
|
|
19
|
-
script?: string;
|
|
20
|
-
cookieDomain?: string;
|
|
21
|
-
recordCrossDomainIFrames?: boolean;
|
|
22
|
-
recordOnlyThisIFrame?: boolean;
|
|
23
|
-
devMode?: boolean;
|
|
24
|
-
}
|
|
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
|
-
/**
|
|
37
|
-
* A callback that will be invoked when FullStory has begun a session.
|
|
38
|
-
*
|
|
39
|
-
* `sessionUrl` contains the URL to the current session.
|
|
40
|
-
*/
|
|
41
|
-
type ReadyCallback = (data: { sessionUrl: string }) => void;
|
|
42
|
-
|
|
43
|
-
// API functions that are available as soon as the snippet has executed.
|
|
44
|
-
export function anonymize(): void;
|
|
45
|
-
export function consent(userConsents?: boolean): void;
|
|
46
|
-
export function event(eventName: string, eventProperties: { [key: string]: any }): void;
|
|
47
|
-
export function identify(uid: string, customVars?: UserVars): void;
|
|
48
|
-
/**
|
|
49
|
-
* Initialize FullStory.
|
|
50
|
-
*
|
|
51
|
-
* @param options Options to pass to the snippet.
|
|
52
|
-
* @param readyCallback If provided, a callback that will be invoked when the FullStory session has begun.
|
|
53
|
-
*/
|
|
54
|
-
export function init(options: SnippetOptions, readyCallback?: ReadyCallback): void;
|
|
55
|
-
export function isInitialized(): boolean;
|
|
56
|
-
export function log(level: LogLevel, msg: string): void;
|
|
57
|
-
export function log(msg: string): void;
|
|
58
|
-
export function restart(): void;
|
|
59
|
-
export function setUserVars(customVars: UserVars): void;
|
|
60
|
-
export function shutdown(): void;
|
|
61
|
-
export function setVars(varScope: VarScope, properties?: { [key: string]: any }): void;
|
|
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;
|
package/src/index.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { initFS } from '@fullstory/snippet';
|
|
2
|
-
|
|
3
|
-
const fs = () => window[window._fs_namespace];
|
|
4
|
-
|
|
5
|
-
const ensureSnippetLoaded = () => {
|
|
6
|
-
const snippetLoaded = !!fs();
|
|
7
|
-
if (!snippetLoaded) {
|
|
8
|
-
throw Error('FullStory is not loaded, please ensure the init function is invoked before calling FullStory API functions');
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const hasFullStoryWithFunction = (...testNames) => {
|
|
13
|
-
ensureSnippetLoaded();
|
|
14
|
-
return testNames.every((current) => fs()[current]);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const guard = (name) => (...args) => {
|
|
18
|
-
if (window._fs_dev_mode) {
|
|
19
|
-
const message = `FullStory is in dev mode and is not recording: ${name} method not executed`;
|
|
20
|
-
console.warn(message);
|
|
21
|
-
return message;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (hasFullStoryWithFunction(name)) {
|
|
25
|
-
return fs()[name](...args);
|
|
26
|
-
}
|
|
27
|
-
console.warn(`FS.${name} not ready`);
|
|
28
|
-
return null;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const event = guard('event');
|
|
32
|
-
export const log = guard('log');
|
|
33
|
-
export const getCurrentSessionURL = guard('getCurrentSessionURL');
|
|
34
|
-
export const identify = guard('identify');
|
|
35
|
-
export const setUserVars = guard('setUserVars');
|
|
36
|
-
export const consent = guard('consent');
|
|
37
|
-
export const shutdown = guard('shutdown');
|
|
38
|
-
export const restart = guard('restart');
|
|
39
|
-
export const anonymize = guard('anonymize');
|
|
40
|
-
export const setVars = guard('setVars');
|
|
41
|
-
|
|
42
|
-
const _init = (inputOptions, readyCallback) => {
|
|
43
|
-
// Make a copy so we can modify `options` if desired.
|
|
44
|
-
const options = { ...inputOptions };
|
|
45
|
-
if (fs()) {
|
|
46
|
-
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// see README for details on the recordCrossDomainIFrames option
|
|
51
|
-
if (options.recordCrossDomainIFrames) {
|
|
52
|
-
window._fs_run_in_iframe = true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// record the contents of this iFrame when embedded in a parent site
|
|
56
|
-
if (options.recordOnlyThisIFrame) {
|
|
57
|
-
window._fs_is_outer_script = true;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Set cookie domain if it was specified.
|
|
61
|
-
if (options.cookieDomain) {
|
|
62
|
-
window._fs_cookie_domain = options.cookieDomain;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (options.debug === true) {
|
|
66
|
-
if (!options.script) {
|
|
67
|
-
options.script = 'edge.fullstory.com/s/fs-debug.js';
|
|
68
|
-
} else {
|
|
69
|
-
console.warn('Ignoring `debug = true` because `script` is set');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
initFS(options);
|
|
74
|
-
|
|
75
|
-
if (readyCallback) {
|
|
76
|
-
fs()('observe', { type: 'start', callback: readyCallback });
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (options.devMode === true) {
|
|
80
|
-
const message = 'FullStory was initialized in devMode and will stop recording';
|
|
81
|
-
event('FullStory Dev Mode', {
|
|
82
|
-
message_str: message,
|
|
83
|
-
});
|
|
84
|
-
shutdown();
|
|
85
|
-
window._fs_dev_mode = true;
|
|
86
|
-
console.warn(message);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const initOnce = (fn, message) => (...args) => {
|
|
91
|
-
if (window._fs_initialized) {
|
|
92
|
-
if (message) console.warn(message);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
fn(...args);
|
|
96
|
-
window._fs_initialized = true;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export const init = initOnce(_init, 'FullStory init has already been called once, additional invocations are ignored');
|
|
100
|
-
|
|
101
|
-
// normalize undefined into boolean
|
|
102
|
-
export const isInitialized = () => !!window._fs_initialized;
|