@fullstory/browser 2.0.6 → 2.0.7

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 CHANGED
@@ -14,17 +14,14 @@ import { FSApi } from '@fullstory/snippet';
14
14
  */
15
15
  export interface SnippetOptions {
16
16
  orgId: string;
17
- appHost?: string;
18
- assetMapId?: string;
19
- cookieDomain?: string;
17
+ namespace?: string;
20
18
  debug?: boolean;
21
- devMode?: boolean;
22
19
  host?: string;
23
- namespace?: string;
20
+ script?: string;
21
+ cookieDomain?: string;
24
22
  recordCrossDomainIFrames?: boolean;
25
23
  recordOnlyThisIFrame?: boolean;
26
- script?: string;
27
- startCaptureManually?: boolean;
24
+ devMode?: boolean;
28
25
  }
29
26
  /**
30
27
  * A callback that will be invoked when FullStory has begun a session.
@@ -38,9 +35,6 @@ type ReadyCallback = (data: {
38
35
  }) => void;
39
36
  declare global {
40
37
  interface Window {
41
- _fs_app_host?: string;
42
- _fs_asset_map_id?: string;
43
- _fs_capture_on_startup?: boolean;
44
38
  _fs_cookie_domain?: string;
45
39
  _fs_debug?: boolean;
46
40
  _fs_dev_mode?: boolean;
@@ -55,5 +49,5 @@ declare global {
55
49
  }
56
50
  export declare const init: (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => void;
57
51
  export declare const isInitialized: () => boolean;
58
- export declare const FullStory: FSApi;
59
- export {};
52
+ declare const FullStory: FSApi;
53
+ export default FullStory;
package/dist/index.esm.js CHANGED
@@ -14,8 +14,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
14
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  PERFORMANCE OF THIS SOFTWARE.
16
16
  ***************************************************************************** */
17
- /* global Reflect, Promise */
18
-
19
17
 
20
18
  var __assign = function() {
21
19
  __assign = Object.assign || function __assign(t) {
@@ -52,15 +50,6 @@ var _init = function (inputOptions, readyCallback) {
52
50
  if (options.recordCrossDomainIFrames) {
53
51
  window._fs_run_in_iframe = true;
54
52
  }
55
- if (options.appHost) {
56
- window._fs_app_host = options.appHost;
57
- }
58
- if (options.assetMapId) {
59
- window._fs_asset_map_id = options.assetMapId;
60
- }
61
- if (options.startCaptureManually) {
62
- window._fs_capture_on_startup = false;
63
- }
64
53
  // record the contents of this iFrame when embedded in a parent site
65
54
  if (options.recordOnlyThisIFrame) {
66
55
  window._fs_is_outer_script = true;
@@ -80,7 +69,7 @@ var _init = function (inputOptions, readyCallback) {
80
69
  initFS(options);
81
70
  var fs = getFullStory();
82
71
  if (!fs) {
83
- console.warn('Failed to initialize FS snippet');
72
+ console.warn('Trouble with fs');
84
73
  return;
85
74
  }
86
75
  if (readyCallback) {
@@ -91,7 +80,7 @@ var _init = function (inputOptions, readyCallback) {
91
80
  fs('trackEvent', {
92
81
  name: 'FullStory Dev Mode',
93
82
  properties: {
94
- message: message,
83
+ message_str: message,
95
84
  }
96
85
  });
97
86
  fs('shutdown');
@@ -125,7 +114,7 @@ var guard = function (name) { return function () {
125
114
  args[_i] = arguments[_i];
126
115
  }
127
116
  if (window._fs_dev_mode) {
128
- var message = "FullStory is in dev mode and is not capturing: ".concat(name, " method not executed");
117
+ var message = "FullStory is in dev mode and is not recording: ".concat(name, " method not executed");
129
118
  console.warn(message);
130
119
  return message;
131
120
  }
@@ -136,30 +125,27 @@ var guard = function (name) { return function () {
136
125
  console.warn("FS.".concat(name, " not ready"));
137
126
  return null;
138
127
  }; };
139
- var buildFullStoryShim = function () {
140
- var FS = function (operation, options, source) {
141
- var fs = ensureSnippetLoaded();
142
- if (window._fs_dev_mode) {
143
- var message = "FullStory is in dev mode and is not capturing: ".concat(operation, " not executed");
144
- console.warn(message);
145
- return undefined;
146
- }
147
- return fs(operation, options, source);
148
- };
149
- FS.anonymize = guard('anonymize');
150
- FS.consent = guard('consent');
151
- FS.disableConsole = guard('disableConsole');
152
- FS.enableConsole = guard('enableConsole');
153
- FS.event = guard('event');
154
- FS.getCurrentSessionURL = guard('getCurrentSessionURL');
155
- FS.identify = guard('identify');
156
- FS.log = guard('log');
157
- FS.restart = guard('restart');
158
- FS.setUserVars = guard('setUserVars');
159
- FS.setVars = guard('setVars');
160
- FS.shutdown = guard('shutdown');
161
- return FS;
162
- };
163
- var FullStory = buildFullStoryShim();
128
+ var FullStory = Object.assign(function (operation, options, source) {
129
+ var fs = ensureSnippetLoaded();
130
+ if (window._fs_dev_mode) {
131
+ var message = 'FullStory is in dev mode and is not recording: method not executed';
132
+ console.warn(message);
133
+ return undefined;
134
+ }
135
+ return fs(operation, options, source);
136
+ }, {
137
+ anonymize: guard('anonymize'),
138
+ consent: guard('consent'),
139
+ disableConsole: guard('disableConsole'),
140
+ enableConsole: guard('enableConsole'),
141
+ event: guard('event'),
142
+ getCurrentSessionURL: guard('getCurrentSessionURL'),
143
+ identify: guard('identify'),
144
+ log: guard('log'),
145
+ restart: guard('restart'),
146
+ setUserVars: guard('setUserVars'),
147
+ setVars: guard('setVars'),
148
+ shutdown: guard('shutdown'),
149
+ });
164
150
 
165
- export { FullStory, init, isInitialized };
151
+ export { FullStory as default, init, isInitialized };
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var snippet = require('@fullstory/snippet');
4
6
 
5
7
  /******************************************************************************
@@ -16,8 +18,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
18
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
19
  PERFORMANCE OF THIS SOFTWARE.
18
20
  ***************************************************************************** */
19
- /* global Reflect, Promise */
20
-
21
21
 
22
22
  var __assign = function() {
23
23
  __assign = Object.assign || function __assign(t) {
@@ -54,15 +54,6 @@ var _init = function (inputOptions, readyCallback) {
54
54
  if (options.recordCrossDomainIFrames) {
55
55
  window._fs_run_in_iframe = true;
56
56
  }
57
- if (options.appHost) {
58
- window._fs_app_host = options.appHost;
59
- }
60
- if (options.assetMapId) {
61
- window._fs_asset_map_id = options.assetMapId;
62
- }
63
- if (options.startCaptureManually) {
64
- window._fs_capture_on_startup = false;
65
- }
66
57
  // record the contents of this iFrame when embedded in a parent site
67
58
  if (options.recordOnlyThisIFrame) {
68
59
  window._fs_is_outer_script = true;
@@ -82,7 +73,7 @@ var _init = function (inputOptions, readyCallback) {
82
73
  snippet.initFS(options);
83
74
  var fs = getFullStory();
84
75
  if (!fs) {
85
- console.warn('Failed to initialize FS snippet');
76
+ console.warn('Trouble with fs');
86
77
  return;
87
78
  }
88
79
  if (readyCallback) {
@@ -93,7 +84,7 @@ var _init = function (inputOptions, readyCallback) {
93
84
  fs('trackEvent', {
94
85
  name: 'FullStory Dev Mode',
95
86
  properties: {
96
- message: message,
87
+ message_str: message,
97
88
  }
98
89
  });
99
90
  fs('shutdown');
@@ -127,7 +118,7 @@ var guard = function (name) { return function () {
127
118
  args[_i] = arguments[_i];
128
119
  }
129
120
  if (window._fs_dev_mode) {
130
- var message = "FullStory is in dev mode and is not capturing: ".concat(name, " method not executed");
121
+ var message = "FullStory is in dev mode and is not recording: ".concat(name, " method not executed");
131
122
  console.warn(message);
132
123
  return message;
133
124
  }
@@ -138,32 +129,29 @@ var guard = function (name) { return function () {
138
129
  console.warn("FS.".concat(name, " not ready"));
139
130
  return null;
140
131
  }; };
141
- var buildFullStoryShim = function () {
142
- var FS = function (operation, options, source) {
143
- var fs = ensureSnippetLoaded();
144
- if (window._fs_dev_mode) {
145
- var message = "FullStory is in dev mode and is not capturing: ".concat(operation, " not executed");
146
- console.warn(message);
147
- return undefined;
148
- }
149
- return fs(operation, options, source);
150
- };
151
- FS.anonymize = guard('anonymize');
152
- FS.consent = guard('consent');
153
- FS.disableConsole = guard('disableConsole');
154
- FS.enableConsole = guard('enableConsole');
155
- FS.event = guard('event');
156
- FS.getCurrentSessionURL = guard('getCurrentSessionURL');
157
- FS.identify = guard('identify');
158
- FS.log = guard('log');
159
- FS.restart = guard('restart');
160
- FS.setUserVars = guard('setUserVars');
161
- FS.setVars = guard('setVars');
162
- FS.shutdown = guard('shutdown');
163
- return FS;
164
- };
165
- var FullStory = buildFullStoryShim();
132
+ var FullStory = Object.assign(function (operation, options, source) {
133
+ var fs = ensureSnippetLoaded();
134
+ if (window._fs_dev_mode) {
135
+ var message = 'FullStory is in dev mode and is not recording: method not executed';
136
+ console.warn(message);
137
+ return undefined;
138
+ }
139
+ return fs(operation, options, source);
140
+ }, {
141
+ anonymize: guard('anonymize'),
142
+ consent: guard('consent'),
143
+ disableConsole: guard('disableConsole'),
144
+ enableConsole: guard('enableConsole'),
145
+ event: guard('event'),
146
+ getCurrentSessionURL: guard('getCurrentSessionURL'),
147
+ identify: guard('identify'),
148
+ log: guard('log'),
149
+ restart: guard('restart'),
150
+ setUserVars: guard('setUserVars'),
151
+ setVars: guard('setVars'),
152
+ shutdown: guard('shutdown'),
153
+ });
166
154
 
167
- exports.FullStory = FullStory;
155
+ exports.default = FullStory;
168
156
  exports.init = init;
169
157
  exports.isInitialized = isInitialized;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstory/browser",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
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",
@@ -11,8 +11,7 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "scripts": {
13
13
  "clean": "rimraf dist",
14
- "pretest": "tsc --project tsconfig.test.json",
15
- "test": "npm run lint && karma start --single-run --browsers ChromeHeadless karma.conf.js",
14
+ "test": "npm run lint && jest",
16
15
  "lint": "eslint src",
17
16
  "build": "rollup -c"
18
17
  },
@@ -26,7 +25,7 @@
26
25
  "sdk"
27
26
  ],
28
27
  "dependencies": {
29
- "@fullstory/snippet": "2.0.5"
28
+ "@fullstory/snippet": "2.0.6"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@babel/core": "^7.8.7",
@@ -34,26 +33,20 @@
34
33
  "@babel/preset-env": "^7.10.4",
35
34
  "@babel/register": "^7.8.6",
36
35
  "@rollup/plugin-typescript": "^11.1.0",
37
- "@types/chai": "^4.3.4",
38
- "@types/mocha": "^10.0.1",
36
+ "@types/jest": "^29.5.0",
39
37
  "@types/node": "^18.15.11",
40
38
  "@typescript-eslint/eslint-plugin": "^5.58.0",
41
39
  "@typescript-eslint/parser": "^5.58.0",
42
- "chai": "^4.1.2",
43
40
  "eslint": "^8.6.0",
44
41
  "eslint-config-airbnb": "^19.0.4",
45
42
  "eslint-plugin-import": "^2.20.1",
46
43
  "eslint-plugin-jsx-a11y": "^6.5.1",
47
44
  "eslint-plugin-react": "^7.28.0",
48
- "karma": "^6.4.2",
49
- "karma-chai": "^0.1.0",
50
- "karma-chrome-launcher": "^3.1.0",
51
- "karma-mocha": "^2.0.1",
52
- "karma-spec-reporter": "0.0.32",
53
- "karma-webpack": "^5.0.0",
54
- "mocha": "^9.2.0",
45
+ "jest": "^29.7.0",
46
+ "jest-environment-jsdom": "^30.3.0",
55
47
  "rimraf": "^2.7.1",
56
48
  "rollup": "^3.21.0",
49
+ "ts-jest": "^29.1.0",
57
50
  "tslib": "^2.5.0",
58
51
  "typescript": "^4.2.4",
59
52
  "webpack": "^5.76.1"
package/src/index.test.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { assert, expect } from 'chai';
2
1
  import {
3
2
  FullStory as FS,
4
3
  init,
@@ -19,23 +18,23 @@ beforeEach(() => {
19
18
 
20
19
  describe('init', () => {
21
20
  it('should throw error if not initialized with an orgId', () => {
22
- expect(() => { init({} as SnippetOptions); }).to.throw();
21
+ expect(() => { init({} as SnippetOptions); }).toThrow();
23
22
  });
24
23
 
25
24
  it('should throw error if API called before init', () => {
26
25
  try {
27
26
  FS('log', { msg: 'my log' });
28
- expect(false).to.be('this should have thrown');
27
+ throw new Error('this should have thrown');
29
28
  } catch (error) {
30
- expect((error as Error).message).to.match(/FullStory is not loaded/);
29
+ expect((error as Error).message).toMatch(/FullStory is not loaded/);
31
30
  }
32
31
  init({ orgId: testOrg });
33
- expect(() => { FS('log', { msg: 'my log' }); }).to.not.throw();
32
+ expect(() => { FS('log', { msg: 'my log' }); }).not.toThrow();
34
33
  });
35
34
 
36
35
  it('should add _fs_org value to window object', () => {
37
36
  init({ orgId: testOrg });
38
- expect(window._fs_org).to.equal(testOrg);
37
+ expect(window._fs_org).toBe(testOrg);
39
38
  });
40
39
 
41
40
  it('should add _fs_run_in_iframe value to window object', () => {
@@ -43,7 +42,7 @@ describe('init', () => {
43
42
  orgId: testOrg,
44
43
  recordCrossDomainIFrames: true,
45
44
  });
46
- expect(window._fs_run_in_iframe).to.equal(true);
45
+ expect(window._fs_run_in_iframe).toBe(true);
47
46
  });
48
47
 
49
48
  it('should add _fs_is_outer_script value to window object', () => {
@@ -51,7 +50,7 @@ describe('init', () => {
51
50
  orgId: testOrg,
52
51
  recordOnlyThisIFrame: true,
53
52
  });
54
- expect(window._fs_is_outer_script).to.equal(true);
53
+ expect(window._fs_is_outer_script).toBe(true);
55
54
  });
56
55
 
57
56
  it('should add _fs_dev_mode value to window when initialized with devMode', () => {
@@ -60,19 +59,19 @@ describe('init', () => {
60
59
  devMode: true,
61
60
  });
62
61
 
63
- expect(window._fs_dev_mode).to.equal(true);
62
+ expect(window._fs_dev_mode).toBe(true);
64
63
  });
65
64
 
66
65
  it('should return whether initialized', () => {
67
66
  let isInit = isInitialized();
68
- expect(isInit).to.equal(false);
67
+ expect(isInit).toBe(false);
69
68
 
70
69
  init({
71
70
  orgId: testOrg,
72
71
  });
73
72
 
74
73
  isInit = isInitialized();
75
- expect(isInit).to.equal(true);
74
+ expect(isInit).toBe(true);
76
75
  });
77
76
 
78
77
  it('should load fs-debug.js when debug is set', () => {
@@ -81,7 +80,22 @@ describe('init', () => {
81
80
  debug: true,
82
81
  });
83
82
 
84
- expect(window._fs_script).to.match(/fs-debug.js$/);
83
+ expect(window._fs_script).toMatch(/fs-debug.js$/);
84
+ });
85
+
86
+ it('should pass sessionUid to FS init', () => {
87
+ const sessionUid = 'session-123';
88
+
89
+ init({
90
+ orgId: testOrg,
91
+ sessionUid,
92
+ });
93
+
94
+ const queue = (window[window._fs_namespace ?? 'FS'] as unknown as { q?: unknown[][] }).q;
95
+ const initCall = queue?.find((call) => call[0] === 'init');
96
+ const initOptions = initCall?.[1] as { env?: { sessionUid?: string } } | undefined;
97
+
98
+ expect(initOptions?.env?.sessionUid).toBe(sessionUid);
85
99
  });
86
100
  });
87
101
 
@@ -98,17 +112,17 @@ describe('devMode', () => {
98
112
  });
99
113
 
100
114
  it('should return a message for functions invoked when in devMode', () => {
101
- expect(consoleWarnedMessage).to.equal(undefined);
115
+ expect(consoleWarnedMessage).toBeUndefined();
102
116
  init({
103
117
  orgId: testOrg,
104
118
  devMode: true,
105
119
  });
106
120
 
107
- expect(consoleWarnedMessage).to.match(/FullStory was initialized in devMode/);
121
+ expect(consoleWarnedMessage).toMatch(/FullStory was initialized in devMode/);
108
122
 
109
123
  FS('log', { msg: 'hello world' });
110
124
 
111
- expect(consoleWarnedMessage).to.equal('FullStory is in dev mode and is not capturing: log not executed');
125
+ expect(consoleWarnedMessage).toBe('FullStory is in dev mode and is not capturing: log not executed');
112
126
  });
113
127
  });
114
128
 
@@ -118,11 +132,7 @@ describe('getCurrentSessionURL', () => {
118
132
  // in theory, this is a race condition - assuming that fs.js
119
133
  // can't load by the time the following statement is executed
120
134
  const url = FS('getSession');
121
- assert.equal(
122
- url,
123
- null,
124
- 'FullStory.getCurrentSessionURL() should return null if executed before fs.js is fully bootstrapped'
125
- );
135
+ expect(url).toBeNull();
126
136
  });
127
137
  });
128
138
 
@@ -177,7 +187,7 @@ describe('typescript safety', () => {
177
187
  FS.event(42, { product_id: 'asdf' });
178
188
 
179
189
  // Assertion for posterity's sake...
180
- expect(true).to.equal(true);
190
+ expect(true).toBe(true);
181
191
  });
182
192
 
183
193
  it('allows the optional "source" param', () => {
@@ -212,7 +222,7 @@ describe('typescript safety', () => {
212
222
  });
213
223
 
214
224
  // NOTE: don't run this test, it will hang since fs.js isn't really running. It's only for typescript safety checks.
215
- xit('provides type assistance for the async api', async () => {
225
+ it.skip('provides type assistance for the async api', async () => {
216
226
  init({ orgId: testOrg });
217
227
 
218
228
  const disconnector = await FS('observeAsync', { type: 'start', callback: () => console.log('STARTED') });
@@ -220,7 +230,6 @@ describe('typescript safety', () => {
220
230
  disconnector.disconnect();
221
231
 
222
232
  const url = await FS('getSessionAsync');
223
-
224
- console.log(url.trim());
233
+ expect(url === null || typeof url === 'string' || typeof url === 'object').toBe(true); // type-check only
225
234
  });
226
235
  });
package/src/index.ts CHANGED
@@ -12,6 +12,7 @@ import { initFS, FSApi } from '@fullstory/snippet';
12
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
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
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
+ * - sessionUid (beta): Sets the session UID passed to the `FS('init', ...)` v2 operation.
15
16
  */
16
17
  export interface SnippetOptions {
17
18
  orgId: string;
@@ -24,6 +25,7 @@ export interface SnippetOptions {
24
25
  namespace?: string;
25
26
  recordCrossDomainIFrames?: boolean;
26
27
  recordOnlyThisIFrame?: boolean;
28
+ sessionUid?: string;
27
29
  script?: string;
28
30
  startCaptureManually?: boolean;
29
31
  }
@@ -124,6 +126,10 @@ const _init = (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => {
124
126
  return;
125
127
  }
126
128
 
129
+ if (options.sessionUid) {
130
+ fs('init', { env: { sessionUid: options.sessionUid } });
131
+ }
132
+
127
133
  if (readyCallback) {
128
134
  fs('observe', { type: 'start', callback: readyCallback });
129
135
  }
@@ -201,7 +207,7 @@ const buildFullStoryShim = (): FSApi => {
201
207
  FS.setVars = guard('setVars');
202
208
  FS.shutdown = guard('shutdown');
203
209
 
204
- return FS;
210
+ return FS as FSApi;
205
211
  };
206
212
 
207
213
  export const FullStory: FSApi = buildFullStoryShim();