@causalfoundry/js-sdk
Version:
Causal Foundry WEB SDK (JS/TS)
110 lines (86 loc) • 2.98 kB
HTML
<html>
<head>
<!-- <script type="text/javascript" src="../lib/init.js"> </script>-->
<title>causalfoundry SDK Test</title>
<script type="text/javascript" src="https://cdn.causalfoundry.ai/sdk-1.2.3.js"> </script>
</head>
<body>
<div>
<button onclick="onClickBtn('btn-1')">Button 1</button>
</div>
<div>
<button onclick="onClickBtn('btn-2')">Button 2</button>
</div>
<div>
<a href="/test/page.html">Go to other page</a>
</div>
<div>
<a href="#bottom">Go to bottom</a>
</div>
<div style="border: 1px solid #f00;" id="scrolldiv">
</div>
<a name="bottom">
Bottom of the page
</a>
<script type="text/javascript">
console.warn("Window onload: ", window.CfLog);
const emsKey = "cfkeyR8NYLNTCyIYONaELgLn2tLl11aggvT1xa8MpmkMVh90DeKI3uaZf0ue3GMG";
const devKey = "cfkey4LcOGUNWfu7sN0RDkfXQ0GZE4qHEtg99iKQoOyTc9pLufT2QGa4kzwxtQUR";
const emsURL = "https://cf.mhems.in/api/v1";
const devURL = "https://api-dev.causalfoundry.ai/v1";
const cflog = new CfLog(
devKey,
{
baseUrl: devURL,
activateNudgeMechanism: true,
selfManagedNudges: false
}
);
const userId = "sdkTestNUserIdRN";
const user_properties = {
id: userId,
name: "John Doe",
organization_id: "cf",
organization_name: "Causal Foundry",
experience: "1 Year",
region_state: "Barcelona",
city: "Barcelona",
workplace: "causalfoundry",
profession: "SDK User",
zipcode: "08008",
country: CommonTypings.Country.Spain,
language: CommonTypings.Language.Spanish,
education_level: NavigationTypings.EducationalLevel.Bachelors,
account_type: NavigationTypings.UserAccountType.Basic,
referral_code: "ASDFGH"
}
cflog.identify(NavigationTypings.IdentityAction.Login, userId, user_properties, "123QWE");
</script>
<script type="text/javascript">
console.warn("Window onload: ", window.CfLog);
const searchProperties = {
page: 1,
query: 'Some Query Text HEREEE',
module: NavigationTypings.ModuleType.Core,
results_list: [{"id": "123", "type":NavigationTypings.SearchItemType.Facility}, {"id": "223", "type":NavigationTypings.SearchItemType.Other}], // Array as mentioned in above table
}
Navigation.logIngestEvent(NavigationTypings.NavigationTypes.Search, searchProperties)
console.log("Search event logged")
console.log(ECommerceTypings.ItemType["Drug"])
let itemDetail = {
id: "itemId112",
type: ECommerceTypings.ItemType["Drug"],
quantity: 1,
price: 1.45,
currency: CommonTypings.CurrencyCode.EUR,
stock_status: ECommerceTypings.StockStatus.InStock,
promo_id: "testPromoId",
}
const itemProps = {
action: ECommerceTypings.ItemAction.View,
item: itemDetail,
}
ECommerce.logItemEvent(itemProps, null)
</script>
</body>
</html>