@amplifyup/sdk 0.1.0 → 0.1.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.
@@ -176,6 +176,16 @@ var AWSAdapter = class {
176
176
  // src/storage.ts
177
177
  var INSTANCE_ID_KEY = "amplifyup_instance_id";
178
178
  var USER_ID_KEY = "amplifyup_user_id";
179
+ function generateGuid() {
180
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
181
+ return crypto.randomUUID();
182
+ }
183
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
184
+ const r = Math.random() * 16 | 0;
185
+ const v = c === "x" ? r : r & 3 | 8;
186
+ return v.toString(16);
187
+ });
188
+ }
179
189
  function getInstanceId() {
180
190
  if (typeof window === "undefined") {
181
191
  return "";
@@ -184,7 +194,7 @@ function getInstanceId() {
184
194
  if (stored) {
185
195
  return stored;
186
196
  }
187
- const instanceId = `anon_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
197
+ const instanceId = `browser_${generateGuid()}`;
188
198
  localStorage.setItem(INSTANCE_ID_KEY, instanceId);
189
199
  return instanceId;
190
200
  }