@fullstory/browser 1.5.0 → 1.6.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/CHANGELOG.md +14 -0
- package/README.md +12 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.esm.js +12 -2
- package/dist/index.js +12 -1
- package/package.json +1 -1
- package/src/index.d.ts +16 -2
- package/src/index.js +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.6.1
|
|
4
|
+
|
|
5
|
+
- Fix a TypeScript type issue with the `readyCallback` API (#144)
|
|
6
|
+
- Add a RELEASING doc (#143)
|
|
7
|
+
## 1.6.0
|
|
8
|
+
|
|
9
|
+
- Add a `readyCallback` parameter to the `init` function (#140)
|
|
10
|
+
- Add an `isInitialized` API (#130)
|
|
11
|
+
- Automated dependency updates
|
|
12
|
+
|
|
13
|
+
## 1.5.1
|
|
14
|
+
|
|
15
|
+
- Updating README to include `host` and `script` configuration options
|
|
16
|
+
|
|
3
17
|
## 1.5.0
|
|
4
18
|
|
|
5
19
|
- Adding the `setVars` API function
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# FullStory Browser SDK
|
|
2
2
|
|
|
3
|
-
[](https://circleci.com/gh/fullstorydev/fullstory-browser-sdk)
|
|
3
|
+
[](https://circleci.com/gh/fullstorydev/fullstory-browser-sdk) [](https://www.npmjs.com/package/@fullstory/browser)
|
|
4
4
|
|
|
5
5
|
FullStory's browser SDK lets you manage FullStory recording on your site as well as retrieve deep links to session replays and send your own custom events. More information about the FullStory API can be found at https://developer.fullstory.com.
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ yarn add @fullstory/browser
|
|
|
20
20
|
|
|
21
21
|
## Initialize the SDK
|
|
22
22
|
|
|
23
|
-
Call the `init()` function with options as soon as you can in your website startup process.
|
|
23
|
+
Call the `init()` function with options as soon as you can in your website startup process. Calling init after successful initialization will trigger console warnings - if you need to programmatically check if FullStory has been initialized at some point in your code, you can call `isInitialized()`.
|
|
24
24
|
|
|
25
25
|
### Configuration Options
|
|
26
26
|
|
|
@@ -28,11 +28,21 @@ The only required option is `orgId`, all others are optional.
|
|
|
28
28
|
|
|
29
29
|
* `orgId` - Sets your FullStory Org Id. Find out how to get your Org Id [here](https://help.fullstory.com/hc/en-us/articles/360047075853).
|
|
30
30
|
* `debug` - When set to `true`, enables FullStory debug messages; defaults to `false`.
|
|
31
|
+
* `host` - The recording server host domain. Can be set to direct recorded events to a proxy that you host. Defaults to `fullstory.com`.
|
|
32
|
+
* `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`.
|
|
31
33
|
* `namespace` - Sets the global identifier for FullStory when conflicts with `FS` arise; see [help](https://help.fullstory.com/hc/en-us/articles/360020624694-What-if-the-identifier-FS-is-used-by-another-script-on-my-site-).
|
|
32
34
|
* `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.
|
|
33
35
|
* `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.
|
|
34
36
|
* `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`.
|
|
35
37
|
|
|
38
|
+
### Ready Callback
|
|
39
|
+
|
|
40
|
+
The `init` function also accepts an optional `readyCallback` argument. If you provide a function, it will be invoked when the FullStory session has started. Your callback will be called with one parameter: an object containing information about the session. Currently the only property is `sessionUrl`, which is a string containing the URL to the session.
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
FullStory.init({ orgId, ({ sessionUrl }) => console.log(`Started session: ${sessionUrl}`));
|
|
44
|
+
```
|
|
45
|
+
|
|
36
46
|
### Initialization Examples
|
|
37
47
|
|
|
38
48
|
#### React
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - debug: Debug mode with extra browser console logging.
|
|
7
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
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
|
-
* - 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).
|
|
9
|
+
* - 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).
|
|
10
10
|
* - 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).
|
|
11
11
|
* - 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`.
|
|
12
12
|
*/
|
|
@@ -31,12 +31,26 @@ type LogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
|
|
|
31
31
|
|
|
32
32
|
type VarScope = 'page';
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* A callback that will be invoked when FullStory has begun a session.
|
|
36
|
+
*
|
|
37
|
+
* `sessionUrl` contains the URL to the current session.
|
|
38
|
+
*/
|
|
39
|
+
type ReadyCallback = (data: { sessionUrl: string }) => void;
|
|
40
|
+
|
|
34
41
|
// API functions that are available as soon as the snippet has executed.
|
|
35
42
|
export function anonymize(): void;
|
|
36
43
|
export function consent(userConsents?: boolean): void;
|
|
37
44
|
export function event(eventName: string, eventProperties: { [key: string]: any }): void;
|
|
38
45
|
export function identify(uid: string, customVars?: UserVars): void;
|
|
39
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Initialize FullStory.
|
|
48
|
+
*
|
|
49
|
+
* @param options Options to pass to the snippet.
|
|
50
|
+
* @param readyCallback If provided, a callback that will be invoked when the FullStory session has begun.
|
|
51
|
+
*/
|
|
52
|
+
export function init(options: SnippetOptions, readyCallback?: ReadyCallback): void;
|
|
53
|
+
export function isInitialized(): boolean;
|
|
40
54
|
export function log(level: LogLevel, msg: string): void;
|
|
41
55
|
export function log(msg: string): void;
|
|
42
56
|
export function restart(): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -157,7 +157,7 @@ var restart = guard('restart');
|
|
|
157
157
|
var anonymize = guard('anonymize');
|
|
158
158
|
var setVars = guard('setVars');
|
|
159
159
|
|
|
160
|
-
var _init = function _init(options) {
|
|
160
|
+
var _init = function _init(options, readyCallback) {
|
|
161
161
|
if (fs()) {
|
|
162
162
|
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
|
|
163
163
|
return;
|
|
@@ -173,6 +173,13 @@ var _init = function _init(options) {
|
|
|
173
173
|
|
|
174
174
|
snippet(options);
|
|
175
175
|
|
|
176
|
+
if (readyCallback) {
|
|
177
|
+
fs()('observe', {
|
|
178
|
+
type: 'start',
|
|
179
|
+
callback: readyCallback
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
176
183
|
if (options.devMode === true) {
|
|
177
184
|
var message = 'FullStory was initialized in devMode and will stop recording';
|
|
178
185
|
event('FullStory Dev Mode', {
|
|
@@ -197,5 +204,8 @@ var initOnce = function initOnce(fn, message) {
|
|
|
197
204
|
};
|
|
198
205
|
|
|
199
206
|
var init = initOnce(_init, 'FullStory init has already been called once, additional invocations are ignored');
|
|
207
|
+
var isInitialized = function isInitialized() {
|
|
208
|
+
return !!window._fs_initialized;
|
|
209
|
+
};
|
|
200
210
|
|
|
201
|
-
export { anonymize, consent, event, getCurrentSessionURL, identify, init, log, restart, setUserVars, setVars, shutdown };
|
|
211
|
+
export { anonymize, consent, event, getCurrentSessionURL, identify, init, isInitialized, log, restart, setUserVars, setVars, shutdown };
|
package/dist/index.js
CHANGED
|
@@ -161,7 +161,7 @@ var restart = guard('restart');
|
|
|
161
161
|
var anonymize = guard('anonymize');
|
|
162
162
|
var setVars = guard('setVars');
|
|
163
163
|
|
|
164
|
-
var _init = function _init(options) {
|
|
164
|
+
var _init = function _init(options, readyCallback) {
|
|
165
165
|
if (fs()) {
|
|
166
166
|
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
|
|
167
167
|
return;
|
|
@@ -177,6 +177,13 @@ var _init = function _init(options) {
|
|
|
177
177
|
|
|
178
178
|
snippet(options);
|
|
179
179
|
|
|
180
|
+
if (readyCallback) {
|
|
181
|
+
fs()('observe', {
|
|
182
|
+
type: 'start',
|
|
183
|
+
callback: readyCallback
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
180
187
|
if (options.devMode === true) {
|
|
181
188
|
var message = 'FullStory was initialized in devMode and will stop recording';
|
|
182
189
|
event('FullStory Dev Mode', {
|
|
@@ -201,6 +208,9 @@ var initOnce = function initOnce(fn, message) {
|
|
|
201
208
|
};
|
|
202
209
|
|
|
203
210
|
var init = initOnce(_init, 'FullStory init has already been called once, additional invocations are ignored');
|
|
211
|
+
var isInitialized = function isInitialized() {
|
|
212
|
+
return !!window._fs_initialized;
|
|
213
|
+
};
|
|
204
214
|
|
|
205
215
|
exports.anonymize = anonymize;
|
|
206
216
|
exports.consent = consent;
|
|
@@ -208,6 +218,7 @@ exports.event = event;
|
|
|
208
218
|
exports.getCurrentSessionURL = getCurrentSessionURL;
|
|
209
219
|
exports.identify = identify;
|
|
210
220
|
exports.init = init;
|
|
221
|
+
exports.isInitialized = isInitialized;
|
|
211
222
|
exports.log = log;
|
|
212
223
|
exports.restart = restart;
|
|
213
224
|
exports.setUserVars = setUserVars;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullstory/browser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "The official FullStory browser SDK",
|
|
5
5
|
"repository": "git://github.com/fullstorydev/fullstory-browser-sdk.git",
|
|
6
6
|
"homepage": "https://github.com/fullstorydev/fullstory-browser-sdk",
|
package/src/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - debug: Debug mode with extra browser console logging.
|
|
7
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
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
|
-
* - 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).
|
|
9
|
+
* - 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).
|
|
10
10
|
* - 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).
|
|
11
11
|
* - 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`.
|
|
12
12
|
*/
|
|
@@ -31,12 +31,26 @@ type LogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
|
|
|
31
31
|
|
|
32
32
|
type VarScope = 'page';
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* A callback that will be invoked when FullStory has begun a session.
|
|
36
|
+
*
|
|
37
|
+
* `sessionUrl` contains the URL to the current session.
|
|
38
|
+
*/
|
|
39
|
+
type ReadyCallback = (data: { sessionUrl: string }) => void;
|
|
40
|
+
|
|
34
41
|
// API functions that are available as soon as the snippet has executed.
|
|
35
42
|
export function anonymize(): void;
|
|
36
43
|
export function consent(userConsents?: boolean): void;
|
|
37
44
|
export function event(eventName: string, eventProperties: { [key: string]: any }): void;
|
|
38
45
|
export function identify(uid: string, customVars?: UserVars): void;
|
|
39
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Initialize FullStory.
|
|
48
|
+
*
|
|
49
|
+
* @param options Options to pass to the snippet.
|
|
50
|
+
* @param readyCallback If provided, a callback that will be invoked when the FullStory session has begun.
|
|
51
|
+
*/
|
|
52
|
+
export function init(options: SnippetOptions, readyCallback?: ReadyCallback): void;
|
|
53
|
+
export function isInitialized(): boolean;
|
|
40
54
|
export function log(level: LogLevel, msg: string): void;
|
|
41
55
|
export function log(msg: string): void;
|
|
42
56
|
export function restart(): void;
|
package/src/index.js
CHANGED
|
@@ -39,7 +39,7 @@ export const restart = guard('restart');
|
|
|
39
39
|
export const anonymize = guard('anonymize');
|
|
40
40
|
export const setVars = guard('setVars');
|
|
41
41
|
|
|
42
|
-
const _init = (options) => {
|
|
42
|
+
const _init = (options, readyCallback) => {
|
|
43
43
|
if (fs()) {
|
|
44
44
|
// eslint-disable-next-line no-console
|
|
45
45
|
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
|
|
@@ -58,6 +58,10 @@ const _init = (options) => {
|
|
|
58
58
|
|
|
59
59
|
snippet(options);
|
|
60
60
|
|
|
61
|
+
if (readyCallback) {
|
|
62
|
+
fs()('observe', { type: 'start', callback: readyCallback });
|
|
63
|
+
}
|
|
64
|
+
|
|
61
65
|
if (options.devMode === true) {
|
|
62
66
|
const message = 'FullStory was initialized in devMode and will stop recording';
|
|
63
67
|
event('FullStory Dev Mode', {
|
|
@@ -80,3 +84,6 @@ const initOnce = (fn, message) => (...args) => {
|
|
|
80
84
|
};
|
|
81
85
|
|
|
82
86
|
export const init = initOnce(_init, 'FullStory init has already been called once, additional invocations are ignored');
|
|
87
|
+
|
|
88
|
+
// normalize undefined into boolean
|
|
89
|
+
export const isInitialized = () => !!window._fs_initialized;
|