@ht-sdks/events-sdk-js-browser 1.5.3 → 1.5.4
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/cjs/core/analytics/index.js.map +1 -1
- package/dist/cjs/core/arguments-resolver/index.js +1 -1
- package/dist/cjs/core/arguments-resolver/index.js.map +1 -1
- package/dist/cjs/core/stats/remote-metrics.js.map +1 -1
- package/dist/cjs/generated/version.js +1 -1
- package/dist/cjs/lib/priority-queue/persisted.js.map +1 -1
- package/dist/pkg/core/analytics/index.js.map +1 -1
- package/dist/pkg/core/arguments-resolver/index.js +1 -1
- package/dist/pkg/core/arguments-resolver/index.js.map +1 -1
- package/dist/pkg/core/stats/remote-metrics.js.map +1 -1
- package/dist/pkg/generated/version.js +1 -1
- package/dist/pkg/lib/priority-queue/persisted.js.map +1 -1
- package/dist/types/core/analytics/index.d.ts.map +1 -1
- package/dist/types/core/buffer/index.d.ts +1 -1
- package/dist/types/core/stats/remote-metrics.d.ts.map +1 -1
- package/dist/types/core/storage/cookieStorage.d.ts.map +1 -1
- package/dist/types/core/storage/localStorage.d.ts.map +1 -1
- package/dist/types/core/storage/memoryStorage.d.ts.map +1 -1
- package/dist/types/core/storage/types.d.ts +1 -1
- package/dist/types/core/storage/types.d.ts.map +1 -1
- package/dist/types/generated/version.d.ts +1 -1
- package/dist/types/lib/priority-queue/persisted.d.ts.map +1 -1
- package/dist/umd/events.min.js +1 -1
- package/dist/umd/events.min.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/analytics/index.ts +27 -24
- package/src/core/arguments-resolver/index.ts +4 -4
- package/src/core/buffer/index.ts +4 -4
- package/src/core/stats/remote-metrics.ts +8 -5
- package/src/core/storage/cookieStorage.ts +3 -3
- package/src/core/storage/localStorage.ts +3 -3
- package/src/core/storage/memoryStorage.ts +3 -3
- package/src/core/storage/types.ts +1 -1
- package/src/generated/version.ts +1 -1
- package/src/lib/bind-all.ts +1 -1
- package/src/lib/priority-queue/persisted.ts +9 -6
- package/src/test-helpers/browser-storage.ts +1 -1
package/package.json
CHANGED
|
@@ -638,31 +638,34 @@ export class Analytics
|
|
|
638
638
|
console.warn(deprecationWarning)
|
|
639
639
|
const integrations = this.queue.plugins
|
|
640
640
|
.filter((plugin) => plugin.type === 'destination')
|
|
641
|
-
.reduce(
|
|
642
|
-
|
|
643
|
-
.
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
641
|
+
.reduce(
|
|
642
|
+
(acc, plugin) => {
|
|
643
|
+
const name = `${plugin.name
|
|
644
|
+
.toLowerCase()
|
|
645
|
+
.replace('.', '')
|
|
646
|
+
.split(' ')
|
|
647
|
+
.join('-')}Integration`
|
|
648
|
+
|
|
649
|
+
// @ts-expect-error
|
|
650
|
+
const integration = window[name] as
|
|
651
|
+
| (LegacyIntegration & { Integration?: LegacyIntegration })
|
|
652
|
+
| undefined
|
|
653
|
+
|
|
654
|
+
if (!integration) {
|
|
655
|
+
return acc
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
const nested = integration.Integration // hack - Google Analytics function resides in the "Integration" field
|
|
659
|
+
if (nested) {
|
|
660
|
+
acc[plugin.name] = nested
|
|
661
|
+
return acc
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
acc[plugin.name] = integration as LegacyIntegration
|
|
654
665
|
return acc
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
if (nested) {
|
|
659
|
-
acc[plugin.name] = nested
|
|
660
|
-
return acc
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
acc[plugin.name] = integration as LegacyIntegration
|
|
664
|
-
return acc
|
|
665
|
-
}, {} as Record<string, LegacyIntegration>)
|
|
666
|
+
},
|
|
667
|
+
{} as Record<string, LegacyIntegration>
|
|
668
|
+
)
|
|
666
669
|
|
|
667
670
|
return integrations
|
|
668
671
|
}
|
|
@@ -34,10 +34,10 @@ export function resolveArguments(
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const data = isPlainObject(eventName)
|
|
37
|
-
? eventName.properties ?? {}
|
|
37
|
+
? (eventName.properties ?? {})
|
|
38
38
|
: isPlainObject(properties)
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
? properties
|
|
40
|
+
: {}
|
|
41
41
|
|
|
42
42
|
let opts: Options = {}
|
|
43
43
|
if (!isFunction(options)) {
|
|
@@ -66,7 +66,7 @@ export function resolvePageArguments(
|
|
|
66
66
|
string | null,
|
|
67
67
|
EventProperties,
|
|
68
68
|
Options,
|
|
69
|
-
Callback | undefined
|
|
69
|
+
Callback | undefined,
|
|
70
70
|
] {
|
|
71
71
|
let resolvedCategory: string | undefined | null = null
|
|
72
72
|
let resolvedName: string | undefined | null = null
|
package/src/core/buffer/index.ts
CHANGED
|
@@ -106,7 +106,7 @@ export const hasBufferedPageContextAsLastArg = (
|
|
|
106
106
|
* Represents a buffered method call that occurred before initialization.
|
|
107
107
|
*/
|
|
108
108
|
export class PreInitMethodCall<
|
|
109
|
-
MethodName extends PreInitMethodName = PreInitMethodName
|
|
109
|
+
MethodName extends PreInitMethodName = PreInitMethodName,
|
|
110
110
|
> {
|
|
111
111
|
method: MethodName
|
|
112
112
|
args: PreInitMethodParams<MethodName>
|
|
@@ -143,7 +143,7 @@ type ReturnTypeUnwrap<Fn> = Fn extends (...args: any[]) => infer ReturnT
|
|
|
143
143
|
type MethodCallMap = Partial<Record<PreInitMethodName, PreInitMethodCall[]>>
|
|
144
144
|
|
|
145
145
|
type SnippetWindowBufferedMethodCall<
|
|
146
|
-
MethodName extends PreInitMethodName = PreInitMethodName
|
|
146
|
+
MethodName extends PreInitMethodName = PreInitMethodName,
|
|
147
147
|
> = [MethodName, ...PreInitMethodParams<MethodName>]
|
|
148
148
|
|
|
149
149
|
/**
|
|
@@ -290,7 +290,7 @@ export class AnalyticsBuffered
|
|
|
290
290
|
| ((instance: [Analytics, Context]) => T1 | PromiseLike<T1>)
|
|
291
291
|
| null
|
|
292
292
|
| undefined,
|
|
293
|
-
onrejected?: (reason: unknown) => T2 | PromiseLike<T2
|
|
293
|
+
onrejected?: (reason: unknown) => T2 | PromiseLike<T2>,
|
|
294
294
|
]
|
|
295
295
|
) {
|
|
296
296
|
return this._promise.then(...args)
|
|
@@ -301,7 +301,7 @@ export class AnalyticsBuffered
|
|
|
301
301
|
onrejected?:
|
|
302
302
|
| ((reason: any) => TResult | PromiseLike<TResult>)
|
|
303
303
|
| undefined
|
|
304
|
-
| null
|
|
304
|
+
| null,
|
|
305
305
|
]
|
|
306
306
|
) {
|
|
307
307
|
return this._promise.catch(...args)
|
|
@@ -29,11 +29,14 @@ const createRemoteMetric = (
|
|
|
29
29
|
tags: string[],
|
|
30
30
|
versionType: 'web' | 'npm'
|
|
31
31
|
): RemoteMetric => {
|
|
32
|
-
const formattedTags = tags.reduce(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const formattedTags = tags.reduce(
|
|
33
|
+
(acc, t) => {
|
|
34
|
+
const [k, v] = t.split(':')
|
|
35
|
+
acc[k] = v
|
|
36
|
+
return acc
|
|
37
|
+
},
|
|
38
|
+
{} as Record<string, string>
|
|
39
|
+
)
|
|
37
40
|
|
|
38
41
|
return {
|
|
39
42
|
type: 'Counter',
|
|
@@ -15,9 +15,9 @@ export interface CookieOptions {
|
|
|
15
15
|
/**
|
|
16
16
|
* Data storage using browser cookies
|
|
17
17
|
*/
|
|
18
|
-
export class CookieStorage<
|
|
19
|
-
|
|
20
|
-
{
|
|
18
|
+
export class CookieStorage<
|
|
19
|
+
Data extends StorageObject = StorageObject,
|
|
20
|
+
> implements Store<Data> {
|
|
21
21
|
static get defaults(): CookieOptions {
|
|
22
22
|
return {
|
|
23
23
|
maxage: ONE_YEAR,
|
|
@@ -3,9 +3,9 @@ import { StorageObject, Store } from './types'
|
|
|
3
3
|
/**
|
|
4
4
|
* Data storage using browser's localStorage
|
|
5
5
|
*/
|
|
6
|
-
export class LocalStorage<
|
|
7
|
-
|
|
8
|
-
{
|
|
6
|
+
export class LocalStorage<
|
|
7
|
+
Data extends StorageObject = StorageObject,
|
|
8
|
+
> implements Store<Data> {
|
|
9
9
|
private localStorageWarning(key: keyof Data, state: 'full' | 'unavailable') {
|
|
10
10
|
console.warn(`Unable to access ${key}, localStorage may be ${state}`)
|
|
11
11
|
}
|
|
@@ -3,9 +3,9 @@ import { Store, StorageObject } from './types'
|
|
|
3
3
|
/**
|
|
4
4
|
* Data Storage using in memory object
|
|
5
5
|
*/
|
|
6
|
-
export class MemoryStorage<
|
|
7
|
-
|
|
8
|
-
{
|
|
6
|
+
export class MemoryStorage<
|
|
7
|
+
Data extends StorageObject = StorageObject,
|
|
8
|
+
> implements Store<Data> {
|
|
9
9
|
private cache: Record<string, unknown> = {}
|
|
10
10
|
|
|
11
11
|
get<K extends keyof Data>(key: K): Data[K] | null {
|
|
@@ -11,7 +11,7 @@ export const StoreType = {
|
|
|
11
11
|
*
|
|
12
12
|
* Convenience settings for storage systems that AJS includes support for
|
|
13
13
|
*/
|
|
14
|
-
export type StoreType = typeof StoreType[keyof typeof StoreType]
|
|
14
|
+
export type StoreType = (typeof StoreType)[keyof typeof StoreType]
|
|
15
15
|
|
|
16
16
|
export type StorageObject = Record<string, unknown>
|
|
17
17
|
|
package/src/generated/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated.
|
|
2
|
-
export const version = '1.5.
|
|
2
|
+
export const version = '1.5.4'
|
package/src/lib/bind-all.ts
CHANGED
|
@@ -27,12 +27,15 @@ function persistItems(key: string, items: Context[]): void {
|
|
|
27
27
|
const existing = persisted(key)
|
|
28
28
|
const all = [...items, ...existing]
|
|
29
29
|
|
|
30
|
-
const merged = all.reduce(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
const merged = all.reduce(
|
|
31
|
+
(acc, item) => {
|
|
32
|
+
return {
|
|
33
|
+
...acc,
|
|
34
|
+
[item.id]: item,
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{} as Record<string, Context>
|
|
38
|
+
)
|
|
36
39
|
|
|
37
40
|
loc.setItem(key, JSON.stringify(Object.values(merged)))
|
|
38
41
|
}
|