@fullstory/browser 1.6.1 → 1.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.0
4
+
5
+ - Add a `cookieDomain` option to the `init` function to support setting `_fs_cookie_domain`.
6
+
7
+ ## 1.6.2
8
+
9
+ - 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-).
10
+
3
11
  ## 1.6.1
4
12
 
5
13
  - Fix a TypeScript type issue with the `readyCallback` API (#144)
package/README.md CHANGED
@@ -31,6 +31,7 @@ The only required option is `orgId`, all others are optional.
31
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
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`.
33
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-).
34
+ * `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-).
34
35
  * `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.
35
36
  * `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.
36
37
  * `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`.
@@ -40,7 +41,7 @@ The only required option is `orgId`, all others are optional.
40
41
  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
 
42
43
  ```javascript
43
- FullStory.init({ orgId, ({ sessionUrl }) => console.log(`Started session: ${sessionUrl}`));
44
+ FullStory.init({ orgId }, ({ sessionUrl }) => console.log(`Started session: ${sessionUrl}`));
44
45
  ```
45
46
 
46
47
  ### Initialization Examples
package/dist/index.d.ts CHANGED
@@ -6,6 +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
+ * - 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-).
9
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).
10
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).
11
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`.
@@ -16,6 +17,7 @@ interface SnippetOptions {
16
17
  debug?: boolean;
17
18
  host?: string;
18
19
  script?: string;
20
+ cookieDomain?: string;
19
21
  recordCrossDomainIFrames?: boolean;
20
22
  recordOnlyThisIFrame?: boolean;
21
23
  devMode?: boolean;
package/dist/index.esm.js CHANGED
@@ -1,9 +1,49 @@
1
+ function ownKeys(object, enumerableOnly) {
2
+ var keys = Object.keys(object);
3
+
4
+ if (Object.getOwnPropertySymbols) {
5
+ var symbols = Object.getOwnPropertySymbols(object);
6
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
7
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
8
+ })), keys.push.apply(keys, symbols);
9
+ }
10
+
11
+ return keys;
12
+ }
13
+
14
+ function _objectSpread2(target) {
15
+ for (var i = 1; i < arguments.length; i++) {
16
+ var source = null != arguments[i] ? arguments[i] : {};
17
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
18
+ _defineProperty(target, key, source[key]);
19
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
20
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
21
+ });
22
+ }
23
+
24
+ return target;
25
+ }
26
+
27
+ function _defineProperty(obj, key, value) {
28
+ if (key in obj) {
29
+ Object.defineProperty(obj, key, {
30
+ value: value,
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true
34
+ });
35
+ } else {
36
+ obj[key] = value;
37
+ }
38
+
39
+ return obj;
40
+ }
41
+
1
42
  var snippet = function snippet(_ref) {
2
43
  var orgId = _ref.orgId,
3
44
  _ref$namespace = _ref.namespace,
4
45
  namespace = _ref$namespace === void 0 ? 'FS' : _ref$namespace,
5
46
  _ref$debug = _ref.debug,
6
- debug = _ref$debug === void 0 ? false : _ref$debug,
7
47
  _ref$host = _ref.host,
8
48
  host = _ref$host === void 0 ? 'fullstory.com' : _ref$host,
9
49
  _ref$script = _ref.script,
@@ -13,7 +53,6 @@ var snippet = function snippet(_ref) {
13
53
  throw new Error('FullStory orgId is a required parameter');
14
54
  }
15
55
 
16
- window['_fs_debug'] = debug;
17
56
  window['_fs_host'] = host;
18
57
  window['_fs_script'] = script;
19
58
  window['_fs_org'] = orgId;
@@ -157,7 +196,9 @@ var restart = guard('restart');
157
196
  var anonymize = guard('anonymize');
158
197
  var setVars = guard('setVars');
159
198
 
160
- var _init = function _init(options, readyCallback) {
199
+ var _init = function _init(inputOptions, readyCallback) {
200
+ var options = _objectSpread2({}, inputOptions);
201
+
161
202
  if (fs()) {
162
203
  console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
163
204
  return;
@@ -171,6 +212,18 @@ var _init = function _init(options, readyCallback) {
171
212
  window._fs_is_outer_script = true;
172
213
  }
173
214
 
215
+ if (options.cookieDomain) {
216
+ window._fs_cookie_domain = options.cookieDomain;
217
+ }
218
+
219
+ if (options.debug === true) {
220
+ if (!options.script) {
221
+ options.script = 'edge.fullstory.com/s/fs-debug.js';
222
+ } else {
223
+ console.warn('Ignoring `debug = true` because `script` is set');
224
+ }
225
+ }
226
+
174
227
  snippet(options);
175
228
 
176
229
  if (readyCallback) {
package/dist/index.js CHANGED
@@ -2,12 +2,52 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function ownKeys(object, enumerableOnly) {
6
+ var keys = Object.keys(object);
7
+
8
+ if (Object.getOwnPropertySymbols) {
9
+ var symbols = Object.getOwnPropertySymbols(object);
10
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
11
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
12
+ })), keys.push.apply(keys, symbols);
13
+ }
14
+
15
+ return keys;
16
+ }
17
+
18
+ function _objectSpread2(target) {
19
+ for (var i = 1; i < arguments.length; i++) {
20
+ var source = null != arguments[i] ? arguments[i] : {};
21
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
22
+ _defineProperty(target, key, source[key]);
23
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
24
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
25
+ });
26
+ }
27
+
28
+ return target;
29
+ }
30
+
31
+ function _defineProperty(obj, key, value) {
32
+ if (key in obj) {
33
+ Object.defineProperty(obj, key, {
34
+ value: value,
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true
38
+ });
39
+ } else {
40
+ obj[key] = value;
41
+ }
42
+
43
+ return obj;
44
+ }
45
+
5
46
  var snippet = function snippet(_ref) {
6
47
  var orgId = _ref.orgId,
7
48
  _ref$namespace = _ref.namespace,
8
49
  namespace = _ref$namespace === void 0 ? 'FS' : _ref$namespace,
9
50
  _ref$debug = _ref.debug,
10
- debug = _ref$debug === void 0 ? false : _ref$debug,
11
51
  _ref$host = _ref.host,
12
52
  host = _ref$host === void 0 ? 'fullstory.com' : _ref$host,
13
53
  _ref$script = _ref.script,
@@ -17,7 +57,6 @@ var snippet = function snippet(_ref) {
17
57
  throw new Error('FullStory orgId is a required parameter');
18
58
  }
19
59
 
20
- window['_fs_debug'] = debug;
21
60
  window['_fs_host'] = host;
22
61
  window['_fs_script'] = script;
23
62
  window['_fs_org'] = orgId;
@@ -161,7 +200,9 @@ var restart = guard('restart');
161
200
  var anonymize = guard('anonymize');
162
201
  var setVars = guard('setVars');
163
202
 
164
- var _init = function _init(options, readyCallback) {
203
+ var _init = function _init(inputOptions, readyCallback) {
204
+ var options = _objectSpread2({}, inputOptions);
205
+
165
206
  if (fs()) {
166
207
  console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
167
208
  return;
@@ -175,6 +216,18 @@ var _init = function _init(options, readyCallback) {
175
216
  window._fs_is_outer_script = true;
176
217
  }
177
218
 
219
+ if (options.cookieDomain) {
220
+ window._fs_cookie_domain = options.cookieDomain;
221
+ }
222
+
223
+ if (options.debug === true) {
224
+ if (!options.script) {
225
+ options.script = 'edge.fullstory.com/s/fs-debug.js';
226
+ } else {
227
+ console.warn('Ignoring `debug = true` because `script` is set');
228
+ }
229
+ }
230
+
178
231
  snippet(options);
179
232
 
180
233
  if (readyCallback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstory/browser",
3
- "version": "1.6.1",
3
+ "version": "1.7.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",
package/src/index.d.ts CHANGED
@@ -6,6 +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
+ * - 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-).
9
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).
10
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).
11
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`.
@@ -16,6 +17,7 @@ interface SnippetOptions {
16
17
  debug?: boolean;
17
18
  host?: string;
18
19
  script?: string;
20
+ cookieDomain?: string;
19
21
  recordCrossDomainIFrames?: boolean;
20
22
  recordOnlyThisIFrame?: boolean;
21
23
  devMode?: boolean;
package/src/index.js CHANGED
@@ -17,14 +17,14 @@ const hasFullStoryWithFunction = (...testNames) => {
17
17
  const guard = (name) => (...args) => {
18
18
  if (window._fs_dev_mode) {
19
19
  const message = `FullStory is in dev mode and is not recording: ${name} method not executed`;
20
- console.warn(message); // eslint-disable-line no-console
20
+ console.warn(message);
21
21
  return message;
22
22
  }
23
23
 
24
24
  if (hasFullStoryWithFunction(name)) {
25
25
  return fs()[name](...args);
26
26
  }
27
- console.warn(`FS.${name} not ready`); // eslint-disable-line no-console
27
+ console.warn(`FS.${name} not ready`);
28
28
  return null;
29
29
  };
30
30
 
@@ -39,9 +39,10 @@ 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, readyCallback) => {
42
+ const _init = (inputOptions, readyCallback) => {
43
+ // Make a copy so we can modify `options` if desired.
44
+ const options = { ...inputOptions };
43
45
  if (fs()) {
44
- // eslint-disable-next-line no-console
45
46
  console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
46
47
  return;
47
48
  }
@@ -56,6 +57,19 @@ const _init = (options, readyCallback) => {
56
57
  window._fs_is_outer_script = true;
57
58
  }
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
+
59
73
  snippet(options);
60
74
 
61
75
  if (readyCallback) {
@@ -69,13 +83,12 @@ const _init = (options, readyCallback) => {
69
83
  });
70
84
  shutdown();
71
85
  window._fs_dev_mode = true;
72
- console.warn(message); // eslint-disable-line no-console
86
+ console.warn(message);
73
87
  }
74
88
  };
75
89
 
76
90
  const initOnce = (fn, message) => (...args) => {
77
91
  if (window._fs_initialized) {
78
- // eslint-disable-next-line no-console
79
92
  if (message) console.warn(message);
80
93
  return;
81
94
  }
package/src/snippet.js CHANGED
@@ -13,8 +13,7 @@ const snippet = (
13
13
  throw new Error('FullStory orgId is a required parameter');
14
14
  }
15
15
  /* begin FullStory snippet */
16
- window['_fs_debug'] = debug;
17
- window['_fs_host'] = host;
16
+ window['_fs_host'] = host;
18
17
  window['_fs_script'] = script;
19
18
  window['_fs_org'] = orgId;
20
19
  window['_fs_namespace'] = namespace;