@cossistant/core 0.0.19 → 0.0.20
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/api.d.ts.map +1 -1
- package/client.d.ts.map +1 -1
- package/client.js +4 -4
- package/client.js.map +1 -1
- package/conversation.d.ts +13 -13
- package/conversation.d.ts.map +1 -1
- package/core.d.ts.map +1 -1
- package/package.json +1 -1
- package/realtime-events.d.ts +7 -7
- package/rest-client.js +1 -1
- package/rest-client.js.map +1 -1
- package/schemas.d.ts.map +1 -1
- package/schemas3.d.ts +3 -3
- package/store/create-store.d.ts.map +1 -1
- package/timeline-item.d.ts +8 -8
- package/timeline-item.d.ts.map +1 -1
- package/visitor-tracker.js +1 -1
- package/visitor-tracker.js.map +1 -1
package/visitor-tracker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visitor-tracker.js","names":[],"sources":["../src/visitor-tracker.ts"],"sourcesContent":["/**\n * Visitor tracking utilities for managing visitor IDs in localStorage\n */\n\nimport { isValidULID } from \"./utils\";\n\nconst STORAGE_KEY_PREFIX = \"cossistant_visitor\";\n\n/**\n * Get the localStorage key for a specific website\n */\nfunction getStorageKey(websiteId: string): string {\n\treturn `${STORAGE_KEY_PREFIX}_${websiteId}`;\n}\n\n/**\n * Check if localStorage is available\n */\nfunction isLocalStorageAvailable(): boolean {\n\ttry {\n\t\tif (typeof window === \"undefined\" || !window.localStorage) {\n\t\t\treturn false;\n\t\t}\n\t\tconst testKey = \"__cossistant_test__\";\n\t\tlocalStorage.setItem(testKey, \"test\");\n\t\tlocalStorage.removeItem(testKey);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Get visitor ID from localStorage for a specific website\n */\nexport function getVisitorId(websiteId: string): string | null {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn null;\n\t\t}\n\t\tconst data = localStorage.getItem(getStorageKey(websiteId));\n\t\tif (!data) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst parsed = JSON.parse(data);\n\t\t// Validate that the visitor ID is a valid ULID (26 characters)\n\t\tif (parsed.visitorId && isValidULID(parsed.visitorId)) {\n\t\t\treturn parsed.visitorId;\n\t\t}\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Set visitor ID in localStorage for a specific website\n */\nexport function setVisitorId(websiteId: string, visitorId: string): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst data = {\n\t\t\tvisitorId,\n\t\t\ttimestamp: Date.now(),\n\t\t\twebsiteId,\n\t\t};\n\t\
|
|
1
|
+
{"version":3,"file":"visitor-tracker.js","names":[],"sources":["../src/visitor-tracker.ts"],"sourcesContent":["/**\n * Visitor tracking utilities for managing visitor IDs in localStorage\n */\n\nimport { isValidULID } from \"./utils\";\n\nconst STORAGE_KEY_PREFIX = \"cossistant_visitor\";\n\n/**\n * Get the localStorage key for a specific website\n */\nfunction getStorageKey(websiteId: string): string {\n\treturn `${STORAGE_KEY_PREFIX}_${websiteId}`;\n}\n\n/**\n * Check if localStorage is available\n */\nfunction isLocalStorageAvailable(): boolean {\n\ttry {\n\t\tif (typeof window === \"undefined\" || !window.localStorage) {\n\t\t\treturn false;\n\t\t}\n\t\tconst testKey = \"__cossistant_test__\";\n\t\tlocalStorage.setItem(testKey, \"test\");\n\t\tlocalStorage.removeItem(testKey);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Get visitor ID from localStorage for a specific website\n */\nexport function getVisitorId(websiteId: string): string | null {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn null;\n\t\t}\n\t\tconst data = localStorage.getItem(getStorageKey(websiteId));\n\t\tif (!data) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst parsed = JSON.parse(data);\n\t\t// Validate that the visitor ID is a valid ULID (26 characters)\n\t\tif (parsed.visitorId && isValidULID(parsed.visitorId)) {\n\t\t\treturn parsed.visitorId;\n\t\t}\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Set visitor ID in localStorage for a specific website\n */\nexport function setVisitorId(websiteId: string, visitorId: string): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tconst data = {\n\t\t\tvisitorId,\n\t\t\ttimestamp: Date.now(),\n\t\t\twebsiteId,\n\t\t};\n\t\tconst key = getStorageKey(websiteId);\n\t\tlocalStorage.setItem(key, JSON.stringify(data));\n\t} catch {\n\t\t// Silently fail - visitor tracking is not critical\n\t}\n}\n\n/**\n * Clear visitor ID for a specific website\n */\nexport function clearVisitorId(websiteId: string): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tlocalStorage.removeItem(getStorageKey(websiteId));\n\t} catch {\n\t\t// Silently fail - visitor tracking is not critical\n\t}\n}\n\n/**\n * Clear all visitor IDs\n */\nexport function clearAllVisitorIds(): void {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tconst keys = Object.keys(localStorage).filter((key) =>\n\t\t\tkey.startsWith(STORAGE_KEY_PREFIX)\n\t\t);\n\t\tfor (const key of keys) {\n\t\t\tlocalStorage.removeItem(key);\n\t\t}\n\t} catch {\n\t\t// Silently fail - visitor tracking is not critical\n\t}\n}\n\n/**\n * Get any existing visitor ID from localStorage by matching the public key\n * This is useful when we don't yet know the website ID but need to check for existing visitors\n */\nexport function getExistingVisitorId(\n\tpublicKey: string\n): { websiteId: string; visitorId: string } | null {\n\tif (!isLocalStorageAvailable()) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn null;\n\t\t}\n\t\t// Find all visitor keys in localStorage\n\t\tconst keys = Object.keys(localStorage).filter((key) =>\n\t\t\tkey.startsWith(STORAGE_KEY_PREFIX)\n\t\t);\n\n\t\t// Check each one to see if we have a valid visitor ID\n\t\tfor (const key of keys) {\n\t\t\tconst data =\n\t\t\t\ttypeof window !== \"undefined\" ? localStorage.getItem(key) : null;\n\t\t\tif (!data) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse(data);\n\t\t\t\t// Validate that the visitor ID is a valid ULID\n\t\t\t\tif (\n\t\t\t\t\tparsed.visitorId &&\n\t\t\t\t\tisValidULID(parsed.visitorId) &&\n\t\t\t\t\tparsed.websiteId\n\t\t\t\t) {\n\t\t\t\t\t// We found a valid visitor ID - return it\n\t\t\t\t\t// Note: In a multi-website scenario, you might want to match by public key\n\t\t\t\t\t// For now, we'll return the first valid one found\n\t\t\t\t\treturn {\n\t\t\t\t\t\twebsiteId: parsed.websiteId,\n\t\t\t\t\t\tvisitorId: parsed.visitorId,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t}\n\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;AAMA,MAAM,qBAAqB;;;;AAK3B,SAAS,cAAc,WAA2B;AACjD,QAAO,GAAG,mBAAmB,GAAG;;;;;AAMjC,SAAS,0BAAmC;AAC3C,KAAI;AACH,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,aAC5C,QAAO;EAER,MAAM,UAAU;AAChB,eAAa,QAAQ,SAAS,OAAO;AACrC,eAAa,WAAW,QAAQ;AAChC,SAAO;SACA;AACP,SAAO;;;;;;AAOT,SAAgB,aAAa,WAAkC;AAC9D,KAAI,CAAC,yBAAyB,CAC7B,QAAO;AAGR,KAAI;AACH,MAA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