@amityco/ts-sdk 6.18.0 → 6.18.1-ab6e7e4.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/.env +26 -26
- package/dist/analytic/api/syncEvent.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +1 -0
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +1 -0
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -1
- package/dist/analytic/service/analytic/AnalyticsEventSyncer.d.ts.map +1 -1
- package/dist/index.cjs.js +23 -10
- package/dist/index.esm.js +23 -10
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/analytic/api/syncEvent.ts +1 -3
- package/src/analytic/service/analytic/AnalyticsEngine.ts +6 -6
- package/src/analytic/service/analytic/AnalyticsEventCapturer.ts +9 -1
- package/src/analytic/service/analytic/AnalyticsEventSyncer.ts +9 -3
package/package.json
CHANGED
|
@@ -6,7 +6,5 @@ export const syncEvent = async (events: Amity.AnalyticEventModel[]) => {
|
|
|
6
6
|
activities: events,
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
await client.http.post<Amity.ChannelPayload>('/api/v1/analytics/activities',
|
|
10
|
-
activities: events,
|
|
11
|
-
});
|
|
9
|
+
await client.http.post<Amity.ChannelPayload>('/api/v1/analytics/activities', params);
|
|
12
10
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
-
import { dropFromCache } from '~/cache/api';
|
|
3
2
|
import { AnalyticsEventSyncer } from './AnalyticsEventSyncer';
|
|
4
3
|
import { AnalyticsEventCapturer } from './AnalyticsEventCapturer';
|
|
5
|
-
import { ANALYTIC_CACHE_KEY } from '../../constant';
|
|
6
4
|
|
|
7
5
|
class AnalyticsEngine {
|
|
8
6
|
private _client: Amity.Client;
|
|
@@ -49,14 +47,16 @@ class AnalyticsEngine {
|
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
handleTokenExpired() {
|
|
52
|
-
this.
|
|
50
|
+
this._stopAndDestry();
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
destroy() {
|
|
56
|
-
this.
|
|
54
|
+
this._stopAndDestry();
|
|
55
|
+
}
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
_stopAndDestry() {
|
|
58
|
+
this._eventSyncer.stop();
|
|
59
|
+
this._eventCapturer.resetAllBuckets();
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { upsertInCache } from '~/cache/api/upsertInCache';
|
|
2
2
|
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
3
3
|
import { DAY, MINUTE } from '~/utils/constants';
|
|
4
|
-
import { pushToCache } from '~/cache/api';
|
|
4
|
+
import { dropFromCache, pushToCache } from '~/cache/api';
|
|
5
5
|
import { fireEvent } from '~/core/events';
|
|
6
6
|
import { STORY_KEY_CACHE } from '~/storyRepository/constants';
|
|
7
7
|
import { ANALYTIC_CACHE_KEY, HIGH_PRIORITY_ANALYTIC_CACHE_KEY } from '../../constant';
|
|
@@ -148,6 +148,14 @@ export class AnalyticsEventCapturer {
|
|
|
148
148
|
}, 300);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
resetAllBuckets() {
|
|
152
|
+
this._recentViewed = {};
|
|
153
|
+
this._recentHighPriorityViewed = {};
|
|
154
|
+
|
|
155
|
+
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
156
|
+
dropFromCache(HIGH_PRIORITY_ANALYTIC_CACHE_KEY);
|
|
157
|
+
}
|
|
158
|
+
|
|
151
159
|
markStoryAsViewed(story: Amity.InternalStory) {
|
|
152
160
|
this.markStory(story, Amity.AnalyticEventActivityType.View);
|
|
153
161
|
}
|
|
@@ -22,9 +22,15 @@ export class AnalyticsEventSyncer {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
stop() {
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
if (this._timer) {
|
|
26
|
+
clearInterval(this._timer);
|
|
27
|
+
this._timer = undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (this._high_priority_timer) {
|
|
31
|
+
clearInterval(this._high_priority_timer);
|
|
32
|
+
this._high_priority_timer = undefined;
|
|
33
|
+
}
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
async syncCapturedEvent() {
|