s-group-dev / react-usercentrics Goto Github PK
View Code? Open in Web Editor NEWReact utils for interacting with the Usercentrics Browser CMP
License: MIT License
React utils for interacting with the Usercentrics Browser CMP
License: MIT License
Hello, i just want to ask, if works in NextJs applications?
https://docs.usercentrics.com/#/cmp-v2-ui-api has some methods that this package doesn't include yet, such as
Is it possible to add them? I'm happy to do a Pull Request.
I'm using the library with NextJs in a similar way as explained by #5
// _app.tsx
<div>
<UsercentricsScript
settingsId={envVars.get("NEXT_PUBLIC_USERCENTRICS_ID")}
version="production"
/>
<UsercentricsProvider windowEventName="ucEvent">
<MatomoProvider value={instance}>
<MatomoClient />
<Component {...pageProps} />
</MatomoProvider>
</UsercentricsProvider>
</div>
On local, with version="preview"
it does show the cookie consent with dummy data (I guess that's why it's preview).
However, on production, I'm running into
errorMessage: "Unable to find available languages using given settingsId and version."
statusCode: 403
The main problem being with calling GET https://api.usercentrics.eu/settings/{:id}/production/languages.json
(403)
Any advice?
My application codebase is in NextJs with React.
I have a component Media, that needs user consent to enable a script that collects data, so we created a hook that verifies if we can load this Media component.
I can run more atomic (atomic pattern design) unit tests without any problems, but when coming to organisms, I start getting this error.
Can you guys assist me on this?
yarn run v1.22.19
$ jest --silent Hero.spec.tsx
FAIL src/components/organisms/Hero/__tests__/Hero.spec.tsx
● Test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
• If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation
Details:
/<APPLICATION>/node_modules/@s-group/react-usercentrics/dist/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { UsercentricsDialogToggle } from './components/UsercentricsDialogToggle.js';
^^^^^^
SyntaxError: Unexpected token 'export'
> 1 | import {
| ^
2 | getServicesBaseInfo,
3 | hasServiceConsent,
4 | ServiceInfo,
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
at Object.<anonymous> (src/hooks/usePermission.ts:1:1)
at Object.<anonymous> (src/hooks/useMarketo.ts:3:1)
at Object.<anonymous> (src/hooks/index.ts:9:1)
at Object.<anonymous> (src/components/molecules/media/Media.tsx:4:1)
at Object.<anonymous> (src/components/molecules/media/index.ts:1:1)
at Object.<anonymous> (src/components/organisms/Hero/Hero.tsx:7:1)
at Object.<anonymous> (src/components/organisms/Hero/index.ts:1:1)
at Object.<anonymous> (src/components/organisms/Hero/__tests__/Hero.spec.tsx:3:1)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 8.356 s
error Command failed with exit code 1.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.