Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fullstory/browser

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fullstory/browser - npm Package Compare versions

Comparing version 1.7.1 to 2.0.0-beta.0

src/index.test.ts

80

dist/index.d.ts

@@ -0,1 +1,2 @@

import { FSApi } from '@fullstory/snippet';
/**

@@ -14,24 +15,13 @@ * FullStory Client SDK snippet options.

*/
interface SnippetOptions {
orgId: string;
namespace?: string;
debug?: boolean;
host?: string;
script?: string;
cookieDomain?: string;
recordCrossDomainIFrames?: boolean;
recordOnlyThisIFrame?: boolean;
devMode?: boolean;
export interface SnippetOptions {
orgId: string;
namespace?: string;
debug?: boolean;
host?: string;
script?: string;
cookieDomain?: string;
recordCrossDomainIFrames?: boolean;
recordOnlyThisIFrame?: boolean;
devMode?: boolean;
}
interface UserVars {
displayName?: string;
email?: string;
[key: string]: any;
}
type LogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';
type VarScope = 'page';
/**

@@ -41,27 +31,25 @@ * A callback that will be invoked when FullStory has begun a session.

* `sessionUrl` contains the URL to the current session.
* `settings` contains the org settings for the current session.
*/
type ReadyCallback = (data: { sessionUrl: string }) => void;
// API functions that are available as soon as the snippet has executed.
export function anonymize(): void;
export function consent(userConsents?: boolean): void;
export function event(eventName: string, eventProperties: { [key: string]: any }): void;
export function identify(uid: string, customVars?: UserVars): void;
/**
* Initialize FullStory.
*
* @param options Options to pass to the snippet.
* @param readyCallback If provided, a callback that will be invoked when the FullStory session has begun.
*/
export function init(options: SnippetOptions, readyCallback?: ReadyCallback): void;
export function isInitialized(): boolean;
export function log(level: LogLevel, msg: string): void;
export function log(msg: string): void;
export function restart(): void;
export function setUserVars(customVars: UserVars): void;
export function shutdown(): void;
export function setVars(varScope: VarScope, properties?: { [key: string]: any }): void;
// API functions that are available after /rec/page returns.
// FullStory bootstrapping details: https://help.fullstory.com/hc/en-us/articles/360032975773
export function getCurrentSessionURL(now?: boolean): string | null;
type ReadyCallback = (data: {
sessionUrl: string;
settings: Readonly<object>;
}) => void;
declare global {
interface Window {
_fs_cookie_domain?: string;
_fs_debug?: boolean;
_fs_dev_mode?: boolean;
_fs_host?: string;
_fs_initialized?: boolean;
_fs_is_outer_script?: boolean;
_fs_namespace?: string;
_fs_org?: string;
_fs_run_in_iframe?: boolean;
_fs_script?: string;
}
}
export declare const init: (inputOptions: SnippetOptions, readyCallback?: ReadyCallback) => void;
export declare const isInitialized: () => boolean;
export declare const FullStory: FSApi;
export {};
import { initFS } from '@fullstory/snippet';
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
/******************************************************************************
Copyright (c) Microsoft Corporation.
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
return keys;
}
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var fs = function fs() {
return window[window._fs_namespace];
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var ensureSnippetLoaded = function ensureSnippetLoaded() {
var snippetLoaded = !!fs();
if (!snippetLoaded) {
throw Error('FullStory is not loaded, please ensure the init function is invoked before calling FullStory API functions');
}
var getFullStory = function () {
if (window._fs_namespace) {
return window[window._fs_namespace];
}
return undefined;
};
var hasFullStoryWithFunction = function hasFullStoryWithFunction() {
ensureSnippetLoaded();
for (var _len = arguments.length, testNames = new Array(_len), _key = 0; _key < _len; _key++) {
testNames[_key] = arguments[_key];
}
return testNames.every(function (current) {
return fs()[current];
});
var ensureSnippetLoaded = function () {
var fs = getFullStory();
if (!fs) {
throw Error('FullStory is not loaded, please ensure the init function is invoked before calling FullStory API functions');
}
return fs;
};
var guard = function guard(name) {
return function () {
if (window._fs_dev_mode) {
var message = "FullStory is in dev mode and is not recording: ".concat(name, " method not executed");
console.warn(message);
return message;
var _init = function (inputOptions, readyCallback) {
// Make a copy so we can modify `options` if desired.
var options = __assign({}, inputOptions);
if (getFullStory()) {
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
return;
}
if (hasFullStoryWithFunction(name)) {
var _fs;
return (_fs = fs())[name].apply(_fs, arguments);
// see README for details on the recordCrossDomainIFrames option
if (options.recordCrossDomainIFrames) {
window._fs_run_in_iframe = true;
}
console.warn("FS.".concat(name, " not ready"));
return null;
};
};
var event = guard('event');
var log = guard('log');
var getCurrentSessionURL = guard('getCurrentSessionURL');
var identify = guard('identify');
var setUserVars = guard('setUserVars');
var consent = guard('consent');
var shutdown = guard('shutdown');
var restart = guard('restart');
var anonymize = guard('anonymize');
var setVars = guard('setVars');
var _init = function _init(inputOptions, readyCallback) {
var options = _objectSpread2({}, inputOptions);
if (fs()) {
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
return;
}
if (options.recordCrossDomainIFrames) {
window._fs_run_in_iframe = true;
}
if (options.recordOnlyThisIFrame) {
window._fs_is_outer_script = true;
}
if (options.cookieDomain) {
window._fs_cookie_domain = options.cookieDomain;
}
if (options.debug === true) {
if (!options.script) {
options.script = 'edge.fullstory.com/s/fs-debug.js';
} else {
console.warn('Ignoring `debug = true` because `script` is set');
// record the contents of this iFrame when embedded in a parent site
if (options.recordOnlyThisIFrame) {
window._fs_is_outer_script = true;
}
}
initFS(options);
if (readyCallback) {
fs()('observe', {
type: 'start',
callback: readyCallback
});
}
if (options.devMode === true) {
var message = 'FullStory was initialized in devMode and will stop recording';
event('FullStory Dev Mode', {
message_str: message
});
shutdown();
window._fs_dev_mode = true;
console.warn(message);
}
// Set cookie domain if it was specified.
if (options.cookieDomain) {
window._fs_cookie_domain = options.cookieDomain;
}
if (options.debug === true) {
if (!options.script) {
options.script = 'edge.fullstory.com/s/fs-debug.js';
}
else {
console.warn('Ignoring `debug = true` because `script` is set');
}
}
initFS(options);
var fs = getFullStory();
if (!fs) {
console.warn('Failed to initialize FS snippet');
return;
}
if (readyCallback) {
fs('observe', { type: 'start', callback: readyCallback });
}
if (options.devMode === true) {
var message = 'FullStory was initialized in devMode and will stop recording';
fs('trackEvent', {
name: 'FullStory Dev Mode',
properties: {
message_str: message,
}
});
fs('shutdown');
window._fs_dev_mode = true;
console.warn(message);
}
};
var initOnce = function initOnce(fn, message) {
return function () {
var initOnce = function (message) { return function (inputOptions, readyCallback) {
if (window._fs_initialized) {
if (message) console.warn(message);
return;
if (message)
console.warn(message);
return;
}
fn.apply(void 0, arguments);
_init(inputOptions, readyCallback);
window._fs_initialized = true;
};
}; };
var init = initOnce('FullStory init has already been called once, additional invocations are ignored');
// normalize undefined into boolean
var isInitialized = function () { return !!window._fs_initialized; };
var hasFullStoryWithFunction = function () {
var testNames = [];
for (var _i = 0; _i < arguments.length; _i++) {
testNames[_i] = arguments[_i];
}
var fs = ensureSnippetLoaded();
return testNames.every(function (current) { return fs[current]; });
};
var init = initOnce(_init, 'FullStory init has already been called once, additional invocations are ignored');
var isInitialized = function isInitialized() {
return !!window._fs_initialized;
var guard = function (name) { return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (window._fs_dev_mode) {
var message = "FullStory is in dev mode and is not recording: ".concat(name, " method not executed");
console.warn(message);
return message;
}
var fs = getFullStory();
if (hasFullStoryWithFunction(name) && fs) {
return fs[name].apply(fs, args);
}
console.warn("FS.".concat(name, " not ready"));
return null;
}; };
var buildFullStoryShim = function () {
var FS = function (operation, options, source) {
var fs = ensureSnippetLoaded();
if (window._fs_dev_mode) {
var message = 'FullStory is in dev mode and is not recording: method not executed';
console.warn(message);
return undefined;
}
return fs(operation, options, source);
};
FS.anonymize = guard('anonymize');
FS.consent = guard('consent');
FS.disableConsole = guard('disableConsole');
FS.enableConsole = guard('enableConsole');
FS.event = guard('event');
FS.getCurrentSessionURL = guard('getCurrentSessionURL');
FS.identify = guard('identify');
FS.log = guard('log');
FS.restart = guard('restart');
FS.setUserVars = guard('setUserVars');
FS.setVars = guard('setVars');
FS.shutdown = guard('shutdown');
return FS;
};
var FullStory = buildFullStoryShim();
export { anonymize, consent, event, getCurrentSessionURL, identify, init, isInitialized, log, restart, setUserVars, setVars, shutdown };
export { FullStory, init, isInitialized };
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var snippet = require('@fullstory/snippet');
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
/******************************************************************************
Copyright (c) Microsoft Corporation.
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
return keys;
}
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var fs = function fs() {
return window[window._fs_namespace];
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var ensureSnippetLoaded = function ensureSnippetLoaded() {
var snippetLoaded = !!fs();
if (!snippetLoaded) {
throw Error('FullStory is not loaded, please ensure the init function is invoked before calling FullStory API functions');
}
var getFullStory = function () {
if (window._fs_namespace) {
return window[window._fs_namespace];
}
return undefined;
};
var hasFullStoryWithFunction = function hasFullStoryWithFunction() {
ensureSnippetLoaded();
for (var _len = arguments.length, testNames = new Array(_len), _key = 0; _key < _len; _key++) {
testNames[_key] = arguments[_key];
}
return testNames.every(function (current) {
return fs()[current];
});
var ensureSnippetLoaded = function () {
var fs = getFullStory();
if (!fs) {
throw Error('FullStory is not loaded, please ensure the init function is invoked before calling FullStory API functions');
}
return fs;
};
var guard = function guard(name) {
return function () {
if (window._fs_dev_mode) {
var message = "FullStory is in dev mode and is not recording: ".concat(name, " method not executed");
console.warn(message);
return message;
var _init = function (inputOptions, readyCallback) {
// Make a copy so we can modify `options` if desired.
var options = __assign({}, inputOptions);
if (getFullStory()) {
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
return;
}
if (hasFullStoryWithFunction(name)) {
var _fs;
return (_fs = fs())[name].apply(_fs, arguments);
// see README for details on the recordCrossDomainIFrames option
if (options.recordCrossDomainIFrames) {
window._fs_run_in_iframe = true;
}
console.warn("FS.".concat(name, " not ready"));
return null;
};
};
var event = guard('event');
var log = guard('log');
var getCurrentSessionURL = guard('getCurrentSessionURL');
var identify = guard('identify');
var setUserVars = guard('setUserVars');
var consent = guard('consent');
var shutdown = guard('shutdown');
var restart = guard('restart');
var anonymize = guard('anonymize');
var setVars = guard('setVars');
var _init = function _init(inputOptions, readyCallback) {
var options = _objectSpread2({}, inputOptions);
if (fs()) {
console.warn('The FullStory snippet has already been defined elsewhere (likely in the <head> element)');
return;
}
if (options.recordCrossDomainIFrames) {
window._fs_run_in_iframe = true;
}
if (options.recordOnlyThisIFrame) {
window._fs_is_outer_script = true;
}
if (options.cookieDomain) {
window._fs_cookie_domain = options.cookieDomain;
}
if (options.debug === true) {
if (!options.script) {
options.script = 'edge.fullstory.com/s/fs-debug.js';
} else {
console.warn('Ignoring `debug = true` because `script` is set');
// record the contents of this iFrame when embedded in a parent site
if (options.recordOnlyThisIFrame) {
window._fs_is_outer_script = true;
}
}
snippet.initFS(options);
if (readyCallback) {
fs()('observe', {
type: 'start',
callback: readyCallback
});
}
if (options.devMode === true) {
var message = 'FullStory was initialized in devMode and will stop recording';
event('FullStory Dev Mode', {
message_str: message
});
shutdown();
window._fs_dev_mode = true;
console.warn(message);
}
// Set cookie domain if it was specified.
if (options.cookieDomain) {
window._fs_cookie_domain = options.cookieDomain;
}
if (options.debug === true) {
if (!options.script) {
options.script = 'edge.fullstory.com/s/fs-debug.js';
}
else {
console.warn('Ignoring `debug = true` because `script` is set');
}
}
snippet.initFS(options);
var fs = getFullStory();
if (!fs) {
console.warn('Failed to initialize FS snippet');
return;
}
if (readyCallback) {
fs('observe', { type: 'start', callback: readyCallback });
}
if (options.devMode === true) {
var message = 'FullStory was initialized in devMode and will stop recording';
fs('trackEvent', {
name: 'FullStory Dev Mode',
properties: {
message_str: message,
}
});
fs('shutdown');
window._fs_dev_mode = true;
console.warn(message);
}
};
var initOnce = function initOnce(fn, message) {
return function () {
var initOnce = function (message) { return function (inputOptions, readyCallback) {
if (window._fs_initialized) {
if (message) console.warn(message);
return;
if (message)
console.warn(message);
return;
}
fn.apply(void 0, arguments);
_init(inputOptions, readyCallback);
window._fs_initialized = true;
};
}; };
var init = initOnce('FullStory init has already been called once, additional invocations are ignored');
// normalize undefined into boolean
var isInitialized = function () { return !!window._fs_initialized; };
var hasFullStoryWithFunction = function () {
var testNames = [];
for (var _i = 0; _i < arguments.length; _i++) {
testNames[_i] = arguments[_i];
}
var fs = ensureSnippetLoaded();
return testNames.every(function (current) { return fs[current]; });
};
var init = initOnce(_init, 'FullStory init has already been called once, additional invocations are ignored');
var isInitialized = function isInitialized() {
return !!window._fs_initialized;
var guard = function (name) { return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (window._fs_dev_mode) {
var message = "FullStory is in dev mode and is not recording: ".concat(name, " method not executed");
console.warn(message);
return message;
}
var fs = getFullStory();
if (hasFullStoryWithFunction(name) && fs) {
return fs[name].apply(fs, args);
}
console.warn("FS.".concat(name, " not ready"));
return null;
}; };
var buildFullStoryShim = function () {
var FS = function (operation, options, source) {
var fs = ensureSnippetLoaded();
if (window._fs_dev_mode) {
var message = 'FullStory is in dev mode and is not recording: method not executed';
console.warn(message);
return undefined;
}
return fs(operation, options, source);
};
FS.anonymize = guard('anonymize');
FS.consent = guard('consent');
FS.disableConsole = guard('disableConsole');
FS.enableConsole = guard('enableConsole');
FS.event = guard('event');
FS.getCurrentSessionURL = guard('getCurrentSessionURL');
FS.identify = guard('identify');
FS.log = guard('log');
FS.restart = guard('restart');
FS.setUserVars = guard('setUserVars');
FS.setVars = guard('setVars');
FS.shutdown = guard('shutdown');
return FS;
};
var FullStory = buildFullStoryShim();
exports.anonymize = anonymize;
exports.consent = consent;
exports.event = event;
exports.getCurrentSessionURL = getCurrentSessionURL;
exports.identify = identify;
exports.FullStory = FullStory;
exports.init = init;
exports.isInitialized = isInitialized;
exports.log = log;
exports.restart = restart;
exports.setUserVars = setUserVars;
exports.setVars = setVars;
exports.shutdown = shutdown;
{
"name": "@fullstory/browser",
"version": "1.7.1",
"version": "2.0.0-beta.0",
"description": "The official FullStory browser SDK",

@@ -14,6 +14,6 @@ "repository": "git://github.com/fullstorydev/fullstory-browser-sdk.git",

"clean": "rimraf dist",
"test": "npm run lint && npm run test:karma",
"test:karma": "karma start --single-run --browsers ChromeHeadless karma.conf.js",
"lint": "eslint src test",
"build": "tsc src/index.d.ts && rollup -c"
"pretest": "tsc --project tsconfig.test.json",
"test": "npm run lint && karma start --single-run --browsers ChromeHeadless karma.conf.js",
"lint": "eslint src",
"build": "rollup -c"
},

@@ -30,3 +30,3 @@ "files": [

"dependencies": {
"@fullstory/snippet": "1.3.1"
"@fullstory/snippet": "2.0.0-beta.2"
},

@@ -38,3 +38,8 @@ "devDependencies": {

"@babel/register": "^7.8.6",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-typescript": "^11.1.0",
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"chai": "^4.1.2",

@@ -54,7 +59,7 @@ "eslint": "^8.6.0",

"rimraf": "^2.7.1",
"rollup": "^1.32.1",
"rollup-plugin-copy": "^3.3.0",
"typescript": "^3.8.3",
"rollup": "^3.21.0",
"tslib": "^2.5.0",
"typescript": "^4.2.4",
"webpack": "^5.76.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc