@aws-amplify/analytics 7.0.1-preview-testing.be90020.0 → 7.0.1-ssr-api.df60e41.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/kinesis/package.json +7 -0
- package/kinesis-firehose/package.json +7 -0
- package/lib/apis/disable.d.ts +8 -0
- package/lib/apis/disable.js +14 -0
- package/lib/apis/enable.d.ts +7 -0
- package/lib/apis/enable.js +13 -0
- package/lib/apis/index.d.ts +2 -0
- package/lib/apis/index.js +9 -0
- package/lib/errors/AnalyticsError.d.ts +2 -2
- package/lib/errors/AnalyticsError.js +7 -11
- package/lib/errors/assertValidationError.d.ts +1 -1
- package/lib/errors/assertValidationError.js +9 -5
- package/lib/errors/validation.d.ts +5 -2
- package/lib/errors/validation.js +22 -11
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -1
- package/lib/providers/kinesis/apis/flushEvents.d.ts +8 -0
- package/lib/providers/kinesis/apis/flushEvents.js +35 -0
- package/lib/providers/kinesis/apis/index.d.ts +2 -0
- package/lib/providers/kinesis/apis/index.js +9 -0
- package/lib/providers/kinesis/apis/record.d.ts +2 -0
- package/lib/providers/kinesis/apis/record.js +46 -0
- package/lib/providers/kinesis/index.d.ts +1 -0
- package/lib/providers/kinesis/index.js +8 -0
- 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 +2 -0
- package/lib/providers/kinesis/types/index.js +4 -0
- package/lib/providers/kinesis/types/inputs.d.ts +6 -0
- package/lib/providers/kinesis/types/inputs.js +4 -0
- 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 +72 -0
- package/lib/providers/kinesis/utils/resolveConfig.d.ts +7 -0
- package/lib/providers/kinesis/utils/resolveConfig.js +25 -0
- package/lib/providers/kinesis-firehose/apis/flushEvents.d.ts +8 -0
- package/lib/providers/kinesis-firehose/apis/flushEvents.js +34 -0
- package/lib/providers/kinesis-firehose/apis/index.d.ts +2 -0
- package/lib/providers/kinesis-firehose/apis/index.js +9 -0
- package/lib/providers/kinesis-firehose/apis/record.d.ts +2 -0
- package/lib/providers/kinesis-firehose/apis/record.js +43 -0
- package/lib/providers/kinesis-firehose/index.d.ts +1 -0
- package/lib/providers/kinesis-firehose/index.js +8 -0
- package/lib/providers/kinesis-firehose/types/buffer.d.ts +15 -0
- package/lib/providers/kinesis-firehose/types/index.d.ts +2 -0
- package/lib/providers/kinesis-firehose/types/index.js +4 -0
- package/lib/providers/kinesis-firehose/types/inputs.d.ts +5 -0
- package/lib/providers/kinesis-firehose/types/inputs.js +4 -0
- 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 +71 -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 +25 -0
- package/lib/providers/personalize/apis/flushEvents.d.ts +8 -0
- package/lib/providers/personalize/apis/flushEvents.js +33 -0
- package/lib/providers/personalize/apis/index.d.ts +2 -0
- package/lib/providers/personalize/apis/index.js +9 -0
- package/lib/providers/personalize/apis/record.d.ts +2 -0
- package/lib/providers/personalize/apis/record.js +71 -0
- package/lib/providers/personalize/index.d.ts +1 -0
- package/lib/providers/personalize/index.js +8 -0
- 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 -0
- package/lib/providers/personalize/types/index.js +4 -0
- package/lib/providers/personalize/types/inputs.d.ts +7 -0
- package/lib/providers/personalize/types/inputs.js +4 -0
- package/lib/providers/personalize/utils/autoTrackMedia.d.ts +10 -0
- package/lib/providers/personalize/utils/autoTrackMedia.js +181 -0
- package/lib/providers/personalize/utils/cachedSession.d.ts +5 -0
- package/lib/providers/personalize/utils/cachedSession.js +49 -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 +73 -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 +26 -0
- package/lib/providers/pinpoint/apis/configureAutoTrack.d.ts +15 -0
- package/lib/providers/pinpoint/apis/configureAutoTrack.js +35 -0
- package/lib/providers/pinpoint/apis/flushEvents.d.ts +8 -0
- package/lib/providers/pinpoint/apis/flushEvents.js +25 -0
- package/lib/providers/pinpoint/apis/identifyUser.d.ts +7 -5
- package/lib/providers/pinpoint/apis/identifyUser.js +24 -32
- package/lib/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib/providers/pinpoint/apis/index.js +5 -1
- package/lib/providers/pinpoint/apis/record.d.ts +8 -14
- package/lib/providers/pinpoint/apis/record.js +31 -34
- package/lib/providers/pinpoint/index.d.ts +2 -2
- package/lib/providers/pinpoint/index.js +3 -1
- package/lib/providers/pinpoint/types/index.d.ts +2 -2
- package/lib/providers/pinpoint/types/index.js +0 -3
- package/lib/providers/pinpoint/types/inputs.d.ts +8 -17
- package/lib/providers/pinpoint/types/options.d.ts +5 -0
- package/lib/providers/pinpoint/types/options.js +4 -0
- package/lib/providers/pinpoint/utils/resolveConfig.js +5 -6
- package/lib/providers/pinpoint/utils/resolveCredentials.d.ts +1 -6
- package/lib/providers/pinpoint/utils/resolveCredentials.js +7 -15
- package/lib/setupTests.js +1 -1
- package/lib/trackers/EventTracker.d.ts +10 -0
- package/lib/trackers/EventTracker.js +98 -0
- package/lib/trackers/PageViewTracker.d.ts +18 -0
- package/lib/trackers/PageViewTracker.js +112 -0
- package/lib/trackers/SessionTracker.d.ts +13 -0
- package/lib/trackers/SessionTracker.js +67 -0
- package/lib/trackers/SessionTracker.native.d.ts +13 -0
- package/lib/trackers/SessionTracker.native.js +67 -0
- package/lib/trackers/index.d.ts +3 -0
- package/lib/trackers/index.js +11 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/types/index.js +0 -2
- package/lib/types/inputs.d.ts +35 -0
- package/lib/types/inputs.js +4 -0
- package/lib/types/kinesis.d.ts +8 -0
- package/lib/types/kinesis.js +4 -0
- package/lib/types/options.d.ts +4 -0
- package/lib/types/options.js +4 -0
- package/lib/types/trackers.d.ts +22 -0
- package/lib/types/trackers.js +4 -0
- package/lib/utils/eventBuffer/EventBuffer.d.ts +16 -0
- package/lib/utils/eventBuffer/EventBuffer.js +63 -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 +12 -0
- package/lib/utils/index.d.ts +7 -0
- package/lib/utils/index.js +22 -0
- package/lib/utils/resolveCredentials.d.ts +4 -0
- package/lib/utils/resolveCredentials.js +13 -0
- package/lib/utils/statusHelpers.d.ts +6 -0
- package/lib/utils/statusHelpers.js +19 -0
- package/lib/utils/trackerConfigHelpers.d.ts +5 -0
- package/lib/utils/trackerConfigHelpers.js +15 -0
- package/lib/utils/trackerConfigHelpers.native.d.ts +5 -0
- package/lib/utils/trackerConfigHelpers.native.js +14 -0
- package/lib/utils/trackerHelpers.d.ts +9 -0
- package/lib/utils/trackerHelpers.js +44 -0
- package/lib/utils/userAgent.js +3 -3
- package/lib-esm/apis/disable.d.ts +8 -0
- package/lib-esm/apis/disable.js +11 -0
- package/lib-esm/apis/enable.d.ts +7 -0
- package/lib-esm/apis/enable.js +10 -0
- package/lib-esm/apis/index.d.ts +2 -0
- package/lib-esm/apis/index.js +4 -0
- package/lib-esm/errors/AnalyticsError.d.ts +2 -2
- package/lib-esm/errors/AnalyticsError.js +7 -12
- package/lib-esm/errors/assertValidationError.d.ts +1 -1
- package/lib-esm/errors/assertValidationError.js +7 -3
- package/lib-esm/errors/validation.d.ts +5 -2
- package/lib-esm/errors/validation.js +22 -11
- package/lib-esm/index.d.ts +2 -1
- package/lib-esm/index.js +2 -1
- package/lib-esm/providers/kinesis/apis/flushEvents.d.ts +8 -0
- package/lib-esm/providers/kinesis/apis/flushEvents.js +31 -0
- package/lib-esm/providers/kinesis/apis/index.d.ts +2 -0
- package/lib-esm/providers/kinesis/apis/index.js +4 -0
- package/lib-esm/providers/kinesis/apis/record.d.ts +2 -0
- package/lib-esm/providers/kinesis/apis/record.js +42 -0
- package/lib-esm/providers/kinesis/index.d.ts +1 -0
- package/lib-esm/providers/kinesis/index.js +3 -0
- 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 +2 -0
- package/lib-esm/providers/kinesis/types/index.js +3 -0
- package/lib-esm/providers/kinesis/types/inputs.d.ts +6 -0
- package/lib-esm/providers/kinesis/types/inputs.js +3 -0
- 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 +68 -0
- package/lib-esm/providers/kinesis/utils/resolveConfig.d.ts +7 -0
- package/lib-esm/providers/kinesis/utils/resolveConfig.js +21 -0
- package/lib-esm/providers/kinesis-firehose/apis/flushEvents.d.ts +8 -0
- package/lib-esm/providers/kinesis-firehose/apis/flushEvents.js +30 -0
- package/lib-esm/providers/kinesis-firehose/apis/index.d.ts +2 -0
- package/lib-esm/providers/kinesis-firehose/apis/index.js +4 -0
- package/lib-esm/providers/kinesis-firehose/apis/record.d.ts +2 -0
- package/lib-esm/providers/kinesis-firehose/apis/record.js +39 -0
- package/lib-esm/providers/kinesis-firehose/index.d.ts +1 -0
- package/lib-esm/providers/kinesis-firehose/index.js +3 -0
- package/lib-esm/providers/kinesis-firehose/types/buffer.d.ts +15 -0
- package/lib-esm/providers/kinesis-firehose/types/index.d.ts +2 -0
- package/lib-esm/providers/kinesis-firehose/types/index.js +3 -0
- package/lib-esm/providers/kinesis-firehose/types/inputs.d.ts +5 -0
- package/lib-esm/providers/kinesis-firehose/types/inputs.js +3 -0
- 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 +67 -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 +21 -0
- package/lib-esm/providers/personalize/apis/flushEvents.d.ts +8 -0
- package/lib-esm/providers/personalize/apis/flushEvents.js +29 -0
- package/lib-esm/providers/personalize/apis/index.d.ts +2 -0
- package/lib-esm/providers/personalize/apis/index.js +4 -0
- package/lib-esm/providers/personalize/apis/record.d.ts +2 -0
- package/lib-esm/providers/personalize/apis/record.js +67 -0
- package/lib-esm/providers/personalize/index.d.ts +1 -0
- package/lib-esm/providers/personalize/index.js +3 -0
- 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 -0
- package/lib-esm/providers/personalize/types/index.js +3 -0
- package/lib-esm/providers/personalize/types/inputs.d.ts +7 -0
- package/lib-esm/providers/personalize/types/inputs.js +3 -0
- package/lib-esm/providers/personalize/utils/autoTrackMedia.d.ts +10 -0
- package/lib-esm/providers/personalize/utils/autoTrackMedia.js +177 -0
- package/lib-esm/providers/personalize/utils/cachedSession.d.ts +5 -0
- package/lib-esm/providers/personalize/utils/cachedSession.js +44 -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 +69 -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 +22 -0
- package/lib-esm/providers/pinpoint/apis/configureAutoTrack.d.ts +15 -0
- package/lib-esm/providers/pinpoint/apis/configureAutoTrack.js +31 -0
- package/lib-esm/providers/pinpoint/apis/flushEvents.d.ts +8 -0
- package/lib-esm/providers/pinpoint/apis/flushEvents.js +21 -0
- package/lib-esm/providers/pinpoint/apis/identifyUser.d.ts +7 -5
- package/lib-esm/providers/pinpoint/apis/identifyUser.js +22 -30
- package/lib-esm/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib-esm/providers/pinpoint/apis/index.js +2 -0
- package/lib-esm/providers/pinpoint/apis/record.d.ts +8 -14
- package/lib-esm/providers/pinpoint/apis/record.js +26 -29
- package/lib-esm/providers/pinpoint/index.d.ts +2 -2
- package/lib-esm/providers/pinpoint/index.js +1 -1
- package/lib-esm/providers/pinpoint/types/index.d.ts +2 -2
- package/lib-esm/providers/pinpoint/types/index.js +1 -1
- package/lib-esm/providers/pinpoint/types/inputs.d.ts +8 -17
- package/lib-esm/providers/pinpoint/types/options.d.ts +5 -0
- package/lib-esm/providers/pinpoint/types/options.js +3 -0
- package/lib-esm/providers/pinpoint/utils/resolveConfig.js +3 -4
- package/lib-esm/providers/pinpoint/utils/resolveCredentials.d.ts +1 -6
- package/lib-esm/providers/pinpoint/utils/resolveCredentials.js +5 -13
- package/lib-esm/setupTests.js +1 -1
- package/lib-esm/trackers/EventTracker.d.ts +10 -0
- package/lib-esm/trackers/EventTracker.js +94 -0
- package/lib-esm/trackers/PageViewTracker.d.ts +18 -0
- package/lib-esm/trackers/PageViewTracker.js +108 -0
- package/lib-esm/trackers/SessionTracker.d.ts +13 -0
- package/lib-esm/trackers/SessionTracker.js +63 -0
- package/lib-esm/trackers/SessionTracker.native.d.ts +13 -0
- package/lib-esm/trackers/SessionTracker.native.js +63 -0
- package/lib-esm/trackers/index.d.ts +3 -0
- package/lib-esm/trackers/index.js +5 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/index.d.ts +3 -1
- package/lib-esm/types/index.js +1 -1
- package/lib-esm/types/inputs.d.ts +35 -0
- package/lib-esm/types/inputs.js +3 -0
- package/lib-esm/types/kinesis.d.ts +8 -0
- package/lib-esm/types/kinesis.js +3 -0
- package/lib-esm/types/options.d.ts +4 -0
- package/lib-esm/types/options.js +3 -0
- package/lib-esm/types/trackers.d.ts +22 -0
- package/lib-esm/types/trackers.js +3 -0
- package/lib-esm/utils/eventBuffer/EventBuffer.d.ts +16 -0
- package/lib-esm/utils/eventBuffer/EventBuffer.js +59 -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 +8 -0
- package/lib-esm/utils/index.d.ts +7 -0
- package/lib-esm/utils/index.js +9 -0
- package/lib-esm/utils/resolveCredentials.d.ts +4 -0
- package/lib-esm/utils/resolveCredentials.js +9 -0
- package/lib-esm/utils/statusHelpers.d.ts +6 -0
- package/lib-esm/utils/statusHelpers.js +13 -0
- package/lib-esm/utils/trackerConfigHelpers.d.ts +5 -0
- package/lib-esm/utils/trackerConfigHelpers.js +11 -0
- package/lib-esm/utils/trackerConfigHelpers.native.d.ts +5 -0
- package/lib-esm/utils/trackerConfigHelpers.native.js +10 -0
- package/lib-esm/utils/trackerHelpers.d.ts +9 -0
- package/lib-esm/utils/trackerHelpers.js +40 -0
- package/lib-esm/utils/userAgent.js +2 -2
- package/package.json +39 -12
- package/personalize/package.json +7 -0
- package/src/apis/disable.ts +13 -0
- package/src/apis/enable.ts +12 -0
- package/src/apis/index.ts +5 -0
- package/src/errors/AnalyticsError.ts +5 -2
- package/src/errors/assertValidationError.ts +9 -3
- package/src/errors/validation.ts +16 -4
- package/src/index.ts +4 -0
- package/src/providers/kinesis/apis/flushEvents.ts +40 -0
- package/src/providers/kinesis/apis/index.ts +5 -0
- package/src/providers/kinesis/apis/record.ts +58 -0
- package/src/providers/kinesis/index.ts +4 -0
- package/src/providers/kinesis/types/buffer.ts +20 -0
- package/src/providers/kinesis/types/index.ts +5 -0
- package/src/providers/kinesis/types/inputs.ts +10 -0
- package/src/providers/kinesis/utils/constants.ts +9 -0
- package/src/providers/kinesis/utils/getEventBuffer.ts +109 -0
- package/src/providers/kinesis/utils/resolveConfig.ts +36 -0
- package/src/providers/kinesis-firehose/apis/flushEvents.ts +39 -0
- package/src/providers/kinesis-firehose/apis/index.ts +5 -0
- package/src/providers/kinesis-firehose/apis/record.ts +51 -0
- package/src/providers/kinesis-firehose/index.ts +4 -0
- package/src/providers/kinesis-firehose/types/buffer.ts +20 -0
- package/src/providers/kinesis-firehose/types/index.ts +9 -0
- package/src/providers/kinesis-firehose/types/inputs.ts +9 -0
- package/src/providers/kinesis-firehose/utils/constants.ts +9 -0
- package/src/providers/kinesis-firehose/utils/getEventBuffer.ts +117 -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 +37 -0
- package/src/providers/personalize/apis/index.ts +5 -0
- package/src/providers/personalize/apis/record.ts +102 -0
- package/src/providers/personalize/index.ts +4 -0
- package/src/providers/personalize/types/buffer.ts +21 -0
- package/src/providers/personalize/types/index.ts +5 -0
- package/src/providers/personalize/types/inputs.ts +11 -0
- package/src/providers/personalize/utils/autoTrackMedia.ts +232 -0
- package/src/providers/personalize/utils/cachedSession.ts +68 -0
- package/src/providers/personalize/utils/constants.ts +12 -0
- package/src/providers/personalize/utils/getEventBuffer.ts +110 -0
- package/src/providers/personalize/utils/index.ts +11 -0
- package/src/providers/personalize/utils/resolveConfig.ts +41 -0
- package/src/providers/pinpoint/apis/configureAutoTrack.ts +49 -0
- package/src/providers/pinpoint/apis/flushEvents.ts +32 -0
- package/src/providers/pinpoint/apis/identifyUser.ts +20 -12
- package/src/providers/pinpoint/apis/index.ts +2 -0
- package/src/providers/pinpoint/apis/record.ts +31 -23
- package/src/providers/pinpoint/index.ts +6 -2
- package/src/providers/pinpoint/types/index.ts +6 -2
- package/src/providers/pinpoint/types/inputs.ts +11 -17
- package/src/providers/pinpoint/types/options.ts +12 -0
- package/src/trackers/EventTracker.ts +135 -0
- package/src/trackers/PageViewTracker.ts +160 -0
- package/src/trackers/SessionTracker.native.ts +105 -0
- package/src/trackers/SessionTracker.ts +105 -0
- package/src/trackers/index.ts +6 -0
- package/src/types/index.ts +8 -1
- package/src/types/inputs.ts +52 -0
- package/src/types/kinesis.ts +13 -0
- package/src/types/options.ts +7 -0
- package/src/types/trackers.ts +35 -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 +21 -0
- package/src/utils/resolveCredentials.ts +14 -0
- package/src/utils/statusHelpers.ts +17 -0
- package/src/utils/trackerConfigHelpers.native.ts +18 -0
- package/src/utils/trackerConfigHelpers.ts +19 -0
- package/src/utils/trackerHelpers.ts +57 -0
- package/lib/providers/pinpoint/types/errors.d.ts +0 -9
- package/lib/providers/pinpoint/types/errors.js +0 -15
- package/lib/types/analytics.d.ts +0 -50
- package/lib-esm/providers/pinpoint/types/errors.d.ts +0 -9
- package/lib-esm/providers/pinpoint/types/errors.js +0 -12
- package/lib-esm/types/analytics.d.ts +0 -50
- package/src/providers/pinpoint/types/errors.ts +0 -12
- package/src/types/analytics.ts +0 -70
- /package/lib/{types/analytics.js → providers/kinesis-firehose/types/buffer.js} +0 -0
- /package/lib-esm/{types/analytics.js → providers/kinesis-firehose/types/buffer.js} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aws-amplify/analytics/kinesis-firehose",
|
|
3
|
+
"main": "../lib/providers/kinesis-firehose/index.js",
|
|
4
|
+
"browser": "../lib-esm/providers/kinesis-firehose/index.js",
|
|
5
|
+
"module": "../lib-esm/providers/kinesis-firehose/index.js",
|
|
6
|
+
"typings": "../lib-esm/providers/kinesis-firehose/index.d.ts"
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disables the Analytics category.
|
|
3
|
+
*
|
|
4
|
+
* @note
|
|
5
|
+
* When Analytics is disabled events will not be buffered or transmitted to your selected service. Any auto-tracking
|
|
6
|
+
* behavior that you have configured via `configureAutoTrack` will not have any effect while Analytics is disabled.
|
|
7
|
+
*/
|
|
8
|
+
export declare const disable: () => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
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.disable = void 0;
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
/**
|
|
8
|
+
* Disables the Analytics category.
|
|
9
|
+
*
|
|
10
|
+
* @note
|
|
11
|
+
* When Analytics is disabled events will not be buffered or transmitted to your selected service. Any auto-tracking
|
|
12
|
+
* behavior that you have configured via `configureAutoTrack` will not have any effect while Analytics is disabled.
|
|
13
|
+
*/
|
|
14
|
+
exports.disable = utils_1.disableAnalytics;
|
|
@@ -0,0 +1,13 @@
|
|
|
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.enable = void 0;
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
/**
|
|
8
|
+
* Enables the Analytics category to permit the transmission of events.
|
|
9
|
+
*
|
|
10
|
+
* @note
|
|
11
|
+
* Analytics is enabled by default. You do not need to call this API unless you have disabled Analytics.
|
|
12
|
+
*/
|
|
13
|
+
exports.enable = utils_1.enableAnalytics;
|
|
@@ -0,0 +1,9 @@
|
|
|
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.disable = exports.enable = void 0;
|
|
6
|
+
var enable_1 = require("./enable");
|
|
7
|
+
Object.defineProperty(exports, "enable", { enumerable: true, get: function () { return enable_1.enable; } });
|
|
8
|
+
var disable_1 = require("./disable");
|
|
9
|
+
Object.defineProperty(exports, "disable", { enumerable: true, get: function () { return disable_1.disable; } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AmplifyError,
|
|
1
|
+
import { AmplifyError, AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
5
|
export declare class AnalyticsError extends AmplifyError {
|
|
6
|
-
constructor(params:
|
|
6
|
+
constructor(params: AmplifyErrorParams);
|
|
7
7
|
}
|
|
@@ -3,21 +3,17 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.AnalyticsError = void 0;
|
|
6
|
-
|
|
7
|
-
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
6
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
7
|
/**
|
|
9
8
|
* @internal
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _this = _super.call(this, params) || this;
|
|
10
|
+
class AnalyticsError extends utils_1.AmplifyError {
|
|
11
|
+
constructor(params) {
|
|
12
|
+
super(params);
|
|
15
13
|
// Hack for making the custom error class work when transpiled to es5
|
|
16
14
|
// TODO: Delete the following 2 lines after we change the build target to >= es2015
|
|
17
|
-
|
|
18
|
-
Object.setPrototypeOf(
|
|
19
|
-
return _this;
|
|
15
|
+
this.constructor = AnalyticsError;
|
|
16
|
+
Object.setPrototypeOf(this, AnalyticsError.prototype);
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
}(utils_1.AmplifyError));
|
|
18
|
+
}
|
|
23
19
|
exports.AnalyticsError = AnalyticsError;
|
|
@@ -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;
|
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.assertValidationError = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const AnalyticsError_1 = require("./AnalyticsError");
|
|
7
|
+
const validation_1 = require("./validation");
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
function assertValidationError(assertion, name) {
|
|
12
|
-
|
|
11
|
+
function assertValidationError(assertion, name, message) {
|
|
12
|
+
const { message: defaultMessage, recoverySuggestion } = validation_1.validationErrorMap[name];
|
|
13
13
|
if (!assertion) {
|
|
14
|
-
throw new AnalyticsError_1.AnalyticsError({
|
|
14
|
+
throw new AnalyticsError_1.AnalyticsError({
|
|
15
|
+
name,
|
|
16
|
+
message: message ?? defaultMessage,
|
|
17
|
+
recoverySuggestion,
|
|
18
|
+
});
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
exports.assertValidationError = assertValidationError;
|
|
@@ -2,8 +2,11 @@ import { AmplifyErrorMap } from '@aws-amplify/core/internals/utils';
|
|
|
2
2
|
export declare enum AnalyticsValidationErrorCode {
|
|
3
3
|
NoAppId = "NoAppId",
|
|
4
4
|
NoCredentials = "NoCredentials",
|
|
5
|
-
NoEvent = "NoEvent",
|
|
6
5
|
NoEventName = "NoEventName",
|
|
7
|
-
NoRegion = "NoRegion"
|
|
6
|
+
NoRegion = "NoRegion",
|
|
7
|
+
InvalidTracker = "InvalidTracker",
|
|
8
|
+
UnsupportedPlatform = "UnsupportedPlatform",
|
|
9
|
+
NoTrackingId = "NoTrackingId",
|
|
10
|
+
InvalidFlushSize = "InvalidFlushSize"
|
|
8
11
|
}
|
|
9
12
|
export declare const validationErrorMap: AmplifyErrorMap<AnalyticsValidationErrorCode>;
|
package/lib/errors/validation.js
CHANGED
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
var _a;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
5
|
exports.validationErrorMap = exports.AnalyticsValidationErrorCode = void 0;
|
|
7
6
|
var AnalyticsValidationErrorCode;
|
|
8
7
|
(function (AnalyticsValidationErrorCode) {
|
|
9
8
|
AnalyticsValidationErrorCode["NoAppId"] = "NoAppId";
|
|
10
9
|
AnalyticsValidationErrorCode["NoCredentials"] = "NoCredentials";
|
|
11
|
-
AnalyticsValidationErrorCode["NoEvent"] = "NoEvent";
|
|
12
10
|
AnalyticsValidationErrorCode["NoEventName"] = "NoEventName";
|
|
13
11
|
AnalyticsValidationErrorCode["NoRegion"] = "NoRegion";
|
|
12
|
+
AnalyticsValidationErrorCode["InvalidTracker"] = "InvalidTracker";
|
|
13
|
+
AnalyticsValidationErrorCode["UnsupportedPlatform"] = "UnsupportedPlatform";
|
|
14
|
+
AnalyticsValidationErrorCode["NoTrackingId"] = "NoTrackingId";
|
|
15
|
+
AnalyticsValidationErrorCode["InvalidFlushSize"] = "InvalidFlushSize";
|
|
14
16
|
})(AnalyticsValidationErrorCode = exports.AnalyticsValidationErrorCode || (exports.AnalyticsValidationErrorCode = {}));
|
|
15
|
-
exports.validationErrorMap =
|
|
16
|
-
|
|
17
|
+
exports.validationErrorMap = {
|
|
18
|
+
[AnalyticsValidationErrorCode.NoAppId]: {
|
|
17
19
|
message: 'Missing application id.',
|
|
18
20
|
},
|
|
19
|
-
|
|
21
|
+
[AnalyticsValidationErrorCode.NoCredentials]: {
|
|
20
22
|
message: 'Credentials should not be empty.',
|
|
21
23
|
},
|
|
22
|
-
|
|
23
|
-
message: 'An event is required to record.',
|
|
24
|
-
},
|
|
25
|
-
_a[AnalyticsValidationErrorCode.NoEventName] = {
|
|
24
|
+
[AnalyticsValidationErrorCode.NoEventName]: {
|
|
26
25
|
message: 'Events must specify a name.',
|
|
27
26
|
},
|
|
28
|
-
|
|
27
|
+
[AnalyticsValidationErrorCode.NoRegion]: {
|
|
29
28
|
message: 'Missing region.',
|
|
30
29
|
},
|
|
31
|
-
|
|
30
|
+
[AnalyticsValidationErrorCode.InvalidTracker]: {
|
|
31
|
+
message: 'Invalid tracker type specified.',
|
|
32
|
+
},
|
|
33
|
+
[AnalyticsValidationErrorCode.UnsupportedPlatform]: {
|
|
34
|
+
message: 'Only session tracking is supported on React Native.',
|
|
35
|
+
},
|
|
36
|
+
[AnalyticsValidationErrorCode.InvalidFlushSize]: {
|
|
37
|
+
message: 'Invalid FlushSize, it should be smaller than BufferSize',
|
|
38
|
+
},
|
|
39
|
+
[AnalyticsValidationErrorCode.NoTrackingId]: {
|
|
40
|
+
message: 'A trackingId is required to use Amazon Personalize',
|
|
41
|
+
},
|
|
42
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { record, identifyUser, RecordInput, IdentifyUserInput, } from './providers/pinpoint';
|
|
1
|
+
export { record, identifyUser, configureAutoTrack, flushEvents, RecordInput, IdentifyUserInput, ConfigureAutoTrackInput, } from './providers/pinpoint';
|
|
2
|
+
export { enable, disable } from './apis';
|
|
2
3
|
export { AnalyticsError } from './errors';
|
package/lib/index.js
CHANGED
|
@@ -2,9 +2,14 @@
|
|
|
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.AnalyticsError = exports.identifyUser = exports.record = void 0;
|
|
5
|
+
exports.AnalyticsError = exports.disable = exports.enable = exports.flushEvents = exports.configureAutoTrack = exports.identifyUser = exports.record = void 0;
|
|
6
6
|
var pinpoint_1 = require("./providers/pinpoint");
|
|
7
7
|
Object.defineProperty(exports, "record", { enumerable: true, get: function () { return pinpoint_1.record; } });
|
|
8
8
|
Object.defineProperty(exports, "identifyUser", { enumerable: true, get: function () { return pinpoint_1.identifyUser; } });
|
|
9
|
+
Object.defineProperty(exports, "configureAutoTrack", { enumerable: true, get: function () { return pinpoint_1.configureAutoTrack; } });
|
|
10
|
+
Object.defineProperty(exports, "flushEvents", { enumerable: true, get: function () { return pinpoint_1.flushEvents; } });
|
|
11
|
+
var apis_1 = require("./apis");
|
|
12
|
+
Object.defineProperty(exports, "enable", { enumerable: true, get: function () { return apis_1.enable; } });
|
|
13
|
+
Object.defineProperty(exports, "disable", { enumerable: true, get: function () { return apis_1.disable; } });
|
|
9
14
|
var errors_1 = require("./errors");
|
|
10
15
|
Object.defineProperty(exports, "AnalyticsError", { enumerable: true, get: function () { return errors_1.AnalyticsError; } });
|
|
@@ -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,35 @@
|
|
|
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.flushEvents = void 0;
|
|
6
|
+
const resolveConfig_1 = require("../utils/resolveConfig");
|
|
7
|
+
const utils_1 = require("../../../utils");
|
|
8
|
+
const getEventBuffer_1 = require("../utils/getEventBuffer");
|
|
9
|
+
const utils_2 = require("@aws-amplify/core/internals/utils");
|
|
10
|
+
const core_1 = require("@aws-amplify/core");
|
|
11
|
+
const logger = new core_1.ConsoleLogger('Kinesis');
|
|
12
|
+
/**
|
|
13
|
+
* Flushes all buffered Kinesis events to the service.
|
|
14
|
+
*
|
|
15
|
+
* @note
|
|
16
|
+
* This API will make a best-effort attempt to flush events from the buffer. Events recorded immediately after invoking
|
|
17
|
+
* this API may not be included in the flush.
|
|
18
|
+
*/
|
|
19
|
+
const flushEvents = () => {
|
|
20
|
+
const { region, flushSize, flushInterval, bufferSize, resendLimit } = (0, resolveConfig_1.resolveConfig)();
|
|
21
|
+
(0, utils_1.resolveCredentials)()
|
|
22
|
+
.then(({ credentials, identityId }) => (0, getEventBuffer_1.getEventBuffer)({
|
|
23
|
+
region,
|
|
24
|
+
flushSize,
|
|
25
|
+
flushInterval,
|
|
26
|
+
bufferSize,
|
|
27
|
+
credentials,
|
|
28
|
+
identityId,
|
|
29
|
+
resendLimit,
|
|
30
|
+
userAgentValue: (0, utils_1.getAnalyticsUserAgentString)(utils_2.AnalyticsAction.Record),
|
|
31
|
+
}))
|
|
32
|
+
.then(eventBuffer => eventBuffer.flushAll())
|
|
33
|
+
.catch(e => logger.warn('Failed to flush events.', e));
|
|
34
|
+
};
|
|
35
|
+
exports.flushEvents = flushEvents;
|
|
@@ -0,0 +1,9 @@
|
|
|
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.flushEvents = exports.record = void 0;
|
|
6
|
+
var record_1 = require("./record");
|
|
7
|
+
Object.defineProperty(exports, "record", { enumerable: true, get: function () { return record_1.record; } });
|
|
8
|
+
var flushEvents_1 = require("./flushEvents");
|
|
9
|
+
Object.defineProperty(exports, "flushEvents", { enumerable: true, get: function () { return flushEvents_1.flushEvents; } });
|
|
@@ -0,0 +1,46 @@
|
|
|
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.record = void 0;
|
|
6
|
+
const getEventBuffer_1 = require("../utils/getEventBuffer");
|
|
7
|
+
const resolveConfig_1 = require("../utils/resolveConfig");
|
|
8
|
+
const utils_1 = require("../../../utils");
|
|
9
|
+
const util_utf8_1 = require("@smithy/util-utf8");
|
|
10
|
+
const utils_2 = require("@aws-amplify/core/internals/utils");
|
|
11
|
+
const core_1 = require("@aws-amplify/core");
|
|
12
|
+
const logger = new core_1.ConsoleLogger('Kinesis');
|
|
13
|
+
const record = ({ streamName, partitionKey, data, }) => {
|
|
14
|
+
if (!(0, utils_1.isAnalyticsEnabled)()) {
|
|
15
|
+
logger.debug('Analytics is disabled, event will not be recorded.');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const timestamp = Date.now();
|
|
19
|
+
const { region, bufferSize, flushSize, flushInterval, resendLimit } = (0, resolveConfig_1.resolveConfig)();
|
|
20
|
+
(0, utils_1.resolveCredentials)()
|
|
21
|
+
.then(({ credentials, identityId }) => {
|
|
22
|
+
const buffer = (0, getEventBuffer_1.getEventBuffer)({
|
|
23
|
+
region,
|
|
24
|
+
bufferSize,
|
|
25
|
+
flushSize,
|
|
26
|
+
flushInterval,
|
|
27
|
+
credentials,
|
|
28
|
+
identityId,
|
|
29
|
+
resendLimit,
|
|
30
|
+
userAgentValue: (0, utils_1.getAnalyticsUserAgentString)(utils_2.AnalyticsAction.Record),
|
|
31
|
+
});
|
|
32
|
+
buffer.append({
|
|
33
|
+
region,
|
|
34
|
+
streamName,
|
|
35
|
+
partitionKey,
|
|
36
|
+
event: ArrayBuffer.isView(data) ? data : (0, util_utf8_1.fromUtf8)(JSON.stringify(data)),
|
|
37
|
+
timestamp,
|
|
38
|
+
retryCount: 0,
|
|
39
|
+
});
|
|
40
|
+
})
|
|
41
|
+
.catch(e => {
|
|
42
|
+
// An error occured while fetching credentials or persisting the event to the buffer
|
|
43
|
+
logger.warn('Failed to record event.', e);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.record = record;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { record, flushEvents } from './apis';
|
|
@@ -0,0 +1,8 @@
|
|
|
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.flushEvents = exports.record = void 0;
|
|
6
|
+
var apis_1 = require("./apis");
|
|
7
|
+
Object.defineProperty(exports, "record", { enumerable: true, get: function () { return apis_1.record; } });
|
|
8
|
+
Object.defineProperty(exports, "flushEvents", { enumerable: true, get: function () { return apis_1.flushEvents; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AWSCredentials } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
import { EventBufferConfig } from '../../../utils';
|
|
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: AWSCredentials;
|
|
12
|
+
identityId?: string;
|
|
13
|
+
resendLimit?: number;
|
|
14
|
+
userAgentValue?: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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.DEFAULT_KINESIS_CONFIG = void 0;
|
|
6
|
+
exports.DEFAULT_KINESIS_CONFIG = {
|
|
7
|
+
bufferSize: 1000,
|
|
8
|
+
flushSize: 100,
|
|
9
|
+
flushInterval: 5000,
|
|
10
|
+
resendLimit: 5,
|
|
11
|
+
};
|
|
@@ -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,72 @@
|
|
|
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.getEventBuffer = void 0;
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const client_kinesis_1 = require("@aws-sdk/client-kinesis");
|
|
8
|
+
/**
|
|
9
|
+
* These Records hold cached event buffers and AWS clients.
|
|
10
|
+
* The hash key is determined by the region and session,
|
|
11
|
+
* consisting of a combined value comprising [region, sessionToken, identityId].
|
|
12
|
+
*
|
|
13
|
+
* Only one active session should exist at any given moment.
|
|
14
|
+
* When a new session is initiated, the previous ones should be released.
|
|
15
|
+
* */
|
|
16
|
+
const eventBufferMap = {};
|
|
17
|
+
const cachedClients = {};
|
|
18
|
+
const createKinesisPutRecordsCommand = (streamName, events) => new client_kinesis_1.PutRecordsCommand({
|
|
19
|
+
StreamName: streamName,
|
|
20
|
+
Records: events.map(event => ({
|
|
21
|
+
PartitionKey: event.partitionKey,
|
|
22
|
+
Data: event.event,
|
|
23
|
+
})),
|
|
24
|
+
});
|
|
25
|
+
const submitEvents = async (events, client, resendLimit) => {
|
|
26
|
+
const groupedByStreamName = Object.entries((0, utils_1.groupBy)(event => event.streamName, events));
|
|
27
|
+
const requests = groupedByStreamName
|
|
28
|
+
.map(([streamName, events]) => createKinesisPutRecordsCommand(streamName, events))
|
|
29
|
+
.map(command => client.send(command));
|
|
30
|
+
const responses = await Promise.allSettled(requests);
|
|
31
|
+
const failedEvents = responses
|
|
32
|
+
.map((response, i) => response.status === 'rejected' ? groupedByStreamName[i][1] : [])
|
|
33
|
+
.flat();
|
|
34
|
+
return resendLimit
|
|
35
|
+
? failedEvents
|
|
36
|
+
.filter(event => event.retryCount < resendLimit)
|
|
37
|
+
.map(event => ({ ...event, retryCount: event.retryCount + 1 }))
|
|
38
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
39
|
+
: [];
|
|
40
|
+
};
|
|
41
|
+
const getEventBuffer = ({ region, flushInterval, flushSize, bufferSize, credentials, identityId, resendLimit, userAgentValue, }) => {
|
|
42
|
+
const sessionIdentityKey = [region, identityId].filter(x => !!x).join('-');
|
|
43
|
+
if (!eventBufferMap[sessionIdentityKey]) {
|
|
44
|
+
const getKinesisClient = () => {
|
|
45
|
+
if (!cachedClients[sessionIdentityKey]) {
|
|
46
|
+
cachedClients[sessionIdentityKey] = new client_kinesis_1.KinesisClient({
|
|
47
|
+
credentials,
|
|
48
|
+
region,
|
|
49
|
+
customUserAgent: userAgentValue,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return events => submitEvents(events, cachedClients[sessionIdentityKey], resendLimit);
|
|
53
|
+
};
|
|
54
|
+
// create new session
|
|
55
|
+
eventBufferMap[sessionIdentityKey] = new utils_1.EventBuffer({
|
|
56
|
+
flushInterval,
|
|
57
|
+
flushSize,
|
|
58
|
+
bufferSize,
|
|
59
|
+
}, getKinesisClient);
|
|
60
|
+
// release other sessions
|
|
61
|
+
const releaseSessionKeys = Object.keys(eventBufferMap).filter(x => x !== sessionIdentityKey);
|
|
62
|
+
for (const releaseSessionKey of releaseSessionKeys) {
|
|
63
|
+
eventBufferMap[releaseSessionKey].flushAll().finally(() => {
|
|
64
|
+
eventBufferMap[releaseSessionKey].release();
|
|
65
|
+
delete eventBufferMap[releaseSessionKey];
|
|
66
|
+
delete cachedClients[releaseSessionKey];
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return eventBufferMap[sessionIdentityKey];
|
|
71
|
+
};
|
|
72
|
+
exports.getEventBuffer = getEventBuffer;
|
|
@@ -0,0 +1,25 @@
|
|
|
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.resolveConfig = void 0;
|
|
6
|
+
const core_1 = require("@aws-amplify/core");
|
|
7
|
+
const errors_1 = require("../../../errors");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const resolveConfig = () => {
|
|
10
|
+
const config = core_1.Amplify.getConfig().Analytics?.Kinesis;
|
|
11
|
+
const { region, bufferSize = constants_1.DEFAULT_KINESIS_CONFIG.bufferSize, flushSize = constants_1.DEFAULT_KINESIS_CONFIG.flushSize, flushInterval = constants_1.DEFAULT_KINESIS_CONFIG.flushInterval, resendLimit, } = {
|
|
12
|
+
...constants_1.DEFAULT_KINESIS_CONFIG,
|
|
13
|
+
...config,
|
|
14
|
+
};
|
|
15
|
+
(0, errors_1.assertValidationError)(!!region, errors_1.AnalyticsValidationErrorCode.NoRegion);
|
|
16
|
+
(0, errors_1.assertValidationError)(flushSize < bufferSize, errors_1.AnalyticsValidationErrorCode.InvalidFlushSize);
|
|
17
|
+
return {
|
|
18
|
+
region,
|
|
19
|
+
bufferSize,
|
|
20
|
+
flushSize,
|
|
21
|
+
flushInterval,
|
|
22
|
+
resendLimit,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.resolveConfig = resolveConfig;
|
|
@@ -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,34 @@
|
|
|
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.flushEvents = void 0;
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const utils_2 = require("../../../utils");
|
|
8
|
+
const utils_3 = require("@aws-amplify/core/internals/utils");
|
|
9
|
+
const core_1 = require("@aws-amplify/core");
|
|
10
|
+
const logger = new core_1.ConsoleLogger('KinesisFirehose');
|
|
11
|
+
/**
|
|
12
|
+
* Flushes all buffered Kinesis events to the service.
|
|
13
|
+
*
|
|
14
|
+
* @note
|
|
15
|
+
* This API will make a best-effort attempt to flush events from the buffer. Events recorded immediately after invoking
|
|
16
|
+
* this API may not be included in the flush.
|
|
17
|
+
*/
|
|
18
|
+
const flushEvents = () => {
|
|
19
|
+
const { region, flushSize, flushInterval, bufferSize, resendLimit } = (0, utils_1.resolveConfig)();
|
|
20
|
+
(0, utils_2.resolveCredentials)()
|
|
21
|
+
.then(({ credentials, identityId }) => (0, utils_1.getEventBuffer)({
|
|
22
|
+
region,
|
|
23
|
+
flushSize,
|
|
24
|
+
flushInterval,
|
|
25
|
+
bufferSize,
|
|
26
|
+
credentials,
|
|
27
|
+
identityId,
|
|
28
|
+
resendLimit,
|
|
29
|
+
userAgentValue: (0, utils_2.getAnalyticsUserAgentString)(utils_3.AnalyticsAction.Record),
|
|
30
|
+
}))
|
|
31
|
+
.then(eventBuffer => eventBuffer.flushAll())
|
|
32
|
+
.catch(e => logger.warn('Failed to flush events.', e));
|
|
33
|
+
};
|
|
34
|
+
exports.flushEvents = flushEvents;
|
|
@@ -0,0 +1,9 @@
|
|
|
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.flushEvents = exports.record = void 0;
|
|
6
|
+
var record_1 = require("./record");
|
|
7
|
+
Object.defineProperty(exports, "record", { enumerable: true, get: function () { return record_1.record; } });
|
|
8
|
+
var flushEvents_1 = require("./flushEvents");
|
|
9
|
+
Object.defineProperty(exports, "flushEvents", { enumerable: true, get: function () { return flushEvents_1.flushEvents; } });
|