@thumbmarkjs/thumbmarkjs 1.5.0 → 1.5.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.
- package/dist/thumbmark.cjs.js +1 -1
- package/dist/thumbmark.cjs.js.map +1 -1
- package/dist/thumbmark.esm.d.ts +1 -1
- package/dist/thumbmark.esm.js +1 -1
- package/dist/thumbmark.esm.js.map +1 -1
- package/dist/thumbmark.umd.js +1 -1
- package/dist/thumbmark.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/options.ts +1 -2
- package/src/utils/visitorId.ts +6 -2
package/package.json
CHANGED
package/src/options.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface optionsInterface {
|
|
2
|
-
storage_property_name
|
|
2
|
+
storage_property_name?: string,
|
|
3
3
|
exclude?: string[],
|
|
4
4
|
include?: string[],
|
|
5
5
|
permissions_to_check?: PermissionName[],
|
|
@@ -24,7 +24,6 @@ export const defaultOptions: optionsInterface = {
|
|
|
24
24
|
cache_api_call: true,
|
|
25
25
|
performance: false,
|
|
26
26
|
experimental: false,
|
|
27
|
-
storage_property_name: 'thumbmark_visitor_id',
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
export let options = { ...defaultOptions };
|
package/src/utils/visitorId.ts
CHANGED
|
@@ -4,12 +4,15 @@ import { optionsInterface } from "../options";
|
|
|
4
4
|
* Visitor ID storage utilities - localStorage only, server generates IDs
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
const DEFAULT_STORAGE_PROPERTY_NAME = 'thumbmark_visitor_id';
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Gets visitor ID from localStorage, returns null if unavailable
|
|
9
11
|
*/
|
|
10
12
|
export function getVisitorId(_options: optionsInterface): string | null {
|
|
13
|
+
const storagePropertyName = _options.storage_property_name || DEFAULT_STORAGE_PROPERTY_NAME;
|
|
11
14
|
try {
|
|
12
|
-
return localStorage.getItem(
|
|
15
|
+
return localStorage.getItem(storagePropertyName);
|
|
13
16
|
} catch {
|
|
14
17
|
return null;
|
|
15
18
|
}
|
|
@@ -19,8 +22,9 @@ export function getVisitorId(_options: optionsInterface): string | null {
|
|
|
19
22
|
* Sets visitor ID in localStorage
|
|
20
23
|
*/
|
|
21
24
|
export function setVisitorId(visitorId: string, _options: optionsInterface): void {
|
|
25
|
+
const storagePropertyName = _options.storage_property_name || DEFAULT_STORAGE_PROPERTY_NAME;
|
|
22
26
|
try {
|
|
23
|
-
localStorage.setItem(
|
|
27
|
+
localStorage.setItem(storagePropertyName, visitorId);
|
|
24
28
|
} catch {
|
|
25
29
|
// Ignore storage errors
|
|
26
30
|
}
|