@aws-amplify/analytics 7.0.1-console-preview.11cf989.0 → 7.0.1-console-preview.4ae78ed.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/errors/assertValidationError.d.ts +1 -1
- package/lib/errors/assertValidationError.js +7 -3
- package/lib/errors/validation.d.ts +3 -1
- package/lib/errors/validation.js +8 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/providers/kinesis/apis/flushEvents.d.ts +8 -0
- package/lib/providers/kinesis/apis/flushEvents.js +37 -0
- package/lib/providers/kinesis/apis/index.d.ts +1 -0
- package/lib/providers/kinesis/apis/index.js +3 -1
- package/lib/providers/kinesis/apis/record.d.ts +1 -1
- package/lib/providers/kinesis/apis/record.js +40 -2
- package/lib/providers/kinesis/index.d.ts +1 -1
- package/lib/providers/kinesis/index.js +2 -1
- package/lib/providers/kinesis/types/buffer.d.ts +15 -0
- package/lib/providers/kinesis/types/buffer.js +4 -0
- package/lib/providers/kinesis/types/index.d.ts +1 -0
- package/lib/providers/kinesis/types/inputs.d.ts +6 -1
- package/lib/providers/kinesis/utils/constants.d.ts +6 -0
- package/lib/providers/kinesis/utils/constants.js +11 -0
- package/lib/providers/kinesis/utils/getEventBuffer.d.ts +3 -0
- package/lib/providers/kinesis/utils/getEventBuffer.js +103 -0
- package/lib/providers/kinesis/utils/resolveConfig.d.ts +7 -0
- package/lib/providers/kinesis/utils/resolveConfig.js +24 -0
- package/lib/providers/kinesis-firehose/apis/flushEvents.d.ts +8 -0
- package/lib/providers/kinesis-firehose/apis/flushEvents.js +36 -0
- package/lib/providers/kinesis-firehose/apis/index.d.ts +1 -0
- package/lib/providers/kinesis-firehose/apis/index.js +3 -1
- package/lib/providers/kinesis-firehose/apis/record.d.ts +1 -1
- package/lib/providers/kinesis-firehose/apis/record.js +37 -2
- package/lib/providers/kinesis-firehose/index.d.ts +1 -1
- package/lib/providers/kinesis-firehose/index.js +2 -1
- package/lib/providers/kinesis-firehose/types/buffer.d.ts +15 -0
- package/lib/providers/kinesis-firehose/types/buffer.js +4 -0
- package/lib/providers/kinesis-firehose/types/index.d.ts +1 -0
- package/lib/providers/kinesis-firehose/types/inputs.d.ts +5 -1
- package/lib/providers/kinesis-firehose/utils/constants.d.ts +6 -0
- package/lib/providers/kinesis-firehose/utils/constants.js +11 -0
- package/lib/providers/kinesis-firehose/utils/getEventBuffer.d.ts +3 -0
- package/lib/providers/kinesis-firehose/utils/getEventBuffer.js +100 -0
- package/lib/providers/kinesis-firehose/utils/index.d.ts +2 -0
- package/lib/providers/kinesis-firehose/utils/index.js +9 -0
- package/lib/providers/kinesis-firehose/utils/resolveConfig.d.ts +7 -0
- package/lib/providers/kinesis-firehose/utils/resolveConfig.js +24 -0
- package/lib/providers/personalize/apis/flushEvents.d.ts +8 -0
- package/lib/providers/personalize/apis/flushEvents.js +35 -0
- package/lib/providers/personalize/apis/index.d.ts +1 -0
- package/lib/providers/personalize/apis/index.js +3 -1
- package/lib/providers/personalize/apis/record.d.ts +1 -1
- package/lib/providers/personalize/apis/record.js +65 -2
- package/lib/providers/personalize/index.d.ts +1 -1
- package/lib/providers/personalize/index.js +2 -1
- package/lib/providers/personalize/types/buffer.d.ts +16 -0
- package/lib/providers/personalize/types/buffer.js +4 -0
- package/lib/providers/personalize/types/index.d.ts +2 -1
- package/lib/providers/personalize/types/inputs.d.ts +7 -1
- package/lib/providers/personalize/utils/autoTrackMedia.d.ts +10 -0
- package/lib/providers/personalize/utils/autoTrackMedia.js +182 -0
- package/lib/providers/personalize/utils/cachedSession.d.ts +5 -0
- package/lib/providers/personalize/utils/cachedSession.js +52 -0
- package/lib/providers/personalize/utils/constants.d.ts +7 -0
- package/lib/providers/personalize/utils/constants.js +12 -0
- package/lib/providers/personalize/utils/getEventBuffer.d.ts +3 -0
- package/lib/providers/personalize/utils/getEventBuffer.js +100 -0
- package/lib/providers/personalize/utils/index.d.ts +5 -0
- package/lib/providers/personalize/utils/index.js +17 -0
- package/lib/providers/personalize/utils/resolveConfig.d.ts +7 -0
- package/lib/providers/personalize/utils/resolveConfig.js +25 -0
- package/lib/providers/pinpoint/apis/flushEvents.d.ts +8 -0
- package/lib/providers/pinpoint/apis/flushEvents.js +27 -0
- package/lib/providers/pinpoint/apis/identifyUser.d.ts +2 -2
- package/lib/providers/pinpoint/apis/identifyUser.js +3 -3
- package/lib/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib/providers/pinpoint/apis/index.js +3 -1
- package/lib/providers/pinpoint/index.d.ts +1 -1
- package/lib/providers/pinpoint/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/kinesis.d.ts +8 -0
- package/lib/types/kinesis.js +4 -0
- package/lib/utils/eventBuffer/EventBuffer.d.ts +16 -0
- package/lib/utils/eventBuffer/EventBuffer.js +91 -0
- package/lib/utils/eventBuffer/index.d.ts +2 -0
- package/lib/utils/eventBuffer/index.js +7 -0
- package/lib/utils/eventBuffer/types.d.ts +8 -0
- package/lib/utils/eventBuffer/types.js +4 -0
- package/lib/utils/groupBy.d.ts +1 -0
- package/lib/utils/groupBy.js +15 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +7 -1
- package/lib/utils/resolveCredentials.d.ts +9 -0
- package/lib/utils/resolveCredentials.js +21 -0
- package/lib-esm/errors/assertValidationError.d.ts +1 -1
- package/lib-esm/errors/assertValidationError.js +7 -3
- package/lib-esm/errors/validation.d.ts +3 -1
- package/lib-esm/errors/validation.js +8 -0
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/index.js +1 -1
- package/lib-esm/providers/kinesis/apis/flushEvents.d.ts +8 -0
- package/lib-esm/providers/kinesis/apis/flushEvents.js +33 -0
- package/lib-esm/providers/kinesis/apis/index.d.ts +1 -0
- package/lib-esm/providers/kinesis/apis/index.js +1 -0
- package/lib-esm/providers/kinesis/apis/record.d.ts +1 -1
- package/lib-esm/providers/kinesis/apis/record.js +40 -2
- package/lib-esm/providers/kinesis/index.d.ts +1 -1
- package/lib-esm/providers/kinesis/index.js +1 -1
- package/lib-esm/providers/kinesis/types/buffer.d.ts +15 -0
- package/lib-esm/providers/kinesis/types/buffer.js +3 -0
- package/lib-esm/providers/kinesis/types/index.d.ts +1 -0
- package/lib-esm/providers/kinesis/types/inputs.d.ts +6 -1
- package/lib-esm/providers/kinesis/utils/constants.d.ts +6 -0
- package/lib-esm/providers/kinesis/utils/constants.js +8 -0
- package/lib-esm/providers/kinesis/utils/getEventBuffer.d.ts +3 -0
- package/lib-esm/providers/kinesis/utils/getEventBuffer.js +99 -0
- package/lib-esm/providers/kinesis/utils/resolveConfig.d.ts +7 -0
- package/lib-esm/providers/kinesis/utils/resolveConfig.js +20 -0
- package/lib-esm/providers/kinesis-firehose/apis/flushEvents.d.ts +8 -0
- package/lib-esm/providers/kinesis-firehose/apis/flushEvents.js +32 -0
- package/lib-esm/providers/kinesis-firehose/apis/index.d.ts +1 -0
- package/lib-esm/providers/kinesis-firehose/apis/index.js +1 -0
- package/lib-esm/providers/kinesis-firehose/apis/record.d.ts +1 -1
- package/lib-esm/providers/kinesis-firehose/apis/record.js +37 -2
- package/lib-esm/providers/kinesis-firehose/index.d.ts +1 -1
- package/lib-esm/providers/kinesis-firehose/index.js +1 -1
- package/lib-esm/providers/kinesis-firehose/types/buffer.d.ts +15 -0
- package/lib-esm/providers/kinesis-firehose/types/buffer.js +3 -0
- package/lib-esm/providers/kinesis-firehose/types/index.d.ts +1 -0
- package/lib-esm/providers/kinesis-firehose/types/inputs.d.ts +5 -1
- package/lib-esm/providers/kinesis-firehose/utils/constants.d.ts +6 -0
- package/lib-esm/providers/kinesis-firehose/utils/constants.js +8 -0
- package/lib-esm/providers/kinesis-firehose/utils/getEventBuffer.d.ts +3 -0
- package/lib-esm/providers/kinesis-firehose/utils/getEventBuffer.js +96 -0
- package/lib-esm/providers/kinesis-firehose/utils/index.d.ts +2 -0
- package/lib-esm/providers/kinesis-firehose/utils/index.js +4 -0
- package/lib-esm/providers/kinesis-firehose/utils/resolveConfig.d.ts +7 -0
- package/lib-esm/providers/kinesis-firehose/utils/resolveConfig.js +20 -0
- package/lib-esm/providers/personalize/apis/flushEvents.d.ts +8 -0
- package/lib-esm/providers/personalize/apis/flushEvents.js +31 -0
- package/lib-esm/providers/personalize/apis/index.d.ts +1 -0
- package/lib-esm/providers/personalize/apis/index.js +1 -0
- package/lib-esm/providers/personalize/apis/record.d.ts +1 -1
- package/lib-esm/providers/personalize/apis/record.js +65 -2
- package/lib-esm/providers/personalize/index.d.ts +1 -1
- package/lib-esm/providers/personalize/index.js +1 -1
- package/lib-esm/providers/personalize/types/buffer.d.ts +16 -0
- package/lib-esm/providers/personalize/types/buffer.js +3 -0
- package/lib-esm/providers/personalize/types/index.d.ts +2 -1
- package/lib-esm/providers/personalize/types/inputs.d.ts +7 -1
- package/lib-esm/providers/personalize/utils/autoTrackMedia.d.ts +10 -0
- package/lib-esm/providers/personalize/utils/autoTrackMedia.js +178 -0
- package/lib-esm/providers/personalize/utils/cachedSession.d.ts +5 -0
- package/lib-esm/providers/personalize/utils/cachedSession.js +47 -0
- package/lib-esm/providers/personalize/utils/constants.d.ts +7 -0
- package/lib-esm/providers/personalize/utils/constants.js +9 -0
- package/lib-esm/providers/personalize/utils/getEventBuffer.d.ts +3 -0
- package/lib-esm/providers/personalize/utils/getEventBuffer.js +96 -0
- package/lib-esm/providers/personalize/utils/index.d.ts +5 -0
- package/lib-esm/providers/personalize/utils/index.js +7 -0
- package/lib-esm/providers/personalize/utils/resolveConfig.d.ts +7 -0
- package/lib-esm/providers/personalize/utils/resolveConfig.js +21 -0
- package/lib-esm/providers/pinpoint/apis/flushEvents.d.ts +8 -0
- package/lib-esm/providers/pinpoint/apis/flushEvents.js +23 -0
- package/lib-esm/providers/pinpoint/apis/identifyUser.d.ts +2 -2
- package/lib-esm/providers/pinpoint/apis/identifyUser.js +3 -3
- package/lib-esm/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/apis/index.js +1 -0
- package/lib-esm/providers/pinpoint/index.d.ts +1 -1
- package/lib-esm/providers/pinpoint/index.js +1 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/index.d.ts +1 -0
- package/lib-esm/types/kinesis.d.ts +8 -0
- package/lib-esm/types/kinesis.js +3 -0
- package/lib-esm/utils/eventBuffer/EventBuffer.d.ts +16 -0
- package/lib-esm/utils/eventBuffer/EventBuffer.js +88 -0
- package/lib-esm/utils/eventBuffer/index.d.ts +2 -0
- package/lib-esm/utils/eventBuffer/index.js +3 -0
- package/lib-esm/utils/eventBuffer/types.d.ts +8 -0
- package/lib-esm/utils/eventBuffer/types.js +3 -0
- package/lib-esm/utils/groupBy.d.ts +1 -0
- package/lib-esm/utils/groupBy.js +11 -0
- package/lib-esm/utils/index.d.ts +3 -0
- package/lib-esm/utils/index.js +3 -0
- package/lib-esm/utils/resolveCredentials.d.ts +9 -0
- package/lib-esm/utils/resolveCredentials.js +17 -0
- package/package.json +5 -4
- package/src/errors/assertValidationError.ts +9 -3
- package/src/errors/validation.ts +8 -0
- package/src/index.ts +1 -0
- package/src/providers/kinesis/apis/flushEvents.ts +42 -0
- package/src/providers/kinesis/apis/index.ts +1 -0
- package/src/providers/kinesis/apis/record.ts +54 -2
- package/src/providers/kinesis/index.ts +1 -1
- package/src/providers/kinesis/types/buffer.ts +20 -0
- package/src/providers/kinesis/types/index.ts +1 -0
- package/src/providers/kinesis/types/inputs.ts +7 -1
- package/src/providers/kinesis/utils/constants.ts +9 -0
- package/src/providers/kinesis/utils/getEventBuffer.ts +110 -0
- package/src/providers/kinesis/utils/resolveConfig.ts +36 -0
- package/src/providers/kinesis-firehose/apis/flushEvents.ts +41 -0
- package/src/providers/kinesis-firehose/apis/index.ts +1 -0
- package/src/providers/kinesis-firehose/apis/record.ts +47 -2
- package/src/providers/kinesis-firehose/index.ts +1 -1
- package/src/providers/kinesis-firehose/types/buffer.ts +20 -0
- package/src/providers/kinesis-firehose/types/index.ts +5 -0
- package/src/providers/kinesis-firehose/types/inputs.ts +6 -1
- package/src/providers/kinesis-firehose/utils/constants.ts +9 -0
- package/src/providers/kinesis-firehose/utils/getEventBuffer.ts +118 -0
- package/src/providers/kinesis-firehose/utils/index.ts +5 -0
- package/src/providers/kinesis-firehose/utils/resolveConfig.ts +36 -0
- package/src/providers/personalize/apis/flushEvents.ts +39 -0
- package/src/providers/personalize/apis/index.ts +1 -0
- package/src/providers/personalize/apis/record.ts +98 -2
- package/src/providers/personalize/index.ts +1 -1
- package/src/providers/personalize/types/buffer.ts +21 -0
- package/src/providers/personalize/types/index.ts +2 -1
- package/src/providers/personalize/types/inputs.ts +8 -1
- package/src/providers/personalize/utils/autoTrackMedia.ts +231 -0
- package/src/providers/personalize/utils/cachedSession.ts +67 -0
- package/src/providers/personalize/utils/constants.ts +12 -0
- package/src/providers/personalize/utils/getEventBuffer.ts +111 -0
- package/src/providers/personalize/utils/index.ts +11 -0
- package/src/providers/personalize/utils/resolveConfig.ts +41 -0
- package/src/providers/pinpoint/apis/flushEvents.ts +34 -0
- package/src/providers/pinpoint/apis/identifyUser.ts +3 -3
- package/src/providers/pinpoint/apis/index.ts +1 -0
- package/src/providers/pinpoint/index.ts +1 -1
- package/src/types/index.ts +2 -0
- package/src/types/kinesis.ts +13 -0
- package/src/utils/eventBuffer/EventBuffer.ts +84 -0
- package/src/utils/eventBuffer/index.ts +5 -0
- package/src/utils/eventBuffer/types.ts +12 -0
- package/src/utils/groupBy.ts +12 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/resolveCredentials.ts +14 -0
package/lib/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { AutoTrackAttributes, AutoTrackEventOpts, AutoTrackPageViewOpts, AutoTrackSessionOpts, EventAttributes, EventMetrics, EventTrackOpts, PageViewTrackOpts, SessionTrackOpts, } from './analytics';
|
|
2
2
|
export { AnalyticsServiceOptions } from './options';
|
|
3
3
|
export { AnalyticsIdentifyUserInput } from './inputs';
|
|
4
|
+
export { KinesisStream, KinesisShard, KinesisEventData } from './kinesis';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EventBufferConfig, IAnalyticsClient } from './';
|
|
2
|
+
export declare class EventBuffer<T> {
|
|
3
|
+
private list;
|
|
4
|
+
private readonly config;
|
|
5
|
+
private getAnalyticsClient;
|
|
6
|
+
private timer?;
|
|
7
|
+
constructor(config: EventBufferConfig, getAnalyticsClient: () => IAnalyticsClient<T>);
|
|
8
|
+
append(...events: T[]): void;
|
|
9
|
+
flushAll(): Promise<void>;
|
|
10
|
+
release(): void;
|
|
11
|
+
get length(): number;
|
|
12
|
+
private head;
|
|
13
|
+
private insertAtBeginning;
|
|
14
|
+
private startEventLoop;
|
|
15
|
+
private submitEvents;
|
|
16
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.EventBuffer = void 0;
|
|
6
|
+
var tslib_1 = require("tslib");
|
|
7
|
+
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
|
+
var logger = new utils_1.ConsoleLogger('EventBuffer');
|
|
9
|
+
var EventBuffer = /** @class */ (function () {
|
|
10
|
+
function EventBuffer(config, getAnalyticsClient) {
|
|
11
|
+
this.list = [];
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.getAnalyticsClient = getAnalyticsClient;
|
|
14
|
+
this.startEventLoop();
|
|
15
|
+
}
|
|
16
|
+
EventBuffer.prototype.append = function () {
|
|
17
|
+
var e_1, _a;
|
|
18
|
+
var events = [];
|
|
19
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
20
|
+
events[_i] = arguments[_i];
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
for (var events_1 = tslib_1.__values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) {
|
|
24
|
+
var event_1 = events_1_1.value;
|
|
25
|
+
if (this.list.length + 1 > this.config.bufferSize) {
|
|
26
|
+
logger.debug("Exceed ".concat(typeof event_1, " event buffer limits, event dropped"));
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
this.list.push(event_1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33
|
+
finally {
|
|
34
|
+
try {
|
|
35
|
+
if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1);
|
|
36
|
+
}
|
|
37
|
+
finally { if (e_1) throw e_1.error; }
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
EventBuffer.prototype.flushAll = function () {
|
|
41
|
+
return this.submitEvents(this.list.length);
|
|
42
|
+
};
|
|
43
|
+
EventBuffer.prototype.release = function () {
|
|
44
|
+
this.list = [];
|
|
45
|
+
if (this.timer) {
|
|
46
|
+
clearInterval(this.timer);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(EventBuffer.prototype, "length", {
|
|
50
|
+
get: function () {
|
|
51
|
+
return this.list.length;
|
|
52
|
+
},
|
|
53
|
+
enumerable: false,
|
|
54
|
+
configurable: true
|
|
55
|
+
});
|
|
56
|
+
EventBuffer.prototype.head = function (count) {
|
|
57
|
+
return this.list.splice(0, count);
|
|
58
|
+
};
|
|
59
|
+
EventBuffer.prototype.insertAtBeginning = function () {
|
|
60
|
+
var _a;
|
|
61
|
+
var data = [];
|
|
62
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
63
|
+
data[_i] = arguments[_i];
|
|
64
|
+
}
|
|
65
|
+
(_a = this.list).unshift.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(data), false));
|
|
66
|
+
};
|
|
67
|
+
EventBuffer.prototype.startEventLoop = function () {
|
|
68
|
+
var _this = this;
|
|
69
|
+
if (this.timer) {
|
|
70
|
+
clearInterval(this.timer);
|
|
71
|
+
}
|
|
72
|
+
var _a = this.config, flushSize = _a.flushSize, flushInterval = _a.flushInterval;
|
|
73
|
+
setInterval(function () {
|
|
74
|
+
_this.submitEvents(flushSize);
|
|
75
|
+
}, flushInterval);
|
|
76
|
+
};
|
|
77
|
+
EventBuffer.prototype.submitEvents = function (count) {
|
|
78
|
+
var _this = this;
|
|
79
|
+
var events = this.head(count);
|
|
80
|
+
if (events.length === 0) {
|
|
81
|
+
return Promise.resolve();
|
|
82
|
+
}
|
|
83
|
+
return this.getAnalyticsClient()(events).then(function (result) {
|
|
84
|
+
if (result.length > 0) {
|
|
85
|
+
_this.insertAtBeginning.apply(_this, tslib_1.__spreadArray([], tslib_1.__read(result), false));
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
return EventBuffer;
|
|
90
|
+
}());
|
|
91
|
+
exports.EventBuffer = EventBuffer;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.EventBuffer = void 0;
|
|
6
|
+
var EventBuffer_1 = require("./EventBuffer");
|
|
7
|
+
Object.defineProperty(exports, "EventBuffer", { enumerable: true, get: function () { return EventBuffer_1.EventBuffer; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const groupBy: <T>(getGroupId: (x: T) => string, list: T[]) => Record<string, T[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.groupBy = void 0;
|
|
6
|
+
var tslib_1 = require("tslib");
|
|
7
|
+
var groupBy = function (getGroupId, list) {
|
|
8
|
+
return list.reduce(function (result, current) {
|
|
9
|
+
var _a;
|
|
10
|
+
var _b;
|
|
11
|
+
var groupId = getGroupId(current);
|
|
12
|
+
return tslib_1.__assign(tslib_1.__assign({}, result), (_a = {}, _a[groupId] = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(((_b = result[groupId]) !== null && _b !== void 0 ? _b : [])), false), [current], false), _a));
|
|
13
|
+
}, {});
|
|
14
|
+
};
|
|
15
|
+
exports.groupBy = groupBy;
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
export { resolveCredentials } from './resolveCredentials';
|
|
2
|
+
export { groupBy } from './groupBy';
|
|
3
|
+
export { EventBuffer, IAnalyticsClient, EventBufferConfig, } from './eventBuffer';
|
|
1
4
|
export { enableAnalytics, disableAnalytics, isAnalyticsEnabled, } from './statusHelpers';
|
|
2
5
|
export { getAnalyticsUserAgent, getAnalyticsUserAgentString, } from './userAgent';
|
package/lib/utils/index.js
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.getAnalyticsUserAgentString = exports.getAnalyticsUserAgent = exports.isAnalyticsEnabled = exports.disableAnalytics = exports.enableAnalytics = void 0;
|
|
5
|
+
exports.getAnalyticsUserAgentString = exports.getAnalyticsUserAgent = exports.isAnalyticsEnabled = exports.disableAnalytics = exports.enableAnalytics = exports.EventBuffer = exports.groupBy = exports.resolveCredentials = void 0;
|
|
6
|
+
var resolveCredentials_1 = require("./resolveCredentials");
|
|
7
|
+
Object.defineProperty(exports, "resolveCredentials", { enumerable: true, get: function () { return resolveCredentials_1.resolveCredentials; } });
|
|
8
|
+
var groupBy_1 = require("./groupBy");
|
|
9
|
+
Object.defineProperty(exports, "groupBy", { enumerable: true, get: function () { return groupBy_1.groupBy; } });
|
|
10
|
+
var eventBuffer_1 = require("./eventBuffer");
|
|
11
|
+
Object.defineProperty(exports, "EventBuffer", { enumerable: true, get: function () { return eventBuffer_1.EventBuffer; } });
|
|
6
12
|
var statusHelpers_1 = require("./statusHelpers");
|
|
7
13
|
Object.defineProperty(exports, "enableAnalytics", { enumerable: true, get: function () { return statusHelpers_1.enableAnalytics; } });
|
|
8
14
|
Object.defineProperty(exports, "disableAnalytics", { enumerable: true, get: function () { return statusHelpers_1.disableAnalytics; } });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.resolveCredentials = void 0;
|
|
6
|
+
var tslib_1 = require("tslib");
|
|
7
|
+
var errors_1 = require("../errors");
|
|
8
|
+
var core_1 = require("@aws-amplify/core");
|
|
9
|
+
var resolveCredentials = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
10
|
+
var _a, credentials, identityId;
|
|
11
|
+
return tslib_1.__generator(this, function (_b) {
|
|
12
|
+
switch (_b.label) {
|
|
13
|
+
case 0: return [4 /*yield*/, (0, core_1.fetchAuthSession)()];
|
|
14
|
+
case 1:
|
|
15
|
+
_a = _b.sent(), credentials = _a.credentials, identityId = _a.identityId;
|
|
16
|
+
(0, errors_1.assertValidationError)(!!credentials, errors_1.AnalyticsValidationErrorCode.NoCredentials);
|
|
17
|
+
return [2 /*return*/, { credentials: credentials, identityId: identityId }];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}); };
|
|
21
|
+
exports.resolveCredentials = resolveCredentials;
|
|
@@ -2,4 +2,4 @@ import { AnalyticsValidationErrorCode } from './validation';
|
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function assertValidationError(assertion: boolean, name: AnalyticsValidationErrorCode): asserts assertion;
|
|
5
|
+
export declare function assertValidationError(assertion: boolean, name: AnalyticsValidationErrorCode, message?: string): asserts assertion;
|
|
@@ -5,9 +5,13 @@ import { validationErrorMap } from './validation';
|
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
export function assertValidationError(assertion, name) {
|
|
9
|
-
var _a = validationErrorMap[name],
|
|
8
|
+
export function assertValidationError(assertion, name, message) {
|
|
9
|
+
var _a = validationErrorMap[name], defaultMessage = _a.message, recoverySuggestion = _a.recoverySuggestion;
|
|
10
10
|
if (!assertion) {
|
|
11
|
-
throw new AnalyticsError({
|
|
11
|
+
throw new AnalyticsError({
|
|
12
|
+
name: name,
|
|
13
|
+
message: message !== null && message !== void 0 ? message : defaultMessage,
|
|
14
|
+
recoverySuggestion: recoverySuggestion,
|
|
15
|
+
});
|
|
12
16
|
}
|
|
13
17
|
}
|
|
@@ -3,6 +3,8 @@ export declare enum AnalyticsValidationErrorCode {
|
|
|
3
3
|
NoAppId = "NoAppId",
|
|
4
4
|
NoCredentials = "NoCredentials",
|
|
5
5
|
NoEventName = "NoEventName",
|
|
6
|
-
NoRegion = "NoRegion"
|
|
6
|
+
NoRegion = "NoRegion",
|
|
7
|
+
NoTrackingId = "NoTrackingId",
|
|
8
|
+
InvalidFlushSize = "InvalidFlushSize"
|
|
7
9
|
}
|
|
8
10
|
export declare const validationErrorMap: AmplifyErrorMap<AnalyticsValidationErrorCode>;
|
|
@@ -7,6 +7,8 @@ export var AnalyticsValidationErrorCode;
|
|
|
7
7
|
AnalyticsValidationErrorCode["NoCredentials"] = "NoCredentials";
|
|
8
8
|
AnalyticsValidationErrorCode["NoEventName"] = "NoEventName";
|
|
9
9
|
AnalyticsValidationErrorCode["NoRegion"] = "NoRegion";
|
|
10
|
+
AnalyticsValidationErrorCode["NoTrackingId"] = "NoTrackingId";
|
|
11
|
+
AnalyticsValidationErrorCode["InvalidFlushSize"] = "InvalidFlushSize";
|
|
10
12
|
})(AnalyticsValidationErrorCode || (AnalyticsValidationErrorCode = {}));
|
|
11
13
|
export var validationErrorMap = (_a = {},
|
|
12
14
|
_a[AnalyticsValidationErrorCode.NoAppId] = {
|
|
@@ -21,4 +23,10 @@ export var validationErrorMap = (_a = {},
|
|
|
21
23
|
_a[AnalyticsValidationErrorCode.NoRegion] = {
|
|
22
24
|
message: 'Missing region.',
|
|
23
25
|
},
|
|
26
|
+
_a[AnalyticsValidationErrorCode.InvalidFlushSize] = {
|
|
27
|
+
message: 'Invalid FlushSize, it should be smaller than BufferSize',
|
|
28
|
+
},
|
|
29
|
+
_a[AnalyticsValidationErrorCode.NoTrackingId] = {
|
|
30
|
+
message: 'A trackingId is required to use Amazon Personalize',
|
|
31
|
+
},
|
|
24
32
|
_a);
|
package/lib-esm/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { record, identifyUser, RecordInput, IdentifyUserInput, } from './providers/pinpoint';
|
|
1
|
+
export { record, identifyUser, RecordInput, IdentifyUserInput, flushEvents, } from './providers/pinpoint';
|
|
2
2
|
export { enable, disable } from './apis';
|
|
3
3
|
export { AnalyticsError } from './errors';
|
package/lib-esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
export { record, identifyUser, } from './providers/pinpoint';
|
|
3
|
+
export { record, identifyUser, flushEvents, } from './providers/pinpoint';
|
|
4
4
|
export { enable, disable } from './apis';
|
|
5
5
|
export { AnalyticsError } from './errors';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flushes all buffered Kinesis events to the service.
|
|
3
|
+
*
|
|
4
|
+
* @note
|
|
5
|
+
* This API will make a best-effort attempt to flush events from the buffer. Events recorded immediately after invoking
|
|
6
|
+
* this API may not be included in the flush.
|
|
7
|
+
*/
|
|
8
|
+
export declare const flushEvents: () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { resolveConfig } from '../utils/resolveConfig';
|
|
4
|
+
import { getAnalyticsUserAgentString, resolveCredentials, } from '../../../utils';
|
|
5
|
+
import { getEventBuffer } from '../utils/getEventBuffer';
|
|
6
|
+
import { AnalyticsAction, ConsoleLogger, } from '@aws-amplify/core/internals/utils';
|
|
7
|
+
var logger = new ConsoleLogger('Kinesis');
|
|
8
|
+
/**
|
|
9
|
+
* Flushes all buffered Kinesis events to the service.
|
|
10
|
+
*
|
|
11
|
+
* @note
|
|
12
|
+
* This API will make a best-effort attempt to flush events from the buffer. Events recorded immediately after invoking
|
|
13
|
+
* this API may not be included in the flush.
|
|
14
|
+
*/
|
|
15
|
+
export var flushEvents = function () {
|
|
16
|
+
var _a = resolveConfig(), region = _a.region, flushSize = _a.flushSize, flushInterval = _a.flushInterval, bufferSize = _a.bufferSize, resendLimit = _a.resendLimit;
|
|
17
|
+
resolveCredentials()
|
|
18
|
+
.then(function (_a) {
|
|
19
|
+
var credentials = _a.credentials, identityId = _a.identityId;
|
|
20
|
+
return getEventBuffer({
|
|
21
|
+
region: region,
|
|
22
|
+
flushSize: flushSize,
|
|
23
|
+
flushInterval: flushInterval,
|
|
24
|
+
bufferSize: bufferSize,
|
|
25
|
+
credentials: credentials,
|
|
26
|
+
identityId: identityId,
|
|
27
|
+
resendLimit: resendLimit,
|
|
28
|
+
userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.Record),
|
|
29
|
+
});
|
|
30
|
+
})
|
|
31
|
+
.then(function (eventBuffer) { return eventBuffer.flushAll(); })
|
|
32
|
+
.catch(function (e) { return logger.warn('Failed to flush events.', e); });
|
|
33
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RecordInput } from '../types';
|
|
2
|
-
export declare const record: (
|
|
2
|
+
export declare const record: ({ streamName, partitionKey, data, }: RecordInput) => void;
|
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { getEventBuffer } from '../utils/getEventBuffer';
|
|
4
|
+
import { resolveConfig } from '../utils/resolveConfig';
|
|
5
|
+
import { getAnalyticsUserAgentString, isAnalyticsEnabled, resolveCredentials, } from '../../../utils';
|
|
6
|
+
import { fromUtf8 } from '@smithy/util-utf8';
|
|
7
|
+
import { AnalyticsAction, ConsoleLogger, } from '@aws-amplify/core/internals/utils';
|
|
8
|
+
var logger = new ConsoleLogger('Kinesis');
|
|
9
|
+
export var record = function (_a) {
|
|
10
|
+
var streamName = _a.streamName, partitionKey = _a.partitionKey, data = _a.data;
|
|
11
|
+
if (!isAnalyticsEnabled()) {
|
|
12
|
+
logger.debug('Analytics is disabled, event will not be recorded.');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
var timestamp = Date.now();
|
|
16
|
+
var _b = resolveConfig(), region = _b.region, bufferSize = _b.bufferSize, flushSize = _b.flushSize, flushInterval = _b.flushInterval, resendLimit = _b.resendLimit;
|
|
17
|
+
resolveCredentials()
|
|
18
|
+
.then(function (_a) {
|
|
19
|
+
var credentials = _a.credentials, identityId = _a.identityId;
|
|
20
|
+
var buffer = getEventBuffer({
|
|
21
|
+
region: region,
|
|
22
|
+
bufferSize: bufferSize,
|
|
23
|
+
flushSize: flushSize,
|
|
24
|
+
flushInterval: flushInterval,
|
|
25
|
+
credentials: credentials,
|
|
26
|
+
identityId: identityId,
|
|
27
|
+
resendLimit: resendLimit,
|
|
28
|
+
userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.Record),
|
|
29
|
+
});
|
|
30
|
+
buffer.append({
|
|
31
|
+
region: region,
|
|
32
|
+
streamName: streamName,
|
|
33
|
+
partitionKey: partitionKey,
|
|
34
|
+
event: ArrayBuffer.isView(data) ? data : fromUtf8(JSON.stringify(data)),
|
|
35
|
+
timestamp: timestamp,
|
|
36
|
+
retryCount: 0,
|
|
37
|
+
});
|
|
38
|
+
})
|
|
39
|
+
.catch(function (e) {
|
|
40
|
+
// An error occured while fetching credentials or persisting the event to the buffer
|
|
41
|
+
logger.warn('Failed to record event.', e);
|
|
42
|
+
});
|
|
5
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { record } from './apis';
|
|
1
|
+
export { record, flushEvents } from './apis';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EventBufferConfig } from '../../../utils';
|
|
2
|
+
import { Credentials } from '@aws-sdk/types';
|
|
3
|
+
import { KinesisShard } from '../../../types';
|
|
4
|
+
export type KinesisBufferEvent = KinesisShard & {
|
|
5
|
+
event: Uint8Array;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
retryCount: number;
|
|
8
|
+
};
|
|
9
|
+
export type KinesisEventBufferConfig = EventBufferConfig & {
|
|
10
|
+
region: string;
|
|
11
|
+
credentials: Credentials;
|
|
12
|
+
identityId?: string;
|
|
13
|
+
resendLimit?: number;
|
|
14
|
+
userAgentValue?: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { KinesisBufferEvent, KinesisEventBufferConfig } from '../types';
|
|
2
|
+
import { EventBuffer } from '../../../utils';
|
|
3
|
+
export declare const getEventBuffer: ({ region, flushInterval, flushSize, bufferSize, credentials, identityId, resendLimit, userAgentValue, }: KinesisEventBufferConfig) => EventBuffer<KinesisBufferEvent>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __assign, __awaiter, __generator, __read, __values } from "tslib";
|
|
4
|
+
import { EventBuffer, groupBy } from '../../../utils';
|
|
5
|
+
import { KinesisClient, PutRecordsCommand } from '@aws-sdk/client-kinesis';
|
|
6
|
+
/**
|
|
7
|
+
* These Records hold cached event buffers and AWS clients.
|
|
8
|
+
* The hash key is determined by the region and session,
|
|
9
|
+
* consisting of a combined value comprising [region, sessionToken, identityId].
|
|
10
|
+
*
|
|
11
|
+
* Only one active session should exist at any given moment.
|
|
12
|
+
* When a new session is initiated, the previous ones should be released.
|
|
13
|
+
* */
|
|
14
|
+
var eventBufferMap = {};
|
|
15
|
+
var cachedClients = {};
|
|
16
|
+
var createKinesisPutRecordsCommand = function (streamName, events) {
|
|
17
|
+
return new PutRecordsCommand({
|
|
18
|
+
StreamName: streamName,
|
|
19
|
+
Records: events.map(function (event) { return ({
|
|
20
|
+
PartitionKey: event.partitionKey,
|
|
21
|
+
Data: event.event,
|
|
22
|
+
}); }),
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var submitEvents = function (events, client, resendLimit) { return __awaiter(void 0, void 0, void 0, function () {
|
|
26
|
+
var groupedByStreamName, requests, responses, failedEvents;
|
|
27
|
+
return __generator(this, function (_a) {
|
|
28
|
+
switch (_a.label) {
|
|
29
|
+
case 0:
|
|
30
|
+
groupedByStreamName = Object.entries(groupBy(function (event) { return event.streamName; }, events));
|
|
31
|
+
requests = groupedByStreamName
|
|
32
|
+
.map(function (_a) {
|
|
33
|
+
var _b = __read(_a, 2), streamName = _b[0], events = _b[1];
|
|
34
|
+
return createKinesisPutRecordsCommand(streamName, events);
|
|
35
|
+
})
|
|
36
|
+
.map(function (command) { return client.send(command); });
|
|
37
|
+
return [4 /*yield*/, Promise.allSettled(requests)];
|
|
38
|
+
case 1:
|
|
39
|
+
responses = _a.sent();
|
|
40
|
+
failedEvents = responses
|
|
41
|
+
.map(function (response, i) {
|
|
42
|
+
return response.status === 'rejected' ? groupedByStreamName[i][1] : [];
|
|
43
|
+
})
|
|
44
|
+
.flat();
|
|
45
|
+
return [2 /*return*/, resendLimit
|
|
46
|
+
? failedEvents
|
|
47
|
+
.filter(function (event) { return event.retryCount < resendLimit; })
|
|
48
|
+
.map(function (event) { return (__assign(__assign({}, event), { retryCount: event.retryCount + 1 })); })
|
|
49
|
+
.sort(function (a, b) { return a.timestamp - b.timestamp; })
|
|
50
|
+
: []];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}); };
|
|
54
|
+
export var getEventBuffer = function (_a) {
|
|
55
|
+
var e_1, _b;
|
|
56
|
+
var region = _a.region, flushInterval = _a.flushInterval, flushSize = _a.flushSize, bufferSize = _a.bufferSize, credentials = _a.credentials, identityId = _a.identityId, resendLimit = _a.resendLimit, userAgentValue = _a.userAgentValue;
|
|
57
|
+
var sessionToken = credentials.sessionToken;
|
|
58
|
+
var sessionIdentityKey = [region, sessionToken, identityId]
|
|
59
|
+
.filter(function (x) { return !!x; })
|
|
60
|
+
.join('-');
|
|
61
|
+
if (!eventBufferMap[sessionIdentityKey]) {
|
|
62
|
+
var getKinesisClient = function () {
|
|
63
|
+
if (!cachedClients[sessionIdentityKey]) {
|
|
64
|
+
cachedClients[sessionIdentityKey] = new KinesisClient({
|
|
65
|
+
credentials: credentials,
|
|
66
|
+
region: region,
|
|
67
|
+
customUserAgent: userAgentValue,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return function (events) {
|
|
71
|
+
return submitEvents(events, cachedClients[sessionIdentityKey], resendLimit);
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
// create new session
|
|
75
|
+
eventBufferMap[sessionIdentityKey] = new EventBuffer({
|
|
76
|
+
flushInterval: flushInterval,
|
|
77
|
+
flushSize: flushSize,
|
|
78
|
+
bufferSize: bufferSize,
|
|
79
|
+
}, getKinesisClient);
|
|
80
|
+
// release other sessions
|
|
81
|
+
var releaseSessionKeys = Object.keys(eventBufferMap).filter(function (x) { return x !== sessionIdentityKey; });
|
|
82
|
+
try {
|
|
83
|
+
for (var releaseSessionKeys_1 = __values(releaseSessionKeys), releaseSessionKeys_1_1 = releaseSessionKeys_1.next(); !releaseSessionKeys_1_1.done; releaseSessionKeys_1_1 = releaseSessionKeys_1.next()) {
|
|
84
|
+
var releaseSessionKey = releaseSessionKeys_1_1.value;
|
|
85
|
+
eventBufferMap[releaseSessionKey].release();
|
|
86
|
+
delete eventBufferMap[releaseSessionKey];
|
|
87
|
+
delete cachedClients[releaseSessionKey];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
91
|
+
finally {
|
|
92
|
+
try {
|
|
93
|
+
if (releaseSessionKeys_1_1 && !releaseSessionKeys_1_1.done && (_b = releaseSessionKeys_1.return)) _b.call(releaseSessionKeys_1);
|
|
94
|
+
}
|
|
95
|
+
finally { if (e_1) throw e_1.error; }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return eventBufferMap[sessionIdentityKey];
|
|
99
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { __assign } from "tslib";
|
|
4
|
+
import { Amplify } from '@aws-amplify/core';
|
|
5
|
+
import { AnalyticsValidationErrorCode, assertValidationError, } from '../../../errors';
|
|
6
|
+
import { DEFAULT_KINESIS_CONFIG } from './constants';
|
|
7
|
+
export var resolveConfig = function () {
|
|
8
|
+
var _a;
|
|
9
|
+
var config = (_a = Amplify.getConfig().Analytics) === null || _a === void 0 ? void 0 : _a.Kinesis;
|
|
10
|
+
var _b = __assign(__assign({}, DEFAULT_KINESIS_CONFIG), config), region = _b.region, _c = _b.bufferSize, bufferSize = _c === void 0 ? DEFAULT_KINESIS_CONFIG.bufferSize : _c, _d = _b.flushSize, flushSize = _d === void 0 ? DEFAULT_KINESIS_CONFIG.flushSize : _d, _e = _b.flushInterval, flushInterval = _e === void 0 ? DEFAULT_KINESIS_CONFIG.flushInterval : _e, resendLimit = _b.resendLimit;
|
|
11
|
+
assertValidationError(!!region, AnalyticsValidationErrorCode.NoRegion);
|
|
12
|
+
assertValidationError(flushSize < bufferSize, AnalyticsValidationErrorCode.InvalidFlushSize);
|
|
13
|
+
return {
|
|
14
|
+
region: region,
|
|
15
|
+
bufferSize: bufferSize,
|
|
16
|
+
flushSize: flushSize,
|
|
17
|
+
flushInterval: flushInterval,
|
|
18
|
+
resendLimit: resendLimit,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flushes all buffered Kinesis events to the service.
|
|
3
|
+
*
|
|
4
|
+
* @note
|
|
5
|
+
* This API will make a best-effort attempt to flush events from the buffer. Events recorded immediately after invoking
|
|
6
|
+
* this API may not be included in the flush.
|
|
7
|
+
*/
|
|
8
|
+
export declare const flushEvents: () => void;
|