@imtbl/sdk 0.45.4 → 0.45.6

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/dist/index.js CHANGED
@@ -24,6 +24,300 @@ import { SwapRouter, PaymentsExtended } from '@uniswap/router-sdk';
24
24
  import { parseUnits } from '@ethersproject/units';
25
25
  import { BigNumber as BigNumber$2 } from '@ethersproject/bignumber';
26
26
 
27
+ const isNode$1 = () => typeof window === 'undefined';
28
+ const isBrowser$1 = () => !isNode$1();
29
+
30
+ var Detail$1;
31
+ (function (Detail) {
32
+ Detail["RUNTIME_ID"] = "rid";
33
+ Detail["PASSPORT_CLIENT_ID"] = "passportClientId";
34
+ Detail["ENVIRONMENT"] = "env";
35
+ Detail["PUBLISHABLE_API_KEY"] = "pak";
36
+ Detail["IDENTITY"] = "uid";
37
+ Detail["DOMAIN"] = "domain";
38
+ })(Detail$1 || (Detail$1 = {}));
39
+ var Store$1;
40
+ (function (Store) {
41
+ Store["EVENTS"] = "events";
42
+ Store["RUNTIME"] = "runtime";
43
+ })(Store$1 || (Store$1 = {}));
44
+ const POLLING_FREQUENCY$1 = 5000;
45
+
46
+ const IMTBL_API$1 = 'https://api.x.immutable.com';
47
+ async function post$1(path, data) {
48
+ const client = globalAxios$1.create({
49
+ baseURL: IMTBL_API$1,
50
+ });
51
+ const payload = JSON.stringify(data);
52
+ const body = {
53
+ payload: btoa(payload),
54
+ };
55
+ const response = await client.post(path, body);
56
+ return response.data;
57
+ }
58
+
59
+ /**
60
+ * Abstraction on localstorage
61
+ */
62
+ const localStoragePrefix$1 = '__IMX-';
63
+ const hasLocalstorage$1 = () => isBrowser$1() && window.localStorage;
64
+ const parseItem$1 = (payload) => {
65
+ // Try to parse, if can't be parsed assume string
66
+ // and return string
67
+ if (payload === null)
68
+ return undefined;
69
+ try {
70
+ return JSON.parse(payload);
71
+ }
72
+ catch (error) {
73
+ // Assumes it's a string.
74
+ return payload;
75
+ }
76
+ };
77
+ const serialiseItem$1 = (payload) => {
78
+ if (typeof payload === 'string') {
79
+ return payload;
80
+ }
81
+ return JSON.stringify(payload);
82
+ };
83
+ /**
84
+ * GenKey will take into account the namespace
85
+ * as well as if being run in the Link, it will tap into the link
86
+ * @param {string} key
87
+ * @returns key
88
+ */
89
+ const genKey$1 = (key) => `${localStoragePrefix$1}${key}`;
90
+ function getItem$1(key) {
91
+ if (hasLocalstorage$1()) {
92
+ return parseItem$1(window.localStorage.getItem(genKey$1(key)));
93
+ }
94
+ return undefined;
95
+ }
96
+ const setItem$1 = (key, payload) => {
97
+ if (hasLocalstorage$1()) {
98
+ window.localStorage.setItem(genKey$1(key), serialiseItem$1(payload));
99
+ return true;
100
+ }
101
+ return false;
102
+ };
103
+
104
+ // In memory storage for events and other data
105
+ let EVENT_STORE$1;
106
+ let RUNTIME_DETAILS$1;
107
+ // Initialise store and runtime
108
+ const initialise$1$1 = () => {
109
+ EVENT_STORE$1 = getItem$1(Store$1.EVENTS) || [];
110
+ RUNTIME_DETAILS$1 = getItem$1(Store$1.RUNTIME) || {};
111
+ };
112
+ initialise$1$1();
113
+ // Runtime Details
114
+ const storeDetail$1 = (key, value) => {
115
+ RUNTIME_DETAILS$1 = {
116
+ ...RUNTIME_DETAILS$1,
117
+ [key]: value,
118
+ };
119
+ setItem$1(Store$1.RUNTIME, RUNTIME_DETAILS$1);
120
+ };
121
+ const getDetail$1 = (key) => {
122
+ // Handle the scenario where detail is a falsy value
123
+ if (RUNTIME_DETAILS$1[key] === undefined) {
124
+ return undefined;
125
+ }
126
+ return RUNTIME_DETAILS$1[key];
127
+ };
128
+ const getAllDetails$1 = () => RUNTIME_DETAILS$1;
129
+ // Events
130
+ const getEvents$1 = () => EVENT_STORE$1;
131
+ const addEvent$1 = (event) => {
132
+ EVENT_STORE$1.push(event);
133
+ setItem$1(Store$1.EVENTS, EVENT_STORE$1);
134
+ };
135
+ const removeSentEvents$1 = (numberOfEvents) => {
136
+ EVENT_STORE$1 = EVENT_STORE$1.slice(numberOfEvents);
137
+ setItem$1(Store$1.EVENTS, EVENT_STORE$1);
138
+ };
139
+ const flattenProperties$1 = (properties) => {
140
+ const propertyMap = [];
141
+ Object.entries(properties).forEach(([key, value]) => {
142
+ if (typeof key === 'string'
143
+ || typeof value === 'string'
144
+ || typeof value === 'number'
145
+ || typeof value === 'boolean') {
146
+ propertyMap.push([key, value.toString()]);
147
+ }
148
+ });
149
+ return propertyMap;
150
+ };
151
+
152
+ let initialised$1 = false;
153
+ const isInitialised$1 = () => initialised$1;
154
+ const getReferrer$1 = () => {
155
+ if (isNode$1()) {
156
+ return '';
157
+ }
158
+ if (window.location.ancestorOrigins
159
+ && window.location.ancestorOrigins.length > 0) {
160
+ return new URL(window.location.ancestorOrigins[0]).hostname;
161
+ }
162
+ return document.referrer ? new URL(window.document.referrer).hostname : '';
163
+ };
164
+ const runtimeHost$1 = () => {
165
+ if (isNode$1()) {
166
+ return '';
167
+ }
168
+ if (window.opener || window.parent !== window) {
169
+ return getReferrer$1();
170
+ }
171
+ return new URL(window.location.href).hostname;
172
+ };
173
+ const getRuntimeDetails$1 = () => {
174
+ if (isNode$1()) {
175
+ return { browser: 'nodejs' };
176
+ }
177
+ const domain = runtimeHost$1();
178
+ if (domain) {
179
+ storeDetail$1(Detail$1.DOMAIN, domain);
180
+ }
181
+ return {
182
+ browser: window.navigator.userAgent,
183
+ domain,
184
+ tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
185
+ screen: `${window.screen.width}x${window.screen.height}`,
186
+ };
187
+ };
188
+ const initialise$2 = async () => {
189
+ const runtimeDetails = flattenProperties$1(getRuntimeDetails$1());
190
+ // Get any existing runtimeId and send it along with the initialise
191
+ const existingRuntimeId = getDetail$1(Detail$1.RUNTIME_ID);
192
+ const body = {
193
+ version: 1,
194
+ data: {
195
+ runtimeDetails,
196
+ runtimeId: existingRuntimeId,
197
+ },
198
+ };
199
+ const response = await post$1('/v1/sdk/initialise', body);
200
+ // Get runtimeId and store it
201
+ const { runtimeId } = response;
202
+ storeDetail$1(Detail$1.RUNTIME_ID, runtimeId);
203
+ initialised$1 = true;
204
+ };
205
+
206
+ function errorBoundary$1(fn) {
207
+ const wrappedFunction = ((...args) => {
208
+ try {
209
+ // Execute the original function
210
+ const result = fn(...args);
211
+ if (result instanceof Promise) {
212
+ // Silent fail for now, in future
213
+ // we can send errors to a logging service
214
+ return result.catch(() => undefined);
215
+ }
216
+ return result;
217
+ }
218
+ catch (error) {
219
+ // As above, fail silently for now
220
+ return undefined;
221
+ }
222
+ });
223
+ return wrappedFunction;
224
+ }
225
+
226
+ function isTestEnvironment$1() {
227
+ if (typeof process === 'undefined') {
228
+ return false;
229
+ }
230
+ return process.env.JEST_WORKER_ID !== undefined;
231
+ }
232
+
233
+ // Store the event in the event store
234
+ const trackFn$1 = (moduleName, eventName, properties) => {
235
+ const event = {
236
+ event: `${moduleName}.${eventName}`,
237
+ time: new Date().toISOString(),
238
+ ...(properties && { properties: flattenProperties$1(properties) }),
239
+ };
240
+ addEvent$1(event);
241
+ };
242
+ const track$1 = errorBoundary$1(trackFn$1);
243
+ // Sending events to the server
244
+ const flushFn$1 = async () => {
245
+ // Don't flush if not initialised
246
+ if (isInitialised$1() === false) {
247
+ await initialise$2();
248
+ return;
249
+ }
250
+ const events = getEvents$1();
251
+ if (events.length === 0) {
252
+ return;
253
+ }
254
+ // Track events length here, incase
255
+ const numEvents = events.length;
256
+ // Get details and send it with the track request
257
+ const details = getAllDetails$1();
258
+ const metricsPayload = {
259
+ version: 1,
260
+ data: {
261
+ events,
262
+ details,
263
+ },
264
+ };
265
+ const response = await post$1('/v1/sdk/metrics', metricsPayload);
266
+ if (response instanceof Error) {
267
+ return;
268
+ }
269
+ // Clear events if successfully posted
270
+ removeSentEvents$1(numEvents);
271
+ };
272
+ const flush$1 = errorBoundary$1(flushFn$1);
273
+ // Flush events every 5 seconds
274
+ const flushPoll$1 = async () => {
275
+ await flush$1();
276
+ setTimeout(flushPoll$1, POLLING_FREQUENCY$1);
277
+ };
278
+ // This will get initialised when module is imported.
279
+ if (!isTestEnvironment$1()) {
280
+ errorBoundary$1(flushPoll$1)();
281
+ }
282
+
283
+ const parseIdentity = (params) => {
284
+ if (params.passportId) {
285
+ const key = `passport:${params.passportId.toLowerCase()}`;
286
+ return key;
287
+ }
288
+ if (params.ethAddress) {
289
+ const key = `ethAddress:${params.ethAddress.toLowerCase()}`;
290
+ return key;
291
+ }
292
+ throw new Error('invalid_identity');
293
+ };
294
+ const identifyFn = (params) => {
295
+ const identity = parseIdentity(params);
296
+ if (!identity) {
297
+ return;
298
+ }
299
+ storeDetail$1(Detail$1.IDENTITY, identity);
300
+ track$1('metrics', 'identify', params.traits);
301
+ };
302
+ const identify = errorBoundary$1(identifyFn);
303
+
304
+ const setEnvironmentFn = (env) => {
305
+ storeDetail$1(Detail$1.ENVIRONMENT, env);
306
+ };
307
+ const setEnvironment = errorBoundary$1(setEnvironmentFn);
308
+ const setPassportClientIdFn = (passportClientId) => {
309
+ storeDetail$1(Detail$1.PASSPORT_CLIENT_ID, passportClientId);
310
+ };
311
+ const setPassportClientId = errorBoundary$1(setPassportClientIdFn);
312
+ const setPublishableApiKeyFn = (publishableApiKey) => {
313
+ storeDetail$1(Detail$1.PUBLISHABLE_API_KEY, publishableApiKey);
314
+ };
315
+ const setPublishableApiKey = errorBoundary$1(setPublishableApiKeyFn);
316
+
317
+ track$1('metrics', 'sdk_version', {
318
+ version: '0.45.6',
319
+ });
320
+
27
321
  var Environment$1;
28
322
  (function (Environment) {
29
323
  Environment["PRODUCTION"] = "production";
@@ -36,6 +330,8 @@ class ImmutableConfiguration {
36
330
  publishableKey;
37
331
  constructor(options) {
38
332
  this.environment = options.environment;
333
+ setEnvironment(options.environment);
334
+ track$1('config', 'created_imtbl_config');
39
335
  }
40
336
  }
41
337
  const API_KEY_PREFIX = 'sk_imapik-';
@@ -51,6 +347,7 @@ const addPublishableKeyToAxiosHeader = (publishableKey) => {
51
347
  throw new Error('Invalid Publishable key. Create your Publishable key in Immutable developer hub.'
52
348
  + ' https://hub.immutable.com');
53
349
  }
350
+ setPublishableApiKey(publishableKey);
54
351
  globalAxios$1.defaults.headers.common['x-immutable-publishable-key'] = publishableKey;
55
352
  };
56
353
  const addRateLimitingKeyToAxiosHeader = (rateLimitingKey) => {
@@ -10619,7 +10916,7 @@ class MultiRollupApiClients {
10619
10916
  }
10620
10917
 
10621
10918
  // eslint-disable-next-line @typescript-eslint/naming-convention
10622
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.45.4' };
10919
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.45.6' };
10623
10920
  const createConfig = ({ basePath, headers, }) => {
10624
10921
  if (!basePath.trim()) {
10625
10922
  throw Error('basePath can not be empty');
@@ -10691,7 +10988,7 @@ class APIError extends Error {
10691
10988
 
10692
10989
  /* eslint-disable implicit-arrow-linebreak */
10693
10990
  const defaultHeaders = {
10694
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.4',
10991
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.6',
10695
10992
  };
10696
10993
  /**
10697
10994
  * createAPIConfiguration to create a custom Configuration
@@ -11130,7 +11427,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11130
11427
  chainID,
11131
11428
  coreContractAddress,
11132
11429
  registrationContractAddress,
11133
- sdkVersion: 'ts-immutable-sdk-0.45.4',
11430
+ sdkVersion: 'ts-immutable-sdk-0.45.6',
11134
11431
  });
11135
11432
  /**
11136
11433
  * Sets `sdkVersion` at the time of build
@@ -17871,7 +18168,8 @@ class Passport {
17871
18168
  this.multiRollupApiClients = new MultiRollupApiClients(this.config.multiRollupConfig);
17872
18169
  this.passportEventEmitter = new TypedEventEmitter();
17873
18170
  const imxClientConfig = this.config.baseConfig.environment === Environment$1.PRODUCTION
17874
- ? imxApiConfig.getProduction() : imxApiConfig.getSandbox();
18171
+ ? imxApiConfig.getProduction()
18172
+ : imxApiConfig.getSandbox();
17875
18173
  const imxApiClients = passportModuleConfiguration.overrides?.imxApiClients
17876
18174
  || new ImxApiClients(imxClientConfig);
17877
18175
  this.passportImxProviderFactory = new PassportImxProviderFactory({
@@ -17883,6 +18181,8 @@ class Passport {
17883
18181
  passportEventEmitter: this.passportEventEmitter,
17884
18182
  imxApiClients,
17885
18183
  });
18184
+ setPassportClientId(passportModuleConfiguration.clientId);
18185
+ track$1('passport', 'initialised');
17886
18186
  }
17887
18187
  /**
17888
18188
  * @deprecated The method `login` with an argument of `{ useCachedSession: true }` should be used in conjunction with
@@ -17928,6 +18228,11 @@ class Passport {
17928
18228
  if (!user && !useCachedSession) {
17929
18229
  user = await this.authManager.login();
17930
18230
  }
18231
+ if (user) {
18232
+ identify({
18233
+ passportId: user.profile.sub,
18234
+ });
18235
+ }
17931
18236
  return user ? user.profile : null;
17932
18237
  }
17933
18238
  async loginCallback() {
@@ -36284,6 +36589,266 @@ class TokenBridge {
36284
36589
  }
36285
36590
  }
36286
36591
 
36592
+ const isNode = () => typeof window === 'undefined';
36593
+ const isBrowser = () => !isNode();
36594
+
36595
+ var Detail;
36596
+ (function (Detail) {
36597
+ Detail["RUNTIME_ID"] = "rid";
36598
+ Detail["PASSPORT_CLIENT_ID"] = "passportClientId";
36599
+ Detail["ENVIRONMENT"] = "env";
36600
+ Detail["PUBLISHABLE_API_KEY"] = "pak";
36601
+ Detail["IDENTITY"] = "uid";
36602
+ Detail["DOMAIN"] = "domain";
36603
+ })(Detail || (Detail = {}));
36604
+ var Store;
36605
+ (function (Store) {
36606
+ Store["EVENTS"] = "events";
36607
+ Store["RUNTIME"] = "runtime";
36608
+ })(Store || (Store = {}));
36609
+ const POLLING_FREQUENCY = 5000;
36610
+
36611
+ const IMTBL_API = 'https://api.x.immutable.com';
36612
+ async function post(path, data) {
36613
+ const client = axios$1.create({
36614
+ baseURL: IMTBL_API,
36615
+ });
36616
+ const payload = JSON.stringify(data);
36617
+ const body = {
36618
+ payload: btoa(payload),
36619
+ };
36620
+ const response = await client.post(path, body);
36621
+ return response.data;
36622
+ }
36623
+
36624
+ /**
36625
+ * Abstraction on localstorage
36626
+ */
36627
+ const localStoragePrefix = '__IMX-';
36628
+ const hasLocalstorage = () => isBrowser() && window.localStorage;
36629
+ const parseItem = (payload) => {
36630
+ // Try to parse, if can't be parsed assume string
36631
+ // and return string
36632
+ if (payload === null)
36633
+ return undefined;
36634
+ try {
36635
+ return JSON.parse(payload);
36636
+ }
36637
+ catch (error) {
36638
+ // Assumes it's a string.
36639
+ return payload;
36640
+ }
36641
+ };
36642
+ const serialiseItem = (payload) => {
36643
+ if (typeof payload === 'string') {
36644
+ return payload;
36645
+ }
36646
+ return JSON.stringify(payload);
36647
+ };
36648
+ /**
36649
+ * GenKey will take into account the namespace
36650
+ * as well as if being run in the Link, it will tap into the link
36651
+ * @param {string} key
36652
+ * @returns key
36653
+ */
36654
+ const genKey = (key) => `${localStoragePrefix}${key}`;
36655
+ function getItem(key) {
36656
+ if (hasLocalstorage()) {
36657
+ return parseItem(window.localStorage.getItem(genKey(key)));
36658
+ }
36659
+ return undefined;
36660
+ }
36661
+ const setItem = (key, payload) => {
36662
+ if (hasLocalstorage()) {
36663
+ window.localStorage.setItem(genKey(key), serialiseItem(payload));
36664
+ return true;
36665
+ }
36666
+ return false;
36667
+ };
36668
+
36669
+ // In memory storage for events and other data
36670
+ let EVENT_STORE;
36671
+ let RUNTIME_DETAILS;
36672
+ // Initialise store and runtime
36673
+ const initialise$1 = () => {
36674
+ EVENT_STORE = getItem(Store.EVENTS) || [];
36675
+ RUNTIME_DETAILS = getItem(Store.RUNTIME) || {};
36676
+ };
36677
+ initialise$1();
36678
+ // Runtime Details
36679
+ const storeDetail = (key, value) => {
36680
+ RUNTIME_DETAILS = {
36681
+ ...RUNTIME_DETAILS,
36682
+ [key]: value,
36683
+ };
36684
+ setItem(Store.RUNTIME, RUNTIME_DETAILS);
36685
+ };
36686
+ const getDetail = (key) => {
36687
+ // Handle the scenario where detail is a falsy value
36688
+ if (RUNTIME_DETAILS[key] === undefined) {
36689
+ return undefined;
36690
+ }
36691
+ return RUNTIME_DETAILS[key];
36692
+ };
36693
+ const getAllDetails = () => RUNTIME_DETAILS;
36694
+ // Events
36695
+ const getEvents = () => EVENT_STORE;
36696
+ const addEvent = (event) => {
36697
+ EVENT_STORE.push(event);
36698
+ setItem(Store.EVENTS, EVENT_STORE);
36699
+ };
36700
+ const removeSentEvents = (numberOfEvents) => {
36701
+ EVENT_STORE = EVENT_STORE.slice(numberOfEvents);
36702
+ setItem(Store.EVENTS, EVENT_STORE);
36703
+ };
36704
+ const flattenProperties = (properties) => {
36705
+ const propertyMap = [];
36706
+ Object.entries(properties).forEach(([key, value]) => {
36707
+ if (typeof key === 'string'
36708
+ || typeof value === 'string'
36709
+ || typeof value === 'number'
36710
+ || typeof value === 'boolean') {
36711
+ propertyMap.push([key, value.toString()]);
36712
+ }
36713
+ });
36714
+ return propertyMap;
36715
+ };
36716
+
36717
+ let initialised = false;
36718
+ const isInitialised = () => initialised;
36719
+ const getReferrer = () => {
36720
+ if (isNode()) {
36721
+ return '';
36722
+ }
36723
+ if (window.location.ancestorOrigins
36724
+ && window.location.ancestorOrigins.length > 0) {
36725
+ return new URL(window.location.ancestorOrigins[0]).hostname;
36726
+ }
36727
+ return document.referrer ? new URL(window.document.referrer).hostname : '';
36728
+ };
36729
+ const runtimeHost = () => {
36730
+ if (isNode()) {
36731
+ return '';
36732
+ }
36733
+ if (window.opener || window.parent !== window) {
36734
+ return getReferrer();
36735
+ }
36736
+ return new URL(window.location.href).hostname;
36737
+ };
36738
+ const getRuntimeDetails = () => {
36739
+ if (isNode()) {
36740
+ return { browser: 'nodejs' };
36741
+ }
36742
+ const domain = runtimeHost();
36743
+ if (domain) {
36744
+ storeDetail(Detail.DOMAIN, domain);
36745
+ }
36746
+ return {
36747
+ browser: window.navigator.userAgent,
36748
+ domain,
36749
+ tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
36750
+ screen: `${window.screen.width}x${window.screen.height}`,
36751
+ };
36752
+ };
36753
+ const initialise = async () => {
36754
+ const runtimeDetails = flattenProperties(getRuntimeDetails());
36755
+ // Get any existing runtimeId and send it along with the initialise
36756
+ const existingRuntimeId = getDetail(Detail.RUNTIME_ID);
36757
+ const body = {
36758
+ version: 1,
36759
+ data: {
36760
+ runtimeDetails,
36761
+ runtimeId: existingRuntimeId,
36762
+ },
36763
+ };
36764
+ const response = await post('/v1/sdk/initialise', body);
36765
+ // Get runtimeId and store it
36766
+ const { runtimeId } = response;
36767
+ storeDetail(Detail.RUNTIME_ID, runtimeId);
36768
+ initialised = true;
36769
+ };
36770
+
36771
+ function errorBoundary(fn) {
36772
+ const wrappedFunction = ((...args) => {
36773
+ try {
36774
+ // Execute the original function
36775
+ const result = fn(...args);
36776
+ if (result instanceof Promise) {
36777
+ // Silent fail for now, in future
36778
+ // we can send errors to a logging service
36779
+ return result.catch(() => undefined);
36780
+ }
36781
+ return result;
36782
+ }
36783
+ catch (error) {
36784
+ // As above, fail silently for now
36785
+ return undefined;
36786
+ }
36787
+ });
36788
+ return wrappedFunction;
36789
+ }
36790
+
36791
+ function isTestEnvironment() {
36792
+ if (typeof process === 'undefined') {
36793
+ return false;
36794
+ }
36795
+ return process.env.JEST_WORKER_ID !== undefined;
36796
+ }
36797
+
36798
+ // Store the event in the event store
36799
+ const trackFn = (moduleName, eventName, properties) => {
36800
+ const event = {
36801
+ event: `${moduleName}.${eventName}`,
36802
+ time: new Date().toISOString(),
36803
+ ...(properties && { properties: flattenProperties(properties) }),
36804
+ };
36805
+ addEvent(event);
36806
+ };
36807
+ const track = errorBoundary(trackFn);
36808
+ // Sending events to the server
36809
+ const flushFn = async () => {
36810
+ // Don't flush if not initialised
36811
+ if (isInitialised() === false) {
36812
+ await initialise();
36813
+ return;
36814
+ }
36815
+ const events = getEvents();
36816
+ if (events.length === 0) {
36817
+ return;
36818
+ }
36819
+ // Track events length here, incase
36820
+ const numEvents = events.length;
36821
+ // Get details and send it with the track request
36822
+ const details = getAllDetails();
36823
+ const metricsPayload = {
36824
+ version: 1,
36825
+ data: {
36826
+ events,
36827
+ details,
36828
+ },
36829
+ };
36830
+ const response = await post('/v1/sdk/metrics', metricsPayload);
36831
+ if (response instanceof Error) {
36832
+ return;
36833
+ }
36834
+ // Clear events if successfully posted
36835
+ removeSentEvents(numEvents);
36836
+ };
36837
+ const flush = errorBoundary(flushFn);
36838
+ // Flush events every 5 seconds
36839
+ const flushPoll = async () => {
36840
+ await flush();
36841
+ setTimeout(flushPoll, POLLING_FREQUENCY);
36842
+ };
36843
+ // This will get initialised when module is imported.
36844
+ if (!isTestEnvironment()) {
36845
+ errorBoundary(flushPoll)();
36846
+ }
36847
+
36848
+ track('metrics', 'sdk_version', {
36849
+ version: '0.45.6',
36850
+ });
36851
+
36287
36852
  var Environment;
36288
36853
  (function (Environment) {
36289
36854
  Environment["PRODUCTION"] = "production";
@@ -41263,7 +41828,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
41263
41828
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
41264
41829
  };
41265
41830
 
41266
- const SDK_VERSION_MARKER = '0.45.4';
41831
+ const SDK_VERSION_MARKER = '0.45.6';
41267
41832
  // This SDK version is replaced by the `yarn build` command ran on the root level
41268
41833
  const globalPackageVersion = () => SDK_VERSION_MARKER;
41269
41834
 
@@ -41468,7 +42033,7 @@ async function getERC20TokenInfo(web3Provider, tokenAddress) {
41468
42033
  }, { type: CheckoutErrorType.GET_ERC20_INFO_ERROR });
41469
42034
  }
41470
42035
 
41471
- const CACHE_DATA_TTL = 60; // seconds
42036
+ const CACHE_DATA_TTL = 5; // seconds
41472
42037
  /**
41473
42038
  * Blockscout class provides a client abstraction for the Immutable 3rd party indexer.
41474
42039
  */
@@ -21,9 +21,9 @@ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (
21
21
  } ? Required<{
22
22
  publishableKey: string;
23
23
  }> : {});
24
- type ImmutableConfigurationWithOmitableFields<T> = (T extends {
24
+ type ImmutableConfigurationWithOmitableFields<T> = T extends {
25
25
  apiKey: 'omit';
26
- } ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
26
+ } ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>;
27
27
  interface ModuleConfiguration<T> {
28
28
  baseConfig: ImmutableConfigurationWithOmitableFields<T>;
29
29
  overrides?: T;