Skip to content

Commit e275cba

Browse files
Update FullStory with current snippet and new API usage (#544)
* Update fs.js source to CDN at edge.fullstory.com * Added some missing lines to the end of the snippet * Add missing definition of window._fs_script * Added another missing line at the end of the snippet * Update Fullstory snippet to latest version * Update FullStory to v3.0.0 * Change trackPagesWithEvents option default to true * Update HISTORY.md to accurately reflect new default state of tracking pages Co-authored-by: Daniel St. Jules <danielst.jules@gmail.com>
1 parent 0053708 commit e275cba

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

integrations/fullstory/HISTORY.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
3.0.0 / 2020-12-11
2+
==================
3+
4+
* Update snippet to the most recent version, including new setVars and anonymize functionality.
5+
* Now use setVars API to track pages in FullStory.
6+
* 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.
7+
8+
2.2.4 / 2020-04-02
9+
==================
10+
11+
* Add missing definition of window._fs_script
12+
* Add a line missing from the end of the snippet
13+
114
2.2.3 / 2020-02-17
215
==================
316

integrations/fullstory/lib/index.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var FullStory = (module.exports = integration('FullStory')
2020
.option('trackAllPages', false)
2121
.option('trackNamedPages', false)
2222
.option('trackCategorizedPages', false)
23+
.option('trackPagesWithEvents', true)
2324
.tag(
2425
'<script async src="https://edge.fullstory.com/s/fs.js" crossorigin="anonymous"></script>'
2526
));
@@ -37,6 +38,7 @@ var apiSource = 'segment';
3738
FullStory.prototype.initialize = function() {
3839
window._fs_debug = this.options.debug;
3940
window._fs_host = 'fullstory.com';
41+
window._fs_script = 'edge.fullstory.com/s/fs.js';
4042
window._fs_org = this.options.org;
4143
window._fs_namespace = 'FS';
4244

@@ -47,13 +49,16 @@ FullStory.prototype.initialize = function() {
4749
if (e in m) {if(m.console && m.console.log) { m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');} return;}
4850
g=m[e]=function(a,b,s){g.q?g.q.push([a,b,s]):g._api(a,b,s);};g.q=[];
4951
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)};
52+
g.anonymize=function(){g.identify(!!0)};
5053
g.shutdown=function(){g("rec",!1)};g.restart=function(){g("rec",!0)};
51-
g.log = function(a,b) { g("log", [a,b]) };
54+
g.log = function(a,b){g("log",[a,b])};
5255
g.consent=function(a){g("consent",!arguments.length||a)};
5356
g.identifyAccount=function(i,v){o='account';v=v||{};v.acctId=i;g(o,v)};
5457
g.clearUserCookie=function(){};
58+
g.setVars=function(n, p){g('setVars',[n,p]);};
5559
g._w={};y='XMLHttpRequest';g._w[y]=m[y];y='fetch';g._w[y]=m[y];
5660
if(m[y])m[y]=function(){return g._w[y].apply(this,arguments)};
61+
g._v="1.3.0";
5762
})(window,document,window['_fs_namespace'],'script','user');
5863
/* eslint-enable */
5964

@@ -112,16 +117,36 @@ FullStory.prototype.page = function(page) {
112117
var category = page.category();
113118
var name = page.fullName();
114119
var opts = this.options;
120+
var trackProps = page.track().properties();
115121

116122
if (name && opts.trackNamedPages) {
117123
// named pages
118-
this.track(page.track(name));
124+
if (opts.trackPagesWithEvents) {
125+
this.track(page.track(name));
126+
}
127+
128+
window.FS.setVars(
129+
'page',
130+
Object.assign(trackProps, { pageName: name }),
131+
apiSource
132+
);
119133
} else if (category && opts.trackCategorizedPages) {
120134
// categorized pages
121-
this.track(page.track(category));
135+
if (opts.trackPagesWithEvents) {
136+
this.track(page.track(category));
137+
}
138+
139+
window.FS.setVars(
140+
'page',
141+
Object.assign(trackProps, { pageName: category }),
142+
apiSource
143+
);
122144
} else if (opts.trackAllPages) {
123145
// all pages
124-
this.track(page.track());
146+
if (opts.trackPagesWithEvents) {
147+
this.track(page.track());
148+
}
149+
window.FS.setVars('page', trackProps, apiSource);
125150
}
126151
};
127152

integrations/fullstory/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-fullstory",
33
"description": "The Fullstory analytics.js integration.",
4-
"version": "2.2.3",
4+
"version": "3.0.0",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",

0 commit comments

Comments
 (0)