Added conversions for public workflows and apps when first utilized

This commit is contained in:
frikky
2022-06-21 02:34:25 +02:00
parent daf200149f
commit 34e6546184
3 changed files with 91 additions and 9 deletions
+1 -5
View File
@@ -208,18 +208,14 @@ const AppGrid = props => {
})
}
console.log(searchClient)
//const searchClient = algoliasearch("L55H18ZINA", "a19be455e7e75ee8f20a93d26b9fc6d6")
console.log(searchClient)
aa('init', {
appId: searchClient.appId,
apiKey: searchClient.transporter.queryParameters["x-algolia-api-key"]
})
console.log("DATA: ", data)
const timestamp = new Date().getTime()
console.log("Timestamp: ", timestamp)
aa('sendEvents', [
{
eventType: 'click',
+55 -2
View File
@@ -26,17 +26,16 @@ import {
import {Close as CloseIcon, Folder as FolderIcon, Polymer as PolymerIcon, LibraryBooks as LibraryBooksIcon} from '@material-ui/icons'
import algoliasearch from 'algoliasearch/lite';
import aa from 'search-insights'
import { InstantSearch, Configure, connectSearchBox, connectHits, Index } from 'react-instantsearch-dom';
//import { InstantSearch, SearchBox, Hits, connectSearchBox, connectHits, Index } from 'react-instantsearch-dom';
// https://www.algolia.com/doc/api-reference/widgets/search-box/react/
//const searchClient = algoliasearch("WIC466KTV8", "fff61b6ae3802ec2b47fed9ab50b532e")
const chipStyle = {
backgroundColor: "#3d3f43", height: 30, marginRight: 5, paddingLeft: 5, paddingRight: 5, height: 28, cursor: "pointer", borderColor: "#3d3f43", color: "white",
}
const searchClient = algoliasearch("JNSS5CFDZZ", "db08e40265e2941b9a7d8f644b6e5240")
//const searchClient = algoliasearch("L55H18ZINA", "a19be455e7e75ee8f20a93d26b9fc6d6")
const SearchField = props => {
const { serverside, } = props
const theme = useTheme();
@@ -213,6 +212,24 @@ const SearchField = props => {
//console.log("CLICK")
setSearchOpen(true)
aa('init', {
appId: searchClient.appId,
apiKey: searchClient.transporter.queryParameters["x-algolia-api-key"]
})
const timestamp = new Date().getTime()
aa('sendEvents', [
{
eventType: 'click',
eventName: 'Product Clicked',
index: 'workflows',
objectIDs: [hit.objectID],
timestamp: timestamp,
queryID: hit.__queryID,
positions: [hit.__position],
}
])
if (!isCloud) {
event.preventDefault()
window.open(parsedUrl, '_blank');
@@ -386,6 +403,24 @@ const SearchField = props => {
console.log("CLICK")
setSearchOpen(true)
aa('init', {
appId: searchClient.appId,
apiKey: searchClient.transporter.queryParameters["x-algolia-api-key"]
})
const timestamp = new Date().getTime()
aa('sendEvents', [
{
eventType: 'click',
eventName: 'Product Clicked',
index: 'appsearch',
objectIDs: [hit.objectID],
timestamp: timestamp,
queryID: hit.__queryID,
positions: [hit.__position],
}
])
if (!isCloud) {
event.preventDefault()
window.open(parsedUrl, '_blank');
@@ -518,6 +553,24 @@ const SearchField = props => {
return (
<Link key={hit.objectID} to={parsedUrl} style={{textDecoration: "none", color: "white",}} onClick={(event) => {
aa('init', {
appId: searchClient.appId,
apiKey: searchClient.transporter.queryParameters["x-algolia-api-key"]
})
const timestamp = new Date().getTime()
aa('sendEvents', [
{
eventType: 'click',
eventName: 'Product Clicked',
index: 'documentation',
objectIDs: [hit.objectID],
timestamp: timestamp,
queryID: hit.__queryID,
positions: [hit.__position],
}
])
console.log("CLICK")
setSearchOpen(true)
}}>
+35 -2
View File
@@ -13,6 +13,7 @@ import ReactMarkdown from "react-markdown";
import { useAlert } from "react-alert";
import theme from '../theme';
import { isMobile } from "react-device-detect"
import aa from 'search-insights'
import {
Zoom,
@@ -10746,7 +10747,7 @@ const AngularWorkflow = (defaultprops) => {
</Tooltip>
)}
{/*userdata.avatar === creatorProfile.github_avatar ? null :*/}
<Tooltip color="primary" title="Save (ctrl+s)" placement="top">
<Tooltip color="primary" title="Save Workflow" placement="top">
<span>
<Button
disabled={savingState !== 0}
@@ -10759,7 +10760,39 @@ const AngularWorkflow = (defaultprops) => {
variant={
lastSaved && !workflow.public ? "outlined" : "contained"
}
onClick={() => saveWorkflow()}
onClick={() => {
saveWorkflow()
if (workflow.public === true) {
console.log("Public!")
const tmpurl = new URL(window.location.href)
const searchParams = tmpurl.searchParams
const queryID = searchParams.get('queryID')
if (queryID !== undefined && queryID !== null) {
aa('init', {
appId: "JNSS5CFDZZ",
apiKey: "db08e40265e2941b9a7d8f644b6e5240",
})
const timestamp = new Date().getTime()
aa('sendEvents', [
{
eventType: 'conversion',
eventName: 'Public Workflow Saved',
index: 'workflows',
objectIDs: [workflow.id],
timestamp: timestamp,
queryID: queryID,
userToken: userdata === undefined || userdata === null || userdata.id === undefined ? "" : userdata.id,
}
])
} else {
console.log("No query to handle")
}
}
}}
>
{savingState === 2 ? (
<CircularProgress style={{ height: 35, width: 35 }} />