@streamscloud/streams-analytics-collector 2.0.5 → 2.0.6

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.
@@ -139,6 +139,45 @@ export declare class AppEventsTracker {
139
139
  * @param adId - The unique ad ID for this element
140
140
  */
141
141
  static trackAdImpressionWithVisibility(el: HTMLElement, adId: string): void;
142
+ /**
143
+ * Track when a short video is shown to the user (basic, immediate call)
144
+ * @param videoId - The ID of the short video
145
+ */
146
+ static trackShortVideoImpression(videoId: string): void;
147
+ /**
148
+ * Track when a short video is shown to the user, using viewport visibility tracking.
149
+ * The impression event will only be fired if the element becomes visible (at least 50% in viewport).
150
+ * The event is only fired once per videoId per session/visit.
151
+ *
152
+ * @param el - The DOM element to observe (e.g., the video element)
153
+ * @param videoId - The unique video ID for this element
154
+ */
155
+ static trackShortVideoImpressionWithVisibility(el: HTMLElement, videoId: string): void;
156
+ /**
157
+ * Track when a short video is viewed by the user
158
+ * @param videoId - The ID of the short video
159
+ * @param playedPercents - The percentage of the video that was played (optional)
160
+ */
161
+ static trackShortVideoView(videoId: string): void;
162
+ /**
163
+ * Track when a product in a short video is clicked
164
+ * @param productId - The ID of the product
165
+ */
166
+ static trackShortVideoProductClick(productId: string): void;
167
+ /**
168
+ * Track when a product in a short video is shown to the user (basic, immediate call)
169
+ * @param productId - The ID of the product
170
+ */
171
+ static trackShortVideoProductImpression(productId: string): void;
172
+ /**
173
+ * Track when a product in a short video is shown to the user, using viewport visibility tracking.
174
+ * The impression event will only be fired if the element becomes visible (at least 50% in viewport).
175
+ * The event is only fired once per productId per session/visit.
176
+ *
177
+ * @param el - The DOM element to observe (e.g., the product element)
178
+ * @param productId - The unique product ID for this element
179
+ */
180
+ static trackShortVideoProductImpressionWithVisibility(el: HTMLElement, productId: string): void;
142
181
  /**
143
182
  * Report an app event to the API
144
183
  * @private
@@ -234,6 +234,67 @@ class AppEventsTracker {
234
234
  });
235
235
  // The ViewportVisibilityTracker will call the callback when visible
236
236
  }
237
+ /**
238
+ * Track when a short video is shown to the user (basic, immediate call)
239
+ * @param videoId - The ID of the short video
240
+ */
241
+ static trackShortVideoImpression(videoId) {
242
+ this.reportAppEvent(videoId, AppEventType.ShortVideoImpression);
243
+ }
244
+ /**
245
+ * Track when a short video is shown to the user, using viewport visibility tracking.
246
+ * The impression event will only be fired if the element becomes visible (at least 50% in viewport).
247
+ * The event is only fired once per videoId per session/visit.
248
+ *
249
+ * @param el - The DOM element to observe (e.g., the video element)
250
+ * @param videoId - The unique video ID for this element
251
+ */
252
+ static trackShortVideoImpressionWithVisibility(el, videoId) {
253
+ if (!el || !videoId)
254
+ return;
255
+ ViewportVisibilityTracker.registerTile(el, videoId, (vid) => {
256
+ this.reportAppEvent(vid, AppEventType.ShortVideoImpression);
257
+ });
258
+ // The ViewportVisibilityTracker will call the callback when visible
259
+ }
260
+ /**
261
+ * Track when a short video is viewed by the user
262
+ * @param videoId - The ID of the short video
263
+ * @param playedPercents - The percentage of the video that was played (optional)
264
+ */
265
+ static trackShortVideoView(videoId) {
266
+ this.reportAppEvent(videoId, AppEventType.ShortVideoView);
267
+ }
268
+ /**
269
+ * Track when a product in a short video is clicked
270
+ * @param productId - The ID of the product
271
+ */
272
+ static trackShortVideoProductClick(productId) {
273
+ this.reportAppEvent(productId, AppEventType.ShortVideoProductClick);
274
+ }
275
+ /**
276
+ * Track when a product in a short video is shown to the user (basic, immediate call)
277
+ * @param productId - The ID of the product
278
+ */
279
+ static trackShortVideoProductImpression(productId) {
280
+ this.reportAppEvent(productId, AppEventType.ShortVideoProductImpression);
281
+ }
282
+ /**
283
+ * Track when a product in a short video is shown to the user, using viewport visibility tracking.
284
+ * The impression event will only be fired if the element becomes visible (at least 50% in viewport).
285
+ * The event is only fired once per productId per session/visit.
286
+ *
287
+ * @param el - The DOM element to observe (e.g., the product element)
288
+ * @param productId - The unique product ID for this element
289
+ */
290
+ static trackShortVideoProductImpressionWithVisibility(el, productId) {
291
+ if (!el || !productId)
292
+ return;
293
+ ViewportVisibilityTracker.registerTile(el, productId, (pid) => {
294
+ this.reportAppEvent(pid, AppEventType.ShortVideoProductImpression);
295
+ });
296
+ // The ViewportVisibilityTracker will call the callback when visible
297
+ }
237
298
  /**
238
299
  * Report an app event to the API
239
300
  * @private
@@ -1,16 +1,21 @@
1
1
  export declare enum AppEventType {
2
+ AdClick = "AD_CLICK",
3
+ AdImpression = "AD_IMPRESSION",
4
+ CommunityMessageView = "COMMUNITY_MESSAGE_VIEW",
5
+ ContributionCreated = "CONTRIBUTION_CREATED",
2
6
  PostView = "POST_VIEW",
7
+ ShortVideoImpression = "SHORT_VIDEO_IMPRESSION",
8
+ ShortVideoProductClick = "SHORT_VIDEO_PRODUCT_CLICK",
9
+ ShortVideoProductImpression = "SHORT_VIDEO_PRODUCT_IMPRESSION",
3
10
  ShortVideoView = "SHORT_VIDEO_VIEW",
4
- CommunityMessageView = "COMMUNITY_MESSAGE_VIEW",
5
- StreamTileImpression = "STREAM_TILE_IMPRESSION",
6
- StreamTileClick = "STREAM_TILE_CLICK",
7
- StreamView = "STREAM_VIEW",
8
11
  StreamEngagementTime = "STREAM_ENGAGEMENT_TIME",
9
- StreamScrollDepth = "STREAM_SCROLL_DEPTH",
10
12
  StreamPageView = "STREAM_PAGE_VIEW",
11
13
  StreamProductClick = "STREAM_PRODUCT_CLICK",
12
- AdImpression = "AD_IMPRESSION",
13
- AdClick = "AD_CLICK"
14
+ StreamProductImpression = "STREAM_PRODUCT_IMPRESSION",
15
+ StreamScrollDepth = "STREAM_SCROLL_DEPTH",
16
+ StreamTileClick = "STREAM_TILE_CLICK",
17
+ StreamTileImpression = "STREAM_TILE_IMPRESSION",
18
+ StreamView = "STREAM_VIEW"
14
19
  }
15
20
  export declare enum CommunityMessageStatus {
16
21
  Sent = "SENT",
@@ -1,17 +1,22 @@
1
1
  var AppEventType;
2
2
  (function (AppEventType) {
3
+ AppEventType["AdClick"] = "AD_CLICK";
4
+ AppEventType["AdImpression"] = "AD_IMPRESSION";
5
+ AppEventType["CommunityMessageView"] = "COMMUNITY_MESSAGE_VIEW";
6
+ AppEventType["ContributionCreated"] = "CONTRIBUTION_CREATED";
3
7
  AppEventType["PostView"] = "POST_VIEW";
8
+ AppEventType["ShortVideoImpression"] = "SHORT_VIDEO_IMPRESSION";
9
+ AppEventType["ShortVideoProductClick"] = "SHORT_VIDEO_PRODUCT_CLICK";
10
+ AppEventType["ShortVideoProductImpression"] = "SHORT_VIDEO_PRODUCT_IMPRESSION";
4
11
  AppEventType["ShortVideoView"] = "SHORT_VIDEO_VIEW";
5
- AppEventType["CommunityMessageView"] = "COMMUNITY_MESSAGE_VIEW";
6
- AppEventType["StreamTileImpression"] = "STREAM_TILE_IMPRESSION";
7
- AppEventType["StreamTileClick"] = "STREAM_TILE_CLICK";
8
- AppEventType["StreamView"] = "STREAM_VIEW";
9
12
  AppEventType["StreamEngagementTime"] = "STREAM_ENGAGEMENT_TIME";
10
- AppEventType["StreamScrollDepth"] = "STREAM_SCROLL_DEPTH";
11
13
  AppEventType["StreamPageView"] = "STREAM_PAGE_VIEW";
12
14
  AppEventType["StreamProductClick"] = "STREAM_PRODUCT_CLICK";
13
- AppEventType["AdImpression"] = "AD_IMPRESSION";
14
- AppEventType["AdClick"] = "AD_CLICK";
15
+ AppEventType["StreamProductImpression"] = "STREAM_PRODUCT_IMPRESSION";
16
+ AppEventType["StreamScrollDepth"] = "STREAM_SCROLL_DEPTH";
17
+ AppEventType["StreamTileClick"] = "STREAM_TILE_CLICK";
18
+ AppEventType["StreamTileImpression"] = "STREAM_TILE_IMPRESSION";
19
+ AppEventType["StreamView"] = "STREAM_VIEW";
15
20
  })(AppEventType || (AppEventType = {}));
16
21
  var CommunityMessageStatus;
17
22
  (function (CommunityMessageStatus) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/streams-analytics-collector",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",