@armco/analytics 0.3.3 → 0.3.5
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/core/analytics.js +14 -13
- package/core/types.d.ts +1 -0
- package/index.js +21 -21
- package/package.json +1 -1
- package/plugins/auto-track/click.js +2 -2
- package/plugins/auto-track/error.js +2 -2
- package/plugins/auto-track/form.js +2 -2
- package/plugins/auto-track/page.js +2 -2
- package/plugins/enrichment/session.js +2 -2
- package/plugins/enrichment/user.js +3 -3
- package/plugins/node/http-request-tracking.js +1 -1
- package/storage/cookie-storage.js +2 -2
- package/storage/hybrid-storage.js +4 -4
- package/storage/local-storage.js +2 -2
- package/storage/memory-storage.js +1 -1
- package/transport/beacon-transport.js +2 -2
- package/transport/fetch-transport.js +2 -2
- package/utils/config-loader.js +2 -2
- package/utils/region.js +2 -2
- package/utils/validation.js +1 -1
package/core/analytics.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from "uuid";
|
|
2
|
-
import { ConfigurationError, InitializationError } from "./errors";
|
|
3
|
-
import { HybridStorage } from "../storage/hybrid-storage";
|
|
4
|
-
import { MemoryStorage } from "../storage/memory-storage";
|
|
5
|
-
import { FetchTransport } from "../transport/fetch-transport";
|
|
6
|
-
import { BeaconTransport } from "../transport/beacon-transport";
|
|
7
|
-
import { SessionPlugin } from "../plugins/enrichment/session";
|
|
8
|
-
import { UserPlugin } from "../plugins/enrichment/user";
|
|
9
|
-
import { validateConfig, sanitizeEventData } from "../utils/validation";
|
|
10
|
-
import { createLogger } from "../utils/logging";
|
|
11
|
-
import { getEnvironmentType, isDoNotTrackEnabled, getTimestamp, deepMerge, } from "../utils/helpers";
|
|
12
|
-
import {
|
|
13
|
-
import { resolveEndpoint, detectEnvironment } from "../utils/config-loader";
|
|
2
|
+
import { ConfigurationError, InitializationError } from "./errors.js";
|
|
3
|
+
import { HybridStorage } from "../storage/hybrid-storage.js";
|
|
4
|
+
import { MemoryStorage } from "../storage/memory-storage.js";
|
|
5
|
+
import { FetchTransport } from "../transport/fetch-transport.js";
|
|
6
|
+
import { BeaconTransport } from "../transport/beacon-transport.js";
|
|
7
|
+
import { SessionPlugin } from "../plugins/enrichment/session.js";
|
|
8
|
+
import { UserPlugin } from "../plugins/enrichment/user.js";
|
|
9
|
+
import { validateConfig, sanitizeEventData } from "../utils/validation.js";
|
|
10
|
+
import { createLogger } from "../utils/logging.js";
|
|
11
|
+
import { getEnvironmentType, isDoNotTrackEnabled, getTimestamp, deepMerge, } from "../utils/helpers.js";
|
|
12
|
+
import { getRegionFallback } from "../utils/region.js";
|
|
13
|
+
import { resolveEndpoint, detectEnvironment } from "../utils/config-loader.js";
|
|
14
14
|
export class AnalyticsBuilder {
|
|
15
15
|
constructor() {
|
|
16
16
|
this.config = {};
|
|
@@ -198,7 +198,8 @@ export class Analytics {
|
|
|
198
198
|
eventType,
|
|
199
199
|
timestamp: getTimestamp(),
|
|
200
200
|
eventId: uuidv4(),
|
|
201
|
-
|
|
201
|
+
region: getRegionFallback(),
|
|
202
|
+
data: sanitizeEventData(data || {}),
|
|
202
203
|
};
|
|
203
204
|
for (const plugin of this.plugins) {
|
|
204
205
|
if (plugin.processEvent) {
|
package/core/types.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export { Analytics, AnalyticsBuilder } from "./core/analytics";
|
|
2
|
-
export { AnalyticsError, ConfigurationError, ValidationError, NetworkError, StorageError, PluginError, InitializationError, } from "./core/errors";
|
|
3
|
-
export { CookieStorage } from "./storage/cookie-storage";
|
|
4
|
-
export { LocalStorage } from "./storage/local-storage";
|
|
5
|
-
export { HybridStorage } from "./storage/hybrid-storage";
|
|
6
|
-
export { MemoryStorage } from "./storage/memory-storage";
|
|
7
|
-
export { FetchTransport } from "./transport/fetch-transport";
|
|
8
|
-
export { BeaconTransport } from "./transport/beacon-transport";
|
|
9
|
-
export { SessionPlugin } from "./plugins/enrichment/session";
|
|
10
|
-
export { UserPlugin } from "./plugins/enrichment/user";
|
|
11
|
-
export { ClickTrackingPlugin } from "./plugins/auto-track/click";
|
|
12
|
-
export { PageTrackingPlugin } from "./plugins/auto-track/page";
|
|
13
|
-
export { FormTrackingPlugin } from "./plugins/auto-track/form";
|
|
14
|
-
export { ErrorTrackingPlugin } from "./plugins/auto-track/error";
|
|
15
|
-
export { HTTPRequestTrackingPlugin } from "./plugins/node/http-request-tracking";
|
|
16
|
-
export { validateConfig, validateUser, validatePageView, validateClickEvent, validateFormEvent, validateErrorEvent, sanitizeEventData, } from "./utils/validation";
|
|
17
|
-
export { Logger, getLogger, createLogger } from "./utils/logging";
|
|
18
|
-
export { generateId, getEnvironmentType, getEnvironment, isDoNotTrackEnabled, isBrowser, areCookiesAvailable, isLocalStorageAvailable, debounce, throttle, deepClone, deepMerge, } from "./utils/helpers";
|
|
19
|
-
export { loadConfigFromFile, loadConfig, detectEnvironment, checkEndpointHealth, resolveEndpoint } from "./utils/config-loader";
|
|
20
|
-
export { getRegionFallback, ensureRegion } from "./utils/region";
|
|
21
|
-
import { AnalyticsBuilder as Builder } from "./core/analytics";
|
|
1
|
+
export { Analytics, AnalyticsBuilder } from "./core/analytics.js";
|
|
2
|
+
export { AnalyticsError, ConfigurationError, ValidationError, NetworkError, StorageError, PluginError, InitializationError, } from "./core/errors.js";
|
|
3
|
+
export { CookieStorage } from "./storage/cookie-storage.js";
|
|
4
|
+
export { LocalStorage } from "./storage/local-storage.js";
|
|
5
|
+
export { HybridStorage } from "./storage/hybrid-storage.js";
|
|
6
|
+
export { MemoryStorage } from "./storage/memory-storage.js";
|
|
7
|
+
export { FetchTransport } from "./transport/fetch-transport.js";
|
|
8
|
+
export { BeaconTransport } from "./transport/beacon-transport.js";
|
|
9
|
+
export { SessionPlugin } from "./plugins/enrichment/session.js";
|
|
10
|
+
export { UserPlugin } from "./plugins/enrichment/user.js";
|
|
11
|
+
export { ClickTrackingPlugin } from "./plugins/auto-track/click.js";
|
|
12
|
+
export { PageTrackingPlugin } from "./plugins/auto-track/page.js";
|
|
13
|
+
export { FormTrackingPlugin } from "./plugins/auto-track/form.js";
|
|
14
|
+
export { ErrorTrackingPlugin } from "./plugins/auto-track/error.js";
|
|
15
|
+
export { HTTPRequestTrackingPlugin } from "./plugins/node/http-request-tracking.js";
|
|
16
|
+
export { validateConfig, validateUser, validatePageView, validateClickEvent, validateFormEvent, validateErrorEvent, sanitizeEventData, } from "./utils/validation.js";
|
|
17
|
+
export { Logger, getLogger, createLogger } from "./utils/logging.js";
|
|
18
|
+
export { generateId, getEnvironmentType, getEnvironment, isDoNotTrackEnabled, isBrowser, areCookiesAvailable, isLocalStorageAvailable, debounce, throttle, deepClone, deepMerge, } from "./utils/helpers.js";
|
|
19
|
+
export { loadConfigFromFile, loadConfig, detectEnvironment, checkEndpointHealth, resolveEndpoint } from "./utils/config-loader.js";
|
|
20
|
+
export { getRegionFallback, ensureRegion } from "./utils/region.js";
|
|
21
|
+
import { AnalyticsBuilder as Builder } from "./core/analytics.js";
|
|
22
22
|
export function createAnalytics() {
|
|
23
23
|
return new Builder();
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isBrowser } from "../../utils/helpers";
|
|
2
|
-
import { getLogger } from "../../utils/logging";
|
|
1
|
+
import { isBrowser } from "../../utils/helpers.js";
|
|
2
|
+
import { getLogger } from "../../utils/logging.js";
|
|
3
3
|
export class ErrorTrackingPlugin {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.name = "ErrorTrackingPlugin";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isBrowser } from "../../utils/helpers";
|
|
2
|
-
import { getLogger } from "../../utils/logging";
|
|
1
|
+
import { isBrowser } from "../../utils/helpers.js";
|
|
2
|
+
import { getLogger } from "../../utils/logging.js";
|
|
3
3
|
export class FormTrackingPlugin {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.name = "FormTrackingPlugin";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isBrowser } from "../../utils/helpers";
|
|
2
|
-
import { getLogger } from "../../utils/logging";
|
|
1
|
+
import { isBrowser } from "../../utils/helpers.js";
|
|
2
|
+
import { getLogger } from "../../utils/logging.js";
|
|
3
3
|
export class PageTrackingPlugin {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.name = "PageTrackingPlugin";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { generateId } from "../../utils/helpers";
|
|
2
|
-
import { getLogger } from "../../utils/logging";
|
|
1
|
+
import { generateId } from "../../utils/helpers.js";
|
|
2
|
+
import { getLogger } from "../../utils/logging.js";
|
|
3
3
|
const SESSION_KEY = "ar_session_id";
|
|
4
4
|
const TAB_KEY = "ar_tab_id";
|
|
5
5
|
const SESSION_EXPIRATION_MINUTES = 30;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { generateId, getEnvironmentType } from "../../utils/helpers";
|
|
2
|
-
import { validateUser } from "../../utils/validation";
|
|
3
|
-
import { getLogger } from "../../utils/logging";
|
|
1
|
+
import { generateId, getEnvironmentType } from "../../utils/helpers.js";
|
|
2
|
+
import { validateUser } from "../../utils/validation.js";
|
|
3
|
+
import { getLogger } from "../../utils/logging.js";
|
|
4
4
|
const USER_KEY = "ar_user";
|
|
5
5
|
const ANONYMOUS_ID_KEY = "ar_anonymous_id";
|
|
6
6
|
export class UserPlugin {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Cookies from "js-cookie";
|
|
2
|
-
import { StorageError } from "../core/errors";
|
|
3
|
-
import { getLogger } from "../utils/logging";
|
|
2
|
+
import { StorageError } from "../core/errors.js";
|
|
3
|
+
import { getLogger } from "../utils/logging.js";
|
|
4
4
|
export class CookieStorage {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.logger = getLogger();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CookieStorage } from "./cookie-storage";
|
|
2
|
-
import { LocalStorage } from "./local-storage";
|
|
3
|
-
import { areCookiesAvailable, isLocalStorageAvailable } from "../utils/helpers";
|
|
4
|
-
import { getLogger } from "../utils/logging";
|
|
1
|
+
import { CookieStorage } from "./cookie-storage.js";
|
|
2
|
+
import { LocalStorage } from "./local-storage.js";
|
|
3
|
+
import { areCookiesAvailable, isLocalStorageAvailable } from "../utils/helpers.js";
|
|
4
|
+
import { getLogger } from "../utils/logging.js";
|
|
5
5
|
export class HybridStorage {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.primary = null;
|
package/storage/local-storage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StorageError } from "../core/errors";
|
|
2
|
-
import { getLogger } from "../utils/logging";
|
|
1
|
+
import { StorageError } from "../core/errors.js";
|
|
2
|
+
import { getLogger } from "../utils/logging.js";
|
|
3
3
|
export class LocalStorage {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.logger = getLogger();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NetworkError } from "../core/errors";
|
|
2
|
-
import { getLogger } from "../utils/logging";
|
|
1
|
+
import { NetworkError } from "../core/errors.js";
|
|
2
|
+
import { getLogger } from "../utils/logging.js";
|
|
3
3
|
export class BeaconTransport {
|
|
4
4
|
constructor(options = {}) {
|
|
5
5
|
this.logger = getLogger();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NetworkError } from "../core/errors";
|
|
2
|
-
import { getLogger } from "../utils/logging";
|
|
1
|
+
import { NetworkError } from "../core/errors.js";
|
|
2
|
+
import { getLogger } from "../utils/logging.js";
|
|
3
3
|
export class FetchTransport {
|
|
4
4
|
constructor(options = {}) {
|
|
5
5
|
this.logger = getLogger();
|
package/utils/config-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getEnvironmentType } from "./helpers";
|
|
2
|
-
import { getLogger } from "./logging";
|
|
1
|
+
import { getEnvironmentType } from "./helpers.js";
|
|
2
|
+
import { getLogger } from "./logging.js";
|
|
3
3
|
const CONFIG_FILE_NAME = "analyticsrc";
|
|
4
4
|
const DEFAULT_FALLBACK_ENDPOINT = "http://localhost:5001/events/add";
|
|
5
5
|
const logger = getLogger();
|
package/utils/region.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getEnvironmentType } from "./helpers";
|
|
2
|
-
import { detectEnvironment } from "./config-loader";
|
|
1
|
+
import { getEnvironmentType } from "./helpers.js";
|
|
2
|
+
import { detectEnvironment } from "./config-loader.js";
|
|
3
3
|
export function getRegionFallback() {
|
|
4
4
|
const envType = getEnvironmentType();
|
|
5
5
|
if (envType === "node") {
|
package/utils/validation.js
CHANGED