@amplitude/analytics-core 2.15.0 → 2.17.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.
- package/lib/cjs/config.d.ts +2 -97
- package/lib/cjs/config.d.ts.map +1 -1
- package/lib/cjs/config.js.map +1 -1
- package/lib/cjs/core-client.d.ts +14 -151
- package/lib/cjs/core-client.d.ts.map +1 -1
- package/lib/cjs/core-client.js +1 -0
- package/lib/cjs/core-client.js.map +1 -1
- package/lib/cjs/index.d.ts +9 -5
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/network-observer.js +3 -3
- package/lib/cjs/network-observer.js.map +1 -1
- package/lib/cjs/network-request-event.d.ts +1 -0
- package/lib/cjs/network-request-event.d.ts.map +1 -1
- package/lib/cjs/network-request-event.js +10 -0
- package/lib/cjs/network-request-event.js.map +1 -1
- package/lib/cjs/plugins/destination.d.ts +1 -1
- package/lib/cjs/plugins/destination.d.ts.map +1 -1
- package/lib/cjs/plugins/destination.js.map +1 -1
- package/lib/cjs/plugins/identity.d.ts +1 -1
- package/lib/cjs/plugins/identity.d.ts.map +1 -1
- package/lib/cjs/plugins/identity.js.map +1 -1
- package/lib/cjs/remote-config/remote-config.d.ts +1 -1
- package/lib/cjs/remote-config/remote-config.d.ts.map +1 -1
- package/lib/cjs/remote-config/remote-config.js +7 -18
- package/lib/cjs/remote-config/remote-config.js.map +1 -1
- package/lib/cjs/timeline.d.ts +4 -2
- package/lib/cjs/timeline.d.ts.map +1 -1
- package/lib/cjs/timeline.js +10 -2
- package/lib/cjs/timeline.js.map +1 -1
- package/lib/cjs/types/{browser-client.d.ts → client/browser-client.d.ts} +5 -5
- package/lib/cjs/types/client/browser-client.d.ts.map +1 -0
- package/lib/cjs/types/client/browser-client.js.map +1 -0
- package/lib/cjs/types/client/core-client.d.ts +144 -0
- package/lib/cjs/types/client/core-client.d.ts.map +1 -0
- package/lib/cjs/types/client/core-client.js +3 -0
- package/lib/cjs/types/client/core-client.js.map +1 -0
- package/lib/cjs/types/client/node-client.d.ts +34 -0
- package/lib/cjs/types/client/node-client.d.ts.map +1 -0
- package/lib/cjs/types/client/node-client.js +3 -0
- package/lib/cjs/types/client/node-client.js.map +1 -0
- package/lib/cjs/types/{browser-config.d.ts → config/browser-config.d.ts} +14 -7
- package/lib/cjs/types/config/browser-config.d.ts.map +1 -0
- package/lib/cjs/types/config/browser-config.js.map +1 -0
- package/lib/cjs/types/config/core-config.d.ts +107 -0
- package/lib/cjs/types/config/core-config.d.ts.map +1 -0
- package/lib/cjs/types/config/core-config.js +3 -0
- package/lib/cjs/types/config/core-config.js.map +1 -0
- package/lib/cjs/types/config/node-config.d.ts +4 -0
- package/lib/cjs/types/config/node-config.d.ts.map +1 -0
- package/lib/cjs/types/config/node-config.js +3 -0
- package/lib/cjs/types/config/node-config.js.map +1 -0
- package/lib/cjs/types/frustration-interactions.d.ts +4 -4
- package/lib/cjs/types/frustration-interactions.d.ts.map +1 -1
- package/lib/cjs/types/frustration-interactions.js +4 -4
- package/lib/cjs/types/frustration-interactions.js.map +1 -1
- package/lib/cjs/types/plugin.d.ts +2 -2
- package/lib/cjs/types/plugin.d.ts.map +1 -1
- package/lib/cjs/types/plugin.js.map +1 -1
- package/lib/esm/config.d.ts +2 -97
- package/lib/esm/config.d.ts.map +1 -1
- package/lib/esm/config.js.map +1 -1
- package/lib/esm/core-client.d.ts +14 -151
- package/lib/esm/core-client.d.ts.map +1 -1
- package/lib/esm/core-client.js +1 -0
- package/lib/esm/core-client.js.map +1 -1
- package/lib/esm/index.d.ts +9 -5
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/network-observer.js +1 -1
- package/lib/esm/network-observer.js.map +1 -1
- package/lib/esm/network-request-event.d.ts +1 -0
- package/lib/esm/network-request-event.d.ts.map +1 -1
- package/lib/esm/network-request-event.js +10 -0
- package/lib/esm/network-request-event.js.map +1 -1
- package/lib/esm/plugins/destination.d.ts +1 -1
- package/lib/esm/plugins/destination.d.ts.map +1 -1
- package/lib/esm/plugins/destination.js.map +1 -1
- package/lib/esm/plugins/identity.d.ts +1 -1
- package/lib/esm/plugins/identity.d.ts.map +1 -1
- package/lib/esm/plugins/identity.js.map +1 -1
- package/lib/esm/remote-config/remote-config.d.ts +1 -1
- package/lib/esm/remote-config/remote-config.d.ts.map +1 -1
- package/lib/esm/remote-config/remote-config.js +6 -17
- package/lib/esm/remote-config/remote-config.js.map +1 -1
- package/lib/esm/timeline.d.ts +4 -2
- package/lib/esm/timeline.d.ts.map +1 -1
- package/lib/esm/timeline.js +10 -2
- package/lib/esm/timeline.js.map +1 -1
- package/lib/esm/types/{browser-client.d.ts → client/browser-client.d.ts} +5 -5
- package/lib/esm/types/client/browser-client.d.ts.map +1 -0
- package/lib/esm/types/client/browser-client.js.map +1 -0
- package/lib/esm/types/client/core-client.d.ts +144 -0
- package/lib/esm/types/client/core-client.d.ts.map +1 -0
- package/lib/esm/types/client/core-client.js +2 -0
- package/lib/esm/types/client/core-client.js.map +1 -0
- package/lib/esm/types/client/node-client.d.ts +34 -0
- package/lib/esm/types/client/node-client.d.ts.map +1 -0
- package/lib/esm/types/client/node-client.js +2 -0
- package/lib/esm/types/client/node-client.js.map +1 -0
- package/lib/esm/types/{browser-config.d.ts → config/browser-config.d.ts} +14 -7
- package/lib/esm/types/config/browser-config.d.ts.map +1 -0
- package/lib/esm/types/config/browser-config.js.map +1 -0
- package/lib/esm/types/config/core-config.d.ts +107 -0
- package/lib/esm/types/config/core-config.d.ts.map +1 -0
- package/lib/esm/types/config/core-config.js +2 -0
- package/lib/esm/types/config/core-config.js.map +1 -0
- package/lib/esm/types/config/node-config.d.ts +4 -0
- package/lib/esm/types/config/node-config.d.ts.map +1 -0
- package/lib/esm/types/config/node-config.js +2 -0
- package/lib/esm/types/config/node-config.js.map +1 -0
- package/lib/esm/types/frustration-interactions.d.ts +4 -4
- package/lib/esm/types/frustration-interactions.d.ts.map +1 -1
- package/lib/esm/types/frustration-interactions.js +4 -4
- package/lib/esm/types/frustration-interactions.js.map +1 -1
- package/lib/esm/types/plugin.d.ts +2 -2
- package/lib/esm/types/plugin.d.ts.map +1 -1
- package/lib/esm/types/plugin.js.map +1 -1
- package/package.json +2 -2
- package/lib/cjs/types/browser-client.d.ts.map +0 -1
- package/lib/cjs/types/browser-client.js.map +0 -1
- package/lib/cjs/types/browser-config.d.ts.map +0 -1
- package/lib/cjs/types/browser-config.js.map +0 -1
- package/lib/esm/types/browser-client.d.ts.map +0 -1
- package/lib/esm/types/browser-client.js.map +0 -1
- package/lib/esm/types/browser-config.d.ts.map +0 -1
- package/lib/esm/types/browser-config.js.map +0 -1
- /package/lib/cjs/types/{browser-client.js → client/browser-client.js} +0 -0
- /package/lib/cjs/types/{browser-config.js → config/browser-config.js} +0 -0
- /package/lib/esm/types/{browser-client.js → client/browser-client.js} +0 -0
- /package/lib/esm/types/{browser-config.js → config/browser-config.js} +0 -0
package/lib/esm/timeline.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AnalyticsIdentity, Plugin } from './types/plugin';
|
|
2
|
-
import { CoreClient } from './core-client';
|
|
3
|
-
import { IConfig } from './config';
|
|
2
|
+
import { CoreClient } from './types/client/core-client';
|
|
3
|
+
import { IConfig } from './types/config/core-config';
|
|
4
|
+
import { ILogger } from './logger';
|
|
4
5
|
import { EventCallback } from './types/event-callback';
|
|
5
6
|
import { Event } from './types/event/event';
|
|
6
7
|
import { Result } from './types/result';
|
|
@@ -9,6 +10,7 @@ export declare class Timeline {
|
|
|
9
10
|
queue: [Event, EventCallback][];
|
|
10
11
|
applying: boolean;
|
|
11
12
|
plugins: Plugin[];
|
|
13
|
+
loggerProvider: ILogger;
|
|
12
14
|
constructor(client: CoreClient);
|
|
13
15
|
register(plugin: Plugin, config: IConfig): Promise<void>;
|
|
14
16
|
deregister(pluginName: string, config: IConfig): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqD,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqD,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,qBAAa,QAAQ;IAYP,OAAO,CAAC,MAAM;IAX1B,KAAK,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,EAAE,CAAM;IAErC,QAAQ,UAAS;IAGjB,OAAO,EAAE,MAAM,EAAE,CAAM;IAIvB,cAAc,EAAE,OAAO,CAAC;gBAEJ,MAAM,EAAE,UAAU;IAEhC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAmBxC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAWpD,KAAK,CAAC,MAAM,EAAE,UAAU;IAQxB,IAAI,CAAC,KAAK,EAAE,KAAK;IAOjB,aAAa,CAAC,OAAO,EAAE,MAAM;IAavB,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG,SAAS;IAsF9C,KAAK;IAiBX,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB;IAU7C,kBAAkB,CAAC,SAAS,EAAE,MAAM;IAUpC,eAAe,CAAC,MAAM,EAAE,OAAO;CAShC"}
|
package/lib/esm/timeline.js
CHANGED
|
@@ -19,12 +19,12 @@ var Timeline = /** @class */ (function () {
|
|
|
19
19
|
case 0:
|
|
20
20
|
if (this.plugins.some(function (existingPlugin) { return existingPlugin.name === plugin.name; })) {
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
22
|
-
|
|
22
|
+
this.loggerProvider.warn("Plugin with name ".concat(plugin.name, " already exists, skipping registration"));
|
|
23
23
|
return [2 /*return*/];
|
|
24
24
|
}
|
|
25
25
|
if (plugin.name === undefined) {
|
|
26
26
|
plugin.name = UUID();
|
|
27
|
-
|
|
27
|
+
this.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(plugin.name, ". \n Set a name for the plugin to prevent it from being added multiple times."));
|
|
28
28
|
}
|
|
29
29
|
plugin.type = (_a = plugin.type) !== null && _a !== void 0 ? _a : 'enrichment';
|
|
30
30
|
return [4 /*yield*/, ((_b = plugin.setup) === null || _b === void 0 ? void 0 : _b.call(plugin, config, this.client))];
|
|
@@ -98,6 +98,8 @@ var Timeline = /** @class */ (function () {
|
|
|
98
98
|
}
|
|
99
99
|
_a = __read(item, 1), event = _a[0];
|
|
100
100
|
_b = __read(item, 2), resolve = _b[1];
|
|
101
|
+
// Log initial event
|
|
102
|
+
this.loggerProvider.log('Timeline.apply: Initial event', event);
|
|
101
103
|
before = this.plugins.filter(function (plugin) { return plugin.type === 'before'; });
|
|
102
104
|
_e.label = 1;
|
|
103
105
|
case 1:
|
|
@@ -116,11 +118,13 @@ var Timeline = /** @class */ (function () {
|
|
|
116
118
|
case 3:
|
|
117
119
|
e = _e.sent();
|
|
118
120
|
if (e === null) {
|
|
121
|
+
this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(plugin.name), "', event: ").concat(JSON.stringify(event)));
|
|
119
122
|
resolve({ event: event, code: 0, message: '' });
|
|
120
123
|
return [2 /*return*/];
|
|
121
124
|
}
|
|
122
125
|
else {
|
|
123
126
|
event = e;
|
|
127
|
+
this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(plugin.name), "', event: ").concat(JSON.stringify(event)));
|
|
124
128
|
}
|
|
125
129
|
_e.label = 4;
|
|
126
130
|
case 4:
|
|
@@ -156,11 +160,13 @@ var Timeline = /** @class */ (function () {
|
|
|
156
160
|
case 11:
|
|
157
161
|
e = _e.sent();
|
|
158
162
|
if (e === null) {
|
|
163
|
+
this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(plugin.name), "', event: ").concat(JSON.stringify(event)));
|
|
159
164
|
resolve({ event: event, code: 0, message: '' });
|
|
160
165
|
return [2 /*return*/];
|
|
161
166
|
}
|
|
162
167
|
else {
|
|
163
168
|
event = e;
|
|
169
|
+
this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(plugin.name), "', event: ").concat(JSON.stringify(event)));
|
|
164
170
|
}
|
|
165
171
|
_e.label = 12;
|
|
166
172
|
case 12:
|
|
@@ -179,6 +185,8 @@ var Timeline = /** @class */ (function () {
|
|
|
179
185
|
return [7 /*endfinally*/];
|
|
180
186
|
case 16:
|
|
181
187
|
destination = this.plugins.filter(function (plugin) { return plugin.type === 'destination'; });
|
|
188
|
+
// Log final event before sending to destinations
|
|
189
|
+
this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(event)));
|
|
182
190
|
executeDestinations = destination.map(function (plugin) {
|
|
183
191
|
var eventClone = __assign({}, event);
|
|
184
192
|
return plugin.execute(eventClone).catch(function (e) { return buildResult(eventClone, 0, String(e)); });
|
package/lib/esm/timeline.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAA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YACxD,0DAA0D;YAC1D,0BAA0B;YAC1B,KAAK,CAAA,MAAA,MAAM,CAAC,eAAe,uDAAG,MAAM,CAAC,CAAA,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;IACH,eAAC;AAAD,CAAC,AAlLD,IAkLC","sourcesContent":["import { AnalyticsIdentity, BeforePlugin, DestinationPlugin, EnrichmentPlugin, Plugin } from './types/plugin';\nimport { CoreClient } from './core-client';\nimport { IConfig } from './config';\nimport { EventCallback } from './types/event-callback';\nimport { Event } from './types/event/event';\nimport { Result } from './types/result';\nimport { buildResult } from './utils/result-builder';\nimport { UUID } from './utils/uuid';\n\nexport class Timeline {\n queue: [Event, EventCallback][] = [];\n // Flag to guarantee one schedule apply is running\n applying = false;\n // Flag indicates whether timeline is ready to process event\n // Events collected before timeline is ready will stay in the queue to be processed later\n plugins: Plugin[] = [];\n\n constructor(private client: CoreClient) {}\n\n async register(plugin: Plugin, config: IConfig) {\n if (this.plugins.some((existingPlugin) => existingPlugin.name === plugin.name)) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n config.loggerProvider.warn(`Plugin with name ${plugin.name} already exists, skipping registration`);\n return;\n }\n\n if (plugin.name === undefined) {\n plugin.name = UUID();\n config.loggerProvider.warn(`Plugin name is undefined. \n Generating a random UUID for plugin name: ${plugin.name}. \n Set a name for the plugin to prevent it from being added multiple times.`);\n }\n\n plugin.type = plugin.type ?? 'enrichment';\n await plugin.setup?.(config, this.client);\n this.plugins.push(plugin);\n }\n\n async deregister(pluginName: string, config: IConfig) {\n const index = this.plugins.findIndex((plugin) => plugin.name === pluginName);\n if (index === -1) {\n config.loggerProvider.warn(`Plugin with name ${pluginName} does not exist, skipping deregistration`);\n return;\n }\n const plugin = this.plugins[index];\n this.plugins.splice(index, 1);\n await plugin.teardown?.();\n }\n\n reset(client: CoreClient) {\n this.applying = false;\n const plugins = this.plugins;\n plugins.map((plugin) => plugin.teardown?.());\n this.plugins = [];\n this.client = client;\n }\n\n push(event: Event) {\n return new Promise<Result>((resolve) => {\n this.queue.push([event, resolve]);\n this.scheduleApply(0);\n });\n }\n\n scheduleApply(timeout: number) {\n if (this.applying) return;\n this.applying = true;\n setTimeout(() => {\n void this.apply(this.queue.shift()).then(() => {\n this.applying = false;\n if (this.queue.length > 0) {\n this.scheduleApply(0);\n }\n });\n }, timeout);\n }\n\n async apply(item: [Event, EventCallback] | undefined) {\n if (!item) {\n return;\n }\n\n let [event] = item;\n const [, resolve] = item;\n\n const before = this.plugins.filter<BeforePlugin>(\n (plugin: Plugin): plugin is BeforePlugin => plugin.type === 'before',\n );\n\n for (const plugin of before) {\n /* istanbul ignore if */\n if (!plugin.execute) {\n // do nothing\n continue;\n }\n const e = await plugin.execute({ ...event });\n if (e === null) {\n resolve({ event, code: 0, message: '' });\n return;\n } else {\n event = e;\n }\n }\n\n const enrichment = this.plugins.filter<EnrichmentPlugin>(\n (plugin: Plugin): plugin is EnrichmentPlugin => plugin.type === 'enrichment' || plugin.type === undefined,\n );\n\n for (const plugin of enrichment) {\n /* istanbul ignore if */\n if (!plugin.execute) {\n // do nothing\n continue;\n }\n const e = await plugin.execute({ ...event });\n if (e === null) {\n resolve({ event, code: 0, message: '' });\n return;\n } else {\n event = e;\n }\n }\n\n const destination = this.plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === 'destination',\n );\n\n const executeDestinations = destination.map((plugin) => {\n const eventClone = { ...event };\n return plugin.execute(eventClone).catch((e) => buildResult(eventClone, 0, String(e)));\n });\n\n void Promise.all(executeDestinations).then(([result]) => {\n const resolveResult =\n result || buildResult(event, 100, 'Event not tracked, no destination plugins on the instance');\n resolve(resolveResult);\n });\n\n return;\n }\n\n async flush() {\n const queue = this.queue;\n this.queue = [];\n\n await Promise.all(queue.map((item) => this.apply(item)));\n\n const destination = this.plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === 'destination',\n );\n\n const executeDestinations = destination.map((plugin) => {\n return plugin.flush && plugin.flush();\n });\n\n await Promise.all(executeDestinations);\n }\n\n onIdentityChanged(identity: AnalyticsIdentity) {\n this.plugins.forEach((plugin) => {\n // Intentionally to not await plugin.onIdentityChanged() for non-blocking.\n // Ignore optional channing next line for test coverage.\n // If the plugin doesn't implement it, it won't be called.\n /* istanbul ignore next */\n void plugin.onIdentityChanged?.(identity);\n });\n }\n\n onSessionIdChanged(sessionId: number) {\n this.plugins.forEach((plugin) => {\n // Intentionally to not await plugin.onSessionIdChanged() for non-blocking.\n // Ignore optional channing next line for test coverage.\n // If the plugin doesn't implement it, it won't be called.\n /* istanbul ignore next */\n void plugin.onSessionIdChanged?.(sessionId);\n });\n }\n\n onOptOutChanged(optOut: boolean) {\n this.plugins.forEach((plugin) => {\n // Intentionally to not await plugin.onOptOutChanged() for non-blocking.\n // Ignore optional channing next line for test coverage.\n // If the plugin doesn't implement it, it won't be called.\n /* istanbul ignore next */\n void plugin.onOptOutChanged?.(optOut);\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC;IAYE,kBAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QAXtC,UAAK,GAA6B,EAAE,CAAC;QACrC,kDAAkD;QAClD,aAAQ,GAAG,KAAK,CAAC;QACjB,4DAA4D;QAC5D,yFAAyF;QACzF,YAAO,GAAa,EAAE,CAAC;IAMkB,CAAC;IAEpC,2BAAQ,GAAd,UAAe,MAAc,EAAE,MAAe;;;;;;wBAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,cAAc,IAAK,OAAA,cAAc,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAnC,CAAmC,CAAC,EAAE;4BAC9E,4EAA4E;4BAC5E,IAAI,C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AAC,OAAO,CAAC,OAAO,CAAC,UAAC,MAAM;;YAC1B,2EAA2E;YAC3E,wDAAwD;YACxD,0DAA0D;YAC1D,0BAA0B;YAC1B,KAAK,CAAA,MAAA,MAAM,CAAC,kBAAkB,uDAAG,SAAS,CAAC,CAAA,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kCAAe,GAAf,UAAgB,MAAe;QAC7B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAC,MAAM;;YAC1B,wEAAwE;YACxE,wDAAwD;YACxD,0DAA0D;YAC1D,0BAA0B;YAC1B,KAAK,CAAA,MAAA,MAAM,CAAC,eAAe,uDAAG,MAAM,CAAC,CAAA,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;IACH,eAAC;AAAD,CAAC,AA5MD,IA4MC","sourcesContent":["import { AnalyticsIdentity, BeforePlugin, DestinationPlugin, EnrichmentPlugin, Plugin } from './types/plugin';\nimport { CoreClient } from './types/client/core-client';\nimport { IConfig } from './types/config/core-config';\nimport { ILogger } from './logger';\nimport { EventCallback } from './types/event-callback';\nimport { Event } from './types/event/event';\nimport { Result } from './types/result';\nimport { buildResult } from './utils/result-builder';\nimport { UUID } from './utils/uuid';\n\nexport class Timeline {\n queue: [Event, EventCallback][] = [];\n // Flag to guarantee one schedule apply is running\n applying = false;\n // Flag indicates whether timeline is ready to process event\n // Events collected before timeline is ready will stay in the queue to be processed later\n plugins: Plugin[] = [];\n // loggerProvider is set by the client at _init()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n loggerProvider: ILogger;\n\n constructor(private client: CoreClient) {}\n\n async register(plugin: Plugin, config: IConfig) {\n if (this.plugins.some((existingPlugin) => existingPlugin.name === plugin.name)) {\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n this.loggerProvider.warn(`Plugin with name ${plugin.name} already exists, skipping registration`);\n return;\n }\n\n if (plugin.name === undefined) {\n plugin.name = UUID();\n this.loggerProvider.warn(`Plugin name is undefined. \n Generating a random UUID for plugin name: ${plugin.name}. \n Set a name for the plugin to prevent it from being added multiple times.`);\n }\n\n plugin.type = plugin.type ?? 'enrichment';\n await plugin.setup?.(config, this.client);\n this.plugins.push(plugin);\n }\n\n async deregister(pluginName: string, config: IConfig) {\n const index = this.plugins.findIndex((plugin) => plugin.name === pluginName);\n if (index === -1) {\n config.loggerProvider.warn(`Plugin with name ${pluginName} does not exist, skipping deregistration`);\n return;\n }\n const plugin = this.plugins[index];\n this.plugins.splice(index, 1);\n await plugin.teardown?.();\n }\n\n reset(client: CoreClient) {\n this.applying = false;\n const plugins = this.plugins;\n plugins.map((plugin) => plugin.teardown?.());\n this.plugins = [];\n this.client = client;\n }\n\n push(event: Event) {\n return new Promise<Result>((resolve) => {\n this.queue.push([event, resolve]);\n this.scheduleApply(0);\n });\n }\n\n scheduleApply(timeout: number) {\n if (this.applying) return;\n this.applying = true;\n setTimeout(() => {\n void this.apply(this.queue.shift()).then(() => {\n this.applying = false;\n if (this.queue.length > 0) {\n this.scheduleApply(0);\n }\n });\n }, timeout);\n }\n\n async apply(item: [Event, EventCallback] | undefined) {\n if (!item) {\n return;\n }\n\n let [event] = item;\n const [, resolve] = item;\n\n // Log initial event\n this.loggerProvider.log('Timeline.apply: Initial event', event);\n\n const before = this.plugins.filter<BeforePlugin>(\n (plugin: Plugin): plugin is BeforePlugin => plugin.type === 'before',\n );\n\n for (const plugin of before) {\n /* istanbul ignore if */\n if (!plugin.execute) {\n // do nothing\n continue;\n }\n const e = await plugin.execute({ ...event });\n if (e === null) {\n this.loggerProvider.log(\n `Timeline.apply: Event filtered out by before plugin '${String(plugin.name)}', event: ${JSON.stringify(\n event,\n )}`,\n );\n resolve({ event, code: 0, message: '' });\n return;\n } else {\n event = e;\n this.loggerProvider.log(\n `Timeline.apply: Event after before plugin '${String(plugin.name)}', event: ${JSON.stringify(event)}`,\n );\n }\n }\n\n const enrichment = this.plugins.filter<EnrichmentPlugin>(\n (plugin: Plugin): plugin is EnrichmentPlugin => plugin.type === 'enrichment' || plugin.type === undefined,\n );\n\n for (const plugin of enrichment) {\n /* istanbul ignore if */\n if (!plugin.execute) {\n // do nothing\n continue;\n }\n const e = await plugin.execute({ ...event });\n if (e === null) {\n this.loggerProvider.log(\n `Timeline.apply: Event filtered out by enrichment plugin '${String(plugin.name)}', event: ${JSON.stringify(\n event,\n )}`,\n );\n resolve({ event, code: 0, message: '' });\n return;\n } else {\n event = e;\n this.loggerProvider.log(\n `Timeline.apply: Event after enrichment plugin '${String(plugin.name)}', event: ${JSON.stringify(event)}`,\n );\n }\n }\n\n const destination = this.plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === 'destination',\n );\n\n // Log final event before sending to destinations\n this.loggerProvider.log(`Timeline.apply: Final event before destinations, event: ${JSON.stringify(event)}`);\n\n const executeDestinations = destination.map((plugin) => {\n const eventClone = { ...event };\n return plugin.execute(eventClone).catch((e) => buildResult(eventClone, 0, String(e)));\n });\n\n void Promise.all(executeDestinations).then(([result]) => {\n const resolveResult =\n result || buildResult(event, 100, 'Event not tracked, no destination plugins on the instance');\n resolve(resolveResult);\n });\n\n return;\n }\n\n async flush() {\n const queue = this.queue;\n this.queue = [];\n\n await Promise.all(queue.map((item) => this.apply(item)));\n\n const destination = this.plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === 'destination',\n );\n\n const executeDestinations = destination.map((plugin) => {\n return plugin.flush && plugin.flush();\n });\n\n await Promise.all(executeDestinations);\n }\n\n onIdentityChanged(identity: AnalyticsIdentity) {\n this.plugins.forEach((plugin) => {\n // Intentionally to not await plugin.onIdentityChanged() for non-blocking.\n // Ignore optional channing next line for test coverage.\n // If the plugin doesn't implement it, it won't be called.\n /* istanbul ignore next */\n void plugin.onIdentityChanged?.(identity);\n });\n }\n\n onSessionIdChanged(sessionId: number) {\n this.plugins.forEach((plugin) => {\n // Intentionally to not await plugin.onSessionIdChanged() for non-blocking.\n // Ignore optional channing next line for test coverage.\n // If the plugin doesn't implement it, it won't be called.\n /* istanbul ignore next */\n void plugin.onSessionIdChanged?.(sessionId);\n });\n }\n\n onOptOutChanged(optOut: boolean) {\n this.plugins.forEach((plugin) => {\n // Intentionally to not await plugin.onOptOutChanged() for non-blocking.\n // Ignore optional channing next line for test coverage.\n // If the plugin doesn't implement it, it won't be called.\n /* istanbul ignore next */\n void plugin.onOptOutChanged?.(optOut);\n });\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TransportType } from '
|
|
2
|
-
import { CoreClient } from '
|
|
3
|
-
import { AnalyticsIdentity, Plugin } from '
|
|
4
|
-
import { AmplitudeReturn } from '
|
|
5
|
-
import { BrowserConfig, BrowserOptions } from '
|
|
1
|
+
import { TransportType } from '../transport';
|
|
2
|
+
import { CoreClient } from './core-client';
|
|
3
|
+
import { AnalyticsIdentity, Plugin } from '../plugin';
|
|
4
|
+
import { AmplitudeReturn } from '../../utils/return-wrapper';
|
|
5
|
+
import { BrowserConfig, BrowserOptions } from '../config/browser-config';
|
|
6
6
|
interface Client extends CoreClient {
|
|
7
7
|
/**
|
|
8
8
|
* Returns current user ID.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-client.d.ts","sourceRoot":"","sources":["../../../../src/types/client/browser-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEzE,UAAU,MAAO,SAAQ,UAAU;IACjC;;;;;;OAMG;IACH,SAAS,IAAI,MAAM,GAAG,SAAS,CAAC;IAEhC;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAE5C;;;;;;OAMG;IACH,WAAW,IAAI,MAAM,GAAG,SAAS,CAAC;IAElC;;;;;;;;OAQG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC;;;;;;OAMG;IACH,YAAY,IAAI,MAAM,GAAG,SAAS,CAAC;IAEnC;;;;;;;OAOG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC;;;;;;;;;OASG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;;;;;;;;;;OAaG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,MAAM;IAC3C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEtE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEvF;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IAE7C;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEzE;;;;;;OAMG;IACH,WAAW,IAAI,iBAAiB,CAAC;IAEjC;;;;;;OAMG;IACH,SAAS,IAAI,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-client.js","sourceRoot":"","sources":["../../../../src/types/client/browser-client.ts"],"names":[],"mappings":"","sourcesContent":["import { TransportType } from '../transport';\nimport { CoreClient } from './core-client';\nimport { AnalyticsIdentity, Plugin } from '../plugin';\nimport { AmplitudeReturn } from '../../utils/return-wrapper';\nimport { BrowserConfig, BrowserOptions } from '../config/browser-config';\n\ninterface Client extends CoreClient {\n /**\n * Returns current user ID.\n *\n * ```typescript\n * const userId = getUserId();\n * ```\n */\n getUserId(): string | undefined;\n\n /**\n * Sets a new user ID.\n *\n * ```typescript\n * setUserId('userId');\n * ```\n */\n setUserId(userId: string | undefined): void;\n\n /**\n * Returns current device ID.\n *\n * ```typescript\n * const deviceId = getDeviceId();\n * ```\n */\n getDeviceId(): string | undefined;\n\n /**\n * Sets a new device ID.\n * When setting a custom device ID, make sure the value is sufficiently unique.\n * A uuid is recommended.\n *\n * ```typescript\n * setDeviceId('deviceId');\n * ```\n */\n setDeviceId(deviceId: string): void;\n\n /**\n * Returns current session ID.\n *\n * ```typescript\n * const sessionId = getSessionId();\n * ```\n */\n getSessionId(): number | undefined;\n\n /**\n * Sets a new session ID.\n * When setting a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp).\n *\n * ```typescript\n * setSessionId(Date.now());\n * ```\n */\n setSessionId(sessionId: number): void;\n\n /**\n * Extends the current session (advanced)\n *\n * Normally sessions are extended automatically by track()'ing events. If you want to extend the session without\n * tracking and event, this will set the last user interaction to the current time.\n *\n * ```typescript\n * extendSession();\n * ```\n */\n extendSession(): void;\n\n /**\n * Anonymizes users after they log out, by:\n *\n * * setting userId to undefined\n * * setting deviceId to a new uuid value\n *\n * With an undefined userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.\n *\n * ```typescript\n * import { reset } from '@amplitude/analytics-browser';\n *\n * reset();\n * ```\n */\n reset(): void;\n}\n\nexport interface BrowserClient extends Client {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: BrowserOptions): AmplitudeReturn<void>;\n\n init(apiKey: string, userId?: string, options?: BrowserOptions): AmplitudeReturn<void>;\n\n /**\n * Sets the network transport type for events.\n *\n * ```typescript\n * // Use Fetch API\n * setTransport('fetch');\n *\n * // Use XMLHttpRequest API\n * setTransport('xhr');\n *\n * // Use navigator.sendBeacon API\n * setTransport('beacon');\n * ```\n */\n setTransport(transport: TransportType): void;\n\n /**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {\n * name: 'my-plugin',\n * type: 'enrichment',\n * async setup(config: BrowserConfig, amplitude: BrowserClient) {\n * return;\n * },\n * async execute(event: Event) {\n * return event;\n * },\n * };\n * amplitude.add(plugin);\n * ```\n */\n add(plugin: Plugin<BrowserClient, BrowserConfig>): AmplitudeReturn<void>;\n\n /**\n * Returns the current identity.\n *\n * ```typescript\n * const identity = getIdentity();\n * ```\n */\n getIdentity(): AnalyticsIdentity;\n\n /**\n * Returns the current optOut config value.\n *\n * ```typescript\n * const optOut = getOptOut();\n * ```\n */\n getOptOut(): boolean;\n}\n"]}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { AmplitudeReturn } from '../../utils/return-wrapper';
|
|
2
|
+
import { BaseEvent, EventOptions } from '../event/base-event';
|
|
3
|
+
import { Result } from '../result';
|
|
4
|
+
import { IIdentify } from '../../identify';
|
|
5
|
+
import { IRevenue } from '../../revenue';
|
|
6
|
+
import { Plugin } from '../plugin';
|
|
7
|
+
export interface PluginHost {
|
|
8
|
+
plugin(name: string): Plugin | undefined;
|
|
9
|
+
plugins<T extends Plugin>(pluginClass: new (...args: any[]) => T): T[];
|
|
10
|
+
}
|
|
11
|
+
export interface CoreClient {
|
|
12
|
+
/**
|
|
13
|
+
* Adds a new plugin.
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const plugin = {
|
|
17
|
+
* name: 'myPlugin',
|
|
18
|
+
* type: 'enrichment',
|
|
19
|
+
* setup(config: Config) {
|
|
20
|
+
* return;
|
|
21
|
+
* },
|
|
22
|
+
* execute(context: Event) {
|
|
23
|
+
* return context;
|
|
24
|
+
* },
|
|
25
|
+
* };
|
|
26
|
+
* amplitude.add(plugin);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
add(plugin: Plugin): AmplitudeReturn<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Removes a plugin.
|
|
32
|
+
*
|
|
33
|
+
* ```typescript
|
|
34
|
+
* amplitude.remove('myPlugin');
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
remove(pluginName: string): AmplitudeReturn<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Tracks user-defined event, with specified type, optional event properties and optional overwrites.
|
|
40
|
+
*
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // event tracking with event type only
|
|
43
|
+
* track('Page Load');
|
|
44
|
+
*
|
|
45
|
+
* // event tracking with event type and additional event properties
|
|
46
|
+
* track('Page Load', { loadTime: 1000 });
|
|
47
|
+
*
|
|
48
|
+
* // event tracking with event type, additional event properties, and overwritten event options
|
|
49
|
+
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 });
|
|
50
|
+
*
|
|
51
|
+
* // alternatively, this tracking method is awaitable
|
|
52
|
+
* const result = await track('Page Load').promise;
|
|
53
|
+
* console.log(result.event); // {...}
|
|
54
|
+
* console.log(result.code); // 200
|
|
55
|
+
* console.log(result.message); // "Event tracked successfully"
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
track(eventInput: BaseEvent | string, eventProperties?: Record<string, any>, eventOptions?: EventOptions): AmplitudeReturn<Result>;
|
|
59
|
+
/**
|
|
60
|
+
* Alias for track()
|
|
61
|
+
*/
|
|
62
|
+
logEvent(eventInput: BaseEvent | string, eventProperties?: Record<string, any>, eventOptions?: EventOptions): AmplitudeReturn<Result>;
|
|
63
|
+
/**
|
|
64
|
+
* Sends an identify event containing user property operations
|
|
65
|
+
*
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const id = new Identify();
|
|
68
|
+
* id.set('colors', ['rose', 'gold']);
|
|
69
|
+
* identify(id);
|
|
70
|
+
*
|
|
71
|
+
* // alternatively, this tracking method is awaitable
|
|
72
|
+
* const result = await identify(id).promise;
|
|
73
|
+
* console.log(result.event); // {...}
|
|
74
|
+
* console.log(result.code); // 200
|
|
75
|
+
* console.log(result.message); // "Event tracked successfully"
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
identify(identify: IIdentify, eventOptions?: EventOptions): AmplitudeReturn<Result>;
|
|
79
|
+
/**
|
|
80
|
+
* Sends a group identify event containing group property operations.
|
|
81
|
+
*
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const id = new Identify();
|
|
84
|
+
* id.set('skills', ['js', 'ts']);
|
|
85
|
+
* const groupType = 'org';
|
|
86
|
+
* const groupName = 'engineering';
|
|
87
|
+
* groupIdentify(groupType, groupName, id);
|
|
88
|
+
*
|
|
89
|
+
* // alternatively, this tracking method is awaitable
|
|
90
|
+
* const result = await groupIdentify(groupType, groupName, id).promise;
|
|
91
|
+
* console.log(result.event); // {...}
|
|
92
|
+
* console.log(result.code); // 200
|
|
93
|
+
* console.log(result.message); // "Event tracked successfully"
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions): AmplitudeReturn<Result>;
|
|
97
|
+
/**
|
|
98
|
+
* Assigns a user to group
|
|
99
|
+
*
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const groupType = 'orgId';
|
|
102
|
+
* const groupName = '15';
|
|
103
|
+
* setGroup(groupType, groupName, { user_id: '12345' })
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
setGroup(groupType: string, groupName: string | string[], eventOptions?: EventOptions): AmplitudeReturn<Result>;
|
|
107
|
+
/**
|
|
108
|
+
* Sends a revenue event containing revenue property operations.
|
|
109
|
+
*
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const rev = new Revenue();
|
|
112
|
+
* rev.setRevenue(100);
|
|
113
|
+
* revenue(rev);
|
|
114
|
+
*
|
|
115
|
+
* // alternatively, this tracking method is awaitable
|
|
116
|
+
* const result = await revenue(rev).promise;
|
|
117
|
+
* console.log(result.event); // {...}
|
|
118
|
+
* console.log(result.code); // 200
|
|
119
|
+
* console.log(result.message); // "Event tracked successfully"
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
revenue(revenue: IRevenue, eventOptions?: EventOptions): AmplitudeReturn<Result>;
|
|
123
|
+
/**
|
|
124
|
+
* Sets a new optOut config value. This toggles event tracking on/off.
|
|
125
|
+
*
|
|
126
|
+
*```typescript
|
|
127
|
+
* // Stops tracking
|
|
128
|
+
* setOptOut(true);
|
|
129
|
+
*
|
|
130
|
+
* // Starts/resumes tracking
|
|
131
|
+
* setOptOut(false);
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
setOptOut(optOut: boolean): void;
|
|
135
|
+
/**
|
|
136
|
+
* Flush all unsent events.
|
|
137
|
+
*
|
|
138
|
+
*```typescript
|
|
139
|
+
* flush();
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
flush(): AmplitudeReturn<void>;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=core-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-client.d.ts","sourceRoot":"","sources":["../../../../src/types/client/core-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;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AM,CAAC,CAAC;IAEhH;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAEjF;;;;;;;;;;OAUG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAEjC;;;;;;OAMG;IACH,KAAK,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-client.js","sourceRoot":"","sources":["../../../../src/types/client/core-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../../utils/return-wrapper';\nimport { BaseEvent, EventOptions } from '../event/base-event';\nimport { Result } from '../result';\nimport { IIdentify } from '../../identify';\nimport { IRevenue } from '../../revenue';\nimport { Plugin } from '../plugin';\n\nexport interface PluginHost {\n plugin(name: string): Plugin | undefined;\n plugins<T extends Plugin>(pluginClass: new (...args: any[]) => T): T[];\n}\n\nexport interface CoreClient {\n /**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {\n * name: 'myPlugin',\n * type: 'enrichment',\n * setup(config: Config) {\n * return;\n * },\n * execute(context: Event) {\n * return context;\n * },\n * };\n * amplitude.add(plugin);\n * ```\n */\n add(plugin: Plugin): AmplitudeReturn<void>;\n\n /**\n * Removes a plugin.\n *\n * ```typescript\n * amplitude.remove('myPlugin');\n * ```\n */\n remove(pluginName: string): AmplitudeReturn<void>;\n\n /**\n * Tracks user-defined event, with specified type, optional event properties and optional overwrites.\n *\n * ```typescript\n * // event tracking with event type only\n * track('Page Load');\n *\n * // event tracking with event type and additional event properties\n * track('Page Load', { loadTime: 1000 });\n *\n * // event tracking with event type, additional event properties, and overwritten event options\n * track('Page Load', { loadTime: 1000 }, { sessionId: -1 });\n *\n * // alternatively, this tracking method is awaitable\n * const result = await track('Page Load').promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\n track(\n eventInput: BaseEvent | string,\n eventProperties?: Record<string, any>,\n eventOptions?: EventOptions,\n ): AmplitudeReturn<Result>;\n\n /**\n * Alias for track()\n */\n logEvent(\n eventInput: BaseEvent | string,\n eventProperties?: Record<string, any>,\n eventOptions?: EventOptions,\n ): AmplitudeReturn<Result>;\n\n /**\n * Sends an identify event containing user property operations\n *\n * ```typescript\n * const id = new Identify();\n * id.set('colors', ['rose', 'gold']);\n * identify(id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await identify(id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\n identify(identify: IIdentify, eventOptions?: EventOptions): AmplitudeReturn<Result>;\n\n /**\n * Sends a group identify event containing group property operations.\n *\n * ```typescript\n * const id = new Identify();\n * id.set('skills', ['js', 'ts']);\n * const groupType = 'org';\n * const groupName = 'engineering';\n * groupIdentify(groupType, groupName, id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await groupIdentify(groupType, groupName, id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\n groupIdentify(\n groupType: string,\n groupName: string | string[],\n identify: IIdentify,\n eventOptions?: EventOptions,\n ): AmplitudeReturn<Result>;\n\n /**\n * Assigns a user to group\n *\n * ```typescript\n * const groupType = 'orgId';\n * const groupName = '15';\n * setGroup(groupType, groupName, { user_id: '12345' })\n * ```\n */\n setGroup(groupType: string, groupName: string | string[], eventOptions?: EventOptions): AmplitudeReturn<Result>;\n\n /**\n * Sends a revenue event containing revenue property operations.\n *\n * ```typescript\n * const rev = new Revenue();\n * rev.setRevenue(100);\n * revenue(rev);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await revenue(rev).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\n revenue(revenue: IRevenue, eventOptions?: EventOptions): AmplitudeReturn<Result>;\n\n /**\n * Sets a new optOut config value. This toggles event tracking on/off.\n *\n *```typescript\n * // Stops tracking\n * setOptOut(true);\n *\n * // Starts/resumes tracking\n * setOptOut(false);\n * ```\n */\n setOptOut(optOut: boolean): void;\n\n /**\n * Flush all unsent events.\n *\n *```typescript\n * flush();\n * ```\n */\n flush(): AmplitudeReturn<void>;\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AmplitudeReturn } from '../../utils/return-wrapper';
|
|
2
|
+
import { NodeConfig, NodeOptions } from '../config/node-config';
|
|
3
|
+
import { CoreClient } from './core-client';
|
|
4
|
+
import { Plugin } from '../plugin';
|
|
5
|
+
export interface NodeClient extends CoreClient {
|
|
6
|
+
/**
|
|
7
|
+
* Initializes the Amplitude SDK with your apiKey, optional configurations.
|
|
8
|
+
* This method must be called before any other operations.
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* await init(API_KEY, options).promise;
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
init(apiKey: string, options?: NodeOptions): AmplitudeReturn<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Adds a new plugin.
|
|
17
|
+
*
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const plugin = {
|
|
20
|
+
* name: 'my-plugin',
|
|
21
|
+
* type: 'enrichment',
|
|
22
|
+
* async setup(config: NodeConfig, amplitude: NodeClient) {
|
|
23
|
+
* return;
|
|
24
|
+
* },
|
|
25
|
+
* async execute(event: Event) {
|
|
26
|
+
* return event;
|
|
27
|
+
* },
|
|
28
|
+
* };
|
|
29
|
+
* amplitude.add(plugin);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
add(plugin: Plugin<NodeClient, NodeConfig>): AmplitudeReturn<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=node-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../../../src/types/client/node-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEnE;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;CACpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../../../src/types/client/node-client.ts"],"names":[],"mappings":"","sourcesContent":["import { AmplitudeReturn } from '../../utils/return-wrapper';\nimport { NodeConfig, NodeOptions } from '../config/node-config';\nimport { CoreClient } from './core-client';\nimport { Plugin } from '../plugin';\n\nexport interface NodeClient extends CoreClient {\n /**\n * Initializes the Amplitude SDK with your apiKey, optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, options).promise;\n * ```\n */\n init(apiKey: string, options?: NodeOptions): AmplitudeReturn<void>;\n\n /**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {\n * name: 'my-plugin',\n * type: 'enrichment',\n * async setup(config: NodeConfig, amplitude: NodeClient) {\n * return;\n * },\n * async execute(event: Event) {\n * return event;\n * },\n * };\n * amplitude.add(plugin);\n * ```\n */\n add(plugin: Plugin<NodeClient, NodeConfig>): AmplitudeReturn<void>;\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { UserSession } from '
|
|
2
|
-
import { IdentityStorageType, Storage } from '
|
|
3
|
-
import { Transport } from '
|
|
4
|
-
import { IConfig } from '
|
|
5
|
-
import { ElementInteractionsOptions } from '
|
|
6
|
-
import { PageTrackingOptions } from '
|
|
7
|
-
import { NetworkTrackingOptions } from '
|
|
1
|
+
import { UserSession } from '../user-session';
|
|
2
|
+
import { IdentityStorageType, Storage } from '../storage';
|
|
3
|
+
import { Transport } from '../transport';
|
|
4
|
+
import { IConfig } from './core-config';
|
|
5
|
+
import { ElementInteractionsOptions } from '../element-interactions';
|
|
6
|
+
import { PageTrackingOptions } from '../page-view-tracking';
|
|
7
|
+
import { NetworkTrackingOptions } from '../network-tracking';
|
|
8
|
+
import { FrustrationInteractionsOptions } from '../frustration-interactions';
|
|
8
9
|
export interface BrowserConfig extends ExternalBrowserConfig, InternalBrowserConfig {
|
|
9
10
|
}
|
|
10
11
|
export interface ExternalBrowserConfig extends IConfig {
|
|
@@ -156,6 +157,12 @@ export interface AutocaptureOptions {
|
|
|
156
157
|
* @defaultValue `false`
|
|
157
158
|
*/
|
|
158
159
|
elementInteractions?: boolean | ElementInteractionsOptions;
|
|
160
|
+
/**
|
|
161
|
+
* Enables/disables frustration interactions tracking.
|
|
162
|
+
* @experimental This feature is experimental and may not be stable
|
|
163
|
+
* @defaultValue `false`
|
|
164
|
+
*/
|
|
165
|
+
frustrationInteractions?: boolean | FrustrationInteractionsOptions;
|
|
159
166
|
/**
|
|
160
167
|
* Enables/disables network request tracking or config with detailed network tracking options.
|
|
161
168
|
* @defaultValue `false`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-config.d.ts","sourceRoot":"","sources":["../../../../src/types/config/browser-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,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;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACvC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,KAAK,aAAa,GAAG,QAAQ,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAGxE,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,aAAa,CAAC;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-config.js","sourceRoot":"","sources":["../../../../src/types/config/browser-config.ts"],"names":[],"mappings":"","sourcesContent":["import { UserSession } from '../user-session';\nimport { IdentityStorageType, Storage } from '../storage';\nimport { Transport } from '../transport';\nimport { IConfig } from './core-config';\nimport { ElementInteractionsOptions } from '../element-interactions';\nimport { PageTrackingOptions } from '../page-view-tracking';\nimport { NetworkTrackingOptions } from '../network-tracking';\nimport { FrustrationInteractionsOptions } from '../frustration-interactions';\n\nexport interface BrowserConfig extends ExternalBrowserConfig, InternalBrowserConfig {}\n\nexport interface ExternalBrowserConfig extends IConfig {\n /**\n * An app version for events tracked. This can be the version of your application.\n * @defaultValue `undefined`\n */\n appVersion?: string;\n /**\n * @deprecated This property is deprecated and will be removed in future versions. Please migrate to using `autocapture` instead.\n * The default event tracking configuration.\n * See {@link https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events}.\n * @defaultValue `true`\n */\n defaultTracking?: boolean | DefaultTrackingOptions;\n /**\n * The configurations for auto-captured events.\n * See {@link https://www.docs.developers.amplitude.com/data/sdks/browser-2/autocapture/}.\n */\n autocapture?: boolean | AutocaptureOptions;\n /**\n * The identifier for the device running your application.\n * @defaultValue `UUID()`\n */\n deviceId?: string;\n /**\n * Configuration for cookie.\n */\n cookieOptions?: CookieOptions;\n /**\n * The storage for user identify.\n * @defaultValue `\"cookie\"`\n */\n identityStorage?: IdentityStorageType;\n /**\n * The partner identifier.\n * Amplitude requires the customer who built an event ingestion integration to add the partner identifier to partner_id.\n * @defaultValue `undefined`\n */\n partnerId?: string;\n /**\n * The custom Session ID for the current session.\n * @defaultValue `timestamp`\n */\n sessionId?: number;\n /**\n * The period of inactivity from the last tracked event before a session expires in milliseconds.\n * @defaultValue `1,800,000` (30 minutes)\n */\n sessionTimeout: number;\n /**\n * The configurations for tracking additional properties.\n * See {@link https://www.docs.developers.amplitude.com/data/sdks/browser-2/#optional-tracking}.\n */\n trackingOptions: TrackingOptions;\n /**\n * Network transport mechanism used to send events.\n * @defaultValue `\"fetch\"`\n */\n transport?: 'fetch' | 'xhr' | 'beacon';\n /**\n * The identifier for the user being tracked.\n * @defaultValue `undefined`\n */\n userId?: string;\n /**\n * User's Nth instance of performing a default Page Viewed event within a session.\n * Used for landing page analysis.\n */\n pageCounter?: number;\n /**\n * Whether to fetch remote configuration. The remote configuration can be updated in the Amplitude platform here:\n * https://app.amplitude.com/data/amplitude/{your_org_name}/settings/autocapture\n * @defaultValue `true`\n */\n fetchRemoteConfig?: boolean;\n /**\n * Captures network requests and responses.\n * @defaultValue `undefined`\n * @deprecated use autocapture.networkTracking instead\n */\n networkTrackingOptions?: NetworkTrackingOptions;\n}\n\ninterface InternalBrowserConfig {\n cookieStorage: Storage<UserSession>;\n lastEventTime?: number;\n lastEventId?: number;\n transportProvider: Transport;\n version?: string;\n}\n\n/**\n * @deprecated This interface is deprecated and will be removed in future versions. Please migrate to using `AutocaptureOptions` instead.\n */\nexport interface DefaultTrackingOptions {\n /**\n * Enables/disables marketing attribution tracking or config with detailed attribution options.\n * @defaultValue `true`\n */\n attribution?: boolean | AttributionOptions;\n /**\n * Enables/disables form downloads tracking.\n * @defaultValue `true`\n */\n fileDownloads?: boolean;\n /**\n * Enables/disables form interaction tracking.\n * @defaultValue `true`\n */\n formInteractions?: boolean;\n /**\n * Enables/disables default page view tracking.\n * @defaultValue `true`\n */\n pageViews?: boolean | PageTrackingOptions;\n /**\n * Enables/disables session tracking.\n * @defaultValue `true`\n */\n sessions?: boolean;\n}\n\nexport interface AutocaptureOptions {\n /**\n * Enables/disables marketing attribution tracking or config with detailed attribution options.\n * @defaultValue `true`\n */\n attribution?: boolean | AttributionOptions;\n /**\n * Enables/disables form downloads tracking.\n * @defaultValue `true`\n */\n fileDownloads?: boolean;\n /**\n * Enables/disables form interaction tracking.\n * @defaultValue `true`\n */\n formInteractions?: boolean;\n /**\n * Enables/disables default page view tracking.\n * @defaultValue `true`\n */\n pageViews?: boolean | PageTrackingOptions;\n /**\n * Enables/disables session tracking.\n * @defaultValue `true`\n */\n sessions?: boolean;\n /**\n * Enables/disables user interactions tracking.\n * @defaultValue `false`\n */\n elementInteractions?: boolean | ElementInteractionsOptions;\n /**\n * Enables/disables frustration interactions tracking.\n * @experimental This feature is experimental and may not be stable\n * @defaultValue `false`\n */\n frustrationInteractions?: boolean | FrustrationInteractionsOptions;\n /**\n * Enables/disables network request tracking or config with detailed network tracking options.\n * @defaultValue `false`\n */\n networkTracking?: boolean | NetworkTrackingOptions;\n}\n\nexport interface TrackingOptions {\n /**\n * Enables/disables ip address tracking.\n * @defaultValue `true`\n */\n ipAddress?: boolean;\n /**\n * Enables/disables language tracking.\n * @defaultValue `true`\n */\n language?: boolean;\n /**\n * Enables/disables plantform tracking.\n * @defaultValue `true`\n */\n platform?: boolean;\n}\n\nexport interface AttributionOptions {\n /**\n * The rules to determine which referrers are excluded from being tracked as traffic source.\n * @defaultValue `[/your-domain\\.com$/]`\n */\n excludeReferrers?: (string | RegExp)[];\n /**\n * The value to represent undefined/no initial campaign parameter for first-touch attribution.\n * @defaultValue `\"EMPTY\"`\n */\n initialEmptyValue?: string;\n /**\n * The flag of if Amplitude to start a new session if any campaign parameter changes.\n * @defaultValue `false`\n */\n resetSessionOnNewCampaign?: boolean;\n}\n\nexport interface CookieOptions {\n /**\n * The domain property of cookies created.\n * @defaultValue `Your top level domain`\n */\n domain?: string;\n /**\n * The expiration of cookies created in days.\n * @defaultValue `365`\n */\n expiration?: number;\n /**\n * How cookies are sent with cross-site requests.\n * @defaultValue `\"Lax\"`\n */\n sameSite?: 'Strict' | 'Lax' | 'None';\n /**\n * The flag of if send cookies over secure protocols.\n * @defaultValue `false`\n */\n secure?: boolean;\n /**\n * The flag of if upgrade the cookies created by maintenance Browser SDK.\n * @defaultValue `true`\n */\n upgrade?: boolean;\n}\n\ntype HiddenOptions = 'apiKey' | 'transportProvider' | 'requestMetadata';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface BrowserOptions extends Omit<Partial<ExternalBrowserConfig>, HiddenOptions> {}\n"]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { LogLevel } from '../loglevel';
|
|
2
|
+
import { ILogger } from '../../logger';
|
|
3
|
+
import { OfflineDisabled } from '../offline';
|
|
4
|
+
import { Plan } from '../event/plan';
|
|
5
|
+
import { IngestionMetadata } from '../event/ingestion-metadata';
|
|
6
|
+
import { ServerZoneType } from '../server-zone';
|
|
7
|
+
import { Transport } from '../transport';
|
|
8
|
+
import { Storage } from '../storage';
|
|
9
|
+
import { Event } from '../event/event';
|
|
10
|
+
export interface IConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Your Amplitude Project API key.
|
|
13
|
+
*/
|
|
14
|
+
apiKey: string;
|
|
15
|
+
/**
|
|
16
|
+
* The interval of uploading events to Amplitude in milliseconds.
|
|
17
|
+
*/
|
|
18
|
+
flushIntervalMillis: number;
|
|
19
|
+
/**
|
|
20
|
+
* The maximum number of retries for failed upload attempts. This is only applicable to retryable errors.
|
|
21
|
+
*/
|
|
22
|
+
flushMaxRetries: number;
|
|
23
|
+
/**
|
|
24
|
+
* The maximum number of events that are batched in a single upload attempt.
|
|
25
|
+
*/
|
|
26
|
+
flushQueueSize: number;
|
|
27
|
+
/**
|
|
28
|
+
* The instance name. For tracking events to multiple Amplitude projects in your application.
|
|
29
|
+
*/
|
|
30
|
+
instanceName?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Level of logs to be printed in the developer console.
|
|
33
|
+
* Valid values are `LogLevel.None`, `LogLevel.Error`, `LogLevel.Warn`, `LogLevel.Verbose`, `LogLevel.Debug`
|
|
34
|
+
*/
|
|
35
|
+
logLevel: LogLevel;
|
|
36
|
+
/**
|
|
37
|
+
* A custom Logger class to emit log messages to desired destination.
|
|
38
|
+
*/
|
|
39
|
+
loggerProvider: ILogger;
|
|
40
|
+
/**
|
|
41
|
+
* The minimum length for the value of userId and deviceId properties.
|
|
42
|
+
*/
|
|
43
|
+
minIdLength?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the SDK is connected to network.
|
|
46
|
+
*/
|
|
47
|
+
offline?: boolean | typeof OfflineDisabled;
|
|
48
|
+
/**
|
|
49
|
+
* The flag to opt this device out of Amplitude tracking.
|
|
50
|
+
* If this flag is set, no additional information will be stored for the user.
|
|
51
|
+
*/
|
|
52
|
+
optOut: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Tracking plan properties.
|
|
55
|
+
* Amplitude internal use.
|
|
56
|
+
*/
|
|
57
|
+
plan?: Plan;
|
|
58
|
+
/**
|
|
59
|
+
* Ingestion metadata.
|
|
60
|
+
* Amplitude internal use.
|
|
61
|
+
*/
|
|
62
|
+
ingestionMetadata?: IngestionMetadata;
|
|
63
|
+
/**
|
|
64
|
+
* The URL where events are upload to.
|
|
65
|
+
*/
|
|
66
|
+
serverUrl?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The Amplitude server zone.
|
|
69
|
+
* Set this to EU for Amplitude projects created in EU data center.
|
|
70
|
+
*/
|
|
71
|
+
serverZone?: ServerZoneType;
|
|
72
|
+
/**
|
|
73
|
+
* The storage provider to persist unsent events.
|
|
74
|
+
*/
|
|
75
|
+
storageProvider?: Storage<Event[]>;
|
|
76
|
+
/**
|
|
77
|
+
* A customer Transport Class for sending data to a server.
|
|
78
|
+
*/
|
|
79
|
+
transportProvider: Transport;
|
|
80
|
+
/**
|
|
81
|
+
* The flag of whether to upload events to Batch API instead of the default HTTP V2 API.
|
|
82
|
+
*/
|
|
83
|
+
useBatch: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Metrics of the SDK.
|
|
86
|
+
*/
|
|
87
|
+
requestMetadata?: IRequestMetadata;
|
|
88
|
+
}
|
|
89
|
+
export interface IRequestMetadata {
|
|
90
|
+
sdk: {
|
|
91
|
+
metrics: {
|
|
92
|
+
histogram: IHistogramOptions;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
recordHistogram<T extends HistogramKey>(key: T, value: IHistogramOptions[T]): void;
|
|
96
|
+
}
|
|
97
|
+
export interface IHistogramOptions {
|
|
98
|
+
remote_config_fetch_time_IDB?: number;
|
|
99
|
+
remote_config_fetch_time_API_success?: number;
|
|
100
|
+
remote_config_fetch_time_API_fail?: number;
|
|
101
|
+
}
|
|
102
|
+
export type HistogramKey = keyof IHistogramOptions;
|
|
103
|
+
export interface ConfigOptions extends Partial<IConfig> {
|
|
104
|
+
apiKey: string;
|
|
105
|
+
transportProvider: Transport;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=core-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-config.d.ts","sourceRoot":"","sources":["../../../../src/types/config/core-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC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AE,gBAAgB,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE;QACH,OAAO,EAAE;YACP,SAAS,EAAE,iBAAiB,CAAC;SAC9B,CAAC;KACH,CAAC;IAEF,eAAe,CAAC,CAAC,SAAS,YAAY,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACpF;AAED,MAAM,WAAW,iBAAiB;IAChC,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,oCAAoC,CAAC,EAAE,MAAM,CAAC;IAC9C,iCAAiC,CAAC,EAAE,MAAM,CAAC;CAC5C;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,aAAc,SAAQ,OAAO,CAAC,OAAO,CAAC;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,SAAS,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-config.js","sourceRoot":"","sources":["../../../../src/types/config/core-config.ts"],"names":[],"mappings":"","sourcesContent":["import { LogLevel } from '../loglevel';\nimport { ILogger } from '../../logger';\nimport { OfflineDisabled } from '../offline';\nimport { Plan } from '../event/plan';\nimport { IngestionMetadata } from '../event/ingestion-metadata';\nimport { ServerZoneType } from '../server-zone';\nimport { Transport } from '../transport';\nimport { Storage } from '../storage';\nimport { Event } from '../event/event';\n\nexport interface IConfig {\n /**\n * Your Amplitude Project API key.\n */\n apiKey: string;\n /**\n * The interval of uploading events to Amplitude in milliseconds.\n */\n flushIntervalMillis: number;\n /**\n * The maximum number of retries for failed upload attempts. This is only applicable to retryable errors.\n */\n flushMaxRetries: number;\n /**\n * The maximum number of events that are batched in a single upload attempt.\n */\n flushQueueSize: number;\n /**\n * The instance name. For tracking events to multiple Amplitude projects in your application.\n */\n instanceName?: string;\n /**\n * Level of logs to be printed in the developer console.\n * Valid values are `LogLevel.None`, `LogLevel.Error`, `LogLevel.Warn`, `LogLevel.Verbose`, `LogLevel.Debug`\n */\n logLevel: LogLevel;\n /**\n * A custom Logger class to emit log messages to desired destination.\n */\n loggerProvider: ILogger;\n /**\n * The minimum length for the value of userId and deviceId properties.\n */\n minIdLength?: number;\n /**\n * Whether the SDK is connected to network.\n */\n offline?: boolean | typeof OfflineDisabled;\n /**\n * The flag to opt this device out of Amplitude tracking.\n * If this flag is set, no additional information will be stored for the user.\n */\n optOut: boolean;\n /**\n * Tracking plan properties.\n * Amplitude internal use.\n */\n plan?: Plan;\n /**\n * Ingestion metadata.\n * Amplitude internal use.\n */\n ingestionMetadata?: IngestionMetadata;\n /**\n * The URL where events are upload to.\n */\n serverUrl?: string;\n /**\n * The Amplitude server zone.\n * Set this to EU for Amplitude projects created in EU data center.\n */\n serverZone?: ServerZoneType;\n /**\n * The storage provider to persist unsent events.\n */\n storageProvider?: Storage<Event[]>;\n /**\n * A customer Transport Class for sending data to a server.\n */\n transportProvider: Transport;\n /**\n * The flag of whether to upload events to Batch API instead of the default HTTP V2 API.\n */\n useBatch: boolean;\n /**\n * Metrics of the SDK.\n */\n requestMetadata?: IRequestMetadata;\n}\n\nexport interface IRequestMetadata {\n sdk: {\n metrics: {\n histogram: IHistogramOptions;\n };\n };\n\n recordHistogram<T extends HistogramKey>(key: T, value: IHistogramOptions[T]): void;\n}\n\nexport interface IHistogramOptions {\n remote_config_fetch_time_IDB?: number;\n remote_config_fetch_time_API_success?: number;\n remote_config_fetch_time_API_fail?: number;\n}\n\nexport type HistogramKey = keyof IHistogramOptions;\n\nexport interface ConfigOptions extends Partial<IConfig> {\n apiKey: string;\n transportProvider: Transport;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-config.d.ts","sourceRoot":"","sources":["../../../../src/types/config/node-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC;AAEjC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-config.js","sourceRoot":"","sources":["../../../../src/types/config/node-config.ts"],"names":[],"mappings":"","sourcesContent":["import { IConfig } from './core-config';\n\nexport type NodeConfig = IConfig;\n\nexport type NodeOptions = Omit<Partial<NodeConfig>, 'apiKey'>;\n"]}
|