clevertap / clevertap-web-sdk Goto Github PK
View Code? Open in Web Editor NEWCleverTap Web SDK
Home Page: https://clevertap.com/
License: MIT License
CleverTap Web SDK
Home Page: https://clevertap.com/
License: MIT License
@pwilkniss @Aditi3 @kunl-code created type-definitions for this repo: DefinitelyTyped/DefinitelyTyped#57546. This will be live in a couple of hours and can be installed via npm.
npm install --save-dev @types/clevertap-web-sdk
or yarn
yarn add --dev @types/clevertap-web-sdk
Can you suggest someone who can maintain this repo for future. Will add them to the repo: https://github.com/droyson/DefinitelyTyped/tree/clevertap-web-sdk
Console Error:
logger.js:56 CleverTap [1658898472908]: CleverTap error: Incorrect embed script.
Clevertap version: 1.2.0
I am not able to understand this error. Can someone help me to understand the error and solution for this.
My application is Sveltekit SSR
Clevertap Setup
let clevertap;
export async function ctInit(id: string) {
if (!window) return
const clevertapInit = await import('clevertap-web-sdk')
clevertap = clevertapInit.default
// replace with the CLEVERTAP_ACCOUNT_ID with the actual ACCOUNT ID value from your Dashboard -> Settings page
clevertap.init(id, '', API.CLEVERTAP_PROXY);
clevertap.privacy.push({ optOut: false }); //set the flag to true, if the user of the device opts out of sharing their data
clevertap.privacy.push({ useIP: false }); //set the flag to true, if the user agrees to share their IP data
clevertap.spa = true;
}
@akashvercetti @abhu-A-J
This is a bug on the admin pages of Clevertap. I want to save my Webhook configuration but i receive a 502 error.
https://eu1.dashboard.clevertap.com/ZR9-7ZR-546Z/account-setup/campaigns-journeys/channels/webhooks
Please, tell someone to fix this. It's very urgent.
Hey @akashvercetti @pranaywarke I am unable to send Array of string as Event Property in Clevertap web SDK, i am getting the below Error, Is it possible to send Array of string/boolean as event property or is there any work Around to send Array as Event Property? please let me know.
Do you have a typescript support for this?
declare module "clevertap-web-sdk" {
export const event: any[];
export const profile: any[];
export const account: any[];
export const onUserLogin: any[];
export const notifications: any[];
export const privacy: any[];
export function init(accountId: string, region?: string, domain?: string);
export let spa: boolean;
export function setLogLevel( level: nuumber );
}
i did end up making a temporary one for now
We received an error reported from our Sentry monitor, mentioned the clevertap web SDK is throwing an error as screenshot below shown.
After tracing the root cause, we found that this is because the SDK never consider boolean value while checking the clevertap data stored in the localstorage.
I think that is quite clear in how to fix the bug, lets me know if you need me to submit a PR ๐
clevertap.init('account_id', '', API.CLEVERTAP_PROXY);
when we are passing the empty string for the REGION
in clevertap init function, it starts loading the random region for in in API url https://eu1.s.myproxyurl.com/
.
It should be like this. https://s.myproxyurl.com/
.
To reproduce this issue please use the 1.1.0
latest version.
For now, I am using the 1.0.0
. It is working fine.
Sometimes the event that triggered appears twice in the clevertap activity tab
Step to reproduce
yarn
.env.local
NEXT_PUBLIC_CT_ID=
and fille with clevertap idyarn dev
Why don't we change the implementation to use fetch api or any http request library instead of appending script
tag inside head
tag and place the query inside it
clevertap-web-sdk/src/util/requestDispatcher.js
Lines 66 to 78 in 7680813
Hi, there Clevertap team.
Due to analytics packet drops on ios devices, we decided to run clever tap by using a custom reverse proxy on our server and followed through the steps mentioned on the docs
Although the proxy setup seems to be running fine, we could see our events get populated, we do not receive any response body when hitting the API through curl or similar, unlike the original domain which returns a response body.
Status code of 200 with empty body. (proxy domain)
https://{proxyDomain}/a?t=96&type=push&d=N4IgLgngDgpiBcIoCcD2AzAlgGzgGiTS1wVAGMwB9VKMVAVzAXQENsBnGAXwMwBMEIAEoBWAJwBaANIB2KRJEAWAGwAtEAQDmg9GICMygBzpdZMnsWKARgAYZVgEx7zZGOjKOxRq8o0h2CAYyNiIyimGGBFDa8A5cQA%3D&optOut=false&rn=1&i=1670574827&sn=0&gc=f9168ff9cc144b07b21c1cefcb2968b6&arp=N4Ig1g%2BgdiBcIG0AEAdEBqAnARkwDgBYBWABgIDZy9M0kAaVEfYsy6tAXRDpACto4IAJoAmAA68ApgHchAQW4gAlgPiiiYAGYBzAIoBhRQBMIAFwDOcEjyMALKzwBucbD36X4wJAF9FSo4IASkSYALQA0gDs4aFEFABaipJmHtYgAE4pLuSRJESRBAV4PErmAPIAqgAycKbpAK6S3kAAAA%3D%3D&tries=1&useIP=true&r=1670574827575
Status code of 200 with body which has a response. (OG API)
https://eu1.clevertap-prod.com/a?t=96&type=push&d=N4IgLgngDgpiBcIoCcD2AzAlgGzgGiTS1wVAGMwB9VKMVAVzAXQENsBnGAXwMwBMEIAEoBWAJwBaANIB2KRJEAWAGwAtEAQDmg9GICMygBzpdZMnsWKARgAYZVgEx7zZGOjKOxRq8o0h2CAYyNiIyimGGBFDa8A5cQA%3D&optOut=false&rn=1&i=1670574827&sn=0&gc=f9168ff9cc144b07b21c1cefcb2968b6&arp=N4Ig1g%2BgdiBcIG0AEAdEBqAnARkwDgBYBWABgIDZy9M0kAaVEfYsy6tAXRDpACto4IAJoAmAA68ApgHchAQW4gAlgPiiiYAGYBzAIoBhRQBMIAFwDOcEjyMALKzwBucbD36X4wJAF9FSo4IASkSYALQA0gDs4aFEFABaipJmHtYgAE4pLuSRJESRBAV4PErmAPIAqgAycKbpAK6S3kAAAA%3D%3D&tries=1&useIP=true&r=1670574827575
Can you help us with what might be causing this/ or do we need additional setup on clkoudfront to get back the origin response body on viewer request? Assuming the incoming body is used by the SDK itself ??
Issue: We want to use two clevertap instances on a site and both instances are belong to different account. But on window level, we get clevertap only and there is no way to indetify which clevertap instance is this.
Can someone please help us how to use multiple clevertap instance.
Hi Clevertap Team,
I wanted to confirm if web SDK supports a way to provide an option for a proxy domain on web SDK, similar to ios SDK's
I was not able to find the option on docs , so wanted if there is a way to achieve this.
For a custom event on clevertap, we are passing a string value for a particular property, but on clevertap events dashboard it is reflecting in integer formats.
Following is the code snippet we are using to record our custom events:
clevertap.event.push("submit_info", {
user_info:"087888975005" // this property is passed as *string*
});
Here, the property user_info although passes as string, is reflecting as integer on the dashboard.
Alternately, for the same event if I limit the user_info property's value to 10 or less characters, it correctly reflects as a string on the dashboard.
clevertap.event.push("submit_info", {
user_info:"0878889750" // "0878889750" instead of"087888975005"
});
We have also updated the custom event schema in project settings by defining the property to accept string format values only, but still the they are being populated in integer format.
Please correct us if we are missing something here, although from our findings it is only happening in case of the property value being more than 10 characters.
Hi Team, hopefully this is right place to ask, if not, I'd appreciate if you can direct me.
I'm the founder of cloudquery.io, a high performance open source ELT framework.
Our users are interested in an CleverTap plugin, but as we cannot maintain all the plugins ourselves, I was curious if this would be an interesting collaboration, where we would help implement an initial source plugin, and you will help maintain it.
This will give your users the ability to sync CleverTap data to any of their datalakes/data-warehouses/databases easily using any of the growing list of CQ destination plugins.
Best,
Yevgeny
some examples on setting up with Next.js will help
we have set it up anyway by adding it to _document.tsx
<script
type="text/javascript"
async
src="https://cdn.jsdelivr.net/npm/clevertap-web-sdk/clevertap.min.js"
/>
clevertap.init('ACCOUNT_ID', 'REGION', 'TARGET_DOMAIN')
TARGET_DOMAIN (optional): domain of the proxy server.
Let's say if I call the clevertap.init()
with params clevertap.init(<my_account_id>, '', <my_custom_domain>)
, to which server <my_custom_domain>
should redirect the clevertap events?
Hi @akashvercetti. We use the clever tap as our analytics tool at our organization and recently have been trying to port all our third-party libraries through Partytown and wanted to know if you plan our adding support (docs on party town) for it as well?
Although Partytown runs with almost zero configuration, depending upon the library we are using we need to set up the correct event forwarding and proxies.
Just wanted to know if a clever tap can be used via Partytown or not?
Would love to help write docs and examples with setting it up if it's possible (since I'm not very well aware of clever tap internals) and bring it to the official list here
Plus the option to alter type of script is some config would be great so we can run it through PT.
<Partytown
debug
forward={[
'clevertap',
'clevertap.account',
'clevertap.clear',
'clevertap.event.push',
'clevertap.event.getDetails',
'clevertap.getClevertapID',
'clevertap.logout',
'clevertap.notifications.push',
'clevertap.onUserLogin.push',
'clevertap.privacy.push',
'clevertap.profile.push',
'clevertap.profile.getAttribute',
'clevertap.session.getPageCount',
'clevertap.session.getTimeElapsed',
'clevertap.user.getLastVisit',
'clevertap.user.getTotalVisits'
]}
resolveUrl={()=>{
// setup reverse proxies if needed
}}
/>
I am using the clevertap-web-sdk for a company project on next-js
This is the error i get when i try to run the app
Server Error
ReferenceError: HTMLElement is not defined
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/node_modules/clevertap-web-sdk/clevertap.js (3473:36)
<unknown>
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/node_modules/clevertap-web-sdk/clevertap.js (2:83)
Object.<anonymous>
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/node_modules/clevertap-web-sdk/clevertap.js (5:2)
Module._compile
internal/modules/cjs/loader.js (1072:14)
Object.Module._extensions..js
internal/modules/cjs/loader.js (1101:10)
Module.load
internal/modules/cjs/loader.js (937:32)
Function.Module._load
internal/modules/cjs/loader.js (778:12)
Module.require
internal/modules/cjs/loader.js (961:19)
require
internal/modules/cjs/helpers.js (92:18)
Object.clevertap-web-sdk
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/pages/_app.js (28307:18)
__webpack_require__
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/webpack-runtime.js (33:43)
eval
webpack-internal:///./src/screens/Login/Login.bookmychef.web.js (51:76)
Function.__webpack_require__.a
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/webpack-runtime.js (97:13)
eval
webpack-internal:///./src/screens/Login/Login.bookmychef.web.js (1:21)
Module../src/screens/Login/Login.bookmychef.web.js
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/pages/_app.js (19538:1)
__webpack_require__
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/webpack-runtime.js (33:43)
eval
webpack-internal:///./app/navigationConfig.js (15:85)
Function.__webpack_require__.a
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/webpack-runtime.js (97:13)
eval
webpack-internal:///./app/navigationConfig.js (1:21)
Module../app/navigationConfig.js
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/pages/_app.js (17570:1)
__webpack_require__
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/webpack-runtime.js (33:43)
eval
webpack-internal:///./src/common/NavigationManager.next.js (16:86)
Function.__webpack_require__.a
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/webpack-runtime.js (97:13)
eval
webpack-internal:///./src/common/NavigationManager.next.js (1:21)
Module../src/common/NavigationManager.next.js
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/pages/_app.js (18262:1)
__webpack_require__
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/webpack-runtime.js (33:43)
eval
webpack-internal:///./src/pages/_app.js (20:90)
Function.__webpack_require__.a
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/webpack-runtime.js (97:13)
eval
webpack-internal:///./src/pages/_app.js (1:21)
Module../src/pages/_app.js
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/pages/_app.js (19175:1)
__webpack_require__
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/webpack-runtime.js (33:43)
__webpack_exec__
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/pages/_app.js (30669:39)
<unknown>
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/pages/_app.js (30670:28)
Object.<anonymous>
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/build/staging_bookmychef/.next/server/pages/_app.js (30673:3)
Module._compile
internal/modules/cjs/loader.js (1072:14)
Object.Module._extensions..js
internal/modules/cjs/loader.js (1101:10)
Module.load
internal/modules/cjs/loader.js (937:32)
Function.Module._load
internal/modules/cjs/loader.js (778:12)
Module.require
internal/modules/cjs/loader.js (961:19)
require
internal/modules/cjs/helpers.js (92:18)
Object.requirePage
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/node_modules/next/dist/server/require.js (58:12)
<unknown>
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/node_modules/next/dist/server/load-components.js (58:54)
runMicrotasks
<anonymous>
processTicksAndRejections
internal/process/task_queues.js (95:5)
async Object.loadComponents
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/node_modules/next/dist/server/load-components.js (56:33)
async DevServer.findPageComponents
file:///Users/ranvijaychouhan/Desktop/Ganesh/mono-repo/presto-rn-build/node_modules/next/dist/server/next-server.js (555:36)
Initialising it like this
clevertap.privacy.push({ optOut: false });
clevertap.privacy.push({ useIP: false });
clevertap.init('XXXXXXXXXX', "eu1");
Version
"clevertap-web-sdk": "^1.6.8",
"next": "^12.2.5",
Please let me know if any other information is needed
Error I receive:
Server Error
ReferenceError: HTMLElement is not defined
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
file:///C:/Users/ASUS/Desktop/Self-Study/NEXT_REACT/clevertap-next-integration/node_modules/.pnpm/[email protected]/node_modules/clevertap-web-sdk/clevertap.js (3474:36)
<unknown>
file:///C:/Users/ASUS/Desktop/Self-Study/NEXT_REACT/clevertap-next-integration/node_modules/.pnpm/[email protected]/node_modules/clevertap-web-sdk/clevertap.js (2:83)
Object.<anonymous>
file:///C:/Users/ASUS/Desktop/Self-Study/NEXT_REACT/clevertap-next-integration/node_modules/.pnpm/[email protected]/node_modules/clevertap-web-sdk/clevertap.js (5:2)
Module._compile
node:internal/modules/cjs/loader (1256:14)
Module._extensions..js
node:internal/modules/cjs/loader (1310:10)
Module.load
node:internal/modules/cjs/loader (1119:32)
Module._load
node:internal/modules/cjs/loader (960:12)
Module.require
node:internal/modules/cjs/loader (1143:19)
mod.require
file:///C:/Users/ASUS/Desktop/Self-Study/NEXT_REACT/clevertap-next-integration/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js (65:28)
require
node:internal/modules/cjs/helpers (121:18)
clevertap-web-sdk
file:///C:/Users/ASUS/Desktop/Self-Study/NEXT_REACT/clevertap-next-integration/.next/server/pages/index.js (76:18)
__webpack_require__
file:///C:/Users/ASUS/Desktop/Self-Study/NEXT_REACT/clevertap-next-integration/.next/server/webpack-runtime.js (33:42)
eval
webpack-internal:///./pages/index.js (7:75)
./pages/index.js
file:///C:/Users/ASUS/Desktop/Self-Study/NEXT_REACT/clevertap-next-integration/.next/server/pages/index.js (55:1)
__webpack_require__
file:///C:/Users/ASUS/Desktop/Self-Study/NEXT_REACT/clevertap-next-integration/.next/server/webpack-runtime.js (33:42)
In my _app.js
import "@/styles/globals.css";
import clevertap from "clevertap-web-sdk"
clevertap.init("********");
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />;
}
Inside my index.js I created a simple app:
import clevertap from "clevertap-web-sdk";
export default function Home() {
return (
<div className="App">
<h3>CleverTap Web SDK using React</h3>
<div>
<button onClick={handleEventPushClick}>Push Event</button>
</div>
</div>
);
}
function handleEventPushClick() {
clevertap.event.push("Product Viewed", {
"Product name": "Casio Chronograph Watch",
Category: "Mens Accessories",
Price: 59.99,
Date: new Date(),
}); // Replace Payload as per your event schema and design
clevertap.onUserLogin.push({
"Site": {
"Name": "Jack Montana", // String
"Identity": 61026032, // String or number
"Email": "[email protected]", // Email address of the user
"Phone": "+14155551234", // Phone (with the country code)
"Gender": "M", // Can be either M or F
"DOB": new Date(), // Date of Birth. Date object
// optional fields. controls whether the user will be sent email, push etc.
"MSG-email": false, // Disable email notifications
"MSG-push": true, // Enable push notifications
"MSG-sms": true, // Enable sms notifications
"MSG-whatsapp": true, // Enable WhatsApp notifications
}
})
}
I tried this: https://github.com/KambleSonam/clevertap-next-demo but it still doesn't work
When I try to do a web push using a simple example for the documentation I get the below error
CleverTap [1678351307444]: Ensure that web push notifications are fully enabled and integrated before requesting them
Before I can use the example and got the push over Chrom, FireFox and Safari, now I only get the error!
<script type="text/javascript">
var clevertap = {event:[], profile:[], account:[], onUserLogin:[], notifications:[], privacy:[]};
// replace with the CLEVERTAP_ACCOUNT_ID with the actual ACCOUNT ID value from your Dashboard -> Settings page
clevertap.account.push({"id": "XXXXXXXXXXXXXX"});
clevertap.privacy.push({optOut: false}); //set the flag to true, if the user of the device opts out of sharing their data
clevertap.privacy.push({useIP: false}); //set the flag to true, if the user agrees to share their IP data
(function () {
var wzrk = document.createElement('script');
wzrk.type = 'text/javascript';
wzrk.async = true;
wzrk.src = 'https://d2r1yp2w7bby2u.cloudfront.net/js/clevertap.min.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wzrk, s);
})();
</script>
<script>
const doPushNotification = () => {
const clevertap = window.clevertap;
let customNotificationPayload = {
msgId: "111111111111111",
};
clevertap.notifications.push({
titleText: "Would you like to receive Push Notifications?",
bodyText:
"We promise to only send you relevant content and give you updates on your transactions",
okButtonText: "Sign me up!",
rejectButtonText: "No thanks",
okButtonColor: "#F28046",
skipDialog: true,
});
}
};
doPushNotification();
</script>
As title described, can I know the release date for this package?
Hi, we have cookiebot for cookie consent.
Im starting clevertap before if user accepted or not cookie consent.
Can we change privacy settings after init?
I've implemented the code in the project and after running, it ends up with this error:
Refused to load the script 'https://us1.clevertap-prod.com/a?t=96&type=page&d=N4IglgJiBcICoFEDKcC0BOAHJ1B2AWgKyoBKALAGz4gA0IADgOYwBMdAxkzCABYAufetAD0wgDYB7dgEMxPCQGc%2B0AMwAGDeImMwAO1ogA6vhIBpAPoBhAIIBZAAoxQAdwC29GGrp8x7GAG0AXQBfOmkAMycQMTAAI25nAFNY1AUIAGtUADcARgA6fJYQYOCgAA%3D&rn=4&i=1649835178&sn=0&useIP=true&r=1649835180740' because it violates the following Content Security Policy directive: "script-src 'nonce-9U7THwOdqNKAWeKl7glt3y==' 'self' https://maps.googleapis.com https://www.googletagmanager.com https://www.google.com/recaptcha/api.js https://cdn.jsdelivr.net/npm/clevertap-web-sdk/clevertap.min.js". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
I'm new to ReactJS app, need your help.
Thanks in advance.
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.