@streamlayer/sdk-web-analytics 1.16.5 → 1.16.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.
- package/lib/advertisement.js +1 -1
- package/lib/analytics.d.ts +2 -1
- package/lib/analytics.js +36 -13
- package/lib/index.js +1 -1
- package/package.json +10 -9
package/lib/advertisement.js
CHANGED
|
@@ -213,7 +213,7 @@ export class AdvertisementAnalytics {
|
|
|
213
213
|
this.analytics.write('games', {
|
|
214
214
|
common: {
|
|
215
215
|
...this.analytics.commonStore.getValues(),
|
|
216
|
-
kind: Kind.
|
|
216
|
+
kind: Kind.POLLS_AD_OPENED,
|
|
217
217
|
topicId: id,
|
|
218
218
|
topicType: TopicType.POLLS_PROMOTION,
|
|
219
219
|
topicSubType,
|
package/lib/analytics.d.ts
CHANGED
|
@@ -44,7 +44,8 @@ export declare class Analytics {
|
|
|
44
44
|
connect: () => void;
|
|
45
45
|
disconnect: () => void;
|
|
46
46
|
write: <T extends keyof typeof AllowedCases = "invitation" | "notification" | "interactions" | "games" | "eventOpened">(key: T, value: AnalyticsMessages[T]) => void;
|
|
47
|
-
|
|
47
|
+
writeCommonValues: <G extends keyof PlainMessage<CommonData>>(values: Partial<PlainMessage<CommonData>>, guardKey: G, delay: number) => void;
|
|
48
|
+
writeCommon: <T extends keyof PlainMessage<CommonData> = "$unknown" | "category" | "eventId" | "kind" | "screenOrientation" | "sessionId" | "overlaySessionId" | "topicId" | "topicType" | "parentTopicId" | "parentTopicType" | "participantsCount" | "routeMap" | "trackTimestamp" | "topicSubType" | "country">(key: T, value: PlainMessage<CommonData>[T], delay?: number) => void;
|
|
48
49
|
onConnect: (cb: OnMountCb) => void;
|
|
49
50
|
private connectToSDK;
|
|
50
51
|
}
|
package/lib/analytics.js
CHANGED
|
@@ -72,15 +72,30 @@ export class Analytics {
|
|
|
72
72
|
this.analyticsClient
|
|
73
73
|
.unary({ message: { case: key, value } })
|
|
74
74
|
.then(() => {
|
|
75
|
-
logger.trace('send analytics success'
|
|
75
|
+
logger.trace({ key, value }, 'send analytics success');
|
|
76
76
|
})
|
|
77
77
|
.catch((e) => {
|
|
78
78
|
logger.error(e, 'send analytics failed');
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
this.commonStore.
|
|
82
|
+
writeCommonValues = (values, guardKey, delay) => {
|
|
83
|
+
const prev = this.commonStore.getValue(guardKey);
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
if (this.connected && prev === this.commonStore.getValue(guardKey)) {
|
|
86
|
+
for (const [key, value] of Object.entries(values)) {
|
|
87
|
+
this.commonStore.setValue(key, value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, delay);
|
|
91
|
+
};
|
|
92
|
+
writeCommon = (key, value, delay) => {
|
|
93
|
+
if (delay) {
|
|
94
|
+
this.writeCommonValues({ [key]: value }, key, delay);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
this.commonStore.setValue(key, value);
|
|
98
|
+
}
|
|
84
99
|
};
|
|
85
100
|
// calls the cb when connected/reconnected, callbacks return a cancel function to be called when disconnected
|
|
86
101
|
onConnect = (cb) => {
|
|
@@ -102,7 +117,7 @@ export class Analytics {
|
|
|
102
117
|
this.writeCommon('overlaySessionId', v4());
|
|
103
118
|
}
|
|
104
119
|
else {
|
|
105
|
-
this.writeCommon('overlaySessionId', '');
|
|
120
|
+
this.writeCommon('overlaySessionId', '', 200);
|
|
106
121
|
}
|
|
107
122
|
}));
|
|
108
123
|
this.onConnect(() => {
|
|
@@ -113,14 +128,13 @@ export class Analytics {
|
|
|
113
128
|
const action = event.slEventBus?.action;
|
|
114
129
|
if (event.slEventBus?.type === 'exposedPauseAd') {
|
|
115
130
|
if (action === 'disabled' || action === 'closed') {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}, 200);
|
|
131
|
+
this.writeCommonValues({
|
|
132
|
+
overlaySessionId: '',
|
|
133
|
+
topicId: '',
|
|
134
|
+
parentTopicId: '',
|
|
135
|
+
topicType: TopicType.UNSET,
|
|
136
|
+
category: Category.UNSET,
|
|
137
|
+
}, 'overlaySessionId', 200);
|
|
124
138
|
}
|
|
125
139
|
if (action === 'enabled') {
|
|
126
140
|
this.writeCommon('overlaySessionId', v4());
|
|
@@ -132,12 +146,21 @@ export class Analytics {
|
|
|
132
146
|
this.writeCommon('overlaySessionId', v4());
|
|
133
147
|
}
|
|
134
148
|
if (action === 'closed') {
|
|
135
|
-
this.writeCommon('overlaySessionId', '');
|
|
149
|
+
this.writeCommon('overlaySessionId', '', 200);
|
|
136
150
|
}
|
|
137
151
|
}
|
|
138
152
|
};
|
|
139
153
|
return eventBus.listen(listener);
|
|
140
154
|
});
|
|
155
|
+
this.onConnect(() => {
|
|
156
|
+
const cancel3 = instance.sdk.uiState.subscribe((uiState) => {
|
|
157
|
+
const nothingOpen = Object.values(uiState).every((value) => value === false);
|
|
158
|
+
if (nothingOpen) {
|
|
159
|
+
this.writeCommon('overlaySessionId', '', 200);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return cancel3;
|
|
163
|
+
});
|
|
141
164
|
this.onConnect(() => {
|
|
142
165
|
const mediaQuery = window.matchMedia('(orientation: portrait)');
|
|
143
166
|
const handleOrientationChange = (e) => {
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export const analytics = (instance, opts, done) => {
|
|
|
6
6
|
instance.analytics.connect();
|
|
7
7
|
instance.sdk.writeOverlaySessionId = (id) => {
|
|
8
8
|
if (id === '') {
|
|
9
|
-
instance.analytics.writeCommon('overlaySessionId', '');
|
|
9
|
+
instance.analytics.writeCommon('overlaySessionId', '', 200);
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
12
12
|
instance.analytics.writeCommon('overlaySessionId', v4());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamlayer/sdk-web-analytics",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -13,18 +13,19 @@
|
|
|
13
13
|
"@connectrpc/connect": "^2.0.0",
|
|
14
14
|
"uuid": "^11.1.0",
|
|
15
15
|
"@streamlayer/sl-eslib": "^5.229.1",
|
|
16
|
-
"@streamlayer/sdk-web-api": "^1.16.
|
|
17
|
-
"@streamlayer/sdk-web-interfaces": "^1.9.
|
|
18
|
-
"@streamlayer/sdk-web-logger": "^1.0.
|
|
19
|
-
"@streamlayer/sdk-web-features": "^1.0.
|
|
20
|
-
"@streamlayer/
|
|
21
|
-
"@streamlayer/
|
|
16
|
+
"@streamlayer/sdk-web-api": "^1.16.6",
|
|
17
|
+
"@streamlayer/sdk-web-interfaces": "^1.9.14",
|
|
18
|
+
"@streamlayer/sdk-web-logger": "^1.0.108",
|
|
19
|
+
"@streamlayer/sdk-web-features": "^1.0.108",
|
|
20
|
+
"@streamlayer/sdk-web-core": "^1.21.6",
|
|
21
|
+
"@streamlayer/feature-gamification": "^1.26.0"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
+
"types": "./lib/index.d.ts",
|
|
26
|
+
"import": "./lib/index.js",
|
|
25
27
|
"module": "./lib/index.js",
|
|
26
|
-
"
|
|
27
|
-
"types": "./lib/index.d.ts"
|
|
28
|
+
"default": "./lib/index.js"
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
}
|