@analyticscli/sdk 0.1.0-preview.6 → 0.1.0-preview.7

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/browser.cjs CHANGED
@@ -237,7 +237,28 @@ var randomId = () => {
237
237
  if (globalThis.crypto?.randomUUID) {
238
238
  return globalThis.crypto.randomUUID();
239
239
  }
240
- return `${Date.now()}-${Math.random().toString(16).slice(2, 12)}`;
240
+ const bytes = new Uint8Array(16);
241
+ if (globalThis.crypto?.getRandomValues) {
242
+ globalThis.crypto.getRandomValues(bytes);
243
+ } else {
244
+ for (let index = 0; index < bytes.length; index += 1) {
245
+ bytes[index] = Math.floor(Math.random() * 256);
246
+ }
247
+ }
248
+ const byte6 = bytes[6] ?? 0;
249
+ const byte8 = bytes[8] ?? 0;
250
+ bytes[6] = byte6 & 15 | 64;
251
+ bytes[8] = byte8 & 63 | 128;
252
+ let output = "";
253
+ for (let index = 0; index < bytes.length; index += 1) {
254
+ const byte = bytes[index] ?? 0;
255
+ const hex = byte.toString(16).padStart(2, "0");
256
+ output += hex;
257
+ if (index === 3 || index === 5 || index === 7 || index === 9) {
258
+ output += "-";
259
+ }
260
+ }
261
+ return output;
241
262
  };
242
263
  var readStorageSync = (storage, key) => {
243
264
  if (!storage) {
package/dist/browser.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  initAsync,
16
16
  initConsentFirst,
17
17
  initConsentFirstAsync
18
- } from "./chunk-RGEYDN6A.js";
18
+ } from "./chunk-O4FIH647.js";
19
19
  export {
20
20
  AnalyticsClient,
21
21
  ONBOARDING_EVENTS,
@@ -196,7 +196,28 @@ var randomId = () => {
196
196
  if (globalThis.crypto?.randomUUID) {
197
197
  return globalThis.crypto.randomUUID();
198
198
  }
199
- return `${Date.now()}-${Math.random().toString(16).slice(2, 12)}`;
199
+ const bytes = new Uint8Array(16);
200
+ if (globalThis.crypto?.getRandomValues) {
201
+ globalThis.crypto.getRandomValues(bytes);
202
+ } else {
203
+ for (let index = 0; index < bytes.length; index += 1) {
204
+ bytes[index] = Math.floor(Math.random() * 256);
205
+ }
206
+ }
207
+ const byte6 = bytes[6] ?? 0;
208
+ const byte8 = bytes[8] ?? 0;
209
+ bytes[6] = byte6 & 15 | 64;
210
+ bytes[8] = byte8 & 63 | 128;
211
+ let output = "";
212
+ for (let index = 0; index < bytes.length; index += 1) {
213
+ const byte = bytes[index] ?? 0;
214
+ const hex = byte.toString(16).padStart(2, "0");
215
+ output += hex;
216
+ if (index === 3 || index === 5 || index === 7 || index === 9) {
217
+ output += "-";
218
+ }
219
+ }
220
+ return output;
200
221
  };
201
222
  var readStorageSync = (storage, key) => {
202
223
  if (!storage) {
package/dist/index.cjs CHANGED
@@ -237,7 +237,28 @@ var randomId = () => {
237
237
  if (globalThis.crypto?.randomUUID) {
238
238
  return globalThis.crypto.randomUUID();
239
239
  }
240
- return `${Date.now()}-${Math.random().toString(16).slice(2, 12)}`;
240
+ const bytes = new Uint8Array(16);
241
+ if (globalThis.crypto?.getRandomValues) {
242
+ globalThis.crypto.getRandomValues(bytes);
243
+ } else {
244
+ for (let index = 0; index < bytes.length; index += 1) {
245
+ bytes[index] = Math.floor(Math.random() * 256);
246
+ }
247
+ }
248
+ const byte6 = bytes[6] ?? 0;
249
+ const byte8 = bytes[8] ?? 0;
250
+ bytes[6] = byte6 & 15 | 64;
251
+ bytes[8] = byte8 & 63 | 128;
252
+ let output = "";
253
+ for (let index = 0; index < bytes.length; index += 1) {
254
+ const byte = bytes[index] ?? 0;
255
+ const hex = byte.toString(16).padStart(2, "0");
256
+ output += hex;
257
+ if (index === 3 || index === 5 || index === 7 || index === 9) {
258
+ output += "-";
259
+ }
260
+ }
261
+ return output;
241
262
  };
242
263
  var readStorageSync = (storage, key) => {
243
264
  if (!storage) {
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  initAsync,
16
16
  initConsentFirst,
17
17
  initConsentFirstAsync
18
- } from "./chunk-RGEYDN6A.js";
18
+ } from "./chunk-O4FIH647.js";
19
19
  export {
20
20
  AnalyticsClient,
21
21
  ONBOARDING_EVENTS,
@@ -237,7 +237,28 @@ var randomId = () => {
237
237
  if (globalThis.crypto?.randomUUID) {
238
238
  return globalThis.crypto.randomUUID();
239
239
  }
240
- return `${Date.now()}-${Math.random().toString(16).slice(2, 12)}`;
240
+ const bytes = new Uint8Array(16);
241
+ if (globalThis.crypto?.getRandomValues) {
242
+ globalThis.crypto.getRandomValues(bytes);
243
+ } else {
244
+ for (let index = 0; index < bytes.length; index += 1) {
245
+ bytes[index] = Math.floor(Math.random() * 256);
246
+ }
247
+ }
248
+ const byte6 = bytes[6] ?? 0;
249
+ const byte8 = bytes[8] ?? 0;
250
+ bytes[6] = byte6 & 15 | 64;
251
+ bytes[8] = byte8 & 63 | 128;
252
+ let output = "";
253
+ for (let index = 0; index < bytes.length; index += 1) {
254
+ const byte = bytes[index] ?? 0;
255
+ const hex = byte.toString(16).padStart(2, "0");
256
+ output += hex;
257
+ if (index === 3 || index === 5 || index === 7 || index === 9) {
258
+ output += "-";
259
+ }
260
+ }
261
+ return output;
241
262
  };
242
263
  var readStorageSync = (storage, key) => {
243
264
  if (!storage) {
@@ -15,7 +15,7 @@ import {
15
15
  initAsync,
16
16
  initConsentFirst,
17
17
  initConsentFirstAsync
18
- } from "./chunk-RGEYDN6A.js";
18
+ } from "./chunk-O4FIH647.js";
19
19
  export {
20
20
  AnalyticsClient,
21
21
  ONBOARDING_EVENTS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analyticscli/sdk",
3
- "version": "0.1.0-preview.6",
3
+ "version": "0.1.0-preview.7",
4
4
  "description": "TypeScript SDK for sending onboarding, paywall, purchase and survey analytics events to AnalyticsCLI.",
5
5
  "license": "MIT",
6
6
  "type": "module",