14
14
* limitations under the License.
15
15
*/
16
16
17
- import { LogLevel } from '../../modules/logging' ;
18
-
19
17
import { OdpEvent } from './odp_event' ;
20
18
import { OdpConfig , OdpIntegrationConfig } from '../odp_config' ;
21
19
import { OdpEventApiManager } from './odp_event_api_manager' ;
@@ -54,8 +52,6 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
54
52
55
53
private retryConfig : RetryConfig ;
56
54
57
- // private readonly userAgentData?: Map<string, unknown>;
58
-
59
55
constructor ( config : OdpEventManagerConfig ) {
60
56
super ( config . startUpLogs ) ;
61
57
@@ -65,28 +61,8 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
65
61
66
62
this . repeater = config . repeater ;
67
63
this . repeater . setTask ( ( ) => this . flush ( ) ) ;
68
-
69
- // if (config.userAgentParser) {
70
- // const { os, device } = config.userAgentParser.parseUserAgentInfo();
71
-
72
- // const userAgentInfo: Record<string, unknown> = {
73
- // 'os': os.name,
74
- // 'os_version': os.version,
75
- // 'device_type': device.type,
76
- // 'model': device.model,
77
- // };
78
-
79
- // this.userAgentData = new Map<string, unknown>(
80
- // Object.entries(userAgentInfo).filter(([_, value]) => value != null && value != undefined)
81
- // );
82
- // }
83
64
}
84
65
85
- // setClientInfo(clientEngine: string, clientVersion: string): void {
86
- // this.clientEngine = clientEngine;
87
- // this.clientVersion = clientVersion;
88
- // }
89
-
90
66
private async executeDispatch ( odpConfig : OdpConfig , batch : OdpEvent [ ] ) : Promise < unknown > {
91
67
const res = await this . apiManager . sendEvents ( odpConfig , batch ) ;
92
68
if ( res . statusCode && ! isSuccessStatusCode ( res . statusCode ) ) {
@@ -106,8 +82,8 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
106
82
const batch = this . queue ;
107
83
this . queue = [ ] ;
108
84
109
- // as the current queue has been emptied, stop repeating flus
110
- // until more events becomes availabe
85
+ // as the queue has been emptied, stop repeating flush
86
+ // until more events become available
111
87
this . repeater . reset ( ) ;
112
88
113
89
return runWithRetry (
@@ -129,18 +105,6 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
129
105
} else {
130
106
this . state = ServiceState . Starting ;
131
107
}
132
-
133
- // if (!this.odpIntegrationConfig) {
134
- // this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_CONFIG_NOT_AVAILABLE);
135
- // return;
136
- // }
137
-
138
- // this.status = Status.Running;
139
-
140
- // // no need of periodic flush if batchSize is 1
141
- // if (this.batchSize > 1) {
142
- // this.setNewTimeout();
143
- // }
144
108
}
145
109
146
110
updateConfig ( odpIntegrationConfig : OdpIntegrationConfig ) : void {
@@ -183,31 +147,6 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
183
147
this . stopPromise . resolve ( ) ;
184
148
}
185
149
186
- // TODO: move this to ODP manager
187
- /**
188
- * Associate a full-stack userid with an established VUID
189
- * @param {string } userId (Optional) Full-stack User ID
190
- * @param {string } vuid (Optional) Visitor User ID
191
- */
192
- // identifyUser(userId?: string, vuid?: string): void {
193
- // const identifiers = new Map<string, string>();
194
- // if (!userId && !vuid) {
195
- // this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_SEND_EVENT_FAILED_UID_MISSING);
196
- // return;
197
- // }
198
-
199
- // if (vuid) {
200
- // identifiers.set(ODP_USER_KEY.VUID, vuid);
201
- // }
202
-
203
- // if (userId) {
204
- // identifiers.set(ODP_USER_KEY.FS_USER_ID, userId);
205
- // }
206
-
207
- // const event = new OdpEvent(ODP_DEFAULT_EVENT_TYPE, ODP_EVENT_ACTION.IDENTIFIED, identifiers);
208
- // this.sendEvent(event);
209
- // }
210
-
211
150
sendEvent ( event : OdpEvent ) : void {
212
151
if ( ! this . isRunning ( ) ) {
213
152
this . logger ?. error ( 'ODP event manager is not running.' ) ;
@@ -220,7 +159,7 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
220
159
}
221
160
222
161
if ( event . identifiers . size === 0 ) {
223
- this . logger ?. log ( LogLevel . ERROR , 'ODP events should have at least one key-value pair in identifiers.' ) ;
162
+ this . logger ?. error ( 'ODP events should have at least one key-value pair in identifiers.' ) ;
224
163
return ;
225
164
}
226
165
@@ -235,7 +174,7 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
235
174
}
236
175
237
176
if ( event . type === '' ) {
238
- event . action = ODP_DEFAULT_EVENT_TYPE ;
177
+ event . type = ODP_DEFAULT_EVENT_TYPE ;
239
178
}
240
179
241
180
event . identifiers . forEach ( ( key , value ) => {
@@ -270,23 +209,4 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
270
209
this . repeater . start ( ) ;
271
210
}
272
211
}
273
-
274
- // TODO: move to ODP maanger
275
- /**
276
- * Add additional common data including an idempotent ID and execution context to event data
277
- * @param sourceData Existing event data to augment
278
- * @returns Augmented event data
279
- * @private
280
- */
281
- // private augmentCommonData(sourceData: Map<string, unknown>): Map<string, unknown> {
282
- // const data = new Map<string, unknown>(this.userAgentData);
283
-
284
- // data.set('idempotence_id', uuidV4());
285
- // data.set('data_source_type', 'sdk');
286
- // data.set('data_source', this.clientEngine);
287
- // data.set('data_source_version', this.clientVersion);
288
-
289
- // sourceData.forEach((value, key) => data.set(key, value));
290
- // return data;
291
- // }
292
212
}
0 commit comments