@coveo/relay 0.6.12 → 0.7.1
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.
- package/lib/cdn/relay.min.js +1 -1
- package/lib/cdn/relay.min.js.map +1 -1
- package/lib/cdn/types/config/config.d.ts +6 -0
- package/lib/cdn/types/config/config.d.ts.map +1 -1
- package/lib/cdn/types/emit/emit.d.ts +1 -1
- package/lib/cdn/types/emit/emit.d.ts.map +1 -1
- package/lib/cdn/types/environment/environment.d.ts +1 -1
- package/lib/cdn/types/environment/environment.d.ts.map +1 -1
- package/lib/cdn/types/event/meta/meta.d.ts +5 -1
- package/lib/cdn/types/event/meta/meta.d.ts.map +1 -1
- package/lib/cdn/types/relay.d.ts +2 -2
- package/lib/cdn/types/relay.d.ts.map +1 -1
- package/lib/docs/relay-docs.json +135 -100
- package/lib/relay.cjs +5 -4
- package/lib/relay.js +5 -4
- package/lib/relay.mjs +5 -4
- package/lib/types/config/config.d.ts +6 -0
- package/lib/types/config/config.d.ts.map +1 -1
- package/lib/types/emit/emit.d.ts +1 -1
- package/lib/types/emit/emit.d.ts.map +1 -1
- package/lib/types/environment/environment.d.ts +1 -1
- package/lib/types/environment/environment.d.ts.map +1 -1
- package/lib/types/event/meta/meta.d.ts +5 -1
- package/lib/types/event/meta/meta.d.ts.map +1 -1
- package/lib/types/relay.d.ts +2 -2
- package/lib/types/relay.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/cdn/relay.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function t(t){const n="visitorId";return{getClientId:()=>{const r=t.get(),o=r.storage,c=o.getItem(n),a=c&&("string"==typeof(s=c)&&e.test(s))?c:r.generateUUID();var s;return o.setItem(n,a),a},clear:()=>{t.get().storage.removeItem(n)}}}const n="0.
|
|
1
|
+
var e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function t(t){const n="visitorId";return{getClientId:()=>{const r=t.get(),o=r.storage,c=o.getItem(n),a=c&&("string"==typeof(s=c)&&e.test(s))?c:r.generateUUID();var s;return o.setItem(n,a),a},clear:()=>{t.get().storage.removeItem(n)}}}const n="0.7.1";function r(e){return(e.source||[]).concat([`relay@${n}`])}function o(e,t,n,o){const{getReferrer:c,getLocation:a,getUserAgent:s}=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:r(t),clientId:u,user:null,userAgent:s(),referrer:c(),location:a()})}const c="*";function a(){const e=[];function t({type:t,callback:n}){return e.findIndex((e=>e.type===t&&e.callback===n))}function n(n,r){r?function(n){const r=t(n);r>=0&&e.splice(r,1)}({type:n,callback:r}):function(t){if(t===c)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(r){return t(r)<0&&e.push(r),()=>n(r.type,r.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 s({url:e,token:t,trackingId:n,...r}){return Object.freeze({url:e,token:t,trackingId:n,...!!r.mode&&{mode:r.mode},...!!r.source&&{source:r.source}})}const i=function(){const e="coveo_";return{getItem(t){const n=`${e}${t}=`,r=document.cookie.split(";");for(const e of r){const t=e.replace(/^\s+/,"");if(0===t.lastIndexOf(n,0))return t.substring(n.length,t.length)}return null},setItem(t,n,r){const o=(e=>{const t=e.split(".").slice(-2);return 2==t.length?t.join("."):""})(window.location.hostname),c=`;expires=${new Date((new Date).getTime()+r).toUTCString()}`,a=o?`;domain=${o}`:"";document.cookie=`${e}${t}=${n}${c}${a};path=/;SameSite=Lax`},removeItem(e){this.setItem(e,"",-1)}}}();function u(){return{runtime:"browser",send:(e,t,n)=>{const r=navigator.sendBeacon(`${e}?access_token=${t}`,new Blob([JSON.stringify([n])],{type:"application/json"})),o=function(){const e="undefined"!=typeof window;return{sendMessage(t){e&&window.postMessage(t,"*")}}}();if(o.sendMessage({kind:"EVENT_PROTOCOL",event:n,url:e,token:t}),!r)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:()=>crypto.randomUUID(),storage:{getItem:e=>i.getItem(e)||localStorage.getItem(e),removeItem(e){i.removeItem(e),localStorage.removeItem(e)},setItem(e,t){localStorage.setItem(e,t),i.setItem(e,t,31556952e3)}}}}function l(e){return"disabled"!==e.get().mode&&function(){try{return"object"==typeof window}catch(e){return!1}}()?u():{runtime:"null",send:()=>{},getReferrer:()=>null,getLocation:()=>null,getUserAgent:()=>null,generateUUID:()=>"",storage:{getItem:()=>null,removeItem(){},setItem(){}}}}function g(e){const r=function(e){let t=s(e);return{get:()=>t,update:e=>{t=s({...t,...e})}}}(e),c=a(),i=function(e){return{get:()=>Object.freeze(l(e))}}(r),u=t(i);return{emit:(e,t)=>{const n=r.get(),a=i.get(),s=function(e,t,n,r,c){return{...t,meta:o(e,n,r,c)}}(e,t,n,a,u);return function({config:e,environment:t,event:n,listenerManager:r}){const{url:o,token:c,mode:a}=e;"disabled"!==a&&(r.call(n),t.send(o,c,n))}({config:n,environment:a,event:s,listenerManager:c})},getMeta:e=>o(e,r.get(),i.get(),u),on:(e,t)=>c.add({type:e,callback:t}),off:(e,t)=>c.remove(e,t),updateConfig:e=>r.update(e),version:n,clearStorage:()=>{u.clear()}}}export{g as createRelay};
|
|
2
2
|
//# sourceMappingURL=relay.min.js.map
|
package/lib/cdn/relay.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay.min.js","sources":["../../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/regex.js","../../src/client-id/client-id.ts","../../../../node_modules/.pnpm/uuid@9.0.1/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.1.1/node_modules/@coveo/explorer-messenger/dist/messenger.js","../../src/environment/browser/storage/storage.ts","../../src/environment/manager/manager.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-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import { validate } from \"uuid\";\nimport { EnvironmentManager } from \"../environment/manager/manager\";\n\nexport interface ClientIdManager {\n getClientId: () => string;\n clear: () => void;\n}\n\nexport function createClientIdManager(\n environmentManager: EnvironmentManager\n): ClientIdManager {\n const key = \"visitorId\";\n\n return {\n getClientId: () => {\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 clear: () => {\n environmentManager.get().storage.removeItem(key);\n },\n };\n}\n","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","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 [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 */\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({\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\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 !!callback ? removeOne({ type, callback }) : removeMultiple(type);\n }\n\n return {\n add,\n call,\n remove,\n };\n}\n","export type RelayMode = \"emit\" | \"disabled\";\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 [Tracking ID](https://docs.coveo.com/en/n8tg0567/).\n */\n trackingId: string;\n\n /**\n * Defines the library mode. The possible values are:\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?: RelayMode;\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\";\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: async (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: () => crypto.randomUUID(),\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 { 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()) {\n return buildBrowserEnvironment();\n }\n\n return buildNullEnvironment();\n}\n\nfunction isBrowser() {\n try {\n return typeof window === \"object\";\n } catch (e) {\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","import { Environment } from \"../environment\";\nimport { createNullStorage } from \"../storage\";\n\nexport function buildNullEnvironment(): Environment {\n return {\n runtime: \"null\",\n send: async () => 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 } 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\";\n\ntype 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 {Promise<void>}\n */\n emit: (type: string, payload: Record<string, any>) => Promise<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 * 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\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 * Removes the visitorId cookie and localStorage key.\n * @returns {void}\n */\n clearStorage: () => void;\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 clearStorage: () => {\n clientIdManager.clear();\n },\n };\n}\n\nexport type { Relay, Meta, EventConfig, EventCallback, RelayConfig };\n","import { ClientIdManager } from \"../client-id/client-id\";\nimport { Environment } from \"../environment/environment\";\nimport { RelayPayload } from \"../internal-types\";\nimport { RelayConfig } from \"../relay\";\nimport { createMeta, Meta } from \"./meta/meta\";\n\nexport interface RelayEvent extends RelayPayload {\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 async 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","createClientIdManager","environmentManager","key","getClientId","environment","get","storage","existingClientId","getItem","clientId","uuid","test","generateUUID","setItem","clear","removeItem","version","getSource","config","source","concat","createMeta","type","clientIdManager","getReferrer","getLocation","getUserAgent","eventConfig","trackingId","getEventConfig","Object","freeze","ts","Date","now","userAgent","referrer","location","ANY_EVENT_TYPE","createListenerManager","listeners","getListenerIndex","callback","findIndex","listener","remove","index","splice","removeOne","length","i","removeMultiple","add","push","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","slice","join","getDomain","window","hostname","expireSection","getTime","toUTCString","domainSection","this","createCookieManager","buildBrowserEnvironment","runtime","send","async","response","navigator","sendBeacon","Blob","JSON","stringify","messenger","isBrowser","sendMessage","message","postMessage","createExplorerMessenger","kind","Error","href","crypto","randomUUID","localStorage","buildEnvironment","configManager","createRelay","initialConfig","_config","update","updatedConfig","createConfigManager","listenerManager","createEnvironmentManager","emit","payload","createRelayEvent","getMeta","on","off","updateConfig","clearStorage"],"mappings":"AAAA,IAAAA,EAAe,sHCQT,SAAUC,EACdC,GAEA,MAAMC,EAAM,YAEZ,MAAO,CACLC,YAAa,KACX,MAAMC,EA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oB,aAC9ByF,IAAK,CAAC7G,EAAcoB,IAClBkF,EAAgB/E,OAAOvB,EAAMoB,GAC/B0F,aAAelH,GACbmG,EAAcI,OAAOvG,GACvBF,UACAqH,aAAc,KACZ9G,EAAgBT,OAAO,EAG7B","x_google_ignoreList":[0,2,9]}
|
|
1
|
+
{"version":3,"file":"relay.min.js","sources":["../../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/regex.js","../../src/client-id/client-id.ts","../../../../node_modules/.pnpm/uuid@9.0.1/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.1.1/node_modules/@coveo/explorer-messenger/dist/messenger.js","../../src/environment/browser/storage/storage.ts","../../src/environment/manager/manager.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-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import { validate } from \"uuid\";\nimport { EnvironmentManager } from \"../environment/manager/manager\";\n\nexport interface ClientIdManager {\n getClientId: () => string;\n clear: () => void;\n}\n\nexport function createClientIdManager(\n environmentManager: EnvironmentManager\n): ClientIdManager {\n const key = \"visitorId\";\n\n return {\n getClientId: () => {\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 clear: () => {\n environmentManager.get().storage.removeItem(key);\n },\n };\n}\n","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","export const version = \"process.env.VERSION\";\n","import { ClientIdManager } from \"../../client-id/client-id\";\nimport { Environment } from \"../../environment/environment\";\nimport { RelayConfig, User } 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 [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 */\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 * Named user identity which logged this event.\n */\n user: User | null;\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({\n type,\n config: eventConfig,\n ts: Date.now(),\n source: getSource(config),\n clientId,\n user: null,\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\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 !!callback ? removeOne({ type, callback }) : removeMultiple(type);\n }\n\n return {\n add,\n call,\n remove,\n };\n}\n","export type RelayMode = \"emit\" | \"disabled\";\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 [Tracking ID](https://docs.coveo.com/en/n8tg0567/).\n */\n trackingId: string;\n\n /**\n * Defines the library mode. The possible values are:\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?: RelayMode;\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 User {\n /**\n * The application's user identifier.\n */\n id: 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\";\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: () => crypto.randomUUID(),\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 { 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()) {\n return buildBrowserEnvironment();\n }\n\n return buildNullEnvironment();\n}\n\nfunction isBrowser() {\n try {\n return typeof window === \"object\";\n } catch (e) {\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","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 } 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\";\n\ntype 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 * 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\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 * Removes the visitorId cookie and localStorage key.\n * @returns {void}\n */\n clearStorage: () => void;\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 clearStorage: () => {\n clientIdManager.clear();\n },\n };\n}\n\nexport type { Relay, Meta, EventConfig, EventCallback, RelayConfig };\n","import { ClientIdManager } from \"../client-id/client-id\";\nimport { Environment } from \"../environment/environment\";\nimport { RelayPayload } from \"../internal-types\";\nimport { RelayConfig } from \"../relay\";\nimport { createMeta, Meta } from \"./meta/meta\";\n\nexport interface RelayEvent extends RelayPayload {\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","createClientIdManager","environmentManager","key","getClientId","environment","get","storage","existingClientId","getItem","clientId","uuid","test","generateUUID","setItem","clear","removeItem","version","getSource","config","source","concat","createMeta","type","clientIdManager","getReferrer","getLocation","getUserAgent","eventConfig","trackingId","getEventConfig","Object","freeze","ts","Date","now","user","userAgent","referrer","location","ANY_EVENT_TYPE","createListenerManager","listeners","getListenerIndex","callback","findIndex","listener","remove","index","splice","removeOne","length","i","removeMultiple","add","push","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","slice","join","getDomain","window","hostname","expireSection","getTime","toUTCString","domainSection","this","createCookieManager","buildBrowserEnvironment","runtime","send","response","navigator","sendBeacon","Blob","JSON","stringify","messenger","isBrowser","sendMessage","message","postMessage","createExplorerMessenger","kind","Error","href","crypto","randomUUID","localStorage","buildEnvironment","configManager","createRelay","initialConfig","_config","update","updatedConfig","createConfigManager","listenerManager","createEnvironmentManager","emit","payload","createRelayEvent","getMeta","on","off","updateConfig","clearStorage"],"mappings":"AAAA,IAAAA,EAAe,sHCQT,SAAUC,EACdC,GAEA,MAAMC,EAAM,YAEZ,MAAO,CACLC,YAAa,KACX,MAAMC,EAAcH,EAAmBI,MACjCC,EAAUF,EAAYE,QAEtBC,EAAmBD,EAAQE,QAAQN,GACnCO,EACJF,ICjBiB,iBADPG,EDkBmBH,ICjBAR,EAAMY,KAAKD,IDkBpCH,EACAH,EAAYQ,eCpBxB,IAAkBF,EDsBZ,OADAJ,EAAQO,QAAQX,EAAKO,GACdA,CAAQ,EAEjBK,MAAO,KACLb,EAAmBI,MAAMC,QAAQS,WAAWb,EAAI,EAGtD,CE9BO,MAAMc,EAAU,QCsEvB,SAASC,EAAUC,GACjB,OAAQA,EAAOC,QAAU,IAAIC,OAAO,CAAC,SAASJ,KAChD,CAEM,SAAUK,EACdC,EACAJ,EACAd,EACAmB,GAEA,MAAMC,YAAEA,EAAWC,YAAEA,EAAWC,aAAEA,GAAiBtB,EAC7CuB,EAhBR,SAAwBT,GACtB,MAAMU,WAAEA,GAAeV,EACvB,MAAO,CAAEU,aACX,CAasBC,CAAeX,GAC7BT,EAAWc,EAAgBpB,cAEjC,OAAO2B,OAAOC,OAAO,CACnBT,OACAJ,OAAQS,EACRK,GAAIC,KAAKC,MACTf,OAAQF,EAAUC,GAClBT,WACA0B,KAAM,KACNC,UAAWV,IACXW,SAAUb,IACVc,SAAUb,KAEd,CC7FA,MAAMc,EAAiB,aAqBPC,IACd,MAAMC,EAAwB,GAE9B,SAASC,GAAiBpB,KAAEA,EAAIqB,SAAEA,IAChC,OAAOF,EAAUG,WACdC,GAAaA,EAASvB,OAASA,GAAQuB,EAASF,WAAaA,GAEjE,CA4CD,SAASG,EAAOxB,EAAcqB,GAC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F,aAATiD,IAGhByD,EAAgBrE,KAAKC,GACrBpD,EAAY6F,KAAKjC,EAAKC,EAAOT,GAEjC,CFqEasE,CAAK,CACV5G,SACAd,cACAoD,QACAoE,mBACA,EAEJK,QAAU3G,GACRD,EACEC,EACA+F,EAAchH,MACdJ,EAAmBI,MACnBkB,GAEJ2G,GAAI,CAAC5G,EAAcqB,IACjBiF,EAAgBvE,IAAI,CAAE/B,OAAMqB,aAC9BwF,IAAK,CAAC7G,EAAcqB,IAClBiF,EAAgB9E,OAAOxB,EAAMqB,GAC/ByF,aAAelH,GACbmG,EAAcI,OAAOvG,GACvBF,UACAqH,aAAc,KACZ9G,EAAgBT,OAAO,EAG7B","x_google_ignoreList":[0,2,9]}
|
|
@@ -29,6 +29,12 @@ export interface RelayConfig {
|
|
|
29
29
|
*/
|
|
30
30
|
source?: string[];
|
|
31
31
|
}
|
|
32
|
+
export interface User {
|
|
33
|
+
/**
|
|
34
|
+
* The application's user identifier.
|
|
35
|
+
*/
|
|
36
|
+
id: string;
|
|
37
|
+
}
|
|
32
38
|
export interface ConfigManager {
|
|
33
39
|
get: () => Readonly<RelayConfig>;
|
|
34
40
|
update: (updatedConfig: Partial<RelayConfig>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;AAE5C;;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,SAAS,CAAC;IAEjB;;;;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,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;AAE5C;;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,SAAS,CAAC;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ;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"}
|
|
@@ -8,5 +8,5 @@ export interface EmitParams {
|
|
|
8
8
|
event: RelayEvent;
|
|
9
9
|
listenerManager: ListenerManager;
|
|
10
10
|
}
|
|
11
|
-
export declare function emit({ config, environment, event, listenerManager, }: EmitParams):
|
|
11
|
+
export declare function emit({ config, environment, event, listenerManager, }: EmitParams): void;
|
|
12
12
|
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/emit/emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/emit/emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,wBAAgB,IAAI,CAAC,EACnB,MAAM,EACN,WAAW,EACX,KAAK,EACL,eAAe,GAChB,EAAE,UAAU,QAQZ"}
|
|
@@ -2,7 +2,7 @@ import { RelayEvent } from "../event/relay-event";
|
|
|
2
2
|
import { Storage } from "./storage";
|
|
3
3
|
export interface Environment {
|
|
4
4
|
runtime: "browser" | "null";
|
|
5
|
-
send: (url: string, token: string, event: RelayEvent) =>
|
|
5
|
+
send: (url: string, token: string, event: RelayEvent) => void;
|
|
6
6
|
getReferrer: () => string | null;
|
|
7
7
|
getLocation: () => string | null;
|
|
8
8
|
getUserAgent: () => 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,
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { ClientIdManager } from "../../client-id/client-id";
|
|
2
2
|
import { Environment } from "../../environment/environment";
|
|
3
|
-
import { RelayConfig } from "../../config/config";
|
|
3
|
+
import { RelayConfig, User } from "../../config/config";
|
|
4
4
|
/**
|
|
5
5
|
* The `EventConfig` object provides additonal information for the configuration associated with the event.
|
|
6
6
|
*/
|
|
@@ -34,6 +34,10 @@ export interface Meta {
|
|
|
34
34
|
* Persistent unique identifier of a device.
|
|
35
35
|
*/
|
|
36
36
|
clientId: string;
|
|
37
|
+
/**
|
|
38
|
+
* Named user identity which logged this event.
|
|
39
|
+
*/
|
|
40
|
+
user: User | null;
|
|
37
41
|
/**
|
|
38
42
|
* Browser Navigator's [user agent](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent) property if set.
|
|
39
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../src/event/meta/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../src/event/meta/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC;IAEpB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAWD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,GAC/B,QAAQ,CAAC,IAAI,CAAC,CAgBhB"}
|
package/lib/cdn/types/relay.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ interface Relay {
|
|
|
11
11
|
* Sends an event to the Event API.
|
|
12
12
|
* @param {string} type - event's type to be emitted.
|
|
13
13
|
* @param {Record<string,any>} payload - payload to include within the event.
|
|
14
|
-
* @returns {
|
|
14
|
+
* @returns {void}
|
|
15
15
|
*/
|
|
16
|
-
emit: (type: string, payload: Record<string, any>) =>
|
|
16
|
+
emit: (type: string, payload: Record<string, any>) => void;
|
|
17
17
|
/**
|
|
18
18
|
* Gets the client-side generated meta object.
|
|
19
19
|
* @param {string} type - event's type that will be included in the meta object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/relay.ts"],"names":[],"mappings":"AAIA,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;AAGnE,KAAK,GAAG,GAAG,MAAM,IAAI,CAAC;AAEtB;;;GAGG;AACH,UAAU,KAAK;IACb;;;;;OAKG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/relay.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB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"children": [
|
|
31
31
|
{
|
|
32
|
-
"id":
|
|
32
|
+
"id": 43,
|
|
33
33
|
"name": "trackingId",
|
|
34
34
|
"variant": "declaration",
|
|
35
35
|
"kind": 1024,
|
|
@@ -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/relay/blob/
|
|
50
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L13"
|
|
51
51
|
}
|
|
52
52
|
],
|
|
53
53
|
"type": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
{
|
|
61
61
|
"title": "Properties",
|
|
62
62
|
"children": [
|
|
63
|
-
|
|
63
|
+
43
|
|
64
64
|
]
|
|
65
65
|
}
|
|
66
66
|
],
|
|
@@ -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/relay/blob/
|
|
72
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/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": 43,
|
|
117
117
|
"character": 2,
|
|
118
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
118
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L43"
|
|
119
119
|
}
|
|
120
120
|
],
|
|
121
121
|
"type": {
|
|
@@ -142,18 +142,18 @@
|
|
|
142
142
|
"fileName": "event/meta/meta.ts",
|
|
143
143
|
"line": 28,
|
|
144
144
|
"character": 2,
|
|
145
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
145
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L28"
|
|
146
146
|
}
|
|
147
147
|
],
|
|
148
148
|
"type": {
|
|
149
149
|
"type": "reference",
|
|
150
|
-
"target":
|
|
150
|
+
"target": 42,
|
|
151
151
|
"name": "EventConfig",
|
|
152
152
|
"package": "@coveo/relay"
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
{
|
|
156
|
-
"id":
|
|
156
|
+
"id": 41,
|
|
157
157
|
"name": "location",
|
|
158
158
|
"variant": "declaration",
|
|
159
159
|
"kind": 1024,
|
|
@@ -169,9 +169,9 @@
|
|
|
169
169
|
"sources": [
|
|
170
170
|
{
|
|
171
171
|
"fileName": "event/meta/meta.ts",
|
|
172
|
-
"line":
|
|
172
|
+
"line": 63,
|
|
173
173
|
"character": 2,
|
|
174
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
174
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L63"
|
|
175
175
|
}
|
|
176
176
|
],
|
|
177
177
|
"type": {
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
}
|
|
190
190
|
},
|
|
191
191
|
{
|
|
192
|
-
"id":
|
|
192
|
+
"id": 40,
|
|
193
193
|
"name": "referrer",
|
|
194
194
|
"variant": "declaration",
|
|
195
195
|
"kind": 1024,
|
|
@@ -205,9 +205,9 @@
|
|
|
205
205
|
"sources": [
|
|
206
206
|
{
|
|
207
207
|
"fileName": "event/meta/meta.ts",
|
|
208
|
-
"line":
|
|
208
|
+
"line": 58,
|
|
209
209
|
"character": 2,
|
|
210
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
210
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L58"
|
|
211
211
|
}
|
|
212
212
|
],
|
|
213
213
|
"type": {
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
"fileName": "event/meta/meta.ts",
|
|
244
244
|
"line": 38,
|
|
245
245
|
"character": 2,
|
|
246
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
246
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L38"
|
|
247
247
|
}
|
|
248
248
|
],
|
|
249
249
|
"type": {
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
"fileName": "event/meta/meta.ts",
|
|
274
274
|
"line": 33,
|
|
275
275
|
"character": 2,
|
|
276
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
276
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L33"
|
|
277
277
|
}
|
|
278
278
|
],
|
|
279
279
|
"type": {
|
|
@@ -300,7 +300,7 @@
|
|
|
300
300
|
"fileName": "event/meta/meta.ts",
|
|
301
301
|
"line": 23,
|
|
302
302
|
"character": 2,
|
|
303
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
303
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L23"
|
|
304
304
|
}
|
|
305
305
|
],
|
|
306
306
|
"type": {
|
|
@@ -310,6 +310,47 @@
|
|
|
310
310
|
},
|
|
311
311
|
{
|
|
312
312
|
"id": 38,
|
|
313
|
+
"name": "user",
|
|
314
|
+
"variant": "declaration",
|
|
315
|
+
"kind": 1024,
|
|
316
|
+
"flags": {},
|
|
317
|
+
"comment": {
|
|
318
|
+
"summary": [
|
|
319
|
+
{
|
|
320
|
+
"kind": "text",
|
|
321
|
+
"text": "Named user identity which logged this event."
|
|
322
|
+
}
|
|
323
|
+
]
|
|
324
|
+
},
|
|
325
|
+
"sources": [
|
|
326
|
+
{
|
|
327
|
+
"fileName": "event/meta/meta.ts",
|
|
328
|
+
"line": 48,
|
|
329
|
+
"character": 2,
|
|
330
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L48"
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
"type": {
|
|
334
|
+
"type": "union",
|
|
335
|
+
"types": [
|
|
336
|
+
{
|
|
337
|
+
"type": "literal",
|
|
338
|
+
"value": null
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"type": "reference",
|
|
342
|
+
"target": {
|
|
343
|
+
"sourceFileName": "src/config/config.ts",
|
|
344
|
+
"qualifiedName": "User"
|
|
345
|
+
},
|
|
346
|
+
"name": "User",
|
|
347
|
+
"package": "@coveo/relay"
|
|
348
|
+
}
|
|
349
|
+
]
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"id": 39,
|
|
313
354
|
"name": "userAgent",
|
|
314
355
|
"variant": "declaration",
|
|
315
356
|
"kind": 1024,
|
|
@@ -325,9 +366,9 @@
|
|
|
325
366
|
"sources": [
|
|
326
367
|
{
|
|
327
368
|
"fileName": "event/meta/meta.ts",
|
|
328
|
-
"line":
|
|
369
|
+
"line": 53,
|
|
329
370
|
"character": 2,
|
|
330
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
371
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L53"
|
|
331
372
|
}
|
|
332
373
|
],
|
|
333
374
|
"type": {
|
|
@@ -351,12 +392,13 @@
|
|
|
351
392
|
"children": [
|
|
352
393
|
37,
|
|
353
394
|
34,
|
|
395
|
+
41,
|
|
354
396
|
40,
|
|
355
|
-
39,
|
|
356
397
|
36,
|
|
357
398
|
35,
|
|
358
399
|
33,
|
|
359
|
-
38
|
|
400
|
+
38,
|
|
401
|
+
39
|
|
360
402
|
]
|
|
361
403
|
}
|
|
362
404
|
],
|
|
@@ -365,7 +407,7 @@
|
|
|
365
407
|
"fileName": "event/meta/meta.ts",
|
|
366
408
|
"line": 19,
|
|
367
409
|
"character": 17,
|
|
368
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
410
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/event/meta/meta.ts#L19"
|
|
369
411
|
}
|
|
370
412
|
]
|
|
371
413
|
},
|
|
@@ -395,7 +437,7 @@
|
|
|
395
437
|
"fileName": "relay.ts",
|
|
396
438
|
"line": 68,
|
|
397
439
|
"character": 2,
|
|
398
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
440
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L68"
|
|
399
441
|
}
|
|
400
442
|
],
|
|
401
443
|
"type": {
|
|
@@ -411,7 +453,7 @@
|
|
|
411
453
|
"fileName": "relay.ts",
|
|
412
454
|
"line": 68,
|
|
413
455
|
"character": 16,
|
|
414
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
456
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L68"
|
|
415
457
|
}
|
|
416
458
|
],
|
|
417
459
|
"signatures": [
|
|
@@ -440,7 +482,7 @@
|
|
|
440
482
|
"fileName": "relay.ts",
|
|
441
483
|
"line": 68,
|
|
442
484
|
"character": 16,
|
|
443
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
485
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L68"
|
|
444
486
|
}
|
|
445
487
|
],
|
|
446
488
|
"type": {
|
|
@@ -463,7 +505,7 @@
|
|
|
463
505
|
"fileName": "relay.ts",
|
|
464
506
|
"line": 23,
|
|
465
507
|
"character": 2,
|
|
466
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
508
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L23"
|
|
467
509
|
}
|
|
468
510
|
],
|
|
469
511
|
"type": {
|
|
@@ -479,7 +521,7 @@
|
|
|
479
521
|
"fileName": "relay.ts",
|
|
480
522
|
"line": 23,
|
|
481
523
|
"character": 8,
|
|
482
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
524
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L23"
|
|
483
525
|
}
|
|
484
526
|
],
|
|
485
527
|
"signatures": [
|
|
@@ -508,7 +550,7 @@
|
|
|
508
550
|
"fileName": "relay.ts",
|
|
509
551
|
"line": 23,
|
|
510
552
|
"character": 8,
|
|
511
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
553
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L23"
|
|
512
554
|
}
|
|
513
555
|
],
|
|
514
556
|
"parameters": [
|
|
@@ -567,19 +609,8 @@
|
|
|
567
609
|
}
|
|
568
610
|
],
|
|
569
611
|
"type": {
|
|
570
|
-
"type": "
|
|
571
|
-
"
|
|
572
|
-
"sourceFileName": "../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript/lib/lib.es5.d.ts",
|
|
573
|
-
"qualifiedName": "Promise"
|
|
574
|
-
},
|
|
575
|
-
"typeArguments": [
|
|
576
|
-
{
|
|
577
|
-
"type": "intrinsic",
|
|
578
|
-
"name": "void"
|
|
579
|
-
}
|
|
580
|
-
],
|
|
581
|
-
"name": "Promise",
|
|
582
|
-
"package": "typescript"
|
|
612
|
+
"type": "intrinsic",
|
|
613
|
+
"name": "void"
|
|
583
614
|
}
|
|
584
615
|
}
|
|
585
616
|
]
|
|
@@ -597,7 +628,7 @@
|
|
|
597
628
|
"fileName": "relay.ts",
|
|
598
629
|
"line": 30,
|
|
599
630
|
"character": 2,
|
|
600
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
631
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L30"
|
|
601
632
|
}
|
|
602
633
|
],
|
|
603
634
|
"type": {
|
|
@@ -613,7 +644,7 @@
|
|
|
613
644
|
"fileName": "relay.ts",
|
|
614
645
|
"line": 30,
|
|
615
646
|
"character": 11,
|
|
616
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
647
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L30"
|
|
617
648
|
}
|
|
618
649
|
],
|
|
619
650
|
"signatures": [
|
|
@@ -642,7 +673,7 @@
|
|
|
642
673
|
"fileName": "relay.ts",
|
|
643
674
|
"line": 30,
|
|
644
675
|
"character": 11,
|
|
645
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
676
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L30"
|
|
646
677
|
}
|
|
647
678
|
],
|
|
648
679
|
"parameters": [
|
|
@@ -688,7 +719,7 @@
|
|
|
688
719
|
"fileName": "relay.ts",
|
|
689
720
|
"line": 50,
|
|
690
721
|
"character": 2,
|
|
691
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
722
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L50"
|
|
692
723
|
}
|
|
693
724
|
],
|
|
694
725
|
"type": {
|
|
@@ -704,7 +735,7 @@
|
|
|
704
735
|
"fileName": "relay.ts",
|
|
705
736
|
"line": 50,
|
|
706
737
|
"character": 7,
|
|
707
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
738
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L50"
|
|
708
739
|
}
|
|
709
740
|
],
|
|
710
741
|
"signatures": [
|
|
@@ -733,7 +764,7 @@
|
|
|
733
764
|
"fileName": "relay.ts",
|
|
734
765
|
"line": 50,
|
|
735
766
|
"character": 7,
|
|
736
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
767
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L50"
|
|
737
768
|
}
|
|
738
769
|
],
|
|
739
770
|
"parameters": [
|
|
@@ -774,7 +805,7 @@
|
|
|
774
805
|
},
|
|
775
806
|
"type": {
|
|
776
807
|
"type": "reference",
|
|
777
|
-
"target":
|
|
808
|
+
"target": 44,
|
|
778
809
|
"name": "EventCallback",
|
|
779
810
|
"package": "@coveo/relay"
|
|
780
811
|
}
|
|
@@ -800,7 +831,7 @@
|
|
|
800
831
|
"fileName": "relay.ts",
|
|
801
832
|
"line": 41,
|
|
802
833
|
"character": 2,
|
|
803
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
834
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L41"
|
|
804
835
|
}
|
|
805
836
|
],
|
|
806
837
|
"type": {
|
|
@@ -816,7 +847,7 @@
|
|
|
816
847
|
"fileName": "relay.ts",
|
|
817
848
|
"line": 41,
|
|
818
849
|
"character": 6,
|
|
819
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
850
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L41"
|
|
820
851
|
}
|
|
821
852
|
],
|
|
822
853
|
"signatures": [
|
|
@@ -845,7 +876,7 @@
|
|
|
845
876
|
"fileName": "relay.ts",
|
|
846
877
|
"line": 41,
|
|
847
878
|
"character": 6,
|
|
848
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
879
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L41"
|
|
849
880
|
}
|
|
850
881
|
],
|
|
851
882
|
"parameters": [
|
|
@@ -876,7 +907,7 @@
|
|
|
876
907
|
"flags": {},
|
|
877
908
|
"type": {
|
|
878
909
|
"type": "reference",
|
|
879
|
-
"target":
|
|
910
|
+
"target": 44,
|
|
880
911
|
"name": "EventCallback",
|
|
881
912
|
"package": "@coveo/relay"
|
|
882
913
|
}
|
|
@@ -907,7 +938,7 @@
|
|
|
907
938
|
"fileName": "relay.ts",
|
|
908
939
|
"line": 57,
|
|
909
940
|
"character": 2,
|
|
910
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
941
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L57"
|
|
911
942
|
}
|
|
912
943
|
],
|
|
913
944
|
"type": {
|
|
@@ -923,7 +954,7 @@
|
|
|
923
954
|
"fileName": "relay.ts",
|
|
924
955
|
"line": 57,
|
|
925
956
|
"character": 16,
|
|
926
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
957
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L57"
|
|
927
958
|
}
|
|
928
959
|
],
|
|
929
960
|
"signatures": [
|
|
@@ -952,7 +983,7 @@
|
|
|
952
983
|
"fileName": "relay.ts",
|
|
953
984
|
"line": 57,
|
|
954
985
|
"character": 16,
|
|
955
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
986
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L57"
|
|
956
987
|
}
|
|
957
988
|
],
|
|
958
989
|
"parameters": [
|
|
@@ -979,7 +1010,7 @@
|
|
|
979
1010
|
"typeArguments": [
|
|
980
1011
|
{
|
|
981
1012
|
"type": "reference",
|
|
982
|
-
"target":
|
|
1013
|
+
"target": 48,
|
|
983
1014
|
"name": "RelayConfig",
|
|
984
1015
|
"package": "@coveo/relay"
|
|
985
1016
|
}
|
|
@@ -1017,7 +1048,7 @@
|
|
|
1017
1048
|
"fileName": "relay.ts",
|
|
1018
1049
|
"line": 62,
|
|
1019
1050
|
"character": 2,
|
|
1020
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1051
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L62"
|
|
1021
1052
|
}
|
|
1022
1053
|
],
|
|
1023
1054
|
"type": {
|
|
@@ -1045,12 +1076,12 @@
|
|
|
1045
1076
|
"fileName": "relay.ts",
|
|
1046
1077
|
"line": 16,
|
|
1047
1078
|
"character": 10,
|
|
1048
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1079
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L16"
|
|
1049
1080
|
}
|
|
1050
1081
|
]
|
|
1051
1082
|
},
|
|
1052
1083
|
{
|
|
1053
|
-
"id":
|
|
1084
|
+
"id": 48,
|
|
1054
1085
|
"name": "RelayConfig",
|
|
1055
1086
|
"variant": "declaration",
|
|
1056
1087
|
"kind": 256,
|
|
@@ -1073,7 +1104,7 @@
|
|
|
1073
1104
|
},
|
|
1074
1105
|
"children": [
|
|
1075
1106
|
{
|
|
1076
|
-
"id":
|
|
1107
|
+
"id": 52,
|
|
1077
1108
|
"name": "mode",
|
|
1078
1109
|
"variant": "declaration",
|
|
1079
1110
|
"kind": 1024,
|
|
@@ -1104,7 +1135,7 @@
|
|
|
1104
1135
|
"fileName": "config/config.ts",
|
|
1105
1136
|
"line": 28,
|
|
1106
1137
|
"character": 2,
|
|
1107
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1138
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/config/config.ts#L28"
|
|
1108
1139
|
}
|
|
1109
1140
|
],
|
|
1110
1141
|
"type": {
|
|
@@ -1118,7 +1149,7 @@
|
|
|
1118
1149
|
}
|
|
1119
1150
|
},
|
|
1120
1151
|
{
|
|
1121
|
-
"id":
|
|
1152
|
+
"id": 53,
|
|
1122
1153
|
"name": "source",
|
|
1123
1154
|
"variant": "declaration",
|
|
1124
1155
|
"kind": 1024,
|
|
@@ -1138,7 +1169,7 @@
|
|
|
1138
1169
|
"fileName": "config/config.ts",
|
|
1139
1170
|
"line": 35,
|
|
1140
1171
|
"character": 2,
|
|
1141
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1172
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/config/config.ts#L35"
|
|
1142
1173
|
}
|
|
1143
1174
|
],
|
|
1144
1175
|
"type": {
|
|
@@ -1150,7 +1181,7 @@
|
|
|
1150
1181
|
}
|
|
1151
1182
|
},
|
|
1152
1183
|
{
|
|
1153
|
-
"id":
|
|
1184
|
+
"id": 50,
|
|
1154
1185
|
"name": "token",
|
|
1155
1186
|
"variant": "declaration",
|
|
1156
1187
|
"kind": 1024,
|
|
@@ -1168,7 +1199,7 @@
|
|
|
1168
1199
|
"fileName": "config/config.ts",
|
|
1169
1200
|
"line": 15,
|
|
1170
1201
|
"character": 2,
|
|
1171
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1202
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/config/config.ts#L15"
|
|
1172
1203
|
}
|
|
1173
1204
|
],
|
|
1174
1205
|
"type": {
|
|
@@ -1177,7 +1208,7 @@
|
|
|
1177
1208
|
}
|
|
1178
1209
|
},
|
|
1179
1210
|
{
|
|
1180
|
-
"id":
|
|
1211
|
+
"id": 51,
|
|
1181
1212
|
"name": "trackingId",
|
|
1182
1213
|
"variant": "declaration",
|
|
1183
1214
|
"kind": 1024,
|
|
@@ -1195,7 +1226,7 @@
|
|
|
1195
1226
|
"fileName": "config/config.ts",
|
|
1196
1227
|
"line": 20,
|
|
1197
1228
|
"character": 2,
|
|
1198
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1229
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/config/config.ts#L20"
|
|
1199
1230
|
}
|
|
1200
1231
|
],
|
|
1201
1232
|
"type": {
|
|
@@ -1204,7 +1235,7 @@
|
|
|
1204
1235
|
}
|
|
1205
1236
|
},
|
|
1206
1237
|
{
|
|
1207
|
-
"id":
|
|
1238
|
+
"id": 49,
|
|
1208
1239
|
"name": "url",
|
|
1209
1240
|
"variant": "declaration",
|
|
1210
1241
|
"kind": 1024,
|
|
@@ -1222,7 +1253,7 @@
|
|
|
1222
1253
|
"fileName": "config/config.ts",
|
|
1223
1254
|
"line": 10,
|
|
1224
1255
|
"character": 2,
|
|
1225
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1256
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/config/config.ts#L10"
|
|
1226
1257
|
}
|
|
1227
1258
|
],
|
|
1228
1259
|
"type": {
|
|
@@ -1235,11 +1266,11 @@
|
|
|
1235
1266
|
{
|
|
1236
1267
|
"title": "Properties",
|
|
1237
1268
|
"children": [
|
|
1238
|
-
51,
|
|
1239
1269
|
52,
|
|
1240
|
-
|
|
1270
|
+
53,
|
|
1241
1271
|
50,
|
|
1242
|
-
|
|
1272
|
+
51,
|
|
1273
|
+
49
|
|
1243
1274
|
]
|
|
1244
1275
|
}
|
|
1245
1276
|
],
|
|
@@ -1248,12 +1279,12 @@
|
|
|
1248
1279
|
"fileName": "config/config.ts",
|
|
1249
1280
|
"line": 6,
|
|
1250
1281
|
"character": 17,
|
|
1251
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1282
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/config/config.ts#L6"
|
|
1252
1283
|
}
|
|
1253
1284
|
]
|
|
1254
1285
|
},
|
|
1255
1286
|
{
|
|
1256
|
-
"id":
|
|
1287
|
+
"id": 44,
|
|
1257
1288
|
"name": "EventCallback",
|
|
1258
1289
|
"variant": "declaration",
|
|
1259
1290
|
"kind": 2097152,
|
|
@@ -1263,13 +1294,13 @@
|
|
|
1263
1294
|
"fileName": "listener/listener.ts",
|
|
1264
1295
|
"line": 11,
|
|
1265
1296
|
"character": 12,
|
|
1266
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1297
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/listener/listener.ts#L11"
|
|
1267
1298
|
}
|
|
1268
1299
|
],
|
|
1269
1300
|
"type": {
|
|
1270
1301
|
"type": "reflection",
|
|
1271
1302
|
"declaration": {
|
|
1272
|
-
"id":
|
|
1303
|
+
"id": 45,
|
|
1273
1304
|
"name": "__type",
|
|
1274
1305
|
"variant": "declaration",
|
|
1275
1306
|
"kind": 65536,
|
|
@@ -1279,12 +1310,12 @@
|
|
|
1279
1310
|
"fileName": "listener/listener.ts",
|
|
1280
1311
|
"line": 11,
|
|
1281
1312
|
"character": 28,
|
|
1282
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1313
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/listener/listener.ts#L11"
|
|
1283
1314
|
}
|
|
1284
1315
|
],
|
|
1285
1316
|
"signatures": [
|
|
1286
1317
|
{
|
|
1287
|
-
"id":
|
|
1318
|
+
"id": 46,
|
|
1288
1319
|
"name": "__type",
|
|
1289
1320
|
"variant": "signature",
|
|
1290
1321
|
"kind": 4096,
|
|
@@ -1305,7 +1336,7 @@
|
|
|
1305
1336
|
},
|
|
1306
1337
|
"parameters": [
|
|
1307
1338
|
{
|
|
1308
|
-
"id":
|
|
1339
|
+
"id": 47,
|
|
1309
1340
|
"name": "event",
|
|
1310
1341
|
"variant": "param",
|
|
1311
1342
|
"kind": 32768,
|
|
@@ -1341,7 +1372,7 @@
|
|
|
1341
1372
|
"fileName": "relay.ts",
|
|
1342
1373
|
"line": 76,
|
|
1343
1374
|
"character": 16,
|
|
1344
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1375
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L76"
|
|
1345
1376
|
}
|
|
1346
1377
|
],
|
|
1347
1378
|
"signatures": [
|
|
@@ -1370,7 +1401,7 @@
|
|
|
1370
1401
|
"fileName": "relay.ts",
|
|
1371
1402
|
"line": 76,
|
|
1372
1403
|
"character": 16,
|
|
1373
|
-
"url": "https://github.com/coveo/relay/blob/
|
|
1404
|
+
"url": "https://github.com/coveo/relay/blob/540ceec/packages/relay/src/relay.ts#L76"
|
|
1374
1405
|
}
|
|
1375
1406
|
],
|
|
1376
1407
|
"parameters": [
|
|
@@ -1382,7 +1413,7 @@
|
|
|
1382
1413
|
"flags": {},
|
|
1383
1414
|
"type": {
|
|
1384
1415
|
"type": "reference",
|
|
1385
|
-
"target":
|
|
1416
|
+
"target": 48,
|
|
1386
1417
|
"name": "RelayConfig",
|
|
1387
1418
|
"package": "@coveo/relay"
|
|
1388
1419
|
}
|
|
@@ -1402,16 +1433,16 @@
|
|
|
1402
1433
|
{
|
|
1403
1434
|
"title": "Interfaces",
|
|
1404
1435
|
"children": [
|
|
1405
|
-
|
|
1436
|
+
42,
|
|
1406
1437
|
32,
|
|
1407
1438
|
4,
|
|
1408
|
-
|
|
1439
|
+
48
|
|
1409
1440
|
]
|
|
1410
1441
|
},
|
|
1411
1442
|
{
|
|
1412
1443
|
"title": "Type Aliases",
|
|
1413
1444
|
"children": [
|
|
1414
|
-
|
|
1445
|
+
44
|
|
1415
1446
|
]
|
|
1416
1447
|
},
|
|
1417
1448
|
{
|
|
@@ -1422,7 +1453,7 @@
|
|
|
1422
1453
|
}
|
|
1423
1454
|
],
|
|
1424
1455
|
"packageName": "@coveo/relay",
|
|
1425
|
-
"packageVersion": "0.
|
|
1456
|
+
"packageVersion": "0.7.1",
|
|
1426
1457
|
"readme": [
|
|
1427
1458
|
{
|
|
1428
1459
|
"kind": "text",
|
|
@@ -1624,31 +1655,31 @@
|
|
|
1624
1655
|
},
|
|
1625
1656
|
"38": {
|
|
1626
1657
|
"sourceFileName": "src/event/meta/meta.ts",
|
|
1627
|
-
"qualifiedName": "Meta.
|
|
1658
|
+
"qualifiedName": "Meta.user"
|
|
1628
1659
|
},
|
|
1629
1660
|
"39": {
|
|
1630
1661
|
"sourceFileName": "src/event/meta/meta.ts",
|
|
1631
|
-
"qualifiedName": "Meta.
|
|
1662
|
+
"qualifiedName": "Meta.userAgent"
|
|
1632
1663
|
},
|
|
1633
1664
|
"40": {
|
|
1634
1665
|
"sourceFileName": "src/event/meta/meta.ts",
|
|
1635
|
-
"qualifiedName": "Meta.
|
|
1666
|
+
"qualifiedName": "Meta.referrer"
|
|
1636
1667
|
},
|
|
1637
1668
|
"41": {
|
|
1638
1669
|
"sourceFileName": "src/event/meta/meta.ts",
|
|
1639
|
-
"qualifiedName": "
|
|
1670
|
+
"qualifiedName": "Meta.location"
|
|
1640
1671
|
},
|
|
1641
1672
|
"42": {
|
|
1642
1673
|
"sourceFileName": "src/event/meta/meta.ts",
|
|
1643
|
-
"qualifiedName": "EventConfig
|
|
1674
|
+
"qualifiedName": "EventConfig"
|
|
1644
1675
|
},
|
|
1645
1676
|
"43": {
|
|
1646
|
-
"sourceFileName": "src/
|
|
1647
|
-
"qualifiedName": "
|
|
1677
|
+
"sourceFileName": "src/event/meta/meta.ts",
|
|
1678
|
+
"qualifiedName": "EventConfig.trackingId"
|
|
1648
1679
|
},
|
|
1649
1680
|
"44": {
|
|
1650
1681
|
"sourceFileName": "src/listener/listener.ts",
|
|
1651
|
-
"qualifiedName": "
|
|
1682
|
+
"qualifiedName": "EventCallback"
|
|
1652
1683
|
},
|
|
1653
1684
|
"45": {
|
|
1654
1685
|
"sourceFileName": "src/listener/listener.ts",
|
|
@@ -1656,29 +1687,33 @@
|
|
|
1656
1687
|
},
|
|
1657
1688
|
"46": {
|
|
1658
1689
|
"sourceFileName": "src/listener/listener.ts",
|
|
1659
|
-
"qualifiedName": "
|
|
1690
|
+
"qualifiedName": "__type"
|
|
1660
1691
|
},
|
|
1661
1692
|
"47": {
|
|
1693
|
+
"sourceFileName": "src/listener/listener.ts",
|
|
1694
|
+
"qualifiedName": "event"
|
|
1695
|
+
},
|
|
1696
|
+
"48": {
|
|
1662
1697
|
"sourceFileName": "src/config/config.ts",
|
|
1663
1698
|
"qualifiedName": "RelayConfig"
|
|
1664
1699
|
},
|
|
1665
|
-
"
|
|
1700
|
+
"49": {
|
|
1666
1701
|
"sourceFileName": "src/config/config.ts",
|
|
1667
1702
|
"qualifiedName": "RelayConfig.url"
|
|
1668
1703
|
},
|
|
1669
|
-
"
|
|
1704
|
+
"50": {
|
|
1670
1705
|
"sourceFileName": "src/config/config.ts",
|
|
1671
1706
|
"qualifiedName": "RelayConfig.token"
|
|
1672
1707
|
},
|
|
1673
|
-
"
|
|
1708
|
+
"51": {
|
|
1674
1709
|
"sourceFileName": "src/config/config.ts",
|
|
1675
1710
|
"qualifiedName": "RelayConfig.trackingId"
|
|
1676
1711
|
},
|
|
1677
|
-
"
|
|
1712
|
+
"52": {
|
|
1678
1713
|
"sourceFileName": "src/config/config.ts",
|
|
1679
1714
|
"qualifiedName": "RelayConfig.mode"
|
|
1680
1715
|
},
|
|
1681
|
-
"
|
|
1716
|
+
"53": {
|
|
1682
1717
|
"sourceFileName": "src/config/config.ts",
|
|
1683
1718
|
"qualifiedName": "RelayConfig.source"
|
|
1684
1719
|
}
|
package/lib/relay.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function emit({ config, environment, event, listenerManager, }) {
|
|
4
4
|
const { url, token, mode } = config;
|
|
5
5
|
const isEnabled = mode !== "disabled";
|
|
6
6
|
if (isEnabled) {
|
|
@@ -34,7 +34,7 @@ function createClientIdManager(environmentManager) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const version = "0.
|
|
37
|
+
const version = "0.7.1";
|
|
38
38
|
|
|
39
39
|
function getEventConfig(config) {
|
|
40
40
|
const { trackingId } = config;
|
|
@@ -53,6 +53,7 @@ function createMeta(type, config, environment, clientIdManager) {
|
|
|
53
53
|
ts: Date.now(),
|
|
54
54
|
source: getSource(config),
|
|
55
55
|
clientId,
|
|
56
|
+
user: null,
|
|
56
57
|
userAgent: getUserAgent(),
|
|
57
58
|
referrer: getReferrer(),
|
|
58
59
|
location: getLocation(),
|
|
@@ -204,7 +205,7 @@ function getReferrer() {
|
|
|
204
205
|
function buildBrowserEnvironment() {
|
|
205
206
|
return {
|
|
206
207
|
runtime: "browser",
|
|
207
|
-
send:
|
|
208
|
+
send: (url, token, event) => {
|
|
208
209
|
const response = navigator.sendBeacon(`${url}?access_token=${token}`, new Blob([JSON.stringify([event])], {
|
|
209
210
|
type: "application/json",
|
|
210
211
|
}));
|
|
@@ -239,7 +240,7 @@ function createNullStorage() {
|
|
|
239
240
|
function buildNullEnvironment() {
|
|
240
241
|
return {
|
|
241
242
|
runtime: "null",
|
|
242
|
-
send:
|
|
243
|
+
send: () => undefined,
|
|
243
244
|
getReferrer: () => null,
|
|
244
245
|
getLocation: () => null,
|
|
245
246
|
getUserAgent: () => null,
|
package/lib/relay.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function emit({ config, environment, event, listenerManager, }) {
|
|
2
2
|
const { url, token, mode } = config;
|
|
3
3
|
const isEnabled = mode !== "disabled";
|
|
4
4
|
if (isEnabled) {
|
|
@@ -32,7 +32,7 @@ function createClientIdManager(environmentManager) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const version = "0.
|
|
35
|
+
const version = "0.7.1";
|
|
36
36
|
|
|
37
37
|
function getEventConfig(config) {
|
|
38
38
|
const { trackingId } = config;
|
|
@@ -51,6 +51,7 @@ function createMeta(type, config, environment, clientIdManager) {
|
|
|
51
51
|
ts: Date.now(),
|
|
52
52
|
source: getSource(config),
|
|
53
53
|
clientId,
|
|
54
|
+
user: null,
|
|
54
55
|
userAgent: getUserAgent(),
|
|
55
56
|
referrer: getReferrer(),
|
|
56
57
|
location: getLocation(),
|
|
@@ -202,7 +203,7 @@ function getReferrer() {
|
|
|
202
203
|
function buildBrowserEnvironment() {
|
|
203
204
|
return {
|
|
204
205
|
runtime: "browser",
|
|
205
|
-
send:
|
|
206
|
+
send: (url, token, event) => {
|
|
206
207
|
const response = navigator.sendBeacon(`${url}?access_token=${token}`, new Blob([JSON.stringify([event])], {
|
|
207
208
|
type: "application/json",
|
|
208
209
|
}));
|
|
@@ -237,7 +238,7 @@ function createNullStorage() {
|
|
|
237
238
|
function buildNullEnvironment() {
|
|
238
239
|
return {
|
|
239
240
|
runtime: "null",
|
|
240
|
-
send:
|
|
241
|
+
send: () => undefined,
|
|
241
242
|
getReferrer: () => null,
|
|
242
243
|
getLocation: () => null,
|
|
243
244
|
getUserAgent: () => null,
|
package/lib/relay.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function emit({ config, environment, event, listenerManager, }) {
|
|
2
2
|
const { url, token, mode } = config;
|
|
3
3
|
const isEnabled = mode !== "disabled";
|
|
4
4
|
if (isEnabled) {
|
|
@@ -32,7 +32,7 @@ function createClientIdManager(environmentManager) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const version = "0.
|
|
35
|
+
const version = "0.7.1";
|
|
36
36
|
|
|
37
37
|
function getEventConfig(config) {
|
|
38
38
|
const { trackingId } = config;
|
|
@@ -51,6 +51,7 @@ function createMeta(type, config, environment, clientIdManager) {
|
|
|
51
51
|
ts: Date.now(),
|
|
52
52
|
source: getSource(config),
|
|
53
53
|
clientId,
|
|
54
|
+
user: null,
|
|
54
55
|
userAgent: getUserAgent(),
|
|
55
56
|
referrer: getReferrer(),
|
|
56
57
|
location: getLocation(),
|
|
@@ -202,7 +203,7 @@ function getReferrer() {
|
|
|
202
203
|
function buildBrowserEnvironment() {
|
|
203
204
|
return {
|
|
204
205
|
runtime: "browser",
|
|
205
|
-
send:
|
|
206
|
+
send: (url, token, event) => {
|
|
206
207
|
const response = navigator.sendBeacon(`${url}?access_token=${token}`, new Blob([JSON.stringify([event])], {
|
|
207
208
|
type: "application/json",
|
|
208
209
|
}));
|
|
@@ -237,7 +238,7 @@ function createNullStorage() {
|
|
|
237
238
|
function buildNullEnvironment() {
|
|
238
239
|
return {
|
|
239
240
|
runtime: "null",
|
|
240
|
-
send:
|
|
241
|
+
send: () => undefined,
|
|
241
242
|
getReferrer: () => null,
|
|
242
243
|
getLocation: () => null,
|
|
243
244
|
getUserAgent: () => null,
|
|
@@ -29,6 +29,12 @@ export interface RelayConfig {
|
|
|
29
29
|
*/
|
|
30
30
|
source?: string[];
|
|
31
31
|
}
|
|
32
|
+
export interface User {
|
|
33
|
+
/**
|
|
34
|
+
* The application's user identifier.
|
|
35
|
+
*/
|
|
36
|
+
id: string;
|
|
37
|
+
}
|
|
32
38
|
export interface ConfigManager {
|
|
33
39
|
get: () => Readonly<RelayConfig>;
|
|
34
40
|
update: (updatedConfig: Partial<RelayConfig>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;AAE5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QAAQ,CAAC,aAAa,CAAC,CASzB"}
|
package/lib/types/emit/emit.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export interface EmitParams {
|
|
|
8
8
|
event: RelayEvent;
|
|
9
9
|
listenerManager: ListenerManager;
|
|
10
10
|
}
|
|
11
|
-
export declare function emit({ config, environment, event, listenerManager, }: EmitParams):
|
|
11
|
+
export declare function emit({ config, environment, event, listenerManager, }: EmitParams): void;
|
|
12
12
|
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/emit/emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/emit/emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,wBAAgB,IAAI,CAAC,EACnB,MAAM,EACN,WAAW,EACX,KAAK,EACL,eAAe,GAChB,EAAE,UAAU,QAQZ"}
|
|
@@ -2,7 +2,7 @@ import { RelayEvent } from "../event/relay-event";
|
|
|
2
2
|
import { Storage } from "./storage";
|
|
3
3
|
export interface Environment {
|
|
4
4
|
runtime: "browser" | "null";
|
|
5
|
-
send: (url: string, token: string, event: RelayEvent) =>
|
|
5
|
+
send: (url: string, token: string, event: RelayEvent) => void;
|
|
6
6
|
getReferrer: () => string | null;
|
|
7
7
|
getLocation: () => string | null;
|
|
8
8
|
getUserAgent: () => 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,
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import { ClientIdManager } from "../../client-id/client-id";
|
|
2
2
|
import { Environment } from "../../environment/environment";
|
|
3
|
-
import { RelayConfig } from "../../config/config";
|
|
3
|
+
import { RelayConfig, User } from "../../config/config";
|
|
4
4
|
/**
|
|
5
5
|
* The `EventConfig` object provides additonal information for the configuration associated with the event.
|
|
6
6
|
*/
|
|
@@ -34,6 +34,10 @@ export interface Meta {
|
|
|
34
34
|
* Persistent unique identifier of a device.
|
|
35
35
|
*/
|
|
36
36
|
clientId: string;
|
|
37
|
+
/**
|
|
38
|
+
* Named user identity which logged this event.
|
|
39
|
+
*/
|
|
40
|
+
user: User | null;
|
|
37
41
|
/**
|
|
38
42
|
* Browser Navigator's [user agent](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent) property if set.
|
|
39
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../src/event/meta/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../src/event/meta/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC;IAEpB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAWD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,GAC/B,QAAQ,CAAC,IAAI,CAAC,CAgBhB"}
|
package/lib/types/relay.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ interface Relay {
|
|
|
11
11
|
* Sends an event to the Event API.
|
|
12
12
|
* @param {string} type - event's type to be emitted.
|
|
13
13
|
* @param {Record<string,any>} payload - payload to include within the event.
|
|
14
|
-
* @returns {
|
|
14
|
+
* @returns {void}
|
|
15
15
|
*/
|
|
16
|
-
emit: (type: string, payload: Record<string, any>) =>
|
|
16
|
+
emit: (type: string, payload: Record<string, any>) => void;
|
|
17
17
|
/**
|
|
18
18
|
* Gets the client-side generated meta object.
|
|
19
19
|
* @param {string} type - event's type that will be included in the meta object.
|
package/lib/types/relay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/relay.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,IAAI,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAyB,aAAa,EAAE,MAAM,qBAAqB,CAAC;A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