### TrackVia API Authentication and Authorization Setup Source: https://trackvia.com/llms-developer-full.txt Guides users on setting up authentication credentials and managing access permissions for the TrackVia API within Postman. This includes defining variables for API keys and access tokens, and understanding how API user roles affect resource accessibility. ```APIDOC TrackVia API Authentication Configuration: 1. **API User, API Key, and Auth Token**: Ensure an API user is created, and an API Key and valid Auth Token are generated before testing. 2. **Postman Variables**: Recommended to add URL, API Key, and Auth Token as variables in Postman to avoid re-authentication. * **UserKey Variable**: - Add API Key as a variable. - In Postman, select an API call from the TrackVia collection. - Navigate to the "Params" tab. - Click the `{{UserKey}}` variable to add your API Key information. * **AccessToken Variable**: - Add Auth Token as a variable. - Navigate to the "Authorization" tab. - In the "Type" dropdown, select "Bearer Token". - Click the `{{AccessToken}}` variable to add your auth token details. TrackVia Resource Access: 1. **API User Roles**: Access to TrackVia resources (e.g., Views) is determined by the API User's assigned role. * Super Admin roles grant access to all resources. * For specific resource access, create a Role, assign the API User to it, and grant access to desired resources. 2. **Troubleshooting 401 Errors (e.g., "DENIED!!! - Record: XXXX either does not exist or you do not have access to it.")**: * **Cause a)** Incorrect Record ID entered for a "Get Record" call. * **Cause b)** The API User associated with the Auth Token lacks permission for the specified View. * **Resolution**: Verify the Record ID or ensure the View is assigned to the API User's role. 3. **Integration with Other Systems**: * Authentication requirements may differ. Other systems might require API Key entry under the "Headers" tab instead of "Params". * Always refer to the specific API documentation for external systems regarding their authentication methods and API call definitions. ``` -------------------------------- ### JavaScript Microservice Handler Example Source: https://trackvia.com/llms-developer-full.txt An example of a JavaScript microservice handler function. It demonstrates how to structure the handler to receive events and context, log messages, perform asynchronous operations, and return success or error responses. ```javascript export const handler = async (event, context) => { // event object contains any data passed into the microservice // context object contains information about the invocation and execution environment try { console.log('Hello, World'); // use the "await" keyword to wait for data returned from asynchronous functions const data = await someAsynchronousFunction(); // a successful response object // ends the microservice return { statusCode: 200, message: 'success' }; } catch (error) { // an error response object // ends the microservice return { statusCode: 500, message: error.message }; } } ``` -------------------------------- ### Algolia Client Initialization and Autocomplete Setup Source: https://trackvia.com/ Initializes the Algolia client using application ID and search API key, then configures autocomplete.js sources with custom hit retrieval and templating. It handles dynamic suggestion templates and highlights search terms. ```javascript window.addEventListener('load', function () { /* Initialize Algolia client */ var client = algoliasearch( algolia.application_id, algolia.search_api_key ); /* Algolia hits source method. * This method defines a custom source to use with autocomplete.js. * @param object $index Algolia index object. * @param object $params Options object to use in search. */ var algoliaHitsSource = function( index, params ) { return function( query, callback ) { index .search( query, params ) .then( function( response ) { callback( response.hits, response ); }) .catch( function( error ) { callback( [], error ); }); } } /* Setup autocomplete.js sources */ var sources = []; algolia.autocomplete.sources.forEach( function( config, i ) { var suggestion_template = wp.template( config[ 'tmpl_suggestion' ] ); sources.push({ source: algoliaHitsSource( client.initIndex( config[ 'index_name' ] ), { hitsPerPage: config[ 'max_suggestions' ], attributesToSnippet: [ 'content:10' ], highlightPreTag: '__ais-highlight__', highlightPostTag: '__/ais-highlight__' }), debounce: config['debounce'], templates: { header: function () { return wp.template( 'autocomplete-header' )( { label: _.escape( config[ 'label' ] ) } ); }, suggestion: function ( hit ) { if ( hit.escaped === true ) { return suggestion_template( hit ); } hit.escaped = true; for ( var key in hit._highlightResult ) { /* We do not deal with arrays. */ if ( typeof hit._highlightResult[ key ].value !== 'string' ) { continue; } hit._highlightResult[ key ].value = _.escape( hit._highlightResult[ key ].value ); hit._highlightResult[ key ].value = hit._highlightResult[ key ].value.replace( /__ais-highlight__/g, '' ).replace( /__\/ais-highlight__/g, '' ); } for ( var key in hit._snippetResult ) { /* We do not deal with arrays. */ if ( typeof hit._snippetResult[ key ].value !== 'string' ) { continue; } hit._snippetResult[ key ].value = _.escape( hit._snippetResult[ key ].value ); hit._snippetResult[ key ].value = hit._snippetResult[ key ].value.replace( /__ais-highlight__/g, '' ).replace( /__\/ais-highlight__/g, '' ); } return suggestion_template( hit ); } } }); }); /* Setup dropdown menus */ document.querySelectorAll( algolia.autocomplete.input_selector ).forEach( function( element ) { var config = { debug: algolia.debug, hint: false, openOnFocus: true, appendTo: 'body', templates: { empty: wp.template( 'autocomplete-empty' ) } }; if ( algolia.powered_by_enabled ) { config.templates.footer = wp.template( 'autocomplete-footer' ); } /* Instantiate autocomplete.js */ var autocomplete = algoliaAutocomplete( element, config, sources ) .on( 'autocomplete:selected', function ( e, suggestion ) { /* Redirect the user when we detect a suggestion selection. */ window.location.href = suggestion.permalink ?? suggestion.posts_url; // Users use the `posts_url` property instead of `permalink`. }); /* Force the dropdown to be re-drawn on scroll to handle fixed containers. */ window.addEventListener( 'scroll', function() { if ( autocomplete.autocomplete.getWrapper().style.display === "block" ) { autocomplete.autocomplete.close(); autocomplete.autocomplete.open(); } }); }); var algoliaPoweredLink = document.querySelector( '.algolia-powered-by-link' ); if ( algoliaPoweredLink ) { algoliaPoweredLink.addEventListener( 'click', function( e ) { e.preventDefault(); window.location = "https://www.algolia.com/?utm_source=WordPress&utm_medium=extension&utm_content=" + window.location.hostname + "&utm_campaign=poweredby"; }); } }); ``` -------------------------------- ### Swagger Authorization Setup Source: https://trackvia.com/llms-developer-full.txt Details the process of authorizing API requests in Swagger using API Keys and Auth Tokens. Proper authorization is required to interact with API endpoints and execute actions. ```APIDOC Swagger Authorization: Prerequisites: - Create an API user. - Generate an API Key. - Obtain a valid Auth Token. Steps: 1. Click the 'Authorize' button at the top of the Swagger page. 2. Navigate to your TrackVia application, click the person icon (top right), select 'My Account', and go to the 'API Access' section. 3. Copy your API Key and Auth Token. 4. Paste the API Key and Auth Token into the respective fields in the Swagger authorization modal. 5. Click 'Authorize' next to each field. Verification: - A locked icon next to the 'Authorize' button indicates successful authorization. - If not authorized, fields for actions (like View ID) will be grayed out. Usage: Once authorized, click 'Try it out' for an action, enter parameters, and click 'Execute' to get results. Error Condition: Failure to authorize or using invalid credentials prevents API action execution and may result in locked input fields. ``` -------------------------------- ### Postman Variable Configuration for TrackVia Host Source: https://trackvia.com/llms-developer-full.txt Instructions and examples for configuring the `{{TrackViaHost}}` variable in Postman to correctly point to the TrackVia API environment (Production, GOV, HIPAA, or custom subdomain). This is crucial for successful API calls. ```APIDOC Postman Variable Setup: To ensure correct API calls, configure the `{{TrackViaHost}}` variable in Postman. 1. Import the TrackVia Postman collection. 2. Select an API call. 3. Locate the `{{TrackViaHost}}` variable placeholder. 4. Click on it and select 'Add new variable'. 5. Enter the appropriate URL for your TrackVia environment: * Production: `go.trackvia.com` * GOV Environment: `gov.trackvia.com` (example) * HIPAA Environment: `hipaa.trackvia.com` * Custom Subdomain: Your specific subdomain URL. Incorrect `{{TrackViaHost}}` configuration will result in a 'Could not send request' error. ``` -------------------------------- ### TrackVia Initialization Script Source: https://go.trackvia.com/ Initializes TrackVia by loading CSS and the main JavaScript bundle. It dynamically constructs CDN paths based on environment variables or local storage, ensuring correct asset loading. ```javascript !function(){var t,e,n,r,s,a="6515",l=localStorage.getItem("cdnPath")||"https://d3gbzgu5n72ptk.cloudfront.net",i=document.getElementsByTagName("head")[0];try{var c=localStorage.getItem("clientVersion");t=JSON.parse(c)}catch(t){}function o(t){if("localhost"===window.location.hostname)return t;var e=[];return l&&e.push(l),a&&e.push(a),e.push(t),e.join("/")}t&&t.build&&(a=t.build),e="build/main.css",(n=document.createElement("link")).setAttribute("href",o(e)),n.setAttribute("rel","stylesheet"),n.setAttribute("type","text/css"),i.appendChild(n),r="build/main.bundle.js",(s=document.createElement("script")).src=o(r),s.async=!1,i.insertBefore(s,i.lastChild)}() ``` -------------------------------- ### Register Subscription Forms and Poll for Changes Source: https://status.trackvia.com/ Initializes subscription forms for email and SMS, and starts polling a status endpoint for changes. This snippet sets up basic application interactivity. ```javascript $(function() { SP.currentPage.registerSubscriptionForm('email'); SP.currentPage.registerSubscriptionForm('sms'); }); SP.pollForChanges('/api/v2/status.json'); ``` -------------------------------- ### TrackVia API Error Response (500 Internal Server Error) Source: https://trackvia.com/llms-developer-full.txt Example of a standard error response body received from the TrackVia API when an internal server error occurs. It includes details about errors, a general message, the error name, and a specific error code. ```json { "errors": [], "message": "We're sorry, there's been an error. Please contact support@trackvia.com for troubleshooting", "name": "exception", "code": "500" } ``` -------------------------------- ### TrackVia Microservice Environment & Limitations Source: https://trackvia.com/llms-developer-full.txt Details the execution environment, resource constraints, and operational limitations for TrackVia Microservices, including runtime, memory, and package size. ```APIDOC TrackViaMicroserviceEnvironment: ExecutionPlatform: Amazon Web Service Lambda Runtimes: - Node.js: x86 Node 16.x - Python: x86 Python 3.9 ProvisionedMemory: 1024 MB TrackViaMicroserviceLimitations: TotalRuntime: 15 minutes AWSIntegration: No access to IAM or other AWS services PackageSize: Max 40MB (ZIP) Dependencies: Standalone, no access to layers TermsOfService: Subject to TrackVia's Terms of Service and security policies TrackViaMicroserviceLogging: Access: Available in the "Log" tab of the account microservices page Permissions: Only super admin users can view logs ``` -------------------------------- ### Microservice Use Cases Source: https://trackvia.com/llms-developer-full.txt Illustrates common scenarios for utilizing TrackVia Microservices to interact with external APIs or perform data manipulation within TrackVia. ```APIDOC MicroserviceUseCases: - Functionality: Integrate with Formstack Documents API to create PDFs from TrackVia record data. Details: Gathers record information, sends request to Formstack, uploads resulting PDF to a TrackVia document field. - Functionality: Call Outlook 365 API for calendar event creation. Details: Creates calendar invites in Outlook 365 based on events created in TrackVia. - Functionality: Post Slack/Teams messages. Details: Sends notifications to shared channels when a project status changes to 'completed' in TrackVia. - Functionality: Image processing upon upload. Details: Downloads an uploaded image, resizes and renames it according to conventions, then re-uploads it to the TrackVia record. ``` -------------------------------- ### Google Tag Manager Initialization Source: https://go.trackvia.com/ Loads Google Tag Manager asynchronously if a GTM ID is present and the domain matches TrackVia or xvia.com. It also initializes the dataLayer. ```javascript (function(win) { var id = 'GTM-5DQFN49'; // Load google tag manager in qa/prod environments. Marketing will target further based on domain if (id && /\.(trackvia|xvia)\.com$/.test(window.location.hostname)) { var script = document.createElement('script'); script.setAttribute('name', `google-tag-manger-${id}`) script.type = 'text/javascript'; script.async = 1; script.src = 'https://www.googletagmanager.com/gtm.js?id=' + id; win.document.head.appendChild(script); win.dataLayer = window.dataLayer || []; win.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js', }); } })(this); ``` -------------------------------- ### JavaScript: RocketLazyLoadScripts Class Initialization Source: https://trackvia.com/ Initializes the RocketLazyLoadScripts class, setting up version, user-configurable events, and attribute-based events. The constructor prepares the environment for script loading optimization. ```javascript class RocketLazyLoadScripts{ constructor(){ this.v="2.0.3", this.userEvents=["keydown","keyup","mousedown","mouseup","mousemove","mouseover","mouseenter","mouseout","mouseleave","touchmove","touchstart","touchend","touchcancel","wheel","click","dblclick","input","visibilitychange"], this.attributeEvents=["onblur","onclick","oncontextmenu","ondblclick","onfocus","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onscroll","onsubmit"] } async t(){ this.i(),this.o(),/iP(ad|hone)/.test(navigator.userAgent)&&this.h(),this.u(),this.l(this),this.m(),this.k(this),this.p(this), this._(),await Promise.all([this.R(),this.L()]),this.lastBreath=Date.now(),this.S(this),this.P(),this.D(),this.O(),this.M(),await this.C(this.delayedScripts.normal),await this.C(this.delayedScripts.defer),await this.C(this.delayedScripts.async), this.F("domReady"),await this.T(),await this.j(),await this.I(),this.F("windowLoad"),await this.A(),window.dispatchEvent(new Event("rocket-allScriptsLoaded")), this.everythingLoaded=!0, this.lastTouchEnd&&await new Promise((t=>setTimeout(t,500-Date.now()+this.lastTouchEnd))), this.H(),this.F("all"),this.U(),this.W() } i(){ this.CSPIssue=sessionStorage.getItem("rocketCSPIssue"), document.addEventListener("securitypolicyviolation",(t=>{ this.CSPIssue||"script-src-elem"!==t.violatedDirective||"data"!==t.blockedURI|| (this.CSPIssue=!0,sessionStorage.setItem("rocketCSPIssue",!0)) }),{isRocket:!0}) } o(){ window.addEventListener("pageshow",(t=>{ this.persisted=t.persisted, this.realWindowLoadedFired=!0 }),{isRocket:!0}), window.addEventListener("pagehide",(()=>{ this.onFirstUserAction=null }),{isRocket:!0}) } h(){ let t; function e(e){t=e} window.addEventListener("touchstart",e,{isRocket:!0}), window.addEventListener("touchend",(function i(o){ Math.abs(o.changedTouches[0].pageX-t.changedTouches[0].pageX)<10&&Math.abs(o.changedTouches[0].pageY-t.changedTouches[0].pageY)<10&& o.timeStamp-t.timeStamp<200&& (o.target.dispatchEvent(new PointerEvent("click",{target:o.target,bubbles:!0,cancelable:!0,detail:1})),event.preventDefault(),window.removeEventListener("touchstart",e,{isRocket:!0}),window.removeEventListener("touchend",i,{isRocket:!0})) }),{isRocket:!0}) } q(t){ this.userActionTriggered|| ("mousemove"!==t.type|| this.firstMousemoveIgnored?"keyup"===t.type||"mouseover"===t.type||"mouseout"===t.type|| (this.userActionTriggered=!0,this.onFirstUserAction&&this.onFirstUserAction()):this.firstMousemoveIgnored=!0), "click"===t.type&&t.preventDefault(), this.savedUserEvents.length>0&& (t.stopPropagation(),t.stopImmediatePropagation()), "touchstart"===this.lastEvent&&"touchend"===t.type&& (this.lastTouchEnd=Date.now()), "click"===t.type&& (this.lastTouchEnd=0), this.lastEvent=t.type, this.savedUserEvents.push(t) } u(){ this.savedUserEvents=[], this.userEventHandler=this.q.bind(this), this.userEvents.forEach((t=>window.addEventListener(t,this.userEventHandler,{passive:!1,isRocket:!0}))) } U(){ this.userEvents.forEach((t=>window.removeEventListener(t,this.userEventHandler,{passive:!1,isRocket:!0}))), this.savedUserEvents.forEach((t=>{ t.target.dispatchEvent(new window[t.constructor.name](t.type,t)) })) } m(){ this.eventsMutationObserver=new MutationObserver((t=>{ const e="return false"; for(const i of t){ if("attributes"===i.type){ const t=i.target.getAttribute(i.attributeName); t&&t!==e&& (i.target.setAttribute("data-rocket-"+i.attributeName,t),i.target["rocket"+i.attributeName]=new Function("event",t),i.target.setAttribute(i.attributeName,e)) } "childList"===i.type&& i.addedNodes.forEach((t=>{ if(t.nodeType===Node.ELEMENT_NODE) for(const i of t.attributes) this.attributeEvents.includes(i.name)&&i.value&&""!==i.value&& (t.setAttribute("data-rocket-"+i.name,i.value),t["rocket"+i.name]=new Function("event",i.value),t.setAttribute(i.name,e)) })) } })), this.eventsMutationObserver.observe(document,{subtree:!0,childList:!0,attributeFilter:this.attributeEvents}) } H(){ this.eventsMutationObserver.disconnect(), this.attributeEvents.forEach((t=>{ document.querySelectorAll("["+"data-rocket-"+t+"]").forEach((e=>{ e.setAttribute(t,e.getAttribute("data-rocket-"+t)), e.removeAttribute("data-rocket-"+t) })) })) } k(t){ Object.defineProperty(HTMLElement.prototype,"onclick",{ get(){ return this.rocketonclick||null }, set(e){ this.rocketonclick=e, t.everythingLoaded?"onclick"==="onclick"?this.setAttribute("onclick","this.rocketonclick(event)"): this.setAttribute("data-rocket-onclick","this.rocketonclick(event)"): this.setAttribute("data-rocket-onclick","this.rocketonclick(event)") } }) } S(t){ function e(e,i){let o=e[i];e[i]=null,Object.defineProperty(e,i,{ get:()=>o, set(s){ t.everythingLoaded?o=s:e["rocket"+i] ``` -------------------------------- ### TrackVia API Testing Tools Source: https://trackvia.com/llms-developer-full.txt Information on using external tools like Swagger and Postman to test and learn about the TrackVia API. ```APIDOC Swagger UI: - Provides an interactive documentation interface for the TrackVia API. - Allows exploration of API endpoints, parameters, and responses. - Useful for understanding API structure and testing requests. Postman: - A collaboration platform for API development. - Enables sending HTTP requests to the TrackVia API. - Supports creating collections of requests, environments, and tests. - Recommended for planning and testing API actions. ``` -------------------------------- ### Initialize Tooltipster with Custom Configuration Source: https://status.trackvia.com/ Configures the Tooltipster jQuery plugin for elements with the class 'tool'. It supports custom options passed via data attributes, enabling dynamic tooltip behavior. ```javascript $(function() { $('.tool').tooltipster({ animationDuration: 100, contentAsHTML: true, delay: 100, theme: 'tooltipster-borderless', functionInit: function (instance, helper) { var $origin = $(helper.origin), dataOptions = $origin.attr('data-tooltip-config'); if (dataOptions){ dataOptions = JSON.parse(dataOptions); $.each(dataOptions, function(name, option){ instance.option(name, option); }); } } }); // clicks on first tab in subscribe popout since we won't know which is first // upon construction in the ruby code $('.updates-dropdown-nav > a').eq(0).click(); // twitter follow button needs some margin $('.twitter-follow-button').css('margin-right', '6px'); }); ``` -------------------------------- ### RocketElementorPreload Initialization and Settings Management Source: https://trackvia.com/ This snippet defines a class `RocketElementorPreload` with a static `run` method that schedules an update using `requestAnimationFrame`. It also includes a method to manage element settings by stringifying them into a data attribute. The script attaches the `run` method to the `DOMContentLoaded` event. ```javascript var _ = (function() { var i = []; var rEach = function(t) { t.forEach(function(e) { i.push(e); }); }; var l = function(t, e) { this.i().forEach(function(e) { delete e[t]; }); t.dataset.settings = JSON.stringify(e); }; var RocketElementorPreload = (function() { function RocketElementorPreload() { this.t = function() { console.log('RocketElementorPreload update'); }; this.i = function() { return ['setting1', 'setting2']; }; } RocketElementorPreload.run = function() { var t = new RocketElementorPreload(); requestAnimationFrame(t.t.bind(t)); }; return RocketElementorPreload; })(); document.addEventListener("DOMContentLoaded", RocketElementorPreload.run); })(); ``` -------------------------------- ### JavaScript Uptime Tooltip Event Listeners Source: https://status.trackvia.com/ Sets up event listeners for various DOM elements related to the uptime visualization. It attaches listeners for mouse enter/leave on tooltip boxes and focus/blur/keydown events on individual uptime days to trigger tooltip behavior. ```javascript var timeoutId = null; // Initialize tooltip box event listeners var tooltipBox = document.querySelector('#uptime-tooltip .tooltip-box'); if (tooltipBox) { tooltipBox.addEventListener('mouseenter', this.mouseEnteredTooltip.bind(this)); tooltipBox.addEventListener('mouseleave', this.unhoverTooltip.bind(this)); } // Add listeners for each uptime day element document.querySelectorAll('.uptime-day').forEach(function (rect) { rect.addEventListener('focus', function (event) { var tooltipHandler = new UptimeTooltipHandler(); tooltipHandler.updateHoveredDay(event); tooltipHandler.updateTooltip(event); }); rect.addEventListener('blur', function () { var tooltipHandler = new UptimeTooltipHandler(); tooltipHandler.unhoverTooltip(); }); rect.addEventListener('keydown', function (event) { if (event.key === 'Escape' || event.keyCode === 27) { var tooltipHandler = new UptimeTooltipHandler(); tooltipHandler.unhoverTooltip(); } }); }); ``` -------------------------------- ### TrackVia API Authentication and Users Source: https://trackvia.com/llms-developer-full.txt Details on how to authenticate with the TrackVia API using API Keys and manage API Users. Covers the purpose, generation, and usage of API Keys, as well as the specific characteristics and management of API Users for secure integration. ```APIDOC API Authentication and Users: API Key: Purpose: A unique key for your TrackVia account, required for accessing the TrackVia API. Usage: Use as the value for the `user_key` query string parameter in API requests. Generation: Navigate to `Account Settings` -> `API Access`. Properties: Once generated, it cannot be changed or deleted. API Users: Purpose: Special users designated for API connections and integrations, used to authenticate with the API via access tokens. Properties: - Restrict Web and Mobile access: Cannot use TrackVia web or mobile applications. - Bypass Single Sign On (SSO): Prevents token expiration due to SSO policies. - Ignore password expiration policies: Exempt from password expiration. - Eligibility for access token creation: Only API Users can create access tokens. - Permissions: Managed like other users; require a properly configured role for read, write, or delete permissions. Creation: 1. Navigate to `Manage Users`. 2. Select the user to assign. 3. Check the `Set As API User` box. Note: Users in `Unverified` status cannot be designated as API Users. Token Management: - A `Super Admin` can create up to 100 unique access tokens per API User. - Each token can have its own expiration date and set of permissions. - Actions performed using an access token are attributed to that API User. ``` -------------------------------- ### reCAPTCHA and WordPress Settings Source: https://trackvia.com/ Configuration for reCAPTCHA integration and WordPress AJAX endpoint. ```javascript var recaptchaData = { "disconnect_title": "Disconnect", "disconnect_message": "Disconnecting from reCAPTCHA will delete your current settings. Do you want to proceed?", "site_key": "6LcxHtMpAAAAABEGUzcgKpzPiNHit2uXBFG1ohae" }; var _wpUtilSettings = { "ajax": { "url": "\/wp-admin\/admin-ajax.php" } }; wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } ); ``` -------------------------------- ### Algolia Autocomplete Suggestion Templates Source: https://trackvia.com/ Templates for rendering suggestions in Algolia's autocomplete widget. Includes structures for posts, pages, resources, and users, displaying titles, snippets, and thumbnails. ```html