@amplitude/analytics-core 0.4.0 → 0.6.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 +4 -4
- package/lib/cjs/config.d.ts.map +1 -1
- package/lib/cjs/config.js +11 -2
- package/lib/cjs/config.js.map +1 -1
- package/lib/cjs/core-client.d.ts +4 -2
- package/lib/cjs/core-client.d.ts.map +1 -1
- package/lib/cjs/core-client.js +9 -11
- package/lib/cjs/core-client.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/plugins/destination.d.ts +11 -9
- package/lib/cjs/plugins/destination.d.ts.map +1 -1
- package/lib/cjs/plugins/destination.js +63 -69
- package/lib/cjs/plugins/destination.js.map +1 -1
- package/lib/cjs/storage/memory.d.ts +6 -6
- package/lib/cjs/storage/memory.d.ts.map +1 -1
- package/lib/cjs/storage/memory.js +40 -7
- package/lib/cjs/storage/memory.js.map +1 -1
- package/lib/cjs/timeline.d.ts +12 -7
- package/lib/cjs/timeline.d.ts.map +1 -1
- package/lib/cjs/timeline.js +154 -138
- package/lib/cjs/timeline.js.map +1 -1
- package/lib/cjs/utils/event-builder.d.ts +2 -2
- package/lib/cjs/utils/event-builder.d.ts.map +1 -1
- package/lib/cjs/utils/event-builder.js +4 -10
- package/lib/cjs/utils/event-builder.js.map +1 -1
- package/lib/esm/config.d.ts +4 -4
- package/lib/esm/config.d.ts.map +1 -1
- package/lib/esm/config.js +11 -2
- package/lib/esm/config.js.map +1 -1
- package/lib/esm/core-client.d.ts +4 -2
- package/lib/esm/core-client.d.ts.map +1 -1
- package/lib/esm/core-client.js +10 -12
- package/lib/esm/core-client.js.map +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/plugins/destination.d.ts +11 -9
- package/lib/esm/plugins/destination.d.ts.map +1 -1
- package/lib/esm/plugins/destination.js +63 -69
- package/lib/esm/plugins/destination.js.map +1 -1
- package/lib/esm/storage/memory.d.ts +6 -6
- package/lib/esm/storage/memory.d.ts.map +1 -1
- package/lib/esm/storage/memory.js +40 -7
- package/lib/esm/storage/memory.js.map +1 -1
- package/lib/esm/timeline.d.ts +12 -7
- package/lib/esm/timeline.d.ts.map +1 -1
- package/lib/esm/timeline.js +153 -130
- package/lib/esm/timeline.js.map +1 -1
- package/lib/esm/utils/event-builder.d.ts +2 -2
- package/lib/esm/utils/event-builder.d.ts.map +1 -1
- package/lib/esm/utils/event-builder.js +4 -10
- package/lib/esm/utils/event-builder.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Storage } from '@amplitude/analytics-types';
|
|
2
2
|
export declare class MemoryStorage<T> implements Storage<T> {
|
|
3
3
|
memoryStorage: Map<string, T>;
|
|
4
|
-
isEnabled(): boolean
|
|
5
|
-
get(key: string): T | undefined
|
|
6
|
-
getRaw(key: string): string | undefined
|
|
7
|
-
set(key: string, value: T): void
|
|
8
|
-
remove(key: string): void
|
|
9
|
-
reset(): void
|
|
4
|
+
isEnabled(): Promise<boolean>;
|
|
5
|
+
get(key: string): Promise<T | undefined>;
|
|
6
|
+
getRaw(key: string): Promise<string | undefined>;
|
|
7
|
+
set(key: string, value: T): Promise<void>;
|
|
8
|
+
remove(key: string): Promise<void>;
|
|
9
|
+
reset(): Promise<void>;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/storage/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IACjD,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAa;
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/storage/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IACjD,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAa;IAEpC,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAI7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAKhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -1,27 +1,60 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.MemoryStorage = void 0;
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
3
4
|
var MemoryStorage = /** @class */ (function () {
|
|
4
5
|
function MemoryStorage() {
|
|
5
6
|
this.memoryStorage = new Map();
|
|
6
7
|
}
|
|
7
8
|
MemoryStorage.prototype.isEnabled = function () {
|
|
8
|
-
return
|
|
9
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
10
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
11
|
+
return [2 /*return*/, true];
|
|
12
|
+
});
|
|
13
|
+
});
|
|
9
14
|
};
|
|
10
15
|
MemoryStorage.prototype.get = function (key) {
|
|
11
|
-
return
|
|
16
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
17
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
18
|
+
return [2 /*return*/, this.memoryStorage.get(key)];
|
|
19
|
+
});
|
|
20
|
+
});
|
|
12
21
|
};
|
|
13
22
|
MemoryStorage.prototype.getRaw = function (key) {
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
24
|
+
var value;
|
|
25
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
26
|
+
switch (_a.label) {
|
|
27
|
+
case 0: return [4 /*yield*/, this.get(key)];
|
|
28
|
+
case 1:
|
|
29
|
+
value = _a.sent();
|
|
30
|
+
return [2 /*return*/, value ? JSON.stringify(value) : undefined];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
16
34
|
};
|
|
17
35
|
MemoryStorage.prototype.set = function (key, value) {
|
|
18
|
-
|
|
36
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
37
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
38
|
+
this.memoryStorage.set(key, value);
|
|
39
|
+
return [2 /*return*/];
|
|
40
|
+
});
|
|
41
|
+
});
|
|
19
42
|
};
|
|
20
43
|
MemoryStorage.prototype.remove = function (key) {
|
|
21
|
-
|
|
44
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
45
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
46
|
+
this.memoryStorage.delete(key);
|
|
47
|
+
return [2 /*return*/];
|
|
48
|
+
});
|
|
49
|
+
});
|
|
22
50
|
};
|
|
23
51
|
MemoryStorage.prototype.reset = function () {
|
|
24
|
-
|
|
52
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
53
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
54
|
+
this.memoryStorage.clear();
|
|
55
|
+
return [2 /*return*/];
|
|
56
|
+
});
|
|
57
|
+
});
|
|
25
58
|
};
|
|
26
59
|
return MemoryStorage;
|
|
27
60
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/storage/memory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/storage/memory.ts"],"names":[],"mappings":";;;AAEA;IAAA;QACE,kBAAa,GAAmB,IAAI,GAAG,EAAE,CAAC;IA0B5C,CAAC;IAxBO,iCAAS,GAAf;;;gBACE,sBAAO,IAAI,EAAC;;;KACb;IAEK,2BAAG,GAAT,UAAU,GAAW;;;gBACnB,sBAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAC;;;KACpC;IAEK,8BAAM,GAAZ,UAAa,GAAW;;;;;4BACR,qBAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;;wBAA3B,KAAK,GAAG,SAAmB;wBACjC,sBAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAC;;;;KAClD;IAEK,2BAAG,GAAT,UAAU,GAAW,EAAE,KAAQ;;;gBAC7B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;;;;KACpC;IAEK,8BAAM,GAAZ,UAAa,GAAW;;;gBACtB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;;;;KAChC;IAEK,6BAAK,GAAX;;;gBACE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;;;;KAC5B;IACH,oBAAC;AAAD,CAAC,AA3BD,IA2BC;AA3BY,sCAAa","sourcesContent":["import { Storage } from '@amplitude/analytics-types';\n\nexport class MemoryStorage<T> implements Storage<T> {\n memoryStorage: Map<string, T> = new Map();\n\n async isEnabled(): Promise<boolean> {\n return true;\n }\n\n async get(key: string): Promise<T | undefined> {\n return this.memoryStorage.get(key);\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const value = await this.get(key);\n return value ? JSON.stringify(value) : undefined;\n }\n\n async set(key: string, value: T): Promise<void> {\n this.memoryStorage.set(key, value);\n }\n\n async remove(key: string): Promise<void> {\n this.memoryStorage.delete(key);\n }\n\n async reset(): Promise<void> {\n this.memoryStorage.clear();\n }\n}\n"]}
|
package/lib/cjs/timeline.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { Config, Event, EventCallback, Plugin, Result } from '@amplitude/analytics-types';
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export declare class Timeline {
|
|
3
|
+
queue: [Event, EventCallback][];
|
|
4
|
+
applying: boolean;
|
|
5
|
+
flushing: boolean;
|
|
6
|
+
plugins: Plugin[];
|
|
7
|
+
register(plugin: Plugin, config: Config): Promise<void>;
|
|
8
|
+
deregister(pluginName: string): Promise<void>;
|
|
9
|
+
push(event: Event, config: Config): Promise<Result>;
|
|
10
|
+
scheduleApply(timeout: number): void;
|
|
11
|
+
apply(item: [Event, EventCallback] | undefined): Promise<void>;
|
|
12
|
+
flush(): Promise<void>;
|
|
13
|
+
}
|
|
9
14
|
//# sourceMappingURL=timeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAGN,KAAK,EACL,aAAa,EACb,MAAM,EAEN,MAAM,EACP,MAAM,4BAA4B,CAAC;AAIpC,qBAAa,QAAQ;IACnB,KAAK,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,EAAE,CAAM;IACrC,QAAQ,UAAS;IACjB,QAAQ,UAAS;IACjB,OAAO,EAAE,MAAM,EAAE,CAAM;IAEjB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK7C,UAAU,CAAC,UAAU,EAAE,MAAM;IAQ7B,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;IAWjC,aAAa,CAAC,OAAO,EAAE,MAAM;IAavB,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG,SAAS;IAwC9C,KAAK;CAgBZ"}
|
package/lib/cjs/timeline.js
CHANGED
|
@@ -1,149 +1,165 @@
|
|
|
1
|
-
var _this = this;
|
|
2
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
2
|
+
exports.Timeline = void 0;
|
|
4
3
|
var tslib_1 = require("tslib");
|
|
5
4
|
var analytics_types_1 = require("@amplitude/analytics-types");
|
|
6
5
|
var messages_1 = require("./messages");
|
|
7
6
|
var result_builder_1 = require("./utils/result-builder");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var scheduleApply = function (timeout) {
|
|
39
|
-
if (applying)
|
|
40
|
-
return;
|
|
41
|
-
applying = true;
|
|
42
|
-
setTimeout(function () {
|
|
43
|
-
void (0, exports.apply)().then(function () {
|
|
44
|
-
applying = false;
|
|
45
|
-
if (exports.queue.length > 0) {
|
|
46
|
-
(0, exports.scheduleApply)(0);
|
|
7
|
+
var Timeline = /** @class */ (function () {
|
|
8
|
+
function Timeline() {
|
|
9
|
+
this.queue = [];
|
|
10
|
+
this.applying = false;
|
|
11
|
+
this.flushing = false;
|
|
12
|
+
this.plugins = [];
|
|
13
|
+
}
|
|
14
|
+
Timeline.prototype.register = function (plugin, config) {
|
|
15
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
16
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
17
|
+
switch (_a.label) {
|
|
18
|
+
case 0: return [4 /*yield*/, plugin.setup(config)];
|
|
19
|
+
case 1:
|
|
20
|
+
_a.sent();
|
|
21
|
+
this.plugins.push(plugin);
|
|
22
|
+
return [2 /*return*/];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
Timeline.prototype.deregister = function (pluginName) {
|
|
28
|
+
this.plugins.splice(this.plugins.findIndex(function (plugin) { return plugin.name === pluginName; }), 1);
|
|
29
|
+
return Promise.resolve();
|
|
30
|
+
};
|
|
31
|
+
Timeline.prototype.push = function (event, config) {
|
|
32
|
+
var _this = this;
|
|
33
|
+
return new Promise(function (resolve) {
|
|
34
|
+
if (config.optOut) {
|
|
35
|
+
resolve((0, result_builder_1.buildResult)(event, 0, messages_1.OPT_OUT_MESSAGE));
|
|
36
|
+
return;
|
|
47
37
|
}
|
|
38
|
+
_this.queue.push([event, resolve]);
|
|
39
|
+
_this.scheduleApply(0);
|
|
48
40
|
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return [2 /*return*/];
|
|
41
|
+
};
|
|
42
|
+
Timeline.prototype.scheduleApply = function (timeout) {
|
|
43
|
+
var _this = this;
|
|
44
|
+
if (this.applying)
|
|
45
|
+
return;
|
|
46
|
+
this.applying = true;
|
|
47
|
+
setTimeout(function () {
|
|
48
|
+
void _this.apply(_this.queue.shift()).then(function () {
|
|
49
|
+
_this.applying = false;
|
|
50
|
+
if (_this.queue.length > 0) {
|
|
51
|
+
_this.scheduleApply(0);
|
|
61
52
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
53
|
+
});
|
|
54
|
+
}, timeout);
|
|
55
|
+
};
|
|
56
|
+
Timeline.prototype.apply = function (item) {
|
|
57
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
58
|
+
var _a, event, _b, resolve, before, before_1, before_1_1, plugin, e_1_1, enrichment, enrichment_1, enrichment_1_1, plugin, e_2_1, destination, executeDestinations;
|
|
59
|
+
var e_1, _c, e_2, _d;
|
|
60
|
+
return (0, tslib_1.__generator)(this, function (_e) {
|
|
61
|
+
switch (_e.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
if (!item) {
|
|
64
|
+
return [2 /*return*/];
|
|
65
|
+
}
|
|
66
|
+
_a = (0, tslib_1.__read)(item, 1), event = _a[0];
|
|
67
|
+
_b = (0, tslib_1.__read)(item, 2), resolve = _b[1];
|
|
68
|
+
before = this.plugins.filter(function (plugin) { return plugin.type === analytics_types_1.PluginType.BEFORE; });
|
|
69
|
+
_e.label = 1;
|
|
70
|
+
case 1:
|
|
71
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
72
|
+
before_1 = (0, tslib_1.__values)(before), before_1_1 = before_1.next();
|
|
73
|
+
_e.label = 2;
|
|
74
|
+
case 2:
|
|
75
|
+
if (!!before_1_1.done) return [3 /*break*/, 5];
|
|
76
|
+
plugin = before_1_1.value;
|
|
77
|
+
return [4 /*yield*/, plugin.execute((0, tslib_1.__assign)({}, event))];
|
|
78
|
+
case 3:
|
|
79
|
+
event = _e.sent();
|
|
80
|
+
_e.label = 4;
|
|
81
|
+
case 4:
|
|
82
|
+
before_1_1 = before_1.next();
|
|
83
|
+
return [3 /*break*/, 2];
|
|
84
|
+
case 5: return [3 /*break*/, 8];
|
|
85
|
+
case 6:
|
|
86
|
+
e_1_1 = _e.sent();
|
|
87
|
+
e_1 = { error: e_1_1 };
|
|
88
|
+
return [3 /*break*/, 8];
|
|
89
|
+
case 7:
|
|
90
|
+
try {
|
|
91
|
+
if (before_1_1 && !before_1_1.done && (_c = before_1.return)) _c.call(before_1);
|
|
92
|
+
}
|
|
93
|
+
finally { if (e_1) throw e_1.error; }
|
|
94
|
+
return [7 /*endfinally*/];
|
|
95
|
+
case 8:
|
|
96
|
+
enrichment = this.plugins.filter(function (plugin) { return plugin.type === analytics_types_1.PluginType.ENRICHMENT; });
|
|
97
|
+
_e.label = 9;
|
|
98
|
+
case 9:
|
|
99
|
+
_e.trys.push([9, 14, 15, 16]);
|
|
100
|
+
enrichment_1 = (0, tslib_1.__values)(enrichment), enrichment_1_1 = enrichment_1.next();
|
|
101
|
+
_e.label = 10;
|
|
102
|
+
case 10:
|
|
103
|
+
if (!!enrichment_1_1.done) return [3 /*break*/, 13];
|
|
104
|
+
plugin = enrichment_1_1.value;
|
|
105
|
+
return [4 /*yield*/, plugin.execute((0, tslib_1.__assign)({}, event))];
|
|
106
|
+
case 11:
|
|
107
|
+
event = _e.sent();
|
|
108
|
+
_e.label = 12;
|
|
109
|
+
case 12:
|
|
110
|
+
enrichment_1_1 = enrichment_1.next();
|
|
111
|
+
return [3 /*break*/, 10];
|
|
112
|
+
case 13: return [3 /*break*/, 16];
|
|
113
|
+
case 14:
|
|
114
|
+
e_2_1 = _e.sent();
|
|
115
|
+
e_2 = { error: e_2_1 };
|
|
116
|
+
return [3 /*break*/, 16];
|
|
117
|
+
case 15:
|
|
118
|
+
try {
|
|
119
|
+
if (enrichment_1_1 && !enrichment_1_1.done && (_d = enrichment_1.return)) _d.call(enrichment_1);
|
|
120
|
+
}
|
|
121
|
+
finally { if (e_2) throw e_2.error; }
|
|
122
|
+
return [7 /*endfinally*/];
|
|
123
|
+
case 16:
|
|
124
|
+
destination = this.plugins.filter(function (plugin) { return plugin.type === analytics_types_1.PluginType.DESTINATION; });
|
|
125
|
+
executeDestinations = destination.map(function (plugin) {
|
|
126
|
+
var eventClone = (0, tslib_1.__assign)({}, event);
|
|
127
|
+
return plugin.execute(eventClone).catch(function (e) { return (0, result_builder_1.buildResult)(eventClone, 0, String(e)); });
|
|
128
|
+
});
|
|
129
|
+
void Promise.all(executeDestinations).then(function (_a) {
|
|
130
|
+
var _b = (0, tslib_1.__read)(_a, 1), result = _b[0];
|
|
131
|
+
resolve(result);
|
|
132
|
+
});
|
|
133
|
+
return [2 /*return*/];
|
|
88
134
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return [3 /*break*/, 16];
|
|
113
|
-
case 15:
|
|
114
|
-
try {
|
|
115
|
-
if (enrichment_1_1 && !enrichment_1_1.done && (_d = enrichment_1.return)) _d.call(enrichment_1);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
Timeline.prototype.flush = function () {
|
|
139
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
140
|
+
var queue, destination, executeDestinations;
|
|
141
|
+
var _this = this;
|
|
142
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
143
|
+
switch (_a.label) {
|
|
144
|
+
case 0:
|
|
145
|
+
queue = this.queue;
|
|
146
|
+
this.queue = [];
|
|
147
|
+
return [4 /*yield*/, Promise.all(queue.map(function (item) { return _this.apply(item); }))];
|
|
148
|
+
case 1:
|
|
149
|
+
_a.sent();
|
|
150
|
+
destination = this.plugins.filter(function (plugin) { return plugin.type === analytics_types_1.PluginType.DESTINATION; });
|
|
151
|
+
executeDestinations = destination.map(function (plugin) {
|
|
152
|
+
return plugin.flush && plugin.flush();
|
|
153
|
+
});
|
|
154
|
+
return [4 /*yield*/, Promise.all(executeDestinations)];
|
|
155
|
+
case 2:
|
|
156
|
+
_a.sent();
|
|
157
|
+
return [2 /*return*/];
|
|
116
158
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return plugin.execute(eventClone).catch(function (e) { return (0, result_builder_1.buildResult)(eventClone, 0, String(e)); });
|
|
124
|
-
});
|
|
125
|
-
void Promise.all(executeDestinations).then(function (_a) {
|
|
126
|
-
var _b = (0, tslib_1.__read)(_a, 1), result = _b[0];
|
|
127
|
-
resolve(result);
|
|
128
|
-
});
|
|
129
|
-
return [2 /*return*/];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}); };
|
|
133
|
-
exports.apply = apply;
|
|
134
|
-
var flush = function (config) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
135
|
-
var destination, flushDestinations;
|
|
136
|
-
return (0, tslib_1.__generator)(this, function (_a) {
|
|
137
|
-
switch (_a.label) {
|
|
138
|
-
case 0:
|
|
139
|
-
destination = config.plugins.filter(function (plugin) { return plugin.type === analytics_types_1.PluginType.DESTINATION; });
|
|
140
|
-
flushDestinations = destination.map(function (plugin) { return plugin.flush && plugin.flush(true); });
|
|
141
|
-
return [4 /*yield*/, Promise.all(flushDestinations)];
|
|
142
|
-
case 1:
|
|
143
|
-
_a.sent();
|
|
144
|
-
return [2 /*return*/];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}); };
|
|
148
|
-
exports.flush = flush;
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
return Timeline;
|
|
163
|
+
}());
|
|
164
|
+
exports.Timeline = Timeline;
|
|
149
165
|
//# sourceMappingURL=timeline.js.map
|
package/lib/cjs/timeline.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":";;;AAAA,8DAUoC;AACpC,uCAA6C;AAC7C,yDAAqD;AAErD;IAAA;QACE,UAAK,GAA6B,EAAE,CAAC;QACrC,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAG,KAAK,CAAC;QACjB,YAAO,GAAa,EAAE,CAAC;IA+FzB,CAAC;IA7FO,2BAAQ,GAAd,UAAe,MAAc,EAAE,MAAc;;;;4BAC3C,qBAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAA;;wBAA1B,SAA0B,CAAC;wBAC3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;;;;KAC3B;IAED,6BAAU,GAAV,UAAW,UAAkB;QAC3B,IAAI,CAAC,OAAO,CAAC,MAAM,CACjB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,IAAI,KAAK,UAAU,EAA1B,CAA0B,CAAC,EAC9D,CAAC,CACF,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,uBAAI,GAAJ,UAAK,KAAY,EAAE,MAAc;QAAjC,iBASC;QARC,OAAO,IAAI,OAAO,CAAS,U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AAK,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,KAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAhB,CAAgB,CAAC,CAAC,EAAA;;wBAAxD,SAAwD,CAAC;wBAEnD,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CACrC,UAAC,MAAc,IAAkC,OAAA,MAAM,CAAC,IAAI,KAAK,4BAAU,CAAC,WAAW,EAAtC,CAAsC,CACxF,CAAC;wBAEI,mBAAmB,GAAG,WAAW,CAAC,GAAG,CAAC,UAAC,MAAM;4BACjD,OAAO,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;wBACxC,CAAC,CAAC,CAAC;wBAEH,qBAAM,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAA;;wBAAtC,SAAsC,CAAC;;;;;KACxC;IACH,eAAC;AAAD,CAAC,AAnGD,IAmGC;AAnGY,4BAAQ","sourcesContent":["import {\n BeforePlugin,\n Config,\n DestinationPlugin,\n EnrichmentPlugin,\n Event,\n EventCallback,\n Plugin,\n PluginType,\n Result,\n} from '@amplitude/analytics-types';\nimport { OPT_OUT_MESSAGE } from './messages';\nimport { buildResult } from './utils/result-builder';\n\nexport class Timeline {\n queue: [Event, EventCallback][] = [];\n applying = false;\n flushing = false;\n plugins: Plugin[] = [];\n\n async register(plugin: Plugin, config: Config) {\n await plugin.setup(config);\n this.plugins.push(plugin);\n }\n\n deregister(pluginName: string) {\n this.plugins.splice(\n this.plugins.findIndex((plugin) => plugin.name === pluginName),\n 1,\n );\n return Promise.resolve();\n }\n\n push(event: Event, config: Config) {\n return new Promise<Result>((resolve) => {\n if (config.optOut) {\n resolve(buildResult(event, 0, OPT_OUT_MESSAGE));\n return;\n }\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 === PluginType.BEFORE,\n );\n\n for (const plugin of before) {\n event = await plugin.execute({ ...event });\n }\n\n const enrichment = this.plugins.filter<EnrichmentPlugin>(\n (plugin: Plugin): plugin is EnrichmentPlugin => plugin.type === PluginType.ENRICHMENT,\n );\n\n for (const plugin of enrichment) {\n event = await plugin.execute({ ...event });\n }\n\n const destination = this.plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === PluginType.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 resolve(result);\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 === PluginType.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"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseEvent, TrackEvent, IdentifyEvent, GroupIdentifyEvent, Identify as IIdentify, Revenue, RevenueEvent, EventOptions } from '@amplitude/analytics-types';
|
|
2
2
|
export declare const createTrackEvent: (eventInput: BaseEvent | string, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => TrackEvent;
|
|
3
|
-
export declare const createIdentifyEvent: (
|
|
4
|
-
export declare const createGroupIdentifyEvent: (
|
|
3
|
+
export declare const createIdentifyEvent: (identify: IIdentify, eventOptions?: EventOptions | undefined) => IdentifyEvent;
|
|
4
|
+
export declare const createGroupIdentifyEvent: (groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => GroupIdentifyEvent;
|
|
5
5
|
export declare const createGroupEvent: (groupType: string, groupName: string | string[]) => IdentifyEvent;
|
|
6
6
|
export declare const createRevenueEvent: (revenue: Revenue, eventOptions?: EventOptions | undefined) => RevenueEvent;
|
|
7
7
|
//# sourceMappingURL=event-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/event-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,aAAa,EACb,kBAAkB,EAElB,QAAQ,IAAI,SAAS,EACrB,OAAO,EACP,YAAY,EACZ,YAAY,EACb,MAAM,4BAA4B,CAAC;AAGpC,eAAO,MAAM,gBAAgB,eACf,SAAS,GAAG,MAAM,iGAG7B,UAOF,CAAC;AAEF,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"event-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/event-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,aAAa,EACb,kBAAkB,EAElB,QAAQ,IAAI,SAAS,EACrB,OAAO,EACP,YAAY,EACZ,YAAY,EACb,MAAM,4BAA4B,CAAC;AAGpC,eAAO,MAAM,gBAAgB,eACf,SAAS,GAAG,MAAM,iGAG7B,UAOF,CAAC;AAEF,eAAO,MAAM,mBAAmB,aAAc,SAAS,8CAAgC,aAQtF,CAAC;AAEF,eAAO,MAAM,wBAAwB,cACxB,MAAM,aACN,MAAM,GAAG,MAAM,EAAE,YAClB,SAAS,8CAElB,kBAWF,CAAC;AAEF,eAAO,MAAM,gBAAgB,cAAe,MAAM,aAAa,MAAM,GAAG,MAAM,EAAE,kBAY/E,CAAC;AAEF,eAAO,MAAM,kBAAkB,YAAa,OAAO,8CAAgC,YAMlF,CAAC"}
|
|
@@ -8,22 +8,16 @@ var createTrackEvent = function (eventInput, eventProperties, eventOptions) {
|
|
|
8
8
|
return (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, baseEvent), eventOptions), (eventProperties && { event_properties: eventProperties }));
|
|
9
9
|
};
|
|
10
10
|
exports.createTrackEvent = createTrackEvent;
|
|
11
|
-
var createIdentifyEvent = function (
|
|
12
|
-
var identifyEvent = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, eventOptions), { event_type: analytics_types_1.SpecialEventType.IDENTIFY, user_properties: identify.getUserProperties()
|
|
13
|
-
if (deviceId !== undefined && deviceId.length > 0) {
|
|
14
|
-
identifyEvent.device_id = deviceId;
|
|
15
|
-
}
|
|
11
|
+
var createIdentifyEvent = function (identify, eventOptions) {
|
|
12
|
+
var identifyEvent = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, eventOptions), { event_type: analytics_types_1.SpecialEventType.IDENTIFY, user_properties: identify.getUserProperties() });
|
|
16
13
|
return identifyEvent;
|
|
17
14
|
};
|
|
18
15
|
exports.createIdentifyEvent = createIdentifyEvent;
|
|
19
|
-
var createGroupIdentifyEvent = function (
|
|
16
|
+
var createGroupIdentifyEvent = function (groupType, groupName, identify, eventOptions) {
|
|
20
17
|
var _a;
|
|
21
18
|
var groupIdentify = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, eventOptions), { event_type: analytics_types_1.SpecialEventType.GROUP_IDENTIFY, group_properties: identify.getUserProperties(), groups: (_a = {},
|
|
22
19
|
_a[groupType] = groupName,
|
|
23
|
-
_a)
|
|
24
|
-
if (deviceId !== undefined && deviceId.length > 0) {
|
|
25
|
-
groupIdentify.device_id = deviceId;
|
|
26
|
-
}
|
|
20
|
+
_a) });
|
|
27
21
|
return groupIdentify;
|
|
28
22
|
};
|
|
29
23
|
exports.createGroupIdentifyEvent = createGroupIdentifyEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-builder.js","sourceRoot":"","sources":["../../../src/utils/event-builder.ts"],"names":[],"mappings":";;;AAAA,8DAUoC;AACpC,wCAAuC;AAEhC,IAAM,gBAAgB,GAAG,UAC9B,UAA8B,EAC9B,eAAqC,EACrC,YAA2B;IAE3B,IAAM,SAAS,GAAc,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;IACtG,6EACK,SAAS,GACT,YAAY,GACZ,CAAC,eAAe,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC,EAC7D;AACJ,CAAC,CAAC;AAXW,QAAA,gBAAgB,oBAW3B;AAEK,IAAM,mBAAmB,GAAG,
|
|
1
|
+
{"version":3,"file":"event-builder.js","sourceRoot":"","sources":["../../../src/utils/event-builder.ts"],"names":[],"mappings":";;;AAAA,8DAUoC;AACpC,wCAAuC;AAEhC,IAAM,gBAAgB,GAAG,UAC9B,UAA8B,EAC9B,eAAqC,EACrC,YAA2B;IAE3B,IAAM,SAAS,GAAc,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;IACtG,6EACK,SAAS,GACT,YAAY,GACZ,CAAC,eAAe,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC,EAC7D;AACJ,CAAC,CAAC;AAXW,QAAA,gBAAgB,oBAW3B;AAEK,IAAM,mBAAmB,GAAG,UAAC,QAAmB,EAAE,YAA2B;IAClF,IAAM,aAAa,mDACd,YAAY,KACf,UAAU,EAAE,kCAAgB,CAAC,QAAQ,EACrC,eAAe,EAAE,QAAQ,CAAC,iBAAiB,EAAE,GAC9C,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B;AAEK,IAAM,wBAAwB,GAAG,UACtC,SAAiB,EACjB,SAA4B,EAC5B,QAAmB,EACnB,YAA2B;;IAE3B,IAAM,aAAa,mDACd,YAAY,KACf,UAAU,EAAE,kCAAgB,CAAC,cAAc,EAC3C,gBAAgB,EAAE,QAAQ,CAAC,iBAAiB,EAAE,EAC9C,MAAM;YACJ,GAAC,SAAS,IAAG,SAAS;kBAEzB,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAhBW,QAAA,wBAAwB,4BAgBnC;AAEK,IAAM,gBAAgB,GAAG,UAAC,SAAiB,EAAE,SAA4B;;IAC9E,IAAM,QAAQ,GAAG,IAAI,mBAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAEnC,IAAM,UAAU,GAAkB;QAChC,UAAU,EAAE,kCAAgB,CAAC,QAAQ;QACrC,eAAe,EAAE,QAAQ,CAAC,iBAAiB,EAAE;QAC7C,MAAM;YACJ,GAAC,SAAS,IAAG,SAAS;eACvB;KACF,CAAC;IACF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAZW,QAAA,gBAAgB,oBAY3B;AAEK,IAAM,kBAAkB,GAAG,UAAC,OAAgB,EAAE,YAA2B;IAC9E,uDACK,YAAY,KACf,UAAU,EAAE,kCAAgB,CAAC,OAAO,EACpC,gBAAgB,EAAE,OAAO,CAAC,kBAAkB,EAAE,IAC9C;AACJ,CAAC,CAAC;AANW,QAAA,kBAAkB,sBAM7B","sourcesContent":["import {\n BaseEvent,\n TrackEvent,\n IdentifyEvent,\n GroupIdentifyEvent,\n SpecialEventType,\n Identify as IIdentify,\n Revenue,\n RevenueEvent,\n EventOptions,\n} from '@amplitude/analytics-types';\nimport { Identify } from '../identify';\n\nexport const createTrackEvent = (\n eventInput: BaseEvent | string,\n eventProperties?: Record<string, any>,\n eventOptions?: EventOptions,\n): TrackEvent => {\n const baseEvent: BaseEvent = typeof eventInput === 'string' ? { event_type: eventInput } : eventInput;\n return {\n ...baseEvent,\n ...eventOptions,\n ...(eventProperties && { event_properties: eventProperties }),\n };\n};\n\nexport const createIdentifyEvent = (identify: IIdentify, eventOptions?: EventOptions): IdentifyEvent => {\n const identifyEvent: IdentifyEvent = {\n ...eventOptions,\n event_type: SpecialEventType.IDENTIFY,\n user_properties: identify.getUserProperties(),\n };\n\n return identifyEvent;\n};\n\nexport const createGroupIdentifyEvent = (\n groupType: string,\n groupName: string | string[],\n identify: IIdentify,\n eventOptions?: EventOptions,\n): GroupIdentifyEvent => {\n const groupIdentify: GroupIdentifyEvent = {\n ...eventOptions,\n event_type: SpecialEventType.GROUP_IDENTIFY,\n group_properties: identify.getUserProperties(),\n groups: {\n [groupType]: groupName,\n },\n };\n\n return groupIdentify;\n};\n\nexport const createGroupEvent = (groupType: string, groupName: string | string[]) => {\n const identify = new Identify();\n identify.set(groupType, groupName);\n\n const groupEvent: IdentifyEvent = {\n event_type: SpecialEventType.IDENTIFY,\n user_properties: identify.getUserProperties(),\n groups: {\n [groupType]: groupName,\n },\n };\n return groupEvent;\n};\n\nexport const createRevenueEvent = (revenue: Revenue, eventOptions?: EventOptions): RevenueEvent => {\n return {\n ...eventOptions,\n event_type: SpecialEventType.REVENUE,\n event_properties: revenue.getEventProperties(),\n };\n};\n"]}
|
package/lib/esm/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event, Config as IConfig, Logger as ILogger, InitOptions, LogLevel, Storage, Transport, Plan,
|
|
1
|
+
import { Event, Config as IConfig, Logger as ILogger, InitOptions, LogLevel, Storage, Transport, Plan, ServerZone } from '@amplitude/analytics-types';
|
|
2
2
|
import { Logger } from './logger';
|
|
3
3
|
export declare const getDefaultConfig: () => {
|
|
4
4
|
flushMaxRetries: number;
|
|
@@ -8,7 +8,6 @@ export declare const getDefaultConfig: () => {
|
|
|
8
8
|
loggerProvider: Logger;
|
|
9
9
|
saveEvents: boolean;
|
|
10
10
|
optOut: boolean;
|
|
11
|
-
plugins: never[];
|
|
12
11
|
serverUrl: string;
|
|
13
12
|
serverZone: ServerZone;
|
|
14
13
|
useBatch: boolean;
|
|
@@ -22,14 +21,15 @@ export declare class Config implements IConfig {
|
|
|
22
21
|
logLevel: LogLevel;
|
|
23
22
|
minIdLength?: number;
|
|
24
23
|
plan?: Plan;
|
|
25
|
-
plugins: Plugin[];
|
|
26
|
-
optOut: boolean;
|
|
27
24
|
saveEvents: boolean;
|
|
28
25
|
serverUrl: string | undefined;
|
|
29
26
|
serverZone?: ServerZone;
|
|
30
27
|
transportProvider: Transport;
|
|
31
28
|
storageProvider: Storage<Event[]>;
|
|
32
29
|
useBatch: boolean;
|
|
30
|
+
private _optOut;
|
|
31
|
+
get optOut(): boolean;
|
|
32
|
+
set optOut(optOut: boolean);
|
|
33
33
|
constructor(options: InitOptions<IConfig>);
|
|
34
34
|
}
|
|
35
35
|
export declare const getServerUrl: (serverZone: ServerZone, useBatch: boolean) => "https://api2.amplitude.com/2/httpapi" | "https://api.eu.amplitude.com/2/httpapi" | "https://api2.amplitude.com/batch" | "https://api.eu.amplitude.com/batch";
|
package/lib/esm/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,IAAI,EACJ,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,IAAI,EACJ,UAAU,EACX,MAAM,4BAA4B,CAAC;AAQpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;;;;;CAW3B,CAAC;AAEH,qBAAa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