@levo-so/core 0.1.34 → 0.1.35

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.
@@ -37,4 +37,33 @@ var getLevoError = (error) => {
37
37
  });
38
38
  };
39
39
 
40
- export { LevoError, getLevoError };
40
+ // src/utils/lock.ts
41
+ var LocalStorageLock = class {
42
+ key;
43
+ constructor(lockKey) {
44
+ this.key = `lock_${lockKey}`;
45
+ }
46
+ acquireLock(expiryMs = 5e3) {
47
+ const now = Date.now();
48
+ const lockValue = localStorage.getItem(this.key);
49
+ if (lockValue) {
50
+ const timestamp = Number(lockValue);
51
+ if (now - timestamp < expiryMs) {
52
+ return false;
53
+ }
54
+ }
55
+ localStorage.setItem(this.key, now.toString());
56
+ return true;
57
+ }
58
+ releaseLock() {
59
+ localStorage.removeItem(this.key);
60
+ }
61
+ isLocked(expiryMs = 5e3) {
62
+ const lockValue = localStorage.getItem(this.key);
63
+ if (!lockValue) return false;
64
+ const timestamp = Number(lockValue);
65
+ return Date.now() - timestamp < expiryMs;
66
+ }
67
+ };
68
+
69
+ export { LevoError, LocalStorageLock, getLevoError };
package/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export * from "./constants";
5
5
  export * from "./utils/formatImagePath";
6
6
  export * from "./utils/getLevoError";
7
7
  export * from "./utils/LevoError";
8
+ export * from "./utils/lock";
8
9
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { LevoError, getLevoError } from './chunk-VQMSBMEM.js';
1
+ export { LevoError, LocalStorageLock, getLevoError } from './chunk-OT564SO4.js';
2
2
  export { LevoOAuthProviderList } from './chunk-ZLLCLSGE.js';
3
3
  export { LevoPlugin } from './chunk-QJSKNLTV.js';
4
4
  import wretch from 'wretch';
@@ -25,7 +25,7 @@ export declare class LevoAudience extends LevoPlugin {
25
25
  seconds: number;
26
26
  } | null;
27
27
  bounce(properties: ILevoAudience.Properties): Promise<void>;
28
- track(event: string, properties: ILevoAudience.Properties): Promise<any>;
28
+ track<T extends ILevoAudience.Properties>(event: string, properties: T & ILevoAudience.Properties): Promise<any>;
29
29
  getCurrentTabId(): string;
30
30
  getTabCount(): number;
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LevoAudience.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoAudience.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,YAAa,SAAQ,UAAU;;IAC1C,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IAC1C,aAAa,EAAE,GAAG,CAAQ;IAoB1B,OAAO,CAAC,YAAY,GAAG,OAAO,EAAE,WAAW,GAAG,OAAO,EACnD,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW;IA8Bb,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU;IA8J7C,QAAQ;IAed,WAAW;;;;;;;;;;;IAmEX,qBAAqB;IAqBrB,iBAAiB,IAAI;QACnB,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;QAC1B,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,IAAI;IAcF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU;IAc3C,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,UAAU;IAoC/D,eAAe;IAaf,WAAW;CAYZ"}
1
+ {"version":3,"file":"LevoAudience.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoAudience.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,YAAa,SAAQ,UAAU;;IAC1C,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IAC1C,aAAa,EAAE,GAAG,CAAQ;IAoB1B,OAAO,CAAC,YAAY,GAAG,OAAO,EAAE,WAAW,GAAG,OAAO,EACnD,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW;IA8Bb,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU;IA8J7C,QAAQ;IAed,WAAW;;;;;;;;;;;IAmEX,qBAAqB;IAqBrB,iBAAiB,IAAI;QACnB,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;QAC1B,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,IAAI;IAcF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU;IAc3C,KAAK,CAAC,CAAC,SAAS,aAAa,CAAC,UAAU,EAC5C,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,CAAC,GAAG,aAAa,CAAC,UAAU;IAuC1C,eAAe;IAaf,WAAW;CAYZ"}
@@ -1,4 +1,4 @@
1
- import { getLevoError } from '../chunk-VQMSBMEM.js';
1
+ import { LocalStorageLock, getLevoError } from '../chunk-OT564SO4.js';
2
2
  import { LevoPlugin } from '../chunk-QJSKNLTV.js';
3
3
  import { onUserActivity } from '@analytics/activity-utils';
4
4
  import { getVisitorSource } from '@analytics/visitor-source';
@@ -266,35 +266,6 @@ var getUserProperties = async () => {
266
266
  };
267
267
  };
268
268
 
269
- // src/utils/lock.ts
270
- var LocalStorageLock = class {
271
- key;
272
- constructor(lockKey) {
273
- this.key = `lock_${lockKey}`;
274
- }
275
- acquireLock(expiryMs = 5e3) {
276
- const now = Date.now();
277
- const lockValue = localStorage.getItem(this.key);
278
- if (lockValue) {
279
- const timestamp = Number(lockValue);
280
- if (now - timestamp < expiryMs) {
281
- return false;
282
- }
283
- }
284
- localStorage.setItem(this.key, now.toString());
285
- return true;
286
- }
287
- releaseLock() {
288
- localStorage.removeItem(this.key);
289
- }
290
- isLocked(expiryMs = 5e3) {
291
- const lockValue = localStorage.getItem(this.key);
292
- if (!lockValue) return false;
293
- const timestamp = Number(lockValue);
294
- return Date.now() - timestamp < expiryMs;
295
- }
296
- };
297
-
298
269
  // src/plugins/LevoAudience.ts
299
270
  var LevoAudience = class extends LevoPlugin {
300
271
  instance = null;
@@ -533,6 +504,7 @@ var LevoAudience = class extends LevoPlugin {
533
504
  if (!this.client.workspace) {
534
505
  return;
535
506
  }
507
+ console.log(event, properties);
536
508
  if (this.instance && this.#is_identified) {
537
509
  return this.instance.track(event, properties);
538
510
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/core",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo common utilities",
6
6
  "type": "module",