@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "6.18.0",
3
+ "version": "6.18.1-ab6e7e4.0",
4
4
  "license": "CC-BY-ND-4.0",
5
5
  "author": "amity.co <developers@amity.co> (https://amity.co)",
6
6
  "description": "Amity Social Cloud Typescript SDK",
@@ -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._eventSyncer.stop();
50
+ this._stopAndDestry();
53
51
  }
54
52
 
55
53
  destroy() {
56
- this._eventSyncer.stop();
54
+ this._stopAndDestry();
55
+ }
57
56
 
58
- // query and destroy all objects.
59
- dropFromCache(ANALYTIC_CACHE_KEY);
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 (!this._timer) return;
26
- clearInterval(this._timer);
27
- this._timer = undefined;
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() {