Skip to content
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

_fs_script is not defined #74

Open
sanathfp opened this issue Oct 15, 2020 · 6 comments
Open

_fs_script is not defined #74

sanathfp opened this issue Oct 15, 2020 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@sanathfp
Copy link

sanathfp commented Oct 15, 2020

I'm using an angular app and I'm trying to render the app on the server.
Here is my app.component.ts

constructor() {
FullStory.init({ orgId: '<code>',
devMode: !environment.fullstoryProduction });
}

When I try to run my application, I get an error that says _fs_script is not defined. I tried manually setting the window element by using window['_fs_script'] = 'edge.fullstory.com/s/fs.js';. Still no luck.

@van-fs
Copy link
Member

van-fs commented Oct 15, 2020

Hi @sanathfp, thanks for reaching out. Admittedly, I haven't tested a server-side rendered scenario for the browser-sdk. Is your app on a test server that I could investigate? As a stop gap, you could simply add the FullStory snippet to the <head> tag in index.html. This obviates the browser-sdk altogether, but if you're in need to getting an SSR version of your app with FullStory, it's an immediate solution. Let me know if that test server might be available, and I'll take a look. Else, I'll need time to update our angular demo app and test.

@van-fs van-fs self-assigned this Oct 15, 2020
@van-fs van-fs added the bug Something isn't working label Oct 15, 2020
@sanathfp
Copy link
Author

Hey @van-fs
Thanks for reaching out on such short notice. I don't have the code up on a test server yet.
I could put the snippet code directly on the head tag, but then I also need it to not track while running on the staging servers.
That's in fact, the main reason why I'm using your npm library!

@van-fs
Copy link
Member

van-fs commented Oct 15, 2020

@sanathfp Ah, so you're using the browser-sdk to selectively load FullStory, correct? If so, I think we can solve that outside of code actually. You can update FullStory admin settings to block recording for specific domains (e.g. localhost:4200 or dev.yourapp.com). See Can I disable recording for a specific domain? Let me know if that's a more appropriate solution to limiting recording for your app

@sanathfp
Copy link
Author

This sounds like a good solution! I'm guessing it will work as it doesn't depend on the library. Thanks for this.
But, it does come across as a bummer to people who want to use this library while doing SSR. Though this might be of low priority, I think it's still worth fixing later.

Thank you!

@patrick-fs
Copy link
Member

Hey @sanathfp not sure if this helps you, but check out this tip we gave someone for running FullStory in a Next.js application: #51

@dalmia
Copy link

dalmia commented Oct 17, 2022

Following @patrick-fs's comment, this is the snippet that worked for my Nuxt.js SSR app in case anyone came here looking for that (adding the fullstory SDK as a plugin and using Nuxt Lifecycle hooks to ensure that the script is added only on the client side):

import * as FullStory from '@fullstory/browser'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.hook('app:beforeMount', () => {
    FullStory.init({ orgId: useRuntimeConfig().FULLSTORY_ORG_ID })
    nuxtApp.vueApp.config.globalProperties.$FullStory = FullStory
  })
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@dalmia @patrick-fs @van-fs @sanathfp and others