Skip to content

Commit

Permalink
feature: default analytics to on for public page
Browse files Browse the repository at this point in the history
  • Loading branch information
skeptrunedev authored and fedhacks committed Dec 12, 2024
1 parent 2cbac8f commit 11ff07b
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 40 deletions.
4 changes: 4 additions & 0 deletions clients/ts-sdk/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -12059,6 +12059,10 @@
"type": "string",
"nullable": true
},
"headingPrefix": {
"type": "string",
"nullable": true
},
"heroPattern": {
"allOf": [
{
Expand Down
2 changes: 1 addition & 1 deletion clients/ts-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"files": [
"dist"
],
"version": "0.0.41",
"version": "0.0.43",
"license": "MIT",
"scripts": {
"lint": "eslint 'src/**/*.ts'",
Expand Down
1 change: 1 addition & 0 deletions clients/ts-sdk/src/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1978,6 +1978,7 @@ export type PublicPageParameters = {
defaultSearchMode?: (string) | null;
defaultSearchQueries?: Array<(string)> | null;
forBrandName?: (string) | null;
headingPrefix?: (string) | null;
heroPattern?: ((HeroPattern) | null);
navLogoImgSrcUrl?: (string) | null;
openGraphMetadata?: ((OpenGraphMetadata) | null);
Expand Down
1 change: 1 addition & 0 deletions frontends/dashboard/src/hooks/usePublicPageSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export const { use: usePublicPage, provider: PublicPageProvider } =
api_key: response.api_key,
extra_params: {
...extraParams,
analytics: true,
},
},
},
Expand Down
63 changes: 45 additions & 18 deletions frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,52 @@ const PublicPageControls = () => {

<div class="mt-4 flex items-start gap-8">
<div class="flex grow flex-col gap-2">
<div class="grow">
<div class="flex items-center gap-1">
<label class="block" for="">
Header Brand Name
</label>
<Tooltip
tooltipText="Brand name which will be displayed in the navbar on the page"
body={<FaRegularCircleQuestion class="h-3 w-3 text-black" />}
/>
<div class="flex grow items-center gap-2">
<div class="grow">
<div class="flex items-center gap-1">
<label class="block" for="">
Heading Prefix
</label>
<Tooltip
tooltipText="Brand name which will be displayed in the navbar on the page"
body={
<FaRegularCircleQuestion class="h-3 w-3 text-black" />
}
/>
</div>
<div class="flex grow items-center gap-2">
<input
placeholder="Demo For"
value={extraParams.headingPrefix || ""}
onInput={(e) => {
setExtraParams("headingPrefix", e.currentTarget.value);
}}
class="block w-full grow rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6"
/>
</div>
</div>
<div class="flex grow items-center gap-2">
<input
placeholder="Devflow, Inc."
value={extraParams.forBrandName || ""}
onInput={(e) => {
setExtraParams("forBrandName", e.currentTarget.value);
}}
class="block w-full grow rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6"
/>
<div class="grow">
<div class="flex items-center gap-1">
<label class="block" for="">
Header Brand Name
</label>
<Tooltip
tooltipText="Brand name which will be displayed in the navbar on the page"
body={
<FaRegularCircleQuestion class="h-3 w-3 text-black" />
}
/>
</div>
<div class="flex grow items-center gap-2">
<input
placeholder="Devflow, Inc."
value={extraParams.forBrandName || ""}
onInput={(e) => {
setExtraParams("forBrandName", e.currentTarget.value);
}}
class="block w-full grow rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6"
/>
</div>
</div>
</div>
<div class="grow">
Expand Down
3 changes: 3 additions & 0 deletions server/src/data/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3111,6 +3111,9 @@ impl DatasetConfigurationDTO {
search_options: page_parameters_self
.search_options
.or(page_parameters_curr.search_options),
heading_prefix: page_parameters_self
.heading_prefix
.or(page_parameters_curr.heading_prefix),
for_brand_name: page_parameters_self
.for_brand_name
.or(page_parameters_curr.for_brand_name),
Expand Down
2 changes: 2 additions & 0 deletions server/src/handlers/page_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ pub struct PublicPageParameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub search_options: Option<PublicPageSearchOptions>,
#[serde(skip_serializing_if = "Option::is_none")]
pub heading_prefix: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub for_brand_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub brand_name: Option<String>,
Expand Down
7 changes: 4 additions & 3 deletions server/src/public/navbar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<nav class="w-screen bg-white border-b">
<nav class="bg-white border-b">
<div
class="max-w-screen-2xl mx-auto w-full p-2 flex items-center justify-center flex-col gap-2 sm:justify-between sm:!flex-row"
>
Expand All @@ -8,9 +8,10 @@
src="{{params.navLogoImgSrcUrl|safe if (params.navLogoImgSrcUrl is defined and params.navLogoImgSrcUrl) else 'https://cdn.trieve.ai/trieve-logo.png'|safe}}"
/>
</a>
<div>
<div class="text-center">
<p class="font-medium text-3xl">
Demo For
{{params.headingPrefix|safe if (params.headingPrefix is defined and
params.headingPrefix) else 'Demo For'|safe}}
<span class="brand-name">
{{params.forBrandName|safe if (params.forBrandName is defined and
params.forBrandName) else 'Prospect'|safe}}
Expand Down
23 changes: 11 additions & 12 deletions server/src/public/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
flex-direction: column;
padding-top: 48px;
gap: 40px;
width: 100vw;
}

.corner-logo {
Expand All @@ -160,9 +159,9 @@

.made-with-love {
font-family: "Maven Pro", sans-serif;
position: fixed;
bottom: 0.5rem;
right: 0.5rem;
margin-right: 0.5rem;
margin-bottom: 0.5rem;
margin-left: auto;
}

.heart {
Expand Down Expand Up @@ -258,7 +257,7 @@
>Back To Dashboard</a
>
{% endif %}
<p class="text-xs made-with-love">
<p class="text-xs made-with-love text-end">
Made with <span class="heart">&hearts;</span> in San Francisco
</p>
</body>
Expand All @@ -279,11 +278,9 @@
tabContainer = document.getElementById("tab-container");
await new Promise((resolve) => setTimeout(resolve, 10));
}
openTrieveModalElement.style.width = tabContainer.offsetWidth / 2 + "px";
console.log(
"set openTrieveModalElement width to",
tabContainer.width + "px"
);
if (window.innerWidth > 768) {
openTrieveModalElement.style.width = tabContainer.offsetWidth / 2 + "px";
}

let brandNameElement = document.querySelector(".brand-name");
while (!brandNameElement) {
Expand Down Expand Up @@ -320,8 +317,10 @@
canvas.style.position = "absolute";
canvas.style.left = "0";
canvas.style.top = "0";
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.width =
document.documentElement.clientWidth || document.body.clientWidth;
canvas.height =
document.documentElement.clientHeight || document.body.clientHeight;
canvas.style.zIndex = "-1";

const rc = rough.canvas(canvas);
Expand Down
6 changes: 4 additions & 2 deletions server/src/public/search-component-code.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<pre class="-my-4"> <code class="language-javascript">import { TrieveModalSearch } from 'trieve-search-component';
<pre class="-my-4">
<code class="language-javascript">
import { TrieveModalSearch } from 'trieve-search-component';
import 'trieve-search-component/styles';

const App = () => {
Expand Down Expand Up @@ -73,7 +75,7 @@
{% if params.debounceMs -%}
debounceMs={{ params.debounceMs }}
{% endif -%}
/&gt;
/&gt;
);
} </code>
</pre>
12 changes: 8 additions & 4 deletions server/static/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,6 @@ video {
width: 100%;
}

.w-screen {
width: 100vw;
}

.max-w-2xl {
max-width: 42rem;
}
Expand Down Expand Up @@ -661,6 +657,14 @@ video {
padding-left: 0.125rem;
}

.text-center {
text-align: center;
}

.text-end {
text-align: end;
}

.text-3xl {
font-size: 1.875rem;
line-height: 2.25rem;
Expand Down

0 comments on commit 11ff07b

Please sign in to comment.