@elu-labs/analytics-browser 1.410.0

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.
@@ -0,0 +1,122 @@
1
+ /** Exact declared source configuration; source key/token inference across sites is forbidden. */
2
+ interface LegacyStorageOptions {
3
+ readonly sourceArtifactSha256: string;
4
+ readonly token: string;
5
+ readonly persistence: 'localStorage' | 'cookie' | 'localStorage+cookie';
6
+ readonly persistence_name?: string;
7
+ readonly consent_persistence_name?: string;
8
+ readonly opt_out_capturing_cookie_prefix?: string;
9
+ readonly prefer_cookie_on_conflict: boolean;
10
+ readonly respect_dnt: boolean;
11
+ readonly opt_out_capturing_by_default: boolean;
12
+ }
13
+
14
+ type V1JsonPrimitive = string | number | boolean | null;
15
+ type V1JsonValue = V1JsonPrimitive | V1JsonObject | readonly V1JsonValue[];
16
+ interface V1JsonObject {
17
+ readonly [key: string]: V1JsonValue;
18
+ }
19
+
20
+ /** Page-lifetime heap and main-thread sampling. Disabled unless enabled locally or remotely. */
21
+ interface PerformanceCaptureConfig {
22
+ readonly memory?: boolean;
23
+ readonly long_tasks?: boolean;
24
+ /** Milliseconds between visible-page samples. Defaults to 30,000; minimum 5,000. */
25
+ readonly sample_interval_ms?: number;
26
+ }
27
+ type EluPerformanceCaptureOptions = boolean | Readonly<PerformanceCaptureConfig>;
28
+
29
+ type V1FacadeProperties = Readonly<Record<string, unknown>>;
30
+ interface V1FacadeCaptureOptions {
31
+ readonly $set?: V1FacadeProperties;
32
+ readonly $set_once?: V1FacadeProperties;
33
+ /** Explicit event time; must not precede persisted activity or the call is dropped. */
34
+ readonly timestamp?: Date;
35
+ }
36
+ interface V1FacadeFlagOptions {
37
+ /** Report `$feature_flag_called` for this read; defaults to true. */
38
+ readonly send_event?: boolean;
39
+ /** Return only values received from the flag endpoint during this owner's lifetime. */
40
+ readonly fresh?: boolean;
41
+ }
42
+ interface V1FacadeIsFeatureEnabledOptions extends V1FacadeFlagOptions {
43
+ readonly defaultValue?: boolean;
44
+ }
45
+ interface V1FacadeFlagResult {
46
+ readonly key: string;
47
+ readonly enabled: boolean;
48
+ readonly variant: string | undefined;
49
+ readonly payload: V1JsonValue | undefined;
50
+ }
51
+ type V1FacadeFlagVariant = string | boolean;
52
+ type V1FacadeFlagsCallback = (flags: readonly string[], variants: Readonly<Record<string, V1FacadeFlagVariant>>, context?: Readonly<{
53
+ errorsLoading?: boolean;
54
+ }>) => void;
55
+ interface V1FacadeOptInOptions {
56
+ /** Event name for the opt-in capture; `null` or `false` captures nothing. */
57
+ readonly captureEventName?: string | null | false;
58
+ readonly captureProperties?: V1FacadeProperties;
59
+ }
60
+ interface V1FacadeFeatureFlags {
61
+ readonly hasLoadedFlags: boolean;
62
+ getFlags(): readonly string[];
63
+ getFlagVariants(): Readonly<Record<string, V1FacadeFlagVariant>>;
64
+ getFlagPayloads(): Readonly<Record<string, V1JsonValue>>;
65
+ getFeatureFlag(key: string, options?: V1FacadeFlagOptions): V1FacadeFlagVariant | undefined;
66
+ getFeatureFlagPayload(key: string): V1JsonValue | undefined;
67
+ getFeatureFlagResult(key: string, options?: V1FacadeFlagOptions): V1FacadeFlagResult | undefined;
68
+ isFeatureEnabled(key: string, options?: V1FacadeIsFeatureEnabledOptions): boolean | undefined;
69
+ reloadFeatureFlags(): void;
70
+ onFeatureFlags(callback: V1FacadeFlagsCallback): () => void;
71
+ }
72
+
73
+ /** The frozen customer API shared by the direct package client and window.elu. */
74
+ interface EluClient {
75
+ identify(distinctId?: string, propertiesToSet?: V1FacadeProperties, propertiesToSetOnce?: V1FacadeProperties): void;
76
+ capture(eventName: string, properties?: V1FacadeProperties | null, options?: V1FacadeCaptureOptions): undefined;
77
+ reset(resetDeviceId?: boolean): void;
78
+ alias(alias: string, original?: string): undefined;
79
+ get_distinct_id(): string | undefined;
80
+ setPersonProperties(propertiesToSet?: V1FacadeProperties, propertiesToSetOnce?: V1FacadeProperties): void;
81
+ captureException(error: unknown, additionalProperties?: V1FacadeProperties): undefined;
82
+ register(properties: V1FacadeProperties, days?: number): void;
83
+ register_once(properties: V1FacadeProperties, defaultValue?: unknown, days?: number): void;
84
+ unregister(property: string): void;
85
+ getFeatureFlag(key: string, options?: V1FacadeFlagOptions): V1FacadeFlagVariant | undefined;
86
+ getFeatureFlagPayload(key: string): V1JsonValue | undefined;
87
+ getFeatureFlagResult(key: string, options?: V1FacadeFlagOptions): V1FacadeFlagResult | undefined;
88
+ isFeatureEnabled(key: string, options?: V1FacadeIsFeatureEnabledOptions): boolean | undefined;
89
+ reloadFeatureFlags(): void;
90
+ onFeatureFlags(callback: V1FacadeFlagsCallback): () => void;
91
+ setPersonPropertiesForFlags(properties: V1FacadeProperties, reloadFeatureFlags?: boolean): void;
92
+ resetPersonPropertiesForFlags(reloadFeatureFlags?: boolean): void;
93
+ setGroupPropertiesForFlags(properties: Readonly<Record<string, V1FacadeProperties>>, reloadFeatureFlags?: boolean): void;
94
+ resetGroupPropertiesForFlags(groupType?: string): void;
95
+ group(groupType: string, groupKey: string, groupPropertiesToSet?: V1FacadeProperties): void;
96
+ resetGroups(): void;
97
+ getGroups(): Readonly<Record<string, string>>;
98
+ opt_in_capturing(options?: V1FacadeOptInOptions): void;
99
+ opt_out_capturing(): void;
100
+ readonly featureFlags: V1FacadeFeatureFlags;
101
+ }
102
+
103
+ type EluPageviewMode = false | true | 'history_change';
104
+
105
+ /** Optional package initialization only; the frozen window.elu method surface is unchanged. */
106
+ interface EluInitializationOptions {
107
+ readonly legacy_storage?: LegacyStorageOptions;
108
+ readonly capture_pageview?: EluPageviewMode;
109
+ readonly autocapture?: boolean;
110
+ readonly capture_exceptions?: boolean;
111
+ readonly capture_performance?: EluPerformanceCaptureOptions;
112
+ readonly loaded?: (client: EluClient) => unknown;
113
+ }
114
+
115
+ /**
116
+ * Creates the direct package client with the same methods and startup buffering as the loader.
117
+ * Importing the module performs no setup; call this once per site key in a browser.
118
+ */
119
+ declare const createEluClient: (siteKey: string, options?: EluInitializationOptions) => EluClient;
120
+
121
+ export { createEluClient };
122
+ export type { EluClient };