@streamscloud/streams-analytics-collector 2.0.8 → 2.0.9

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.
@@ -113,6 +113,22 @@ export declare class AppEventsTracker {
113
113
  * @param streamId - The ID of the stream
114
114
  */
115
115
  static trackStreamProductClicked(productId: string, streamId: string): void;
116
+ /**
117
+ * Track when a product in a stream is shown to the user (basic, immediate call)
118
+ * @param productId - The ID of the product
119
+ * @param streamId - The ID of the stream
120
+ */
121
+ static trackStreamProductImpression(productId: string, streamId: string): void;
122
+ /**
123
+ * Track when a product in a stream is shown to the user, using viewport visibility tracking.
124
+ * The impression event will only be fired if the element becomes visible (at least 50% in viewport).
125
+ * The event is only fired once per productId per session/visit.
126
+ *
127
+ * @param el - The DOM element to observe (e.g., the product element)
128
+ * @param productId - The unique product ID for this element
129
+ * @param streamId - The ID of the stream
130
+ */
131
+ static trackStreamProductImpressionWithVisibility(el: HTMLElement, productId: string, streamId: string): void;
116
132
  /**
117
133
  * Track when a post is closed
118
134
  * @param postId - The ID of the post
@@ -184,6 +184,31 @@ class AppEventsTracker {
184
184
  static trackStreamProductClicked(productId, streamId) {
185
185
  this.reportAppEvent(productId, AppEventType.StreamProductClick, streamId);
186
186
  }
187
+ /**
188
+ * Track when a product in a stream is shown to the user (basic, immediate call)
189
+ * @param productId - The ID of the product
190
+ * @param streamId - The ID of the stream
191
+ */
192
+ static trackStreamProductImpression(productId, streamId) {
193
+ this.reportAppEvent(productId, AppEventType.StreamProductImpression, streamId);
194
+ }
195
+ /**
196
+ * Track when a product in a stream is shown to the user, using viewport visibility tracking.
197
+ * The impression event will only be fired if the element becomes visible (at least 50% in viewport).
198
+ * The event is only fired once per productId per session/visit.
199
+ *
200
+ * @param el - The DOM element to observe (e.g., the product element)
201
+ * @param productId - The unique product ID for this element
202
+ * @param streamId - The ID of the stream
203
+ */
204
+ static trackStreamProductImpressionWithVisibility(el, productId, streamId) {
205
+ if (!el || !productId || !streamId)
206
+ return;
207
+ ViewportVisibilityTracker.registerTile(el, productId, (pid) => {
208
+ this.reportAppEvent(pid, AppEventType.StreamProductImpression, streamId);
209
+ });
210
+ // The ViewportVisibilityTracker will call the callback when visible
211
+ }
187
212
  /**
188
213
  * Track when a post is closed
189
214
  * @param postId - The ID of the post
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/streams-analytics-collector",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",