@rudderstack/analytics-js 3.0.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +66 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/index.d.ts +358 -0
- package/legacy/cjs/index.js +3881 -0
- package/legacy/esm/index.js +3874 -0
- package/legacy/umd/index.js +3887 -0
- package/modern/cjs/index.js +1728 -0
- package/modern/esm/index.js +1719 -0
- package/modern/umd/index.js +1734 -0
- package/package.json +183 -0
package/CHANGELOG.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
|
+
|
6
|
+
# 3.0.0-beta.1 (2023-07-25)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **analytics-js:** add new flag in errorHandler, add state reset method ([#998](https://github.com/rudderlabs/rudder-sdk-js/issues/998)) ([4c76315](https://github.com/rudderlabs/rudder-sdk-js/commit/4c76315481793cd29ae4dc9b249a0684df2540d4))
|
12
|
+
* **analytics-js:** data residency url detection issue ([#1163](https://github.com/rudderlabs/rudder-sdk-js/issues/1163)) ([4e80937](https://github.com/rudderlabs/rudder-sdk-js/commit/4e8093742935366918de2526eeabdf2b51851f55))
|
13
|
+
* **analytics-js:** fix edge cases & add unit tests for error handler ([068f305](https://github.com/rudderlabs/rudder-sdk-js/commit/068f305a6f401b7b521b2f0b0bdd8124d31c67c0))
|
14
|
+
* **analytics-js:** fix issues with tracking methods overloads ([#1164](https://github.com/rudderlabs/rudder-sdk-js/issues/1164)) ([718f9a9](https://github.com/rudderlabs/rudder-sdk-js/commit/718f9a9bf9e24fa203cfe9cec835528c91ed955f))
|
15
|
+
* **analytics-js:** fix type issues & broken unit tests ([dd198bc](https://github.com/rudderlabs/rudder-sdk-js/commit/dd198bc737f23d666dff15501a530b65c5b674f3))
|
16
|
+
* **analytics-js:** support imports in SSR & reduce shared bundles code ([#1135](https://github.com/rudderlabs/rudder-sdk-js/issues/1135)) ([29d1d75](https://github.com/rudderlabs/rudder-sdk-js/commit/29d1d75325c732d62b9926d3848c0b1b2e566c85))
|
17
|
+
* auto capture anonymous id ([#1160](https://github.com/rudderlabs/rudder-sdk-js/issues/1160)) ([2947ead](https://github.com/rudderlabs/rudder-sdk-js/commit/2947ead0b431ea608f510939f1d68ca1bae58095))
|
18
|
+
* auto detection of destSDKBaseUrl ([#1144](https://github.com/rudderlabs/rudder-sdk-js/issues/1144)) ([1d6a1d7](https://github.com/rudderlabs/rudder-sdk-js/commit/1d6a1d7788f03fcd3d0eb101c277737a5f758368))
|
19
|
+
* avoid persisting user id in alias api ([#1057](https://github.com/rudderlabs/rudder-sdk-js/issues/1057)) ([273eb9e](https://github.com/rudderlabs/rudder-sdk-js/commit/273eb9e27fda917f443cd1eff63d74580b612662))
|
20
|
+
* cookie storage options ([#1232](https://github.com/rudderlabs/rudder-sdk-js/issues/1232)) ([23970bc](https://github.com/rudderlabs/rudder-sdk-js/commit/23970bc88965b8a8631f406cd0c47b6bb949e0ea))
|
21
|
+
* issues in rudder event structure ([#1111](https://github.com/rudderlabs/rudder-sdk-js/issues/1111)) ([bed6210](https://github.com/rudderlabs/rudder-sdk-js/commit/bed6210cdc1097f1e3a75e9151cace1a7425401d))
|
22
|
+
* issues post sanity checks, tidy up code structure, add uaCH, npm packaging ([#1132](https://github.com/rudderlabs/rudder-sdk-js/issues/1132)) ([0fa64c1](https://github.com/rudderlabs/rudder-sdk-js/commit/0fa64c1bb277cbd20b0d7c984347e5fe52e4d4fe))
|
23
|
+
* native destinations queue options ([#1209](https://github.com/rudderlabs/rudder-sdk-js/issues/1209)) ([0341fc8](https://github.com/rudderlabs/rudder-sdk-js/commit/0341fc8a35433209a402f497cd92865bcec9f20f))
|
24
|
+
* normalize all error messages ([#1191](https://github.com/rudderlabs/rudder-sdk-js/issues/1191)) ([b45f3f3](https://github.com/rudderlabs/rudder-sdk-js/commit/b45f3f324afd2df6e806a586fe7d281392b03d79))
|
25
|
+
* storage option configuration ([#1217](https://github.com/rudderlabs/rudder-sdk-js/issues/1217)) ([7dc0488](https://github.com/rudderlabs/rudder-sdk-js/commit/7dc048895f7fae0783284dc5351b9a86df8981db))
|
26
|
+
* xhr queue plugin retry mechanism ([#1171](https://github.com/rudderlabs/rudder-sdk-js/issues/1171)) ([6d8d2b9](https://github.com/rudderlabs/rudder-sdk-js/commit/6d8d2b9db554459061995494de0b42c1f35b3bb6))
|
27
|
+
|
28
|
+
|
29
|
+
### Features
|
30
|
+
|
31
|
+
* add application state to bugsnag metadata ([#1168](https://github.com/rudderlabs/rudder-sdk-js/issues/1168)) ([7273e3a](https://github.com/rudderlabs/rudder-sdk-js/commit/7273e3af6683165c3c33265c64db6fb28a3ff5e5))
|
32
|
+
* **analytics-js-plugins:** new beacon queue plugin ([#1173](https://github.com/rudderlabs/rudder-sdk-js/issues/1173)) ([9e4602b](https://github.com/rudderlabs/rudder-sdk-js/commit/9e4602b67c7ce1345023388e09c3701820f71091))
|
33
|
+
* **analytics-js:** add application lifecycle and analytics class ([71ceed5](https://github.com/rudderlabs/rudder-sdk-js/commit/71ceed5276a9a4da83df4654b76b1d012e72f766))
|
34
|
+
* **analytics-js:** add external source loader, fix async tests, cleanup ([8ba7bdf](https://github.com/rudderlabs/rudder-sdk-js/commit/8ba7bdf260a6771bf4cfc154b9f84ab61846a622))
|
35
|
+
* **analytics-js:** add global state initial structure ([f636227](https://github.com/rudderlabs/rudder-sdk-js/commit/f636227e0094a4a3f0bfdc17d52c4731ab17e20c))
|
36
|
+
* **analytics-js:** add globaly exposed analytics instances ([03931a6](https://github.com/rudderlabs/rudder-sdk-js/commit/03931a67c51a62b41db1398a28f1e82d48b9a8a5))
|
37
|
+
* **analytics-js:** add HttpClient, Logger & ErrorHandler services ([236f951](https://github.com/rudderlabs/rudder-sdk-js/commit/236f95198d8f2ae4a029339074fa063679fbaa38))
|
38
|
+
* **analytics-js:** add more state slices ([#973](https://github.com/rudderlabs/rudder-sdk-js/issues/973)) ([7c1e627](https://github.com/rudderlabs/rudder-sdk-js/commit/7c1e6275ad9eeec2ccdd4a100b085437f78a2603))
|
39
|
+
* **analytics-js:** add online status detection in capabilities mngr ([a4702da](https://github.com/rudderlabs/rudder-sdk-js/commit/a4702dab9718f66cacc8aa58add41840f1853a23))
|
40
|
+
* **analytics-js:** add storage manager,fix issue with localhost cookies ([9a5bff7](https://github.com/rudderlabs/rudder-sdk-js/commit/9a5bff7ebbf76da9cbb768c401362b57da67d37b))
|
41
|
+
* **analytics-js:** expose global analytics instances & preload buffer ([203919f](https://github.com/rudderlabs/rudder-sdk-js/commit/203919fd8efd263afb41732cb912898d50ca5781))
|
42
|
+
* **analytics-js:** migrated js-plugin dependency to source code ([4be78ab](https://github.com/rudderlabs/rudder-sdk-js/commit/4be78abcddbc11bae85c5d5f2718a46a4b0119db))
|
43
|
+
* bugsnag plugin ([#1159](https://github.com/rudderlabs/rudder-sdk-js/issues/1159)) ([c59cfd9](https://github.com/rudderlabs/rudder-sdk-js/commit/c59cfd9e6e4160e4759695dddf527bfc512f119e))
|
44
|
+
* config manager ([#990](https://github.com/rudderlabs/rudder-sdk-js/issues/990)) ([cc48a29](https://github.com/rudderlabs/rudder-sdk-js/commit/cc48a29b414ffbbbba10980c73a3fa78c6fd5e7c))
|
45
|
+
* consent manager plugin ([#1096](https://github.com/rudderlabs/rudder-sdk-js/issues/1096)) ([7af1cce](https://github.com/rudderlabs/rudder-sdk-js/commit/7af1ccec03997cd55ce70aa1e4afba05b22da264))
|
46
|
+
* create bundling and packaging for v3 ([#1098](https://github.com/rudderlabs/rudder-sdk-js/issues/1098)) ([3f14bbe](https://github.com/rudderlabs/rudder-sdk-js/commit/3f14bbe8d9d6af62d4366873c59c9c21df704675))
|
47
|
+
* dataplane events queue ([#1088](https://github.com/rudderlabs/rudder-sdk-js/issues/1088)) ([17f45bc](https://github.com/rudderlabs/rudder-sdk-js/commit/17f45bc1a57f37edee56808aa1f337deef208528))
|
48
|
+
* events repository ([#1063](https://github.com/rudderlabs/rudder-sdk-js/issues/1063)) ([8a92dcb](https://github.com/rudderlabs/rudder-sdk-js/commit/8a92dcb14311b3537d391375fc0ed34433b5afe7))
|
49
|
+
* events service ([#1000](https://github.com/rudderlabs/rudder-sdk-js/issues/1000)) ([7bb3025](https://github.com/rudderlabs/rudder-sdk-js/commit/7bb30251f4e5bfb169e69aca377e7e57df8ac58a))
|
50
|
+
* hybrid mode ([#1147](https://github.com/rudderlabs/rudder-sdk-js/issues/1147)) ([e623214](https://github.com/rudderlabs/rudder-sdk-js/commit/e6232145818032aa6e33130511b1e1d41d4a293b))
|
51
|
+
* improve adblocker detection ([#1176](https://github.com/rudderlabs/rudder-sdk-js/issues/1176)) ([6fb57ef](https://github.com/rudderlabs/rudder-sdk-js/commit/6fb57ef40c4ea73cb9d1c01844458702e2819ebc))
|
52
|
+
* ketch consent manager plugin ([#1210](https://github.com/rudderlabs/rudder-sdk-js/issues/1210)) ([75d4588](https://github.com/rudderlabs/rudder-sdk-js/commit/75d4588481e3fe86bad804162663f332ce2f895d))
|
53
|
+
* log messages language dictionary ([#1206](https://github.com/rudderlabs/rudder-sdk-js/issues/1206)) ([77a867e](https://github.com/rudderlabs/rudder-sdk-js/commit/77a867e9c109122a9223293cb5af25f1ccb48ecc))
|
54
|
+
* native destinations events queue ([#1127](https://github.com/rudderlabs/rudder-sdk-js/issues/1127)) ([ead338c](https://github.com/rudderlabs/rudder-sdk-js/commit/ead338cb5a45c7d109428259459892ff896a0ccb))
|
55
|
+
* plugins manager & capabilities manager ([#1062](https://github.com/rudderlabs/rudder-sdk-js/issues/1062)) ([9d03bbd](https://github.com/rudderlabs/rudder-sdk-js/commit/9d03bbdea3bf2658f56580aa9bb8df2af9baf9a0))
|
56
|
+
* remove crypto based encryption for persistent data ([#1197](https://github.com/rudderlabs/rudder-sdk-js/issues/1197)) ([187b701](https://github.com/rudderlabs/rudder-sdk-js/commit/187b7016e75f092c54698fe7fe3652656943e35f))
|
57
|
+
* rename sdk file name ([#1190](https://github.com/rudderlabs/rudder-sdk-js/issues/1190)) ([0167e38](https://github.com/rudderlabs/rudder-sdk-js/commit/0167e384a05e1fa33b3da3b940f3952ee06ef21e))
|
58
|
+
* session tracking ([#1061](https://github.com/rudderlabs/rudder-sdk-js/issues/1061)) ([e46e98c](https://github.com/rudderlabs/rudder-sdk-js/commit/e46e98c5211aaccb325e4c1109d8c26e4c41394d))
|
59
|
+
* storage service improvements ([#1233](https://github.com/rudderlabs/rudder-sdk-js/issues/1233)) ([441fd60](https://github.com/rudderlabs/rudder-sdk-js/commit/441fd600c2e72e990518e45c972e43ce33567e7f))
|
60
|
+
* user session manager ([#1013](https://github.com/rudderlabs/rudder-sdk-js/issues/1013)) ([450cce0](https://github.com/rudderlabs/rudder-sdk-js/commit/450cce03bf09a5c3f3d93b6a6083173ddb6309d7))
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
# Change Log
|
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 RudderStack
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/index.d.ts
ADDED
@@ -0,0 +1,358 @@
|
|
1
|
+
import { AnonymousIdOptions, LoadOptions } from '@rudderstack/analytics-js-common/types/LoadOptions';
|
2
|
+
export { AnonymousIdOptions, BeaconQueueOpts, CookieSameSite, DestinationsQueueOpts, LoadOptions, QueueOpts, SessionOpts, UaChTrackLevel } from '@rudderstack/analytics-js-common/types/LoadOptions';
|
3
|
+
import { APIEvent, ApiCallback, ApiOptions } from '@rudderstack/analytics-js-common/types/EventApi';
|
4
|
+
export { ApiCallback, ApiOptions } from '@rudderstack/analytics-js-common/types/EventApi';
|
5
|
+
import { ApiObject } from '@rudderstack/analytics-js-common/types/ApiObject';
|
6
|
+
export { ApiObject } from '@rudderstack/analytics-js-common/types/ApiObject';
|
7
|
+
export { IntegrationOpts } from '@rudderstack/analytics-js-common/types/Integration';
|
8
|
+
export { ResidencyServerRegion } from '@rudderstack/analytics-js-common/types/DataResidency';
|
9
|
+
import { ILogger } from '@rudderstack/analytics-js-common/types/Logger';
|
10
|
+
export { LogLevel } from '@rudderstack/analytics-js-common/types/Logger';
|
11
|
+
import { IPluginsManager } from '@rudderstack/analytics-js-common/types/PluginsManager';
|
12
|
+
export { PluginName } from '@rudderstack/analytics-js-common/types/PluginsManager';
|
13
|
+
import { IRudderAnalytics } from '@rudderstack/analytics-js-common/types/IRudderAnalytics';
|
14
|
+
import { Nullable } from '@rudderstack/analytics-js-common/types/Nullable';
|
15
|
+
import { IHttpClient } from '@rudderstack/analytics-js-common/types/HttpClient';
|
16
|
+
import { IErrorHandler } from '@rudderstack/analytics-js-common/types/ErrorHandler';
|
17
|
+
import { IExternalSrcLoader } from '@rudderstack/analytics-js-common/services/ExternalSrcLoader/types';
|
18
|
+
import { IStore, IStorage, IStoreConfig, IStoreManager } from '@rudderstack/analytics-js-common/types/Store';
|
19
|
+
import { LifecycleStatus } from '@rudderstack/analytics-js-common/types/ApplicationLifecycle';
|
20
|
+
import { PageCallOptions, TrackCallOptions, IdentifyCallOptions, AliasCallOptions, GroupCallOptions } from '@rudderstack/analytics-js-common/utilities/eventMethodOverloads';
|
21
|
+
import { ApplicationState } from '@rudderstack/analytics-js-common/types/ApplicationState';
|
22
|
+
|
23
|
+
interface ICapabilitiesManager {
|
24
|
+
logger?: ILogger;
|
25
|
+
errorHandler?: IErrorHandler;
|
26
|
+
externalSrcLoader?: IExternalSrcLoader;
|
27
|
+
init(): void;
|
28
|
+
detectBrowserCapabilities(): void;
|
29
|
+
prepareBrowserCapabilities(): void;
|
30
|
+
attachWindowListeners(): void;
|
31
|
+
onReady(): void;
|
32
|
+
}
|
33
|
+
|
34
|
+
interface IEventManager {
|
35
|
+
init(): void;
|
36
|
+
addEvent(event: APIEvent): void;
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Store Implementation with dedicated storage
|
41
|
+
*/
|
42
|
+
declare class Store implements IStore {
|
43
|
+
id: string;
|
44
|
+
name: string;
|
45
|
+
isEncrypted: boolean;
|
46
|
+
validKeys: Record<string, string>;
|
47
|
+
engine: IStorage;
|
48
|
+
originalEngine: IStorage;
|
49
|
+
noKeyValidation?: boolean;
|
50
|
+
noCompoundKey?: boolean;
|
51
|
+
errorHandler?: IErrorHandler;
|
52
|
+
hasErrorHandler: boolean;
|
53
|
+
logger?: ILogger;
|
54
|
+
pluginsManager?: IPluginsManager;
|
55
|
+
constructor(config: IStoreConfig, engine?: IStorage, pluginsManager?: IPluginsManager);
|
56
|
+
/**
|
57
|
+
* Ensure the key is valid and with correct format
|
58
|
+
*/
|
59
|
+
createValidKey(key: string): string | undefined;
|
60
|
+
/**
|
61
|
+
* Switch to inMemoryEngine, bringing any existing data with.
|
62
|
+
*/
|
63
|
+
swapQueueStoreToInMemoryEngine(): void;
|
64
|
+
/**
|
65
|
+
* Set value by key.
|
66
|
+
*/
|
67
|
+
set(key: string, value: any): void;
|
68
|
+
/**
|
69
|
+
* Get by Key.
|
70
|
+
*/
|
71
|
+
get<T = any>(key: string): Nullable<T>;
|
72
|
+
/**
|
73
|
+
* Remove by Key.
|
74
|
+
*/
|
75
|
+
remove(key: string): void;
|
76
|
+
/**
|
77
|
+
* Get original engine
|
78
|
+
*/
|
79
|
+
getOriginalEngine(): IStorage;
|
80
|
+
/**
|
81
|
+
* Decrypt values
|
82
|
+
*/
|
83
|
+
decrypt(value?: Nullable<string>): Nullable<string>;
|
84
|
+
/**
|
85
|
+
* Encrypt value
|
86
|
+
*/
|
87
|
+
encrypt(value: Nullable<any>): string;
|
88
|
+
/**
|
89
|
+
* Extension point to use with encryption plugins
|
90
|
+
*/
|
91
|
+
crypto(value: Nullable<any>, mode: 'encrypt' | 'decrypt'): string;
|
92
|
+
/**
|
93
|
+
* Handle errors
|
94
|
+
*/
|
95
|
+
onError(error: unknown): void;
|
96
|
+
}
|
97
|
+
//# sourceMappingURL=Store.d.ts.map
|
98
|
+
|
99
|
+
interface IUserSessionManager {
|
100
|
+
store?: IStore;
|
101
|
+
init(storage: IStore): void;
|
102
|
+
setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;
|
103
|
+
getAnonymousId(options?: AnonymousIdOptions): string;
|
104
|
+
refreshSession(): void;
|
105
|
+
getGroupId(): Nullable<string>;
|
106
|
+
getUserId(): Nullable<string>;
|
107
|
+
setUserId(userId?: null | string): void;
|
108
|
+
setUserTraits(traits?: Nullable<ApiObject>): void;
|
109
|
+
getUserTraits(): Nullable<ApiObject>;
|
110
|
+
getGroupTraits(): Nullable<ApiObject>;
|
111
|
+
setGroupId(groupId?: Nullable<string>): void;
|
112
|
+
setGroupTraits(traits?: Nullable<ApiObject>): void;
|
113
|
+
reset(resetAnonymousId?: boolean, noNewSessionStart?: boolean): void;
|
114
|
+
start(sessionId?: number): void;
|
115
|
+
end(): void;
|
116
|
+
clearUserSessionStorage(resetAnonymousId?: boolean): void;
|
117
|
+
}
|
118
|
+
|
119
|
+
interface IConfigManager {
|
120
|
+
httpClient: IHttpClient;
|
121
|
+
errorHandler?: IErrorHandler;
|
122
|
+
logger?: ILogger;
|
123
|
+
init: () => void;
|
124
|
+
getConfig: () => void;
|
125
|
+
processConfig: () => void;
|
126
|
+
}
|
127
|
+
|
128
|
+
/**
|
129
|
+
* A buffer queue to serve as a store for any type of data
|
130
|
+
*/
|
131
|
+
declare class BufferQueue<T = any> {
|
132
|
+
items: T[];
|
133
|
+
constructor();
|
134
|
+
enqueue(item: T): void;
|
135
|
+
dequeue(): Nullable<T> | undefined;
|
136
|
+
isEmpty(): boolean;
|
137
|
+
size(): number;
|
138
|
+
clear(): void;
|
139
|
+
}
|
140
|
+
//# sourceMappingURL=BufferQueue.d.ts.map
|
141
|
+
|
142
|
+
type PreloadedEventCall = Array<string | any>;
|
143
|
+
|
144
|
+
interface IAnalytics {
|
145
|
+
preloadBuffer: BufferQueue<PreloadedEventCall>;
|
146
|
+
initialized: boolean;
|
147
|
+
status?: LifecycleStatus;
|
148
|
+
httpClient: IHttpClient;
|
149
|
+
logger: ILogger;
|
150
|
+
errorHandler: IErrorHandler;
|
151
|
+
externalSrcLoader: IExternalSrcLoader;
|
152
|
+
capabilitiesManager: ICapabilitiesManager;
|
153
|
+
storeManager?: IStoreManager;
|
154
|
+
configManager?: IConfigManager;
|
155
|
+
eventManager?: IEventManager;
|
156
|
+
userSessionManager?: IUserSessionManager;
|
157
|
+
pluginsManager?: IPluginsManager;
|
158
|
+
clientDataStore?: Store;
|
159
|
+
/**
|
160
|
+
* Start application lifecycle if not already started
|
161
|
+
*/
|
162
|
+
load(writeKey: string, dataPlaneUrl?: string | Partial<LoadOptions>, loadOptions?: Partial<LoadOptions>): void;
|
163
|
+
/**
|
164
|
+
* Orchestrate the lifecycle of the application phases/status
|
165
|
+
*/
|
166
|
+
startLifecycle(): void;
|
167
|
+
/**
|
168
|
+
* Load browser polyfill if required
|
169
|
+
*/
|
170
|
+
prepareBrowserCapabilities(): void;
|
171
|
+
/**
|
172
|
+
* Enqueue in buffer the events that were triggered pre SDK initialization
|
173
|
+
*/
|
174
|
+
enqueuePreloadBufferEvents(bufferedEvents: PreloadedEventCall[]): void;
|
175
|
+
/**
|
176
|
+
* Start the process of consuming the buffered events that were triggered pre SDK initialization
|
177
|
+
*/
|
178
|
+
processDataInPreloadBuffer(): void;
|
179
|
+
/**
|
180
|
+
* Assign instances for the internal services
|
181
|
+
*/
|
182
|
+
prepareInternalServices(): void;
|
183
|
+
/**
|
184
|
+
* Load configuration
|
185
|
+
*/
|
186
|
+
loadConfig(): void;
|
187
|
+
/**
|
188
|
+
* Initialize the storage and event queue
|
189
|
+
*/
|
190
|
+
init(): void;
|
191
|
+
/**
|
192
|
+
* Load plugins
|
193
|
+
*/
|
194
|
+
loadPlugins(): void;
|
195
|
+
/**
|
196
|
+
* Trigger onLoaded callback if any is provided in config
|
197
|
+
*/
|
198
|
+
onLoaded(): void;
|
199
|
+
/**
|
200
|
+
* Consume preloaded events buffer
|
201
|
+
*/
|
202
|
+
processBufferedEvents(): void;
|
203
|
+
/**
|
204
|
+
* Load device mode integrations
|
205
|
+
*/
|
206
|
+
loadIntegrations(): void;
|
207
|
+
/**
|
208
|
+
* Invoke the ready callbacks if any exist
|
209
|
+
*/
|
210
|
+
onReady(): void;
|
211
|
+
/**
|
212
|
+
* To register a callback for SDK ready state
|
213
|
+
*/
|
214
|
+
ready(callback: ApiCallback): void;
|
215
|
+
/**
|
216
|
+
* To record a page view event
|
217
|
+
*/
|
218
|
+
page(pageOptions: PageCallOptions): void;
|
219
|
+
/**
|
220
|
+
* To record a user track event
|
221
|
+
*/
|
222
|
+
track(trackCallOptions: TrackCallOptions): void;
|
223
|
+
/**
|
224
|
+
* To record a user identification event
|
225
|
+
*/
|
226
|
+
identify(identifyCallOptions: IdentifyCallOptions): void;
|
227
|
+
/**
|
228
|
+
* To record a user alias event
|
229
|
+
*/
|
230
|
+
alias(aliasCallOptions: AliasCallOptions): void;
|
231
|
+
/**
|
232
|
+
* To record a user group event
|
233
|
+
*/
|
234
|
+
group(groupCallOptions: GroupCallOptions): void;
|
235
|
+
/**
|
236
|
+
* To get anonymousId set in the SDK
|
237
|
+
*/
|
238
|
+
getAnonymousId(options?: AnonymousIdOptions): string | undefined;
|
239
|
+
/**
|
240
|
+
* To set anonymousId
|
241
|
+
*/
|
242
|
+
setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;
|
243
|
+
/**
|
244
|
+
* Clear user information, optionally anonymousId as well
|
245
|
+
*/
|
246
|
+
reset(resetAnonymousId?: boolean): void;
|
247
|
+
/**
|
248
|
+
* To get userId set in the SDK
|
249
|
+
*/
|
250
|
+
getUserId(): Nullable<string> | undefined;
|
251
|
+
/**
|
252
|
+
* To get user traits set in the SDK
|
253
|
+
*/
|
254
|
+
getUserTraits(): Nullable<ApiObject> | undefined;
|
255
|
+
/**
|
256
|
+
* To get groupId set in the SDK
|
257
|
+
*/
|
258
|
+
getGroupId(): Nullable<string> | undefined;
|
259
|
+
/**
|
260
|
+
* To get group traits set in the SDK
|
261
|
+
*/
|
262
|
+
getGroupTraits(): Nullable<ApiObject> | undefined;
|
263
|
+
/**
|
264
|
+
* To manually start user session in the SDK
|
265
|
+
*/
|
266
|
+
startSession(sessionId?: number): void;
|
267
|
+
/**
|
268
|
+
* To manually end user session in the SDK
|
269
|
+
*/
|
270
|
+
endSession(): void;
|
271
|
+
/**
|
272
|
+
* To fetch the current sessionId
|
273
|
+
*/
|
274
|
+
getSessionId(): Nullable<number>;
|
275
|
+
}
|
276
|
+
|
277
|
+
declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
|
278
|
+
static globalSingleton: Nullable<RudderAnalytics>;
|
279
|
+
analyticsInstances: Record<string, IAnalytics>;
|
280
|
+
defaultAnalyticsKey: string;
|
281
|
+
constructor();
|
282
|
+
/**
|
283
|
+
* Set instance to use if no specific writeKey is provided in methods
|
284
|
+
* automatically for the first created instance
|
285
|
+
* TODO: to support multiple analytics instances in the near future
|
286
|
+
*/
|
287
|
+
setDefaultInstanceKey(writeKey: string): void;
|
288
|
+
/**
|
289
|
+
* Retrieve an existing analytics instance
|
290
|
+
*/
|
291
|
+
getAnalyticsInstance(writeKey?: string): IAnalytics;
|
292
|
+
/**
|
293
|
+
* Create new analytics instance and trigger application lifecycle start
|
294
|
+
*/
|
295
|
+
load(writeKey: string, dataPlaneUrl: string, loadOptions?: Partial<LoadOptions>): void;
|
296
|
+
/**
|
297
|
+
* Get preloaded events in buffer queue if exists
|
298
|
+
*/
|
299
|
+
getPreloadBuffer(): void;
|
300
|
+
/**
|
301
|
+
* Trigger load event in buffer queue if exists
|
302
|
+
*/
|
303
|
+
triggerBufferedLoadEvent(): void;
|
304
|
+
/**
|
305
|
+
* Get ready callback arguments and forward to ready call
|
306
|
+
*/
|
307
|
+
ready(callback: ApiCallback): void;
|
308
|
+
/**
|
309
|
+
* Process page arguments and forward to page call
|
310
|
+
*/
|
311
|
+
page(category?: string | Nullable<ApiObject> | ApiCallback, name?: string | Nullable<ApiOptions> | Nullable<ApiObject> | ApiCallback, properties?: Nullable<ApiOptions> | Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
312
|
+
/**
|
313
|
+
* Process track arguments and forward to page call
|
314
|
+
*/
|
315
|
+
track(event: string, properties?: Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
316
|
+
/**
|
317
|
+
* Process identify arguments and forward to page call
|
318
|
+
*/
|
319
|
+
identify(userId?: string | number | Nullable<ApiObject>, traits?: Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
320
|
+
/**
|
321
|
+
* Process alias arguments and forward to page call
|
322
|
+
*/
|
323
|
+
alias(to?: Nullable<string> | ApiCallback, from?: string | Nullable<ApiOptions> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
324
|
+
/**
|
325
|
+
* Process group arguments and forward to page call
|
326
|
+
*/
|
327
|
+
group(groupId: string | number | Nullable<ApiObject> | ApiCallback, traits?: Nullable<ApiOptions> | Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
328
|
+
reset(resetAnonymousId?: boolean): void;
|
329
|
+
getAnonymousId(options?: AnonymousIdOptions): string | undefined;
|
330
|
+
setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;
|
331
|
+
getUserId(): Nullable<string> | undefined;
|
332
|
+
getUserTraits(): Nullable<ApiObject> | undefined;
|
333
|
+
getGroupId(): Nullable<string> | undefined;
|
334
|
+
getGroupTraits(): Nullable<ApiObject> | undefined;
|
335
|
+
startSession(sessionId?: number): void;
|
336
|
+
endSession(): void;
|
337
|
+
getSessionId(): Nullable<number>;
|
338
|
+
}
|
339
|
+
//# sourceMappingURL=RudderAnalytics.d.ts.map
|
340
|
+
|
341
|
+
/**
|
342
|
+
* Exposed values that can be accessed as global objects per analytics instance
|
343
|
+
* // TODO: find all values that need to be exposed in globals if anything else
|
344
|
+
*/
|
345
|
+
type ExposedGlobals = {
|
346
|
+
state?: ApplicationState;
|
347
|
+
preloadedEventsBuffer?: PreloadedEventCall[];
|
348
|
+
pluginsCDNPath?: string;
|
349
|
+
};
|
350
|
+
/**
|
351
|
+
* Exposing all globally accessible values for all analytics instances
|
352
|
+
* As key, we use the value of writeKey assigned to analytics instance that the values belong to
|
353
|
+
*/
|
354
|
+
interface IRudderStackGlobals {
|
355
|
+
[key: string]: ExposedGlobals;
|
356
|
+
}
|
357
|
+
|
358
|
+
export { IRudderStackGlobals, RudderAnalytics };
|