### ChatFeedbackSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ChatFeedbackSchema.md Demonstrates how to import, instantiate, and use the ChatFeedbackSchema. Includes examples for converting to and from JSON strings. ```typescript import type { ChatFeedbackSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies ChatFeedbackSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ChatFeedbackSchema console.log(exampleParsed) ``` -------------------------------- ### CDN Installation Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md Install Beacon.js using a CDN by including the script tag in your HTML. After loading, `window.athos.tracker` will be available for use. ```APIDOC ## CDN Installation ### Description Install Beacon.js using a CDN by including the script tag in your HTML. After loading, `window.athos.tracker` will be available for use. ### Script Tag ```html ``` ### Usage Example ```html ``` ``` -------------------------------- ### Autocomplete Render Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/AutocompleteApi.md Example of how to use the AutocompleteApi to call the autocompleteRender function. Ensure you have the necessary imports and configuration. ```typescript import { Configuration, AutocompleteApi, } from ''; import type { AutocompleteRenderRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new AutocompleteApi(); const body = { // string | Customer siteId found in the Athos Console or Athos Management Console siteId: siteId_example, // RenderSchema | Render payload renderSchema: ..., } satisfies AutocompleteRenderRequest; try { const data = await api.autocompleteRender(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### SearchRender Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/SearchApi.md This example demonstrates how to use the searchRender method from the SearchApi. It requires importing Configuration and SearchApi, and defining the SearchRenderRequest body with siteId and renderSchema. The method is called within a try-catch block to handle potential errors. ```typescript import { Configuration, SearchApi, } from ''; import type { SearchRenderRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new SearchApi(); const body = { // string | Customer siteId found in the Athos Console or Athos Management Console siteId: siteId_example, // RenderSchema | Render payload renderSchema: ..., } satisfies SearchRenderRequest; try { const data = await api.searchRender(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### NPM Installation Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md Install Beacon.js as an NPM package for use in JavaScript/TypeScript applications. This provides better integration with your build tooling. ```APIDOC ## NPM Installation ### Description Install Beacon.js as an NPM package for use in JavaScript/TypeScript applications. This provides better integration with your build tooling. ### Command ```bash npm install --save @athoscommerce/beacon ``` ``` -------------------------------- ### Install Beacon.js via NPM Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md Use this command to install the Beacon.js package if you are working within a JavaScript/TypeScript application. This method provides typed imports and better integration with build tools. ```bash npm install --save @athoscommerce/beacon ``` -------------------------------- ### RecommendationsClickthroughSchema Structure and Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RecommendationsClickthroughSchema.md This snippet shows the properties of the RecommendationsClickthroughSchema and provides a TypeScript example of its usage, including instantiation, JSON stringification, and parsing. ```APIDOC ## RecommendationsClickthroughSchema ### Description Represents the schema for clickthrough events related to recommendations. ### Properties - **context** ([Context](Context.md)) - Optional - The context of the recommendation event. - **data** ([RecommendationsClickthroughSchemaData](RecommendationsClickthroughSchemaData.md)) - Optional - The data associated with the recommendation clickthrough. ### Request Example ```typescript import type { RecommendationsClickthroughSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies RecommendationsClickthroughSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as RecommendationsClickthroughSchema console.log(exampleParsed) ``` ### Response Example (No specific response example provided for this schema, but it would typically mirror the request structure if used in an API response.) ``` -------------------------------- ### Example Context Object Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/Context.md Demonstrates how to create, log, and parse a context object. Ensure you replace null values with actual data. ```typescript import type { Context } from '' // TODO: Update the object below with actual values const example = { "initiator": null, "pageLoadId": null, "pageUrl": null, "sessionId": null, "timestamp": null, "userId": null, "attribution": null, "currency": null, "dev": null, "iP": null, "shopperId": null, "userAgent": null, } satisfies Context console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as Context console.log(exampleParsed) ``` -------------------------------- ### Quick Start: NPM Integration Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md Instantiate `Beacon` in your application and call methods on your instance. Replace `siteId` with your Athos or Searchspring site ID before deploying. ```typescript import { Beacon } from '@athoscommerce/beacon'; // Initialize Beacon with required siteId const beacon = new Beacon({ siteId: '[REPLACE WITH ACCOUNT SITEID]' }); // Optionally set currency for transaction tracking beacon.setCurrency({ code: 'USD' }); // Track an autocomplete render event beacon.events.autocomplete.render({ data: { // ... render data } }); // Track a product page view beacon.events.product.pageView({ data: { result: { uid: 'variant-123', sku: 'SKU-123', parentId: 'product-123' } } }); ``` -------------------------------- ### BundlesClickthroughSchemaData Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/BundlesClickthroughSchemaData.md Demonstrates how to instantiate, stringify, and parse the BundlesClickthroughSchemaData object. Ensure the correct type import is used. ```typescript import type { BundlesClickthroughSchemaData } from '' // TODO: Update the object below with actual values const example = { "tag": null, "responseId": null, "results": null, "banners": null, } satisfies BundlesClickthroughSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as BundlesClickthroughSchemaData console.log(exampleParsed) ``` -------------------------------- ### RecommendationsRenderSchema Structure and Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RecommendationsRenderSchema.md This snippet shows the structure of the RecommendationsRenderSchema and provides a TypeScript example of its usage, including instantiation, JSON stringification, and parsing. ```APIDOC ## RecommendationsRenderSchema ### Description Represents the schema for rendering recommendations. ### Properties - **context** (Context) - Description of the context object. - **data** (RecommendationsRenderSchemaData) - Description of the data object. ### Request Body Example ```json { "context": null, "data": null } ``` ### Request Example (TypeScript) ```typescript import type { RecommendationsRenderSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies RecommendationsRenderSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as RecommendationsRenderSchema console.log(exampleParsed) ``` ### Response Example (Note: Response structure is typically the same as the request body for this schema) ```json { "context": null, "data": null } ``` ``` -------------------------------- ### Quick Start: CDN Integration Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md Include the CDN script and call methods on the auto-created global `window.athos.tracker`. Replace `siteId` with your Athos or Searchspring site ID before deploying. ```html ``` -------------------------------- ### Product Object Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/Product.md Demonstrates how to define and use a Product object, including converting it to and from a JSON string. Ensure the 'Product' type is imported correctly. ```typescript import type { Product } from '' // TODO: Update the object below with actual values const example = { "parentId": null, "uid": null, "sku": null, "qty": null, "price": null, } satisfies Product console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as Product console.log(exampleParsed) ``` -------------------------------- ### ChatImpressionSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ChatImpressionSchema.md Demonstrates how to use the ChatImpressionSchema in TypeScript. Includes creating an example object, converting it to a JSON string, and parsing it back. ```typescript import type { ChatImpressionSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies ChatImpressionSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ChatImpressionSchema console.log(exampleParsed) ``` -------------------------------- ### Chat Impression Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ChatApi.md This example demonstrates how to use the `chatImpression` method from the Chat API SDK. Ensure you have the necessary imports and correctly define the request body, including the site ID and impression schema. ```typescript import { Configuration, ChatApi, } from ''; import type { ChatImpressionRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new ChatApi(); const body = { // string | Customer siteId found in the Athos Console or Athos Management Console siteId: siteId_example, // ChatImpressionSchema | Impression payload chatImpressionSchema: ... } satisfies ChatImpressionRequest; try { const data = await api.chatImpression(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### ChatAddtocartSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ChatAddtocartSchema.md Demonstrates how to instantiate, stringify, and parse the ChatAddtocartSchema in TypeScript. Ensure you import the schema type correctly. The example initializes context and data to null, which might need to be updated with actual values. ```typescript import type { ChatAddtocartSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies ChatAddtocartSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ChatAddtocartSchema console.log(exampleParsed) ``` -------------------------------- ### Install Beacon.js via CDN Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md Include this script tag in your HTML's to load the Beacon.js library from a CDN. After loading, the tracker will be available on `window.athos.tracker`. ```html ``` -------------------------------- ### RecommendationsImpressionSchema Structure and Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RecommendationsImpressionSchema.md This snippet shows the properties of the RecommendationsImpressionSchema and provides an example of how to use it in TypeScript, including instantiation, JSON stringification, and parsing. ```APIDOC ## RecommendationsImpressionSchema ### Description Represents the schema for a recommendation impression. ### Properties - **context** ([Context](Context.md)) - Type: Object - Description: The context of the impression. - **data** ([RecommendationsImpressionSchemaData](RecommendationsImpressionSchemaData.md)) - Type: Object - Description: The data associated with the recommendation impression. ### Request Example ```typescript import type { RecommendationsImpressionSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies RecommendationsImpressionSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as RecommendationsImpressionSchema console.log(exampleParsed) ``` ### Response Example ```json { "context": {}, "data": {} } ``` ``` -------------------------------- ### BundlesClickthroughSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/BundlesClickthroughSchema.md Demonstrates how to create, stringify, and parse an instance of BundlesClickthroughSchema using TypeScript. Ensure the schema type is imported correctly. ```typescript import type { BundlesClickthroughSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies BundlesClickthroughSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as BundlesClickthroughSchema console.log(exampleParsed) ``` -------------------------------- ### Autocomplete Redirect Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/AutocompleteApi.md Demonstrates how to use the AutocompleteApi to perform a redirect. Ensure you have the necessary imports and define the siteId and redirectSchema variables. ```typescript import { Configuration, AutocompleteApi, } from ''; import type { AutocompleteRedirectRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new AutocompleteApi(); const body = { // string | Customer siteId found in the Athos Console or Athos Management Console siteId: siteId_example, // RedirectSchema | Redirect payload redirectSchema: ... } satisfies AutocompleteRedirectRequest; try { const data = await api.autocompleteRedirect(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Category Impression Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/CategoryApi.md This example demonstrates how to use the `categoryImpression` method from the Category API. It requires importing `Configuration` and `CategoryApi`, and defining the `CategoryImpressionRequest` type. Ensure `siteId_example` and the `impressionSchema` are correctly defined before execution. ```typescript import { Configuration, CategoryApi, } from ''; import type { CategoryImpressionRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new CategoryApi(); const body = { // string | Customer siteId found in the Athos Console or Athos Management Console siteId: siteId_example, // ImpressionSchema | Impression payload impressionSchema: ... } satisfies CategoryImpressionRequest; try { const data = await api.categoryImpression(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Create and Log PersonalizationLogSchemaData Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/PersonalizationLogSchemaData.md Demonstrates how to create an instance of PersonalizationLogSchemaData, log it, convert it to a JSON string, and parse it back. Ensure the 'PersonalizationLogSchemaData' type is imported. ```typescript import type { PersonalizationLogSchemaData } from '' // TODO: Update the object below with actual values const example = { "message": null, "stack": null, "details": null, } satisfies PersonalizationLogSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as PersonalizationLogSchemaData console.log(exampleParsed) ``` -------------------------------- ### ShopperLoginSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ShopperLoginSchema.md Demonstrates how to create an instance of ShopperLoginSchema, convert it to a JSON string, and parse it back. Ensure to update the 'context' property with actual ShopperContext values. ```typescript import type { ShopperLoginSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, } satisfies ShopperLoginSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ShopperLoginSchema console.log(exampleParsed) ``` -------------------------------- ### Chat API chatFeedback Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ChatApi.md This example demonstrates how to use the chatFeedback method from the ChatApi class to send feedback. Ensure you have the necessary SDK and types imported. The body includes the siteId and the feedback payload. ```typescript import { Configuration, ChatApi, } from ''; import type { ChatFeedbackRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new ChatApi(); const body = { // string | Customer siteId found in the Athos Console or Athos Management Console siteId: siteId_example, // ChatFeedbackSchema | Feedback payload chatFeedbackSchema: ... } satisfies ChatFeedbackRequest; try { const data = await api.chatFeedback(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### ChatAddtocartSchemaData Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ChatAddtocartSchemaData.md Demonstrates how to use the ChatAddtocartSchemaData type in TypeScript. Includes creating an example object, logging it, converting it to a JSON string, and parsing it back. ```typescript import type { ChatAddtocartSchemaData } from '' // TODO: Update the object below with actual values const example = { "chatSessionId": null, "responseId": null, "results": null, } satisfies ChatAddtocartSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ChatAddtocartSchemaData console.log(exampleParsed) ``` -------------------------------- ### MessagingSchema Example in TypeScript Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/MessagingSchema.md Demonstrates how to import, instantiate, stringify, and parse the MessagingSchema in TypeScript. Ensure the MessagingSchema type is correctly imported. ```typescript import type { MessagingSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies MessagingSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as MessagingSchema console.log(exampleParsed) ``` -------------------------------- ### AutocompleteClickthrough Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/AutocompleteApi.md Demonstrates how to use the autocompleteClickthrough method to send clickthrough data. Ensure the Configuration and AutocompleteApi are imported, and a valid clickthroughSchema is provided. ```typescript import { Configuration, AutocompleteApi, } from ''; import type { AutocompleteClickthroughRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new AutocompleteApi(); const body = { // string | Customer siteId found in the Athos Console or Athos Management Console siteId: siteId_example, // ClickthroughSchema | Clickthrough payload clickthroughSchema: ... } satisfies AutocompleteClickthroughRequest; try { const data = await api.autocompleteClickthrough(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### BundlesRenderSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/BundlesRenderSchema.md Demonstrates how to create, stringify, and parse a BundlesRenderSchema object in TypeScript. Ensure the correct type import is used. ```typescript import type { BundlesRenderSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies BundlesRenderSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as BundlesRenderSchema console.log(exampleParsed) ``` -------------------------------- ### MessagingSchemaContext Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/MessagingSchemaContext.md Demonstrates how to create, stringify, and parse a MessagingSchemaContext object. Ensure the 'MessagingSchemaContext' type is imported. ```typescript import type { MessagingSchemaContext } from '' // TODO: Update the object below with actual values const example = { "userId": null, "timestamp": null, "dev": null, } satisfies MessagingSchemaContext console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as MessagingSchemaContext console.log(exampleParsed) ``` -------------------------------- ### RecommendationsClickthroughSchemaData Schema Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RecommendationsClickthroughSchemaData.md Schema definition and example usage for RecommendationsClickthroughSchemaData. ```APIDOC ## RecommendationsClickthroughSchemaData ### Description Event details for RecommendationsClickthroughSchemaData. ### Properties - **tag** (string) - Description not available - **responseId** (string) - Description not available - **results** (Array) - Description not available - **banners** (Array) - Description not available ### Request Example ```typescript import type { RecommendationsClickthroughSchemaData } from '' // TODO: Update the object below with actual values const example = { "tag": null, "responseId": null, "results": null, "banners": null, } satisfies RecommendationsClickthroughSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as RecommendationsClickthroughSchemaData console.log(exampleParsed) ``` ### Response #### Success Response (200) - **tag** (string) - Description not available - **responseId** (string) - Description not available - **results** (Array) - Description not available - **banners** (Array) - Description not available #### Response Example ```json { "tag": null, "responseId": null, "results": null, "banners": null } ``` ``` -------------------------------- ### Import and Use ResultProductType Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ResultProductType.md Demonstrates how to import the ResultProductType, create an example instance, convert it to a JSON string, and parse it back. Ensure the object is updated with actual values. ```typescript import type { ResultProductType } from '' // TODO: Update the object below with actual values const example = { } satisfies ResultProductType console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ResultProductType console.log(exampleParsed) ``` -------------------------------- ### Create, Stringify, and Parse LogSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/LogSchema.md Demonstrates how to instantiate a LogSchema object, convert it to a JSON string, and then parse it back into an object. Ensure the LogSchema type is imported before use. ```typescript import type { LogSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies LogSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as LogSchema console.log(exampleParsed) ``` -------------------------------- ### BundlesAddtocartSchemaData Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/BundlesAddtocartSchemaData.md Demonstrates how to create, stringify, and parse a BundlesAddtocartSchemaData object in TypeScript. Ensure the correct type import is used. ```typescript import type { BundlesAddtocartSchemaData } from '' // TODO: Update the object below with actual values const example = { "responseId": null, "tag": null, "results": null, } satisfies BundlesAddtocartSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as BundlesAddtocartSchemaData console.log(exampleParsed) ``` -------------------------------- ### TypeScript ProductPageviewSchemaData Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ProductPageviewSchemaData.md Demonstrates how to create, log, stringify, and parse a ProductPageviewSchemaData object in TypeScript. Ensure the 'result' property is updated with actual values. ```typescript import type { ProductPageviewSchemaData } from '' // TODO: Update the object below with actual values const example = { "result": null, } satisfies ProductPageviewSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ProductPageviewSchemaData console.log(exampleParsed) ``` -------------------------------- ### ChatClickthroughSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ChatClickthroughSchema.md Demonstrates how to create an instance of ChatClickthroughSchema, convert it to a JSON string, and parse it back. Ensure to update the object with actual values. ```typescript import type { ChatClickthroughSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies ChatClickthroughSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ChatClickthroughSchema console.log(exampleParsed) ``` -------------------------------- ### BundlesAddtocartSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/BundlesAddtocartSchema.md Demonstrates how to create an instance of BundlesAddtocartSchema, convert it to a JSON string, and then parse it back. This is useful for validating and serializing data conforming to the schema. ```typescript import type { BundlesAddtocartSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies BundlesAddtocartSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as BundlesAddtocartSchema console.log(exampleParsed) ``` -------------------------------- ### ChatFeedbackSchemaData Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ChatFeedbackSchemaData.md Demonstrates how to create, log, stringify, and parse ChatFeedbackSchemaData objects in TypeScript. Use this for initializing and handling chat feedback data. ```typescript import type { ChatFeedbackSchemaData } from '' // TODO: Update the object below with actual values const example = { "chatSessionId": null, "feedback": null, } satisfies ChatFeedbackSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ChatFeedbackSchemaData console.log(exampleParsed) ``` -------------------------------- ### PersonalizationLogSchema Example in TypeScript Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/PersonalizationLogSchema.md Demonstrates how to create an instance of PersonalizationLogSchema, convert it to a JSON string, and parse it back. Ensure the 'PersonalizationLogSchema' type is imported correctly. ```typescript import type { PersonalizationLogSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies PersonalizationLogSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as PersonalizationLogSchema console.log(exampleParsed) ``` -------------------------------- ### ChatClickthroughSchemaData Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ChatClickthroughSchemaData.md Demonstrates how to create, stringify, and parse an object conforming to the ChatClickthroughSchemaData type in TypeScript. Ensure you have the correct type import. ```typescript import type { ChatClickthroughSchemaData } from '' // TODO: Update the object below with actual values const example = { "chatSessionId": null, "responseId": null, "results": null, } satisfies ChatClickthroughSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ChatClickthroughSchemaData console.log(exampleParsed) ``` -------------------------------- ### Instantiate and Use ClickthroughBannersInner Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ClickthroughBannersInner.md Demonstrates how to import, instantiate, log, stringify, and parse the ClickthroughBannersInner type. Ensure the import path is correct for your project setup. ```typescript import type { ClickthroughBannersInner } from '' // TODO: Update the object below with actual values const example = { "uid": null, } satisfies ClickthroughBannersInner console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ClickthroughBannersInner console.log(exampleParsed) ``` -------------------------------- ### ShopperContext Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ShopperContext.md Demonstrates how to instantiate a ShopperContext object with null values, convert it to a JSON string, and then parse it back. This is useful for understanding the structure and basic manipulation of shopper event data. ```typescript import type { ShopperContext } from '' // TODO: Update the object below with actual values const example = { "initiator": null, "pageLoadId": null, "pageUrl": null, "sessionId": null, "shopperId": null, "timestamp": null, "userId": null, "attribution": null, "currency": null, "dev": null, "iP": null, "userAgent": null, } satisfies ShopperContext console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ShopperContext console.log(exampleParsed) ``` -------------------------------- ### BundlesImpressionSchema Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/BundlesImpressionSchema.md Demonstrates how to import, initialize, stringify, and parse a BundlesImpressionSchema object in TypeScript. Ensure the object is updated with actual values before use. ```typescript import type { BundlesImpressionSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies BundlesImpressionSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as BundlesImpressionSchema console.log(exampleParsed) ``` -------------------------------- ### RenderSchema Example in TypeScript Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RenderSchema.md Demonstrates how to define and use the RenderSchema type in TypeScript, including converting an instance to a JSON string and parsing it back. Ensure the RenderSchema type is correctly imported. ```typescript import type { RenderSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies RenderSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as RenderSchema console.log(exampleParsed) ``` -------------------------------- ### BundlesImpressionSchemaData Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/BundlesImpressionSchemaData.md Demonstrates how to create an instance of BundlesImpressionSchemaData, convert it to a JSON string, and parse it back. Use this pattern to construct and manage event data. ```typescript import type { BundlesImpressionSchemaData } from '' // TODO: Update the object below with actual values const example = { "tag": null, "responseId": null, "results": null, "banners": null, } satisfies BundlesImpressionSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as BundlesImpressionSchemaData console.log(exampleParsed) ``` -------------------------------- ### Track Search Render Event via CDN Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md Once the Beacon.js CDN script is loaded and initialized, you can use `window.athos.tracker` to send events. This example shows how to track a search render event. ```html ``` -------------------------------- ### NPM Initialization Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md Initialize Beacon using the `Beacon` constructor when integrating via NPM. Configuration includes required global settings and optional API behavior settings. ```APIDOC ## NPM Initialization ### Description Use the `Beacon` constructor when integrating through the NPM package. Configuration includes required global settings and optional API behavior settings. ### Beacon Globals The first parameter to the `Beacon` constructor contains required global configuration that applies to all tracking events. ```typescript import { Beacon } from '@athoscommerce/beacon'; const beacon = new Beacon({ siteId: 'abc123' }); ``` | Option | Type | Description | Required | |--------|------|-------------|----------| | `siteId` | `string` | Your Athos site ID | ✔️ | ### Beacon Config The second parameter to the `Beacon` constructor provides _optional_ configuration for API behavior and request handling. ```typescript const beacon = new Beacon( { siteId: 'abc123' }, { mode: 'development', initiator: 'my-app/1.0.0', requesters: { beacon: { origin: 'https://custom-beacon.example.com/beacon/v2', headers: { 'Authorization': 'Bearer token' } }, personalization: { origin: 'https://custom-personalization.example.com', headers: { 'X-Custom-Header': 'value' } } }, apis: { fetch: customFetchImplementation }, href: 'https://example.com/page', userAgent: 'Custom User Agent' } ); ``` | Option | Type | Description | Default | |--------|------|-------------|---------| | `mode` | `'production' | 'development'` | Application mode. In development mode, errors are logged to console | `'production'` | | `initiator` | `string` | Identifier for the beacon instance | `{athos|searchspring}/beaconjs/{version}` | | `apis.fetch` | `FetchAPI` | Custom fetch implementation | Global `fetch` (if available) | | `requesters.beacon.origin` | `string` | Custom beacon API endpoint | Athos: `https://analytics.athoscommerce.net/beacon/v2`, Searchspring: `https://analytics.searchspring.net/beacon/v2` | | `requesters.beacon.headers` | `HTTPHeaders` | Custom headers for beacon API requests | `{ 'Content-Type': 'text/plain' }` | | `requesters.personalization.origin` | `string` | Custom personalization preflight origin (the SDK appends `/v1/preflight`) | `https://{siteId}.a.{athoscommerce.net|searchspring.io}` | | `requesters.personalization.headers` | `HTTPHeaders` | Custom headers for personalization requests | | | `href` | `string` | Override page URL for tracking | `window.location.href` | | `userAgent` | `string` | Override user agent string | `navigator.userAgent` | ``` -------------------------------- ### ClickthroughSchema Structure and Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ClickthroughSchema.md This snippet shows the properties of the ClickthroughSchema and provides a TypeScript example of its usage, including instantiation, JSON stringification, and parsing. ```APIDOC ## ClickthroughSchema ### Description Represents the schema for clickthrough events, containing context and data. ### Properties - **context** (Context) - Description of the context object. - **data** (ClickthroughSchemaData) - Description of the data object. ### Request Body Example ```json { "context": null, "data": null } ``` ### Response Example ```json { "context": null, "data": null } ``` ### Usage Example (TypeScript) ```typescript import type { ClickthroughSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies ClickthroughSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ClickthroughSchema console.log(exampleParsed) ``` ``` -------------------------------- ### Track product page views with ProductApi Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ProductApi.md Demonstrates how to initialize the ProductApi and call the productPageview method to track a shopper's navigation to a product detail page. ```ts import { Configuration, ProductApi, } from ''; import type { ProductPageviewRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const api = new ProductApi(); const body = { // string | Customer siteId found in the Athos Console or Athos Management Console siteId: siteId_example, // ProductPageviewSchema | Product page view payload productPageviewSchema: ..., } satisfies ProductPageviewRequest; try { const data = await api.productPageview(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### TypeScript AddtocartSchemaData Example Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/AddtocartSchemaData.md Demonstrates how to define and use the AddtocartSchemaData in TypeScript. Includes examples for JSON stringification and parsing. Ensure the object is updated with actual values before use. ```typescript import type { AddtocartSchemaData } from '' // TODO: Update the object below with actual values const example = { "responseId": null, "results": null, } satisfies AddtocartSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as AddtocartSchemaData console.log(exampleParsed) ``` -------------------------------- ### Instantiate and Serialize RecommendationsAddtocartSchema Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RecommendationsAddtocartSchema.md Demonstrates how to create an instance of the schema, convert it to a JSON string, and parse it back into an object. ```typescript import type { RecommendationsAddtocartSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies RecommendationsAddtocartSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as RecommendationsAddtocartSchema console.log(exampleParsed) ``` -------------------------------- ### Create and Use RecommendationsClickthroughSchema Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RecommendationsClickthroughSchema.md Demonstrates how to create an instance of RecommendationsClickthroughSchema, convert it to a JSON string, and parse it back. Ensure you import the type correctly and update placeholder values. ```typescript import type { RecommendationsClickthroughSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies RecommendationsClickthroughSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as RecommendationsClickthroughSchema console.log(exampleParsed) ``` -------------------------------- ### Create, Stringify, and Parse RecommendationsRenderSchema Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RecommendationsRenderSchema.md Demonstrates how to create an instance of RecommendationsRenderSchema, convert it to a JSON string, and then parse it back into an object. Ensure the object is updated with actual values before use. ```typescript import type { RecommendationsRenderSchema } from '' // TODO: Update the object below with actual values const example = { "context": null, "data": null, } satisfies RecommendationsRenderSchema console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as RecommendationsRenderSchema console.log(exampleParsed) ``` -------------------------------- ### ValidationErrorWithDataField Model Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ValidationErrorWithDataField.md Definition and usage example for the ValidationErrorWithDataField model. ```APIDOC ## Model: ValidationErrorWithDataField ### Description Represents a validation error response that includes a specific data field. ### Properties - **success** (boolean) - Indicates if the operation was successful. - **error** (string) - The error message description. - **messages** (Array) - A list of validation error messages. - **data** (string) - Additional data associated with the validation error. ### Usage Example ```typescript const example = { "success": false, "error": "Validation failed", "messages": ["Field is required"], "data": "{\"field\": \"username\"}" } satisfies ValidationErrorWithDataField; ``` ``` -------------------------------- ### Initialize Beacon with Full Configuration (NPM) Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md Configure Beacon with optional parameters for development mode, custom API endpoints, headers, fetch implementations, and more. This provides fine-grained control over the tracker's behavior. ```typescript const beacon = new Beacon( { siteId: 'abc123' }, { mode: 'development', initiator: 'my-app/1.0.0', requesters: { beacon: { origin: 'https://custom-beacon.example.com/beacon/v2', headers: { 'Authorization': 'Bearer token' } }, personalization: { origin: 'https://custom-personalization.example.com', headers: { 'X-Custom-Header': 'value' } } }, apis: { fetch: customFetchImplementation }, href: 'https://example.com/page', userAgent: 'Custom User Agent' } ); ``` -------------------------------- ### ResultProductType Model Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/ResultProductType.md Definition and usage example for the ResultProductType model. ```APIDOC ## ResultProductType ### Description Defines the type of item tracked within the beacon.js project. ### Request Example ```typescript import type { ResultProductType } from '' const example = { } satisfies ResultProductType console.log(example) ``` ``` -------------------------------- ### RenderSchemaData Model Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RenderSchemaData.md Definition and usage example for the RenderSchemaData model. ```APIDOC ## RenderSchemaData ### Description Represents event details within the beacon.js project. ### Properties - **responseId** (string) - The unique identifier for the response. ``` -------------------------------- ### Instantiate and Serialize RecommendationsImpressionSchemaData Source: https://github.com/athoscommerce/beacon.js/blob/main/src/client/docs/RecommendationsImpressionSchemaData.md Demonstrates how to define an object matching the schema, convert it to a JSON string, and parse it back into the typed interface. ```typescript import type { RecommendationsImpressionSchemaData } from '' // TODO: Update the object below with actual values const example = { "tag": null, "responseId": null, "results": null, "banners": null, } satisfies RecommendationsImpressionSchemaData console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as RecommendationsImpressionSchemaData console.log(exampleParsed) ``` -------------------------------- ### Initialize Beacon with Site ID (NPM) Source: https://github.com/athoscommerce/beacon.js/blob/main/README.md When using the NPM package, instantiate the `Beacon` class with your site ID as the first argument. This is a required global configuration. ```typescript import { Beacon } from '@athoscommerce/beacon'; const beacon = new Beacon({ siteId: 'abc123' }); ```