@aws-amplify/analytics 7.0.1-console-preview.8d88eef.0 → 7.0.1-console-preview.b278dcb.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/errors/validation.d.ts +2 -0
- package/lib/errors/validation.js +8 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/providers/pinpoint/apis/configureAutoTrack.d.ts +15 -0
- package/lib/providers/pinpoint/apis/configureAutoTrack.js +35 -0
- package/lib/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib/providers/pinpoint/apis/index.js +3 -1
- package/lib/providers/pinpoint/index.d.ts +2 -2
- package/lib/providers/pinpoint/index.js +2 -1
- package/lib/providers/pinpoint/types/index.d.ts +1 -1
- package/lib/providers/pinpoint/types/inputs.d.ts +5 -1
- 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 +1 -2
- package/lib/types/inputs.d.ts +16 -0
- package/lib/types/trackers.d.ts +22 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +5 -1
- 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/errors/validation.d.ts +2 -0
- package/lib-esm/errors/validation.js +8 -0
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/index.js +1 -1
- package/lib-esm/providers/pinpoint/apis/configureAutoTrack.d.ts +15 -0
- package/lib-esm/providers/pinpoint/apis/configureAutoTrack.js +31 -0
- package/lib-esm/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib-esm/providers/pinpoint/apis/index.js +1 -0
- package/lib-esm/providers/pinpoint/apis/record.js +1 -1
- 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 +1 -1
- package/lib-esm/providers/pinpoint/types/inputs.d.ts +5 -1
- 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 +1 -2
- package/lib-esm/types/inputs.d.ts +16 -0
- package/lib-esm/types/trackers.d.ts +22 -0
- package/lib-esm/utils/index.d.ts +2 -0
- package/lib-esm/utils/index.js +2 -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 +5 -4
- package/src/errors/validation.ts +8 -0
- package/src/index.ts +3 -1
- package/src/providers/pinpoint/apis/configureAutoTrack.ts +49 -0
- package/src/providers/pinpoint/apis/index.ts +1 -0
- package/src/providers/pinpoint/apis/record.ts +1 -1
- package/src/providers/pinpoint/index.ts +6 -2
- package/src/providers/pinpoint/types/index.ts +5 -1
- package/src/providers/pinpoint/types/inputs.ts +9 -1
- 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 +4 -13
- package/src/types/inputs.ts +25 -0
- package/src/types/trackers.ts +35 -0
- package/src/utils/index.ts +2 -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/types/analytics.d.ts +0 -50
- package/lib-esm/types/analytics.d.ts +0 -50
- package/src/types/analytics.ts +0 -70
- /package/lib/types/{analytics.js → trackers.js} +0 -0
- /package/lib-esm/types/{analytics.js → trackers.js} +0 -0
|
@@ -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
|
+
}
|
|
@@ -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.initialEventSent = false;
|
|
13
|
+
this.sessionTrackingActive = 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 };
|