@imtbl/sdk 0.45.5 → 1.0.0-alpha.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.
@@ -4232,6 +4232,10 @@ const getDetail = (key) => {
4232
4232
  const getAllDetails = () => RUNTIME_DETAILS;
4233
4233
  // Events
4234
4234
  const getEvents = () => EVENT_STORE;
4235
+ const addEvent = (event) => {
4236
+ EVENT_STORE.push(event);
4237
+ setItem(Store.EVENTS, EVENT_STORE);
4238
+ };
4235
4239
  const removeSentEvents = (numberOfEvents) => {
4236
4240
  EVENT_STORE = EVENT_STORE.slice(numberOfEvents);
4237
4241
  setItem(Store.EVENTS, EVENT_STORE);
@@ -4239,7 +4243,10 @@ const removeSentEvents = (numberOfEvents) => {
4239
4243
  const flattenProperties = (properties) => {
4240
4244
  const propertyMap = [];
4241
4245
  Object.entries(properties).forEach(([key, value]) => {
4242
- if (typeof value === 'string' || typeof value === 'number') {
4246
+ if (typeof key === 'string'
4247
+ || typeof value === 'string'
4248
+ || typeof value === 'number'
4249
+ || typeof value === 'boolean') {
4243
4250
  propertyMap.push([key, value.toString()]);
4244
4251
  }
4245
4252
  });
@@ -4326,6 +4333,17 @@ function isTestEnvironment() {
4326
4333
  }
4327
4334
  return process.env.JEST_WORKER_ID !== undefined;
4328
4335
  }
4336
+
4337
+ // Store the event in the event store
4338
+ const trackFn = (moduleName, eventName, properties) => {
4339
+ const event = {
4340
+ event: `${moduleName}.${eventName}`,
4341
+ time: new Date().toISOString(),
4342
+ ...(properties && { properties: flattenProperties(properties) }),
4343
+ };
4344
+ addEvent(event);
4345
+ };
4346
+ const track = errorBoundary(trackFn);
4329
4347
  // Sending events to the server
4330
4348
  const flushFn = async () => {
4331
4349
  // Don't flush if not initialised
@@ -4366,6 +4384,10 @@ if (!isTestEnvironment()) {
4366
4384
  errorBoundary(flushPoll)();
4367
4385
  }
4368
4386
 
4387
+ track('metrics', 'sdk_version', {
4388
+ version: '1.0.0-alpha.1',
4389
+ });
4390
+
4369
4391
  var Environment;
4370
4392
  (function (Environment) {
4371
4393
  Environment["PRODUCTION"] = "production";
@@ -4391,7 +4413,7 @@ class APIError extends Error {
4391
4413
 
4392
4414
  /* eslint-disable implicit-arrow-linebreak */
4393
4415
  const defaultHeaders = {
4394
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.5',
4416
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.0.0-alpha.1',
4395
4417
  };
4396
4418
  /**
4397
4419
  * createAPIConfiguration to create a custom Configuration