@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
|
@@ -19,8 +19,9 @@ import { IdentifyUserInput } from '../types';
|
|
|
19
19
|
* await identifyUser({
|
|
20
20
|
* userId,
|
|
21
21
|
* userProfile: {
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* email: 'userEmail@example.com'
|
|
23
|
+
* customProperties: {
|
|
24
|
+
* phoneNumber: ['555-555-5555'],
|
|
24
25
|
* },
|
|
25
26
|
* }
|
|
26
27
|
* });
|
|
@@ -32,8 +33,9 @@ import { IdentifyUserInput } from '../types';
|
|
|
32
33
|
* await identifyUser({
|
|
33
34
|
* userId,
|
|
34
35
|
* userProfile: {
|
|
35
|
-
*
|
|
36
|
-
*
|
|
36
|
+
* email: 'userEmail@example.com'
|
|
37
|
+
* customProperties: {
|
|
38
|
+
* phoneNumber: ['555-555-5555'],
|
|
37
39
|
* },
|
|
38
40
|
* demographic: {
|
|
39
41
|
* platform: 'ios',
|
|
@@ -42,4 +44,4 @@ import { IdentifyUserInput } from '../types';
|
|
|
42
44
|
* }
|
|
43
45
|
* });
|
|
44
46
|
*/
|
|
45
|
-
export declare const identifyUser: ({ userId, userProfile, }: IdentifyUserInput) => Promise<void>;
|
|
47
|
+
export declare const identifyUser: ({ userId, userProfile, options, }: IdentifyUserInput) => Promise<void>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { __awaiter, __generator } from "tslib";
|
|
4
4
|
import { AnalyticsAction } from '@aws-amplify/core/internals/utils';
|
|
5
|
-
import { updateEndpoint } from '@aws-amplify/core/internals/providers/pinpoint';
|
|
6
|
-
import { getAnalyticsUserAgentString } from '../../../utils
|
|
5
|
+
import { updateEndpoint, } from '@aws-amplify/core/internals/providers/pinpoint';
|
|
6
|
+
import { getAnalyticsUserAgentString } from '../../../utils';
|
|
7
7
|
import { resolveConfig, resolveCredentials } from '../utils';
|
|
8
8
|
/**
|
|
9
9
|
* Sends information about a user to Pinpoint. Sending user information allows you to associate a user to their user
|
|
@@ -25,8 +25,9 @@ import { resolveConfig, resolveCredentials } from '../utils';
|
|
|
25
25
|
* await identifyUser({
|
|
26
26
|
* userId,
|
|
27
27
|
* userProfile: {
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* email: 'userEmail@example.com'
|
|
29
|
+
* customProperties: {
|
|
30
|
+
* phoneNumber: ['555-555-5555'],
|
|
30
31
|
* },
|
|
31
32
|
* }
|
|
32
33
|
* });
|
|
@@ -38,8 +39,9 @@ import { resolveConfig, resolveCredentials } from '../utils';
|
|
|
38
39
|
* await identifyUser({
|
|
39
40
|
* userId,
|
|
40
41
|
* userProfile: {
|
|
41
|
-
*
|
|
42
|
-
*
|
|
42
|
+
* email: 'userEmail@example.com'
|
|
43
|
+
* customProperties: {
|
|
44
|
+
* phoneNumber: ['555-555-5555'],
|
|
43
45
|
* },
|
|
44
46
|
* demographic: {
|
|
45
47
|
* platform: 'ios',
|
|
@@ -49,24 +51,26 @@ import { resolveConfig, resolveCredentials } from '../utils';
|
|
|
49
51
|
* });
|
|
50
52
|
*/
|
|
51
53
|
export var identifyUser = function (_a) {
|
|
52
|
-
var userId = _a.userId, userProfile = _a.userProfile;
|
|
54
|
+
var userId = _a.userId, userProfile = _a.userProfile, options = _a.options;
|
|
53
55
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
-
var _b, credentials, identityId, _c, appId, region;
|
|
56
|
+
var _b, credentials, identityId, _c, appId, region, userAttributes;
|
|
55
57
|
return __generator(this, function (_d) {
|
|
56
58
|
switch (_d.label) {
|
|
57
59
|
case 0: return [4 /*yield*/, resolveCredentials()];
|
|
58
60
|
case 1:
|
|
59
61
|
_b = _d.sent(), credentials = _b.credentials, identityId = _b.identityId;
|
|
60
62
|
_c = resolveConfig(), appId = _c.appId, region = _c.region;
|
|
63
|
+
userAttributes = (options !== null && options !== void 0 ? options : {}).userAttributes;
|
|
61
64
|
updateEndpoint({
|
|
62
65
|
appId: appId,
|
|
63
66
|
category: 'Analytics',
|
|
64
67
|
credentials: credentials,
|
|
65
68
|
identityId: identityId,
|
|
66
69
|
region: region,
|
|
70
|
+
userAttributes: userAttributes,
|
|
67
71
|
userId: userId,
|
|
68
72
|
userProfile: userProfile,
|
|
69
|
-
userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.
|
|
73
|
+
userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.IdentifyUser),
|
|
70
74
|
});
|
|
71
75
|
return [2 /*return*/];
|
|
72
76
|
}
|
|
@@ -10,27 +10,21 @@ import { RecordInput } from '../types';
|
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
12
12
|
* // Send an event to Pinpoint
|
|
13
|
-
* record({
|
|
14
|
-
* event: {
|
|
15
|
-
* name: eventName,
|
|
16
|
-
* }
|
|
17
|
-
* })
|
|
13
|
+
* record({ name: eventName })
|
|
18
14
|
* ```
|
|
19
15
|
*
|
|
20
16
|
* @example
|
|
21
17
|
* ```ts
|
|
22
18
|
* // Send an event to Pinpoint with metrics & custom attributes
|
|
23
19
|
* record({
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* 'my-metric': metricValue
|
|
31
|
-
* }
|
|
20
|
+
* name: eventName,
|
|
21
|
+
* attributes: {
|
|
22
|
+
* 'my-attribute': attributeValue
|
|
23
|
+
* },
|
|
24
|
+
* metrics: {
|
|
25
|
+
* 'my-metric': metricValue
|
|
32
26
|
* }
|
|
33
27
|
* })
|
|
34
28
|
* ```
|
|
35
29
|
*/
|
|
36
|
-
export declare const record: (
|
|
30
|
+
export declare const record: (input: RecordInput) => void;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import {
|
|
3
|
+
import { Hub, ConsoleLogger } from '@aws-amplify/core';
|
|
4
|
+
import { AMPLIFY_SYMBOL, AnalyticsAction, } from '@aws-amplify/core/internals/utils';
|
|
4
5
|
import { record as recordCore } from '@aws-amplify/core/internals/providers/pinpoint';
|
|
5
6
|
import { AnalyticsValidationErrorCode, assertValidationError, } from '../../../errors';
|
|
6
|
-
import { getAnalyticsUserAgentString } from '../../../utils
|
|
7
|
+
import { getAnalyticsUserAgentString, isAnalyticsEnabled, } from '../../../utils';
|
|
7
8
|
import { resolveConfig, resolveCredentials } from '../utils';
|
|
8
|
-
var logger = new
|
|
9
|
+
var logger = new ConsoleLogger('Analytics');
|
|
9
10
|
/**
|
|
10
11
|
* Records an Analytic event to Pinpoint. Events will be buffered and periodically sent to Pinpoint.
|
|
11
12
|
*
|
|
@@ -17,42 +18,39 @@ var logger = new Logger('Analytics');
|
|
|
17
18
|
* @example
|
|
18
19
|
* ```ts
|
|
19
20
|
* // Send an event to Pinpoint
|
|
20
|
-
* record({
|
|
21
|
-
* event: {
|
|
22
|
-
* name: eventName,
|
|
23
|
-
* }
|
|
24
|
-
* })
|
|
21
|
+
* record({ name: eventName })
|
|
25
22
|
* ```
|
|
26
23
|
*
|
|
27
24
|
* @example
|
|
28
25
|
* ```ts
|
|
29
26
|
* // Send an event to Pinpoint with metrics & custom attributes
|
|
30
27
|
* record({
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* 'my-metric': metricValue
|
|
38
|
-
* }
|
|
28
|
+
* name: eventName,
|
|
29
|
+
* attributes: {
|
|
30
|
+
* 'my-attribute': attributeValue
|
|
31
|
+
* },
|
|
32
|
+
* metrics: {
|
|
33
|
+
* 'my-metric': metricValue
|
|
39
34
|
* }
|
|
40
35
|
* })
|
|
41
36
|
* ```
|
|
42
37
|
*/
|
|
43
|
-
export var record = function (
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
export var record = function (input) {
|
|
39
|
+
var _a = resolveConfig(), appId = _a.appId, region = _a.region;
|
|
40
|
+
if (!isAnalyticsEnabled()) {
|
|
41
|
+
logger.debug('Analytics is disabled, event will not be recorded.');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
assertValidationError(!!input.name, AnalyticsValidationErrorCode.NoEventName);
|
|
48
45
|
resolveCredentials()
|
|
49
46
|
.then(function (_a) {
|
|
50
47
|
var credentials = _a.credentials, identityId = _a.identityId;
|
|
48
|
+
Hub.dispatch('analytics', { event: 'record', data: input, message: 'Recording Analytics event' }, 'Analytics', AMPLIFY_SYMBOL);
|
|
51
49
|
recordCore({
|
|
52
50
|
appId: appId,
|
|
53
51
|
category: 'Analytics',
|
|
54
52
|
credentials: credentials,
|
|
55
|
-
event:
|
|
53
|
+
event: input,
|
|
56
54
|
identityId: identityId,
|
|
57
55
|
region: region,
|
|
58
56
|
userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.Record),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { record, identifyUser } from './apis';
|
|
2
|
-
export { RecordInput, IdentifyUserInput } from './types/inputs';
|
|
1
|
+
export { record, identifyUser, flushEvents, configureAutoTrack } from './apis';
|
|
2
|
+
export { RecordInput, IdentifyUserInput, ConfigureAutoTrackInput, } from './types/inputs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { RecordInput, IdentifyUserInput, ConfigureAutoTrackInput, } from './inputs';
|
|
2
|
+
export { IdentifyUserOptions } from './options';
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
import { UserProfile } from '@aws-amplify/core';
|
|
2
1
|
import { PinpointAnalyticsEvent } from '@aws-amplify/core/internals/providers/pinpoint';
|
|
2
|
+
import { IdentifyUserOptions } from '.';
|
|
3
|
+
import { AnalyticsConfigureAutoTrackInput, AnalyticsIdentifyUserInput } from '../../../types';
|
|
3
4
|
/**
|
|
4
5
|
* Input type for Pinpoint record API.
|
|
5
6
|
*/
|
|
6
|
-
export type RecordInput =
|
|
7
|
-
/**
|
|
8
|
-
* An event to send to the default Analytics provider.
|
|
9
|
-
*/
|
|
10
|
-
event: PinpointAnalyticsEvent;
|
|
11
|
-
};
|
|
7
|
+
export type RecordInput = PinpointAnalyticsEvent;
|
|
12
8
|
/**
|
|
13
9
|
* Input type for Pinpoint identifyUser API.
|
|
14
10
|
*/
|
|
15
|
-
export type IdentifyUserInput =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Additional information about the user and their device.
|
|
22
|
-
*/
|
|
23
|
-
userProfile: UserProfile;
|
|
24
|
-
};
|
|
11
|
+
export type IdentifyUserInput = AnalyticsIdentifyUserInput<IdentifyUserOptions>;
|
|
12
|
+
/**
|
|
13
|
+
* Input type for Pinpoint configureAutoTrack API.
|
|
14
|
+
*/
|
|
15
|
+
export type ConfigureAutoTrackInput = AnalyticsConfigureAutoTrackInput;
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* @internal
|
|
3
3
|
*/
|
|
4
4
|
export declare const resolveCredentials: () => Promise<{
|
|
5
|
-
credentials:
|
|
6
|
-
accessKeyId: string;
|
|
7
|
-
secretAccessKey: string;
|
|
8
|
-
sessionToken?: string | undefined;
|
|
9
|
-
expiration?: Date | undefined;
|
|
10
|
-
};
|
|
5
|
+
credentials: import("@aws-amplify/core/lib-esm/libraryUtils").AWSCredentials;
|
|
11
6
|
identityId: string | undefined;
|
|
12
7
|
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EventTrackingOptions, TrackerEventRecorder, TrackerInterface } from '../types/trackers';
|
|
2
|
+
export declare class EventTracker implements TrackerInterface {
|
|
3
|
+
private trackerActive;
|
|
4
|
+
private options;
|
|
5
|
+
private eventRecorder;
|
|
6
|
+
constructor(eventRecorder: TrackerEventRecorder, options?: EventTrackingOptions);
|
|
7
|
+
configure(eventRecorder: TrackerEventRecorder, options?: EventTrackingOptions): void;
|
|
8
|
+
cleanup(): void;
|
|
9
|
+
private handleDocEvent;
|
|
10
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { ConsoleLogger } from '@aws-amplify/core';
|
|
4
|
+
import { isBrowser } from '@aws-amplify/core/internals/utils';
|
|
5
|
+
var DEFAULT_EVENTS = ['click'];
|
|
6
|
+
var DEFAULT_SELECTOR_PREFIX = 'data-amplify-analytics-';
|
|
7
|
+
var DEFAULT_EVENT_NAME = 'event'; // Default event name as sent to the analytics provider
|
|
8
|
+
var logger = new ConsoleLogger('EventTracker');
|
|
9
|
+
var EventTracker = /** @class */ (function () {
|
|
10
|
+
function EventTracker(eventRecorder, options) {
|
|
11
|
+
this.options = {};
|
|
12
|
+
this.trackerActive = false;
|
|
13
|
+
this.eventRecorder = eventRecorder;
|
|
14
|
+
this.handleDocEvent = this.handleDocEvent.bind(this);
|
|
15
|
+
this.configure(eventRecorder, options);
|
|
16
|
+
}
|
|
17
|
+
EventTracker.prototype.configure = function (eventRecorder, options) {
|
|
18
|
+
var _this = this;
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
this.eventRecorder = eventRecorder;
|
|
21
|
+
// Clean up any existing listeners
|
|
22
|
+
this.cleanup();
|
|
23
|
+
// Apply defaults
|
|
24
|
+
this.options = {
|
|
25
|
+
attributes: (_a = options === null || options === void 0 ? void 0 : options.attributes) !== null && _a !== void 0 ? _a : undefined,
|
|
26
|
+
events: (_b = options === null || options === void 0 ? void 0 : options.events) !== null && _b !== void 0 ? _b : DEFAULT_EVENTS,
|
|
27
|
+
selectorPrefix: (_c = options === null || options === void 0 ? void 0 : options.selectorPrefix) !== null && _c !== void 0 ? _c : DEFAULT_SELECTOR_PREFIX,
|
|
28
|
+
};
|
|
29
|
+
// Register event listeners
|
|
30
|
+
if (isBrowser()) {
|
|
31
|
+
(_d = this.options.events) === null || _d === void 0 ? void 0 : _d.forEach(function (targetEvent) {
|
|
32
|
+
document.addEventListener(targetEvent, _this.handleDocEvent, {
|
|
33
|
+
capture: true,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
this.trackerActive = true;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
EventTracker.prototype.cleanup = function () {
|
|
40
|
+
var _this = this;
|
|
41
|
+
var _a;
|
|
42
|
+
// No-op if document listener is not active
|
|
43
|
+
if (!this.trackerActive) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Clean up event listeners
|
|
47
|
+
(_a = this.options.events) === null || _a === void 0 ? void 0 : _a.forEach(function (targetEvent) {
|
|
48
|
+
document.removeEventListener(targetEvent, _this.handleDocEvent, {
|
|
49
|
+
capture: true,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
EventTracker.prototype.handleDocEvent = function (event) {
|
|
54
|
+
var _a;
|
|
55
|
+
/**
|
|
56
|
+
* Example DOM element:
|
|
57
|
+
*
|
|
58
|
+
* ```
|
|
59
|
+
* <button
|
|
60
|
+
* data-amplify-analytics-on="click"
|
|
61
|
+
* data-amplify-analytics-name="click"
|
|
62
|
+
* data-amplify-analytics-attrs="attr1:attr1_value,attr2:attr2_value"
|
|
63
|
+
* />
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
var triggerSelector = "[".concat(this.options.selectorPrefix, "on]");
|
|
67
|
+
var attrSelector = "".concat(this.options.selectorPrefix, "attrs");
|
|
68
|
+
var eventNameSelector = "".concat(this.options.selectorPrefix, "name");
|
|
69
|
+
var eventSource = event.target;
|
|
70
|
+
// Validate that the triggering event type is being tracked
|
|
71
|
+
if (!((_a = this.options.events) === null || _a === void 0 ? void 0 : _a.includes(event.type))) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (eventSource instanceof HTMLElement) {
|
|
75
|
+
var target = eventSource.closest(triggerSelector);
|
|
76
|
+
if (target) {
|
|
77
|
+
// Parse event name from the element
|
|
78
|
+
var eventName = target.getAttribute(eventNameSelector) || DEFAULT_EVENT_NAME;
|
|
79
|
+
// Parse attributes from the element
|
|
80
|
+
var elementAttributes_1 = {};
|
|
81
|
+
var rawElementAttributes = target.getAttribute(attrSelector);
|
|
82
|
+
rawElementAttributes === null || rawElementAttributes === void 0 ? void 0 : rawElementAttributes.split(/\s*,\s*/).forEach(function (attr) {
|
|
83
|
+
var tmp = attr.trim().split(/\s*:\s*/);
|
|
84
|
+
elementAttributes_1[tmp[0]] = tmp[1];
|
|
85
|
+
});
|
|
86
|
+
// Assemble final list of attributes
|
|
87
|
+
var attributes = Object.assign({
|
|
88
|
+
type: event.type,
|
|
89
|
+
target: "".concat(target.localName, " with id ").concat(target.id),
|
|
90
|
+
}, this.options.attributes, elementAttributes_1);
|
|
91
|
+
logger.debug('Recording automatically tracked DOM event', {
|
|
92
|
+
eventName: eventName,
|
|
93
|
+
attributes: attributes,
|
|
94
|
+
});
|
|
95
|
+
this.eventRecorder(eventName, attributes);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return EventTracker;
|
|
100
|
+
}());
|
|
101
|
+
export { EventTracker };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PageViewTrackingOptions, TrackerEventRecorder, TrackerInterface } from '../types/trackers';
|
|
2
|
+
export declare class PageViewTracker implements TrackerInterface {
|
|
3
|
+
private trackerActive;
|
|
4
|
+
private options;
|
|
5
|
+
private eventRecorder;
|
|
6
|
+
private spaTrackingActive;
|
|
7
|
+
private pushStateProxy?;
|
|
8
|
+
private replaceStateProxy?;
|
|
9
|
+
private originalPushState;
|
|
10
|
+
private originalReplaceState;
|
|
11
|
+
constructor(eventRecorder: TrackerEventRecorder, options?: PageViewTrackingOptions);
|
|
12
|
+
configure(eventRecorder: TrackerEventRecorder, options?: PageViewTrackingOptions): void;
|
|
13
|
+
cleanup(): void;
|
|
14
|
+
private setupSPATracking;
|
|
15
|
+
private setupMPATracking;
|
|
16
|
+
private handleLocationChange;
|
|
17
|
+
private urlHasChanged;
|
|
18
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { ConsoleLogger } from '@aws-amplify/core';
|
|
4
|
+
import { isBrowser } from '@aws-amplify/core/internals/utils';
|
|
5
|
+
var logger = new ConsoleLogger('PageViewTracker');
|
|
6
|
+
var DEFAULT_EVENT_NAME = 'pageView';
|
|
7
|
+
var DEFAULT_APP_TYPE = 'singlePage';
|
|
8
|
+
var DEFAULT_URL_PROVIDER = function () {
|
|
9
|
+
return window.location.origin + window.location.pathname;
|
|
10
|
+
};
|
|
11
|
+
var PREV_URL_STORAGE_KEY = 'aws-amplify-analytics-prevUrl';
|
|
12
|
+
var PageViewTracker = /** @class */ (function () {
|
|
13
|
+
function PageViewTracker(eventRecorder, options) {
|
|
14
|
+
this.options = {};
|
|
15
|
+
this.trackerActive = true;
|
|
16
|
+
this.eventRecorder = eventRecorder;
|
|
17
|
+
this.spaTrackingActive = false;
|
|
18
|
+
this.handleLocationChange = this.handleLocationChange.bind(this);
|
|
19
|
+
this.configure(eventRecorder, options);
|
|
20
|
+
}
|
|
21
|
+
PageViewTracker.prototype.configure = function (eventRecorder, options) {
|
|
22
|
+
var _a, _b, _c, _d, _e, _f;
|
|
23
|
+
this.eventRecorder = eventRecorder;
|
|
24
|
+
// Clean up any existing listeners
|
|
25
|
+
this.cleanup();
|
|
26
|
+
// Apply defaults
|
|
27
|
+
this.options = {
|
|
28
|
+
appType: (_a = options === null || options === void 0 ? void 0 : options.appType) !== null && _a !== void 0 ? _a : DEFAULT_APP_TYPE,
|
|
29
|
+
attributes: (_b = options === null || options === void 0 ? void 0 : options.attributes) !== null && _b !== void 0 ? _b : undefined,
|
|
30
|
+
eventName: (_d = (_c = this.options) === null || _c === void 0 ? void 0 : _c.eventName) !== null && _d !== void 0 ? _d : DEFAULT_EVENT_NAME,
|
|
31
|
+
urlProvider: (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.urlProvider) !== null && _f !== void 0 ? _f : DEFAULT_URL_PROVIDER,
|
|
32
|
+
};
|
|
33
|
+
// Configure SPA or MPA page view tracking
|
|
34
|
+
if (isBrowser()) {
|
|
35
|
+
if (this.options.appType === 'singlePage') {
|
|
36
|
+
this.setupSPATracking();
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.setupMPATracking();
|
|
40
|
+
}
|
|
41
|
+
this.trackerActive = true;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
PageViewTracker.prototype.cleanup = function () {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
// No-op if document listener is not active
|
|
47
|
+
if (!this.trackerActive) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// Clean up SPA page view listeners
|
|
51
|
+
if (this.spaTrackingActive) {
|
|
52
|
+
window.history.pushState = this.originalPushState;
|
|
53
|
+
window.history.replaceState = this.originalReplaceState;
|
|
54
|
+
(_a = this.pushStateProxy) === null || _a === void 0 ? void 0 : _a.revoke();
|
|
55
|
+
(_b = this.replaceStateProxy) === null || _b === void 0 ? void 0 : _b.revoke();
|
|
56
|
+
window.removeEventListener('popstate', this.handleLocationChange);
|
|
57
|
+
this.spaTrackingActive = false;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
PageViewTracker.prototype.setupSPATracking = function () {
|
|
61
|
+
var _this = this;
|
|
62
|
+
if (!this.spaTrackingActive) {
|
|
63
|
+
// Configure proxies on History APIs
|
|
64
|
+
this.pushStateProxy = Proxy.revocable(window.history.pushState, {
|
|
65
|
+
apply: function (target, thisArg, args) {
|
|
66
|
+
var proxiedResult = target.apply(thisArg, args);
|
|
67
|
+
_this.handleLocationChange();
|
|
68
|
+
return proxiedResult;
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
this.replaceStateProxy = Proxy.revocable(window.history.replaceState, {
|
|
72
|
+
apply: function (target, thisArg, args) {
|
|
73
|
+
var proxiedResult = target.apply(thisArg, args);
|
|
74
|
+
_this.handleLocationChange();
|
|
75
|
+
return proxiedResult;
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
this.originalPushState = window.history.pushState;
|
|
79
|
+
this.originalReplaceState = window.history.replaceState;
|
|
80
|
+
window.history.pushState = this.pushStateProxy.proxy;
|
|
81
|
+
window.history.replaceState = this.replaceStateProxy.proxy;
|
|
82
|
+
window.addEventListener('popstate', this.handleLocationChange);
|
|
83
|
+
sessionStorage.removeItem(PREV_URL_STORAGE_KEY);
|
|
84
|
+
this.spaTrackingActive = true;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
PageViewTracker.prototype.setupMPATracking = function () {
|
|
88
|
+
this.handleLocationChange();
|
|
89
|
+
};
|
|
90
|
+
PageViewTracker.prototype.handleLocationChange = function () {
|
|
91
|
+
var currentUrl = this.options.urlProvider();
|
|
92
|
+
var eventName = this.options.eventName || DEFAULT_EVENT_NAME;
|
|
93
|
+
if (this.urlHasChanged()) {
|
|
94
|
+
sessionStorage.setItem(PREV_URL_STORAGE_KEY, currentUrl);
|
|
95
|
+
// Assemble attribute list
|
|
96
|
+
var attributes = Object.assign({
|
|
97
|
+
url: currentUrl,
|
|
98
|
+
}, this.options.attributes);
|
|
99
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
100
|
+
eventName: eventName,
|
|
101
|
+
attributes: attributes,
|
|
102
|
+
});
|
|
103
|
+
this.eventRecorder(eventName, attributes);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
PageViewTracker.prototype.urlHasChanged = function () {
|
|
107
|
+
var prevUrl = sessionStorage.getItem(PREV_URL_STORAGE_KEY);
|
|
108
|
+
var currUrl = this.options.urlProvider();
|
|
109
|
+
return currUrl !== prevUrl;
|
|
110
|
+
};
|
|
111
|
+
return PageViewTracker;
|
|
112
|
+
}());
|
|
113
|
+
export { PageViewTracker };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SessionTrackingOptions, TrackerEventRecorder, TrackerInterface } from '../types/trackers';
|
|
2
|
+
export declare class SessionTracker implements TrackerInterface {
|
|
3
|
+
private options;
|
|
4
|
+
private eventRecorder;
|
|
5
|
+
private sessionTrackingActive;
|
|
6
|
+
private initialEventSent;
|
|
7
|
+
constructor(eventRecorder: TrackerEventRecorder, options?: SessionTrackingOptions);
|
|
8
|
+
configure(eventRecorder: TrackerEventRecorder, options?: SessionTrackingOptions): void;
|
|
9
|
+
cleanup(): void;
|
|
10
|
+
private handleStateChange;
|
|
11
|
+
private sessionStarted;
|
|
12
|
+
private sessionStopped;
|
|
13
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { sessionListener, } from '@aws-amplify/core/internals/utils';
|
|
4
|
+
import { ConsoleLogger } from '@aws-amplify/core';
|
|
5
|
+
var SESSION_START_EVENT = '_session.start';
|
|
6
|
+
var SESSION_STOP_EVENT = '_session.stop';
|
|
7
|
+
var logger = new ConsoleLogger('SessionTracker');
|
|
8
|
+
var SessionTracker = /** @class */ (function () {
|
|
9
|
+
function SessionTracker(eventRecorder, options) {
|
|
10
|
+
this.options = {};
|
|
11
|
+
this.eventRecorder = eventRecorder;
|
|
12
|
+
this.sessionTrackingActive = false;
|
|
13
|
+
this.initialEventSent = false;
|
|
14
|
+
this.handleStateChange = this.handleStateChange.bind(this);
|
|
15
|
+
this.configure(eventRecorder, options);
|
|
16
|
+
}
|
|
17
|
+
SessionTracker.prototype.configure = function (eventRecorder, options) {
|
|
18
|
+
var _a;
|
|
19
|
+
this.eventRecorder = eventRecorder;
|
|
20
|
+
// Clean up any existing listeners
|
|
21
|
+
this.cleanup();
|
|
22
|
+
// Apply defaults
|
|
23
|
+
this.options = {
|
|
24
|
+
attributes: (_a = options === null || options === void 0 ? void 0 : options.attributes) !== null && _a !== void 0 ? _a : {},
|
|
25
|
+
};
|
|
26
|
+
// Setup state listeners
|
|
27
|
+
if (!this.sessionTrackingActive) {
|
|
28
|
+
sessionListener.addStateChangeListener(this.handleStateChange, !this.initialEventSent);
|
|
29
|
+
this.sessionTrackingActive = true;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
SessionTracker.prototype.cleanup = function () {
|
|
33
|
+
if (this.sessionTrackingActive) {
|
|
34
|
+
sessionListener.removeStateChangeListener(this.handleStateChange);
|
|
35
|
+
}
|
|
36
|
+
this.sessionTrackingActive = false;
|
|
37
|
+
};
|
|
38
|
+
SessionTracker.prototype.handleStateChange = function (state) {
|
|
39
|
+
if (state === 'started') {
|
|
40
|
+
this.sessionStarted();
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.sessionStopped();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
SessionTracker.prototype.sessionStarted = function () {
|
|
47
|
+
var _a;
|
|
48
|
+
var attributes = (_a = this.options.attributes) !== null && _a !== void 0 ? _a : {};
|
|
49
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
50
|
+
SESSION_START_EVENT: SESSION_START_EVENT,
|
|
51
|
+
attributes: attributes,
|
|
52
|
+
});
|
|
53
|
+
this.eventRecorder(SESSION_START_EVENT, attributes);
|
|
54
|
+
// NOTE: The initial event will not be re-sent on re-configuration (e.g. to add additional custom attributes)
|
|
55
|
+
if (!this.initialEventSent) {
|
|
56
|
+
this.initialEventSent = true;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
SessionTracker.prototype.sessionStopped = function () {
|
|
60
|
+
var _a;
|
|
61
|
+
var attributes = (_a = this.options.attributes) !== null && _a !== void 0 ? _a : {};
|
|
62
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
63
|
+
SESSION_STOP_EVENT: SESSION_STOP_EVENT,
|
|
64
|
+
attributes: attributes,
|
|
65
|
+
});
|
|
66
|
+
this.eventRecorder(SESSION_STOP_EVENT, attributes);
|
|
67
|
+
};
|
|
68
|
+
return SessionTracker;
|
|
69
|
+
}());
|
|
70
|
+
export { SessionTracker };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SessionTrackingOptions, TrackerEventRecorder, TrackerInterface } from '../types/trackers';
|
|
2
|
+
export declare class SessionTracker implements TrackerInterface {
|
|
3
|
+
private options;
|
|
4
|
+
private eventRecorder;
|
|
5
|
+
private initialEventSent;
|
|
6
|
+
private sessionTrackingActive;
|
|
7
|
+
constructor(eventRecorder: TrackerEventRecorder, options?: SessionTrackingOptions);
|
|
8
|
+
configure(eventRecorder: TrackerEventRecorder, options?: SessionTrackingOptions): void;
|
|
9
|
+
cleanup(): void;
|
|
10
|
+
private handleStateChange;
|
|
11
|
+
private sessionStarted;
|
|
12
|
+
private sessionStopped;
|
|
13
|
+
}
|