@fullstory/snippet
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -1,7 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.initFS = exports.SnippetSrc = void 0; | ||
// @ts-nocheck | ||
@@ -113,4 +107,18 @@ var executeSnippetV1 = function executeSnippetV1() { | ||
}; | ||
exports.initFS = initFS; | ||
var SnippetSrc = toV1String(); | ||
exports.SnippetSrc = SnippetSrc; | ||
var generateSnippetText = function generateSnippetText(_a) { | ||
var orgId = _a.orgId, | ||
_b = _a.namespace, | ||
namespace = _b === void 0 ? 'FS' : _b, | ||
_c = _a.debug, | ||
debug = _c === void 0 ? false : _c, | ||
_d = _a.host, | ||
host = _d === void 0 ? 'fullstory.com' : _d, | ||
_e = _a.script, | ||
script = _e === void 0 ? 'edge.fullstory.com/s/fs.js' : _e; | ||
if (!orgId) { | ||
throw new Error('FullStory orgId is a required parameter'); | ||
} | ||
return "window['_fs_debug'] = ".concat(debug, ";\nwindow['_fs_host'] = '").concat(host, "';\nwindow['_fs_script'] = '").concat(script, "';\nwindow['_fs_org'] = '").concat(orgId, "';\nwindow['_fs_namespace'] = '").concat(namespace, "';\n").concat(SnippetSrc, "\n"); | ||
}; | ||
export { SnippetSrc, generateSnippetText, initFS }; |
@@ -114,3 +114,19 @@ 'use strict'; | ||
var SnippetSrc = toV1String(); | ||
var generateSnippetText = function generateSnippetText(_a) { | ||
var orgId = _a.orgId, | ||
_b = _a.namespace, | ||
namespace = _b === void 0 ? 'FS' : _b, | ||
_c = _a.debug, | ||
debug = _c === void 0 ? false : _c, | ||
_d = _a.host, | ||
host = _d === void 0 ? 'fullstory.com' : _d, | ||
_e = _a.script, | ||
script = _e === void 0 ? 'edge.fullstory.com/s/fs.js' : _e; | ||
if (!orgId) { | ||
throw new Error('FullStory orgId is a required parameter'); | ||
} | ||
return "window['_fs_debug'] = ".concat(debug, ";\nwindow['_fs_host'] = '").concat(host, "';\nwindow['_fs_script'] = '").concat(script, "';\nwindow['_fs_org'] = '").concat(orgId, "';\nwindow['_fs_namespace'] = '").concat(namespace, "';\n").concat(SnippetSrc, "\n"); | ||
}; | ||
exports.SnippetSrc = SnippetSrc; | ||
exports.generateSnippetText = generateSnippetText; | ||
exports.initFS = initFS; |
{ | ||
"name": "@fullstory/snippet", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "FullStory snippet source", | ||
@@ -9,3 +9,3 @@ "main": "./dist/index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "rollup -c && babel bundle --out-dir dist" | ||
"build": "rollup -c && babel bundle --out-dir dist && cp bundle/build/index.d.ts dist" | ||
}, | ||
@@ -12,0 +12,0 @@ "files": [ |
# FullStory Snippet | ||
This is currently used internally at FullStory. Public documentation coming soon. | ||
FullStory's snippet package provides a number of ways to integrate the FullStory snippet with your build tooling of choice. For a more integrated experience, try the [browser SDK](https://www.npmjs.com/package/@fullstory/browser). | ||
## Installation | ||
#### with npm | ||
``` | ||
npm i @fullstory/snippet --save | ||
``` | ||
#### with yarn | ||
``` | ||
yarn add @fullstory/snippet | ||
``` | ||
## Exports | ||
### `generateSnippetText` | ||
#### Options | ||
* `orgId` - Sets your FullStory Org Id. Find out how to get your Org Id [here](https://help.fullstory.com/hc/en-us/articles/360047075853). Required. | ||
* `host` - The recording server host domain. Can be set to direct recorded events to a proxy that you host. Defaults to `fullstory.com`. | ||
* `script` - The full location of the FullStory script (fs.js). FullStory hosts the `fs.js` recording script on a CDN, but you can choose to host a copy yourself. Defaults to `edge.fullstory.com/s/fs.js`. | ||
* `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-). Defaults to `FS`. | ||
#### Usage | ||
Returns a stringified version of the FullStory snippet. This is useful for various build systems like webpack. | ||
#### Examples | ||
Webpack ([docs](https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates)) | ||
```js | ||
// webpack.config.js | ||
{ | ||
// ... | ||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
fsSnippet: generateSnippetText({ orgId: 'xyz' }), | ||
template: 'index.html', | ||
}) | ||
] | ||
} | ||
// index.html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script><%= htmlWebpackPlugin.options.fsSnippet %></script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> | ||
``` | ||
Gatsby ([docs](https://www.gatsbyjs.com/docs/reference/config-files/gatsby-ssr/#onRenderBody)) | ||
```js | ||
// gatsby-ssr.js | ||
exports.onRenderBody = ({ setHeadComponents }) => { | ||
setHeadComponent( | ||
<script | ||
dangerouslySetInnerHTML={{ | ||
__html: generateSnippetTxt({ orgId: 'xyz' }), | ||
}} | ||
/> | ||
); | ||
} | ||
``` | ||
### `initFS` | ||
#### Options | ||
Same as `generateSnippetText`. | ||
#### Usage | ||
Calling this function sets all the necessary global variables and immediately executes the FullStory snippet. | ||
> NOTE: this is used internally by [@fullstory/browser](https://www.npmjs.com/package/@fullstory/browser). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14092
5
278
76