@imtbl/sdk 1.0.0 → 1.1.1-alpha

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.
@@ -4139,6 +4139,7 @@ var Detail;
4139
4139
  Detail["PUBLISHABLE_API_KEY"] = "pak";
4140
4140
  Detail["IDENTITY"] = "uid";
4141
4141
  Detail["DOMAIN"] = "domain";
4142
+ Detail["SDK_VERSION"] = "sdkVersion";
4142
4143
  })(Detail || (Detail = {}));
4143
4144
  var Store;
4144
4145
  (function (Store) {
@@ -4232,10 +4233,6 @@ const getDetail = (key) => {
4232
4233
  const getAllDetails = () => RUNTIME_DETAILS;
4233
4234
  // Events
4234
4235
  const getEvents = () => EVENT_STORE;
4235
- const addEvent = (event) => {
4236
- EVENT_STORE.push(event);
4237
- setItem(Store.EVENTS, EVENT_STORE);
4238
- };
4239
4236
  const removeSentEvents = (numberOfEvents) => {
4240
4237
  EVENT_STORE = EVENT_STORE.slice(numberOfEvents);
4241
4238
  setItem(Store.EVENTS, EVENT_STORE);
@@ -4253,6 +4250,8 @@ const flattenProperties = (properties) => {
4253
4250
  return propertyMap;
4254
4251
  };
4255
4252
 
4253
+ // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
4254
+ const SDK_VERSION = '1.1.1-alpha';
4256
4255
  let initialised = false;
4257
4256
  const isInitialised = () => initialised;
4258
4257
  const getReferrer = () => {
@@ -4275,14 +4274,16 @@ const runtimeHost = () => {
4275
4274
  return new URL(window.location.href).hostname;
4276
4275
  };
4277
4276
  const getRuntimeDetails = () => {
4277
+ storeDetail(Detail.SDK_VERSION, SDK_VERSION);
4278
4278
  if (isNode()) {
4279
- return { browser: 'nodejs' };
4279
+ return { browser: 'nodejs', sdkVersion: SDK_VERSION };
4280
4280
  }
4281
4281
  const domain = runtimeHost();
4282
4282
  if (domain) {
4283
4283
  storeDetail(Detail.DOMAIN, domain);
4284
4284
  }
4285
4285
  return {
4286
+ sdkVersion: SDK_VERSION,
4286
4287
  browser: window.navigator.userAgent,
4287
4288
  domain,
4288
4289
  tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
@@ -4291,7 +4292,6 @@ const getRuntimeDetails = () => {
4291
4292
  };
4292
4293
  const initialise = async () => {
4293
4294
  const runtimeDetails = flattenProperties(getRuntimeDetails());
4294
- // Get any existing runtimeId and send it along with the initialise
4295
4295
  const existingRuntimeId = getDetail(Detail.RUNTIME_ID);
4296
4296
  const body = {
4297
4297
  version: 1,
@@ -4331,19 +4331,10 @@ function isTestEnvironment() {
4331
4331
  if (typeof process === 'undefined') {
4332
4332
  return false;
4333
4333
  }
4334
+ // Consider using `ci-info` package for better results, though might fail as not browser safe.
4335
+ // Just use process.env.CI for now.
4334
4336
  return process.env.JEST_WORKER_ID !== undefined;
4335
4337
  }
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);
4347
4338
  // Sending events to the server
4348
4339
  const flushFn = async () => {
4349
4340
  // Don't flush if not initialised
@@ -4384,10 +4375,6 @@ if (!isTestEnvironment()) {
4384
4375
  errorBoundary(flushPoll)();
4385
4376
  }
4386
4377
 
4387
- track('metrics', 'sdk_version', {
4388
- version: '1.0.0',
4389
- });
4390
-
4391
4378
  var Environment;
4392
4379
  (function (Environment) {
4393
4380
  Environment["PRODUCTION"] = "production";
@@ -4413,7 +4400,7 @@ class APIError extends Error {
4413
4400
 
4414
4401
  /* eslint-disable implicit-arrow-linebreak */
4415
4402
  const defaultHeaders = {
4416
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.0.0',
4403
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.1.1-alpha',
4417
4404
  };
4418
4405
  /**
4419
4406
  * createAPIConfiguration to create a custom Configuration