1

I am new to Google Apps Script Add-on. I want to implement fullStory for data capture and user experience. I had developed the fullstory in the excel add-in successfully, but when I tried to create the same for the google app script add-on it was not working. I have added the script tag in google sheet add-on but it's not working as per it's document.

I have followed the below step:

https://help.fullstory.com/hc/en-us/articles/360020828273-Getting-Started-with-FullStory

I have added the below script in head section of add-on HTML file.

<script>
window['_fs_host'] = 'fullstory.com';
window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
window['_fs_org'] = 'id';
window['_fs_namespace'] = 'FS';
(function(m,n,e,t,l,o,g,y){
    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=[];
    o=n.createElement(t);o.async=1;o.crossOrigin='anonymous';o.src='https://'+_fs_script;
    y=n.getElementsByTagName(t)[0];y.parentNode.insertBefore(o,y);
    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.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');
</script>

Code of Apps Script

Login.html

<head>
  <base target="_top">
  <script type="module" src="https://unpkg.com/@fluentui/web-components"></script>
  <?!= include('stylesheet'); ?>
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
  <!-- Style CDN -->
  <link href="https://fonts.cdnfonts.com/css/graphik" rel="stylesheet" crossorigin="anonymous">
  <style>
    body {
      margin: 0;
      padding: 0;
    }
  </style>
  <script>
    window['_fs_host'] = 'fullstory.com';
    window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
    window['_fs_org'] = 'id';
    window['_fs_namespace'] = 'FS';
    (function (m, n, e, t, l, o, g, y) {
      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 = [];
      o = n.createElement(t); o.async = 1; o.crossOrigin = 'anonymous'; o.src = 'https://' + _fs_script;
      y = n.getElementsByTagName(t)[0]; y.parentNode.insertBefore(o, y);
      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.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');
  </script>
</head>

macro.gs

function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu('Custom Menu')
    .addItem('Show sidebar', 'showSidebar')
    .addToUi();
}

function doGet() {
  return HtmlService.createHtmlOutputFromFile('home');
}

function include(filename) {
  return HtmlService.createHtmlOutputFromFile(filename)
    .getContent();
}

function showSidebar() {
  var html = HtmlService.createTemplateFromFile('login').evaluate().setTitle("Add-on")
  SpreadsheetApp.getUi()
    .showSidebar(html);
}

I have provided the image of network pane for fullStory. network pane of fullStory

Image of privacy Section Privacy section Here is the link for fullStory document.

https://developer.fullstory.com/introduction

I don't know why it's not working.
Can anyone guide me on this?

Shiv Yadav
  • 467
  • 2
  • 11
  • Pleae show what you have tried and add a brief description of your search efforts including links to the most relevant posts from this site explaning why they didn't help you. – Rubén Feb 03 '23 at 06:09
  • I have added the script tag in the head section of the HTML file of the add-on. I had find the document for fullStory development for the google add-on but I'm not got it. I had find the question on the StackOverflow but i failed to get it. – Shiv Yadav Feb 03 '23 at 06:42
  • Please add a [mcve] (you should include how the add-on opens the html and a complete html, not only the script of the head) – Rubén Feb 03 '23 at 06:43
  • Also add the relevant Web Browser JavaScript console logs errors and the Apps Script execution logs – Rubén Feb 03 '23 at 06:46
  • There is not any console logs error. In the network pane, it's showing the status 200. Fullstory working fine with other web project but not with add-on – Shiv Yadav Feb 03 '23 at 07:00
  • Could you explain "not working"? What do you expect to happen? Why? What happened? – TheMaster Feb 03 '23 at 10:50
  • When I see users of the day in my fullStory account. At that time it displays 0 Users. – Shiv Yadav Feb 03 '23 at 10:53
  • I have tried the same code with another web project. In that project, it's working fine. In my fullStory account it's not displaying user of the day – Shiv Yadav Feb 03 '23 at 10:55
  • What about "Privacy" section in fuStory dashboard - can you see multiple data elements? – TheMaster Feb 03 '23 at 14:26
  • I have added the screenShot of the privacy section. – Shiv Yadav Feb 06 '23 at 06:33

2 Answers2

2

Your client side of the sidebar is sent as a string to be injected into an iframe. One thing that you could try that others have found worked for them is adding this additional flag in script:

window['_fs_is_outer_script'] = true;

You can get more information on this flag in the iframe article :

Hope this will help you.

Poojan3037
  • 310
  • 1
  • 9
0

I'm not familiar with fullstory, but I see that your add-on is opening the client-side code in a sidebar. In this case the client-side of the sidebar is sent as as string to be injected into an iframe, so it will be constrained to the sidebar dimensions.

In other other words, if you are intending to use fullstory over the grid and other Google Sheets UI elements, it will not work.

Anyway, please be aware that the client-side code is satinized so the parts that don't pass the sanitization will not be included, so use the browser developer tools to validate that the whole client-side code is sent.

P.S. I suggest you to include <!DOCTYPE html> and <html>, </html>.

Related

Resources

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • docType already added in the original code. I have not include the question. – Shiv Yadav Feb 03 '23 at 07:36
  • Measns we can't implement fullStory in the google Appscript Add-on? – Shiv Yadav Feb 03 '23 at 07:36
  • I added a link to a related question that you might find helpful to understand the iframe layers in the sidebar. As I mentioned in my answer I'm not familiar with fullStory, if no body else comes with a more specific answer you have to read the fullStory docs to learn about its requirements / limitations. – Rubén Feb 03 '23 at 07:41
  • Your related link help to understand the layers. but i'm not getting the meaning of "In other words, if you are intending to use fullstory over the grid, it will not work." which type of grid you are talking about? – Poojan3037 Feb 03 '23 at 08:56
  • Have you hear the term "gridlines"? Like in Sheets toolbar View > Show > Gridlines – Rubén Feb 03 '23 at 08:59
  • The grid is the area where the cells are placed. A sheet contains a grid (cells organized in columns and rows), column headers, row headers,, a tab, etc. – Rubén Feb 03 '23 at 09:00