• Borislav Stoilov
  • NEWBIE
  • 0 Points
  • Member since 2023
  • Developer
  • Klarna Bank AB

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

I am trying to integrate FullStory into SF.

The instalation is quite simple for regular pages, you just include a code snippet in the head ot the page, stuff gets loaded and it just works. However with Salesforce I am restricted by the shadow dom.

What I've tried is creating a static resource with the installation snippet, placed it inside a component and then placed the component inside a page.

I have logs in the script indicating that it was executed, furthermore in the component I have access to the variables declared by the script. However those variables are not present in the window object in the browser console. In order for FullStory to work (or any other third party that gets installed this way like Google Analytics) the data needs to be accessible on page global level.

 

This is my component

 

import { LightningElement } from 'lwc';
import fsScript from "@salesforce/resourceUrl/fsScript";
import { loadStyle, loadScript } from "lightning/platformResourceLoader";


export default class FullStoryTest extends LightningElement {

    connectedCallback() {
        console.log("in connect " + fsScript);
        loadScript(this, fsScript)
            .then(() => {
                console.log("Loaded");
                console.log("FS obj " + FS);
                window.FS = FS; // I have the variable here

                console.log("window " + window);
                console.log("FS window " + window.FS); // setting it to the window object doesn't help


            }).catch((err) => console.log(err));

    }

}

 

How to properly install this library? 

I am trying to integrate FullStory into SF.

The instalation is quite simple for regular pages, you just include a code snippet in the head ot the page, stuff gets loaded and it just works. However with Salesforce I am restricted by the shadow dom.

What I've tried is creating a static resource with the installation snippet, placed it inside a component and then placed the component inside a page.

I have logs in the script indicating that it was executed, furthermore in the component I have access to the variables declared by the script. However those variables are not present in the window object in the browser console. In order for FullStory to work (or any other third party that gets installed this way like Google Analytics) the data needs to be accessible on page global level.

 

This is my component

 

import { LightningElement } from 'lwc';
import fsScript from "@salesforce/resourceUrl/fsScript";
import { loadStyle, loadScript } from "lightning/platformResourceLoader";


export default class FullStoryTest extends LightningElement {

    connectedCallback() {
        console.log("in connect " + fsScript);
        loadScript(this, fsScript)
            .then(() => {
                console.log("Loaded");
                console.log("FS obj " + FS);
                window.FS = FS; // I have the variable here

                console.log("window " + window);
                console.log("FS window " + window.FS); // setting it to the window object doesn't help


            }).catch((err) => console.log(err));

    }

}

 

How to properly install this library?