@coveo/relay 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;const t=[];for(let e=0;e<256;++e)t.push((e+256).toString(16).slice(1));let n;const o=new Uint8Array(16);var r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,c,a){if(r.randomUUID&&!e)return r.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!n){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");n=crypto.getRandomValues.bind(crypto)}return n(o)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,n=0){return(t[e[n+0]]+t[e[n+1]]+t[e[n+2]]+t[e[n+3]]+"-"+t[e[n+4]]+t[e[n+5]]+"-"+t[e[n+6]]+t[e[n+7]]+"-"+t[e[n+8]]+t[e[n+9]]+"-"+t[e[n+10]]+t[e[n+11]]+t[e[n+12]]+t[e[n+13]]+t[e[n+14]]+t[e[n+15]]).toLowerCase()}(i)}function a(t){return{getClientId:()=>{const n="visitorId",o=t.get(),r=o.storage,c=r.getItem(n),a=c&&("string"==typeof(i=c)&&e.test(i))?c:o.generateUUID();var i;return r.setItem(n,a),a}}}const i="1.0.0";function s(e){return(e.source||[]).concat([`relay@${i}`])}function u(e,t,n,o){const{getReferrer:r,getLocation:c,getUserAgent:a}=n,i=function(e){const{trackingId:t}=e;return{trackingId:t}}(t),u=o.getClientId();return Object.freeze({type:e,config:i,ts:Date.now(),source:s(t),clientId:u,userAgent:a(),referrer:r(),location:c()})}function f(){const e=[];function t({type:t,callback:n}){return e.findIndex((e=>e.type===t&&e.callback===n))}function n(n,o){o?function(n){const o=t(n);o>=0&&e.splice(o,1)}({type:n,callback:o}):function(t){if("*"===t)e.length=0;else for(let n=e.length-1;n>=0;n--)e[n].type===t&&e.splice(n,1)}(n)}return{add:function(o){return t(o)<0&&e.push(o),()=>n(o.type,o.callback)},call:function(t){e.forEach((e=>{if(function(e,t){return"*"===e.type||t===e.type}(e,t.meta.type))try{e.callback(t)}catch(e){console.error(e)}}))},remove:n}}function l({url:e,token:t,trackingId:n,...o}){return Object.freeze({url:e,token:t,trackingId:n,...!!o.mode&&{mode:o.mode},...!!o.source&&{source:o.source}})}const g=function(){const e="coveo_";return{getItem(t){const n=`${e}${t}=`,o=document.cookie.split(";");for(const e of o){const t=e.replace(/^\s+/,"");if(0===t.lastIndexOf(n,0))return t.substring(n.length,t.length)}return null},setItem(t,n,o){const r=(e=>{const t=e.split(".").slice(-2);return 2==t.length?t.join("."):""})(window.location.hostname),c=`;expires=${new Date((new Date).getTime()+o).toUTCString()}`,a=r?`;domain=${r}`:"";document.cookie=`${e}${t}=${n}${c}${a};path=/;SameSite=Lax`},removeItem(e){this.setItem(e,"",-1)}}}();function d(){return{runtime:"browser",send:(e,t,n)=>{const o=navigator.sendBeacon(`${e}?access_token=${t}`,new Blob([JSON.stringify([n])],{type:"application/json"})),r=function(){const e="undefined"!=typeof window;return{sendMessage(t){e&&window.postMessage(t,"*")}}}();if(r.sendMessage({kind:"EVENT_PROTOCOL",event:n,url:e,token:t}),!o)throw new Error("Failed to send the event(s) because the payload size exceeded the maximum allowed size (32 KB). Please contact support if the problem persists.")},getReferrer:()=>function(){const e=document.referrer;return""===e?null:e}(),getLocation:()=>window.location.href,getUserAgent:()=>navigator.userAgent,generateUUID:()=>c(),storage:{getItem:e=>g.getItem(e)||localStorage.getItem(e),removeItem(e){g.removeItem(e),localStorage.removeItem(e)},setItem(e,t){localStorage.setItem(e,t),g.setItem(e,t,31556952e3)}}}}function m(e){return"disabled"!==e.get().mode&&function(){try{return"object"==typeof window}catch{return!1}}()&&function(){try{const e="__storage_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return e instanceof DOMException&&"QuotaExceededError"===e.name&&localStorage&&0!==localStorage.length}}()?d():{runtime:"null",send:()=>{},getReferrer:()=>null,getLocation:()=>null,getUserAgent:()=>null,generateUUID:()=>"",storage:{getItem:()=>null,removeItem(){},setItem(){}}}}function p(e){const t=function(e){let t=l(e);return{get:()=>t,update:e=>{t=l({...t,...e})}}}(e),n=f(),o=function(e){return{get:()=>Object.freeze(m(e))}}(t),r=a(o);return{emit:(e,c)=>{const a=t.get(),i=o.get(),s=function(e,t,n,o,r){return{...t,meta:u(e,n,o,r)}}(e,c,a,i,r);return function({config:e,environment:t,event:n,listenerManager:o}){const{url:r,token:c,mode:a}=e;"disabled"!==a&&(o.call(n),t.send(r,c,n))}({config:a,environment:i,event:s,listenerManager:n})},getMeta:e=>u(e,t.get(),o.get(),r),on:(e,t)=>n.add({type:e,callback:t}),off:(e,t)=>n.remove(e,t),updateConfig:e=>t.update(e),version:i}}export{p as createRelay};
1
+ var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;const t=[];for(let e=0;e<256;++e)t.push((e+256).toString(16).slice(1));let n;const o=new Uint8Array(16);var r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,c,a){if(r.randomUUID&&!e)return r.randomUUID();const i=(e=e||{}).random??e.rng?.()??function(){if(!n){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");n=crypto.getRandomValues.bind(crypto)}return n(o)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,n=0){return(t[e[n+0]]+t[e[n+1]]+t[e[n+2]]+t[e[n+3]]+"-"+t[e[n+4]]+t[e[n+5]]+"-"+t[e[n+6]]+t[e[n+7]]+"-"+t[e[n+8]]+t[e[n+9]]+"-"+t[e[n+10]]+t[e[n+11]]+t[e[n+12]]+t[e[n+13]]+t[e[n+14]]+t[e[n+15]]).toLowerCase()}(i)}function a(t){return{getClientId:()=>{const n="visitorId",o=t.get(),r=o.storage,c=r.getItem(n),a=c&&("string"==typeof(i=c)&&e.test(i))?c:o.generateUUID();var i;return r.setItem(n,a),a}}}const i="1.1.0";function s(e){return(e.source||[]).concat([`relay@${i}`])}function u(e,t,n,o){const{getReferrer:r,getLocation:c,getUserAgent:a}=n,i=function(e){const{trackingId:t}=e;return{trackingId:t}}(t),u=o.getClientId();return Object.freeze({type:e,config:i,ts:Date.now(),source:s(t),clientId:u,userAgent:a(),referrer:r(),location:c()})}function f(){const e=[];function t({type:t,callback:n}){return e.findIndex((e=>e.type===t&&e.callback===n))}function n(n,o){o?function(n){const o=t(n);o>=0&&e.splice(o,1)}({type:n,callback:o}):function(t){if("*"===t)e.length=0;else for(let n=e.length-1;n>=0;n--)e[n].type===t&&e.splice(n,1)}(n)}return{add:function(o){return t(o)<0&&e.push(o),()=>n(o.type,o.callback)},call:function(t){e.forEach((e=>{if(function(e,t){return"*"===e.type||t===e.type}(e,t.meta.type))try{e.callback(t)}catch(e){console.error(e)}}))},remove:n}}function l({url:e,token:t,trackingId:n,...o}){return Object.freeze({url:e,token:t,trackingId:n,...!!o.mode&&{mode:o.mode},...!!o.source&&{source:o.source},...!!o.environment&&{environment:o.environment}})}const g=function(){const e="coveo_";return{getItem(t){const n=`${e}${t}=`,o=document.cookie.split(";");for(const e of o){const t=e.replace(/^\s+/,"");if(0===t.lastIndexOf(n,0))return t.substring(n.length,t.length)}return null},setItem(t,n,o){const r=(e=>{const t=e.split(".").slice(-2);return 2==t.length?t.join("."):""})(window.location.hostname),c=`;expires=${new Date((new Date).getTime()+o).toUTCString()}`,a=r?`;domain=${r}`:"";document.cookie=`${e}${t}=${n}${c}${a};path=/;SameSite=Lax`},removeItem(e){this.setItem(e,"",-1)}}}();function d(){return{runtime:"browser",send:(e,t,n)=>{const o=navigator.sendBeacon(`${e}?access_token=${t}`,new Blob([JSON.stringify([n])],{type:"application/json"})),r=function(){const e="undefined"!=typeof window;return{sendMessage(t){e&&window.postMessage(t,"*")}}}();if(r.sendMessage({kind:"EVENT_PROTOCOL",event:n,url:e,token:t}),!o)throw new Error("Failed to send the event(s) because the payload size exceeded the maximum allowed size (32 KB). Please contact support if the problem persists.")},getReferrer:()=>function(){const e=document.referrer;return""===e?null:e}(),getLocation:()=>window.location.href,getUserAgent:()=>navigator.userAgent,generateUUID:()=>c(),storage:{getItem:e=>g.getItem(e)||localStorage.getItem(e),removeItem(e){g.removeItem(e),localStorage.removeItem(e)},setItem(e,t){localStorage.setItem(e,t),g.setItem(e,t,31556952e3)}}}}function m(e){const t="disabled"!==e.get().mode,n=e.get().environment;return t&&n?{...n,runtime:"custom"}:t&&function(){try{return"object"==typeof window}catch{return!1}}()&&function(){try{const e="__storage_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return e instanceof DOMException&&"QuotaExceededError"===e.name&&localStorage&&0!==localStorage.length}}()?d():{runtime:"null",send:()=>{},getReferrer:()=>null,getLocation:()=>null,getUserAgent:()=>null,generateUUID:()=>"",storage:{getItem:()=>null,removeItem(){},setItem(){}}}}function p(e){const t=function(e){let t=l(e);return{get:()=>t,update:e=>{t=l({...t,...e})}}}(e),n=f(),o=function(e){return{get:()=>Object.freeze(m(e))}}(t),r=a(o);return{emit:(e,c)=>{const a=t.get(),i=o.get(),s=function(e,t,n,o,r){return{...t,meta:u(e,n,o,r)}}(e,c,a,i,r);return function({config:e,environment:t,event:n,listenerManager:o}){const{url:r,token:c,mode:a}=e;"disabled"!==a&&(o.call(n),t.send(r,c,n))}({config:a,environment:i,event:s,listenerManager:n})},getMeta:e=>u(e,t.get(),o.get(),r),on:(e,t)=>n.add({type:e,callback:t}),off:(e,t)=>n.remove(e,t),updateConfig:e=>t.update(e),version:i}}export{p as createRelay};
2
2
  //# sourceMappingURL=relay.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"relay.min.js","sources":["../../../../node_modules/.pnpm/uuid@11.0.4/node_modules/uuid/dist/esm-browser/regex.js","../../../../node_modules/.pnpm/uuid@11.0.4/node_modules/uuid/dist/esm-browser/stringify.js","../../../../node_modules/.pnpm/uuid@11.0.4/node_modules/uuid/dist/esm-browser/rng.js","../../../../node_modules/.pnpm/uuid@11.0.4/node_modules/uuid/dist/esm-browser/native.js","../../../../node_modules/.pnpm/uuid@11.0.4/node_modules/uuid/dist/esm-browser/v4.js","../../../src/client-id/client-id.ts","../../../../node_modules/.pnpm/uuid@11.0.4/node_modules/uuid/dist/esm-browser/validate.js","../../../src/version.ts","../../../src/event/meta/meta.ts","../../../src/listener/listener.ts","../../../src/config/config.ts","../../../src/environment/browser/storage/cookie.ts","../../../src/environment/browser/browser.ts","../../../../node_modules/.pnpm/@coveo+explorer-messenger@0.4.0/node_modules/@coveo/explorer-messenger/dist/messenger.js","../../../src/environment/browser/storage/storage.ts","../../../src/environment/manager/manager.ts","../../../src/environment/browser/storage/availability.ts","../../../src/environment/null/null.ts","../../../src/environment/storage.ts","../../../src/relay.ts","../../../src/event/relay-event.ts","../../../src/emit/emit.ts"],"sourcesContent":["export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;\n","import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;\n","import { validate } from \"uuid\";\nimport { EnvironmentManager } from \"../environment/manager/manager\";\n\nexport interface ClientIdManager {\n getClientId: () => string;\n}\n\nexport function createClientIdManager(\n environmentManager: EnvironmentManager,\n): ClientIdManager {\n return {\n getClientId: () => {\n const key = \"visitorId\";\n const environment = environmentManager.get();\n const storage = environment.storage;\n\n const existingClientId = storage.getItem(key);\n const clientId =\n existingClientId && validate(existingClientId)\n ? existingClientId\n : environment.generateUUID();\n storage.setItem(key, clientId);\n return clientId;\n },\n };\n}\n","import REGEX from './regex.js';\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\nexport default validate;\n","export const version = \"process.env.VERSION\";\n","import { ClientIdManager } from \"../../client-id/client-id\";\nimport { Environment } from \"../../environment/environment\";\nimport { RelayConfig } from \"../../config/config\";\nimport { version } from \"../../version\";\n\n/**\n * The `EventConfig` object provides additonal information for the configuration associated with the event.\n */\nexport interface EventConfig {\n /**\n * The unique identifier of a web property. See [What's a tracking ID?](https://docs.coveo.com/en/n8tg0567/).\n */\n trackingId: string;\n}\n\n/**\n * The `Meta` object provides a structured representation of metadata associated with an emitted event.\n * This object is auto-populated by Relay.\n */\nexport interface Meta {\n /**\n * Event's type that was emitted.\n */\n type: string;\n\n /**\n * Configuration associated with the event.\n */\n config: EventConfig;\n\n /**\n * Timestamp when the event was emitted.\n */\n ts: number;\n\n /**\n * Names and versions of the client side libraries which built and emitted this event.\n */\n source: string[];\n\n /**\n * Persistent unique identifier of a device.\n */\n clientId: string;\n\n /**\n * Browser Navigator's [user agent](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent) property if set.\n */\n userAgent: string | null;\n\n /**\n * Browser Document's [referrer](https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer) property if set.\n */\n referrer: string | null;\n\n /**\n * Browser Location's [href](https://developer.mozilla.org/en-US/docs/Web/API/Location/href) property if set.\n */\n location: string | null;\n}\n\nfunction getEventConfig(config: RelayConfig): EventConfig {\n const { trackingId } = config;\n return { trackingId };\n}\n\nfunction getSource(config: RelayConfig): string[] {\n return (config.source || []).concat([`relay@${version}`]);\n}\n\nexport function createMeta(\n type: string,\n config: RelayConfig,\n environment: Environment,\n clientIdManager: ClientIdManager,\n): Readonly<Meta> {\n const { getReferrer, getLocation, getUserAgent } = environment;\n const eventConfig = getEventConfig(config);\n const clientId = clientIdManager.getClientId();\n\n return Object.freeze<Meta>({\n type,\n config: eventConfig,\n ts: Date.now(),\n source: getSource(config),\n clientId,\n userAgent: getUserAgent(),\n referrer: getReferrer(),\n location: getLocation(),\n });\n}\n","import { RelayEvent } from \"../event/relay-event\";\n\nconst ANY_EVENT_TYPE = \"*\";\n\n/**\n * Callback to perform an action when a specified event is emitted.\n * @typedef {function} EventCallback\n * @param {RelayEvent} event - the Relay event payload that triggered the callback.\n * @returns {void}\n */\nexport type EventCallback = (event: RelayEvent) => void;\n\ninterface Listener {\n type: string;\n callback: EventCallback;\n}\n\nexport interface ListenerManager {\n add: (listener: Listener) => () => void;\n call: (event: RelayEvent) => void;\n remove: (type: string, callback?: EventCallback) => void;\n}\n\nexport function createListenerManager(): ListenerManager {\n const listeners: Listener[] = [];\n\n function getListenerIndex({ type, callback }: Listener): number {\n return listeners.findIndex(\n (listener) => listener.type === type && listener.callback === callback,\n );\n }\n\n function isMatchesType(listener: Listener, type: string): boolean {\n return listener.type === \"*\" || type === listener.type;\n }\n\n function add(listener: Listener): () => void {\n if (getListenerIndex(listener) < 0) {\n listeners.push(listener);\n }\n return () => remove(listener.type, listener.callback);\n }\n\n function call(event: RelayEvent) {\n listeners.forEach((listener) => {\n if (isMatchesType(listener, event.meta.type)) {\n try {\n listener.callback(event);\n } catch (e) {\n console.error(e);\n }\n }\n });\n }\n\n function removeMultiple(type: string) {\n if (type === ANY_EVENT_TYPE) {\n listeners.length = 0;\n } else {\n for (let i = listeners.length - 1; i >= 0; i--) {\n if (listeners[i].type === type) {\n listeners.splice(i, 1);\n }\n }\n }\n }\n\n function removeOne(listener: Listener) {\n const index = getListenerIndex(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n }\n\n function remove(type: string, callback?: EventCallback) {\n if (callback) {\n removeOne({ type, callback });\n } else {\n removeMultiple(type);\n }\n }\n\n return {\n add,\n call,\n remove,\n };\n}\n","/**\n * The `RelayConfig` object defines the configuration options for initializing a Relay instance.\n */\nexport interface RelayConfig {\n /**\n * Endpoint defined to communicate with the Event API.\n */\n url: string;\n\n /**\n * Token to authorize the access to the Event API endpoint.\n */\n token: string;\n\n /**\n * The unique identifier of a web property. See [What's a tracking ID?](https://docs.coveo.com/en/n8tg0567/).\n */\n trackingId: string;\n\n /**\n * Defines the library mode. The available modes are `emit` and `disabled`.\n * `emit` sends analytics events to Coveo to be stored.\n * `disabled` prevents the emission of events and does not trigger callbacks.\n * @default emit\n */\n mode?: \"emit\" | \"disabled\";\n\n /**\n * Optionally allows a Relay integration to specify the name(s) of software package(s) relay is\n * being called from. These names will be transmitted with each event, along with Relay's own\n * version. The recommendation is to specify them using a 'softwarename@softwareversion' string.\n */\n source?: string[];\n}\n\nexport interface ConfigManager {\n get: () => Readonly<RelayConfig>;\n update: (updatedConfig: Partial<RelayConfig>) => void;\n}\n\nfunction pick({\n url,\n token,\n trackingId,\n ...rest\n}: RelayConfig): Readonly<RelayConfig> {\n return Object.freeze({\n url,\n token,\n trackingId,\n ...(!!rest.mode && { mode: rest.mode }),\n ...(!!rest.source && { source: rest.source }),\n });\n}\n\nexport function createConfigManager(\n initialConfig: RelayConfig,\n): Readonly<ConfigManager> {\n let _config: Readonly<RelayConfig> = pick(initialConfig);\n\n return {\n get: () => _config,\n update: (updatedConfig: Partial<RelayConfig>) => {\n _config = pick({ ..._config, ...updatedConfig });\n },\n };\n}\n","export interface CookieManager {\n getItem: (key: string) => string | null;\n removeItem: (key: string) => void;\n setItem: (key: string, data: string, expire: number) => void;\n}\n\nexport const cookieManager: CookieManager = createCookieManager();\n\nfunction createCookieManager(): CookieManager {\n const prefix = \"coveo_\";\n const getDomain = (host: string) => {\n const parts = host.split(\".\").slice(-2);\n return parts.length == 2 ? parts.join(\".\") : \"\";\n };\n\n return {\n getItem(key: string): string | null {\n const cookiePrefix = `${prefix}${key}=`;\n const cookieArray = document.cookie.split(\";\");\n for (const cookie of cookieArray) {\n const prettifyCookie = cookie.replace(/^\\s+/, \"\");\n if (prettifyCookie.lastIndexOf(cookiePrefix, 0) === 0) {\n return prettifyCookie.substring(\n cookiePrefix.length,\n prettifyCookie.length,\n );\n }\n }\n return null;\n },\n setItem(key: string, data: string, expire: number): void {\n const domain = getDomain(window.location.hostname);\n const expireSection = `;expires=${new Date(\n new Date().getTime() + expire,\n ).toUTCString()}`;\n const domainSection = domain ? `;domain=${domain}` : \"\";\n document.cookie = `${prefix}${key}=${data}${expireSection}${domainSection};path=/;SameSite=Lax`;\n },\n\n removeItem(key: string): void {\n this.setItem(key, \"\", -1);\n },\n };\n}\n","import { createExplorerMessenger } from \"@coveo/explorer-messenger\";\nimport { Environment } from \"../environment\";\nimport { createBrowserStorage } from \"./storage/storage\";\nimport { RelayEvent } from \"../../event/relay-event\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nfunction getReferrer() {\n const referrer = document.referrer;\n\n return referrer === \"\" ? null : referrer;\n}\n\nexport function buildBrowserEnvironment(): Environment {\n return {\n runtime: \"browser\",\n send: (url: string, token: string, event: RelayEvent) => {\n const response = navigator.sendBeacon(\n `${url}?access_token=${token}`,\n new Blob([JSON.stringify([event])], {\n type: \"application/json\",\n }),\n );\n\n const messenger = createExplorerMessenger();\n messenger.sendMessage({ kind: \"EVENT_PROTOCOL\", event, url, token });\n\n if (!response) {\n throw new Error(\n `Failed to send the event(s) because the payload size exceeded the maximum allowed size (32 KB). Please contact support if the problem persists.`,\n );\n }\n },\n getReferrer: () => getReferrer(),\n getLocation: () => window.location.href,\n getUserAgent: () => navigator.userAgent,\n generateUUID: () => uuidv4(),\n storage: createBrowserStorage(),\n };\n}\n","function createExplorerMessenger() {\n const isBrowser = typeof window !== \"undefined\";\n return {\n sendMessage(message) {\n isBrowser && window.postMessage(message, \"*\");\n }\n };\n}\nexport {\n createExplorerMessenger\n};\n","import { Storage } from \"../../storage\";\nimport { cookieManager } from \"./cookie\";\n\nexport function createBrowserStorage(): Storage {\n return {\n getItem(key: string): string | null {\n return cookieManager.getItem(key) || localStorage.getItem(key);\n },\n\n removeItem(key: string): void {\n cookieManager.removeItem(key);\n localStorage.removeItem(key);\n },\n\n setItem(key: string, data: string): void {\n const oneYear = 31556952000;\n localStorage.setItem(key, data);\n cookieManager.setItem(key, data, oneYear);\n },\n };\n}\n","import { ConfigManager } from \"../../config/config\";\nimport { buildBrowserEnvironment } from \"../browser/browser\";\nimport { localStorageAvailable } from \"../browser/storage/availability\";\nimport { Environment } from \"../environment\";\nimport { buildNullEnvironment } from \"../null/null\";\n\nexport interface EnvironmentManager {\n get: () => Readonly<Environment>;\n}\n\nfunction buildEnvironment(configManager: ConfigManager) {\n const active = configManager.get().mode !== \"disabled\";\n\n if (active && isBrowser() && localStorageAvailable()) {\n return buildBrowserEnvironment();\n }\n\n return buildNullEnvironment();\n}\n\nfunction isBrowser() {\n try {\n return typeof window === \"object\";\n } catch {\n return false;\n }\n}\n\nexport function createEnvironmentManager(\n configManager: ConfigManager,\n): Readonly<EnvironmentManager> {\n return {\n get: () => Object.freeze(buildEnvironment(configManager)),\n };\n}\n","// From: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage\nexport function localStorageAvailable() {\n try {\n const x = \"__storage_test__\";\n localStorage.setItem(x, x);\n localStorage.removeItem(x);\n return true;\n } catch (e) {\n return (\n e instanceof DOMException &&\n e.name === \"QuotaExceededError\" &&\n // acknowledge QuotaExceededError only if there's something already stored\n localStorage &&\n localStorage.length !== 0\n );\n }\n}\n","import { Environment } from \"../environment\";\nimport { createNullStorage } from \"../storage\";\n\nexport function buildNullEnvironment(): Environment {\n return {\n runtime: \"null\",\n send: () => undefined,\n getReferrer: () => null,\n getLocation: () => null,\n getUserAgent: () => null,\n generateUUID: () => \"\",\n storage: createNullStorage(),\n };\n}\n","export interface Storage {\n getItem: (key: string) => string | null;\n removeItem: (key: string) => void;\n setItem: (key: string, data: string) => void;\n}\n\nexport function createNullStorage(): Storage {\n return {\n getItem(): string | null {\n return null;\n },\n removeItem(): void {\n return;\n },\n setItem(): void {\n return;\n },\n };\n}\n","import { emit } from \"./emit/emit\";\nimport { createClientIdManager } from \"./client-id/client-id\";\nimport { createRelayEvent, RelayEvent } from \"./event/relay-event\";\nimport { version } from \"./version\";\nimport { createMeta, Meta, EventConfig } from \"./event/meta/meta\";\nimport { createListenerManager, EventCallback } from \"./listener/listener\";\nimport { createConfigManager, RelayConfig } from \"./config/config\";\nimport { createEnvironmentManager } from \"./environment/manager/manager\";\nimport { RelayPayload } from \"./relay-payload\";\n\n/**\n * Function that detaches an event callback.\n * @typedef {function} Off\n * @returns {void}\n */\nexport type Off = () => void;\n\n/**\n * Relay instance.\n * This object provides a comprehensive set of variables and methods for interacting with the Event API.\n */\ninterface Relay {\n /**\n * Sends an event to the Event API.\n * @param {string} type - event's type to be emitted.\n * @param {Record<string,any>} payload - payload to include within the event.\n * @returns {void}\n */\n emit: (type: string, payload: Record<string, any>) => void;\n\n /**\n * Gets the client-side generated meta object.\n * @param {string} type - event's type that will be included in the meta object.\n * @returns {Meta}\n */\n getMeta: (type: string) => Meta;\n\n /**\n * Attaches an event callback to either all event types or a specific one.\n * The callback set will be called when an event with the specified type is emitted.\n * It’s not possible to modify the payload of the event sent to Coveo using this listener.\n * Setting type as \"*\" will trigger the callback for all event types.\n * Returns the \"off\" function to detach the event callback.\n * @param {string} type - event's type.\n * @param {EventCallback} callback - callback that should be called when the event is emitted.\n * @returns {Off}\n */\n on: (type: string, callback: EventCallback) => Off;\n\n /**\n * Detach callback(s) from events.\n * If only the \"type\" parameter is set, all callbacks for the specified type will be removed.\n * @param {string} type - event's type.\n * @param {EventCallback} callback - callback that should be removed.\n * @returns {void}\n */\n off: (type: string, callback?: EventCallback) => void;\n\n /**\n * Updates Relay's configuration after its initialization.\n * @param {Partial<RelayConfig>} config - configuration that should be updated.\n * @returns {void}\n */\n updateConfig: (config: Partial<RelayConfig>) => void;\n\n /**\n * Current version of the Relay library.\n */\n version: string;\n}\n\n/**\n * Initializes the Relay library object.\n * @param {RelayConfig} initialConfig\n * @returns {Relay}\n */\nexport function createRelay(initialConfig: RelayConfig): Relay {\n const configManager = createConfigManager(initialConfig);\n const listenerManager = createListenerManager();\n const environmentManager = createEnvironmentManager(configManager);\n const clientIdManager = createClientIdManager(environmentManager);\n\n return {\n emit: (type: string, payload: Record<string, any>) => {\n const config = configManager.get();\n const environment = environmentManager.get();\n\n const event = createRelayEvent(\n type,\n payload,\n config,\n environment,\n clientIdManager,\n );\n\n return emit({\n config,\n environment,\n event,\n listenerManager,\n });\n },\n getMeta: (type: string) =>\n createMeta(\n type,\n configManager.get(),\n environmentManager.get(),\n clientIdManager,\n ),\n on: (type: string, callback: EventCallback) =>\n listenerManager.add({ type, callback }),\n off: (type: string, callback?: EventCallback) =>\n listenerManager.remove(type, callback),\n updateConfig: (config: Partial<RelayConfig>) =>\n configManager.update(config),\n version,\n };\n}\n\nexport type {\n Relay,\n Meta,\n EventConfig,\n EventCallback,\n RelayConfig,\n RelayPayload,\n RelayEvent,\n};\n","import { ClientIdManager } from \"../client-id/client-id\";\nimport { Environment } from \"../environment/environment\";\nimport { RelayPayload } from \"../relay-payload\";\nimport { RelayConfig } from \"../relay\";\nimport { createMeta, Meta } from \"./meta/meta\";\n\n/**\n * Defines the structure of a RelayEvent, extending the RelayPayload.\n */\nexport interface RelayEvent extends RelayPayload {\n /**\n * Read-only `meta` property of Meta type.\n */\n meta: Readonly<Meta>;\n}\n\nexport function createRelayEvent(\n type: string,\n payload: RelayPayload,\n config: RelayConfig,\n environment: Environment,\n clientIdManager: ClientIdManager,\n): Readonly<RelayEvent> {\n return {\n ...payload,\n meta: createMeta(type, config, environment, clientIdManager),\n };\n}\n","import { Environment } from \"../environment/environment\";\nimport { ListenerManager } from \"../listener/listener\";\nimport { RelayEvent } from \"../event/relay-event\";\nimport { RelayConfig } from \"../relay\";\n\nexport interface EmitParams {\n config: RelayConfig;\n environment: Environment;\n event: RelayEvent;\n listenerManager: ListenerManager;\n}\n\nexport function emit({\n config,\n environment,\n event,\n listenerManager,\n}: EmitParams) {\n const { url, token, mode } = config;\n const isEnabled = mode !== \"disabled\";\n\n if (isEnabled) {\n listenerManager.call(event);\n environment.send(url, token, event);\n }\n}\n"],"names":["REGEX","byteToHex","i","push","toString","slice","getRandomValues","rnds8","Uint8Array","native","randomUUID","crypto","bind","v4","options","buf","offset","rnds","random","rng","Error","length","arr","toLowerCase","unsafeStringify","createClientIdManager","environmentManager","getClientId","key","environment","get","storage","existingClientId","getItem","clientId","uuid","test","generateUUID","setItem","version","getSource","config","source","concat","createMeta","type","clientIdManager","getReferrer","getLocation","getUserAgent","eventConfig","trackingId","getEventConfig","Object","freeze","ts","Date","now","userAgent","referrer","location","createListenerManager","listeners","getListenerIndex","callback","findIndex","listener","remove","index","splice","removeOne","removeMultiple","add","call","event","forEach","isMatchesType","meta","e","console","error","pick","url","token","rest","mode","cookieManager","prefix","cookiePrefix","cookieArray","document","cookie","split","prettifyCookie","replace","lastIndexOf","substring","data","expire","domain","host","parts","join","getDomain","window","hostname","expireSection","getTime","toUTCString","domainSection","removeItem","this","createCookieManager","buildBrowserEnvironment","runtime","send","response","navigator","sendBeacon","Blob","JSON","stringify","messenger","isBrowser","sendMessage","message","postMessage","createExplorerMessenger","kind","href","uuidv4","localStorage","buildEnvironment","configManager","x","DOMException","name","localStorageAvailable","createRelay","initialConfig","_config","update","updatedConfig","createConfigManager","listenerManager","createEnvironmentManager","emit","payload","createRelayEvent","getMeta","on","off","updateConfig"],"mappings":"AAAA,IAAAA,EAAe,2JCCf,MAAMC,EAAY,GAClB,IAAK,IAAIC,EAAI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AUxG,GACRD,EACEC,EACAwF,EAAcvG,MACdJ,EAAmBI,MACnBgB,GAEJwG,GAAI,CAACzG,EAAcmB,IACjBgF,EAAgBxE,IAAI,CAAE3B,OAAMmB,aAC9BuF,IAAK,CAAC1G,EAAcmB,IAClBgF,EAAgB7E,OAAOtB,EAAMmB,GAC/BwF,aAAe/G,GACb4F,EAAcQ,OAAOpG,GACvBF,UAEJ","x_google_ignoreList":[0,1,2,3,4,6,13]}
1
+ {"version":3,"file":"relay.min.js","sources":["../../../../node_modules/.pnpm/uuid@11.0.5/node_modules/uuid/dist/esm-browser/regex.js","../../../../node_modules/.pnpm/uuid@11.0.5/node_modules/uuid/dist/esm-browser/stringify.js","../../../../node_modules/.pnpm/uuid@11.0.5/node_modules/uuid/dist/esm-browser/rng.js","../../../../node_modules/.pnpm/uuid@11.0.5/node_modules/uuid/dist/esm-browser/native.js","../../../../node_modules/.pnpm/uuid@11.0.5/node_modules/uuid/dist/esm-browser/v4.js","../../../src/client-id/client-id.ts","../../../../node_modules/.pnpm/uuid@11.0.5/node_modules/uuid/dist/esm-browser/validate.js","../../../src/version.ts","../../../src/event/meta/meta.ts","../../../src/listener/listener.ts","../../../src/config/config.ts","../../../src/environment/browser/storage/cookie.ts","../../../src/environment/browser/browser.ts","../../../../node_modules/.pnpm/@coveo+explorer-messenger@0.4.0/node_modules/@coveo/explorer-messenger/dist/messenger.js","../../../src/environment/browser/storage/storage.ts","../../../src/environment/manager/manager.ts","../../../src/environment/browser/storage/availability.ts","../../../src/environment/null/null.ts","../../../src/environment/storage.ts","../../../src/relay.ts","../../../src/event/relay-event.ts","../../../src/emit/emit.ts"],"sourcesContent":["export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;\n","import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;\n","import { validate } from \"uuid\";\nimport { EnvironmentManager } from \"../environment/manager/manager\";\n\nexport interface ClientIdManager {\n getClientId: () => string;\n}\n\nexport function createClientIdManager(\n environmentManager: EnvironmentManager,\n): ClientIdManager {\n return {\n getClientId: () => {\n const key = \"visitorId\";\n const environment = environmentManager.get();\n const storage = environment.storage;\n\n const existingClientId = storage.getItem(key);\n const clientId =\n existingClientId && validate(existingClientId)\n ? existingClientId\n : environment.generateUUID();\n storage.setItem(key, clientId);\n return clientId;\n },\n };\n}\n","import REGEX from './regex.js';\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\nexport default validate;\n","export const version = \"process.env.VERSION\";\n","import { ClientIdManager } from \"../../client-id/client-id\";\nimport { Environment } from \"../../environment/environment\";\nimport { RelayConfig } from \"../../config/config\";\nimport { version } from \"../../version\";\n\n/**\n * The `EventConfig` object provides additonal information for the configuration associated with the event.\n */\nexport interface EventConfig {\n /**\n * The unique identifier of a web property. See [What's a tracking ID?](https://docs.coveo.com/en/n8tg0567/).\n */\n trackingId: string;\n}\n\n/**\n * The `Meta` object provides a structured representation of metadata associated with an emitted event.\n * This object is auto-populated by Relay.\n */\nexport interface Meta {\n /**\n * Event's type that was emitted.\n */\n type: string;\n\n /**\n * Configuration associated with the event.\n */\n config: EventConfig;\n\n /**\n * Timestamp when the event was emitted.\n */\n ts: number;\n\n /**\n * Names and versions of the client side libraries which built and emitted this event.\n */\n source: string[];\n\n /**\n * Persistent unique identifier of a device.\n */\n clientId: string;\n\n /**\n * Browser Navigator's [user agent](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent) property if set.\n */\n userAgent: string | null;\n\n /**\n * Browser Document's [referrer](https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer) property if set.\n */\n referrer: string | null;\n\n /**\n * Browser Location's [href](https://developer.mozilla.org/en-US/docs/Web/API/Location/href) property if set.\n */\n location: string | null;\n}\n\nfunction getEventConfig(config: RelayConfig): EventConfig {\n const { trackingId } = config;\n return { trackingId };\n}\n\nfunction getSource(config: RelayConfig): string[] {\n return (config.source || []).concat([`relay@${version}`]);\n}\n\nexport function createMeta(\n type: string,\n config: RelayConfig,\n environment: Environment,\n clientIdManager: ClientIdManager,\n): Readonly<Meta> {\n const { getReferrer, getLocation, getUserAgent } = environment;\n const eventConfig = getEventConfig(config);\n const clientId = clientIdManager.getClientId();\n\n return Object.freeze<Meta>({\n type,\n config: eventConfig,\n ts: Date.now(),\n source: getSource(config),\n clientId,\n userAgent: getUserAgent(),\n referrer: getReferrer(),\n location: getLocation(),\n });\n}\n","import { RelayEvent } from \"../event/relay-event\";\n\nconst ANY_EVENT_TYPE = \"*\";\n\n/**\n * Callback to perform an action when a specified event is emitted.\n * @typedef {function} EventCallback\n * @param {RelayEvent} event - the Relay event payload that triggered the callback.\n * @returns {void}\n */\nexport type EventCallback = (event: RelayEvent) => void;\n\ninterface Listener {\n type: string;\n callback: EventCallback;\n}\n\nexport interface ListenerManager {\n add: (listener: Listener) => () => void;\n call: (event: RelayEvent) => void;\n remove: (type: string, callback?: EventCallback) => void;\n}\n\nexport function createListenerManager(): ListenerManager {\n const listeners: Listener[] = [];\n\n function getListenerIndex({ type, callback }: Listener): number {\n return listeners.findIndex(\n (listener) => listener.type === type && listener.callback === callback,\n );\n }\n\n function isMatchesType(listener: Listener, type: string): boolean {\n return listener.type === \"*\" || type === listener.type;\n }\n\n function add(listener: Listener): () => void {\n if (getListenerIndex(listener) < 0) {\n listeners.push(listener);\n }\n return () => remove(listener.type, listener.callback);\n }\n\n function call(event: RelayEvent) {\n listeners.forEach((listener) => {\n if (isMatchesType(listener, event.meta.type)) {\n try {\n listener.callback(event);\n } catch (e) {\n console.error(e);\n }\n }\n });\n }\n\n function removeMultiple(type: string) {\n if (type === ANY_EVENT_TYPE) {\n listeners.length = 0;\n } else {\n for (let i = listeners.length - 1; i >= 0; i--) {\n if (listeners[i].type === type) {\n listeners.splice(i, 1);\n }\n }\n }\n }\n\n function removeOne(listener: Listener) {\n const index = getListenerIndex(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n }\n\n function remove(type: string, callback?: EventCallback) {\n if (callback) {\n removeOne({ type, callback });\n } else {\n removeMultiple(type);\n }\n }\n\n return {\n add,\n call,\n remove,\n };\n}\n","import { Environment } from \"../environment/environment\";\n\nexport type CustomEnvironment = Pick<\n Environment,\n | \"generateUUID\"\n | \"getLocation\"\n | \"getReferrer\"\n | \"getUserAgent\"\n | \"send\"\n | \"storage\"\n>;\n\n/**\n * The `RelayConfig` object defines the configuration options for initializing a Relay instance.\n */\nexport interface RelayConfig {\n /**\n * Endpoint defined to communicate with the Event API.\n */\n url: string;\n\n /**\n * Token to authorize the access to the Event API endpoint.\n */\n token: string;\n\n /**\n * The unique identifier of a web property. See [What's a tracking ID?](https://docs.coveo.com/en/n8tg0567/).\n */\n trackingId: string;\n\n /**\n * Defines the library mode. The available modes are `emit` and `disabled`.\n * `emit` sends analytics events to Coveo to be stored.\n * `disabled` prevents the emission of events and does not trigger callbacks.\n * @default emit\n */\n mode?: \"emit\" | \"disabled\";\n\n /**\n * Optionally allows a Relay integration to specify the name(s) of software package(s) relay is\n * being called from. These names will be transmitted with each event, along with Relay's own\n * version. The recommendation is to specify them using a 'softwarename@softwareversion' string.\n */\n source?: string[];\n\n /**\n * Specifies a custom environment for Relay, allowing integrations to override the default behavior.\n * This is useful when Relay runs in unsupported or specialized contexts that require custom handling.\n */\n environment?: CustomEnvironment;\n}\n\nexport interface ConfigManager {\n get: () => Readonly<RelayConfig>;\n update: (updatedConfig: Partial<RelayConfig>) => void;\n}\n\nfunction pick({\n url,\n token,\n trackingId,\n ...rest\n}: RelayConfig): Readonly<RelayConfig> {\n return Object.freeze({\n url,\n token,\n trackingId,\n ...(!!rest.mode && { mode: rest.mode }),\n ...(!!rest.source && { source: rest.source }),\n ...(!!rest.environment && { environment: rest.environment }),\n });\n}\n\nexport function createConfigManager(\n initialConfig: RelayConfig,\n): Readonly<ConfigManager> {\n let _config: Readonly<RelayConfig> = pick(initialConfig);\n\n return {\n get: () => _config,\n update: (updatedConfig: Partial<RelayConfig>) => {\n _config = pick({ ..._config, ...updatedConfig });\n },\n };\n}\n","export interface CookieManager {\n getItem: (key: string) => string | null;\n removeItem: (key: string) => void;\n setItem: (key: string, data: string, expire: number) => void;\n}\n\nexport const cookieManager: CookieManager = createCookieManager();\n\nfunction createCookieManager(): CookieManager {\n const prefix = \"coveo_\";\n const getDomain = (host: string) => {\n const parts = host.split(\".\").slice(-2);\n return parts.length == 2 ? parts.join(\".\") : \"\";\n };\n\n return {\n getItem(key: string): string | null {\n const cookiePrefix = `${prefix}${key}=`;\n const cookieArray = document.cookie.split(\";\");\n for (const cookie of cookieArray) {\n const prettifyCookie = cookie.replace(/^\\s+/, \"\");\n if (prettifyCookie.lastIndexOf(cookiePrefix, 0) === 0) {\n return prettifyCookie.substring(\n cookiePrefix.length,\n prettifyCookie.length,\n );\n }\n }\n return null;\n },\n setItem(key: string, data: string, expire: number): void {\n const domain = getDomain(window.location.hostname);\n const expireSection = `;expires=${new Date(\n new Date().getTime() + expire,\n ).toUTCString()}`;\n const domainSection = domain ? `;domain=${domain}` : \"\";\n document.cookie = `${prefix}${key}=${data}${expireSection}${domainSection};path=/;SameSite=Lax`;\n },\n\n removeItem(key: string): void {\n this.setItem(key, \"\", -1);\n },\n };\n}\n","import { createExplorerMessenger } from \"@coveo/explorer-messenger\";\nimport { Environment } from \"../environment\";\nimport { createBrowserStorage } from \"./storage/storage\";\nimport { RelayEvent } from \"../../event/relay-event\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nfunction getReferrer() {\n const referrer = document.referrer;\n\n return referrer === \"\" ? null : referrer;\n}\n\nexport function buildBrowserEnvironment(): Environment {\n return {\n runtime: \"browser\",\n send: (url: string, token: string, event: RelayEvent) => {\n const response = navigator.sendBeacon(\n `${url}?access_token=${token}`,\n new Blob([JSON.stringify([event])], {\n type: \"application/json\",\n }),\n );\n\n const messenger = createExplorerMessenger();\n messenger.sendMessage({ kind: \"EVENT_PROTOCOL\", event, url, token });\n\n if (!response) {\n throw new Error(\n `Failed to send the event(s) because the payload size exceeded the maximum allowed size (32 KB). Please contact support if the problem persists.`,\n );\n }\n },\n getReferrer: () => getReferrer(),\n getLocation: () => window.location.href,\n getUserAgent: () => navigator.userAgent,\n generateUUID: () => uuidv4(),\n storage: createBrowserStorage(),\n };\n}\n","function createExplorerMessenger() {\n const isBrowser = typeof window !== \"undefined\";\n return {\n sendMessage(message) {\n isBrowser && window.postMessage(message, \"*\");\n }\n };\n}\nexport {\n createExplorerMessenger\n};\n","import { Storage } from \"../../storage\";\nimport { cookieManager } from \"./cookie\";\n\nexport function createBrowserStorage(): Storage {\n return {\n getItem(key: string): string | null {\n return cookieManager.getItem(key) || localStorage.getItem(key);\n },\n\n removeItem(key: string): void {\n cookieManager.removeItem(key);\n localStorage.removeItem(key);\n },\n\n setItem(key: string, data: string): void {\n const oneYear = 31556952000;\n localStorage.setItem(key, data);\n cookieManager.setItem(key, data, oneYear);\n },\n };\n}\n","import { ConfigManager } from \"../../config/config\";\nimport { buildBrowserEnvironment } from \"../browser/browser\";\nimport { localStorageAvailable } from \"../browser/storage/availability\";\nimport { Environment } from \"../environment\";\nimport { buildNullEnvironment } from \"../null/null\";\nexport interface EnvironmentManager {\n get: () => Readonly<Environment>;\n}\n\nfunction buildEnvironment(configManager: ConfigManager): Environment {\n const active = configManager.get().mode !== \"disabled\";\n\n const environmentFromConfig = configManager.get().environment;\n\n if (active && environmentFromConfig) {\n return { ...environmentFromConfig, runtime: \"custom\" };\n }\n\n if (active && isBrowser() && localStorageAvailable()) {\n return buildBrowserEnvironment();\n }\n\n return buildNullEnvironment();\n}\n\nfunction isBrowser() {\n try {\n return typeof window === \"object\";\n } catch {\n return false;\n }\n}\n\nexport function createEnvironmentManager(\n configManager: ConfigManager,\n): Readonly<EnvironmentManager> {\n return {\n get: () => Object.freeze(buildEnvironment(configManager)),\n };\n}\n","// From: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage\nexport function localStorageAvailable() {\n try {\n const x = \"__storage_test__\";\n localStorage.setItem(x, x);\n localStorage.removeItem(x);\n return true;\n } catch (e) {\n return (\n e instanceof DOMException &&\n e.name === \"QuotaExceededError\" &&\n // acknowledge QuotaExceededError only if there's something already stored\n localStorage &&\n localStorage.length !== 0\n );\n }\n}\n","import { Environment } from \"../environment\";\nimport { createNullStorage } from \"../storage\";\n\nexport function buildNullEnvironment(): Environment {\n return {\n runtime: \"null\",\n send: () => undefined,\n getReferrer: () => null,\n getLocation: () => null,\n getUserAgent: () => null,\n generateUUID: () => \"\",\n storage: createNullStorage(),\n };\n}\n","export interface Storage {\n getItem: (key: string) => string | null;\n removeItem: (key: string) => void;\n setItem: (key: string, data: string) => void;\n}\n\nexport function createNullStorage(): Storage {\n return {\n getItem(): string | null {\n return null;\n },\n removeItem(): void {\n return;\n },\n setItem(): void {\n return;\n },\n };\n}\n","import { emit } from \"./emit/emit\";\nimport { createClientIdManager } from \"./client-id/client-id\";\nimport { createRelayEvent, RelayEvent } from \"./event/relay-event\";\nimport { version } from \"./version\";\nimport { createMeta, Meta, EventConfig } from \"./event/meta/meta\";\nimport { createListenerManager, EventCallback } from \"./listener/listener\";\nimport {\n createConfigManager,\n RelayConfig,\n CustomEnvironment,\n} from \"./config/config\";\nimport { createEnvironmentManager } from \"./environment/manager/manager\";\nimport { RelayPayload } from \"./relay-payload\";\n\n/**\n * Function that detaches an event callback.\n * @typedef {function} Off\n * @returns {void}\n */\nexport type Off = () => void;\n\n/**\n * Relay instance.\n * This object provides a comprehensive set of variables and methods for interacting with the Event API.\n */\ninterface Relay {\n /**\n * Sends an event to the Event API.\n * @param {string} type - event's type to be emitted.\n * @param {Record<string,any>} payload - payload to include within the event.\n * @returns {void}\n */\n emit: (type: string, payload: Record<string, any>) => void;\n\n /**\n * Gets the client-side generated meta object.\n * @param {string} type - event's type that will be included in the meta object.\n * @returns {Meta}\n */\n getMeta: (type: string) => Meta;\n\n /**\n * Attaches an event callback to either all event types or a specific one.\n * The callback set will be called when an event with the specified type is emitted.\n * It’s not possible to modify the payload of the event sent to Coveo using this listener.\n * Setting type as \"*\" will trigger the callback for all event types.\n * Returns the \"off\" function to detach the event callback.\n * @param {string} type - event's type.\n * @param {EventCallback} callback - callback that should be called when the event is emitted.\n * @returns {Off}\n */\n on: (type: string, callback: EventCallback) => Off;\n\n /**\n * Detach callback(s) from events.\n * If only the \"type\" parameter is set, all callbacks for the specified type will be removed.\n * @param {string} type - event's type.\n * @param {EventCallback} callback - callback that should be removed.\n * @returns {void}\n */\n off: (type: string, callback?: EventCallback) => void;\n\n /**\n * Updates Relay's configuration after its initialization.\n * @param {Partial<RelayConfig>} config - configuration that should be updated.\n * @returns {void}\n */\n updateConfig: (config: Partial<RelayConfig>) => void;\n\n /**\n * Current version of the Relay library.\n */\n version: string;\n}\n\n/**\n * Initializes the Relay library object.\n * @param {RelayConfig} initialConfig\n * @returns {Relay}\n */\nexport function createRelay(initialConfig: RelayConfig): Relay {\n const configManager = createConfigManager(initialConfig);\n const listenerManager = createListenerManager();\n const environmentManager = createEnvironmentManager(configManager);\n const clientIdManager = createClientIdManager(environmentManager);\n\n return {\n emit: (type: string, payload: Record<string, any>) => {\n const config = configManager.get();\n const environment = environmentManager.get();\n\n const event = createRelayEvent(\n type,\n payload,\n config,\n environment,\n clientIdManager,\n );\n\n return emit({\n config,\n environment,\n event,\n listenerManager,\n });\n },\n getMeta: (type: string) =>\n createMeta(\n type,\n configManager.get(),\n environmentManager.get(),\n clientIdManager,\n ),\n on: (type: string, callback: EventCallback) =>\n listenerManager.add({ type, callback }),\n off: (type: string, callback?: EventCallback) =>\n listenerManager.remove(type, callback),\n updateConfig: (config: Partial<RelayConfig>) =>\n configManager.update(config),\n version,\n };\n}\n\nexport type {\n Relay,\n Meta,\n EventConfig,\n EventCallback,\n RelayConfig,\n RelayPayload,\n RelayEvent,\n CustomEnvironment,\n};\n","import { ClientIdManager } from \"../client-id/client-id\";\nimport { Environment } from \"../environment/environment\";\nimport { RelayPayload } from \"../relay-payload\";\nimport { RelayConfig } from \"../relay\";\nimport { createMeta, Meta } from \"./meta/meta\";\n\n/**\n * Defines the structure of a RelayEvent, extending the RelayPayload.\n */\nexport interface RelayEvent extends RelayPayload {\n /**\n * Read-only `meta` property of Meta type.\n */\n meta: Readonly<Meta>;\n}\n\nexport function createRelayEvent(\n type: string,\n payload: RelayPayload,\n config: RelayConfig,\n environment: Environment,\n clientIdManager: ClientIdManager,\n): Readonly<RelayEvent> {\n return {\n ...payload,\n meta: createMeta(type, config, environment, clientIdManager),\n };\n}\n","import { Environment } from \"../environment/environment\";\nimport { ListenerManager } from \"../listener/listener\";\nimport { RelayEvent } from \"../event/relay-event\";\nimport { RelayConfig } from \"../relay\";\n\nexport interface EmitParams {\n config: RelayConfig;\n environment: Environment;\n event: RelayEvent;\n listenerManager: ListenerManager;\n}\n\nexport function emit({\n config,\n environment,\n event,\n listenerManager,\n}: EmitParams) {\n const { url, token, mode } = config;\n const isEnabled = mode !== \"disabled\";\n\n if (isEnabled) {\n listenerManager.call(event);\n environment.send(url, token, event);\n }\n}\n"],"names":["REGEX","byteToHex","i","push","toString","slice","getRandomValues","rnds8","Uint8Array","native","randomUUID","crypto","bind","v4","options","buf","offset","rnds","random","rng","Error","length","arr","toLowerCase","unsafeStringify","createClientIdManager","environmentManager","getClientId","key","environment","get","storage","existingClientId","getItem","clientId","uuid","test","generateUUID","setItem","version","getSource","config","source","concat","createMeta","type","clientIdManager","getReferrer","getLocation","getUserAgent","eventConfig","trackingId","getEventConfig","Object","freeze","ts","Date","now","userAgent","referrer","location","createListenerManager","listeners","getListenerIndex","callback","findIndex","listener","remove","index","splice","removeOne","removeMultiple","add","call","event","forEach","isMatchesType","meta","e","console","error","pick","url","token","rest","mode","cookieManager","prefix","cookiePrefix","cookieArray","document","cookie","split","prettifyCookie","replace","lastIndexOf","substring","data","expire","domain","host","parts","join","getDomain","window","hostname","expireSection","getTime","toUTCString","domainSection","removeItem","this","createCookieManager","buildBrowserEnvironment","runtime","send","response","navigator","sendBeacon","Blob","JSON","stringify","messenger","isBrowser","sendMessage","message","postMessage","createExplorerMessenger","kind","href","uuidv4","localStorage","buildEnvironment","configManager","active","environmentFromConfig","x","DOMException","name","localStorageAvailable","createRelay","initialConfig","_config","update","updatedConfig","createConfigManager","listenerManager","createEnvironmentManager","emit","payload","createRelayEvent","getMeta","on","off","updateConfig"],"mappings":"AAAA,IAAAA,EAAe,2JCCf,MAAMC,EAAY,GAClB,IAAK,IAAIC,EAAI,EAAGA,EAAI,MAAOA,EACvBD,EAAUE,MAAMD,EAAI,KAAOE,SAAS,IAAIC,MAAM,ICHlD,IAAIC,EACJ,MAAMC,EAAQ,IAAIC,WAAW,ICA7B,IAAeC,EAAA,CAAEC,WADoB,oBAAXC,QAA0BA,OAAOD,YAAcC,OAAOD,WAAWE,KAAKD,SCGhG,SAASE,EAAGC,EAASC,EAAKC,GACtB,GAAIP,EAAOC,aAAuBI,EAC9B,OAAOL,EAAOC,aAGlB,MAAMO,GADNH,EAAUA,GAAW,CAAE,GACFI,QAAUJ,EAAQK,SFN5B,WACX,IAAKb,EAAiB,CAClB,GAAsB,oBAAXK,SAA2BA,OAAOL,gBACzC,MAAM,IAAIc,MAAM,4GAEpBd,EAAkBK,OAAOL,gBAAgBM,KAAKD,OACtD,CACI,OAAOL,EAAgBC,EAC3B,CEFsDY,GAClD,GAAIF,EAAKI,OAAS,GACd,MAAM,IAAID,MAAM,qCAcpB,OAZAH,EAAK,GAAgB,GAAVA,EAAK,GAAa,GAC7BA,EAAK,GAAgB,GAAVA,EAAK,GAAa,IHR1B,SAAyBK,EAAKN,EAAS,GAC1C,OAAQf,EAAUqB,EAAIN,EAAS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G,IAAK,IAAMuB,OAAOC,OAAO8E,EAAiBC,IAE9C,CI4C6Bc,CAAyBd,GAC9CvF,EAAkBrB,EAAsBC,GAE9C,MAAO,CACL0H,KAAM,CAACvG,EAAcwG,KACnB,MAAM5G,EAAS4F,EAAcvG,MACvBD,EAAcH,EAAmBI,MAEjC4C,EC3EN,SACJ7B,EACAwG,EACA5G,EACAZ,EACAiB,GAEA,MAAO,IACFuG,EACHxE,KAAMjC,EAAWC,EAAMJ,EAAQZ,EAAaiB,GAEhD,CDgEoBwG,CACZzG,EACAwG,EACA5G,EACAZ,EACAiB,GAGF,OEvFA,UAAeL,OACnBA,EAAMZ,YACNA,EAAW6C,MACXA,EAAKwE,gBACLA,IAEA,MAAMhE,IAAEA,EAAGC,MAAEA,EAAKE,KAAEA,GAAS5C,EACF,aAAT4C,IAGhB6D,EAAgBzE,KAAKC,GACrB7C,EAAYsF,KAAKjC,EAAKC,EAAOT,GAEjC,CF0Ea0E,CAAK,CACV3G,SACAZ,cACA6C,QACAwE,mBACA,EAEJK,QAAU1G,GACRD,EACEC,EACAwF,EAAcvG,MACdJ,EAAmBI,MACnBgB,GAEJ0G,GAAI,CAAC3G,EAAcmB,IACjBkF,EAAgB1E,IAAI,CAAE3B,OAAMmB,aAC9ByF,IAAK,CAAC5G,EAAcmB,IAClBkF,EAAgB/E,OAAOtB,EAAMmB,GAC/B0F,aAAejH,GACb4F,EAAcU,OAAOtG,GACvBF,UAEJ","x_google_ignoreList":[0,1,2,3,4,6,13]}
@@ -1,3 +1,5 @@
1
+ import { Environment } from "../environment/environment";
2
+ export type CustomEnvironment = Pick<Environment, "generateUUID" | "getLocation" | "getReferrer" | "getUserAgent" | "send" | "storage">;
1
3
  /**
2
4
  * The `RelayConfig` object defines the configuration options for initializing a Relay instance.
3
5
  */
@@ -27,6 +29,11 @@ export interface RelayConfig {
27
29
  * version. The recommendation is to specify them using a 'softwarename@softwareversion' string.
28
30
  */
29
31
  source?: string[];
32
+ /**
33
+ * Specifies a custom environment for Relay, allowing integrations to override the default behavior.
34
+ * This is useful when Relay runs in unsupported or specialized contexts that require custom handling.
35
+ */
36
+ environment?: CustomEnvironment;
30
37
  }
31
38
  export interface ConfigManager {
32
39
  get: () => Readonly<RelayConfig>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,MAAM,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACvD;AAiBD,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,WAAW,GACzB,QAAQ,CAAC,aAAa,CAAC,CASzB"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,WAAW,EACT,cAAc,GACd,aAAa,GACb,aAAa,GACb,cAAc,GACd,MAAM,GACN,SAAS,CACZ,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,MAAM,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACvD;AAkBD,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,WAAW,GACzB,QAAQ,CAAC,aAAa,CAAC,CASzB"}
@@ -47,7 +47,7 @@
47
47
  "fileName": "event/meta/meta.ts",
48
48
  "line": 13,
49
49
  "character": 2,
50
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L13"
50
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L13"
51
51
  }
52
52
  ],
53
53
  "type": {
@@ -69,7 +69,7 @@
69
69
  "fileName": "event/meta/meta.ts",
70
70
  "line": 9,
71
71
  "character": 17,
72
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L9"
72
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L9"
73
73
  }
74
74
  ]
75
75
  },
@@ -115,7 +115,7 @@
115
115
  "fileName": "event/meta/meta.ts",
116
116
  "line": 44,
117
117
  "character": 2,
118
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L44"
118
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L44"
119
119
  }
120
120
  ],
121
121
  "type": {
@@ -142,7 +142,7 @@
142
142
  "fileName": "event/meta/meta.ts",
143
143
  "line": 29,
144
144
  "character": 2,
145
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L29"
145
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L29"
146
146
  }
147
147
  ],
148
148
  "type": {
@@ -171,7 +171,7 @@
171
171
  "fileName": "event/meta/meta.ts",
172
172
  "line": 59,
173
173
  "character": 2,
174
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L59"
174
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L59"
175
175
  }
176
176
  ],
177
177
  "type": {
@@ -207,7 +207,7 @@
207
207
  "fileName": "event/meta/meta.ts",
208
208
  "line": 54,
209
209
  "character": 2,
210
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L54"
210
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L54"
211
211
  }
212
212
  ],
213
213
  "type": {
@@ -243,7 +243,7 @@
243
243
  "fileName": "event/meta/meta.ts",
244
244
  "line": 39,
245
245
  "character": 2,
246
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L39"
246
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L39"
247
247
  }
248
248
  ],
249
249
  "type": {
@@ -273,7 +273,7 @@
273
273
  "fileName": "event/meta/meta.ts",
274
274
  "line": 34,
275
275
  "character": 2,
276
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L34"
276
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L34"
277
277
  }
278
278
  ],
279
279
  "type": {
@@ -300,7 +300,7 @@
300
300
  "fileName": "event/meta/meta.ts",
301
301
  "line": 24,
302
302
  "character": 2,
303
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L24"
303
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L24"
304
304
  }
305
305
  ],
306
306
  "type": {
@@ -327,7 +327,7 @@
327
327
  "fileName": "event/meta/meta.ts",
328
328
  "line": 49,
329
329
  "character": 2,
330
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L49"
330
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L49"
331
331
  }
332
332
  ],
333
333
  "type": {
@@ -365,7 +365,7 @@
365
365
  "fileName": "event/meta/meta.ts",
366
366
  "line": 20,
367
367
  "character": 17,
368
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/meta/meta.ts#L20"
368
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/meta/meta.ts#L20"
369
369
  }
370
370
  ]
371
371
  },
@@ -401,9 +401,9 @@
401
401
  "sources": [
402
402
  {
403
403
  "fileName": "relay.ts",
404
- "line": 29,
404
+ "line": 33,
405
405
  "character": 2,
406
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L29"
406
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L33"
407
407
  }
408
408
  ],
409
409
  "type": {
@@ -417,9 +417,9 @@
417
417
  "sources": [
418
418
  {
419
419
  "fileName": "relay.ts",
420
- "line": 29,
420
+ "line": 33,
421
421
  "character": 8,
422
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L29"
422
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L33"
423
423
  }
424
424
  ],
425
425
  "signatures": [
@@ -441,9 +441,9 @@
441
441
  "sources": [
442
442
  {
443
443
  "fileName": "relay.ts",
444
- "line": 29,
444
+ "line": 33,
445
445
  "character": 8,
446
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L29"
446
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L33"
447
447
  }
448
448
  ],
449
449
  "parameters": [
@@ -483,7 +483,7 @@
483
483
  "type": {
484
484
  "type": "reference",
485
485
  "target": {
486
- "sourceFileName": "../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es5.d.ts",
486
+ "sourceFileName": "../../node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/lib.es5.d.ts",
487
487
  "qualifiedName": "Record"
488
488
  },
489
489
  "typeArguments": [
@@ -527,9 +527,9 @@
527
527
  "sources": [
528
528
  {
529
529
  "fileName": "relay.ts",
530
- "line": 36,
530
+ "line": 40,
531
531
  "character": 2,
532
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L36"
532
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L40"
533
533
  }
534
534
  ],
535
535
  "type": {
@@ -543,9 +543,9 @@
543
543
  "sources": [
544
544
  {
545
545
  "fileName": "relay.ts",
546
- "line": 36,
546
+ "line": 40,
547
547
  "character": 11,
548
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L36"
548
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L40"
549
549
  }
550
550
  ],
551
551
  "signatures": [
@@ -567,9 +567,9 @@
567
567
  "sources": [
568
568
  {
569
569
  "fileName": "relay.ts",
570
- "line": 36,
570
+ "line": 40,
571
571
  "character": 11,
572
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L36"
572
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L40"
573
573
  }
574
574
  ],
575
575
  "parameters": [
@@ -621,9 +621,9 @@
621
621
  "sources": [
622
622
  {
623
623
  "fileName": "relay.ts",
624
- "line": 57,
624
+ "line": 61,
625
625
  "character": 2,
626
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L57"
626
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L61"
627
627
  }
628
628
  ],
629
629
  "type": {
@@ -637,9 +637,9 @@
637
637
  "sources": [
638
638
  {
639
639
  "fileName": "relay.ts",
640
- "line": 57,
640
+ "line": 61,
641
641
  "character": 7,
642
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L57"
642
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L61"
643
643
  }
644
644
  ],
645
645
  "signatures": [
@@ -661,9 +661,9 @@
661
661
  "sources": [
662
662
  {
663
663
  "fileName": "relay.ts",
664
- "line": 57,
664
+ "line": 61,
665
665
  "character": 7,
666
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L57"
666
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L61"
667
667
  }
668
668
  ],
669
669
  "parameters": [
@@ -736,9 +736,9 @@
736
736
  "sources": [
737
737
  {
738
738
  "fileName": "relay.ts",
739
- "line": 48,
739
+ "line": 52,
740
740
  "character": 2,
741
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L48"
741
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L52"
742
742
  }
743
743
  ],
744
744
  "type": {
@@ -752,9 +752,9 @@
752
752
  "sources": [
753
753
  {
754
754
  "fileName": "relay.ts",
755
- "line": 48,
755
+ "line": 52,
756
756
  "character": 6,
757
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L48"
757
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L52"
758
758
  }
759
759
  ],
760
760
  "signatures": [
@@ -776,9 +776,9 @@
776
776
  "sources": [
777
777
  {
778
778
  "fileName": "relay.ts",
779
- "line": 48,
779
+ "line": 52,
780
780
  "character": 6,
781
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L48"
781
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L52"
782
782
  }
783
783
  ],
784
784
  "parameters": [
@@ -851,9 +851,9 @@
851
851
  "sources": [
852
852
  {
853
853
  "fileName": "relay.ts",
854
- "line": 64,
854
+ "line": 68,
855
855
  "character": 2,
856
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L64"
856
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L68"
857
857
  }
858
858
  ],
859
859
  "type": {
@@ -867,9 +867,9 @@
867
867
  "sources": [
868
868
  {
869
869
  "fileName": "relay.ts",
870
- "line": 64,
870
+ "line": 68,
871
871
  "character": 16,
872
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L64"
872
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L68"
873
873
  }
874
874
  ],
875
875
  "signatures": [
@@ -891,9 +891,9 @@
891
891
  "sources": [
892
892
  {
893
893
  "fileName": "relay.ts",
894
- "line": 64,
894
+ "line": 68,
895
895
  "character": 16,
896
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L64"
896
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L68"
897
897
  }
898
898
  ],
899
899
  "parameters": [
@@ -914,7 +914,7 @@
914
914
  "type": {
915
915
  "type": "reference",
916
916
  "target": {
917
- "sourceFileName": "../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es5.d.ts",
917
+ "sourceFileName": "../../node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/lib.es5.d.ts",
918
918
  "qualifiedName": "Partial"
919
919
  },
920
920
  "typeArguments": [
@@ -956,9 +956,9 @@
956
956
  "sources": [
957
957
  {
958
958
  "fileName": "relay.ts",
959
- "line": 69,
959
+ "line": 73,
960
960
  "character": 2,
961
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L69"
961
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L73"
962
962
  }
963
963
  ],
964
964
  "type": {
@@ -983,9 +983,9 @@
983
983
  "sources": [
984
984
  {
985
985
  "fileName": "relay.ts",
986
- "line": 22,
986
+ "line": 26,
987
987
  "character": 10,
988
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L22"
988
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L26"
989
989
  }
990
990
  ]
991
991
  },
@@ -1012,6 +1012,37 @@
1012
1012
  ]
1013
1013
  },
1014
1014
  "children": [
1015
+ {
1016
+ "id": 53,
1017
+ "name": "environment",
1018
+ "variant": "declaration",
1019
+ "kind": 1024,
1020
+ "flags": {
1021
+ "isOptional": true
1022
+ },
1023
+ "comment": {
1024
+ "summary": [
1025
+ {
1026
+ "kind": "text",
1027
+ "text": "Specifies a custom environment for Relay, allowing integrations to override the default behavior.\nThis is useful when Relay runs in unsupported or specialized contexts that require custom handling."
1028
+ }
1029
+ ]
1030
+ },
1031
+ "sources": [
1032
+ {
1033
+ "fileName": "config/config.ts",
1034
+ "line": 51,
1035
+ "character": 2,
1036
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/config/config.ts#L51"
1037
+ }
1038
+ ],
1039
+ "type": {
1040
+ "type": "reference",
1041
+ "target": -1,
1042
+ "name": "CustomEnvironment",
1043
+ "package": "@coveo/relay"
1044
+ }
1045
+ },
1015
1046
  {
1016
1047
  "id": 51,
1017
1048
  "name": "mode",
@@ -1074,9 +1105,9 @@
1074
1105
  "sources": [
1075
1106
  {
1076
1107
  "fileName": "config/config.ts",
1077
- "line": 26,
1108
+ "line": 38,
1078
1109
  "character": 2,
1079
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/config/config.ts#L26"
1110
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/config/config.ts#L38"
1080
1111
  }
1081
1112
  ],
1082
1113
  "type": {
@@ -1112,9 +1143,9 @@
1112
1143
  "sources": [
1113
1144
  {
1114
1145
  "fileName": "config/config.ts",
1115
- "line": 33,
1146
+ "line": 45,
1116
1147
  "character": 2,
1117
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/config/config.ts#L33"
1148
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/config/config.ts#L45"
1118
1149
  }
1119
1150
  ],
1120
1151
  "type": {
@@ -1142,9 +1173,9 @@
1142
1173
  "sources": [
1143
1174
  {
1144
1175
  "fileName": "config/config.ts",
1145
- "line": 13,
1176
+ "line": 25,
1146
1177
  "character": 2,
1147
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/config/config.ts#L13"
1178
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/config/config.ts#L25"
1148
1179
  }
1149
1180
  ],
1150
1181
  "type": {
@@ -1169,9 +1200,9 @@
1169
1200
  "sources": [
1170
1201
  {
1171
1202
  "fileName": "config/config.ts",
1172
- "line": 18,
1203
+ "line": 30,
1173
1204
  "character": 2,
1174
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/config/config.ts#L18"
1205
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/config/config.ts#L30"
1175
1206
  }
1176
1207
  ],
1177
1208
  "type": {
@@ -1196,9 +1227,9 @@
1196
1227
  "sources": [
1197
1228
  {
1198
1229
  "fileName": "config/config.ts",
1199
- "line": 8,
1230
+ "line": 20,
1200
1231
  "character": 2,
1201
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/config/config.ts#L8"
1232
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/config/config.ts#L20"
1202
1233
  }
1203
1234
  ],
1204
1235
  "type": {
@@ -1211,6 +1242,7 @@
1211
1242
  {
1212
1243
  "title": "Properties",
1213
1244
  "children": [
1245
+ 53,
1214
1246
  51,
1215
1247
  52,
1216
1248
  49,
@@ -1222,14 +1254,14 @@
1222
1254
  "sources": [
1223
1255
  {
1224
1256
  "fileName": "config/config.ts",
1225
- "line": 4,
1257
+ "line": 16,
1226
1258
  "character": 17,
1227
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/config/config.ts#L4"
1259
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/config/config.ts#L16"
1228
1260
  }
1229
1261
  ]
1230
1262
  },
1231
1263
  {
1232
- "id": 54,
1264
+ "id": 55,
1233
1265
  "name": "RelayEvent",
1234
1266
  "variant": "declaration",
1235
1267
  "kind": 256,
@@ -1244,7 +1276,7 @@
1244
1276
  },
1245
1277
  "children": [
1246
1278
  {
1247
- "id": 55,
1279
+ "id": 56,
1248
1280
  "name": "meta",
1249
1281
  "variant": "declaration",
1250
1282
  "kind": 1024,
@@ -1270,13 +1302,13 @@
1270
1302
  "fileName": "event/relay-event.ts",
1271
1303
  "line": 14,
1272
1304
  "character": 2,
1273
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/relay-event.ts#L14"
1305
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/relay-event.ts#L14"
1274
1306
  }
1275
1307
  ],
1276
1308
  "type": {
1277
1309
  "type": "reference",
1278
1310
  "target": {
1279
- "sourceFileName": "../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es5.d.ts",
1311
+ "sourceFileName": "../../node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/lib.es5.d.ts",
1280
1312
  "qualifiedName": "Readonly"
1281
1313
  },
1282
1314
  "typeArguments": [
@@ -1296,7 +1328,7 @@
1296
1328
  {
1297
1329
  "title": "Properties",
1298
1330
  "children": [
1299
- 55
1331
+ 56
1300
1332
  ]
1301
1333
  }
1302
1334
  ],
@@ -1305,13 +1337,13 @@
1305
1337
  "fileName": "event/relay-event.ts",
1306
1338
  "line": 10,
1307
1339
  "character": 17,
1308
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/event/relay-event.ts#L10"
1340
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/event/relay-event.ts#L10"
1309
1341
  }
1310
1342
  ],
1311
1343
  "extendedTypes": [
1312
1344
  {
1313
1345
  "type": "reference",
1314
- "target": 53,
1346
+ "target": 54,
1315
1347
  "name": "RelayPayload",
1316
1348
  "package": "@coveo/relay"
1317
1349
  }
@@ -1336,7 +1368,7 @@
1336
1368
  "fileName": "listener/listener.ts",
1337
1369
  "line": 11,
1338
1370
  "character": 12,
1339
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/listener/listener.ts#L11"
1371
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/listener/listener.ts#L11"
1340
1372
  }
1341
1373
  ],
1342
1374
  "type": {
@@ -1352,7 +1384,7 @@
1352
1384
  "fileName": "listener/listener.ts",
1353
1385
  "line": 11,
1354
1386
  "character": 28,
1355
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/listener/listener.ts#L11"
1387
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/listener/listener.ts#L11"
1356
1388
  }
1357
1389
  ],
1358
1390
  "signatures": [
@@ -1388,7 +1420,7 @@
1388
1420
  },
1389
1421
  "type": {
1390
1422
  "type": "reference",
1391
- "target": 54,
1423
+ "target": 55,
1392
1424
  "name": "RelayEvent",
1393
1425
  "package": "@coveo/relay"
1394
1426
  }
@@ -1420,9 +1452,9 @@
1420
1452
  "sources": [
1421
1453
  {
1422
1454
  "fileName": "relay.ts",
1423
- "line": 16,
1455
+ "line": 20,
1424
1456
  "character": 12,
1425
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L16"
1457
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L20"
1426
1458
  }
1427
1459
  ],
1428
1460
  "type": {
@@ -1436,9 +1468,9 @@
1436
1468
  "sources": [
1437
1469
  {
1438
1470
  "fileName": "relay.ts",
1439
- "line": 16,
1471
+ "line": 20,
1440
1472
  "character": 18,
1441
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L16"
1473
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L20"
1442
1474
  }
1443
1475
  ],
1444
1476
  "signatures": [
@@ -1467,7 +1499,7 @@
1467
1499
  }
1468
1500
  },
1469
1501
  {
1470
- "id": 53,
1502
+ "id": 54,
1471
1503
  "name": "RelayPayload",
1472
1504
  "variant": "declaration",
1473
1505
  "kind": 2097152,
@@ -1485,13 +1517,13 @@
1485
1517
  "fileName": "relay-payload.ts",
1486
1518
  "line": 5,
1487
1519
  "character": 12,
1488
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay-payload.ts#L5"
1520
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay-payload.ts#L5"
1489
1521
  }
1490
1522
  ],
1491
1523
  "type": {
1492
1524
  "type": "reference",
1493
1525
  "target": {
1494
- "sourceFileName": "../../node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/lib/lib.es5.d.ts",
1526
+ "sourceFileName": "../../node_modules/.pnpm/typescript@5.7.3/node_modules/typescript/lib/lib.es5.d.ts",
1495
1527
  "qualifiedName": "Record"
1496
1528
  },
1497
1529
  "typeArguments": [
@@ -1510,7 +1542,7 @@
1510
1542
  "extendedBy": [
1511
1543
  {
1512
1544
  "type": "reference",
1513
- "target": 54,
1545
+ "target": 55,
1514
1546
  "name": "RelayEvent"
1515
1547
  }
1516
1548
  ]
@@ -1524,9 +1556,9 @@
1524
1556
  "sources": [
1525
1557
  {
1526
1558
  "fileName": "relay.ts",
1527
- "line": 77,
1559
+ "line": 81,
1528
1560
  "character": 16,
1529
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L77"
1561
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L81"
1530
1562
  }
1531
1563
  ],
1532
1564
  "signatures": [
@@ -1553,9 +1585,9 @@
1553
1585
  "sources": [
1554
1586
  {
1555
1587
  "fileName": "relay.ts",
1556
- "line": 77,
1588
+ "line": 81,
1557
1589
  "character": 16,
1558
- "url": "https://github.com/coveo-platform/relay/blob/bcd1b028a071583b747ff4919f61570855068484/packages/relay/src/relay.ts#L77"
1590
+ "url": "https://github.com/coveo-platform/relay/blob/8654ceb4a6845e5e2828a4e41d0838274ff6c9c9/packages/relay/src/relay.ts#L81"
1559
1591
  }
1560
1592
  ],
1561
1593
  "parameters": [
@@ -1591,7 +1623,7 @@
1591
1623
  32,
1592
1624
  7,
1593
1625
  47,
1594
- 54
1626
+ 55
1595
1627
  ]
1596
1628
  },
1597
1629
  {
@@ -1599,7 +1631,7 @@
1599
1631
  "children": [
1600
1632
  43,
1601
1633
  4,
1602
- 53
1634
+ 54
1603
1635
  ]
1604
1636
  },
1605
1637
  {
@@ -1610,7 +1642,7 @@
1610
1642
  }
1611
1643
  ],
1612
1644
  "packageName": "@coveo/relay",
1613
- "packageVersion": "1.0.0",
1645
+ "packageVersion": "1.1.0",
1614
1646
  "readme": [
1615
1647
  {
1616
1648
  "kind": "text",
@@ -1839,14 +1871,18 @@
1839
1871
  "qualifiedName": "RelayConfig.source"
1840
1872
  },
1841
1873
  "53": {
1874
+ "sourceFileName": "src/config/config.ts",
1875
+ "qualifiedName": "RelayConfig.environment"
1876
+ },
1877
+ "54": {
1842
1878
  "sourceFileName": "src/relay-payload.ts",
1843
1879
  "qualifiedName": "RelayPayload"
1844
1880
  },
1845
- "54": {
1881
+ "55": {
1846
1882
  "sourceFileName": "src/event/relay-event.ts",
1847
1883
  "qualifiedName": "RelayEvent"
1848
1884
  },
1849
- "55": {
1885
+ "56": {
1850
1886
  "sourceFileName": "src/event/relay-event.ts",
1851
1887
  "qualifiedName": "RelayEvent.meta"
1852
1888
  }
@@ -1,7 +1,7 @@
1
1
  import { RelayEvent } from "../event/relay-event";
2
2
  import { Storage } from "./storage";
3
3
  export interface Environment {
4
- runtime: "browser" | "null";
4
+ runtime: "browser" | "null" | "custom";
5
5
  send: (url: string, token: string, event: RelayEvent) => void;
6
6
  getReferrer: () => string | null;
7
7
  getLocation: () => string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/environment/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAC9D,WAAW,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;CAClB"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/environment/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IACvC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAC9D,WAAW,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/environment/manager/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;CAClC;AAoBD,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,aAAa,GAC3B,QAAQ,CAAC,kBAAkB,CAAC,CAI9B"}
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/environment/manager/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;CAClC;AA0BD,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,aAAa,GAC3B,QAAQ,CAAC,kBAAkB,CAAC,CAI9B"}
package/lib/relay.cjs CHANGED
@@ -86,7 +86,7 @@ function createClientIdManager(environmentManager) {
86
86
  };
87
87
  }
88
88
 
89
- const version = "1.0.0";
89
+ const version = "1.1.0";
90
90
 
91
91
  function getEventConfig(config) {
92
92
  const { trackingId } = config;
@@ -185,6 +185,7 @@ function pick({ url, token, trackingId, ...rest }) {
185
185
  trackingId,
186
186
  ...(!!rest.mode && { mode: rest.mode }),
187
187
  ...(!!rest.source && { source: rest.source }),
188
+ ...(!!rest.environment && { environment: rest.environment }),
188
189
  });
189
190
  }
190
191
  function createConfigManager(initialConfig) {
@@ -324,6 +325,10 @@ function buildNullEnvironment() {
324
325
 
325
326
  function buildEnvironment(configManager) {
326
327
  const active = configManager.get().mode !== "disabled";
328
+ const environmentFromConfig = configManager.get().environment;
329
+ if (active && environmentFromConfig) {
330
+ return { ...environmentFromConfig, runtime: "custom" };
331
+ }
327
332
  if (active && isBrowser() && localStorageAvailable()) {
328
333
  return buildBrowserEnvironment();
329
334
  }
package/lib/relay.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RelayEvent } from "./event/relay-event";
2
2
  import { Meta, EventConfig } from "./event/meta/meta";
3
3
  import { EventCallback } from "./listener/listener";
4
- import { RelayConfig } from "./config/config";
4
+ import { RelayConfig, CustomEnvironment } from "./config/config";
5
5
  import { RelayPayload } from "./relay-payload";
6
6
  /**
7
7
  * Function that detaches an event callback.
@@ -63,5 +63,5 @@ interface Relay {
63
63
  * @returns {Relay}
64
64
  */
65
65
  export declare function createRelay(initialConfig: RelayConfig): Relay;
66
- export type { Relay, Meta, EventConfig, EventCallback, RelayConfig, RelayPayload, RelayEvent, };
66
+ export type { Relay, Meta, EventConfig, EventCallback, RelayConfig, RelayPayload, RelayEvent, CustomEnvironment, };
67
67
  //# sourceMappingURL=relay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../src/relay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAc,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAyB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAuB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC;AAE7B;;;GAGG;AACH,UAAU,KAAK;IACb;;;;;OAKG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAE3D;;;;OAIG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAEhC;;;;;;;;;OASG;IACH,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,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;IACH,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAEtD;;;;OAIG;IACH,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAErD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,WAAW,GAAG,KAAK,CAyC7D;AAED,YAAY,EACV,KAAK,EACL,IAAI,EACJ,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,iBAAiB,GAClB,CAAC"}
package/lib/relay.js CHANGED
@@ -85,7 +85,7 @@ function createClientIdManager(environmentManager) {
85
85
  };
86
86
  }
87
87
 
88
- const version = "1.0.0";
88
+ const version = "1.1.0";
89
89
 
90
90
  function getEventConfig(config) {
91
91
  const { trackingId } = config;
@@ -184,6 +184,7 @@ function pick({ url, token, trackingId, ...rest }) {
184
184
  trackingId,
185
185
  ...(!!rest.mode && { mode: rest.mode }),
186
186
  ...(!!rest.source && { source: rest.source }),
187
+ ...(!!rest.environment && { environment: rest.environment }),
187
188
  });
188
189
  }
189
190
  function createConfigManager(initialConfig) {
@@ -323,6 +324,10 @@ function buildNullEnvironment() {
323
324
 
324
325
  function buildEnvironment(configManager) {
325
326
  const active = configManager.get().mode !== "disabled";
327
+ const environmentFromConfig = configManager.get().environment;
328
+ if (active && environmentFromConfig) {
329
+ return { ...environmentFromConfig, runtime: "custom" };
330
+ }
326
331
  if (active && isBrowser() && localStorageAvailable()) {
327
332
  return buildBrowserEnvironment();
328
333
  }
package/lib/relay.mjs CHANGED
@@ -84,7 +84,7 @@ function createClientIdManager(environmentManager) {
84
84
  };
85
85
  }
86
86
 
87
- const version = "1.0.0";
87
+ const version = "1.1.0";
88
88
 
89
89
  function getEventConfig(config) {
90
90
  const { trackingId } = config;
@@ -183,6 +183,7 @@ function pick({ url, token, trackingId, ...rest }) {
183
183
  trackingId,
184
184
  ...(!!rest.mode && { mode: rest.mode }),
185
185
  ...(!!rest.source && { source: rest.source }),
186
+ ...(!!rest.environment && { environment: rest.environment }),
186
187
  });
187
188
  }
188
189
  function createConfigManager(initialConfig) {
@@ -322,6 +323,10 @@ function buildNullEnvironment() {
322
323
 
323
324
  function buildEnvironment(configManager) {
324
325
  const active = configManager.get().mode !== "disabled";
326
+ const environmentFromConfig = configManager.get().environment;
327
+ if (active && environmentFromConfig) {
328
+ return { ...environmentFromConfig, runtime: "custom" };
329
+ }
325
330
  if (active && isBrowser() && localStorageAvailable()) {
326
331
  return buildBrowserEnvironment();
327
332
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coveo/relay",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A library for sending analytics events using Coveo's Event protocol.",
5
5
  "files": [
6
6
  "lib/**/*"