@streamscloud/streams-analytics-collector 2.0.10 → 4.0.0
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/dist/analytics-collector.d.ts +24 -0
- package/dist/analytics-collector.js +51 -0
- package/dist/appearance-events-tracker.d.ts +15 -0
- package/dist/appearance-events-tracker.js +27 -0
- package/dist/graphql/report-event.graphql.js +3 -0
- package/dist/graphql/report-external-event.graphql.js +3 -0
- package/dist/graphql/report-external-measurement.graphql.js +3 -0
- package/dist/graphql/report-measurement.graphql.js +3 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -4
- package/dist/measurements-batcher.d.ts +24 -0
- package/dist/measurements-batcher.js +91 -0
- package/dist/reporting/events-reporter.d.ts +15 -0
- package/dist/reporting/events-reporter.js +33 -0
- package/dist/reporting/gql-data-sender.d.ts +12 -0
- package/dist/reporting/gql-data-sender.js +35 -0
- package/dist/reporting/index.d.ts +4 -0
- package/dist/reporting/measurements-reporter.d.ts +16 -0
- package/dist/reporting/measurements-reporter.js +34 -0
- package/dist/reporting/types.d.ts +58 -0
- package/dist/reporting/types.js +35 -0
- package/dist/schemas.d.ts +5 -0
- package/dist/schemas.js +17 -0
- package/dist/viewport-visibility-tracker.d.ts +13 -0
- package/dist/viewport-visibility-tracker.js +104 -0
- package/package.json +5 -6
- package/dist/adcampaignsquery.graphql.js +0 -3
- package/dist/analytics/ViewportVisibilityTracker.d.ts +0 -46
- package/dist/analytics/ViewportVisibilityTracker.js +0 -117
- package/dist/analytics/app-events-tracker.d.ts +0 -243
- package/dist/analytics/app-events-tracker.js +0 -430
- package/dist/analytics/index.d.ts +0 -3
- package/dist/analytics/index.js +0 -3
- package/dist/analytics/types.d.ts +0 -37
- package/dist/analytics/types.js +0 -33
- package/dist/analytics.graphql.js +0 -3
- package/dist/articlequery.graphql.js +0 -3
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.js +0 -1
- package/dist/components/types.d.ts +0 -19
- package/dist/components/types.js +0 -12
- package/dist/components-data/component-data-provider.service.d.ts +0 -3
- package/dist/components-data/component-data-provider.service.js +0 -35
- package/dist/components-data/components-data-fetcher.service.d.ts +0 -5
- package/dist/components-data/components-data-fetcher.service.js +0 -35
- package/dist/components-data/components-data-parameters-reader.service.d.ts +0 -2
- package/dist/components-data/components-data-parameters-reader.service.js +0 -20
- package/dist/components-data/index.d.ts +0 -4
- package/dist/components-data/index.js +0 -3
- package/dist/components-data/types.d.ts +0 -24
- package/dist/components-data/types.js +0 -6
- package/dist/contentlistsquery.graphql.js +0 -3
- package/dist/data-loaders/index.d.ts +0 -2
- package/dist/data-loaders/index.js +0 -2
- package/dist/data-loaders/short-videos-data-loader/index.d.ts +0 -2
- package/dist/data-loaders/short-videos-data-loader/loader.d.ts +0 -4
- package/dist/data-loaders/short-videos-data-loader/loader.js +0 -14
- package/dist/data-loaders/short-videos-data-loader/mapper.d.ts +0 -3
- package/dist/data-loaders/short-videos-data-loader/mapper.js +0 -27
- package/dist/data-loaders/short-videos-data-loader/types.d.ts +0 -14
- package/dist/data-loaders/streams-data-loader/index.d.ts +0 -2
- package/dist/data-loaders/streams-data-loader/loader.d.ts +0 -4
- package/dist/data-loaders/streams-data-loader/loader.js +0 -14
- package/dist/data-loaders/streams-data-loader/mapper.d.ts +0 -3
- package/dist/data-loaders/streams-data-loader/mapper.js +0 -11
- package/dist/data-loaders/streams-data-loader/types.d.ts +0 -4
- package/dist/data-loaders/types.d.ts +0 -3
- package/dist/external-analytics.graphql.js +0 -3
- package/dist/internal-analytics.graphql.js +0 -3
- package/dist/postsquery.graphql.js +0 -3
- package/dist/services/embed-content-api-client.d.ts +0 -8
- package/dist/services/embed-content-api-client.js +0 -48
- package/dist/services/embed-content-client.service.d.ts +0 -2
- package/dist/services/embed-content-client.service.js +0 -5
- package/dist/services/index.d.ts +0 -2
- package/dist/services/index.js +0 -2
- package/dist/services/operations/posts-query.graphql.js +0 -3
- package/dist/services/operations/streams-query.graphql.js +0 -3
- package/dist/services/types.d.ts +0 -303
- package/dist/streams-api-client-model.d.ts +0 -5
- package/dist/streams-content-api-client.d.ts +0 -14
- package/dist/streams-content-api-client.js +0 -89
- package/dist/types.d.ts +0 -4
- package/dist/types.js +0 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
const VISIBILITY_THRESHOLD = 0.5;
|
|
2
|
+
class ViewportVisibilityTracker {
|
|
3
|
+
trackedIds = new Set();
|
|
4
|
+
targetToElements = new Map();
|
|
5
|
+
elementToTargetId = new Map();
|
|
6
|
+
callbacks = new Map();
|
|
7
|
+
observer;
|
|
8
|
+
registerElement(el, targetId, callback) {
|
|
9
|
+
if (this.trackedIds.has(targetId)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const set = this.targetToElements.get(targetId) ?? new Set();
|
|
13
|
+
set.add(el);
|
|
14
|
+
this.targetToElements.set(targetId, set);
|
|
15
|
+
this.elementToTargetId.set(el, targetId);
|
|
16
|
+
this.callbacks.set(targetId, callback);
|
|
17
|
+
const observer = this.getObserver();
|
|
18
|
+
observer.observe(el);
|
|
19
|
+
}
|
|
20
|
+
unregisterElement(el) {
|
|
21
|
+
const targetId = this.elementToTargetId.get(el);
|
|
22
|
+
if (!targetId) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.getObserver().unobserve(el);
|
|
26
|
+
this.elementToTargetId.delete(el);
|
|
27
|
+
const set = this.targetToElements.get(targetId);
|
|
28
|
+
if (set) {
|
|
29
|
+
set.delete(el);
|
|
30
|
+
if (set.size === 0) {
|
|
31
|
+
this.targetToElements.delete(targetId);
|
|
32
|
+
this.callbacks.delete(targetId);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
unregisterAllElements(targetId) {
|
|
37
|
+
const set = this.targetToElements.get(targetId);
|
|
38
|
+
if (set) {
|
|
39
|
+
for (const el of set) {
|
|
40
|
+
this.getObserver().unobserve(el);
|
|
41
|
+
this.elementToTargetId.delete(el);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
this.targetToElements.delete(targetId);
|
|
45
|
+
this.callbacks.delete(targetId);
|
|
46
|
+
}
|
|
47
|
+
reset() {
|
|
48
|
+
for (const set of this.targetToElements.values()) {
|
|
49
|
+
for (const el of set) {
|
|
50
|
+
this.getObserver().unobserve(el);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
this.trackedIds.clear();
|
|
54
|
+
this.targetToElements.clear();
|
|
55
|
+
this.elementToTargetId.clear();
|
|
56
|
+
this.callbacks.clear();
|
|
57
|
+
if (this.observer) {
|
|
58
|
+
this.observer.disconnect();
|
|
59
|
+
this.observer = undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
getObserver() {
|
|
63
|
+
if (!this.observer) {
|
|
64
|
+
this.observer = new IntersectionObserver(this.handleIntersections.bind(this), {
|
|
65
|
+
threshold: VISIBILITY_THRESHOLD,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return this.observer;
|
|
69
|
+
}
|
|
70
|
+
handleIntersections(entries) {
|
|
71
|
+
for (const entry of entries) {
|
|
72
|
+
const el = entry.target;
|
|
73
|
+
const targetId = this.elementToTargetId.get(el);
|
|
74
|
+
if (!targetId) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (entry.isIntersecting && entry.intersectionRatio >= VISIBILITY_THRESHOLD) {
|
|
78
|
+
if (!this.trackedIds.has(targetId)) {
|
|
79
|
+
this.trackedIds.add(targetId);
|
|
80
|
+
const cb = this.callbacks.get(targetId);
|
|
81
|
+
if (cb) {
|
|
82
|
+
try {
|
|
83
|
+
cb(targetId);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.error('ViewportVisibilityTracker callback error:', err);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const set = this.targetToElements.get(targetId);
|
|
90
|
+
if (set) {
|
|
91
|
+
for (const node of set) {
|
|
92
|
+
this.getObserver().unobserve(node);
|
|
93
|
+
this.elementToTargetId.delete(node);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
this.targetToElements.delete(targetId);
|
|
97
|
+
this.callbacks.delete(targetId);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { ViewportVisibilityTracker };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamscloud/streams-analytics-collector",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
"svelte": "./dist/index.js"
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
13
12
|
},
|
|
14
|
-
"./
|
|
15
|
-
"import": "./dist/
|
|
16
|
-
"types": "./dist/
|
|
13
|
+
"./reporting": {
|
|
14
|
+
"import": "./dist/reporting/index.js",
|
|
15
|
+
"types": "./dist/reporting/index.d.ts"
|
|
17
16
|
}
|
|
18
17
|
},
|
|
19
18
|
"files": [
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var SiteActiveCampaignsQuery = "query SiteActiveCampaigns($filter: SiteActiveCampaignsFilterInput!, $pageQuery: PaginationOfAdCampaignsOrderByInput!) {\n siteActiveCampaigns(filter: $filter, pagination: $pageQuery) {\n total\n items {\n id\n name\n status\n adGroupIds\n adGroups {\n name\n ads {\n ..._adForGridPayloadFragment\n }\n adPlacement {\n name\n }\n }\n status\n updatedAt\n editorProfile {\n id\n name\n handle\n image\n }\n }\n }\n}\n\nfragment _adForGridPayloadFragment on Ad {\n id\n media {\n type\n url\n thumbnailUrl\n }\n name\n title\n description\n status\n updatedAt\n}\n";
|
|
2
|
-
|
|
3
|
-
export { SiteActiveCampaignsQuery as default };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ViewportVisibilityTracker
|
|
3
|
-
*
|
|
4
|
-
* Utility for tracking when DOM elements (e.g., stream tiles) become visible in the viewport.
|
|
5
|
-
* Fires impression events only once per unique element (by streamId) per session/visit.
|
|
6
|
-
* Uses IntersectionObserver for efficient observation, with a fallback to manual visibility checks.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* ViewportVisibilityTracker.registerTile(element, streamId, callback?);
|
|
10
|
-
*
|
|
11
|
-
* - The element must have a unique streamId (e.g., from data-stream-id attribute).
|
|
12
|
-
* - The impression event is fired only once per streamId per session.
|
|
13
|
-
* - Handles rapid scrolling, re-renders, and element replacement.
|
|
14
|
-
* - You can provide a custom callback to be called when the element becomes visible.
|
|
15
|
-
*/
|
|
16
|
-
export declare class ViewportVisibilityTracker {
|
|
17
|
-
private static trackedStreamIds;
|
|
18
|
-
private static observedElements;
|
|
19
|
-
private static callbacks;
|
|
20
|
-
private static observer;
|
|
21
|
-
/**
|
|
22
|
-
* Register a tile element for visibility tracking.
|
|
23
|
-
* @param el The DOM element to observe
|
|
24
|
-
* @param streamId The unique stream ID for this tile
|
|
25
|
-
* @param callback Optional callback to call when the element becomes visible (defaults to AppEventsTracker.trackStreamTileImpression)
|
|
26
|
-
*/
|
|
27
|
-
static registerTile(el: HTMLElement, streamId: string, callback?: (streamId: string) => void): void;
|
|
28
|
-
/**
|
|
29
|
-
* Internal: Get or create the IntersectionObserver instance
|
|
30
|
-
*/
|
|
31
|
-
private static getObserver;
|
|
32
|
-
/**
|
|
33
|
-
* Internal: IntersectionObserver callback
|
|
34
|
-
*/
|
|
35
|
-
private static handleIntersections;
|
|
36
|
-
/**
|
|
37
|
-
* Fallback: Check if an element is in the viewport (at least 50% visible)
|
|
38
|
-
* @param el The DOM element
|
|
39
|
-
* @returns true if at least 50% of the element is visible
|
|
40
|
-
*/
|
|
41
|
-
static isElementInViewport(el: HTMLElement): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Reset tracked state (for testing or new session)
|
|
44
|
-
*/
|
|
45
|
-
static reset(): void;
|
|
46
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { AppEventsTracker } from './app-events-tracker.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ViewportVisibilityTracker
|
|
5
|
-
*
|
|
6
|
-
* Utility for tracking when DOM elements (e.g., stream tiles) become visible in the viewport.
|
|
7
|
-
* Fires impression events only once per unique element (by streamId) per session/visit.
|
|
8
|
-
* Uses IntersectionObserver for efficient observation, with a fallback to manual visibility checks.
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
* ViewportVisibilityTracker.registerTile(element, streamId, callback?);
|
|
12
|
-
*
|
|
13
|
-
* - The element must have a unique streamId (e.g., from data-stream-id attribute).
|
|
14
|
-
* - The impression event is fired only once per streamId per session.
|
|
15
|
-
* - Handles rapid scrolling, re-renders, and element replacement.
|
|
16
|
-
* - You can provide a custom callback to be called when the element becomes visible.
|
|
17
|
-
*/
|
|
18
|
-
class ViewportVisibilityTracker {
|
|
19
|
-
// Set of streamIds that have already been tracked for impression
|
|
20
|
-
static trackedStreamIds = new Set();
|
|
21
|
-
// Map from streamId to the currently observed element
|
|
22
|
-
static observedElements = new Map();
|
|
23
|
-
// Map from streamId to the callback to call when visible
|
|
24
|
-
static callbacks = new Map();
|
|
25
|
-
// Singleton IntersectionObserver instance
|
|
26
|
-
static observer = null;
|
|
27
|
-
/**
|
|
28
|
-
* Register a tile element for visibility tracking.
|
|
29
|
-
* @param el The DOM element to observe
|
|
30
|
-
* @param streamId The unique stream ID for this tile
|
|
31
|
-
* @param callback Optional callback to call when the element becomes visible (defaults to AppEventsTracker.trackStreamTileImpression)
|
|
32
|
-
*/
|
|
33
|
-
static registerTile(el, streamId, callback = AppEventsTracker.trackStreamTileImpression.bind(AppEventsTracker)) {
|
|
34
|
-
if (!el || !streamId)
|
|
35
|
-
return;
|
|
36
|
-
// If already tracked, do nothing
|
|
37
|
-
if (this.trackedStreamIds.has(streamId))
|
|
38
|
-
return;
|
|
39
|
-
// If an element for this streamId is already being observed, unobserve it (handles re-renders)
|
|
40
|
-
const prevEl = this.observedElements.get(streamId);
|
|
41
|
-
if (prevEl && prevEl !== el) {
|
|
42
|
-
this.getObserver().unobserve(prevEl);
|
|
43
|
-
}
|
|
44
|
-
this.observedElements.set(streamId, el);
|
|
45
|
-
this.callbacks.set(streamId, callback);
|
|
46
|
-
this.getObserver().observe(el);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Internal: Get or create the IntersectionObserver instance
|
|
50
|
-
*/
|
|
51
|
-
static getObserver() {
|
|
52
|
-
if (!this.observer) {
|
|
53
|
-
this.observer = new window.IntersectionObserver(this.handleIntersections.bind(this), {
|
|
54
|
-
threshold: 0.5, // At least 50% of the element must be visible
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return this.observer;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Internal: IntersectionObserver callback
|
|
61
|
-
*/
|
|
62
|
-
static handleIntersections(entries) {
|
|
63
|
-
for (const entry of entries) {
|
|
64
|
-
const el = entry.target;
|
|
65
|
-
// Try to get streamId from map or from data attribute
|
|
66
|
-
let streamId = Array.from(this.observedElements.entries()).find(([, v]) => v === el)?.[0];
|
|
67
|
-
if (!streamId) {
|
|
68
|
-
streamId = el.getAttribute("data-stream-id") || undefined;
|
|
69
|
-
}
|
|
70
|
-
if (!streamId)
|
|
71
|
-
continue;
|
|
72
|
-
if (entry.isIntersecting && entry.intersectionRatio >= 0.5) {
|
|
73
|
-
// Only fire once per streamId per session
|
|
74
|
-
if (!this.trackedStreamIds.has(streamId)) {
|
|
75
|
-
this.trackedStreamIds.add(streamId);
|
|
76
|
-
const callback = this.callbacks.get(streamId);
|
|
77
|
-
if (callback) {
|
|
78
|
-
callback(streamId);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// Once tracked, stop observing this element
|
|
82
|
-
this.getObserver().unobserve(el);
|
|
83
|
-
this.observedElements.delete(streamId);
|
|
84
|
-
this.callbacks.delete(streamId);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Fallback: Check if an element is in the viewport (at least 50% visible)
|
|
90
|
-
* @param el The DOM element
|
|
91
|
-
* @returns true if at least 50% of the element is visible
|
|
92
|
-
*/
|
|
93
|
-
static isElementInViewport(el) {
|
|
94
|
-
if (!el)
|
|
95
|
-
return false;
|
|
96
|
-
const rect = el.getBoundingClientRect();
|
|
97
|
-
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
98
|
-
const windowWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
99
|
-
const vertInView = rect.top <= windowHeight * 0.5 && rect.top + rect.height * 0.5 >= 0;
|
|
100
|
-
const horInView = rect.left <= windowWidth * 0.5 && rect.left + rect.width * 0.5 >= 0;
|
|
101
|
-
return vertInView && horInView;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Reset tracked state (for testing or new session)
|
|
105
|
-
*/
|
|
106
|
-
static reset() {
|
|
107
|
-
this.trackedStreamIds.clear();
|
|
108
|
-
this.observedElements.clear();
|
|
109
|
-
this.callbacks.clear();
|
|
110
|
-
if (this.observer) {
|
|
111
|
-
this.observer.disconnect();
|
|
112
|
-
this.observer = null;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export { ViewportVisibilityTracker };
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import type { Client } from "@urql/core";
|
|
2
|
-
/**
|
|
3
|
-
* AppEventsTracker is a utility class for tracking various user events in StreamsCloud applications
|
|
4
|
-
* such as post views, community message views, stream interactions, etc.
|
|
5
|
-
*/
|
|
6
|
-
export declare class AppEventsTracker {
|
|
7
|
-
private static reported;
|
|
8
|
-
private static playedPercentsByPost;
|
|
9
|
-
private static videosByPage;
|
|
10
|
-
private static gqlEndpoint;
|
|
11
|
-
private static client;
|
|
12
|
-
private static organizationId;
|
|
13
|
-
private static profileId;
|
|
14
|
-
private static useClient;
|
|
15
|
-
/**
|
|
16
|
-
* Set the GraphQL client for making API calls (for authorized calls)
|
|
17
|
-
* @param client - The URQL client instance
|
|
18
|
-
*/
|
|
19
|
-
static setClient(client: Client): void;
|
|
20
|
-
/**
|
|
21
|
-
* Set the GraphQL endpoint for making API calls (for non-authorized calls)
|
|
22
|
-
* @param endpoint - The GraphQL endpoint URL
|
|
23
|
-
*/
|
|
24
|
-
static setEndpoint(endpoint: string): void;
|
|
25
|
-
/**
|
|
26
|
-
* Set organization ID for non-authorized calls
|
|
27
|
-
* @param organizationId - The organization ID
|
|
28
|
-
*/
|
|
29
|
-
static setOrganizationId(organizationId: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Set profile ID for non-authorized calls
|
|
32
|
-
* @param profileId - The profile ID
|
|
33
|
-
*/
|
|
34
|
-
static setProfileId(profileId: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* Track the progress of a short video within a page
|
|
37
|
-
* @param pageId - The ID of the page containing the video
|
|
38
|
-
* @param videoId - The ID of the video
|
|
39
|
-
* @param playedPercents - The percentage of the video that has been played
|
|
40
|
-
* @param streamId - The ID of the stream containing the video (optional)
|
|
41
|
-
*/
|
|
42
|
-
static trackShortVideoProgress(pageId: string, videoId: string, playedPercents: number, streamId?: string): void;
|
|
43
|
-
/**
|
|
44
|
-
* Report all video views for a page when it's deactivated
|
|
45
|
-
* @param pageId - The ID of the page that's being deactivated
|
|
46
|
-
* @param streamId - The ID of the stream containing the page (optional)
|
|
47
|
-
*/
|
|
48
|
-
static reportPageVideoViews(pageId: string, streamId?: string): void;
|
|
49
|
-
/**
|
|
50
|
-
* Track when a post is opened
|
|
51
|
-
* @param postId - The ID of the post
|
|
52
|
-
* @param ownerId - The ID of the owner
|
|
53
|
-
*/
|
|
54
|
-
static trackPostOpened(postId: string, ownerId: string): void;
|
|
55
|
-
/**
|
|
56
|
-
* Track when a post is being played
|
|
57
|
-
* @param postId - The ID of the post
|
|
58
|
-
* @param playedPercents - The percentage of the post that has been played
|
|
59
|
-
* @deprecated Consider using trackShortVideoProgress for better tracking of multiple videos
|
|
60
|
-
*/
|
|
61
|
-
static reportVideoPostPlayingProgress(postId: string, playedPercents: number): void;
|
|
62
|
-
/**
|
|
63
|
-
* Track when a community message is opened
|
|
64
|
-
* @param messageId - The ID of the message
|
|
65
|
-
* @param status - The status of the message
|
|
66
|
-
*/
|
|
67
|
-
static trackCommunityMessageOpened(messageId: string, status: string): void;
|
|
68
|
-
/**
|
|
69
|
-
* Track when a stream tile is shown to the user (basic, immediate call).
|
|
70
|
-
* @param streamId - The ID of the stream
|
|
71
|
-
*/
|
|
72
|
-
static trackStreamTileImpression(streamId: string): void;
|
|
73
|
-
/**
|
|
74
|
-
* Track when a stream tile is shown to the user, using viewport visibility tracking.
|
|
75
|
-
* The impression event will only be fired if the element becomes visible (at least 50% in viewport).
|
|
76
|
-
* The event is only fired once per streamId per session/visit.
|
|
77
|
-
*
|
|
78
|
-
* @param el - The DOM element to observe (e.g., the stream tile)
|
|
79
|
-
* @param streamId - The unique stream ID for this tile
|
|
80
|
-
*/
|
|
81
|
-
static trackStreamTileImpressionWithVisibility(el: HTMLElement, streamId: string): void;
|
|
82
|
-
/**
|
|
83
|
-
* Track when a stream tile is clicked
|
|
84
|
-
* @param streamId - The ID of the stream
|
|
85
|
-
*/
|
|
86
|
-
static trackStreamTileClick(streamId: string): void;
|
|
87
|
-
/**
|
|
88
|
-
* Track when a stream is viewed
|
|
89
|
-
* @param streamId - The ID of the stream
|
|
90
|
-
*/
|
|
91
|
-
static trackStreamView(streamId: string): void;
|
|
92
|
-
/**
|
|
93
|
-
* Track the amount of time a user engages with a stream
|
|
94
|
-
* @param streamId - The ID of the stream
|
|
95
|
-
* @param engagementTimeSeconds - The engagement time in seconds
|
|
96
|
-
*/
|
|
97
|
-
static trackStreamEngagementTime(streamId: string, engagementTimeSeconds: number): void;
|
|
98
|
-
/**
|
|
99
|
-
* Track how deep a user scrolls in a stream
|
|
100
|
-
* @param streamId - The ID of the stream
|
|
101
|
-
* @param scrollDepth - The scroll depth (typically a percentage)
|
|
102
|
-
*/
|
|
103
|
-
static trackStreamScrollDepth(streamId: string, scrollDepth: number): void;
|
|
104
|
-
/**
|
|
105
|
-
* Track when a stream page is viewed
|
|
106
|
-
* @param pageId - The ID of the page
|
|
107
|
-
* @param streamId - The ID of the stream
|
|
108
|
-
*/
|
|
109
|
-
static trackStreamPageView(pageId: string, streamId: string): void;
|
|
110
|
-
/**
|
|
111
|
-
* Track when a product in a stream is clicked
|
|
112
|
-
* @param productId - The ID of the product
|
|
113
|
-
* @param streamId - The ID of the stream
|
|
114
|
-
*/
|
|
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;
|
|
144
|
-
/**
|
|
145
|
-
* Track when a post is closed
|
|
146
|
-
* @param postId - The ID of the post
|
|
147
|
-
* @param streamId - The ID of the stream
|
|
148
|
-
* @deprecated Consider using trackShortVideoProgress and reportPageVideoViews for better tracking of multiple videos
|
|
149
|
-
*/
|
|
150
|
-
static trackClosed(postId: string, streamId: string): void;
|
|
151
|
-
/**
|
|
152
|
-
* Track when an ad is shown to the user
|
|
153
|
-
* @param adId - The ID of the ad
|
|
154
|
-
*/
|
|
155
|
-
static trackAdImpression(adId: string): void;
|
|
156
|
-
/**
|
|
157
|
-
* Track when an ad is clicked by the user
|
|
158
|
-
* @param adId - The ID of the ad
|
|
159
|
-
*/
|
|
160
|
-
static trackAdClick(adId: string): void;
|
|
161
|
-
/**
|
|
162
|
-
* Track when an ad is shown to the user, using viewport visibility tracking.
|
|
163
|
-
* The impression event will only be fired if the element becomes visible (at least 50% in viewport).
|
|
164
|
-
* The event is only fired once per adId per session/visit.
|
|
165
|
-
*
|
|
166
|
-
* @param el - The DOM element to observe (e.g., the ad element)
|
|
167
|
-
* @param adId - The unique ad ID for this element
|
|
168
|
-
*/
|
|
169
|
-
static trackAdImpressionWithVisibility(el: HTMLElement, adId: string): void;
|
|
170
|
-
/**
|
|
171
|
-
* Track when a short video is shown to the user (basic, immediate call)
|
|
172
|
-
* @param videoId - The ID of the short video
|
|
173
|
-
*/
|
|
174
|
-
static trackShortVideoImpression(videoId: string): void;
|
|
175
|
-
/**
|
|
176
|
-
* Track when a short video is shown to the user, using viewport visibility tracking.
|
|
177
|
-
* The impression event will only be fired if the element becomes visible (at least 50% in viewport).
|
|
178
|
-
* The event is only fired once per videoId per session/visit.
|
|
179
|
-
*
|
|
180
|
-
* @param el - The DOM element to observe (e.g., the video element)
|
|
181
|
-
* @param videoId - The unique video ID for this element
|
|
182
|
-
*/
|
|
183
|
-
static trackShortVideoImpressionWithVisibility(el: HTMLElement, videoId: string): void;
|
|
184
|
-
/**
|
|
185
|
-
* Track when a short video is viewed by the user
|
|
186
|
-
* @param videoId - The ID of the short video
|
|
187
|
-
* @param playedPercents - The percentage of the video that was played (optional)
|
|
188
|
-
*/
|
|
189
|
-
static trackShortVideoView(videoId: string): void;
|
|
190
|
-
/**
|
|
191
|
-
* Track when a product in a short video is clicked
|
|
192
|
-
* @param productId - The ID of the product
|
|
193
|
-
* @param videoId - The ID of the short video containing the product
|
|
194
|
-
*/
|
|
195
|
-
static trackShortVideoProductClick(productId: string, videoId: string): void;
|
|
196
|
-
/**
|
|
197
|
-
* Track when a product in a short video is shown to the user (basic, immediate call)
|
|
198
|
-
* @param productId - The ID of the product
|
|
199
|
-
* @param videoId - The ID of the short video containing the product
|
|
200
|
-
*/
|
|
201
|
-
static trackShortVideoProductImpression(productId: string, videoId: string): void;
|
|
202
|
-
/**
|
|
203
|
-
* Track when a product in a short video is shown to the user, using viewport visibility tracking.
|
|
204
|
-
* The impression event will only be fired if the element becomes visible (at least 50% in viewport).
|
|
205
|
-
* The event is only fired once per productId per session/visit.
|
|
206
|
-
*
|
|
207
|
-
* @param el - The DOM element to observe (e.g., the product element)
|
|
208
|
-
* @param productId - The unique product ID for this element
|
|
209
|
-
* @param videoId - The ID of the short video containing the product
|
|
210
|
-
*/
|
|
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;
|
|
224
|
-
/**
|
|
225
|
-
* Report an app event to the API
|
|
226
|
-
* @private
|
|
227
|
-
* @param targetId - The ID of the target object
|
|
228
|
-
* @param eventType - The type of event
|
|
229
|
-
* @param ownerId - The ID of the owner (optional)
|
|
230
|
-
* @param value - Additional value for the event (optional)
|
|
231
|
-
*/
|
|
232
|
-
private static reportAppEvent;
|
|
233
|
-
/**
|
|
234
|
-
* Save an app event to the API
|
|
235
|
-
* @private
|
|
236
|
-
* @param targetId - The ID of the target object
|
|
237
|
-
* @param eventType - The type of event
|
|
238
|
-
* @param ownerId - The ID of the owner (optional)
|
|
239
|
-
* @param value - Additional value for the event (optional)
|
|
240
|
-
*/
|
|
241
|
-
private static saveAppEvent;
|
|
242
|
-
private static queryGql;
|
|
243
|
-
}
|