@streamscloud/embeddable 14.0.3 → 15.0.0-rc.1
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/core/analytics.installation-id.d.ts +5 -0
- package/dist/core/{analytics.profile-id.js → analytics.installation-id.js} +20 -10
- package/dist/external-api/data-providers/internal-media-center-analytics-handler.d.ts +14 -14
- package/dist/external-api/data-providers/internal-media-center-analytics-handler.js +170 -19
- package/dist/external-api/data-providers/internal-post-analytics-handler.d.ts +7 -7
- package/dist/external-api/data-providers/internal-post-analytics-handler.js +72 -11
- package/dist/external-api/data-providers/internal-stream-analytics-handler.d.ts +12 -13
- package/dist/external-api/data-providers/internal-stream-analytics-handler.js +162 -18
- package/dist/external-api/data-providers/mapper.d.ts +3 -0
- package/dist/external-api/data-providers/mapper.js +18 -0
- package/dist/external-api/data-providers/post-data-loaders/mapper.js +1 -3
- package/dist/posts/posts-player/posts-player-view.svelte +2 -5
- package/dist/posts/posts-player/types.d.ts +3 -5
- package/dist/streams/streams-player/streams-player-view.svelte +0 -3
- package/dist/streams/streams-player/types.d.ts +0 -1
- package/package.json +2 -2
- package/dist/core/analytics.profile-id.d.ts +0 -5
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Key used for storing the
|
|
2
|
+
* Key used for storing the installation ID in local storage (new)
|
|
3
|
+
*/
|
|
4
|
+
const INSTALLATION_ID_STORAGE_KEY = 'streamscloud_installation_id';
|
|
5
|
+
/**
|
|
6
|
+
* Legacy key used for storing the profile ID in local storage (to be migrated)
|
|
3
7
|
*/
|
|
4
8
|
const PROFILE_ID_STORAGE_KEY = 'streamscloud_profile_id';
|
|
5
9
|
/**
|
|
6
|
-
* Retrieves the
|
|
7
|
-
* @returns The
|
|
10
|
+
* Retrieves the installation ID from localStorage or generates a new one if it doesn't exist
|
|
11
|
+
* @returns The installation ID to use for analytics tracking
|
|
8
12
|
*/
|
|
9
|
-
export const
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
export const getOrCreateInstallationId = () => {
|
|
14
|
+
const currentId = localStorage.getItem(INSTALLATION_ID_STORAGE_KEY);
|
|
15
|
+
if (currentId) {
|
|
16
|
+
return currentId;
|
|
17
|
+
}
|
|
18
|
+
const legacyId = localStorage.getItem(PROFILE_ID_STORAGE_KEY);
|
|
19
|
+
if (legacyId) {
|
|
20
|
+
localStorage.setItem(INSTALLATION_ID_STORAGE_KEY, legacyId);
|
|
21
|
+
localStorage.removeItem(PROFILE_ID_STORAGE_KEY);
|
|
22
|
+
return legacyId;
|
|
15
23
|
}
|
|
16
|
-
|
|
24
|
+
const newInstallationId = safeRandomUUID();
|
|
25
|
+
localStorage.setItem(INSTALLATION_ID_STORAGE_KEY, newInstallationId);
|
|
26
|
+
return newInstallationId;
|
|
17
27
|
};
|
|
18
28
|
function safeRandomUUID() {
|
|
19
29
|
// 1) Native support
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import type { PostType } from '../..';
|
|
1
2
|
import type { IPostAnalyticsHandler } from '../../posts/posts-player/types';
|
|
2
3
|
import type { IStreamAnalyticsHandler } from '../../streams/streams-player/types';
|
|
3
4
|
export declare class InternalMediaCenterAnalyticsHandler implements IPostAnalyticsHandler, IStreamAnalyticsHandler {
|
|
4
5
|
constructor(graphqlOrigin: string | undefined);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
trackShortVideoProductClick: (productId: string, videoId: string) => void;
|
|
6
|
+
trackPostOpened: (postType: PostType, postId: string) => Promise<void>;
|
|
7
|
+
trackStreamView: (streamId: string) => Promise<void>;
|
|
8
|
+
trackStreamPageView: (pageId: string, streamId: string) => Promise<void>;
|
|
9
|
+
trackStreamEngagementTime: (streamId: string, engagementTime: number) => Promise<void>;
|
|
10
|
+
trackStreamScrollDepth: (streamId: string, scrollDepth: number) => Promise<void>;
|
|
11
|
+
trackStreamProductImpression: (productId: string, streamId: string) => Promise<void>;
|
|
12
|
+
trackStreamProductClicked: (productId: string, streamId: string) => Promise<void>;
|
|
13
|
+
reportPageVideoViews: (pageId: string, streamId: string) => Promise<import("@streamscloud/streams-analytics-collector").MeasurementsBatchReportResult>;
|
|
14
|
+
trackShortVideoView: (videoId: string) => Promise<void>;
|
|
15
|
+
trackShortVideoProductImpression: (productId: string, videoId: string) => Promise<void>;
|
|
16
|
+
trackShortVideoProductClick: (productId: string, videoId: string) => Promise<void>;
|
|
17
17
|
trackShortVideoProgress: (pageId: string, videoId: string, progress: number, streamId: string) => void;
|
|
18
|
-
trackAdClick: (adId: string) => void
|
|
19
|
-
trackAdImpression: (adId: string) => void
|
|
18
|
+
trackAdClick: (adId: string) => Promise<void>;
|
|
19
|
+
trackAdImpression: (adId: string) => Promise<void>;
|
|
20
20
|
}
|
|
@@ -1,24 +1,175 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getOrCreateInstallationId } from '../../core/analytics.installation-id';
|
|
2
2
|
import { constructGraphQLUrl } from '../../core/graphql';
|
|
3
|
-
import {
|
|
3
|
+
import { mapPostTypeToEntityType } from './mapper';
|
|
4
|
+
import { AnalyticsCollector, EntityRelationType, EntityType, EventType, MeasurementType, Schemas } from '@streamscloud/streams-analytics-collector';
|
|
4
5
|
export class InternalMediaCenterAnalyticsHandler {
|
|
5
6
|
constructor(graphqlOrigin) {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
AnalyticsCollector.initialize({
|
|
8
|
+
gqlDataSenderOptions: {
|
|
9
|
+
endpoint: constructGraphQLUrl(graphqlOrigin)
|
|
10
|
+
},
|
|
11
|
+
schema: Schemas.external,
|
|
12
|
+
metadata: {
|
|
13
|
+
installationId: getOrCreateInstallationId()
|
|
14
|
+
}
|
|
15
|
+
});
|
|
8
16
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
trackPostOpened = (postType, postId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
18
|
+
entity: {
|
|
19
|
+
type: mapPostTypeToEntityType(postType),
|
|
20
|
+
id: postId
|
|
21
|
+
},
|
|
22
|
+
eventType: EventType.Viewed
|
|
23
|
+
});
|
|
24
|
+
trackStreamView = (streamId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
25
|
+
entity: {
|
|
26
|
+
type: EntityType.Stream,
|
|
27
|
+
id: streamId
|
|
28
|
+
},
|
|
29
|
+
eventType: EventType.Viewed
|
|
30
|
+
});
|
|
31
|
+
trackStreamPageView = (pageId, streamId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
32
|
+
entity: {
|
|
33
|
+
type: EntityType.StreamPage,
|
|
34
|
+
id: pageId
|
|
35
|
+
},
|
|
36
|
+
eventType: EventType.Viewed,
|
|
37
|
+
relatedEntities: [
|
|
38
|
+
{
|
|
39
|
+
relationType: EntityRelationType.PlacedIn,
|
|
40
|
+
entity: {
|
|
41
|
+
type: EntityType.Stream,
|
|
42
|
+
id: streamId
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
trackStreamEngagementTime = (streamId, engagementTime) => AnalyticsCollector.measurementsReporter.reportMeasurement({
|
|
48
|
+
entity: {
|
|
49
|
+
type: EntityType.Stream,
|
|
50
|
+
id: streamId
|
|
51
|
+
},
|
|
52
|
+
measurementType: MeasurementType.EngagementTime,
|
|
53
|
+
value: engagementTime
|
|
54
|
+
});
|
|
55
|
+
trackStreamScrollDepth = (streamId, scrollDepth) => AnalyticsCollector.measurementsReporter.reportMeasurement({
|
|
56
|
+
entity: {
|
|
57
|
+
type: EntityType.Stream,
|
|
58
|
+
id: streamId
|
|
59
|
+
},
|
|
60
|
+
measurementType: MeasurementType.ScrollDepth,
|
|
61
|
+
value: scrollDepth
|
|
62
|
+
});
|
|
63
|
+
trackStreamProductImpression = (productId, streamId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
64
|
+
entity: {
|
|
65
|
+
type: EntityType.Product,
|
|
66
|
+
id: productId
|
|
67
|
+
},
|
|
68
|
+
eventType: EventType.Appeared,
|
|
69
|
+
relatedEntities: [
|
|
70
|
+
{
|
|
71
|
+
relationType: EntityRelationType.PlacedIn,
|
|
72
|
+
entity: {
|
|
73
|
+
type: EntityType.Stream,
|
|
74
|
+
id: streamId
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
trackStreamProductClicked = (productId, streamId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
80
|
+
entity: {
|
|
81
|
+
type: EntityType.Product,
|
|
82
|
+
id: productId
|
|
83
|
+
},
|
|
84
|
+
eventType: EventType.Clicked,
|
|
85
|
+
relatedEntities: [
|
|
86
|
+
{
|
|
87
|
+
relationType: EntityRelationType.PlacedIn,
|
|
88
|
+
entity: {
|
|
89
|
+
type: EntityType.Stream,
|
|
90
|
+
id: streamId
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
reportPageVideoViews = (pageId, streamId) => AnalyticsCollector.measurementsBatcher.reportBatch([
|
|
96
|
+
{
|
|
97
|
+
type: EntityType.StreamPage,
|
|
98
|
+
id: pageId
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: EntityType.Stream,
|
|
102
|
+
id: streamId
|
|
103
|
+
}
|
|
104
|
+
]);
|
|
105
|
+
trackShortVideoView = (videoId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
106
|
+
entity: {
|
|
107
|
+
type: EntityType.ShortVideo,
|
|
108
|
+
id: videoId
|
|
109
|
+
},
|
|
110
|
+
eventType: EventType.Viewed
|
|
111
|
+
});
|
|
112
|
+
trackShortVideoProductImpression = (productId, videoId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
113
|
+
entity: {
|
|
114
|
+
type: EntityType.Product,
|
|
115
|
+
id: productId
|
|
116
|
+
},
|
|
117
|
+
eventType: EventType.Appeared,
|
|
118
|
+
relatedEntities: [
|
|
119
|
+
{
|
|
120
|
+
relationType: EntityRelationType.PlacedIn,
|
|
121
|
+
entity: {
|
|
122
|
+
type: EntityType.ShortVideo,
|
|
123
|
+
id: videoId
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
trackShortVideoProductClick = (productId, videoId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
129
|
+
entity: {
|
|
130
|
+
type: EntityType.Product,
|
|
131
|
+
id: productId
|
|
132
|
+
},
|
|
133
|
+
eventType: EventType.Clicked,
|
|
134
|
+
relatedEntities: [
|
|
135
|
+
{
|
|
136
|
+
relationType: EntityRelationType.PlacedIn,
|
|
137
|
+
entity: {
|
|
138
|
+
type: EntityType.ShortVideo,
|
|
139
|
+
id: videoId
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
});
|
|
144
|
+
trackShortVideoProgress = (pageId, videoId, progress, streamId) => AnalyticsCollector.measurementsBatcher.collect([
|
|
145
|
+
{
|
|
146
|
+
type: EntityType.StreamPage,
|
|
147
|
+
id: pageId
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: EntityType.Stream,
|
|
151
|
+
id: streamId
|
|
152
|
+
}
|
|
153
|
+
], {
|
|
154
|
+
entity: {
|
|
155
|
+
type: EntityType.ShortVideo,
|
|
156
|
+
id: videoId
|
|
157
|
+
},
|
|
158
|
+
measurementType: MeasurementType.Progress,
|
|
159
|
+
value: progress
|
|
160
|
+
});
|
|
161
|
+
trackAdClick = (adId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
162
|
+
entity: {
|
|
163
|
+
type: EntityType.Ad,
|
|
164
|
+
id: adId
|
|
165
|
+
},
|
|
166
|
+
eventType: EventType.Clicked
|
|
167
|
+
});
|
|
168
|
+
trackAdImpression = (adId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
169
|
+
entity: {
|
|
170
|
+
type: EntityType.Ad,
|
|
171
|
+
id: adId
|
|
172
|
+
},
|
|
173
|
+
eventType: EventType.Appeared
|
|
174
|
+
});
|
|
24
175
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import type { PostType } from '../../core/enums';
|
|
1
2
|
import type { IPostAnalyticsHandler } from '../../posts/posts-player';
|
|
2
3
|
export declare class InternalPostAnalyticsHandler implements IPostAnalyticsHandler {
|
|
3
4
|
constructor(graphqlOrigin: string | undefined);
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
trackAdImpression: (adId: string) => void;
|
|
5
|
+
trackPostOpened: (postType: PostType, postId: string) => Promise<void>;
|
|
6
|
+
trackShortVideoView: (videoId: string) => Promise<void>;
|
|
7
|
+
trackShortVideoProductImpression: (productId: string, videoId: string) => Promise<void>;
|
|
8
|
+
trackShortVideoProductClick: (productId: string, videoId: string) => Promise<void>;
|
|
9
|
+
trackAdClick: (adId: string) => Promise<void>;
|
|
10
|
+
trackAdImpression: (adId: string) => Promise<void>;
|
|
11
11
|
}
|
|
@@ -1,16 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getOrCreateInstallationId } from '../../core/analytics.installation-id';
|
|
2
2
|
import { constructGraphQLUrl } from '../../core/graphql';
|
|
3
|
-
import {
|
|
3
|
+
import { mapPostTypeToEntityType } from './mapper';
|
|
4
|
+
import { AnalyticsCollector, EntityRelationType, EntityType, EventType, Schemas } from '@streamscloud/streams-analytics-collector';
|
|
4
5
|
export class InternalPostAnalyticsHandler {
|
|
5
6
|
constructor(graphqlOrigin) {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
AnalyticsCollector.initialize({
|
|
8
|
+
gqlDataSenderOptions: {
|
|
9
|
+
endpoint: constructGraphQLUrl(graphqlOrigin)
|
|
10
|
+
},
|
|
11
|
+
schema: Schemas.external,
|
|
12
|
+
metadata: {
|
|
13
|
+
installationId: getOrCreateInstallationId()
|
|
14
|
+
}
|
|
15
|
+
});
|
|
8
16
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
trackPostOpened = (postType, postId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
18
|
+
entity: {
|
|
19
|
+
type: mapPostTypeToEntityType(postType),
|
|
20
|
+
id: postId
|
|
21
|
+
},
|
|
22
|
+
eventType: EventType.Viewed
|
|
23
|
+
});
|
|
24
|
+
trackShortVideoView = (videoId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
25
|
+
entity: {
|
|
26
|
+
type: EntityType.ShortVideo,
|
|
27
|
+
id: videoId
|
|
28
|
+
},
|
|
29
|
+
eventType: EventType.Viewed
|
|
30
|
+
});
|
|
31
|
+
trackShortVideoProductImpression = (productId, videoId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
32
|
+
entity: {
|
|
33
|
+
type: EntityType.Product,
|
|
34
|
+
id: productId
|
|
35
|
+
},
|
|
36
|
+
eventType: EventType.Appeared,
|
|
37
|
+
relatedEntities: [
|
|
38
|
+
{
|
|
39
|
+
relationType: EntityRelationType.PlacedIn,
|
|
40
|
+
entity: {
|
|
41
|
+
type: EntityType.ShortVideo,
|
|
42
|
+
id: videoId
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
trackShortVideoProductClick = (productId, videoId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
48
|
+
entity: {
|
|
49
|
+
type: EntityType.Product,
|
|
50
|
+
id: productId
|
|
51
|
+
},
|
|
52
|
+
eventType: EventType.Clicked,
|
|
53
|
+
relatedEntities: [
|
|
54
|
+
{
|
|
55
|
+
relationType: EntityRelationType.PlacedIn,
|
|
56
|
+
entity: {
|
|
57
|
+
type: EntityType.ShortVideo,
|
|
58
|
+
id: videoId
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
trackAdClick = (adId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
64
|
+
entity: {
|
|
65
|
+
type: EntityType.Ad,
|
|
66
|
+
id: adId
|
|
67
|
+
},
|
|
68
|
+
eventType: EventType.Clicked
|
|
69
|
+
});
|
|
70
|
+
trackAdImpression = (adId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
71
|
+
entity: {
|
|
72
|
+
type: EntityType.Ad,
|
|
73
|
+
id: adId
|
|
74
|
+
},
|
|
75
|
+
eventType: EventType.Appeared
|
|
76
|
+
});
|
|
16
77
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import type { IStreamAnalyticsHandler } from '../../streams/streams-player/types';
|
|
2
2
|
export declare class InternalStreamAnalyticsHandler implements IStreamAnalyticsHandler {
|
|
3
3
|
constructor(graphqlOrigin: string | undefined);
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
trackShortVideoProductClick: (productId: string, videoId: string) => void;
|
|
4
|
+
trackStreamView: (streamId: string) => Promise<void>;
|
|
5
|
+
trackStreamPageView: (pageId: string, streamId: string) => Promise<void>;
|
|
6
|
+
trackStreamEngagementTime: (streamId: string, engagementTime: number) => Promise<void>;
|
|
7
|
+
trackStreamScrollDepth: (streamId: string, scrollDepth: number) => Promise<void>;
|
|
8
|
+
trackStreamProductImpression: (productId: string, streamId: string) => Promise<void>;
|
|
9
|
+
trackStreamProductClicked: (productId: string, streamId: string) => Promise<void>;
|
|
10
|
+
reportPageVideoViews: (pageId: string, streamId: string) => Promise<import("@streamscloud/streams-analytics-collector").MeasurementsBatchReportResult>;
|
|
11
|
+
trackShortVideoView: (videoId: string) => Promise<void>;
|
|
12
|
+
trackShortVideoProductImpression: (productId: string, videoId: string) => Promise<void>;
|
|
13
|
+
trackShortVideoProductClick: (productId: string, videoId: string) => Promise<void>;
|
|
15
14
|
trackShortVideoProgress: (pageId: string, videoId: string, progress: number, streamId: string) => void;
|
|
16
|
-
trackAdClick: (adId: string) => void
|
|
17
|
-
trackAdImpression: (adId: string) => void
|
|
15
|
+
trackAdClick: (adId: string) => Promise<void>;
|
|
16
|
+
trackAdImpression: (adId: string) => Promise<void>;
|
|
18
17
|
}
|
|
@@ -1,23 +1,167 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getOrCreateInstallationId } from '../../core/analytics.installation-id';
|
|
2
2
|
import { constructGraphQLUrl } from '../../core/graphql';
|
|
3
|
-
import {
|
|
3
|
+
import { AnalyticsCollector, EntityRelationType, EntityType, EventType, MeasurementType, Schemas } from '@streamscloud/streams-analytics-collector';
|
|
4
4
|
export class InternalStreamAnalyticsHandler {
|
|
5
5
|
constructor(graphqlOrigin) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
AnalyticsCollector.initialize({
|
|
7
|
+
gqlDataSenderOptions: {
|
|
8
|
+
endpoint: constructGraphQLUrl(graphqlOrigin)
|
|
9
|
+
},
|
|
10
|
+
schema: Schemas.external,
|
|
11
|
+
metadata: {
|
|
12
|
+
installationId: getOrCreateInstallationId()
|
|
13
|
+
}
|
|
14
|
+
});
|
|
8
15
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
trackStreamView = (streamId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
17
|
+
entity: {
|
|
18
|
+
type: EntityType.Stream,
|
|
19
|
+
id: streamId
|
|
20
|
+
},
|
|
21
|
+
eventType: EventType.Viewed
|
|
22
|
+
});
|
|
23
|
+
trackStreamPageView = (pageId, streamId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
24
|
+
entity: {
|
|
25
|
+
type: EntityType.StreamPage,
|
|
26
|
+
id: pageId
|
|
27
|
+
},
|
|
28
|
+
eventType: EventType.Viewed,
|
|
29
|
+
relatedEntities: [
|
|
30
|
+
{
|
|
31
|
+
relationType: EntityRelationType.PlacedIn,
|
|
32
|
+
entity: {
|
|
33
|
+
type: EntityType.Stream,
|
|
34
|
+
id: streamId
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
trackStreamEngagementTime = (streamId, engagementTime) => AnalyticsCollector.measurementsReporter.reportMeasurement({
|
|
40
|
+
entity: {
|
|
41
|
+
type: EntityType.Stream,
|
|
42
|
+
id: streamId
|
|
43
|
+
},
|
|
44
|
+
measurementType: MeasurementType.EngagementTime,
|
|
45
|
+
value: engagementTime
|
|
46
|
+
});
|
|
47
|
+
trackStreamScrollDepth = (streamId, scrollDepth) => AnalyticsCollector.measurementsReporter.reportMeasurement({
|
|
48
|
+
entity: {
|
|
49
|
+
type: EntityType.Stream,
|
|
50
|
+
id: streamId
|
|
51
|
+
},
|
|
52
|
+
measurementType: MeasurementType.ScrollDepth,
|
|
53
|
+
value: scrollDepth
|
|
54
|
+
});
|
|
55
|
+
trackStreamProductImpression = (productId, streamId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
56
|
+
entity: {
|
|
57
|
+
type: EntityType.Product,
|
|
58
|
+
id: productId
|
|
59
|
+
},
|
|
60
|
+
eventType: EventType.Appeared,
|
|
61
|
+
relatedEntities: [
|
|
62
|
+
{
|
|
63
|
+
relationType: EntityRelationType.PlacedIn,
|
|
64
|
+
entity: {
|
|
65
|
+
type: EntityType.Stream,
|
|
66
|
+
id: streamId
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
trackStreamProductClicked = (productId, streamId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
72
|
+
entity: {
|
|
73
|
+
type: EntityType.Product,
|
|
74
|
+
id: productId
|
|
75
|
+
},
|
|
76
|
+
eventType: EventType.Clicked,
|
|
77
|
+
relatedEntities: [
|
|
78
|
+
{
|
|
79
|
+
relationType: EntityRelationType.PlacedIn,
|
|
80
|
+
entity: {
|
|
81
|
+
type: EntityType.Stream,
|
|
82
|
+
id: streamId
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
reportPageVideoViews = (pageId, streamId) => AnalyticsCollector.measurementsBatcher.reportBatch([
|
|
88
|
+
{
|
|
89
|
+
type: EntityType.StreamPage,
|
|
90
|
+
id: pageId
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: EntityType.Stream,
|
|
94
|
+
id: streamId
|
|
95
|
+
}
|
|
96
|
+
]);
|
|
97
|
+
trackShortVideoView = (videoId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
98
|
+
entity: {
|
|
99
|
+
type: EntityType.ShortVideo,
|
|
100
|
+
id: videoId
|
|
101
|
+
},
|
|
102
|
+
eventType: EventType.Viewed
|
|
103
|
+
});
|
|
104
|
+
trackShortVideoProductImpression = (productId, videoId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
105
|
+
entity: {
|
|
106
|
+
type: EntityType.Product,
|
|
107
|
+
id: productId
|
|
108
|
+
},
|
|
109
|
+
eventType: EventType.Appeared,
|
|
110
|
+
relatedEntities: [
|
|
111
|
+
{
|
|
112
|
+
relationType: EntityRelationType.PlacedIn,
|
|
113
|
+
entity: {
|
|
114
|
+
type: EntityType.ShortVideo,
|
|
115
|
+
id: videoId
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
trackShortVideoProductClick = (productId, videoId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
121
|
+
entity: {
|
|
122
|
+
type: EntityType.Product,
|
|
123
|
+
id: productId
|
|
124
|
+
},
|
|
125
|
+
eventType: EventType.Clicked,
|
|
126
|
+
relatedEntities: [
|
|
127
|
+
{
|
|
128
|
+
relationType: EntityRelationType.PlacedIn,
|
|
129
|
+
entity: {
|
|
130
|
+
type: EntityType.ShortVideo,
|
|
131
|
+
id: videoId
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
trackShortVideoProgress = (pageId, videoId, progress, streamId) => AnalyticsCollector.measurementsBatcher.collect([
|
|
137
|
+
{
|
|
138
|
+
type: EntityType.StreamPage,
|
|
139
|
+
id: pageId
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
type: EntityType.Stream,
|
|
143
|
+
id: streamId
|
|
144
|
+
}
|
|
145
|
+
], {
|
|
146
|
+
entity: {
|
|
147
|
+
type: EntityType.ShortVideo,
|
|
148
|
+
id: videoId
|
|
149
|
+
},
|
|
150
|
+
measurementType: MeasurementType.Progress,
|
|
151
|
+
value: progress
|
|
152
|
+
});
|
|
153
|
+
trackAdClick = (adId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
154
|
+
entity: {
|
|
155
|
+
type: EntityType.Ad,
|
|
156
|
+
id: adId
|
|
157
|
+
},
|
|
158
|
+
eventType: EventType.Clicked
|
|
159
|
+
});
|
|
160
|
+
trackAdImpression = (adId) => AnalyticsCollector.eventsReporter.reportEvent({
|
|
161
|
+
entity: {
|
|
162
|
+
type: EntityType.Ad,
|
|
163
|
+
id: adId
|
|
164
|
+
},
|
|
165
|
+
eventType: EventType.Appeared
|
|
166
|
+
});
|
|
23
167
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PostType } from '../../core/enums';
|
|
2
|
+
import { EntityType } from '@streamscloud/streams-analytics-collector';
|
|
3
|
+
export function mapPostTypeToEntityType(postType) {
|
|
4
|
+
switch (postType) {
|
|
5
|
+
case PostType.Article:
|
|
6
|
+
return EntityType.Article;
|
|
7
|
+
case PostType.Media:
|
|
8
|
+
return EntityType.Media;
|
|
9
|
+
case PostType.Moment:
|
|
10
|
+
return EntityType.Moment;
|
|
11
|
+
case PostType.ShortVideo:
|
|
12
|
+
return EntityType.ShortVideo;
|
|
13
|
+
case PostType.Video:
|
|
14
|
+
return EntityType.Video;
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(`Unknown PostType: ${postType}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { ProfileType } from '../../../core/enums';
|
|
2
1
|
import { mapToPostModel } from '../../../posts/post-viewer';
|
|
3
2
|
export const mapToPostPlayerModel = (payload) => {
|
|
4
3
|
const viewerModel = mapToPostModel(payload);
|
|
5
4
|
return {
|
|
6
|
-
...viewerModel
|
|
7
|
-
analyticsOrganizationId: payload.ownerProfile.type === ProfileType.Organization ? payload.ownerProfile.id : null
|
|
5
|
+
...viewerModel
|
|
8
6
|
};
|
|
9
7
|
};
|
|
@@ -69,14 +69,11 @@ const contentPlayerConfig = new PlayerConfig({
|
|
|
69
69
|
if (on === null || on === void 0 ? void 0 : on.backgroundImageLoaded) {
|
|
70
70
|
on.backgroundImageLoaded(getPostCoverImage(post));
|
|
71
71
|
}
|
|
72
|
-
if (post.analyticsOrganizationId) {
|
|
73
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.setOrganizationId(post.analyticsOrganizationId);
|
|
74
|
-
}
|
|
75
72
|
if (post.postType === PostType.ShortVideo) {
|
|
76
73
|
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackShortVideoView(id);
|
|
77
74
|
}
|
|
78
|
-
else if (post.
|
|
79
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackPostOpened(
|
|
75
|
+
else if (post.postType) {
|
|
76
|
+
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackPostOpened(post.postType, id);
|
|
80
77
|
}
|
|
81
78
|
(_a = on === null || on === void 0 ? void 0 : on.postActivated) === null || _a === void 0 ? void 0 : _a.call(on, id);
|
|
82
79
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PostType } from '../../core/enums';
|
|
1
2
|
import type { Locale } from '../../core/locale';
|
|
2
3
|
import type { ThemeValue } from '../../core/theme';
|
|
3
4
|
import type { IPostModel } from '..';
|
|
@@ -7,17 +8,14 @@ import type { ICloseOrchestrator } from '../../ui/player/close-orchestrator';
|
|
|
7
8
|
import type { PlayerColors } from '../../ui/player/colors';
|
|
8
9
|
import type { IPlayerBuffer, IPlayerDataProvider } from '../../ui/player/providers';
|
|
9
10
|
export interface IPostAnalyticsHandler {
|
|
10
|
-
|
|
11
|
-
trackPostOpened: (postId: string, ownerId: string) => void;
|
|
11
|
+
trackPostOpened: (postType: PostType, postId: string) => void;
|
|
12
12
|
trackShortVideoView: (videoId: string) => void;
|
|
13
13
|
trackShortVideoProductImpression: (productId: string, videoId: string) => void;
|
|
14
14
|
trackShortVideoProductClick: (productId: string, videoId: string) => void;
|
|
15
15
|
trackAdClick: (adId: string) => void;
|
|
16
16
|
trackAdImpression: (adId: string) => void;
|
|
17
17
|
}
|
|
18
|
-
export type PostPlayerModel = IPostModel
|
|
19
|
-
analyticsOrganizationId: string | null;
|
|
20
|
-
};
|
|
18
|
+
export type PostPlayerModel = IPostModel;
|
|
21
19
|
export type PostsPlayerProps = {
|
|
22
20
|
dataProvider: {
|
|
23
21
|
type: 'buffer';
|
|
@@ -60,9 +60,6 @@ $effect(() => {
|
|
|
60
60
|
var _a;
|
|
61
61
|
if (stream) {
|
|
62
62
|
currentStreamModel = stream;
|
|
63
|
-
if (stream.organizationId) {
|
|
64
|
-
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.setOrganizationId(stream.organizationId);
|
|
65
|
-
}
|
|
66
63
|
(_a = on === null || on === void 0 ? void 0 : on.streamActivated) === null || _a === void 0 ? void 0 : _a.call(on, { id: stream.id, title: stream.title, image: stream.cover });
|
|
67
64
|
analyticsHandler === null || analyticsHandler === void 0 ? void 0 : analyticsHandler.trackStreamView(stream.id);
|
|
68
65
|
startActivityTracking();
|
|
@@ -70,7 +70,6 @@ export interface IStreamsPlayerDataProvider {
|
|
|
70
70
|
onEndReached?: () => void;
|
|
71
71
|
}
|
|
72
72
|
export interface IStreamAnalyticsHandler {
|
|
73
|
-
setOrganizationId: (organizationId: string) => void;
|
|
74
73
|
trackStreamView: (streamId: string) => void;
|
|
75
74
|
trackStreamPageView: (pageId: string, streamId: string) => void;
|
|
76
75
|
trackStreamProductImpression: (productId: string, streamId: string) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamscloud/embeddable",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0-rc.1",
|
|
4
4
|
"author": "StreamsCloud",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
"peerDependencies": {
|
|
136
136
|
"@fluentui/svg-icons": "^1.1.301",
|
|
137
137
|
"@popperjs/core": "^2.11.8",
|
|
138
|
-
"@streamscloud/streams-analytics-collector": "^
|
|
138
|
+
"@streamscloud/streams-analytics-collector": "^3.0.0",
|
|
139
139
|
"@urql/core": "^5.1.1",
|
|
140
140
|
"dequal": "^2.0.3",
|
|
141
141
|
"dompurify": "^3.2.6",
|