@fullstory/browser 2.0.0-beta.0 → 2.0.0-beta.4
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 +110 -30
- package/dist/index.d.ts +8 -4
- package/dist/index.esm.js +6 -0
- package/dist/index.js +6 -0
- package/package.json +2 -2
- package/src/index.ts +16 -4
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
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
|
|
|
7
|
+
> **NOTE:** this is the documentation for version 2. For version 1 documentation, please see [@fullstory/browser@1.7.1](https://www.npmjs.com/package/@fullstory/browser/v/1.7.1).
|
|
7
8
|
|
|
8
9
|
## Install the SDK
|
|
9
10
|
|
|
@@ -18,6 +19,48 @@ npm i @fullstory/browser --save
|
|
|
18
19
|
yarn add @fullstory/browser
|
|
19
20
|
```
|
|
20
21
|
|
|
22
|
+
## Migrating to Version 2.x.x
|
|
23
|
+
In version 2.x.x, `init` is a separate named export from `FullStory`. You will need to update all of your wildcard (`'*'`) imports to explicit named imports.
|
|
24
|
+
|
|
25
|
+
_Version 1.x.x_
|
|
26
|
+
```js
|
|
27
|
+
import * as FullStory from '@fullstory/browser';
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
_Version 2.x.x_
|
|
31
|
+
```js
|
|
32
|
+
import { FullStory, init } from '@fullstory/browser';
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `init`
|
|
36
|
+
You can use the named import `init` by itself:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import { init } from '@fullstory/browser';
|
|
40
|
+
|
|
41
|
+
init({ orgId: 'my-org-id' })
|
|
42
|
+
```
|
|
43
|
+
You can also rename the function for readability:
|
|
44
|
+
```js
|
|
45
|
+
import { init as initFullStory } from '@fullstory/browser';
|
|
46
|
+
|
|
47
|
+
initFullStory({ orgId: 'my-org-id' })
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `FullStory`
|
|
51
|
+
The `FullStory` named export is equivalent to the global `FS` object described in the [developer documentation](https://developer.fullstory.com/browser/v2/getting-started/). You can use it to make all version 2 API calls:
|
|
52
|
+
```js
|
|
53
|
+
import { FullStory } from '@fullstory/browser';
|
|
54
|
+
|
|
55
|
+
FullStory('trackEvent', {
|
|
56
|
+
name: 'My Event',
|
|
57
|
+
properties: {
|
|
58
|
+
product: 'Sprockets',
|
|
59
|
+
quantity: 1,
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
21
64
|
## Initialize the SDK
|
|
22
65
|
|
|
23
66
|
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()`.
|
|
@@ -35,13 +78,17 @@ The only required option is `orgId`, all others are optional.
|
|
|
35
78
|
* `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
79
|
* `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
80
|
* `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`.
|
|
81
|
+
* `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`.
|
|
82
|
+
* `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
83
|
|
|
39
84
|
### Ready Callback
|
|
40
85
|
|
|
41
86
|
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.
|
|
42
87
|
|
|
43
88
|
```javascript
|
|
44
|
-
|
|
89
|
+
import { init } from '@fullstory/browser';
|
|
90
|
+
|
|
91
|
+
init({ orgId }, ({ sessionUrl }) => console.log(`Started session: ${sessionUrl}`));
|
|
45
92
|
```
|
|
46
93
|
|
|
47
94
|
### Initialization Examples
|
|
@@ -53,10 +100,10 @@ import React from 'react';
|
|
|
53
100
|
import ReactDOM from 'react-dom';
|
|
54
101
|
import './index.css';
|
|
55
102
|
import App from './App';
|
|
56
|
-
import
|
|
103
|
+
import { init as initFullStory } from '@fullstory/browser';
|
|
57
104
|
|
|
58
105
|
|
|
59
|
-
|
|
106
|
+
initFullStory({ orgId: '<your org id here>' });
|
|
60
107
|
|
|
61
108
|
ReactDOM.render(<App />, document.getElementById('root'));
|
|
62
109
|
```
|
|
@@ -65,7 +112,7 @@ ReactDOM.render(<App />, document.getElementById('root'));
|
|
|
65
112
|
|
|
66
113
|
```javascript
|
|
67
114
|
import { Component } from '@angular/core';
|
|
68
|
-
import
|
|
115
|
+
import { init as initFullStory } from '@fullstory/browser';
|
|
69
116
|
import { environment } from '../environments/environment';
|
|
70
117
|
|
|
71
118
|
@Component({
|
|
@@ -76,8 +123,10 @@ import { environment } from '../environments/environment';
|
|
|
76
123
|
export class AppComponent {
|
|
77
124
|
|
|
78
125
|
constructor() {
|
|
79
|
-
|
|
80
|
-
|
|
126
|
+
initFullStory({
|
|
127
|
+
orgId: '<your org id here>',
|
|
128
|
+
devMode: !environment.production,
|
|
129
|
+
});
|
|
81
130
|
}
|
|
82
131
|
}
|
|
83
132
|
```
|
|
@@ -87,9 +136,9 @@ export class AppComponent {
|
|
|
87
136
|
```javascript
|
|
88
137
|
import Vue from 'vue';
|
|
89
138
|
import App from './App.vue';
|
|
90
|
-
import
|
|
139
|
+
import { init as initFullStory, FullStory } from '@fullstory/browser';
|
|
91
140
|
|
|
92
|
-
|
|
141
|
+
initFullStory({ orgId: '<your org id here>' });
|
|
93
142
|
Vue.prototype.$FullStory = FullStory;
|
|
94
143
|
|
|
95
144
|
new Vue({
|
|
@@ -100,11 +149,11 @@ new Vue({
|
|
|
100
149
|
#### Vue 3
|
|
101
150
|
|
|
102
151
|
```javascript
|
|
103
|
-
import { createApp } from 'vue'
|
|
104
|
-
import App from './App.vue'
|
|
105
|
-
import
|
|
152
|
+
import { createApp } from 'vue';
|
|
153
|
+
import App from './App.vue';
|
|
154
|
+
import { init as initFullStory, FullStory } from '@fullstory/browser';
|
|
106
155
|
|
|
107
|
-
|
|
156
|
+
initFullStory({ orgId: '<your org id here>' });
|
|
108
157
|
|
|
109
158
|
const app = createApp(App);
|
|
110
159
|
app.config.globalProperties.$FullStory = FullStory;
|
|
@@ -113,37 +162,68 @@ app.mount('#app');
|
|
|
113
162
|
|
|
114
163
|
## Using the SDK
|
|
115
164
|
|
|
116
|
-
Once FullStory is initialized, you can make calls to the FullStory SDK.
|
|
165
|
+
Once FullStory is initialized, you can make calls to the FullStory SDK. See the [developer documentation](https://developer.fullstory.com/browser/v2/getting-started/) for more information.
|
|
117
166
|
|
|
118
167
|
### Sending custom events
|
|
119
168
|
|
|
120
169
|
```JavaScript
|
|
121
|
-
FullStory
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
170
|
+
FullStory('trackEvent', {
|
|
171
|
+
name: 'Subscribed',
|
|
172
|
+
properties: {
|
|
173
|
+
uid: '750948353',
|
|
174
|
+
plan_name: 'Professional',
|
|
175
|
+
plan_price: 299,
|
|
176
|
+
plan_users: 10,
|
|
177
|
+
days_in_trial: 42,
|
|
178
|
+
feature_packs: ['MAPS', 'DEV', 'DATA'],
|
|
179
|
+
},
|
|
180
|
+
schema: {
|
|
181
|
+
properties: {
|
|
182
|
+
plan_users: 'int', // override default inferred "real" type with "int"
|
|
183
|
+
days_in_trial: 'int', // override default inferred "real" type with "int"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
128
186
|
});
|
|
129
187
|
```
|
|
130
188
|
|
|
189
|
+
> **NOTE:** The inclusion of type suffixes - appending `_str` or `_int` to the end of properties - is no longer required. All custom properties are inferred on the server. To override any default inference, you can add a `schema`. See [Custom Properties](https://developer.fullstory.com/browser/v2/custom-properties/) for more information.
|
|
190
|
+
|
|
131
191
|
### Generating session replay links
|
|
132
192
|
|
|
133
193
|
```JavaScript
|
|
134
|
-
const startOfPlayback = FullStory
|
|
135
|
-
const playbackAtThisMomentInTime = FullStory.
|
|
194
|
+
const startOfPlayback = FullStory('getSession');
|
|
195
|
+
const playbackAtThisMomentInTime = FullStory('getSession', { format: 'url.now' });
|
|
136
196
|
```
|
|
137
197
|
|
|
138
|
-
### Sending custom
|
|
198
|
+
### Sending custom user properties
|
|
139
199
|
```JavaScript
|
|
140
|
-
FullStory
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
200
|
+
FullStory('setProperties', {
|
|
201
|
+
type: 'user',
|
|
202
|
+
properties: {
|
|
203
|
+
displayName: 'Daniel Falko',
|
|
204
|
+
email: 'daniel.falko@example.com',
|
|
205
|
+
pricing_plan: 'free',
|
|
206
|
+
popup_help: true,
|
|
207
|
+
total_spent: 14.50,
|
|
208
|
+
},
|
|
144
209
|
});
|
|
145
210
|
```
|
|
146
|
-
For more information on
|
|
211
|
+
For more information on sending custom user properties, view the FullStory help article on [Capturing custom user properties](https://help.fullstory.com/hc/en-us/articles/360020623294).
|
|
147
212
|
|
|
148
|
-
|
|
149
|
-
|
|
213
|
+
### Sending custom page properties
|
|
214
|
+
```JavaScript
|
|
215
|
+
FullStory('setProperties', {
|
|
216
|
+
type: 'page',
|
|
217
|
+
properties: {
|
|
218
|
+
pageName: 'Checkout', // what is the name of the page?
|
|
219
|
+
cart_size: 10, // how many items were in the cart?
|
|
220
|
+
used_coupon: true, // was a coupon used?
|
|
221
|
+
},
|
|
222
|
+
schema: {
|
|
223
|
+
properties: {
|
|
224
|
+
cart_size: 'int', // override default inferred "real" type with "int"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
For more information on setting page properties, view the FullStory help article on [Sending custom page data to FullStory](https://help.fullstory.com/hc/en-us/articles/1500004101581-FS-setVars-API-Sending-custom-page-data-to-FullStory).
|
package/dist/index.d.ts
CHANGED
|
@@ -14,14 +14,16 @@ import { FSApi } from '@fullstory/snippet';
|
|
|
14
14
|
*/
|
|
15
15
|
export interface SnippetOptions {
|
|
16
16
|
orgId: string;
|
|
17
|
-
|
|
17
|
+
assetMapId?: string;
|
|
18
|
+
cookieDomain?: string;
|
|
18
19
|
debug?: boolean;
|
|
20
|
+
devMode?: boolean;
|
|
19
21
|
host?: string;
|
|
20
|
-
|
|
21
|
-
cookieDomain?: string;
|
|
22
|
+
namespace?: string;
|
|
22
23
|
recordCrossDomainIFrames?: boolean;
|
|
23
24
|
recordOnlyThisIFrame?: boolean;
|
|
24
|
-
|
|
25
|
+
script?: string;
|
|
26
|
+
startCaptureManually?: boolean;
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* A callback that will be invoked when FullStory has begun a session.
|
|
@@ -35,6 +37,8 @@ type ReadyCallback = (data: {
|
|
|
35
37
|
}) => void;
|
|
36
38
|
declare global {
|
|
37
39
|
interface Window {
|
|
40
|
+
_fs_asset_map_id?: string;
|
|
41
|
+
_fs_capture_on_startup?: boolean;
|
|
38
42
|
_fs_cookie_domain?: string;
|
|
39
43
|
_fs_debug?: boolean;
|
|
40
44
|
_fs_dev_mode?: boolean;
|
package/dist/index.esm.js
CHANGED
|
@@ -50,6 +50,12 @@ var _init = function (inputOptions, readyCallback) {
|
|
|
50
50
|
if (options.recordCrossDomainIFrames) {
|
|
51
51
|
window._fs_run_in_iframe = true;
|
|
52
52
|
}
|
|
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
|
+
}
|
|
53
59
|
// record the contents of this iFrame when embedded in a parent site
|
|
54
60
|
if (options.recordOnlyThisIFrame) {
|
|
55
61
|
window._fs_is_outer_script = true;
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,12 @@ var _init = function (inputOptions, readyCallback) {
|
|
|
52
52
|
if (options.recordCrossDomainIFrames) {
|
|
53
53
|
window._fs_run_in_iframe = true;
|
|
54
54
|
}
|
|
55
|
+
if (options.assetMapId) {
|
|
56
|
+
window._fs_asset_map_id = options.assetMapId;
|
|
57
|
+
}
|
|
58
|
+
if (options.startCaptureManually) {
|
|
59
|
+
window._fs_capture_on_startup = false;
|
|
60
|
+
}
|
|
55
61
|
// record the contents of this iFrame when embedded in a parent site
|
|
56
62
|
if (options.recordOnlyThisIFrame) {
|
|
57
63
|
window._fs_is_outer_script = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullstory/browser",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
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",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"sdk"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@fullstory/snippet": "2.0.0-beta.
|
|
29
|
+
"@fullstory/snippet": "2.0.0-beta.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@babel/core": "^7.8.7",
|
package/src/index.ts
CHANGED
|
@@ -15,14 +15,16 @@ import { initFS, FSApi } from '@fullstory/snippet';
|
|
|
15
15
|
*/
|
|
16
16
|
export interface SnippetOptions {
|
|
17
17
|
orgId: string;
|
|
18
|
-
|
|
18
|
+
assetMapId?: string;
|
|
19
|
+
cookieDomain?: string;
|
|
19
20
|
debug?: boolean;
|
|
21
|
+
devMode?: boolean;
|
|
20
22
|
host?: string;
|
|
21
|
-
|
|
22
|
-
cookieDomain?: string;
|
|
23
|
+
namespace?: string;
|
|
23
24
|
recordCrossDomainIFrames?: boolean;
|
|
24
25
|
recordOnlyThisIFrame?: boolean;
|
|
25
|
-
|
|
26
|
+
script?: string;
|
|
27
|
+
startCaptureManually?: boolean;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -35,6 +37,8 @@ type ReadyCallback = (data: { sessionUrl: string, settings: Readonly<object> })
|
|
|
35
37
|
|
|
36
38
|
declare global {
|
|
37
39
|
interface Window {
|
|
40
|
+
_fs_asset_map_id?: string;
|
|
41
|
+
_fs_capture_on_startup?: boolean;
|
|
38
42
|
_fs_cookie_domain?: string;
|
|
39
43
|
_fs_debug?: boolean;
|
|
40
44
|
_fs_dev_mode?: boolean;
|
|
@@ -79,6 +83,14 @@ const _init = (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => {
|
|
|
79
83
|
window._fs_run_in_iframe = true;
|
|
80
84
|
}
|
|
81
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
|
+
|
|
82
94
|
// record the contents of this iFrame when embedded in a parent site
|
|
83
95
|
if (options.recordOnlyThisIFrame) {
|
|
84
96
|
window._fs_is_outer_script = true;
|