@coveo/relay 0.7.2 → 0.7.3

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/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @coveo/relay
2
+
3
+ Relay is a compact library for emitting Event Protocol analytics events. It simplifies tracking relevant user interactions. This analytics data powers reports and helps train Coveo Machine Learning models.
4
+
5
+ ## Usage
6
+
7
+ First, create an instance of Relay in your project. This instance can then be used to emit an event or perform other actions.
8
+
9
+ ```js
10
+ import { createRelay } from "@coveo/relay";
11
+
12
+ const config = {...};
13
+ const relay = createRelay(config);
14
+
15
+ const payload = {...};
16
+ relay.emit('itemView', payload);
17
+ ```
18
+
19
+ ## Official documentation
20
+
21
+ - [Learn more about Relay](https://docs.coveo.com/en/relay/latest/)
22
+ - [List of Event API schemas and reference types](https://docs.coveo.com/en/n9da0377/build-a-search-ui/event-api-reference)
@@ -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.7.2";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,user:null}}(t),u=o.getClientId();return Object.freeze({type:e,config:i,ts:Date.now(),source:r(t),clientId:u,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};
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.3";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,user:null}}(t),u=o.getClientId();return Object.freeze({type:e,config:i,ts:Date.now(),source:r(t),clientId:u,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
@@ -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/d9c8da6/packages/relay/src/event/meta/meta.ts#L13"
50
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L13"
51
51
  }
52
52
  ],
53
53
  "type": {
@@ -74,7 +74,7 @@
74
74
  "fileName": "event/meta/meta.ts",
75
75
  "line": 18,
76
76
  "character": 2,
77
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L18"
77
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L18"
78
78
  }
79
79
  ],
80
80
  "type": {
@@ -111,7 +111,7 @@
111
111
  "fileName": "event/meta/meta.ts",
112
112
  "line": 9,
113
113
  "character": 17,
114
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L9"
114
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L9"
115
115
  }
116
116
  ]
117
117
  },
@@ -157,7 +157,7 @@
157
157
  "fileName": "event/meta/meta.ts",
158
158
  "line": 48,
159
159
  "character": 2,
160
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L48"
160
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L48"
161
161
  }
162
162
  ],
163
163
  "type": {
@@ -184,7 +184,7 @@
184
184
  "fileName": "event/meta/meta.ts",
185
185
  "line": 33,
186
186
  "character": 2,
187
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L33"
187
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L33"
188
188
  }
189
189
  ],
190
190
  "type": {
@@ -213,7 +213,7 @@
213
213
  "fileName": "event/meta/meta.ts",
214
214
  "line": 63,
215
215
  "character": 2,
216
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L63"
216
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L63"
217
217
  }
218
218
  ],
219
219
  "type": {
@@ -249,7 +249,7 @@
249
249
  "fileName": "event/meta/meta.ts",
250
250
  "line": 58,
251
251
  "character": 2,
252
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L58"
252
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L58"
253
253
  }
254
254
  ],
255
255
  "type": {
@@ -285,7 +285,7 @@
285
285
  "fileName": "event/meta/meta.ts",
286
286
  "line": 43,
287
287
  "character": 2,
288
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L43"
288
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L43"
289
289
  }
290
290
  ],
291
291
  "type": {
@@ -315,7 +315,7 @@
315
315
  "fileName": "event/meta/meta.ts",
316
316
  "line": 38,
317
317
  "character": 2,
318
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L38"
318
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L38"
319
319
  }
320
320
  ],
321
321
  "type": {
@@ -342,7 +342,7 @@
342
342
  "fileName": "event/meta/meta.ts",
343
343
  "line": 28,
344
344
  "character": 2,
345
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L28"
345
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L28"
346
346
  }
347
347
  ],
348
348
  "type": {
@@ -369,7 +369,7 @@
369
369
  "fileName": "event/meta/meta.ts",
370
370
  "line": 53,
371
371
  "character": 2,
372
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L53"
372
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L53"
373
373
  }
374
374
  ],
375
375
  "type": {
@@ -407,7 +407,7 @@
407
407
  "fileName": "event/meta/meta.ts",
408
408
  "line": 24,
409
409
  "character": 17,
410
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/event/meta/meta.ts#L24"
410
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/event/meta/meta.ts#L24"
411
411
  }
412
412
  ]
413
413
  },
@@ -437,7 +437,7 @@
437
437
  "fileName": "relay.ts",
438
438
  "line": 68,
439
439
  "character": 2,
440
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L68"
440
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L68"
441
441
  }
442
442
  ],
443
443
  "type": {
@@ -453,7 +453,7 @@
453
453
  "fileName": "relay.ts",
454
454
  "line": 68,
455
455
  "character": 16,
456
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L68"
456
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L68"
457
457
  }
458
458
  ],
459
459
  "signatures": [
@@ -482,7 +482,7 @@
482
482
  "fileName": "relay.ts",
483
483
  "line": 68,
484
484
  "character": 16,
485
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L68"
485
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L68"
486
486
  }
487
487
  ],
488
488
  "type": {
@@ -505,7 +505,7 @@
505
505
  "fileName": "relay.ts",
506
506
  "line": 23,
507
507
  "character": 2,
508
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L23"
508
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L23"
509
509
  }
510
510
  ],
511
511
  "type": {
@@ -521,7 +521,7 @@
521
521
  "fileName": "relay.ts",
522
522
  "line": 23,
523
523
  "character": 8,
524
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L23"
524
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L23"
525
525
  }
526
526
  ],
527
527
  "signatures": [
@@ -550,7 +550,7 @@
550
550
  "fileName": "relay.ts",
551
551
  "line": 23,
552
552
  "character": 8,
553
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L23"
553
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L23"
554
554
  }
555
555
  ],
556
556
  "parameters": [
@@ -628,7 +628,7 @@
628
628
  "fileName": "relay.ts",
629
629
  "line": 30,
630
630
  "character": 2,
631
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L30"
631
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L30"
632
632
  }
633
633
  ],
634
634
  "type": {
@@ -644,7 +644,7 @@
644
644
  "fileName": "relay.ts",
645
645
  "line": 30,
646
646
  "character": 11,
647
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L30"
647
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L30"
648
648
  }
649
649
  ],
650
650
  "signatures": [
@@ -673,7 +673,7 @@
673
673
  "fileName": "relay.ts",
674
674
  "line": 30,
675
675
  "character": 11,
676
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L30"
676
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L30"
677
677
  }
678
678
  ],
679
679
  "parameters": [
@@ -719,7 +719,7 @@
719
719
  "fileName": "relay.ts",
720
720
  "line": 50,
721
721
  "character": 2,
722
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L50"
722
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L50"
723
723
  }
724
724
  ],
725
725
  "type": {
@@ -735,7 +735,7 @@
735
735
  "fileName": "relay.ts",
736
736
  "line": 50,
737
737
  "character": 7,
738
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L50"
738
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L50"
739
739
  }
740
740
  ],
741
741
  "signatures": [
@@ -764,7 +764,7 @@
764
764
  "fileName": "relay.ts",
765
765
  "line": 50,
766
766
  "character": 7,
767
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L50"
767
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L50"
768
768
  }
769
769
  ],
770
770
  "parameters": [
@@ -831,7 +831,7 @@
831
831
  "fileName": "relay.ts",
832
832
  "line": 41,
833
833
  "character": 2,
834
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L41"
834
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L41"
835
835
  }
836
836
  ],
837
837
  "type": {
@@ -847,7 +847,7 @@
847
847
  "fileName": "relay.ts",
848
848
  "line": 41,
849
849
  "character": 6,
850
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L41"
850
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L41"
851
851
  }
852
852
  ],
853
853
  "signatures": [
@@ -876,7 +876,7 @@
876
876
  "fileName": "relay.ts",
877
877
  "line": 41,
878
878
  "character": 6,
879
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L41"
879
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L41"
880
880
  }
881
881
  ],
882
882
  "parameters": [
@@ -938,7 +938,7 @@
938
938
  "fileName": "relay.ts",
939
939
  "line": 57,
940
940
  "character": 2,
941
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L57"
941
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L57"
942
942
  }
943
943
  ],
944
944
  "type": {
@@ -954,7 +954,7 @@
954
954
  "fileName": "relay.ts",
955
955
  "line": 57,
956
956
  "character": 16,
957
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L57"
957
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L57"
958
958
  }
959
959
  ],
960
960
  "signatures": [
@@ -983,7 +983,7 @@
983
983
  "fileName": "relay.ts",
984
984
  "line": 57,
985
985
  "character": 16,
986
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L57"
986
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L57"
987
987
  }
988
988
  ],
989
989
  "parameters": [
@@ -1048,7 +1048,7 @@
1048
1048
  "fileName": "relay.ts",
1049
1049
  "line": 62,
1050
1050
  "character": 2,
1051
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L62"
1051
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L62"
1052
1052
  }
1053
1053
  ],
1054
1054
  "type": {
@@ -1076,7 +1076,7 @@
1076
1076
  "fileName": "relay.ts",
1077
1077
  "line": 16,
1078
1078
  "character": 10,
1079
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L16"
1079
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L16"
1080
1080
  }
1081
1081
  ]
1082
1082
  },
@@ -1135,7 +1135,7 @@
1135
1135
  "fileName": "config/config.ts",
1136
1136
  "line": 28,
1137
1137
  "character": 2,
1138
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/config/config.ts#L28"
1138
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/config/config.ts#L28"
1139
1139
  }
1140
1140
  ],
1141
1141
  "type": {
@@ -1169,7 +1169,7 @@
1169
1169
  "fileName": "config/config.ts",
1170
1170
  "line": 35,
1171
1171
  "character": 2,
1172
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/config/config.ts#L35"
1172
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/config/config.ts#L35"
1173
1173
  }
1174
1174
  ],
1175
1175
  "type": {
@@ -1199,7 +1199,7 @@
1199
1199
  "fileName": "config/config.ts",
1200
1200
  "line": 15,
1201
1201
  "character": 2,
1202
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/config/config.ts#L15"
1202
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/config/config.ts#L15"
1203
1203
  }
1204
1204
  ],
1205
1205
  "type": {
@@ -1226,7 +1226,7 @@
1226
1226
  "fileName": "config/config.ts",
1227
1227
  "line": 20,
1228
1228
  "character": 2,
1229
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/config/config.ts#L20"
1229
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/config/config.ts#L20"
1230
1230
  }
1231
1231
  ],
1232
1232
  "type": {
@@ -1253,7 +1253,7 @@
1253
1253
  "fileName": "config/config.ts",
1254
1254
  "line": 10,
1255
1255
  "character": 2,
1256
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/config/config.ts#L10"
1256
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/config/config.ts#L10"
1257
1257
  }
1258
1258
  ],
1259
1259
  "type": {
@@ -1279,7 +1279,7 @@
1279
1279
  "fileName": "config/config.ts",
1280
1280
  "line": 6,
1281
1281
  "character": 17,
1282
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/config/config.ts#L6"
1282
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/config/config.ts#L6"
1283
1283
  }
1284
1284
  ]
1285
1285
  },
@@ -1294,7 +1294,7 @@
1294
1294
  "fileName": "listener/listener.ts",
1295
1295
  "line": 11,
1296
1296
  "character": 12,
1297
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/listener/listener.ts#L11"
1297
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/listener/listener.ts#L11"
1298
1298
  }
1299
1299
  ],
1300
1300
  "type": {
@@ -1310,7 +1310,7 @@
1310
1310
  "fileName": "listener/listener.ts",
1311
1311
  "line": 11,
1312
1312
  "character": 28,
1313
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/listener/listener.ts#L11"
1313
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/listener/listener.ts#L11"
1314
1314
  }
1315
1315
  ],
1316
1316
  "signatures": [
@@ -1372,7 +1372,7 @@
1372
1372
  "fileName": "relay.ts",
1373
1373
  "line": 76,
1374
1374
  "character": 16,
1375
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L76"
1375
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L76"
1376
1376
  }
1377
1377
  ],
1378
1378
  "signatures": [
@@ -1401,7 +1401,7 @@
1401
1401
  "fileName": "relay.ts",
1402
1402
  "line": 76,
1403
1403
  "character": 16,
1404
- "url": "https://github.com/coveo/relay/blob/d9c8da6/packages/relay/src/relay.ts#L76"
1404
+ "url": "https://github.com/coveo/relay/blob/05ba89b/packages/relay/src/relay.ts#L76"
1405
1405
  }
1406
1406
  ],
1407
1407
  "parameters": [
@@ -1453,51 +1453,19 @@
1453
1453
  }
1454
1454
  ],
1455
1455
  "packageName": "@coveo/relay",
1456
- "packageVersion": "0.7.2",
1456
+ "packageVersion": "0.7.3",
1457
1457
  "readme": [
1458
1458
  {
1459
1459
  "kind": "text",
1460
- "text": "# Relay\n\nThe Relay repository contains a client-side library and set of related tools for sending events from the browser using Coveo's Event protocol. It consists of multiple components:\n\n- The core relay library in "
1460
+ "text": "# @coveo/relay\n\nRelay is a compact library for emitting Event Protocol analytics events. It simplifies tracking relevant user interactions. This analytics data powers reports and helps train Coveo Machine Learning models.\n\n## Usage\n\nFirst, create an instance of Relay in your project. This instance can then be used to emit an event or perform other actions.\n\n"
1461
1461
  },
1462
1462
  {
1463
1463
  "kind": "code",
1464
- "text": "`packages/relay`"
1464
+ "text": "```js\nimport { createRelay } from \"@coveo/relay\";\n\nconst config = {...};\nconst relay = createRelay(config);\n\nconst payload = {...};\nrelay.emit('itemView', payload);\n```"
1465
1465
  },
1466
1466
  {
1467
1467
  "kind": "text",
1468
- "text": ": Relay is an event agnostic library which is responsible for enriching, packaging and sending browser event streams into Coveo's backend.\n- The relay playground in "
1469
- },
1470
- {
1471
- "kind": "code",
1472
- "text": "`apps/playground`"
1473
- },
1474
- {
1475
- "kind": "text",
1476
- "text": ": The playground is a sample webpage that can be used to experiment with and validate Event Protocol payloads.\n\nRelay can be used standalone, or be embedded in Coveo front end packages as the main client-side logging component.\n\n## Relay design principles and scope\n\nThe core relay library should adhere to a few core design principles:\n\n- Relay is responsible for handling any concerns that are relevant to generic event logging, including but not limited to:\n - Enriching events with information that is only present in the browser (e.g. userAgent, local time).\n - Tracking and persisting a unique identifier for a user (e.g. clientId)\n - Configuration of, and authentication with logging endpoints.\n - Privacy considerations (e.g. do not track, disable logging).\n- Relay is event-agnostic, meaning Relay has no knowledge on the contents of specific type of event payload that is being transmitted. It only handles event content, when that content is applicable to all logged events. In practice this means the following:\n - Relay event modification code is typically confined to the generic 'meta' key only.\n - Relay will not validate or modify event payloads, since it has no knowledge of the content of individual events.\n - Code should **not** contain event-type specific switches: e.g. "
1477
- },
1478
- {
1479
- "kind": "code",
1480
- "text": "`if (event_type = <sometype>) then`"
1481
- },
1482
- {
1483
- "kind": "text",
1484
- "text": " code is highly suspect.\n - Code should **not** contain line of business specific switches: e.g. "
1485
- },
1486
- {
1487
- "kind": "code",
1488
- "text": "`if (lob = service) then`"
1489
- },
1490
- {
1491
- "kind": "text",
1492
- "text": " code is highly suspect.\n- While Relay provides hooks which can be used to listen to the emission of events, it will not allow you to modify event content prior to logging. In practice, this functionality will be abused to \"fix up\" payloads or add \"business logic\" which makes it really hard to reason about payloads.\n- Relay supports all relevant Javascript based environments, including cross-browser support, node support and React native support.\n- Relay is **not** responsible for storing the TypeScript definitions of individual event types. Please use the [@coveo/relay-event-types](https://www.npmjs.com/package/@coveo/relay-event-types) package instead.\n\n## Event structure\n\nThe basic event structure for a generic client side event is as follows:\n\n"
1493
- },
1494
- {
1495
- "kind": "code",
1496
- "text": "```\n{\n <event parameters>\n meta: {\n type: the event type\n <dynamic meta data added by relay>\n config: {\n <subset of static relay config parameters>\n }\n }\n}\n```"
1497
- },
1498
- {
1499
- "kind": "text",
1500
- "text": "\n\nThis means an event payload can be freely defined, with the exception of the reserved keyword 'meta', which is exclusively intended to contain event metadata populated by Relay. Prior to logging events with the Coveo platform, ensure that you create appropriate event schemas in the [schema repository](https://github.com/coveo/analytics_schema).\n\nIf you want to log information from a Coveo owned backend service, do not use Relay. Instead, log them on the appropriate server side endpoint, see [this guide](https://coveord.atlassian.net/wiki/spaces/DATA/pages/3175383082/Server+side+event+logging)\n\n## Contributing\n\nPrior to contributing to the project, kindly review the guidelines outlined in [CONTRIBUTING.md](CONTRIBUTING.md)."
1468
+ "text": "\n\n## Official documentation\n\n- [Learn more about Relay](https://docs.coveo.com/en/relay/latest/)\n- [List of Event API schemas and reference types](https://docs.coveo.com/en/n9da0377/build-a-search-ui/event-api-reference)"
1501
1469
  }
1502
1470
  ],
1503
1471
  "symbolIdMap": {
package/lib/relay.cjs CHANGED
@@ -34,7 +34,7 @@ function createClientIdManager(environmentManager) {
34
34
  };
35
35
  }
36
36
 
37
- const version = "0.7.2";
37
+ const version = "0.7.3";
38
38
 
39
39
  function getEventConfig(config) {
40
40
  const { trackingId } = config;
package/lib/relay.js CHANGED
@@ -32,7 +32,7 @@ function createClientIdManager(environmentManager) {
32
32
  };
33
33
  }
34
34
 
35
- const version = "0.7.2";
35
+ const version = "0.7.3";
36
36
 
37
37
  function getEventConfig(config) {
38
38
  const { trackingId } = config;
package/lib/relay.mjs CHANGED
@@ -32,7 +32,7 @@ function createClientIdManager(environmentManager) {
32
32
  };
33
33
  }
34
34
 
35
- const version = "0.7.2";
35
+ const version = "0.7.3";
36
36
 
37
37
  function getEventConfig(config) {
38
38
  const { trackingId } = config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coveo/relay",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "A library for sending analytics events using Coveo's Event protocol.",
5
5
  "files": [
6
6
  "lib/**/*"
@@ -29,7 +29,8 @@
29
29
  "keywords": [
30
30
  "Coveo",
31
31
  "analytics",
32
- "event"
32
+ "event",
33
+ "Event Protocol"
33
34
  ],
34
35
  "author": "Coveo",
35
36
  "license": "Apache-2.0",
@@ -53,8 +54,8 @@
53
54
  "ts-jest": "^29.1.1",
54
55
  "typedoc": "^0.25.3",
55
56
  "typescript": "^5.1.6",
56
- "tsconfig": "0.0.0",
57
- "eslint-config-custom": "0.0.0"
57
+ "eslint-config-custom": "0.0.0",
58
+ "tsconfig": "0.0.0"
58
59
  },
59
60
  "dependencies": {
60
61
  "@coveo/explorer-messenger": "^0.1.1",