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

Script load ever and do not respect a condition for a trigger manual #307

Open
Met96 opened this issue Oct 22, 2024 · 4 comments
Open

Script load ever and do not respect a condition for a trigger manual #307

Met96 opened this issue Oct 22, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@Met96
Copy link

Met96 commented Oct 22, 2024

📚 What are you trying to do?

I make the follow code for run the script only in a specific countries, but it will be loaded ever without respect the condition
The follow code is inside a composable called in the app.vue of nuxt project.

Can you help me ?

🔍 What have you tried?

const notLoadCookieBanner = ['en-us'] 
const countryLocale = ref('es-es')
const {
    onLoaded,
    load: loadCookie,
  } = useScript<OneTrust>(
    {
      src: 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js',
      'data-domain-script': '....',
      defer: true,
    },
    {
      trigger: 'manual',
      use() {
        return window.OneTrust
      },
    }
  )

  if (
    countryLocale.value &&
    notLoadCookieBanner.findIndex(
      countryLocaleBanner => countryLocaleBanner === countryLocale.value
    ) === -1
  ) {
    loadCookie()
  }

ℹ️ Additional context

No response

@Met96 Met96 added the help wanted Extra attention is needed label Oct 22, 2024
@harlan-zw
Copy link
Collaborator

Hi, can you please make a minimal reproduction?

You can use the starter here: https://stackblitz.com/edit/nuxt-starter-pkwfkx?file=pages%2Findex.vue

@Met96
Copy link
Author

Met96 commented Oct 22, 2024

I tried it with stackblitz but it's running correctly, so i think it was a problem with Netlify or cache system

@harlan-zw
Copy link
Collaborator

I need a way to replicate it to fix it unfortunately

@Met96
Copy link
Author

Met96 commented Oct 22, 2024

Yeah i know, so next days i'll send you more updates to test it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants