@aws-amplify/analytics 7.0.1-preview-testing.034e780.0 → 7.0.1-server-generate-client.1e317a1.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/assertValidationError.d.ts +1 -1
- package/lib/errors/assertValidationError.js +7 -3
- package/lib/errors/validation.d.ts +5 -2
- package/lib/errors/validation.js +16 -4
- 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 +38 -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 +48 -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 +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 +37 -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 +45 -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 +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 +36 -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 +87 -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 +183 -0
- package/lib/providers/personalize/utils/cachedSession.d.ts +5 -0
- package/lib/providers/personalize/utils/cachedSession.js +61 -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/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 +28 -0
- package/lib/providers/pinpoint/apis/identifyUser.d.ts +7 -5
- package/lib/providers/pinpoint/apis/identifyUser.js +15 -11
- 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 +22 -24
- 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/resolveCredentials.d.ts +1 -6
- package/lib/trackers/EventTracker.d.ts +10 -0
- package/lib/trackers/EventTracker.js +104 -0
- package/lib/trackers/PageViewTracker.d.ts +18 -0
- package/lib/trackers/PageViewTracker.js +116 -0
- package/lib/trackers/SessionTracker.d.ts +13 -0
- package/lib/trackers/SessionTracker.js +73 -0
- package/lib/trackers/SessionTracker.native.d.ts +13 -0
- package/lib/trackers/SessionTracker.native.js +73 -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 +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 +7 -0
- package/lib/utils/index.js +22 -0
- package/lib/utils/resolveCredentials.d.ts +4 -0
- package/lib/utils/resolveCredentials.js +21 -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-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 +1 -1
- 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 +16 -4
- 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 +34 -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 +44 -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 +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 +33 -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 +41 -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 +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 +32 -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 +83 -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 +179 -0
- package/lib-esm/providers/personalize/utils/cachedSession.d.ts +5 -0
- package/lib-esm/providers/personalize/utils/cachedSession.js +56 -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/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 +24 -0
- package/lib-esm/providers/pinpoint/apis/identifyUser.d.ts +7 -5
- package/lib-esm/providers/pinpoint/apis/identifyUser.js +13 -9
- 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 +20 -22
- 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/resolveCredentials.d.ts +1 -6
- package/lib-esm/trackers/EventTracker.d.ts +10 -0
- package/lib-esm/trackers/EventTracker.js +101 -0
- package/lib-esm/trackers/PageViewTracker.d.ts +18 -0
- package/lib-esm/trackers/PageViewTracker.js +113 -0
- package/lib-esm/trackers/SessionTracker.d.ts +13 -0
- package/lib-esm/trackers/SessionTracker.js +70 -0
- package/lib-esm/trackers/SessionTracker.native.d.ts +13 -0
- package/lib-esm/trackers/SessionTracker.native.js +70 -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 +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 +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 +17 -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/package.json +39 -9
- 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 +110 -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 +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 +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 +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/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 +106 -0
- package/src/trackers/SessionTracker.ts +106 -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,106 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
sessionListener,
|
|
6
|
+
SessionState,
|
|
7
|
+
} from '@aws-amplify/core/internals/utils';
|
|
8
|
+
import { ConsoleLogger } from '@aws-amplify/core';
|
|
9
|
+
import {
|
|
10
|
+
SessionTrackingOptions,
|
|
11
|
+
TrackerEventRecorder,
|
|
12
|
+
TrackerInterface,
|
|
13
|
+
} from '../types/trackers';
|
|
14
|
+
|
|
15
|
+
const SESSION_START_EVENT = '_session.start';
|
|
16
|
+
const SESSION_STOP_EVENT = '_session.stop';
|
|
17
|
+
|
|
18
|
+
const logger = new ConsoleLogger('SessionTracker');
|
|
19
|
+
|
|
20
|
+
export class SessionTracker implements TrackerInterface {
|
|
21
|
+
private options: SessionTrackingOptions;
|
|
22
|
+
private eventRecorder: TrackerEventRecorder;
|
|
23
|
+
private initialEventSent: boolean;
|
|
24
|
+
private sessionTrackingActive: boolean;
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
eventRecorder: TrackerEventRecorder,
|
|
28
|
+
options?: SessionTrackingOptions
|
|
29
|
+
) {
|
|
30
|
+
this.options = {};
|
|
31
|
+
this.eventRecorder = eventRecorder;
|
|
32
|
+
this.initialEventSent = false;
|
|
33
|
+
this.sessionTrackingActive = false;
|
|
34
|
+
this.handleStateChange = this.handleStateChange.bind(this);
|
|
35
|
+
|
|
36
|
+
this.configure(eventRecorder, options);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public configure(
|
|
40
|
+
eventRecorder: TrackerEventRecorder,
|
|
41
|
+
options?: SessionTrackingOptions
|
|
42
|
+
) {
|
|
43
|
+
this.eventRecorder = eventRecorder;
|
|
44
|
+
|
|
45
|
+
// Clean up any existing listeners
|
|
46
|
+
this.cleanup();
|
|
47
|
+
|
|
48
|
+
// Apply defaults
|
|
49
|
+
this.options = {
|
|
50
|
+
attributes: options?.attributes ?? {},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Setup state listeners
|
|
54
|
+
if (!this.sessionTrackingActive) {
|
|
55
|
+
sessionListener.addStateChangeListener(
|
|
56
|
+
this.handleStateChange,
|
|
57
|
+
!this.initialEventSent
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
this.sessionTrackingActive = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public cleanup() {
|
|
65
|
+
if (this.sessionTrackingActive) {
|
|
66
|
+
sessionListener.removeStateChangeListener(this.handleStateChange);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.sessionTrackingActive = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private handleStateChange(state: SessionState) {
|
|
73
|
+
if (state === 'started') {
|
|
74
|
+
this.sessionStarted();
|
|
75
|
+
} else {
|
|
76
|
+
this.sessionStopped();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private sessionStarted() {
|
|
81
|
+
const attributes = this.options.attributes ?? {};
|
|
82
|
+
|
|
83
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
84
|
+
SESSION_START_EVENT,
|
|
85
|
+
attributes,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
this.eventRecorder(SESSION_START_EVENT, attributes);
|
|
89
|
+
|
|
90
|
+
// NOTE: The initial event will not be re-sent on re-configuration (e.g. to add additional custom attributes)
|
|
91
|
+
if (!this.initialEventSent) {
|
|
92
|
+
this.initialEventSent = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private sessionStopped() {
|
|
97
|
+
const attributes = this.options.attributes ?? {};
|
|
98
|
+
|
|
99
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
100
|
+
SESSION_STOP_EVENT,
|
|
101
|
+
attributes,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
this.eventRecorder(SESSION_STOP_EVENT, attributes);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
sessionListener,
|
|
6
|
+
SessionState,
|
|
7
|
+
} from '@aws-amplify/core/internals/utils';
|
|
8
|
+
import { ConsoleLogger } from '@aws-amplify/core';
|
|
9
|
+
import {
|
|
10
|
+
SessionTrackingOptions,
|
|
11
|
+
TrackerEventRecorder,
|
|
12
|
+
TrackerInterface,
|
|
13
|
+
} from '../types/trackers';
|
|
14
|
+
|
|
15
|
+
const SESSION_START_EVENT = '_session.start';
|
|
16
|
+
const SESSION_STOP_EVENT = '_session.stop';
|
|
17
|
+
|
|
18
|
+
const logger = new ConsoleLogger('SessionTracker');
|
|
19
|
+
|
|
20
|
+
export class SessionTracker implements TrackerInterface {
|
|
21
|
+
private options: SessionTrackingOptions;
|
|
22
|
+
private eventRecorder: TrackerEventRecorder;
|
|
23
|
+
private sessionTrackingActive: boolean;
|
|
24
|
+
private initialEventSent: boolean;
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
eventRecorder: TrackerEventRecorder,
|
|
28
|
+
options?: SessionTrackingOptions
|
|
29
|
+
) {
|
|
30
|
+
this.options = {};
|
|
31
|
+
this.eventRecorder = eventRecorder;
|
|
32
|
+
this.sessionTrackingActive = false;
|
|
33
|
+
this.initialEventSent = false;
|
|
34
|
+
this.handleStateChange = this.handleStateChange.bind(this);
|
|
35
|
+
|
|
36
|
+
this.configure(eventRecorder, options);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public configure(
|
|
40
|
+
eventRecorder: TrackerEventRecorder,
|
|
41
|
+
options?: SessionTrackingOptions
|
|
42
|
+
) {
|
|
43
|
+
this.eventRecorder = eventRecorder;
|
|
44
|
+
|
|
45
|
+
// Clean up any existing listeners
|
|
46
|
+
this.cleanup();
|
|
47
|
+
|
|
48
|
+
// Apply defaults
|
|
49
|
+
this.options = {
|
|
50
|
+
attributes: options?.attributes ?? {},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Setup state listeners
|
|
54
|
+
if (!this.sessionTrackingActive) {
|
|
55
|
+
sessionListener.addStateChangeListener(
|
|
56
|
+
this.handleStateChange,
|
|
57
|
+
!this.initialEventSent
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
this.sessionTrackingActive = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public cleanup() {
|
|
65
|
+
if (this.sessionTrackingActive) {
|
|
66
|
+
sessionListener.removeStateChangeListener(this.handleStateChange);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.sessionTrackingActive = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private handleStateChange(state: SessionState) {
|
|
73
|
+
if (state === 'started') {
|
|
74
|
+
this.sessionStarted();
|
|
75
|
+
} else {
|
|
76
|
+
this.sessionStopped();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private sessionStarted() {
|
|
81
|
+
const attributes = this.options.attributes ?? {};
|
|
82
|
+
|
|
83
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
84
|
+
SESSION_START_EVENT,
|
|
85
|
+
attributes,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
this.eventRecorder(SESSION_START_EVENT, attributes);
|
|
89
|
+
|
|
90
|
+
// NOTE: The initial event will not be re-sent on re-configuration (e.g. to add additional custom attributes)
|
|
91
|
+
if (!this.initialEventSent) {
|
|
92
|
+
this.initialEventSent = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private sessionStopped() {
|
|
97
|
+
const attributes = this.options.attributes ?? {};
|
|
98
|
+
|
|
99
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
100
|
+
SESSION_STOP_EVENT,
|
|
101
|
+
attributes,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
this.eventRecorder(SESSION_STOP_EVENT, attributes);
|
|
105
|
+
}
|
|
106
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export { AnalyticsServiceOptions } from './options';
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
AnalyticsConfigureAutoTrackInput,
|
|
8
|
+
AnalyticsIdentifyUserInput,
|
|
9
|
+
} from './inputs';
|
|
10
|
+
|
|
11
|
+
export { KinesisStream, KinesisShard, KinesisEventData } from './kinesis';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { UserProfile } from '@aws-amplify/core';
|
|
5
|
+
import { AnalyticsServiceOptions } from '.';
|
|
6
|
+
import {
|
|
7
|
+
SessionTrackingOptions,
|
|
8
|
+
PageViewTrackingOptions,
|
|
9
|
+
EventTrackingOptions,
|
|
10
|
+
} from './trackers';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Input type for `identifyUser`.
|
|
14
|
+
*/
|
|
15
|
+
export type AnalyticsIdentifyUserInput<
|
|
16
|
+
ServiceOptions extends AnalyticsServiceOptions = AnalyticsServiceOptions
|
|
17
|
+
> = {
|
|
18
|
+
/**
|
|
19
|
+
* A User ID associated to the current device.
|
|
20
|
+
*/
|
|
21
|
+
userId: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Additional information about the user and their device.
|
|
25
|
+
*/
|
|
26
|
+
userProfile: UserProfile;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Options to be passed to the API.
|
|
30
|
+
*/
|
|
31
|
+
options?: ServiceOptions;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Input type for `configureAutoTrack`.
|
|
36
|
+
*/
|
|
37
|
+
export type AnalyticsConfigureAutoTrackInput = {
|
|
38
|
+
enable: boolean;
|
|
39
|
+
} & (
|
|
40
|
+
| {
|
|
41
|
+
type: 'session';
|
|
42
|
+
options?: SessionTrackingOptions;
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
type: 'pageView';
|
|
46
|
+
options?: PageViewTrackingOptions;
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
type: 'event';
|
|
50
|
+
options?: EventTrackingOptions;
|
|
51
|
+
}
|
|
52
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export type KinesisStream = {
|
|
5
|
+
region: string;
|
|
6
|
+
streamName: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type KinesisShard = KinesisStream & {
|
|
10
|
+
partitionKey: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type KinesisEventData = Record<string, unknown> | Uint8Array;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export type SessionTrackingOptions = {
|
|
5
|
+
attributes?: TrackerAttributes;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type PageViewTrackingOptions = {
|
|
9
|
+
attributes?: TrackerAttributes;
|
|
10
|
+
eventName?: string;
|
|
11
|
+
urlProvider?: () => string;
|
|
12
|
+
appType?: 'multiPage' | 'singlePage';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type EventTrackingOptions = {
|
|
16
|
+
attributes?: TrackerAttributes;
|
|
17
|
+
events?: DOMEvent[];
|
|
18
|
+
selectorPrefix?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type TrackerType = 'event' | 'pageView' | 'session';
|
|
22
|
+
|
|
23
|
+
export type TrackerAttributes = Record<string, string>;
|
|
24
|
+
|
|
25
|
+
export type TrackerEventRecorder = (
|
|
26
|
+
eventName: string,
|
|
27
|
+
attributes: TrackerAttributes
|
|
28
|
+
) => void;
|
|
29
|
+
|
|
30
|
+
export type DOMEvent = keyof GlobalEventHandlersEventMap;
|
|
31
|
+
|
|
32
|
+
export interface TrackerInterface {
|
|
33
|
+
configure(eventRecorder: TrackerEventRecorder, options?: object): void;
|
|
34
|
+
cleanup(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ConsoleLogger } from '@aws-amplify/core';
|
|
5
|
+
import { EventBufferConfig, IAnalyticsClient } from './';
|
|
6
|
+
|
|
7
|
+
const logger = new ConsoleLogger('EventBuffer');
|
|
8
|
+
|
|
9
|
+
export class EventBuffer<T> {
|
|
10
|
+
private list: T[];
|
|
11
|
+
private readonly config: EventBufferConfig;
|
|
12
|
+
private getAnalyticsClient: () => IAnalyticsClient<T>;
|
|
13
|
+
|
|
14
|
+
private timer?: ReturnType<typeof setInterval>;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
config: EventBufferConfig,
|
|
18
|
+
getAnalyticsClient: () => IAnalyticsClient<T>
|
|
19
|
+
) {
|
|
20
|
+
this.list = [];
|
|
21
|
+
this.config = config;
|
|
22
|
+
this.getAnalyticsClient = getAnalyticsClient;
|
|
23
|
+
this.startEventLoop();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public append(...events: T[]) {
|
|
27
|
+
for (const event of events) {
|
|
28
|
+
if (this.list.length + 1 > this.config.bufferSize) {
|
|
29
|
+
logger.debug(
|
|
30
|
+
`Exceed ${typeof event} event buffer limits, event dropped`
|
|
31
|
+
);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
this.list.push(event);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public flushAll(): Promise<void> {
|
|
39
|
+
return this.submitEvents(this.list.length);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public release() {
|
|
43
|
+
this.list = [];
|
|
44
|
+
if (this.timer) {
|
|
45
|
+
clearInterval(this.timer);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public get length() {
|
|
50
|
+
return this.list.length;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private head(count: number) {
|
|
54
|
+
return this.list.splice(0, count);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private insertAtBeginning(...data: T[]) {
|
|
58
|
+
this.list.unshift(...data);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private startEventLoop() {
|
|
62
|
+
if (this.timer) {
|
|
63
|
+
clearInterval(this.timer);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const { flushSize, flushInterval } = this.config;
|
|
67
|
+
setInterval(() => {
|
|
68
|
+
this.submitEvents(flushSize);
|
|
69
|
+
}, flushInterval);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private submitEvents(count: number): Promise<void> {
|
|
73
|
+
const events = this.head(count);
|
|
74
|
+
if (events.length === 0) {
|
|
75
|
+
return Promise.resolve();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return this.getAnalyticsClient()(events).then(result => {
|
|
79
|
+
if (result.length > 0) {
|
|
80
|
+
this.insertAtBeginning(...result);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export interface IAnalyticsClient<T> {
|
|
5
|
+
(events: T[]): Promise<T[]>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type EventBufferConfig = {
|
|
9
|
+
flushSize: number;
|
|
10
|
+
flushInterval: number;
|
|
11
|
+
bufferSize: number;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export const groupBy = <T>(
|
|
5
|
+
getGroupId: (x: T) => string,
|
|
6
|
+
list: T[]
|
|
7
|
+
): Record<string, T[]> => {
|
|
8
|
+
return list.reduce((result, current) => {
|
|
9
|
+
const groupId = getGroupId(current);
|
|
10
|
+
return { ...result, [groupId]: [...(result[groupId] ?? []), current] };
|
|
11
|
+
}, {} as Record<string, T[]>);
|
|
12
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export { resolveCredentials } from './resolveCredentials';
|
|
5
|
+
export { groupBy } from './groupBy';
|
|
6
|
+
export {
|
|
7
|
+
EventBuffer,
|
|
8
|
+
IAnalyticsClient,
|
|
9
|
+
EventBufferConfig,
|
|
10
|
+
} from './eventBuffer';
|
|
11
|
+
export {
|
|
12
|
+
enableAnalytics,
|
|
13
|
+
disableAnalytics,
|
|
14
|
+
isAnalyticsEnabled,
|
|
15
|
+
} from './statusHelpers';
|
|
16
|
+
export {
|
|
17
|
+
getAnalyticsUserAgent,
|
|
18
|
+
getAnalyticsUserAgentString,
|
|
19
|
+
} from './userAgent';
|
|
20
|
+
export { updateProviderTrackers } from './trackerHelpers';
|
|
21
|
+
export { validateTrackerConfiguration } from './trackerConfigHelpers';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { AnalyticsValidationErrorCode, assertValidationError } from '../errors';
|
|
5
|
+
import { fetchAuthSession } from '@aws-amplify/core';
|
|
6
|
+
|
|
7
|
+
export const resolveCredentials = async () => {
|
|
8
|
+
const { credentials, identityId } = await fetchAuthSession();
|
|
9
|
+
assertValidationError(
|
|
10
|
+
!!credentials,
|
|
11
|
+
AnalyticsValidationErrorCode.NoCredentials
|
|
12
|
+
);
|
|
13
|
+
return { credentials, identityId };
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
let analyticsEnabled = true;
|
|
5
|
+
|
|
6
|
+
export const enableAnalytics = () => {
|
|
7
|
+
analyticsEnabled = true;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const disableAnalytics = () => {
|
|
11
|
+
analyticsEnabled = false;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Returns the current status of the Analytics category.
|
|
16
|
+
*/
|
|
17
|
+
export const isAnalyticsEnabled = () => analyticsEnabled;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { AnalyticsValidationErrorCode, assertValidationError } from '../errors';
|
|
5
|
+
import { AnalyticsConfigureAutoTrackInput } from '../types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Validates tracker configuration.
|
|
9
|
+
*/
|
|
10
|
+
export const validateTrackerConfiguration = (
|
|
11
|
+
input: AnalyticsConfigureAutoTrackInput
|
|
12
|
+
) => {
|
|
13
|
+
// React Native only supports session tracking
|
|
14
|
+
assertValidationError(
|
|
15
|
+
input.type === 'session',
|
|
16
|
+
AnalyticsValidationErrorCode.UnsupportedPlatform
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { AnalyticsValidationErrorCode, assertValidationError } from '../errors';
|
|
5
|
+
import { AnalyticsConfigureAutoTrackInput } from '../types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Validates tracker configuration.
|
|
9
|
+
*/
|
|
10
|
+
export const validateTrackerConfiguration = (
|
|
11
|
+
input: AnalyticsConfigureAutoTrackInput
|
|
12
|
+
) => {
|
|
13
|
+
assertValidationError(
|
|
14
|
+
input.type === 'event' ||
|
|
15
|
+
input.type === 'pageView' ||
|
|
16
|
+
input.type === 'session',
|
|
17
|
+
AnalyticsValidationErrorCode.InvalidTracker
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
TrackerAttributes,
|
|
6
|
+
TrackerEventRecorder,
|
|
7
|
+
TrackerInterface,
|
|
8
|
+
TrackerType,
|
|
9
|
+
} from '../types/trackers';
|
|
10
|
+
import { EventTracker, PageViewTracker, SessionTracker } from '../trackers';
|
|
11
|
+
import { ConfigureAutoTrackInput } from '../providers/pinpoint';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Updates a provider's trackers as appropriate for the provided auto-track configuration.
|
|
15
|
+
*
|
|
16
|
+
* @remark
|
|
17
|
+
* This utility will mutate the provider's configured trackers via `providerTrackers`.
|
|
18
|
+
*/
|
|
19
|
+
export const updateProviderTrackers = (
|
|
20
|
+
input: ConfigureAutoTrackInput,
|
|
21
|
+
providerEventRecorder: TrackerEventRecorder,
|
|
22
|
+
providerTrackers: Partial<Record<TrackerType, TrackerInterface>>
|
|
23
|
+
) => {
|
|
24
|
+
let trackerInstance;
|
|
25
|
+
const trackerType = input.type;
|
|
26
|
+
const currentTracker = providerTrackers[trackerType];
|
|
27
|
+
|
|
28
|
+
// Check if the tracker was disabled & should be cleaned up
|
|
29
|
+
if (!input.enable) {
|
|
30
|
+
if (currentTracker) {
|
|
31
|
+
currentTracker.cleanup();
|
|
32
|
+
delete providerTrackers[trackerType];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Re-configure the existing tracker, or create & configure an instance if it doesn't exist yet
|
|
39
|
+
if (currentTracker) {
|
|
40
|
+
currentTracker.configure(providerEventRecorder, input.options);
|
|
41
|
+
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Create a new tracker instance for the type
|
|
46
|
+
if (trackerType === 'event') {
|
|
47
|
+
trackerInstance = new EventTracker(providerEventRecorder, input.options);
|
|
48
|
+
} else if (trackerType === 'pageView') {
|
|
49
|
+
trackerInstance = new PageViewTracker(providerEventRecorder, input.options);
|
|
50
|
+
} else if (trackerType === 'session') {
|
|
51
|
+
trackerInstance = new SessionTracker(providerEventRecorder, input.options);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (trackerInstance) {
|
|
55
|
+
providerTrackers[trackerType] = trackerInstance;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare enum UpdateEndpointException {
|
|
2
|
-
BadRequestException = "BadRequestException",
|
|
3
|
-
ForbiddenException = "ForbiddenException",
|
|
4
|
-
InternalServerErrorException = "InternalServerErrorException",
|
|
5
|
-
MethodNotAllowedException = "MethodNotAllowedException",
|
|
6
|
-
NotFoundException = "NotFoundException",
|
|
7
|
-
PayloadTooLargeException = "PayloadTooLargeException",
|
|
8
|
-
TooManyRequestsException = "TooManyRequestsException"
|
|
9
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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.UpdateEndpointException = void 0;
|
|
6
|
-
var UpdateEndpointException;
|
|
7
|
-
(function (UpdateEndpointException) {
|
|
8
|
-
UpdateEndpointException["BadRequestException"] = "BadRequestException";
|
|
9
|
-
UpdateEndpointException["ForbiddenException"] = "ForbiddenException";
|
|
10
|
-
UpdateEndpointException["InternalServerErrorException"] = "InternalServerErrorException";
|
|
11
|
-
UpdateEndpointException["MethodNotAllowedException"] = "MethodNotAllowedException";
|
|
12
|
-
UpdateEndpointException["NotFoundException"] = "NotFoundException";
|
|
13
|
-
UpdateEndpointException["PayloadTooLargeException"] = "PayloadTooLargeException";
|
|
14
|
-
UpdateEndpointException["TooManyRequestsException"] = "TooManyRequestsException";
|
|
15
|
-
})(UpdateEndpointException = exports.UpdateEndpointException || (exports.UpdateEndpointException = {}));
|