@streamscloud/streams-analytics-collector 2.0.8 → 2.0.10

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,34 @@ 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;
132
+ /**
133
+ * Track when a product in a stream is added to cart
134
+ * @param productId - The ID of the product
135
+ * @param streamId - The ID of the stream
136
+ */
137
+ static trackStreamProductAddToCart(productId: string, streamId: string): void;
138
+ /**
139
+ * Track when a product in a stream is checked out
140
+ * @param productId - The ID of the product
141
+ * @param streamId - The ID of the stream
142
+ */
143
+ static trackStreamProductCheckout(productId: string, streamId: string): void;
116
144
  /**
117
145
  * Track when a post is closed
118
146
  * @param postId - The ID of the post
@@ -181,6 +209,18 @@ export declare class AppEventsTracker {
181
209
  * @param videoId - The ID of the short video containing the product
182
210
  */
183
211
  static trackShortVideoProductImpressionWithVisibility(el: HTMLElement, productId: string, videoId: string): void;
212
+ /**
213
+ * Track when a product in a short video is added to cart
214
+ * @param productId - The ID of the product
215
+ * @param videoId - The ID of the short video containing the product
216
+ */
217
+ static trackShortVideoProductAddToCart(productId: string, videoId: string): void;
218
+ /**
219
+ * Track when a product in a short video is checked out
220
+ * @param productId - The ID of the product
221
+ * @param videoId - The ID of the short video containing the product
222
+ */
223
+ static trackShortVideoProductCheckout(productId: string, videoId: string): void;
184
224
  /**
185
225
  * Report an app event to the API
186
226
  * @private
@@ -184,6 +184,47 @@ 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
+ }
212
+ /**
213
+ * Track when a product in a stream is added to cart
214
+ * @param productId - The ID of the product
215
+ * @param streamId - The ID of the stream
216
+ */
217
+ static trackStreamProductAddToCart(productId, streamId) {
218
+ this.reportAppEvent(productId, AppEventType.StreamProductAddToCart, streamId);
219
+ }
220
+ /**
221
+ * Track when a product in a stream is checked out
222
+ * @param productId - The ID of the product
223
+ * @param streamId - The ID of the stream
224
+ */
225
+ static trackStreamProductCheckout(productId, streamId) {
226
+ this.reportAppEvent(productId, AppEventType.StreamProductCheckout, streamId);
227
+ }
187
228
  /**
188
229
  * Track when a post is closed
189
230
  * @param postId - The ID of the post
@@ -298,6 +339,22 @@ class AppEventsTracker {
298
339
  });
299
340
  // The ViewportVisibilityTracker will call the callback when visible
300
341
  }
342
+ /**
343
+ * Track when a product in a short video is added to cart
344
+ * @param productId - The ID of the product
345
+ * @param videoId - The ID of the short video containing the product
346
+ */
347
+ static trackShortVideoProductAddToCart(productId, videoId) {
348
+ this.reportAppEvent(productId, AppEventType.ShortVideoProductAddToCart, videoId);
349
+ }
350
+ /**
351
+ * Track when a product in a short video is checked out
352
+ * @param productId - The ID of the product
353
+ * @param videoId - The ID of the short video containing the product
354
+ */
355
+ static trackShortVideoProductCheckout(productId, videoId) {
356
+ this.reportAppEvent(productId, AppEventType.ShortVideoProductCheckout, videoId);
357
+ }
301
358
  /**
302
359
  * Report an app event to the API
303
360
  * @private
@@ -5,11 +5,15 @@ export declare enum AppEventType {
5
5
  ContributionCreated = "CONTRIBUTION_CREATED",
6
6
  PostView = "POST_VIEW",
7
7
  ShortVideoImpression = "SHORT_VIDEO_IMPRESSION",
8
+ ShortVideoProductAddToCart = "SHORT_VIDEO_PRODUCT_ADD_TO_CART",
9
+ ShortVideoProductCheckout = "SHORT_VIDEO_PRODUCT_CHECKOUT",
8
10
  ShortVideoProductClick = "SHORT_VIDEO_PRODUCT_CLICK",
9
11
  ShortVideoProductImpression = "SHORT_VIDEO_PRODUCT_IMPRESSION",
10
12
  ShortVideoView = "SHORT_VIDEO_VIEW",
11
13
  StreamEngagementTime = "STREAM_ENGAGEMENT_TIME",
12
14
  StreamPageView = "STREAM_PAGE_VIEW",
15
+ StreamProductAddToCart = "STREAM_PRODUCT_ADD_TO_CART",
16
+ StreamProductCheckout = "STREAM_PRODUCT_CHECKOUT",
13
17
  StreamProductClick = "STREAM_PRODUCT_CLICK",
14
18
  StreamProductImpression = "STREAM_PRODUCT_IMPRESSION",
15
19
  StreamScrollDepth = "STREAM_SCROLL_DEPTH",
@@ -6,11 +6,15 @@ var AppEventType;
6
6
  AppEventType["ContributionCreated"] = "CONTRIBUTION_CREATED";
7
7
  AppEventType["PostView"] = "POST_VIEW";
8
8
  AppEventType["ShortVideoImpression"] = "SHORT_VIDEO_IMPRESSION";
9
+ AppEventType["ShortVideoProductAddToCart"] = "SHORT_VIDEO_PRODUCT_ADD_TO_CART";
10
+ AppEventType["ShortVideoProductCheckout"] = "SHORT_VIDEO_PRODUCT_CHECKOUT";
9
11
  AppEventType["ShortVideoProductClick"] = "SHORT_VIDEO_PRODUCT_CLICK";
10
12
  AppEventType["ShortVideoProductImpression"] = "SHORT_VIDEO_PRODUCT_IMPRESSION";
11
13
  AppEventType["ShortVideoView"] = "SHORT_VIDEO_VIEW";
12
14
  AppEventType["StreamEngagementTime"] = "STREAM_ENGAGEMENT_TIME";
13
15
  AppEventType["StreamPageView"] = "STREAM_PAGE_VIEW";
16
+ AppEventType["StreamProductAddToCart"] = "STREAM_PRODUCT_ADD_TO_CART";
17
+ AppEventType["StreamProductCheckout"] = "STREAM_PRODUCT_CHECKOUT";
14
18
  AppEventType["StreamProductClick"] = "STREAM_PRODUCT_CLICK";
15
19
  AppEventType["StreamProductImpression"] = "STREAM_PRODUCT_IMPRESSION";
16
20
  AppEventType["StreamScrollDepth"] = "STREAM_SCROLL_DEPTH";
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.10",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",