posthog-js-lite 2.0.0-alpha1 → 2.0.0-alpha4
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/lib/index.cjs.js +24 -17
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.esm.js +24 -17
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/eventemitter.d.ts +2 -2
- package/lib/posthog-core/src/index.d.ts +4 -1
- package/package.json +6 -2
- package/src/context.ts +1 -4
- package/src/posthog-web.ts +3 -3
- package/src/storage.ts +2 -3
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-js-lite",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-alpha4",
|
|
4
4
|
"main": "lib/index.cjs.js",
|
|
5
5
|
"module": "lib/index.esm.js",
|
|
6
|
-
"types": "lib/index.d.ts"
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest -c jest.config.js",
|
|
9
|
+
"prepublish": "cd .. && yarn build"
|
|
10
|
+
}
|
|
7
11
|
}
|
package/src/context.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { utils } from '../../posthog-core'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// TODO: Get this from package.json
|
|
5
|
-
const version = '2.0.0-alpha'
|
|
2
|
+
import { version } from '../package.json'
|
|
6
3
|
|
|
7
4
|
export function getContext(window: Window): any {
|
|
8
5
|
let context = {}
|
package/src/posthog-web.ts
CHANGED
|
@@ -41,18 +41,18 @@ export class PostHog extends PostHogCore {
|
|
|
41
41
|
|
|
42
42
|
if (value === null) {
|
|
43
43
|
delete this._storageCache[key]
|
|
44
|
-
this._storage.removeItem(this._storageKey)
|
|
45
44
|
} else {
|
|
46
45
|
this._storageCache[key] = value
|
|
47
|
-
this._storage.setItem(this._storageKey, JSON.stringify(this._storageCache))
|
|
48
46
|
}
|
|
47
|
+
|
|
48
|
+
this._storage.setItem(this._storageKey, JSON.stringify(this._storageCache))
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
fetch(url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse> {
|
|
52
52
|
return window.fetch(url, options)
|
|
53
53
|
}
|
|
54
54
|
getLibraryId(): string {
|
|
55
|
-
return 'posthog-
|
|
55
|
+
return 'posthog-js-lite'
|
|
56
56
|
}
|
|
57
57
|
getLibraryVersion(): string {
|
|
58
58
|
return version
|
package/src/storage.ts
CHANGED
|
@@ -31,8 +31,7 @@ export const cookieStore: PostHogStorage = {
|
|
|
31
31
|
expires = '',
|
|
32
32
|
secure = ''
|
|
33
33
|
|
|
34
|
-
const new_cookie_val =
|
|
35
|
-
key + '=' + encodeURIComponent(JSON.stringify(value)) + expires + '; path=/' + cdomain + secure
|
|
34
|
+
const new_cookie_val = key + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure
|
|
36
35
|
document.cookie = new_cookie_val
|
|
37
36
|
} catch (err) {
|
|
38
37
|
return
|
|
@@ -72,7 +71,7 @@ const createStorageLike = (store: any): PostHogStorage => {
|
|
|
72
71
|
},
|
|
73
72
|
|
|
74
73
|
setItem(key, value) {
|
|
75
|
-
store.setItem(key,
|
|
74
|
+
store.setItem(key, value)
|
|
76
75
|
},
|
|
77
76
|
|
|
78
77
|
removeItem(key) {
|