@streamlayer/sdk-web-analytics 1.4.12 → 1.5.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/lib/advertisement.d.ts +4 -1
- package/lib/advertisement.js +20 -4
- package/lib/notifications.js +24 -2
- package/package.json +8 -8
package/lib/advertisement.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { EventBusActionPayload } from '@streamlayer/sdk-web-interfaces';
|
|
2
|
+
import { PromotionType } from '@streamlayer/sdk-web-types';
|
|
2
3
|
import { TopicSubType } from '@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb';
|
|
3
4
|
import { Analytics } from './analytics';
|
|
4
5
|
type TransformedPayload = {
|
|
5
6
|
topicSubType: TopicSubType;
|
|
6
7
|
};
|
|
8
|
+
export declare const getPromotionSubType: (type?: PromotionType) => TopicSubType;
|
|
7
9
|
export declare class AdvertisementAnalytics {
|
|
8
10
|
private analytics;
|
|
9
11
|
constructor(analytics: Analytics);
|
|
10
12
|
received: ({ id }: EventBusActionPayload["advertisement"], { topicSubType }: TransformedPayload) => void;
|
|
11
|
-
opened: ({ id }: EventBusActionPayload["advertisement"], { topicSubType }: TransformedPayload) => void;
|
|
13
|
+
opened: ({ id, openedFrom }: EventBusActionPayload["advertisement"], { topicSubType }: TransformedPayload) => void;
|
|
14
|
+
viewed: ({ id }: EventBusActionPayload["advertisement"], { topicSubType }: TransformedPayload) => void;
|
|
12
15
|
videoPlay: ({ id }: EventBusActionPayload["advertisement"], { topicSubType }: TransformedPayload) => void;
|
|
13
16
|
buttonSelect: ({ id }: EventBusActionPayload["advertisement"], { topicSubType }: TransformedPayload) => void;
|
|
14
17
|
bannerSelect: ({ id }: EventBusActionPayload["advertisement"], { topicSubType }: TransformedPayload) => void;
|
package/lib/advertisement.js
CHANGED
|
@@ -10,6 +10,9 @@ const MAP_PROMOTION_TYPE_TO_TOPIC_TYPE = {
|
|
|
10
10
|
[PromotionType.INGAME_IAB61]: TopicSubType.PROMOTION_INGAME_IAB61,
|
|
11
11
|
[PromotionType.EXTERNAL_AD]: TopicSubType.PROMOTION_GAM,
|
|
12
12
|
};
|
|
13
|
+
export const getPromotionSubType = (type) => {
|
|
14
|
+
return type ? MAP_PROMOTION_TYPE_TO_TOPIC_TYPE[type] : TopicSubType.UNSET;
|
|
15
|
+
};
|
|
13
16
|
export class AdvertisementAnalytics {
|
|
14
17
|
analytics;
|
|
15
18
|
constructor(analytics) {
|
|
@@ -20,9 +23,7 @@ export class AdvertisementAnalytics {
|
|
|
20
23
|
return;
|
|
21
24
|
}
|
|
22
25
|
if (event.slEventBus?.type === 'advertisement') {
|
|
23
|
-
const topicSubType = event.slEventBus.payload.type
|
|
24
|
-
? MAP_PROMOTION_TYPE_TO_TOPIC_TYPE[event.slEventBus.payload.type]
|
|
25
|
-
: TopicSubType.UNSET;
|
|
26
|
+
const topicSubType = getPromotionSubType(event.slEventBus.payload.type);
|
|
26
27
|
switch (event.slEventBus.action) {
|
|
27
28
|
case 'videoPlay':
|
|
28
29
|
this.videoPlay(event.slEventBus.payload, { topicSubType });
|
|
@@ -39,6 +40,9 @@ export class AdvertisementAnalytics {
|
|
|
39
40
|
case 'opened':
|
|
40
41
|
this.opened(event.slEventBus.payload, { topicSubType });
|
|
41
42
|
break;
|
|
43
|
+
case 'viewed':
|
|
44
|
+
this.viewed(event.slEventBus.payload, { topicSubType });
|
|
45
|
+
break;
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
};
|
|
@@ -57,7 +61,19 @@ export class AdvertisementAnalytics {
|
|
|
57
61
|
pollOpenedFrom: PollOpenedFrom.UNSET,
|
|
58
62
|
});
|
|
59
63
|
};
|
|
60
|
-
opened = ({ id }, { topicSubType }) => {
|
|
64
|
+
opened = ({ id, openedFrom }, { topicSubType }) => {
|
|
65
|
+
this.analytics.write('games', {
|
|
66
|
+
common: {
|
|
67
|
+
...this.analytics.commonStore.getValues(),
|
|
68
|
+
kind: Kind.POLLS_OPENED,
|
|
69
|
+
topicId: id,
|
|
70
|
+
topicType: TopicType.POLLS_PROMOTION,
|
|
71
|
+
topicSubType,
|
|
72
|
+
},
|
|
73
|
+
pollOpenedFrom: openedFrom === 'notification' ? PollOpenedFrom.IN_APP : PollOpenedFrom.UNSET,
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
viewed = ({ id }, { topicSubType }) => {
|
|
61
77
|
this.analytics.write('games', {
|
|
62
78
|
common: {
|
|
63
79
|
...this.analytics.commonStore.getValues(),
|
package/lib/notifications.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { QuestionType } from '@streamlayer/sdk-web-types';
|
|
1
2
|
import { eventBus } from '@streamlayer/sdk-web-interfaces';
|
|
2
3
|
import { Kind, TopicType } from '@streamlayer/sl-eslib/analytics/v1/common/analytics.common_pb';
|
|
3
4
|
import { NotificationKind, NotificationType } from '@streamlayer/sl-eslib/analytics/v1/notifications/notifications_pb';
|
|
4
5
|
import { TOPIC_TYPE_MAP } from './constants';
|
|
6
|
+
import { getPromotionSubType } from './advertisement';
|
|
5
7
|
export class NotificationsAnalytics {
|
|
6
8
|
analytics;
|
|
7
9
|
constructor(analytics) {
|
|
@@ -18,29 +20,49 @@ export class NotificationsAnalytics {
|
|
|
18
20
|
break;
|
|
19
21
|
}
|
|
20
22
|
}
|
|
23
|
+
if (event.slEventBus?.type === 'advertisement') {
|
|
24
|
+
switch (event.slEventBus.action) {
|
|
25
|
+
case 'notification-received':
|
|
26
|
+
this.received({
|
|
27
|
+
questionId: event.slEventBus.payload.id,
|
|
28
|
+
questionType: QuestionType.PROMOTION,
|
|
29
|
+
topicSubType: getPromotionSubType(event.slEventBus.payload.type),
|
|
30
|
+
});
|
|
31
|
+
break;
|
|
32
|
+
case 'notification-opened':
|
|
33
|
+
this.opened({
|
|
34
|
+
questionId: event.slEventBus.payload.id,
|
|
35
|
+
questionType: QuestionType.PROMOTION,
|
|
36
|
+
topicSubType: getPromotionSubType(event.slEventBus.payload.type),
|
|
37
|
+
});
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
21
41
|
};
|
|
22
42
|
return eventBus.listen(listener);
|
|
23
43
|
});
|
|
24
44
|
}
|
|
25
|
-
received = ({ questionId, questionType }) => {
|
|
45
|
+
received = ({ questionId, questionType, topicSubType, }) => {
|
|
26
46
|
this.analytics.write('notification', {
|
|
27
47
|
common: {
|
|
28
48
|
...this.analytics.commonStore.getValues(),
|
|
29
49
|
kind: Kind.NOTIFICATION_RECEIVED,
|
|
30
50
|
topicId: questionId,
|
|
31
51
|
topicType: questionType ? TOPIC_TYPE_MAP[questionType] : TopicType.UNSET,
|
|
52
|
+
topicSubType,
|
|
32
53
|
},
|
|
33
54
|
notificationKind: NotificationKind.POLLS,
|
|
34
55
|
notificationType: NotificationType.IN_APP,
|
|
35
56
|
});
|
|
36
57
|
};
|
|
37
|
-
opened = ({ questionId, questionType }) => {
|
|
58
|
+
opened = ({ questionId, questionType, topicSubType, }) => {
|
|
38
59
|
this.analytics.write('notification', {
|
|
39
60
|
common: {
|
|
40
61
|
...this.analytics.commonStore.getValues(),
|
|
41
62
|
kind: Kind.NOTIFICATION_OPENED,
|
|
42
63
|
topicId: questionId,
|
|
43
64
|
topicType: questionType ? TOPIC_TYPE_MAP[questionType] : TopicType.UNSET,
|
|
65
|
+
topicSubType,
|
|
44
66
|
},
|
|
45
67
|
notificationKind: NotificationKind.POLLS,
|
|
46
68
|
notificationType: NotificationType.IN_APP,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamlayer/sdk-web-analytics",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
],
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"@bufbuild/protobuf": "^1.10.0",
|
|
13
|
-
"@connectrpc/connect": "^1.
|
|
13
|
+
"@connectrpc/connect": "^1.6.1",
|
|
14
14
|
"nanoid": "3.3.7",
|
|
15
15
|
"@streamlayer/sl-eslib": "^5.130.0",
|
|
16
|
-
"@streamlayer/sdk-web-
|
|
17
|
-
"@streamlayer/sdk-web-
|
|
18
|
-
"@streamlayer/sdk-web-logger": "^1.0.
|
|
19
|
-
"@streamlayer/sdk-web-features": "^1.0.
|
|
20
|
-
"@streamlayer/
|
|
21
|
-
"@streamlayer/
|
|
16
|
+
"@streamlayer/sdk-web-interfaces": "^1.4.1",
|
|
17
|
+
"@streamlayer/sdk-web-api": "^1.6.14",
|
|
18
|
+
"@streamlayer/sdk-web-logger": "^1.0.35",
|
|
19
|
+
"@streamlayer/sdk-web-features": "^1.0.35",
|
|
20
|
+
"@streamlayer/feature-gamification": "^1.12.1",
|
|
21
|
+
"@streamlayer/sdk-web-core": "^1.8.3"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|