@aws-amplify/analytics 0.0.0-unstable-1ca644b-20260128091132
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/README.md +3 -0
- package/dist/cjs/apis/disable.js +16 -0
- package/dist/cjs/apis/disable.js.map +1 -0
- package/dist/cjs/apis/enable.js +15 -0
- package/dist/cjs/apis/enable.js.map +1 -0
- package/dist/cjs/apis/index.js +11 -0
- package/dist/cjs/apis/index.js.map +1 -0
- package/dist/cjs/errors/AnalyticsError.js +21 -0
- package/dist/cjs/errors/AnalyticsError.js.map +1 -0
- package/dist/cjs/errors/assertValidationError.js +22 -0
- package/dist/cjs/errors/assertValidationError.js.map +1 -0
- package/dist/cjs/errors/index.js +14 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/errors/validation.js +44 -0
- package/dist/cjs/errors/validation.js.map +1 -0
- package/dist/cjs/index.js +17 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/providers/kinesis/apis/flushEvents.js +39 -0
- package/dist/cjs/providers/kinesis/apis/flushEvents.js.map +1 -0
- package/dist/cjs/providers/kinesis/apis/index.js +11 -0
- package/dist/cjs/providers/kinesis/apis/index.js.map +1 -0
- package/dist/cjs/providers/kinesis/apis/record.js +69 -0
- package/dist/cjs/providers/kinesis/apis/record.js.map +1 -0
- package/dist/cjs/providers/kinesis/index.js +10 -0
- package/dist/cjs/providers/kinesis/index.js.map +1 -0
- package/dist/cjs/providers/kinesis/types/buffer.js +6 -0
- package/dist/cjs/providers/kinesis/types/buffer.js.map +1 -0
- package/dist/cjs/providers/kinesis/types/index.js +6 -0
- package/dist/cjs/providers/kinesis/types/index.js.map +1 -0
- package/dist/cjs/providers/kinesis/types/inputs.js +6 -0
- package/dist/cjs/providers/kinesis/types/inputs.js.map +1 -0
- package/dist/cjs/providers/kinesis/utils/constants.js +13 -0
- package/dist/cjs/providers/kinesis/utils/constants.js.map +1 -0
- package/dist/cjs/providers/kinesis/utils/getEventBuffer.js +85 -0
- package/dist/cjs/providers/kinesis/utils/getEventBuffer.js.map +1 -0
- package/dist/cjs/providers/kinesis/utils/resolveConfig.js +27 -0
- package/dist/cjs/providers/kinesis/utils/resolveConfig.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/apis/flushEvents.js +38 -0
- package/dist/cjs/providers/kinesis-firehose/apis/flushEvents.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/apis/index.js +11 -0
- package/dist/cjs/providers/kinesis-firehose/apis/index.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/apis/record.js +62 -0
- package/dist/cjs/providers/kinesis-firehose/apis/record.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/index.js +10 -0
- package/dist/cjs/providers/kinesis-firehose/index.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/types/buffer.js +6 -0
- package/dist/cjs/providers/kinesis-firehose/types/buffer.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/types/index.js +6 -0
- package/dist/cjs/providers/kinesis-firehose/types/index.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/types/inputs.js +6 -0
- package/dist/cjs/providers/kinesis-firehose/types/inputs.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/utils/constants.js +13 -0
- package/dist/cjs/providers/kinesis-firehose/utils/constants.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/utils/getEventBuffer.js +83 -0
- package/dist/cjs/providers/kinesis-firehose/utils/getEventBuffer.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/utils/index.js +11 -0
- package/dist/cjs/providers/kinesis-firehose/utils/index.js.map +1 -0
- package/dist/cjs/providers/kinesis-firehose/utils/resolveConfig.js +27 -0
- package/dist/cjs/providers/kinesis-firehose/utils/resolveConfig.js.map +1 -0
- package/dist/cjs/providers/personalize/apis/flushEvents.js +37 -0
- package/dist/cjs/providers/personalize/apis/flushEvents.js.map +1 -0
- package/dist/cjs/providers/personalize/apis/index.js +11 -0
- package/dist/cjs/providers/personalize/apis/index.js.map +1 -0
- package/dist/cjs/providers/personalize/apis/record.js +98 -0
- package/dist/cjs/providers/personalize/apis/record.js.map +1 -0
- package/dist/cjs/providers/personalize/index.js +10 -0
- package/dist/cjs/providers/personalize/index.js.map +1 -0
- package/dist/cjs/providers/personalize/types/buffer.js +6 -0
- package/dist/cjs/providers/personalize/types/buffer.js.map +1 -0
- package/dist/cjs/providers/personalize/types/index.js +6 -0
- package/dist/cjs/providers/personalize/types/index.js.map +1 -0
- package/dist/cjs/providers/personalize/types/inputs.js +6 -0
- package/dist/cjs/providers/personalize/types/inputs.js.map +1 -0
- package/dist/cjs/providers/personalize/utils/autoTrackMedia.js +183 -0
- package/dist/cjs/providers/personalize/utils/autoTrackMedia.js.map +1 -0
- package/dist/cjs/providers/personalize/utils/cachedSession.js +51 -0
- package/dist/cjs/providers/personalize/utils/cachedSession.js.map +1 -0
- package/dist/cjs/providers/personalize/utils/constants.js +14 -0
- package/dist/cjs/providers/personalize/utils/constants.js.map +1 -0
- package/dist/cjs/providers/personalize/utils/getEventBuffer.js +86 -0
- package/dist/cjs/providers/personalize/utils/getEventBuffer.js.map +1 -0
- package/dist/cjs/providers/personalize/utils/index.js +19 -0
- package/dist/cjs/providers/personalize/utils/index.js.map +1 -0
- package/dist/cjs/providers/personalize/utils/resolveConfig.js +28 -0
- package/dist/cjs/providers/personalize/utils/resolveConfig.js.map +1 -0
- package/dist/cjs/providers/pinpoint/apis/configureAutoTrack.js +39 -0
- package/dist/cjs/providers/pinpoint/apis/configureAutoTrack.js.map +1 -0
- package/dist/cjs/providers/pinpoint/apis/flushEvents.js +43 -0
- package/dist/cjs/providers/pinpoint/apis/flushEvents.js.map +1 -0
- package/dist/cjs/providers/pinpoint/apis/identifyUser.js +75 -0
- package/dist/cjs/providers/pinpoint/apis/identifyUser.js.map +1 -0
- package/dist/cjs/providers/pinpoint/apis/index.js +15 -0
- package/dist/cjs/providers/pinpoint/apis/index.js.map +1 -0
- package/dist/cjs/providers/pinpoint/apis/record.js +74 -0
- package/dist/cjs/providers/pinpoint/apis/record.js.map +1 -0
- package/dist/cjs/providers/pinpoint/index.js +12 -0
- package/dist/cjs/providers/pinpoint/index.js.map +1 -0
- package/dist/cjs/providers/pinpoint/types/index.js +6 -0
- package/dist/cjs/providers/pinpoint/types/index.js.map +1 -0
- package/dist/cjs/providers/pinpoint/types/inputs.js +6 -0
- package/dist/cjs/providers/pinpoint/types/inputs.js.map +1 -0
- package/dist/cjs/providers/pinpoint/types/options.js +6 -0
- package/dist/cjs/providers/pinpoint/types/options.js.map +1 -0
- package/dist/cjs/providers/pinpoint/utils/index.js +11 -0
- package/dist/cjs/providers/pinpoint/utils/index.js.map +1 -0
- package/dist/cjs/providers/pinpoint/utils/resolveConfig.js +19 -0
- package/dist/cjs/providers/pinpoint/utils/resolveConfig.js.map +1 -0
- package/dist/cjs/providers/pinpoint/utils/resolveCredentials.js +18 -0
- package/dist/cjs/providers/pinpoint/utils/resolveCredentials.js.map +1 -0
- package/dist/cjs/trackers/EventTracker.js +100 -0
- package/dist/cjs/trackers/EventTracker.js.map +1 -0
- package/dist/cjs/trackers/PageViewTracker.js +112 -0
- package/dist/cjs/trackers/PageViewTracker.js.map +1 -0
- package/dist/cjs/trackers/SessionTracker.js +69 -0
- package/dist/cjs/trackers/SessionTracker.js.map +1 -0
- package/dist/cjs/trackers/SessionTracker.native.js +69 -0
- package/dist/cjs/trackers/SessionTracker.native.js.map +1 -0
- package/dist/cjs/trackers/index.js +13 -0
- package/dist/cjs/trackers/index.js.map +1 -0
- package/dist/cjs/types/index.js +6 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/inputs.js +6 -0
- package/dist/cjs/types/inputs.js.map +1 -0
- package/dist/cjs/types/kinesis.js +6 -0
- package/dist/cjs/types/kinesis.js.map +1 -0
- package/dist/cjs/types/options.js +6 -0
- package/dist/cjs/types/options.js.map +1 -0
- package/dist/cjs/types/trackers.js +6 -0
- package/dist/cjs/types/trackers.js.map +1 -0
- package/dist/cjs/utils/eventBuffer/EventBuffer.js +65 -0
- package/dist/cjs/utils/eventBuffer/EventBuffer.js.map +1 -0
- package/dist/cjs/utils/eventBuffer/index.js +9 -0
- package/dist/cjs/utils/eventBuffer/index.js.map +1 -0
- package/dist/cjs/utils/eventBuffer/types.js +6 -0
- package/dist/cjs/utils/eventBuffer/types.js.map +1 -0
- package/dist/cjs/utils/groupBy.js +14 -0
- package/dist/cjs/utils/groupBy.js.map +1 -0
- package/dist/cjs/utils/index.js +24 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/resolveCredentials.js +15 -0
- package/dist/cjs/utils/resolveCredentials.js.map +1 -0
- package/dist/cjs/utils/statusHelpers.js +21 -0
- package/dist/cjs/utils/statusHelpers.js.map +1 -0
- package/dist/cjs/utils/trackerConfigHelpers.js +17 -0
- package/dist/cjs/utils/trackerConfigHelpers.js.map +1 -0
- package/dist/cjs/utils/trackerConfigHelpers.native.js +16 -0
- package/dist/cjs/utils/trackerConfigHelpers.native.js.map +1 -0
- package/dist/cjs/utils/trackerHelpers.js +46 -0
- package/dist/cjs/utils/trackerHelpers.js.map +1 -0
- package/dist/cjs/utils/userAgent.js +21 -0
- package/dist/cjs/utils/userAgent.js.map +1 -0
- package/dist/esm/apis/disable.d.ts +8 -0
- package/dist/esm/apis/disable.mjs +22 -0
- package/dist/esm/apis/disable.mjs.map +1 -0
- package/dist/esm/apis/enable.d.ts +7 -0
- package/dist/esm/apis/enable.mjs +21 -0
- package/dist/esm/apis/enable.mjs.map +1 -0
- package/dist/esm/apis/index.d.ts +2 -0
- package/dist/esm/apis/index.mjs +3 -0
- package/dist/esm/apis/index.mjs.map +1 -0
- package/dist/esm/errors/AnalyticsError.d.ts +7 -0
- package/dist/esm/errors/AnalyticsError.mjs +19 -0
- package/dist/esm/errors/AnalyticsError.mjs.map +1 -0
- package/dist/esm/errors/assertValidationError.d.ts +5 -0
- package/dist/esm/errors/assertValidationError.mjs +21 -0
- package/dist/esm/errors/assertValidationError.mjs.map +1 -0
- package/dist/esm/errors/index.d.ts +3 -0
- package/dist/esm/errors/index.mjs +4 -0
- package/dist/esm/errors/index.mjs.map +1 -0
- package/dist/esm/errors/validation.d.ts +12 -0
- package/dist/esm/errors/validation.mjs +42 -0
- package/dist/esm/errors/validation.mjs.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.mjs +9 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/providers/kinesis/apis/flushEvents.d.ts +8 -0
- package/dist/esm/providers/kinesis/apis/flushEvents.mjs +43 -0
- package/dist/esm/providers/kinesis/apis/flushEvents.mjs.map +1 -0
- package/dist/esm/providers/kinesis/apis/index.d.ts +2 -0
- package/dist/esm/providers/kinesis/apis/index.mjs +3 -0
- package/dist/esm/providers/kinesis/apis/index.mjs.map +1 -0
- package/dist/esm/providers/kinesis/apis/record.d.ts +23 -0
- package/dist/esm/providers/kinesis/apis/record.mjs +74 -0
- package/dist/esm/providers/kinesis/apis/record.mjs.map +1 -0
- package/dist/esm/providers/kinesis/index.d.ts +1 -0
- package/dist/esm/providers/kinesis/index.mjs +3 -0
- package/dist/esm/providers/kinesis/index.mjs.map +1 -0
- package/dist/esm/providers/kinesis/types/buffer.d.ts +15 -0
- package/dist/esm/providers/kinesis/types/buffer.mjs +2 -0
- package/dist/esm/providers/kinesis/types/buffer.mjs.map +1 -0
- package/dist/esm/providers/kinesis/types/index.d.ts +2 -0
- package/dist/esm/providers/kinesis/types/index.mjs +2 -0
- package/dist/esm/providers/kinesis/types/index.mjs.map +1 -0
- package/dist/esm/providers/kinesis/types/inputs.d.ts +6 -0
- package/dist/esm/providers/kinesis/types/inputs.mjs +2 -0
- package/dist/esm/providers/kinesis/types/inputs.mjs.map +1 -0
- package/dist/esm/providers/kinesis/utils/constants.d.ts +6 -0
- package/dist/esm/providers/kinesis/utils/constants.mjs +11 -0
- package/dist/esm/providers/kinesis/utils/constants.mjs.map +1 -0
- package/dist/esm/providers/kinesis/utils/getEventBuffer.d.ts +3 -0
- package/dist/esm/providers/kinesis/utils/getEventBuffer.mjs +89 -0
- package/dist/esm/providers/kinesis/utils/getEventBuffer.mjs.map +1 -0
- package/dist/esm/providers/kinesis/utils/resolveConfig.d.ts +7 -0
- package/dist/esm/providers/kinesis/utils/resolveConfig.mjs +27 -0
- package/dist/esm/providers/kinesis/utils/resolveConfig.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/apis/flushEvents.d.ts +8 -0
- package/dist/esm/providers/kinesis-firehose/apis/flushEvents.mjs +43 -0
- package/dist/esm/providers/kinesis-firehose/apis/flushEvents.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/apis/index.d.ts +2 -0
- package/dist/esm/providers/kinesis-firehose/apis/index.mjs +3 -0
- package/dist/esm/providers/kinesis-firehose/apis/index.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/apis/record.d.ts +19 -0
- package/dist/esm/providers/kinesis-firehose/apis/record.mjs +68 -0
- package/dist/esm/providers/kinesis-firehose/apis/record.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/index.d.ts +1 -0
- package/dist/esm/providers/kinesis-firehose/index.mjs +3 -0
- package/dist/esm/providers/kinesis-firehose/index.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/types/buffer.d.ts +15 -0
- package/dist/esm/providers/kinesis-firehose/types/buffer.mjs +2 -0
- package/dist/esm/providers/kinesis-firehose/types/buffer.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/types/index.d.ts +2 -0
- package/dist/esm/providers/kinesis-firehose/types/index.mjs +2 -0
- package/dist/esm/providers/kinesis-firehose/types/index.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/types/inputs.d.ts +5 -0
- package/dist/esm/providers/kinesis-firehose/types/inputs.mjs +2 -0
- package/dist/esm/providers/kinesis-firehose/types/inputs.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/utils/constants.d.ts +6 -0
- package/dist/esm/providers/kinesis-firehose/utils/constants.mjs +11 -0
- package/dist/esm/providers/kinesis-firehose/utils/constants.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/utils/getEventBuffer.d.ts +3 -0
- package/dist/esm/providers/kinesis-firehose/utils/getEventBuffer.mjs +87 -0
- package/dist/esm/providers/kinesis-firehose/utils/getEventBuffer.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/utils/index.d.ts +2 -0
- package/dist/esm/providers/kinesis-firehose/utils/index.mjs +3 -0
- package/dist/esm/providers/kinesis-firehose/utils/index.mjs.map +1 -0
- package/dist/esm/providers/kinesis-firehose/utils/resolveConfig.d.ts +7 -0
- package/dist/esm/providers/kinesis-firehose/utils/resolveConfig.mjs +27 -0
- package/dist/esm/providers/kinesis-firehose/utils/resolveConfig.mjs.map +1 -0
- package/dist/esm/providers/personalize/apis/flushEvents.d.ts +8 -0
- package/dist/esm/providers/personalize/apis/flushEvents.mjs +43 -0
- package/dist/esm/providers/personalize/apis/flushEvents.mjs.map +1 -0
- package/dist/esm/providers/personalize/apis/index.d.ts +2 -0
- package/dist/esm/providers/personalize/apis/index.mjs +3 -0
- package/dist/esm/providers/personalize/apis/index.mjs.map +1 -0
- package/dist/esm/providers/personalize/apis/record.d.ts +27 -0
- package/dist/esm/providers/personalize/apis/record.mjs +106 -0
- package/dist/esm/providers/personalize/apis/record.mjs.map +1 -0
- package/dist/esm/providers/personalize/index.d.ts +1 -0
- package/dist/esm/providers/personalize/index.mjs +3 -0
- package/dist/esm/providers/personalize/index.mjs.map +1 -0
- package/dist/esm/providers/personalize/types/buffer.d.ts +16 -0
- package/dist/esm/providers/personalize/types/buffer.mjs +2 -0
- package/dist/esm/providers/personalize/types/buffer.mjs.map +1 -0
- package/dist/esm/providers/personalize/types/index.d.ts +2 -0
- package/dist/esm/providers/personalize/types/index.mjs +2 -0
- package/dist/esm/providers/personalize/types/index.mjs.map +1 -0
- package/dist/esm/providers/personalize/types/inputs.d.ts +7 -0
- package/dist/esm/providers/personalize/types/inputs.mjs +2 -0
- package/dist/esm/providers/personalize/types/inputs.mjs.map +1 -0
- package/dist/esm/providers/personalize/utils/autoTrackMedia.d.ts +10 -0
- package/dist/esm/providers/personalize/utils/autoTrackMedia.mjs +181 -0
- package/dist/esm/providers/personalize/utils/autoTrackMedia.mjs.map +1 -0
- package/dist/esm/providers/personalize/utils/cachedSession.d.ts +5 -0
- package/dist/esm/providers/personalize/utils/cachedSession.mjs +48 -0
- package/dist/esm/providers/personalize/utils/cachedSession.mjs.map +1 -0
- package/dist/esm/providers/personalize/utils/constants.d.ts +7 -0
- package/dist/esm/providers/personalize/utils/constants.mjs +12 -0
- package/dist/esm/providers/personalize/utils/constants.mjs.map +1 -0
- package/dist/esm/providers/personalize/utils/getEventBuffer.d.ts +3 -0
- package/dist/esm/providers/personalize/utils/getEventBuffer.mjs +90 -0
- package/dist/esm/providers/personalize/utils/getEventBuffer.mjs.map +1 -0
- package/dist/esm/providers/personalize/utils/index.d.ts +5 -0
- package/dist/esm/providers/personalize/utils/index.mjs +6 -0
- package/dist/esm/providers/personalize/utils/index.mjs.map +1 -0
- package/dist/esm/providers/personalize/utils/resolveConfig.d.ts +7 -0
- package/dist/esm/providers/personalize/utils/resolveConfig.mjs +28 -0
- package/dist/esm/providers/personalize/utils/resolveConfig.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/apis/configureAutoTrack.d.ts +17 -0
- package/dist/esm/providers/pinpoint/apis/configureAutoTrack.mjs +42 -0
- package/dist/esm/providers/pinpoint/apis/configureAutoTrack.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/apis/flushEvents.d.ts +10 -0
- package/dist/esm/providers/pinpoint/apis/flushEvents.mjs +47 -0
- package/dist/esm/providers/pinpoint/apis/flushEvents.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/apis/identifyUser.d.ts +49 -0
- package/dist/esm/providers/pinpoint/apis/identifyUser.mjs +80 -0
- package/dist/esm/providers/pinpoint/apis/identifyUser.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/apis/index.d.ts +4 -0
- package/dist/esm/providers/pinpoint/apis/index.mjs +5 -0
- package/dist/esm/providers/pinpoint/apis/index.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/apis/record.d.ts +32 -0
- package/dist/esm/providers/pinpoint/apis/record.mjs +79 -0
- package/dist/esm/providers/pinpoint/apis/record.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/index.d.ts +2 -0
- package/dist/esm/providers/pinpoint/index.mjs +5 -0
- package/dist/esm/providers/pinpoint/index.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/types/index.d.ts +2 -0
- package/dist/esm/providers/pinpoint/types/index.mjs +2 -0
- package/dist/esm/providers/pinpoint/types/index.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/types/inputs.d.ts +15 -0
- package/dist/esm/providers/pinpoint/types/inputs.mjs +2 -0
- package/dist/esm/providers/pinpoint/types/inputs.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/types/options.d.ts +5 -0
- package/dist/esm/providers/pinpoint/types/options.mjs +2 -0
- package/dist/esm/providers/pinpoint/types/options.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/utils/index.d.ts +2 -0
- package/dist/esm/providers/pinpoint/utils/index.mjs +3 -0
- package/dist/esm/providers/pinpoint/utils/index.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/utils/resolveConfig.d.ts +11 -0
- package/dist/esm/providers/pinpoint/utils/resolveConfig.mjs +19 -0
- package/dist/esm/providers/pinpoint/utils/resolveConfig.mjs.map +1 -0
- package/dist/esm/providers/pinpoint/utils/resolveCredentials.d.ts +7 -0
- package/dist/esm/providers/pinpoint/utils/resolveCredentials.mjs +18 -0
- package/dist/esm/providers/pinpoint/utils/resolveCredentials.mjs.map +1 -0
- package/dist/esm/trackers/EventTracker.d.ts +10 -0
- package/dist/esm/trackers/EventTracker.mjs +98 -0
- package/dist/esm/trackers/EventTracker.mjs.map +1 -0
- package/dist/esm/trackers/PageViewTracker.d.ts +18 -0
- package/dist/esm/trackers/PageViewTracker.mjs +110 -0
- package/dist/esm/trackers/PageViewTracker.mjs.map +1 -0
- package/dist/esm/trackers/SessionTracker.d.ts +13 -0
- package/dist/esm/trackers/SessionTracker.mjs +67 -0
- package/dist/esm/trackers/SessionTracker.mjs.map +1 -0
- package/dist/esm/trackers/SessionTracker.native.d.ts +13 -0
- package/dist/esm/trackers/SessionTracker.native.mjs +67 -0
- package/dist/esm/trackers/SessionTracker.native.mjs.map +1 -0
- package/dist/esm/trackers/index.d.ts +3 -0
- package/dist/esm/trackers/index.mjs +4 -0
- package/dist/esm/trackers/index.mjs.map +1 -0
- package/dist/esm/types/index.d.ts +3 -0
- package/dist/esm/types/index.mjs +2 -0
- package/dist/esm/types/index.mjs.map +1 -0
- package/dist/esm/types/inputs.d.ts +35 -0
- package/dist/esm/types/inputs.mjs +2 -0
- package/dist/esm/types/inputs.mjs.map +1 -0
- package/dist/esm/types/kinesis.d.ts +8 -0
- package/dist/esm/types/kinesis.mjs +2 -0
- package/dist/esm/types/kinesis.mjs.map +1 -0
- package/dist/esm/types/options.d.ts +4 -0
- package/dist/esm/types/options.mjs +2 -0
- package/dist/esm/types/options.mjs.map +1 -0
- package/dist/esm/types/trackers.d.ts +22 -0
- package/dist/esm/types/trackers.mjs +2 -0
- package/dist/esm/types/trackers.mjs.map +1 -0
- package/dist/esm/utils/eventBuffer/EventBuffer.d.ts +16 -0
- package/dist/esm/utils/eventBuffer/EventBuffer.mjs +63 -0
- package/dist/esm/utils/eventBuffer/EventBuffer.mjs.map +1 -0
- package/dist/esm/utils/eventBuffer/index.d.ts +2 -0
- package/dist/esm/utils/eventBuffer/index.mjs +2 -0
- package/dist/esm/utils/eventBuffer/index.mjs.map +1 -0
- package/dist/esm/utils/eventBuffer/types.d.ts +6 -0
- package/dist/esm/utils/eventBuffer/types.mjs +2 -0
- package/dist/esm/utils/eventBuffer/types.mjs.map +1 -0
- package/dist/esm/utils/groupBy.d.ts +1 -0
- package/dist/esm/utils/groupBy.mjs +11 -0
- package/dist/esm/utils/groupBy.mjs.map +1 -0
- package/dist/esm/utils/index.d.ts +7 -0
- package/dist/esm/utils/index.mjs +8 -0
- package/dist/esm/utils/index.mjs.map +1 -0
- package/dist/esm/utils/resolveCredentials.d.ts +4 -0
- package/dist/esm/utils/resolveCredentials.mjs +15 -0
- package/dist/esm/utils/resolveCredentials.mjs.map +1 -0
- package/dist/esm/utils/statusHelpers.d.ts +6 -0
- package/dist/esm/utils/statusHelpers.mjs +16 -0
- package/dist/esm/utils/statusHelpers.mjs.map +1 -0
- package/dist/esm/utils/trackerConfigHelpers.d.ts +5 -0
- package/dist/esm/utils/trackerConfigHelpers.mjs +17 -0
- package/dist/esm/utils/trackerConfigHelpers.mjs.map +1 -0
- package/dist/esm/utils/trackerConfigHelpers.native.d.ts +5 -0
- package/dist/esm/utils/trackerConfigHelpers.native.mjs +16 -0
- package/dist/esm/utils/trackerConfigHelpers.native.mjs.map +1 -0
- package/dist/esm/utils/trackerHelpers.d.ts +9 -0
- package/dist/esm/utils/trackerHelpers.mjs +46 -0
- package/dist/esm/utils/trackerHelpers.mjs.map +1 -0
- package/dist/esm/utils/userAgent.d.ts +4 -0
- package/dist/esm/utils/userAgent.mjs +19 -0
- package/dist/esm/utils/userAgent.mjs.map +1 -0
- package/kinesis/package.json +8 -0
- package/kinesis-firehose/package.json +8 -0
- package/package.json +110 -0
- package/personalize/package.json +8 -0
- package/pinpoint/package.json +8 -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 +21 -0
- package/src/errors/assertValidationError.ts +25 -0
- package/src/errors/index.ts +6 -0
- package/src/errors/validation.ts +43 -0
- package/src/index.ts +14 -0
- package/src/providers/kinesis/apis/flushEvents.ts +43 -0
- package/src/providers/kinesis/apis/index.ts +5 -0
- package/src/providers/kinesis/apis/record.ts +82 -0
- package/src/providers/kinesis/index.ts +4 -0
- package/src/providers/kinesis/types/buffer.ts +21 -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 +130 -0
- package/src/providers/kinesis/utils/resolveConfig.ts +39 -0
- package/src/providers/kinesis-firehose/apis/flushEvents.ts +42 -0
- package/src/providers/kinesis-firehose/apis/index.ts +5 -0
- package/src/providers/kinesis-firehose/apis/record.ts +71 -0
- package/src/providers/kinesis-firehose/index.ts +4 -0
- package/src/providers/kinesis-firehose/types/buffer.ts +21 -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 +138 -0
- package/src/providers/kinesis-firehose/utils/index.ts +5 -0
- package/src/providers/kinesis-firehose/utils/resolveConfig.ts +39 -0
- package/src/providers/personalize/apis/flushEvents.ts +40 -0
- package/src/providers/personalize/apis/index.ts +5 -0
- package/src/providers/personalize/apis/record.ts +130 -0
- package/src/providers/personalize/index.ts +4 -0
- package/src/providers/personalize/types/buffer.ts +23 -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 +240 -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 +135 -0
- package/src/providers/personalize/utils/index.ts +11 -0
- package/src/providers/personalize/utils/resolveConfig.ts +46 -0
- package/src/providers/pinpoint/apis/configureAutoTrack.ts +54 -0
- package/src/providers/pinpoint/apis/flushEvents.ts +42 -0
- package/src/providers/pinpoint/apis/identifyUser.ts +81 -0
- package/src/providers/pinpoint/apis/index.ts +7 -0
- package/src/providers/pinpoint/apis/record.ts +92 -0
- package/src/providers/pinpoint/index.ts +9 -0
- package/src/providers/pinpoint/types/index.ts +9 -0
- package/src/providers/pinpoint/types/inputs.ts +26 -0
- package/src/providers/pinpoint/types/options.ts +12 -0
- package/src/providers/pinpoint/utils/index.ts +5 -0
- package/src/providers/pinpoint/utils/resolveConfig.ts +21 -0
- package/src/providers/pinpoint/utils/resolveCredentials.ts +22 -0
- package/src/trackers/EventTracker.ts +136 -0
- package/src/trackers/PageViewTracker.ts +155 -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 +11 -0
- package/src/types/inputs.ts +53 -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 +85 -0
- package/src/utils/eventBuffer/index.ts +5 -0
- package/src/utils/eventBuffer/types.ts +10 -0
- package/src/utils/groupBy.ts +16 -0
- package/src/utils/index.ts +21 -0
- package/src/utils/resolveCredentials.ts +16 -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 +56 -0
- package/src/utils/userAgent.ts +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifyUser.js","sources":["../../../../../src/providers/pinpoint/apis/identifyUser.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.identifyUser = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst pinpoint_1 = require(\"@aws-amplify/core/internals/providers/pinpoint\");\nconst utils_2 = require(\"../../../utils\");\nconst utils_3 = require(\"../utils\");\n/**\n * Sends information about a user to Pinpoint. Sending user information allows you to associate a user to their user\n * profile and activities or actions in your application. Activity can be tracked across devices & platforms by using\n * the same `userId`.\n *\n * @deprecated AWS will end support for Amazon Pinpoint on October 30, 2026.\n *\n * @param {IdentifyUserInput} params The input object used to construct requests sent to Pinpoint's UpdateEndpoint\n * API.\n *\n * @throws service: {@link UpdateEndpointException} - Thrown when the underlying Pinpoint service returns an error.\n * @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library\n * configuration is incorrect.\n *\n * @returns A promise that will resolve when the operation is complete.\n *\n * @example\n * ```ts\n * // Identify a user with Pinpoint\n * await identifyUser({\n * userId,\n * userProfile: {\n * email: 'userEmail@example.com'\n * customProperties: {\n * phoneNumber: ['555-555-5555'],\n * },\n * }\n * });\n * ```\n *\n * @example\n * ```ts\n * // Identify a user with Pinpoint with some additional demographics\n * await identifyUser({\n * userId,\n * userProfile: {\n * email: 'userEmail@example.com'\n * customProperties: {\n * phoneNumber: ['555-555-5555'],\n * },\n * demographic: {\n * platform: 'ios',\n * timezone: 'America/Los_Angeles'\n * }\n * }\n * });\n */\nconst identifyUser = async ({ userId, userProfile, options, }) => {\n const { credentials, identityId } = await (0, utils_3.resolveCredentials)();\n const { appId, region } = (0, utils_3.resolveConfig)();\n const { userAttributes } = options ?? {};\n await (0, pinpoint_1.updateEndpoint)({\n appId,\n category: 'Analytics',\n credentials,\n identityId,\n region,\n userAttributes,\n userId,\n userProfile,\n userAgentValue: (0, utils_2.getAnalyticsUserAgentString)(utils_1.AnalyticsAction.IdentifyUser),\n });\n};\nexports.identifyUser = identifyUser;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,YAAY,GAAG,MAAM;AAC7B,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,UAAU,GAAG,OAAO,CAAC,gDAAgD,CAAC;AAC5E,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;AACzC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,YAAY,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,KAAK;AAClE,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,OAAO,CAAC,kBAAkB,GAAG;AAC/E,IAAI,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,OAAO,CAAC,aAAa,GAAG;AAC1D,IAAI,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,IAAI,EAAE;AAC5C,IAAI,MAAM,IAAI,UAAU,CAAC,cAAc,EAAE;AACzC,QAAQ,KAAK;AACb,QAAQ,QAAQ,EAAE,WAAW;AAC7B,QAAQ,WAAW;AACnB,QAAQ,UAAU;AAClB,QAAQ,MAAM;AACd,QAAQ,cAAc;AACtB,QAAQ,MAAM;AACd,QAAQ,WAAW;AACnB,QAAQ,cAAc,EAAE,IAAI,OAAO,CAAC,2BAA2B,EAAE,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC;AACtG,KAAK,CAAC;AACN,CAAC;AACD,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.flushEvents = exports.configureAutoTrack = exports.identifyUser = exports.record = void 0;
|
|
7
|
+
var record_1 = require("./record");
|
|
8
|
+
Object.defineProperty(exports, "record", { enumerable: true, get: function () { return record_1.record; } });
|
|
9
|
+
var identifyUser_1 = require("./identifyUser");
|
|
10
|
+
Object.defineProperty(exports, "identifyUser", { enumerable: true, get: function () { return identifyUser_1.identifyUser; } });
|
|
11
|
+
var configureAutoTrack_1 = require("./configureAutoTrack");
|
|
12
|
+
Object.defineProperty(exports, "configureAutoTrack", { enumerable: true, get: function () { return configureAutoTrack_1.configureAutoTrack; } });
|
|
13
|
+
var flushEvents_1 = require("./flushEvents");
|
|
14
|
+
Object.defineProperty(exports, "flushEvents", { enumerable: true, get: function () { return flushEvents_1.flushEvents; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/providers/pinpoint/apis/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.flushEvents = exports.configureAutoTrack = exports.identifyUser = exports.record = void 0;\nvar record_1 = require(\"./record\");\nObject.defineProperty(exports, \"record\", { enumerable: true, get: function () { return record_1.record; } });\nvar identifyUser_1 = require(\"./identifyUser\");\nObject.defineProperty(exports, \"identifyUser\", { enumerable: true, get: function () { return identifyUser_1.identifyUser; } });\nvar configureAutoTrack_1 = require(\"./configureAutoTrack\");\nObject.defineProperty(exports, \"configureAutoTrack\", { enumerable: true, get: function () { return configureAutoTrack_1.configureAutoTrack; } });\nvar flushEvents_1 = require(\"./flushEvents\");\nObject.defineProperty(exports, \"flushEvents\", { enumerable: true, get: function () { return flushEvents_1.flushEvents; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM;AACjG,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;AAClC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5G,IAAI,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;AAC9C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9H,IAAI,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC;AAC1D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;AAChJ,IAAI,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;AAC5C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;;"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.record = void 0;
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
8
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
|
+
const pinpoint_1 = require("@aws-amplify/core/internals/providers/pinpoint");
|
|
10
|
+
const errors_1 = require("../../../errors");
|
|
11
|
+
const utils_2 = require("../../../utils");
|
|
12
|
+
const utils_3 = require("../utils");
|
|
13
|
+
const logger = new core_1.ConsoleLogger('Analytics');
|
|
14
|
+
/**
|
|
15
|
+
* Records an Analytic event to Pinpoint. Events will be buffered and periodically sent to Pinpoint.
|
|
16
|
+
*
|
|
17
|
+
* @deprecated AWS will end support for Amazon Pinpoint on October 30, 2026.
|
|
18
|
+
*
|
|
19
|
+
* @param params The input object used to construct the request.
|
|
20
|
+
*
|
|
21
|
+
* @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
|
|
22
|
+
* configuration is incorrect.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // Send an event to Pinpoint
|
|
27
|
+
* record({ name: eventName })
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* // Send an event to Pinpoint with metrics & custom attributes
|
|
33
|
+
* record({
|
|
34
|
+
* name: eventName,
|
|
35
|
+
* attributes: {
|
|
36
|
+
* 'my-attribute': attributeValue
|
|
37
|
+
* },
|
|
38
|
+
* metrics: {
|
|
39
|
+
* 'my-metric': metricValue
|
|
40
|
+
* }
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
const record = (input) => {
|
|
45
|
+
const { appId, region, bufferSize, flushSize, flushInterval, resendLimit } = (0, utils_3.resolveConfig)();
|
|
46
|
+
if (!(0, utils_2.isAnalyticsEnabled)()) {
|
|
47
|
+
logger.debug('Analytics is disabled, event will not be recorded.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
(0, errors_1.assertValidationError)(!!input.name, errors_1.AnalyticsValidationErrorCode.NoEventName);
|
|
51
|
+
(0, utils_3.resolveCredentials)()
|
|
52
|
+
.then(({ credentials, identityId }) => {
|
|
53
|
+
core_1.Hub.dispatch('analytics', { event: 'record', data: input, message: 'Recording Analytics event' }, 'Analytics', utils_1.AMPLIFY_SYMBOL);
|
|
54
|
+
(0, pinpoint_1.record)({
|
|
55
|
+
appId,
|
|
56
|
+
category: 'Analytics',
|
|
57
|
+
credentials,
|
|
58
|
+
event: input,
|
|
59
|
+
identityId,
|
|
60
|
+
region,
|
|
61
|
+
userAgentValue: (0, utils_2.getAnalyticsUserAgentString)(utils_1.AnalyticsAction.Record),
|
|
62
|
+
bufferSize,
|
|
63
|
+
flushSize,
|
|
64
|
+
flushInterval,
|
|
65
|
+
resendLimit,
|
|
66
|
+
});
|
|
67
|
+
})
|
|
68
|
+
.catch(e => {
|
|
69
|
+
// An error occured while fetching credentials or persisting the event to the buffer
|
|
70
|
+
logger.warn('Failed to record event.', e);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
exports.record = record;
|
|
74
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sources":["../../../../../src/providers/pinpoint/apis/record.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.record = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst pinpoint_1 = require(\"@aws-amplify/core/internals/providers/pinpoint\");\nconst errors_1 = require(\"../../../errors\");\nconst utils_2 = require(\"../../../utils\");\nconst utils_3 = require(\"../utils\");\nconst logger = new core_1.ConsoleLogger('Analytics');\n/**\n * Records an Analytic event to Pinpoint. Events will be buffered and periodically sent to Pinpoint.\n *\n * @deprecated AWS will end support for Amazon Pinpoint on October 30, 2026.\n *\n * @param params The input object used to construct the request.\n *\n * @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library\n * configuration is incorrect.\n *\n * @example\n * ```ts\n * // Send an event to Pinpoint\n * record({ name: eventName })\n * ```\n *\n * @example\n * ```ts\n * // Send an event to Pinpoint with metrics & custom attributes\n * record({\n * name: eventName,\n * attributes: {\n * 'my-attribute': attributeValue\n * },\n * metrics: {\n * 'my-metric': metricValue\n * }\n * })\n * ```\n */\nconst record = (input) => {\n const { appId, region, bufferSize, flushSize, flushInterval, resendLimit } = (0, utils_3.resolveConfig)();\n if (!(0, utils_2.isAnalyticsEnabled)()) {\n logger.debug('Analytics is disabled, event will not be recorded.');\n return;\n }\n (0, errors_1.assertValidationError)(!!input.name, errors_1.AnalyticsValidationErrorCode.NoEventName);\n (0, utils_3.resolveCredentials)()\n .then(({ credentials, identityId }) => {\n core_1.Hub.dispatch('analytics', { event: 'record', data: input, message: 'Recording Analytics event' }, 'Analytics', utils_1.AMPLIFY_SYMBOL);\n (0, pinpoint_1.record)({\n appId,\n category: 'Analytics',\n credentials,\n event: input,\n identityId,\n region,\n userAgentValue: (0, utils_2.getAnalyticsUserAgentString)(utils_1.AnalyticsAction.Record),\n bufferSize,\n flushSize,\n flushInterval,\n resendLimit,\n });\n })\n .catch(e => {\n // An error occured while fetching credentials or persisting the event to the buffer\n logger.warn('Failed to record event.', e);\n });\n};\nexports.record = record;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,MAAM,GAAG,MAAM;AACvB,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,UAAU,GAAG,OAAO,CAAC,gDAAgD,CAAC;AAC5E,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;AACzC,MAAM,OAAO,GAAG,O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AAC;AACpG,YAAY,UAAU;AACtB,YAAY,SAAS;AACrB,YAAY,aAAa;AACzB,YAAY,WAAW;AACvB,SAAS,CAAC;AACV,IAAI,CAAC;AACL,SAAS,KAAK,CAAC,CAAC,IAAI;AACpB;AACA,QAAQ,MAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAC;AACjD,IAAI,CAAC,CAAC;AACN,CAAC;AACD,OAAO,CAAC,MAAM,GAAG,MAAM;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.configureAutoTrack = exports.flushEvents = exports.identifyUser = exports.record = void 0;
|
|
7
|
+
var apis_1 = require("./apis");
|
|
8
|
+
Object.defineProperty(exports, "record", { enumerable: true, get: function () { return apis_1.record; } });
|
|
9
|
+
Object.defineProperty(exports, "identifyUser", { enumerable: true, get: function () { return apis_1.identifyUser; } });
|
|
10
|
+
Object.defineProperty(exports, "flushEvents", { enumerable: true, get: function () { return apis_1.flushEvents; } });
|
|
11
|
+
Object.defineProperty(exports, "configureAutoTrack", { enumerable: true, get: function () { return apis_1.configureAutoTrack; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/providers/pinpoint/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.configureAutoTrack = exports.flushEvents = exports.identifyUser = exports.record = void 0;\nvar apis_1 = require(\"./apis\");\nObject.defineProperty(exports, \"record\", { enumerable: true, get: function () { return apis_1.record; } });\nObject.defineProperty(exports, \"identifyUser\", { enumerable: true, get: function () { return apis_1.identifyUser; } });\nObject.defineProperty(exports, \"flushEvents\", { enumerable: true, get: function () { return apis_1.flushEvents; } });\nObject.defineProperty(exports, \"configureAutoTrack\", { enumerable: true, get: function () { return apis_1.configureAutoTrack; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM;AACjG,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;AAC9B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1G,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;AACtH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;AACpH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/providers/pinpoint/types/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputs.js","sources":["../../../../../src/providers/pinpoint/types/inputs.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sources":["../../../../../src/providers/pinpoint/types/options.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveCredentials = exports.resolveConfig = void 0;
|
|
7
|
+
var resolveConfig_1 = require("./resolveConfig");
|
|
8
|
+
Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });
|
|
9
|
+
var resolveCredentials_1 = require("./resolveCredentials");
|
|
10
|
+
Object.defineProperty(exports, "resolveCredentials", { enumerable: true, get: function () { return resolveCredentials_1.resolveCredentials; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/providers/pinpoint/utils/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveCredentials = exports.resolveConfig = void 0;\nvar resolveConfig_1 = require(\"./resolveConfig\");\nObject.defineProperty(exports, \"resolveConfig\", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });\nvar resolveCredentials_1 = require(\"./resolveCredentials\");\nObject.defineProperty(exports, \"resolveCredentials\", { enumerable: true, get: function () { return resolveCredentials_1.resolveCredentials; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,aAAa,GAAG,MAAM;AAC3D,IAAI,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAChD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;AACjI,IAAI,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC;AAC1D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveConfig = void 0;
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
8
|
+
const errors_1 = require("../../../errors");
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
const resolveConfig = () => {
|
|
13
|
+
const { appId, region, bufferSize, flushSize, flushInterval, resendLimit } = core_1.Amplify.getConfig().Analytics?.Pinpoint ?? {};
|
|
14
|
+
(0, errors_1.assertValidationError)(!!appId, errors_1.AnalyticsValidationErrorCode.NoAppId);
|
|
15
|
+
(0, errors_1.assertValidationError)(!!region, errors_1.AnalyticsValidationErrorCode.NoRegion);
|
|
16
|
+
return { appId, region, bufferSize, flushSize, flushInterval, resendLimit };
|
|
17
|
+
};
|
|
18
|
+
exports.resolveConfig = resolveConfig;
|
|
19
|
+
//# sourceMappingURL=resolveConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveConfig.js","sources":["../../../../../src/providers/pinpoint/utils/resolveConfig.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveConfig = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst errors_1 = require(\"../../../errors\");\n/**\n * @internal\n */\nconst resolveConfig = () => {\n const { appId, region, bufferSize, flushSize, flushInterval, resendLimit } = core_1.Amplify.getConfig().Analytics?.Pinpoint ?? {};\n (0, errors_1.assertValidationError)(!!appId, errors_1.AnalyticsValidationErrorCode.NoAppId);\n (0, errors_1.assertValidationError)(!!region, errors_1.AnalyticsValidationErrorCode.NoRegion);\n return { appId, region, bufferSize, flushSize, flushInterval, resendLimit };\n};\nexports.resolveConfig = resolveConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,aAAa,GAAG,MAAM;AAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAC3C;AACA;AACA;AACA,MAAM,aAAa,GAAG,MAAM;AAC5B,IAAI,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,QAAQ,IAAI,EAAE;AACrI,IAAI,IAAI,QAAQ,CAAC,qBAAqB,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,4BAA4B,CAAC,OAAO,CAAC;AAC/F,IAAI,IAAI,QAAQ,CAAC,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,4BAA4B,CAAC,QAAQ,CAAC;AACjG,IAAI,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE;AAC/E,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveCredentials = void 0;
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
8
|
+
const errors_1 = require("../../../errors");
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
const resolveCredentials = async () => {
|
|
13
|
+
const { credentials, identityId } = await (0, core_1.fetchAuthSession)();
|
|
14
|
+
(0, errors_1.assertValidationError)(!!credentials, errors_1.AnalyticsValidationErrorCode.NoCredentials);
|
|
15
|
+
return { credentials, identityId };
|
|
16
|
+
};
|
|
17
|
+
exports.resolveCredentials = resolveCredentials;
|
|
18
|
+
//# sourceMappingURL=resolveCredentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveCredentials.js","sources":["../../../../../src/providers/pinpoint/utils/resolveCredentials.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveCredentials = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst errors_1 = require(\"../../../errors\");\n/**\n * @internal\n */\nconst resolveCredentials = async () => {\n const { credentials, identityId } = await (0, core_1.fetchAuthSession)();\n (0, errors_1.assertValidationError)(!!credentials, errors_1.AnalyticsValidationErrorCode.NoCredentials);\n return { credentials, identityId };\n};\nexports.resolveCredentials = resolveCredentials;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,kBAAkB,GAAG,MAAM;AACnC,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAC3C;AACA;AACA;AACA,MAAM,kBAAkB,GAAG,YAAY;AACvC,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,MAAM,CAAC,gBAAgB,GAAG;AAC5E,IAAI,IAAI,QAAQ,CAAC,qBAAqB,EAAE,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,4BAA4B,CAAC,aAAa,CAAC;AAC3G,IAAI,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE;AACtC,CAAC;AACD,OAAO,CAAC,kBAAkB,GAAG,kBAAkB;;"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EventTracker = void 0;
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
8
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
|
+
const DEFAULT_EVENTS = ['click'];
|
|
10
|
+
const DEFAULT_SELECTOR_PREFIX = 'data-amplify-analytics-';
|
|
11
|
+
const DEFAULT_EVENT_NAME = 'event'; // Default event name as sent to the analytics provider
|
|
12
|
+
const logger = new core_1.ConsoleLogger('EventTracker');
|
|
13
|
+
class EventTracker {
|
|
14
|
+
constructor(eventRecorder, options) {
|
|
15
|
+
this.options = {};
|
|
16
|
+
this.trackerActive = false;
|
|
17
|
+
this.eventRecorder = eventRecorder;
|
|
18
|
+
this.handleDocEvent = this.handleDocEvent.bind(this);
|
|
19
|
+
this.configure(eventRecorder, options);
|
|
20
|
+
}
|
|
21
|
+
configure(eventRecorder, options) {
|
|
22
|
+
this.eventRecorder = eventRecorder;
|
|
23
|
+
// Clean up any existing listeners
|
|
24
|
+
this.cleanup();
|
|
25
|
+
// Apply defaults
|
|
26
|
+
this.options = {
|
|
27
|
+
attributes: options?.attributes ?? undefined,
|
|
28
|
+
events: options?.events ?? DEFAULT_EVENTS,
|
|
29
|
+
selectorPrefix: options?.selectorPrefix ?? DEFAULT_SELECTOR_PREFIX,
|
|
30
|
+
};
|
|
31
|
+
// Register event listeners
|
|
32
|
+
if ((0, utils_1.isBrowser)()) {
|
|
33
|
+
this.options.events?.forEach(targetEvent => {
|
|
34
|
+
document.addEventListener(targetEvent, this.handleDocEvent, {
|
|
35
|
+
capture: true,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
this.trackerActive = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
cleanup() {
|
|
42
|
+
// No-op if document listener is not active
|
|
43
|
+
if (!this.trackerActive) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Clean up event listeners
|
|
47
|
+
this.options.events?.forEach(targetEvent => {
|
|
48
|
+
document.removeEventListener(targetEvent, this.handleDocEvent, {
|
|
49
|
+
capture: true,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
handleDocEvent(event) {
|
|
54
|
+
/**
|
|
55
|
+
* Example DOM element:
|
|
56
|
+
*
|
|
57
|
+
* ```
|
|
58
|
+
* <button
|
|
59
|
+
* data-amplify-analytics-on="click"
|
|
60
|
+
* data-amplify-analytics-name="click"
|
|
61
|
+
* data-amplify-analytics-attrs="attr1:attr1_value,attr2:attr2_value"
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
const triggerSelector = `[${this.options.selectorPrefix}on]`;
|
|
66
|
+
const attrSelector = `${this.options.selectorPrefix}attrs`;
|
|
67
|
+
const eventNameSelector = `${this.options.selectorPrefix}name`;
|
|
68
|
+
const eventSource = event.target;
|
|
69
|
+
// Validate that the triggering event type is being tracked
|
|
70
|
+
if (!this.options.events?.includes(event.type)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (eventSource instanceof HTMLElement) {
|
|
74
|
+
const target = eventSource.closest(triggerSelector);
|
|
75
|
+
if (target) {
|
|
76
|
+
// Parse event name from the element
|
|
77
|
+
const eventName = target.getAttribute(eventNameSelector) || DEFAULT_EVENT_NAME;
|
|
78
|
+
// Parse attributes from the element
|
|
79
|
+
const elementAttributes = {};
|
|
80
|
+
const rawElementAttributes = target.getAttribute(attrSelector);
|
|
81
|
+
rawElementAttributes?.split(/\s*,\s*/).forEach(attr => {
|
|
82
|
+
const tmp = attr.trim().split(/\s*:\s*/);
|
|
83
|
+
elementAttributes[tmp[0]] = tmp[1];
|
|
84
|
+
});
|
|
85
|
+
// Assemble final list of attributes
|
|
86
|
+
const attributes = Object.assign({
|
|
87
|
+
type: event.type,
|
|
88
|
+
target: `${target.localName} with id ${target.id}`,
|
|
89
|
+
}, this.options.attributes, elementAttributes);
|
|
90
|
+
logger.debug('Recording automatically tracked DOM event', {
|
|
91
|
+
eventName,
|
|
92
|
+
attributes,
|
|
93
|
+
});
|
|
94
|
+
this.eventRecorder(eventName, attributes);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.EventTracker = EventTracker;
|
|
100
|
+
//# sourceMappingURL=EventTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventTracker.js","sources":["../../../src/trackers/EventTracker.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.EventTracker = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst DEFAULT_EVENTS = ['click'];\nconst DEFAULT_SELECTOR_PREFIX = 'data-amplify-analytics-';\nconst DEFAULT_EVENT_NAME = 'event'; // Default event name as sent to the analytics provider\nconst logger = new core_1.ConsoleLogger('EventTracker');\nclass EventTracker {\n constructor(eventRecorder, options) {\n this.options = {};\n this.trackerActive = false;\n this.eventRecorder = eventRecorder;\n this.handleDocEvent = this.handleDocEvent.bind(this);\n this.configure(eventRecorder, options);\n }\n configure(eventRecorder, options) {\n this.eventRecorder = eventRecorder;\n // Clean up any existing listeners\n this.cleanup();\n // Apply defaults\n this.options = {\n attributes: options?.attributes ?? undefined,\n events: options?.events ?? DEFAULT_EVENTS,\n selectorPrefix: options?.selectorPrefix ?? DEFAULT_SELECTOR_PREFIX,\n };\n // Register event listeners\n if ((0, utils_1.isBrowser)()) {\n this.options.events?.forEach(targetEvent => {\n document.addEventListener(targetEvent, this.handleDocEvent, {\n capture: true,\n });\n });\n this.trackerActive = true;\n }\n }\n cleanup() {\n // No-op if document listener is not active\n if (!this.trackerActive) {\n return;\n }\n // Clean up event listeners\n this.options.events?.forEach(targetEvent => {\n document.removeEventListener(targetEvent, this.handleDocEvent, {\n capture: true,\n });\n });\n }\n handleDocEvent(event) {\n /**\n * Example DOM element:\n *\n * ```\n * <button\n * data-amplify-analytics-on=\"click\"\n * data-amplify-analytics-name=\"click\"\n * data-amplify-analytics-attrs=\"attr1:attr1_value,attr2:attr2_value\"\n * />\n * ```\n */\n const triggerSelector = `[${this.options.selectorPrefix}on]`;\n const attrSelector = `${this.options.selectorPrefix}attrs`;\n const eventNameSelector = `${this.options.selectorPrefix}name`;\n const eventSource = event.target;\n // Validate that the triggering event type is being tracked\n if (!this.options.events?.includes(event.type)) {\n return;\n }\n if (eventSource instanceof HTMLElement) {\n const target = eventSource.closest(triggerSelector);\n if (target) {\n // Parse event name from the element\n const eventName = target.getAttribute(eventNameSelector) || DEFAULT_EVENT_NAME;\n // Parse attributes from the element\n const elementAttributes = {};\n const rawElementAttributes = target.getAttribute(attrSelector);\n rawElementAttributes?.split(/\\s*,\\s*/).forEach(attr => {\n const tmp = attr.trim().split(/\\s*:\\s*/);\n elementAttributes[tmp[0]] = tmp[1];\n });\n // Assemble final list of attributes\n const attributes = Object.assign({\n type: event.type,\n target: `${target.localName} with id ${target.id}`,\n }, this.options.attributes, elementAttributes);\n logger.debug('Recording automatically tracked DOM event', {\n eventName,\n attributes,\n });\n this.eventRecorder(eventName, attributes);\n }\n }\n }\n}\nexports.EventTracker = EventTracker;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OA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AAM,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,kBAAkB;AAC9F;AACA,gBAAgB,MAAM,iBAAiB,GAAG,EAAE;AAC5C,gBAAgB,MAAM,oBAAoB,GAAG,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC;AAC9E,gBAAgB,oBAAoB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI;AACvE,oBAAoB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC;AAC5D,oBAAoB,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;AACtD,gBAAgB,CAAC,CAAC;AAClB;AACA,gBAAgB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;AACjD,oBAAoB,IAAI,EAAE,KAAK,CAAC,IAAI;AACpC,oBAAoB,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AACtE,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC;AAC9D,gBAAgB,MAAM,CAAC,KAAK,CAAC,2CAA2C,EAAE;AAC1E,oBAAoB,SAAS;AAC7B,oBAAoB,UAAU;AAC9B,iBAAiB,CAAC;AAClB,gBAAgB,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC;AACzD,YAAY;AACZ,QAAQ;AACR,IAAI;AACJ;AACA,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PageViewTracker = void 0;
|
|
7
|
+
const core_1 = require("@aws-amplify/core");
|
|
8
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
9
|
+
const logger = new core_1.ConsoleLogger('PageViewTracker');
|
|
10
|
+
const DEFAULT_EVENT_NAME = 'pageView';
|
|
11
|
+
const DEFAULT_APP_TYPE = 'singlePage';
|
|
12
|
+
const DEFAULT_URL_PROVIDER = () => {
|
|
13
|
+
return window.location.origin + window.location.pathname;
|
|
14
|
+
};
|
|
15
|
+
const PREV_URL_STORAGE_KEY = 'aws-amplify-analytics-prevUrl';
|
|
16
|
+
class PageViewTracker {
|
|
17
|
+
constructor(eventRecorder, options) {
|
|
18
|
+
this.options = {};
|
|
19
|
+
this.trackerActive = true;
|
|
20
|
+
this.eventRecorder = eventRecorder;
|
|
21
|
+
this.spaTrackingActive = false;
|
|
22
|
+
this.handleLocationChange = this.handleLocationChange.bind(this);
|
|
23
|
+
this.configure(eventRecorder, options);
|
|
24
|
+
}
|
|
25
|
+
configure(eventRecorder, options) {
|
|
26
|
+
this.eventRecorder = eventRecorder;
|
|
27
|
+
// Clean up any existing listeners
|
|
28
|
+
this.cleanup();
|
|
29
|
+
// Apply defaults
|
|
30
|
+
this.options = {
|
|
31
|
+
appType: options?.appType ?? DEFAULT_APP_TYPE,
|
|
32
|
+
attributes: options?.attributes ?? undefined,
|
|
33
|
+
eventName: options?.eventName ?? DEFAULT_EVENT_NAME,
|
|
34
|
+
urlProvider: options?.urlProvider ?? DEFAULT_URL_PROVIDER,
|
|
35
|
+
};
|
|
36
|
+
// Configure SPA or MPA page view tracking
|
|
37
|
+
if ((0, utils_1.isBrowser)()) {
|
|
38
|
+
if (this.options.appType === 'singlePage') {
|
|
39
|
+
this.setupSPATracking();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.setupMPATracking();
|
|
43
|
+
}
|
|
44
|
+
this.trackerActive = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
cleanup() {
|
|
48
|
+
// No-op if document listener is not active
|
|
49
|
+
if (!this.trackerActive) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// Clean up SPA page view listeners
|
|
53
|
+
if (this.spaTrackingActive) {
|
|
54
|
+
window.history.pushState = this.originalPushState;
|
|
55
|
+
window.history.replaceState = this.originalReplaceState;
|
|
56
|
+
this.pushStateProxy?.revoke();
|
|
57
|
+
this.replaceStateProxy?.revoke();
|
|
58
|
+
window.removeEventListener('popstate', this.handleLocationChange);
|
|
59
|
+
this.spaTrackingActive = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
setupSPATracking() {
|
|
63
|
+
if (!this.spaTrackingActive) {
|
|
64
|
+
// Configure proxies on History APIs
|
|
65
|
+
this.pushStateProxy = Proxy.revocable(window.history.pushState, {
|
|
66
|
+
apply: (target, thisArg, args) => {
|
|
67
|
+
target.apply(thisArg, args);
|
|
68
|
+
this.handleLocationChange();
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
this.replaceStateProxy = Proxy.revocable(window.history.replaceState, {
|
|
72
|
+
apply: (target, thisArg, args) => {
|
|
73
|
+
target.apply(thisArg, args);
|
|
74
|
+
this.handleLocationChange();
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
this.originalPushState = window.history.pushState;
|
|
78
|
+
this.originalReplaceState = window.history.replaceState;
|
|
79
|
+
window.history.pushState = this.pushStateProxy.proxy;
|
|
80
|
+
window.history.replaceState = this.replaceStateProxy.proxy;
|
|
81
|
+
window.addEventListener('popstate', this.handleLocationChange);
|
|
82
|
+
sessionStorage.removeItem(PREV_URL_STORAGE_KEY);
|
|
83
|
+
this.spaTrackingActive = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
setupMPATracking() {
|
|
87
|
+
this.handleLocationChange();
|
|
88
|
+
}
|
|
89
|
+
handleLocationChange() {
|
|
90
|
+
const currentUrl = this.options.urlProvider();
|
|
91
|
+
const eventName = this.options.eventName || DEFAULT_EVENT_NAME;
|
|
92
|
+
if (this.urlHasChanged()) {
|
|
93
|
+
sessionStorage.setItem(PREV_URL_STORAGE_KEY, currentUrl);
|
|
94
|
+
// Assemble attribute list
|
|
95
|
+
const attributes = Object.assign({
|
|
96
|
+
url: currentUrl,
|
|
97
|
+
}, this.options.attributes);
|
|
98
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
99
|
+
eventName,
|
|
100
|
+
attributes,
|
|
101
|
+
});
|
|
102
|
+
this.eventRecorder(eventName, attributes);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
urlHasChanged() {
|
|
106
|
+
const prevUrl = sessionStorage.getItem(PREV_URL_STORAGE_KEY);
|
|
107
|
+
const currUrl = this.options.urlProvider();
|
|
108
|
+
return currUrl !== prevUrl;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.PageViewTracker = PageViewTracker;
|
|
112
|
+
//# sourceMappingURL=PageViewTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageViewTracker.js","sources":["../../../src/trackers/PageViewTracker.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.PageViewTracker = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst logger = new core_1.ConsoleLogger('PageViewTracker');\nconst DEFAULT_EVENT_NAME = 'pageView';\nconst DEFAULT_APP_TYPE = 'singlePage';\nconst DEFAULT_URL_PROVIDER = () => {\n return window.location.origin + window.location.pathname;\n};\nconst PREV_URL_STORAGE_KEY = 'aws-amplify-analytics-prevUrl';\nclass PageViewTracker {\n constructor(eventRecorder, options) {\n this.options = {};\n this.trackerActive = true;\n this.eventRecorder = eventRecorder;\n this.spaTrackingActive = false;\n this.handleLocationChange = this.handleLocationChange.bind(this);\n this.configure(eventRecorder, options);\n }\n configure(eventRecorder, options) {\n this.eventRecorder = eventRecorder;\n // Clean up any existing listeners\n this.cleanup();\n // Apply defaults\n this.options = {\n appType: options?.appType ?? DEFAULT_APP_TYPE,\n attributes: options?.attributes ?? undefined,\n eventName: options?.eventName ?? DEFAULT_EVENT_NAME,\n urlProvider: options?.urlProvider ?? DEFAULT_URL_PROVIDER,\n };\n // Configure SPA or MPA page view tracking\n if ((0, utils_1.isBrowser)()) {\n if (this.options.appType === 'singlePage') {\n this.setupSPATracking();\n }\n else {\n this.setupMPATracking();\n }\n this.trackerActive = true;\n }\n }\n cleanup() {\n // No-op if document listener is not active\n if (!this.trackerActive) {\n return;\n }\n // Clean up SPA page view listeners\n if (this.spaTrackingActive) {\n window.history.pushState = this.originalPushState;\n window.history.replaceState = this.originalReplaceState;\n this.pushStateProxy?.revoke();\n this.replaceStateProxy?.revoke();\n window.removeEventListener('popstate', this.handleLocationChange);\n this.spaTrackingActive = false;\n }\n }\n setupSPATracking() {\n if (!this.spaTrackingActive) {\n // Configure proxies on History APIs\n this.pushStateProxy = Proxy.revocable(window.history.pushState, {\n apply: (target, thisArg, args) => {\n target.apply(thisArg, args);\n this.handleLocationChange();\n },\n });\n this.replaceStateProxy = Proxy.revocable(window.history.replaceState, {\n apply: (target, thisArg, args) => {\n target.apply(thisArg, args);\n this.handleLocationChange();\n },\n });\n this.originalPushState = window.history.pushState;\n this.originalReplaceState = window.history.replaceState;\n window.history.pushState = this.pushStateProxy.proxy;\n window.history.replaceState = this.replaceStateProxy.proxy;\n window.addEventListener('popstate', this.handleLocationChange);\n sessionStorage.removeItem(PREV_URL_STORAGE_KEY);\n this.spaTrackingActive = true;\n }\n }\n setupMPATracking() {\n this.handleLocationChange();\n }\n handleLocationChange() {\n const currentUrl = this.options.urlProvider();\n const eventName = this.options.eventName || DEFAULT_EVENT_NAME;\n if (this.urlHasChanged()) {\n sessionStorage.setItem(PREV_URL_STORAGE_KEY, currentUrl);\n // Assemble attribute list\n const attributes = Object.assign({\n url: currentUrl,\n }, this.options.attributes);\n logger.debug('Recording automatically tracked page view event', {\n eventName,\n attributes,\n });\n this.eventRecorder(eventName, attributes);\n }\n }\n urlHasChanged() {\n const prevUrl = sessionStorage.getItem(PREV_URL_STORAGE_KEY);\n const currUrl = this.options.urlProvider();\n return currUrl !== prevUrl;\n }\n}\nexports.PageViewTracker = PageViewTracker;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,eAAe,GAAG,MAAM;AAChC,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC;AAC1D,MAAM,kBAAkB,GAAG,UAAU;AACrC,MAAM,gBAAgB,GAAG,YAAY;AACrC,MAAM,oBAAoB,GAAG,MAAM;AACnC,IAAI,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ;AAC5D,CAAC;AACD,MAAM,oBAAoB,GAAG,+BAA+B;AAC5D,MAAM,eAAe,CAAC;AACtB,IAAI,WAAW,CAAC,aAAa,EAAE,OAAO,EAAE;AACxC,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE;AACzB,QAAQ,IAAI,CAAC,aAAa,GAAG,IAAI;AACjC,QAAQ,IAAI,CAAC,aAAa,GAAG,aAAa;AAC1C,QAAQ,IAAI,CAAC,iBAAiB,GAAG,KAAK;AACtC,QAAQ,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC;AACxE,QAAQ,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC;AAC9C,IAAI;AACJ,IAAI,SAAS,CAAC,aAAa,EAAE,OAAO,EAAE;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,oBAAoB,EAAE;AACnC,IAAI;AACJ,IAAI,oBAAoB,GAAG;AAC3B,QAAQ,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;AACrD,QAAQ,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,kBAAkB;AACtE,QAAQ,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE;AAClC,YAAY,cAAc,CAAC,OAAO,CAAC,oBAAoB,EAAE,UAAU,CAAC;AACpE;AACA,YAAY,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;AAC7C,gBAAgB,GAAG,EAAE,UAAU;AAC/B,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;AACvC,YAAY,MAAM,CAAC,KAAK,CAAC,iDAAiD,EAAE;AAC5E,gBAAgB,SAAS;AACzB,gBAAgB,UAAU;AAC1B,aAAa,CAAC;AACd,YAAY,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC;AACrD,QAAQ;AACR,IAAI;AACJ,IAAI,aAAa,GAAG;AACpB,QAAQ,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,oBAAoB,CAAC;AACpE,QAAQ,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;AAClD,QAAQ,OAAO,OAAO,KAAK,OAAO;AAClC,IAAI;AACJ;AACA,OAAO,CAAC,eAAe,GAAG,eAAe;;"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SessionTracker = void 0;
|
|
7
|
+
const utils_1 = require("@aws-amplify/core/internals/utils");
|
|
8
|
+
const core_1 = require("@aws-amplify/core");
|
|
9
|
+
const logger = new core_1.ConsoleLogger('SessionTracker');
|
|
10
|
+
class SessionTracker {
|
|
11
|
+
constructor(eventRecorder, options) {
|
|
12
|
+
this.options = {};
|
|
13
|
+
this.eventRecorder = eventRecorder;
|
|
14
|
+
this.sessionTrackingActive = false;
|
|
15
|
+
this.initialEventSent = false;
|
|
16
|
+
this.handleStateChange = this.handleStateChange.bind(this);
|
|
17
|
+
this.configure(eventRecorder, options);
|
|
18
|
+
}
|
|
19
|
+
configure(eventRecorder, options) {
|
|
20
|
+
this.eventRecorder = eventRecorder;
|
|
21
|
+
// Clean up any existing listeners
|
|
22
|
+
this.cleanup();
|
|
23
|
+
// Apply defaults
|
|
24
|
+
this.options = {
|
|
25
|
+
attributes: options?.attributes ?? {},
|
|
26
|
+
};
|
|
27
|
+
// Setup state listeners
|
|
28
|
+
if (!this.sessionTrackingActive) {
|
|
29
|
+
utils_1.sessionListener.addStateChangeListener(this.handleStateChange, !this.initialEventSent);
|
|
30
|
+
this.sessionTrackingActive = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
cleanup() {
|
|
34
|
+
if (this.sessionTrackingActive) {
|
|
35
|
+
utils_1.sessionListener.removeStateChangeListener(this.handleStateChange);
|
|
36
|
+
}
|
|
37
|
+
this.sessionTrackingActive = false;
|
|
38
|
+
}
|
|
39
|
+
handleStateChange(state) {
|
|
40
|
+
if (state === 'started') {
|
|
41
|
+
this.sessionStarted();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.sessionStopped();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
sessionStarted() {
|
|
48
|
+
const attributes = this.options.attributes ?? {};
|
|
49
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
50
|
+
SESSION_START_EVENT: utils_1.SESSION_START_EVENT,
|
|
51
|
+
attributes,
|
|
52
|
+
});
|
|
53
|
+
this.eventRecorder(utils_1.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
|
+
sessionStopped() {
|
|
60
|
+
const attributes = this.options.attributes ?? {};
|
|
61
|
+
logger.debug('Recording automatically tracked page view event', {
|
|
62
|
+
SESSION_STOP_EVENT: utils_1.SESSION_STOP_EVENT,
|
|
63
|
+
attributes,
|
|
64
|
+
});
|
|
65
|
+
this.eventRecorder(utils_1.SESSION_STOP_EVENT, attributes);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.SessionTracker = SessionTracker;
|
|
69
|
+
//# sourceMappingURL=SessionTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionTracker.js","sources":["../../../src/trackers/SessionTracker.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.SessionTracker = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst core_1 = require(\"@aws-amplify/core\");\nconst logger = new core_1.ConsoleLogger('SessionTracker');\nclass SessionTracker {\n constructor(eventRecorder, options) {\n this.options = {};\n this.eventRecorder = eventRecorder;\n this.sessionTrackingActive = false;\n this.initialEventSent = false;\n this.handleStateChange = this.handleStateChange.bind(this);\n this.configure(eventRecorder, options);\n }\n configure(eventRecorder, options) {\n this.eventRecorder = eventRecorder;\n // Clean up any existing listeners\n this.cleanup();\n // Apply defaults\n this.options = {\n attributes: options?.attributes ?? {},\n };\n // Setup state listeners\n if (!this.sessionTrackingActive) {\n utils_1.sessionListener.addStateChangeListener(this.handleStateChange, !this.initialEventSent);\n this.sessionTrackingActive = true;\n }\n }\n cleanup() {\n if (this.sessionTrackingActive) {\n utils_1.sessionListener.removeStateChangeListener(this.handleStateChange);\n }\n this.sessionTrackingActive = false;\n }\n handleStateChange(state) {\n if (state === 'started') {\n this.sessionStarted();\n }\n else {\n this.sessionStopped();\n }\n }\n sessionStarted() {\n const attributes = this.options.attributes ?? {};\n logger.debug('Recording automatically tracked page view event', {\n SESSION_START_EVENT: utils_1.SESSION_START_EVENT,\n attributes,\n });\n this.eventRecorder(utils_1.SESSION_START_EVENT, attributes);\n // NOTE: The initial event will not be re-sent on re-configuration (e.g. to add additional custom attributes)\n if (!this.initialEventSent) {\n this.initialEventSent = true;\n }\n }\n sessionStopped() {\n const attributes = this.options.attributes ?? {};\n logger.debug('Recording automatically tracked page view event', {\n SESSION_STOP_EVENT: utils_1.SESSION_STOP_EVENT,\n attributes,\n });\n this.eventRecorder(utils_1.SESSION_STOP_EVENT, attributes);\n }\n}\nexports.SessionTracker = SessionTracker;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC7D,OAAO,CAAC,cAAc,GAAG,MAAM;AAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;AAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC;AACzD,MAAM,cAAc,CAAC;AACrB,IAAI,WAAW,CAAC,aAAa,EAAE,OAAO,EAAE;AACxC,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE;AACzB,QAAQ,IAAI,CAAC,aAAa,GAAG,aAAa;AAC1C,QAAQ,IAAI,CAAC,qBAAqB,GAAG,KAAK;AAC1C,QAAQ,IAAI,CAAC,gBAAgB,GAAG,KAAK;AACrC,QAAQ,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;AAClE,QAAQ,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC;AAC9C,IAAI;AACJ,IAAI,SAA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