Skip to content

Update FullStory with current snippet and new API usage #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions integrations/fullstory/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
3.0.0 / 2020-12-11
==================

* Update snippet to the most recent version, including new setVars and anonymize functionality.
* Now use setVars API to track pages in FullStory.
* A new setting, trackPagesWithEvents has been added to allow tracking via events in addition to the new behavior, to support the transition. This defaults to true.

2.2.4 / 2020-04-02
==================

* Add missing definition of window._fs_script
* Add a line missing from the end of the snippet

2.2.3 / 2020-02-17
==================

Expand Down
33 changes: 29 additions & 4 deletions integrations/fullstory/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var FullStory = (module.exports = integration('FullStory')
.option('trackAllPages', false)
.option('trackNamedPages', false)
.option('trackCategorizedPages', false)
.option('trackPagesWithEvents', true)
.tag(
'<script async src="https://edge.fullstory.com/s/fs.js" crossorigin="anonymous"></script>'
));
Expand All @@ -37,6 +38,7 @@ var apiSource = 'segment';
FullStory.prototype.initialize = function() {
window._fs_debug = this.options.debug;
window._fs_host = 'fullstory.com';
window._fs_script = 'edge.fullstory.com/s/fs.js';
window._fs_org = this.options.org;
window._fs_namespace = 'FS';

Expand All @@ -47,13 +49,16 @@ FullStory.prototype.initialize = function() {
if (e in m) {if(m.console && m.console.log) { m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');} return;}
g=m[e]=function(a,b,s){g.q?g.q.push([a,b,s]):g._api(a,b,s);};g.q=[];
g.identify=function(i,v,s){g(l,{uid:i},s);if(v)g(l,v,s)};g.setUserVars=function(v,s){g(l,v,s)};g.event=function(i,v,s){g('event',{n:i,p:v},s)};
g.anonymize=function(){g.identify(!!0)};
g.shutdown=function(){g("rec",!1)};g.restart=function(){g("rec",!0)};
g.log = function(a,b) { g("log", [a,b]) };
g.log = function(a,b){g("log",[a,b])};
g.consent=function(a){g("consent",!arguments.length||a)};
g.identifyAccount=function(i,v){o='account';v=v||{};v.acctId=i;g(o,v)};
g.clearUserCookie=function(){};
g.setVars=function(n, p){g('setVars',[n,p]);};
g._w={};y='XMLHttpRequest';g._w[y]=m[y];y='fetch';g._w[y]=m[y];
if(m[y])m[y]=function(){return g._w[y].apply(this,arguments)};
g._v="1.3.0";
})(window,document,window['_fs_namespace'],'script','user');
/* eslint-enable */

Expand Down Expand Up @@ -112,16 +117,36 @@ FullStory.prototype.page = function(page) {
var category = page.category();
var name = page.fullName();
var opts = this.options;
var trackProps = page.track().properties();

if (name && opts.trackNamedPages) {
// named pages
this.track(page.track(name));
if (opts.trackPagesWithEvents) {
this.track(page.track(name));
}

window.FS.setVars(
'page',
Object.assign(trackProps, { pageName: name }),
apiSource
);
} else if (category && opts.trackCategorizedPages) {
// categorized pages
this.track(page.track(category));
if (opts.trackPagesWithEvents) {
this.track(page.track(category));
}

window.FS.setVars(
'page',
Object.assign(trackProps, { pageName: category }),
apiSource
);
} else if (opts.trackAllPages) {
// all pages
this.track(page.track());
if (opts.trackPagesWithEvents) {
this.track(page.track());
}
window.FS.setVars('page', trackProps, apiSource);
}
};

Expand Down
2 changes: 1 addition & 1 deletion integrations/fullstory/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/analytics.js-integration-fullstory",
"description": "The Fullstory analytics.js integration.",
"version": "2.2.3",
"version": "3.0.0",
"keywords": [
"analytics.js",
"analytics.js-integration",
Expand Down