1export async function startSession() {
2 GLANCE.Cobrowse.Visitor.startSession("GLANCE_KEYTYPE_RANDOM");
3}
4// If you forget to add functions called by events
5// to the global scope (e.g., `onclick="startSession();"`),
6// then those functions won't be in the global scope,
7// and the onclick will fail with Uncaught ReferenceError.
8window.startSession = startSession;
6});
7
8export async function setPageID(data: any) {
9 try {
10 const page = await notion.pages.update({
6});
7
8export async function setPageIcon(id: string, iconURL: string) {
9 try {
10 const page = await notion.pages.update({
6});
7
8export async function setDemoURL(id: string, url: string) {
9 try {
10 const page = await notion.pages.update({
6});
7
8export async function setCobrowse(id: string, cobrowse: boolean) {
9 try {
10 const page = await notion.pages.update({
6});
7
8export async function setAction(data: any) {
9 try {
10 const page = await notion.pages.create({
1export async function recordClick(action: string) {
2 // Create data to store
3 const clickData = {
86```typescript
87// Client-side event recording
88window.recordClick = function (action) {
89 fetch(`/api/setAction`, {
90 method: "POST",
116│ └── index.tsx # Frontend JavaScript entry point
117└── shared/ # Utilities used by both frontend and backend
118 └── utils/ # Shared helper functions
119```
120
129### Shared (`/shared`)
130
131Contains utilities and functions that work in both browser and server environments, ensuring code reusability across the application.
132
133## Framework and Technology Stack
189### Shared Utilities (`/shared`)
190
191Contains helper functions that work in both frontend and backend environments:
192
193```typescript
220
221```typescript
222export default async function (interval: Interval) {
223 const pages = await notion.databases.query({
224 database_id: Deno.env.get("GLANCE_DEMOS_DB_ID"),
280| Aspect | Controller | Utility |
281| ------------ | --------------------------------------------- | ------------------------------------------------- |
282| Purpose | Orchestrates business logic and workflows | Provides small, stateless helper functions |
283| Scope | High-level, involves services or side effects | Low-level, narrow focus (string, date operations) |
284| State | Works with application or user-specific data | Stateless - input in, output out |
6| Aspect | **Controller** | **Util** |
7| ----------------- | --------------------------------------------------- | --------------------------------------------------- |
8| **Purpose** | Orchestrates business logic and workflows | Provides small, stateless helper functions |
9| **Scope** | High-level, often involves services or side effects | Low-level, narrow in focus (e.g., string, date ops) |
10| **State** | Works with application or user-specific data | Stateless – input in, output out |
7### Task endpoints use /controllers to get and save data
8
9In order to keep the API easy to look and work with, the routes in /tasks handle routing but do not get data from or save data to Notion. The functions that connect to Notion live in the /controllers directory, and are _called_ from the endpoints in /tasks.
10
11### Naming convention for routes and controllers
25 Note that the export in the controller follows the same convention; it's also called `setDemoURL`.
26
271. Once the controller is imported, pass data to the exported function so that it can do its thing:
28
29 ```
31 ```
32
33 Note the function call is the exported function in the import object at the top of the route; i.e., `{ setDemoURL }`. The `setDemoURL.ts` controller exports it like this:
34
35 ```
36 // /controllers/setDemoURL.ts
37 export async function setDemoURL(data: any) {
38 try {
39 ...
Simple functional CSS library for Val Town
A helper function to build a file's email
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.