@fullstory/browser 2.0.0-beta.3 → 2.0.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/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()`.
@@ -37,13 +80,16 @@ The only required option is `orgId`, all others are optional.
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`.
38
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`.
39
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.
83
+ * `appHost` - Use this to set the app host for displaying session urls. If using a version of [FullStory Relay](https://help.fullstory.com/hc/en-us/articles/360046112593-How-to-send-captured-traffic-to-your-First-Party-Domain-using-FullStory-Relay), you may need to set `appHost` "app.fullstory.com" or "app.eu1.fullstory.com" depending on your region.
40
84
 
41
85
  ### Ready Callback
42
86
 
43
87
  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.
44
88
 
45
89
  ```javascript
46
- FullStory.init({ orgId }, ({ sessionUrl }) => console.log(`Started session: ${sessionUrl}`));
90
+ import { init } from '@fullstory/browser';
91
+
92
+ init({ orgId }, ({ sessionUrl }) => console.log(`Started session: ${sessionUrl}`));
47
93
  ```
48
94
 
49
95
  ### Initialization Examples
@@ -55,10 +101,10 @@ import React from 'react';
55
101
  import ReactDOM from 'react-dom';
56
102
  import './index.css';
57
103
  import App from './App';
58
- import * as FullStory from '@fullstory/browser';
104
+ import { init as initFullStory } from '@fullstory/browser';
59
105
 
60
106
 
61
- FullStory.init({ orgId: '<your org id here>' });
107
+ initFullStory({ orgId: '<your org id here>' });
62
108
 
63
109
  ReactDOM.render(<App />, document.getElementById('root'));
64
110
  ```
@@ -67,7 +113,7 @@ ReactDOM.render(<App />, document.getElementById('root'));
67
113
 
68
114
  ```javascript
69
115
  import { Component } from '@angular/core';
70
- import * as FullStory from '@fullstory/browser';
116
+ import { init as initFullStory } from '@fullstory/browser';
71
117
  import { environment } from '../environments/environment';
72
118
 
73
119
  @Component({
@@ -78,8 +124,10 @@ import { environment } from '../environments/environment';
78
124
  export class AppComponent {
79
125
 
80
126
  constructor() {
81
- FullStory.init({ orgId: '<your org id here>',
82
- devMode: !environment.production });
127
+ initFullStory({
128
+ orgId: '<your org id here>',
129
+ devMode: !environment.production,
130
+ });
83
131
  }
84
132
  }
85
133
  ```
@@ -89,9 +137,9 @@ export class AppComponent {
89
137
  ```javascript
90
138
  import Vue from 'vue';
91
139
  import App from './App.vue';
92
- import * as FullStory from '@fullstory/browser';
140
+ import { init as initFullStory, FullStory } from '@fullstory/browser';
93
141
 
94
- FullStory.init({ orgId: '<your org id here>' });
142
+ initFullStory({ orgId: '<your org id here>' });
95
143
  Vue.prototype.$FullStory = FullStory;
96
144
 
97
145
  new Vue({
@@ -102,11 +150,11 @@ new Vue({
102
150
  #### Vue 3
103
151
 
104
152
  ```javascript
105
- import { createApp } from 'vue'
106
- import App from './App.vue'
107
- import * as FullStory from '@fullstory/browser';
153
+ import { createApp } from 'vue';
154
+ import App from './App.vue';
155
+ import { init as initFullStory, FullStory } from '@fullstory/browser';
108
156
 
109
- FullStory.init({ orgId: '<your org id here>' });
157
+ initFullStory({ orgId: '<your org id here>' });
110
158
 
111
159
  const app = createApp(App);
112
160
  app.config.globalProperties.$FullStory = FullStory;
@@ -115,37 +163,68 @@ app.mount('#app');
115
163
 
116
164
  ## Using the SDK
117
165
 
118
- Once FullStory is initialized, you can make calls to the FullStory SDK.
166
+ 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.
119
167
 
120
168
  ### Sending custom events
121
169
 
122
170
  ```JavaScript
123
- FullStory.event('Subscribed', {
124
- uid_str: '750948353',
125
- plan_name_str: 'Professional',
126
- plan_price_real: 299,
127
- plan_users_int: 10,
128
- days_in_trial_int: 42,
129
- feature_packs: ['MAPS', 'DEV', 'DATA'],
171
+ FullStory('trackEvent', {
172
+ name: 'Subscribed',
173
+ properties: {
174
+ uid: '750948353',
175
+ plan_name: 'Professional',
176
+ plan_price: 299,
177
+ plan_users: 10,
178
+ days_in_trial: 42,
179
+ feature_packs: ['MAPS', 'DEV', 'DATA'],
180
+ },
181
+ schema: {
182
+ properties: {
183
+ plan_users: 'int', // override default inferred "real" type with "int"
184
+ days_in_trial: 'int', // override default inferred "real" type with "int"
185
+ }
186
+ }
130
187
  });
131
188
  ```
132
189
 
190
+ > **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.
191
+
133
192
  ### Generating session replay links
134
193
 
135
194
  ```JavaScript
136
- const startOfPlayback = FullStory.getCurrentSessionURL();
137
- const playbackAtThisMomentInTime = FullStory.getCurrentSessionURL(true);
195
+ const startOfPlayback = FullStory('getSession');
196
+ const playbackAtThisMomentInTime = FullStory('getSession', { format: 'url.now' });
138
197
  ```
139
198
 
140
- ### Sending custom page data
199
+ ### Sending custom user properties
141
200
  ```JavaScript
142
- FullStory.setVars('page', {
143
- pageName : 'Checkout', // what is the name of the page?
144
- cart_size_int : 10, // how many items were in the cart?
145
- used_coupon_bool : true, // was a coupon used?
201
+ FullStory('setProperties', {
202
+ type: 'user',
203
+ properties: {
204
+ displayName: 'Daniel Falko',
205
+ email: 'daniel.falko@example.com',
206
+ pricing_plan: 'free',
207
+ popup_help: true,
208
+ total_spent: 14.50,
209
+ },
146
210
  });
147
211
  ```
148
- For more information on setting page vars, 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).
212
+ 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).
149
213
 
150
- #### Note
151
- `FullStory.setVars(<scope>, <payload>)` currently only supports a string value of "page" for the scope. Using arbitrary strings for the scope parameter will result in an Error that will be logged to the browser console or discarded, depending on whether devMode or debug is enabled.
214
+ ### Sending custom page properties
215
+ ```JavaScript
216
+ FullStory('setProperties', {
217
+ type: 'page',
218
+ properties: {
219
+ pageName: 'Checkout', // what is the name of the page?
220
+ cart_size: 10, // how many items were in the cart?
221
+ used_coupon: true, // was a coupon used?
222
+ },
223
+ schema: {
224
+ properties: {
225
+ cart_size: 'int', // override default inferred "real" type with "int"
226
+ }
227
+ }
228
+ });
229
+ ```
230
+ 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,6 +14,7 @@ import { FSApi } from '@fullstory/snippet';
14
14
  */
15
15
  export interface SnippetOptions {
16
16
  orgId: string;
17
+ appHost?: string;
17
18
  assetMapId?: string;
18
19
  cookieDomain?: string;
19
20
  debug?: boolean;
@@ -37,6 +38,7 @@ type ReadyCallback = (data: {
37
38
  }) => void;
38
39
  declare global {
39
40
  interface Window {
41
+ _fs_app_host?: string;
40
42
  _fs_asset_map_id?: string;
41
43
  _fs_capture_on_startup?: boolean;
42
44
  _fs_cookie_domain?: string;
package/dist/index.esm.js CHANGED
@@ -50,6 +50,9 @@ var _init = function (inputOptions, readyCallback) {
50
50
  if (options.recordCrossDomainIFrames) {
51
51
  window._fs_run_in_iframe = true;
52
52
  }
53
+ if (options.appHost) {
54
+ window._fs_app_host = options.appHost;
55
+ }
53
56
  if (options.assetMapId) {
54
57
  window._fs_asset_map_id = options.assetMapId;
55
58
  }
@@ -86,7 +89,7 @@ var _init = function (inputOptions, readyCallback) {
86
89
  fs('trackEvent', {
87
90
  name: 'FullStory Dev Mode',
88
91
  properties: {
89
- message_str: message,
92
+ message: message,
90
93
  }
91
94
  });
92
95
  fs('shutdown');
package/dist/index.js CHANGED
@@ -52,6 +52,9 @@ var _init = function (inputOptions, readyCallback) {
52
52
  if (options.recordCrossDomainIFrames) {
53
53
  window._fs_run_in_iframe = true;
54
54
  }
55
+ if (options.appHost) {
56
+ window._fs_app_host = options.appHost;
57
+ }
55
58
  if (options.assetMapId) {
56
59
  window._fs_asset_map_id = options.assetMapId;
57
60
  }
@@ -88,7 +91,7 @@ var _init = function (inputOptions, readyCallback) {
88
91
  fs('trackEvent', {
89
92
  name: 'FullStory Dev Mode',
90
93
  properties: {
91
- message_str: message,
94
+ message: message,
92
95
  }
93
96
  });
94
97
  fs('shutdown');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstory/browser",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0",
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.3"
29
+ "@fullstory/snippet": "2.0.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@babel/core": "^7.8.7",
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ import { initFS, FSApi } from '@fullstory/snippet';
15
15
  */
16
16
  export interface SnippetOptions {
17
17
  orgId: string;
18
+ appHost?: string;
18
19
  assetMapId?: string;
19
20
  cookieDomain?: string;
20
21
  debug?: boolean;
@@ -37,6 +38,7 @@ type ReadyCallback = (data: { sessionUrl: string, settings: Readonly<object> })
37
38
 
38
39
  declare global {
39
40
  interface Window {
41
+ _fs_app_host?: string;
40
42
  _fs_asset_map_id?: string;
41
43
  _fs_capture_on_startup?: boolean;
42
44
  _fs_cookie_domain?: string;
@@ -83,6 +85,10 @@ const _init = (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => {
83
85
  window._fs_run_in_iframe = true;
84
86
  }
85
87
 
88
+ if (options.appHost) {
89
+ window._fs_app_host = options.appHost;
90
+ }
91
+
86
92
  if (options.assetMapId) {
87
93
  window._fs_asset_map_id = options.assetMapId;
88
94
  }
@@ -127,7 +133,7 @@ const _init = (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => {
127
133
  fs('trackEvent', {
128
134
  name: 'FullStory Dev Mode',
129
135
  properties: {
130
- message_str: message,
136
+ message,
131
137
  }
132
138
  });
133
139
  fs('shutdown');