@aws-amplify/analytics 7.0.1-console-preview.f63250a.0 → 7.0.1-console-preview.5dc0b68.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/AnalyticsError.d.ts +7 -0
- package/lib/errors/AnalyticsError.js +23 -0
- package/lib/errors/assertValidationError.d.ts +5 -0
- package/lib/errors/assertValidationError.js +17 -0
- package/lib/errors/index.d.ts +3 -0
- package/lib/errors/index.js +12 -0
- package/lib/errors/validation.d.ts +9 -0
- package/lib/errors/validation.js +31 -0
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -15
- package/lib/providers/pinpoint/apis/identifyUser.d.ts +10 -0
- package/lib/providers/pinpoint/apis/identifyUser.js +44 -0
- package/lib/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib/providers/pinpoint/apis/index.js +9 -0
- package/lib/providers/pinpoint/apis/record.d.ts +11 -0
- package/lib/providers/pinpoint/apis/record.js +44 -0
- package/lib/providers/pinpoint/index.d.ts +1 -1
- package/lib/providers/pinpoint/index.js +1 -7
- package/lib/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib/providers/pinpoint/types/errors.js +15 -0
- package/lib/providers/pinpoint/types/index.d.ts +2 -0
- package/lib/providers/pinpoint/types/index.js +7 -0
- package/lib/providers/pinpoint/types/parameters.d.ts +18 -0
- package/lib/providers/pinpoint/utils/index.d.ts +2 -0
- package/lib/providers/pinpoint/utils/index.js +9 -0
- package/lib/providers/pinpoint/utils/resolveConfig.d.ts +7 -0
- package/lib/providers/pinpoint/utils/resolveConfig.js +18 -0
- package/lib/providers/pinpoint/utils/resolveCredentials.d.ts +12 -0
- package/lib/providers/pinpoint/utils/resolveCredentials.js +24 -0
- package/lib/setupTests.js +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/{lib-esm/types/Analytics.d.ts → lib/types/analytics.d.ts} +0 -8
- package/lib/types/index.d.ts +1 -3
- package/lib/types/index.js +1 -3
- package/lib/utils/{UserAgent.d.ts → userAgent.d.ts} +1 -1
- package/lib/utils/{UserAgent.js → userAgent.js} +5 -5
- package/lib-esm/errors/AnalyticsError.d.ts +7 -0
- package/lib-esm/errors/AnalyticsError.js +20 -0
- package/lib-esm/errors/assertValidationError.d.ts +5 -0
- package/lib-esm/errors/assertValidationError.js +13 -0
- package/lib-esm/errors/index.d.ts +3 -0
- package/lib-esm/errors/index.js +5 -0
- package/lib-esm/errors/validation.d.ts +9 -0
- package/lib-esm/errors/validation.js +28 -0
- package/lib-esm/index.d.ts +0 -3
- package/lib-esm/index.js +0 -12
- package/lib-esm/providers/pinpoint/apis/identifyUser.d.ts +10 -0
- package/lib-esm/providers/pinpoint/apis/identifyUser.js +40 -0
- package/lib-esm/providers/pinpoint/apis/index.d.ts +2 -0
- package/{src/types/providers/index.ts → lib-esm/providers/pinpoint/apis/index.js} +2 -1
- package/lib-esm/providers/pinpoint/apis/record.d.ts +11 -0
- package/lib-esm/providers/pinpoint/apis/record.js +40 -0
- package/lib-esm/providers/pinpoint/index.d.ts +1 -1
- package/lib-esm/providers/pinpoint/index.js +1 -6
- package/lib-esm/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib-esm/providers/pinpoint/types/errors.js +12 -0
- package/lib-esm/providers/pinpoint/types/index.d.ts +2 -0
- package/lib-esm/{types/providers → providers/pinpoint/types}/index.js +1 -1
- package/lib-esm/providers/pinpoint/types/parameters.d.ts +18 -0
- package/lib-esm/providers/pinpoint/utils/index.d.ts +2 -0
- package/lib-esm/{utils/AppUtils.js → providers/pinpoint/utils/index.js} +2 -4
- package/lib-esm/providers/pinpoint/utils/resolveConfig.d.ts +7 -0
- package/lib-esm/providers/pinpoint/utils/resolveConfig.js +14 -0
- package/lib-esm/providers/pinpoint/utils/resolveCredentials.d.ts +12 -0
- package/lib-esm/providers/pinpoint/utils/resolveCredentials.js +20 -0
- package/lib-esm/setupTests.js +1 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/{lib/types/Analytics.d.ts → lib-esm/types/analytics.d.ts} +0 -8
- package/lib-esm/types/index.d.ts +1 -3
- package/lib-esm/types/index.js +1 -3
- package/lib-esm/utils/{UserAgent.d.ts → userAgent.d.ts} +1 -1
- package/lib-esm/utils/{UserAgent.js → userAgent.js} +1 -1
- package/package.json +11 -29
- package/src/errors/AnalyticsError.ts +18 -0
- package/src/errors/assertValidationError.ts +19 -0
- package/src/errors/index.ts +6 -0
- package/src/errors/validation.ts +31 -0
- package/src/index.ts +0 -15
- package/src/providers/pinpoint/apis/identifyUser.ts +35 -0
- package/src/{utils/AppUtils.ts → providers/pinpoint/apis/index.ts} +2 -4
- package/src/providers/pinpoint/apis/record.ts +50 -0
- package/src/providers/pinpoint/index.ts +1 -3
- package/src/providers/pinpoint/types/errors.ts +12 -0
- package/src/providers/pinpoint/types/index.ts +5 -0
- package/src/providers/pinpoint/types/parameters.ts +24 -0
- package/src/providers/pinpoint/utils/index.ts +5 -0
- package/src/providers/pinpoint/utils/resolveConfig.ts +18 -0
- package/src/providers/pinpoint/utils/resolveCredentials.ts +20 -0
- package/src/types/{Analytics.ts → analytics.ts} +1 -10
- package/src/types/index.ts +1 -3
- package/src/utils/{UserAgent.ts → userAgent.ts} +1 -1
- package/lib/Analytics.d.ts +0 -87
- package/lib/Analytics.js +0 -354
- package/lib/providers/AWSKinesisFirehoseProvider.d.ts +0 -12
- package/lib/providers/AWSKinesisFirehoseProvider.js +0 -82
- package/lib/providers/AWSKinesisProvider.d.ts +0 -43
- package/lib/providers/AWSKinesisProvider.js +0 -240
- package/lib/providers/AWSPinpointProvider.d.ts +0 -67
- package/lib/providers/AWSPinpointProvider.js +0 -576
- package/lib/providers/AmazonPersonalizeHelper/DataType.d.ts +0 -40
- package/lib/providers/AmazonPersonalizeHelper/MediaAutoTrack.d.ts +0 -20
- package/lib/providers/AmazonPersonalizeHelper/MediaAutoTrack.js +0 -156
- package/lib/providers/AmazonPersonalizeHelper/SessionInfoManager.d.ts +0 -17
- package/lib/providers/AmazonPersonalizeHelper/SessionInfoManager.js +0 -96
- package/lib/providers/AmazonPersonalizeHelper/index.d.ts +0 -3
- package/lib/providers/AmazonPersonalizeHelper/index.js +0 -7
- package/lib/providers/AmazonPersonalizeProvider.d.ts +0 -76
- package/lib/providers/AmazonPersonalizeProvider.js +0 -331
- package/lib/providers/EventBuffer.d.ts +0 -28
- package/lib/providers/EventBuffer.js +0 -209
- package/lib/providers/index.d.ts +0 -4
- package/lib/providers/index.js +0 -14
- package/lib/trackers/EventTracker.d.ts +0 -9
- package/lib/trackers/EventTracker.js +0 -99
- package/lib/trackers/PageViewTracker.d.ts +0 -12
- package/lib/trackers/PageViewTracker.js +0 -158
- package/lib/trackers/SessionTracker-rn.d.ts +0 -12
- package/lib/trackers/SessionTracker-rn.js +0 -134
- package/lib/trackers/SessionTracker.d.ts +0 -14
- package/lib/trackers/SessionTracker.js +0 -163
- package/lib/trackers/index.d.ts +0 -3
- package/lib/trackers/index.js +0 -11
- package/lib/trackers/reactnative.d.ts +0 -8
- package/lib/trackers/reactnative.js +0 -19
- package/lib/types/Analytics.js +0 -2
- package/lib/types/Provider.d.ts +0 -10
- package/lib/types/providers/AWSKinesisProvider.d.ts +0 -6
- package/lib/types/providers/AWSKinesisProvider.js +0 -2
- package/lib/types/providers/AWSPinpointProvider.d.ts +0 -50
- package/lib/types/providers/AWSPinpointProvider.js +0 -2
- package/lib/types/providers/AmazonPersonalizeProvider.d.ts +0 -7
- package/lib/types/providers/AmazonPersonalizeProvider.js +0 -2
- package/lib/types/providers/index.d.ts +0 -1
- package/lib/types/providers/index.js +0 -6
- package/lib/utils/AppUtils.d.ts +0 -2
- package/lib/utils/AppUtils.js +0 -9
- package/lib/utils/AppUtils.native.d.ts +0 -2
- package/lib/utils/AppUtils.native.js +0 -10
- package/lib/utils/MethodEmbed.d.ts +0 -11
- package/lib/utils/MethodEmbed.js +0 -43
- package/lib/vendor/dom-utils/closest.d.ts +0 -12
- package/lib/vendor/dom-utils/closest.js +0 -27
- package/lib/vendor/dom-utils/delegate.d.ts +0 -18
- package/lib/vendor/dom-utils/delegate.js +0 -51
- package/lib/vendor/dom-utils/dispatch.d.ts +0 -17
- package/lib/vendor/dom-utils/dispatch.js +0 -51
- package/lib/vendor/dom-utils/get-attributes.d.ts +0 -11
- package/lib/vendor/dom-utils/get-attributes.js +0 -28
- package/lib/vendor/dom-utils/index.d.ts +0 -7
- package/lib/vendor/dom-utils/index.js +0 -17
- package/lib/vendor/dom-utils/matches.d.ts +0 -11
- package/lib/vendor/dom-utils/matches.js +0 -69
- package/lib/vendor/dom-utils/parents.d.ts +0 -10
- package/lib/vendor/dom-utils/parents.js +0 -22
- package/lib/vendor/dom-utils/parse-url.d.ts +0 -9
- package/lib/vendor/dom-utils/parse-url.js +0 -59
- package/lib-esm/Analytics.d.ts +0 -87
- package/lib-esm/Analytics.js +0 -351
- package/lib-esm/providers/AWSKinesisFirehoseProvider.d.ts +0 -12
- package/lib-esm/providers/AWSKinesisFirehoseProvider.js +0 -79
- package/lib-esm/providers/AWSKinesisProvider.d.ts +0 -43
- package/lib-esm/providers/AWSKinesisProvider.js +0 -237
- package/lib-esm/providers/AWSPinpointProvider.d.ts +0 -67
- package/lib-esm/providers/AWSPinpointProvider.js +0 -573
- package/lib-esm/providers/AmazonPersonalizeHelper/DataType.d.ts +0 -40
- package/lib-esm/providers/AmazonPersonalizeHelper/MediaAutoTrack.d.ts +0 -20
- package/lib-esm/providers/AmazonPersonalizeHelper/MediaAutoTrack.js +0 -153
- package/lib-esm/providers/AmazonPersonalizeHelper/SessionInfoManager.d.ts +0 -17
- package/lib-esm/providers/AmazonPersonalizeHelper/SessionInfoManager.js +0 -92
- package/lib-esm/providers/AmazonPersonalizeHelper/index.d.ts +0 -3
- package/lib-esm/providers/AmazonPersonalizeHelper/index.js +0 -2
- package/lib-esm/providers/AmazonPersonalizeProvider.d.ts +0 -76
- package/lib-esm/providers/AmazonPersonalizeProvider.js +0 -328
- package/lib-esm/providers/EventBuffer.d.ts +0 -28
- package/lib-esm/providers/EventBuffer.js +0 -207
- package/lib-esm/providers/index.d.ts +0 -4
- package/lib-esm/providers/index.js +0 -7
- package/lib-esm/trackers/EventTracker.d.ts +0 -9
- package/lib-esm/trackers/EventTracker.js +0 -96
- package/lib-esm/trackers/PageViewTracker.d.ts +0 -12
- package/lib-esm/trackers/PageViewTracker.js +0 -155
- package/lib-esm/trackers/SessionTracker-rn.d.ts +0 -12
- package/lib-esm/trackers/SessionTracker-rn.js +0 -131
- package/lib-esm/trackers/SessionTracker.d.ts +0 -14
- package/lib-esm/trackers/SessionTracker.js +0 -160
- package/lib-esm/trackers/index.d.ts +0 -3
- package/lib-esm/trackers/index.js +0 -5
- package/lib-esm/trackers/reactnative.d.ts +0 -8
- package/lib-esm/trackers/reactnative.js +0 -14
- package/lib-esm/types/Analytics.js +0 -1
- package/lib-esm/types/Provider.d.ts +0 -10
- package/lib-esm/types/providers/AWSKinesisProvider.d.ts +0 -6
- package/lib-esm/types/providers/AWSKinesisProvider.js +0 -1
- package/lib-esm/types/providers/AWSPinpointProvider.d.ts +0 -50
- package/lib-esm/types/providers/AWSPinpointProvider.js +0 -1
- package/lib-esm/types/providers/AmazonPersonalizeProvider.d.ts +0 -7
- package/lib-esm/types/providers/AmazonPersonalizeProvider.js +0 -1
- package/lib-esm/types/providers/index.d.ts +0 -1
- package/lib-esm/utils/AppUtils.d.ts +0 -2
- package/lib-esm/utils/AppUtils.native.d.ts +0 -2
- package/lib-esm/utils/AppUtils.native.js +0 -7
- package/lib-esm/utils/MethodEmbed.d.ts +0 -11
- package/lib-esm/utils/MethodEmbed.js +0 -40
- package/lib-esm/vendor/dom-utils/closest.d.ts +0 -12
- package/lib-esm/vendor/dom-utils/closest.js +0 -23
- package/lib-esm/vendor/dom-utils/delegate.d.ts +0 -18
- package/lib-esm/vendor/dom-utils/delegate.js +0 -47
- package/lib-esm/vendor/dom-utils/dispatch.d.ts +0 -17
- package/lib-esm/vendor/dom-utils/dispatch.js +0 -47
- package/lib-esm/vendor/dom-utils/get-attributes.d.ts +0 -11
- package/lib-esm/vendor/dom-utils/get-attributes.js +0 -24
- package/lib-esm/vendor/dom-utils/index.d.ts +0 -7
- package/lib-esm/vendor/dom-utils/index.js +0 -7
- package/lib-esm/vendor/dom-utils/matches.d.ts +0 -11
- package/lib-esm/vendor/dom-utils/matches.js +0 -65
- package/lib-esm/vendor/dom-utils/parents.d.ts +0 -10
- package/lib-esm/vendor/dom-utils/parents.js +0 -18
- package/lib-esm/vendor/dom-utils/parse-url.d.ts +0 -9
- package/lib-esm/vendor/dom-utils/parse-url.js +0 -55
- package/src/Analytics.ts +0 -446
- package/src/providers/AWSKinesisFirehoseProvider.ts +0 -105
- package/src/providers/AWSKinesisProvider.ts +0 -250
- package/src/providers/AWSPinpointProvider.ts +0 -685
- package/src/providers/AmazonPersonalizeHelper/DataType.ts +0 -49
- package/src/providers/AmazonPersonalizeHelper/MediaAutoTrack.ts +0 -196
- package/src/providers/AmazonPersonalizeHelper/SessionInfoManager.ts +0 -121
- package/src/providers/AmazonPersonalizeHelper/index.ts +0 -11
- package/src/providers/AmazonPersonalizeProvider.ts +0 -398
- package/src/providers/EventBuffer.ts +0 -257
- package/src/providers/index.ts +0 -8
- package/src/trackers/EventTracker.ts +0 -115
- package/src/trackers/PageViewTracker.ts +0 -157
- package/src/trackers/SessionTracker-rn.ts +0 -134
- package/src/trackers/SessionTracker.ts +0 -179
- package/src/trackers/index.ts +0 -5
- package/src/trackers/reactnative.ts +0 -13
- package/src/types/Provider.ts +0 -26
- package/src/types/providers/AWSKinesisProvider.ts +0 -8
- package/src/types/providers/AWSPinpointProvider.ts +0 -60
- package/src/types/providers/AmazonPersonalizeProvider.ts +0 -9
- package/src/utils/AppUtils.native.ts +0 -9
- package/src/utils/MethodEmbed.ts +0 -49
- package/src/vendor/dom-utils/closest.ts +0 -25
- package/src/vendor/dom-utils/delegate.ts +0 -51
- package/src/vendor/dom-utils/dispatch.ts +0 -59
- package/src/vendor/dom-utils/get-attributes.ts +0 -26
- package/src/vendor/dom-utils/index.ts +0 -7
- package/src/vendor/dom-utils/matches.ts +0 -68
- package/src/vendor/dom-utils/parents.ts +0 -19
- package/src/vendor/dom-utils/parse-url.ts +0 -66
- /package/lib/{types/Provider.js → providers/pinpoint/types/parameters.js} +0 -0
- /package/lib/{providers/AmazonPersonalizeHelper/DataType.js → types/analytics.js} +0 -0
- /package/lib-esm/{types/Provider.js → providers/pinpoint/types/parameters.js} +0 -0
- /package/lib-esm/{providers/AmazonPersonalizeHelper/DataType.js → types/analytics.js} +0 -0
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MediaAutoTrack = void 0;
|
|
4
|
-
var HTML5_MEDIA_EVENT;
|
|
5
|
-
(function (HTML5_MEDIA_EVENT) {
|
|
6
|
-
HTML5_MEDIA_EVENT["PLAY"] = "play";
|
|
7
|
-
HTML5_MEDIA_EVENT["PAUSE"] = "pause";
|
|
8
|
-
HTML5_MEDIA_EVENT["ENDED"] = "Ended";
|
|
9
|
-
})(HTML5_MEDIA_EVENT || (HTML5_MEDIA_EVENT = {}));
|
|
10
|
-
var MEDIA_TYPE;
|
|
11
|
-
(function (MEDIA_TYPE) {
|
|
12
|
-
MEDIA_TYPE["IFRAME"] = "IFRAME";
|
|
13
|
-
MEDIA_TYPE["VIDEO"] = "VIDEO";
|
|
14
|
-
MEDIA_TYPE["AUDIO"] = "AUDIO";
|
|
15
|
-
})(MEDIA_TYPE || (MEDIA_TYPE = {}));
|
|
16
|
-
var EVENT_TYPE;
|
|
17
|
-
(function (EVENT_TYPE) {
|
|
18
|
-
EVENT_TYPE["PLAY"] = "Play";
|
|
19
|
-
EVENT_TYPE["ENDED"] = "Ended";
|
|
20
|
-
EVENT_TYPE["PAUSE"] = "Pause";
|
|
21
|
-
EVENT_TYPE["TIME_WATCHED"] = "TimeWatched";
|
|
22
|
-
})(EVENT_TYPE || (EVENT_TYPE = {}));
|
|
23
|
-
var MediaAutoTrack = /** @class */ (function () {
|
|
24
|
-
function MediaAutoTrack(params, provider) {
|
|
25
|
-
var _a;
|
|
26
|
-
this.eventActionMapping = (_a = {},
|
|
27
|
-
_a[EVENT_TYPE.ENDED] = this.endedEventAction.bind(this),
|
|
28
|
-
_a[EVENT_TYPE.PLAY] = this.playEventAction.bind(this),
|
|
29
|
-
_a[EVENT_TYPE.PAUSE] = this.pauseEventAction.bind(this),
|
|
30
|
-
_a);
|
|
31
|
-
var eventData = params.eventData;
|
|
32
|
-
this._params = params;
|
|
33
|
-
this._mediaElement = document.getElementById(eventData.properties['domElementId']);
|
|
34
|
-
this._started = false;
|
|
35
|
-
this._provider = provider;
|
|
36
|
-
var mediaTrackFunMapping = {
|
|
37
|
-
IFRAME: this._iframeMediaTracker,
|
|
38
|
-
VIDEO: this._html5MediaTracker,
|
|
39
|
-
AUDIO: this._html5MediaTracker,
|
|
40
|
-
};
|
|
41
|
-
mediaTrackFunMapping[this._mediaElement.tagName].bind(this)();
|
|
42
|
-
this._initYoutubeFrame();
|
|
43
|
-
}
|
|
44
|
-
MediaAutoTrack.prototype._initYoutubeFrame = function () {
|
|
45
|
-
this._youTubeIframeLoader = {
|
|
46
|
-
src: 'https://www.youtube.com/iframe_api',
|
|
47
|
-
loading: false,
|
|
48
|
-
loaded: false,
|
|
49
|
-
listeners: [],
|
|
50
|
-
load: function (callback) {
|
|
51
|
-
var _this = this;
|
|
52
|
-
this.listeners.push(callback);
|
|
53
|
-
if (this.loaded) {
|
|
54
|
-
setTimeout(function () {
|
|
55
|
-
_this.done();
|
|
56
|
-
});
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (this.loading) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
this.loading = true;
|
|
63
|
-
window['onYouTubeIframeAPIReady'] = function () {
|
|
64
|
-
_this.loaded = true;
|
|
65
|
-
_this.done();
|
|
66
|
-
};
|
|
67
|
-
var script = document.createElement('script');
|
|
68
|
-
script.type = 'text/javascript';
|
|
69
|
-
script.src = this.src;
|
|
70
|
-
document.body.appendChild(script);
|
|
71
|
-
},
|
|
72
|
-
done: function () {
|
|
73
|
-
delete window['onYouTubeIframeAPIReady'];
|
|
74
|
-
while (this.listeners.length) {
|
|
75
|
-
this.listeners.pop()(window['YT']);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
MediaAutoTrack.prototype._iframeMediaTracker = function () {
|
|
81
|
-
var that = this;
|
|
82
|
-
setInterval(function () {
|
|
83
|
-
if (that._started) {
|
|
84
|
-
that.recordEvent(MEDIA_TYPE.IFRAME, EVENT_TYPE.TIME_WATCHED);
|
|
85
|
-
}
|
|
86
|
-
}, 3 * 1000);
|
|
87
|
-
this._youTubeIframeLoader.load(function (YT) {
|
|
88
|
-
that._iframePlayer = new YT.Player(that._mediaElement.id, {
|
|
89
|
-
events: { onStateChange: that._onPlayerStateChange.bind(that) },
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
MediaAutoTrack.prototype._onPlayerStateChange = function (event) {
|
|
94
|
-
var iframeEventMapping = {
|
|
95
|
-
0: EVENT_TYPE.ENDED,
|
|
96
|
-
1: EVENT_TYPE.PLAY,
|
|
97
|
-
2: EVENT_TYPE.PAUSE,
|
|
98
|
-
};
|
|
99
|
-
var eventType = iframeEventMapping[event.data];
|
|
100
|
-
if (eventType) {
|
|
101
|
-
this.eventActionMapping[eventType](MEDIA_TYPE.IFRAME);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
MediaAutoTrack.prototype._html5MediaTracker = function () {
|
|
105
|
-
var that = this;
|
|
106
|
-
setInterval(function () {
|
|
107
|
-
if (that._started) {
|
|
108
|
-
that.recordEvent(MEDIA_TYPE.VIDEO, EVENT_TYPE.TIME_WATCHED);
|
|
109
|
-
}
|
|
110
|
-
}, 3 * 1000);
|
|
111
|
-
this._mediaElement.addEventListener(HTML5_MEDIA_EVENT.PLAY, function () {
|
|
112
|
-
that.eventActionMapping[EVENT_TYPE.PLAY](MEDIA_TYPE.VIDEO);
|
|
113
|
-
}, false);
|
|
114
|
-
this._mediaElement.addEventListener(HTML5_MEDIA_EVENT.PAUSE, function () {
|
|
115
|
-
that.eventActionMapping[EVENT_TYPE.PAUSE](MEDIA_TYPE.VIDEO);
|
|
116
|
-
}, false);
|
|
117
|
-
this._mediaElement.addEventListener(HTML5_MEDIA_EVENT.ENDED, function () {
|
|
118
|
-
that.eventActionMapping[EVENT_TYPE.ENDED](MEDIA_TYPE.VIDEO);
|
|
119
|
-
}, false);
|
|
120
|
-
};
|
|
121
|
-
MediaAutoTrack.prototype.playEventAction = function (mediaType) {
|
|
122
|
-
this._started = true;
|
|
123
|
-
this.recordEvent(mediaType, EVENT_TYPE.PLAY);
|
|
124
|
-
};
|
|
125
|
-
MediaAutoTrack.prototype.pauseEventAction = function (mediaType) {
|
|
126
|
-
this._started = false;
|
|
127
|
-
this.recordEvent(mediaType, EVENT_TYPE.PAUSE);
|
|
128
|
-
};
|
|
129
|
-
MediaAutoTrack.prototype.endedEventAction = function (mediaType) {
|
|
130
|
-
this._started = false;
|
|
131
|
-
this.recordEvent(mediaType, EVENT_TYPE.ENDED);
|
|
132
|
-
};
|
|
133
|
-
MediaAutoTrack.prototype.recordEvent = function (mediaType, eventType) {
|
|
134
|
-
var newParams = Object.assign({}, this._params);
|
|
135
|
-
var eventData = newParams.eventData;
|
|
136
|
-
eventData.eventType = eventType;
|
|
137
|
-
var currentPlayTime;
|
|
138
|
-
if (mediaType === MEDIA_TYPE.VIDEO) {
|
|
139
|
-
currentPlayTime = this._mediaElement.currentTime;
|
|
140
|
-
eventData.properties.duration = this._mediaElement.duration;
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
currentPlayTime = this._financial(this._iframePlayer.getCurrentTime());
|
|
144
|
-
eventData.properties.duration = this._financial(this._iframePlayer.getDuration());
|
|
145
|
-
}
|
|
146
|
-
var percentage = parseFloat(currentPlayTime) / parseFloat(eventData.properties.duration);
|
|
147
|
-
eventData.properties.eventValue = Number(percentage.toFixed(4));
|
|
148
|
-
delete eventData.properties.domElementId;
|
|
149
|
-
this._provider.putToBuffer(newParams);
|
|
150
|
-
};
|
|
151
|
-
MediaAutoTrack.prototype._financial = function (x) {
|
|
152
|
-
return Number.parseFloat(x).toFixed(4);
|
|
153
|
-
};
|
|
154
|
-
return MediaAutoTrack;
|
|
155
|
-
}());
|
|
156
|
-
exports.MediaAutoTrack = MediaAutoTrack;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SessionInfo } from './DataType';
|
|
2
|
-
export declare class SessionInfoManager {
|
|
3
|
-
private _isBrowser;
|
|
4
|
-
private _cache;
|
|
5
|
-
private _timer;
|
|
6
|
-
private _timerKey;
|
|
7
|
-
constructor(prefixKey?: string);
|
|
8
|
-
private _refreshTimer;
|
|
9
|
-
private storeValue;
|
|
10
|
-
private retrieveValue;
|
|
11
|
-
private _getCachePrefix;
|
|
12
|
-
getTimerKey(): any;
|
|
13
|
-
updateSessionInfo(userId: string, sessionInfo: SessionInfo): void;
|
|
14
|
-
private _isRequireUpdateSessionInfo;
|
|
15
|
-
retrieveSessionInfo(trackingId: string): SessionInfo;
|
|
16
|
-
private _isRequireNewSession;
|
|
17
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SessionInfoManager = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
6
|
-
var isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
|
|
7
|
-
var uuid_1 = require("uuid");
|
|
8
|
-
var core_1 = require("@aws-amplify/core");
|
|
9
|
-
var PERSONALIZE_CACHE = '_awsct';
|
|
10
|
-
var PERSONALIZE_CACHE_USERID = '_awsct_uid';
|
|
11
|
-
var PERSONALIZE_CACHE_SESSIONID = '_awsct_sid';
|
|
12
|
-
var DEFAULT_CACHE_PREFIX = 'personalize';
|
|
13
|
-
var TIMER_INTERVAL = 30 * 1000;
|
|
14
|
-
var DELIMITER = '.';
|
|
15
|
-
var CACHE_EXPIRY_IN_DAYS = 7;
|
|
16
|
-
var logger = new core_1.ConsoleLogger('AmazonPersonalizeProvider');
|
|
17
|
-
var SessionInfoManager = /** @class */ (function () {
|
|
18
|
-
function SessionInfoManager(prefixKey) {
|
|
19
|
-
if (prefixKey === void 0) { prefixKey = ''; }
|
|
20
|
-
this._isBrowser = (0, core_1.browserOrNode)().isBrowser;
|
|
21
|
-
this._timerKey = (0, uuid_1.v1)().substr(0, 15);
|
|
22
|
-
this._refreshTimer();
|
|
23
|
-
}
|
|
24
|
-
SessionInfoManager.prototype._refreshTimer = function () {
|
|
25
|
-
if (this._timer) {
|
|
26
|
-
clearInterval(this._timer);
|
|
27
|
-
}
|
|
28
|
-
var that = this;
|
|
29
|
-
this._timer = setInterval(function () {
|
|
30
|
-
that._timerKey = (0, uuid_1.v1)().substr(0, 15);
|
|
31
|
-
}, TIMER_INTERVAL);
|
|
32
|
-
};
|
|
33
|
-
SessionInfoManager.prototype.storeValue = function (key, value) {
|
|
34
|
-
var today = new Date();
|
|
35
|
-
var expire = new Date();
|
|
36
|
-
expire.setTime(today.getTime() + 3600000 * 24 * CACHE_EXPIRY_IN_DAYS);
|
|
37
|
-
core_1.Cache.setItem(this._getCachePrefix(key), value, {
|
|
38
|
-
expires: expire.getTime(),
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
SessionInfoManager.prototype.retrieveValue = function (key) {
|
|
42
|
-
return core_1.Cache.getItem(this._getCachePrefix(key));
|
|
43
|
-
};
|
|
44
|
-
SessionInfoManager.prototype._getCachePrefix = function (key) {
|
|
45
|
-
if (this._isBrowser) {
|
|
46
|
-
return key + DELIMITER + window.location.host;
|
|
47
|
-
}
|
|
48
|
-
return DEFAULT_CACHE_PREFIX;
|
|
49
|
-
};
|
|
50
|
-
SessionInfoManager.prototype.getTimerKey = function () {
|
|
51
|
-
return this._timerKey;
|
|
52
|
-
};
|
|
53
|
-
SessionInfoManager.prototype.updateSessionInfo = function (userId, sessionInfo) {
|
|
54
|
-
var existUserId = sessionInfo.userId;
|
|
55
|
-
var existSessionId = sessionInfo.sessionId;
|
|
56
|
-
if (this._isRequireNewSession(userId, existUserId, existSessionId)) {
|
|
57
|
-
var newSessionId = (0, uuid_1.v1)();
|
|
58
|
-
this.storeValue(PERSONALIZE_CACHE_USERID, userId);
|
|
59
|
-
this.storeValue(PERSONALIZE_CACHE_SESSIONID, newSessionId);
|
|
60
|
-
sessionInfo.sessionId = newSessionId;
|
|
61
|
-
}
|
|
62
|
-
else if (this._isRequireUpdateSessionInfo(userId, existUserId, existSessionId)) {
|
|
63
|
-
this.storeValue(PERSONALIZE_CACHE_USERID, userId);
|
|
64
|
-
}
|
|
65
|
-
sessionInfo.userId = userId;
|
|
66
|
-
};
|
|
67
|
-
SessionInfoManager.prototype._isRequireUpdateSessionInfo = function (userId, cachedSessionUserId, cachedSessionSessionId) {
|
|
68
|
-
// anonymouse => sign in : hasSession && s_userId == null && curr_userId !=null
|
|
69
|
-
var isNoCachedSession = (0, isEmpty_1.default)(cachedSessionSessionId);
|
|
70
|
-
return (!isNoCachedSession && (0, isEmpty_1.default)(cachedSessionUserId) && !(0, isEmpty_1.default)(userId));
|
|
71
|
-
};
|
|
72
|
-
SessionInfoManager.prototype.retrieveSessionInfo = function (trackingId) {
|
|
73
|
-
var sessionInfo = {};
|
|
74
|
-
sessionInfo.trackingId = trackingId;
|
|
75
|
-
sessionInfo.sessionId = this.retrieveValue(PERSONALIZE_CACHE_SESSIONID);
|
|
76
|
-
sessionInfo.userId = this.retrieveValue(PERSONALIZE_CACHE_USERID);
|
|
77
|
-
if ((0, isEmpty_1.default)(sessionInfo.sessionId)) {
|
|
78
|
-
sessionInfo.sessionId = (0, uuid_1.v1)();
|
|
79
|
-
this.storeValue(PERSONALIZE_CACHE_SESSIONID, sessionInfo.sessionId);
|
|
80
|
-
}
|
|
81
|
-
this.storeValue(PERSONALIZE_CACHE, trackingId);
|
|
82
|
-
return sessionInfo;
|
|
83
|
-
};
|
|
84
|
-
SessionInfoManager.prototype._isRequireNewSession = function (userId, cachedSessionUserId, cachedSessionSessionId) {
|
|
85
|
-
// new session => 1. no cached session info 2. signOut: s_userId !=null && curr_userId ==null
|
|
86
|
-
// 3. switch account: s_userId !=null && curr_userId !=null && s_userId != curr_userId
|
|
87
|
-
var isNoCachedSession = (0, isEmpty_1.default)(cachedSessionSessionId);
|
|
88
|
-
var isSignoutCase = (0, isEmpty_1.default)(userId) && !(0, isEmpty_1.default)(cachedSessionUserId);
|
|
89
|
-
var isSwitchUserCase = !(0, isEmpty_1.default)(userId) &&
|
|
90
|
-
!(0, isEmpty_1.default)(cachedSessionUserId) &&
|
|
91
|
-
!(0, isEqual_1.default)(userId, cachedSessionUserId);
|
|
92
|
-
return isNoCachedSession || isSignoutCase || isSwitchUserCase;
|
|
93
|
-
};
|
|
94
|
-
return SessionInfoManager;
|
|
95
|
-
}());
|
|
96
|
-
exports.SessionInfoManager = SessionInfoManager;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MediaAutoTrack = exports.SessionInfoManager = void 0;
|
|
4
|
-
var SessionInfoManager_1 = require("./SessionInfoManager");
|
|
5
|
-
Object.defineProperty(exports, "SessionInfoManager", { enumerable: true, get: function () { return SessionInfoManager_1.SessionInfoManager; } });
|
|
6
|
-
var MediaAutoTrack_1 = require("./MediaAutoTrack");
|
|
7
|
-
Object.defineProperty(exports, "MediaAutoTrack", { enumerable: true, get: function () { return MediaAutoTrack_1.MediaAutoTrack; } });
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { AnalyticsProvider } from '../types';
|
|
2
|
-
export declare class AmazonPersonalizeProvider implements AnalyticsProvider {
|
|
3
|
-
private _config;
|
|
4
|
-
private _personalize;
|
|
5
|
-
private _buffer;
|
|
6
|
-
private _timer;
|
|
7
|
-
private _sessionInfo;
|
|
8
|
-
private _sessionManager;
|
|
9
|
-
private _isBrowser;
|
|
10
|
-
constructor(config?: any);
|
|
11
|
-
private _setupTimer;
|
|
12
|
-
/**
|
|
13
|
-
* Record event
|
|
14
|
-
* @param eventType - type of the event action. e.g. "Click"
|
|
15
|
-
* @param properties - properties of the event
|
|
16
|
-
* @return Promise
|
|
17
|
-
*/
|
|
18
|
-
record(params: any): Promise<boolean>;
|
|
19
|
-
private loadElement;
|
|
20
|
-
private isElementFullyLoaded;
|
|
21
|
-
/**
|
|
22
|
-
* get the category of the plugin
|
|
23
|
-
*/
|
|
24
|
-
getCategory(): string;
|
|
25
|
-
/**
|
|
26
|
-
* get provider name of the plugin
|
|
27
|
-
*/
|
|
28
|
-
getProviderName(): string;
|
|
29
|
-
/**
|
|
30
|
-
* configure the plugin
|
|
31
|
-
* @param {Object} config - configuration
|
|
32
|
-
*/
|
|
33
|
-
configure(config: any): object;
|
|
34
|
-
/**
|
|
35
|
-
* Generate the requestParams from customer input params and sessionInfo
|
|
36
|
-
* @private
|
|
37
|
-
* @param eventData - customer input for event data
|
|
38
|
-
* @param api - api name
|
|
39
|
-
* @return RequestParams - wrapper object with all information required for make request
|
|
40
|
-
*/
|
|
41
|
-
private generateRequestParams;
|
|
42
|
-
/**
|
|
43
|
-
* record an event
|
|
44
|
-
* @param {Object} params - the params of an event
|
|
45
|
-
*/
|
|
46
|
-
private _sendEvents;
|
|
47
|
-
/**
|
|
48
|
-
* Put event into buffer
|
|
49
|
-
* @private
|
|
50
|
-
* @param params - params for the event recording
|
|
51
|
-
*/
|
|
52
|
-
private putToBuffer;
|
|
53
|
-
/**
|
|
54
|
-
* flush the buffer and batch sending the request
|
|
55
|
-
* @private
|
|
56
|
-
* @param eventsParams - the buffer for cache the payload
|
|
57
|
-
*/
|
|
58
|
-
private _sendFromBuffer;
|
|
59
|
-
/**
|
|
60
|
-
* Generate the record payload for single event
|
|
61
|
-
* @private
|
|
62
|
-
* @param params - RequestParams
|
|
63
|
-
*/
|
|
64
|
-
private _generateSingleRecordPayload;
|
|
65
|
-
/**
|
|
66
|
-
* Initialize the personalize client
|
|
67
|
-
* @private
|
|
68
|
-
* @param params - RequestParams
|
|
69
|
-
*/
|
|
70
|
-
private _init;
|
|
71
|
-
/**
|
|
72
|
-
* check if current credentials exists
|
|
73
|
-
* @private
|
|
74
|
-
*/
|
|
75
|
-
private _getCredentials;
|
|
76
|
-
}
|