@aws-amplify/analytics 7.0.1-console-preview.f63250a.0 → 7.0.1-console-preview.e8aa063.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.
Files changed (254) hide show
  1. package/lib/errors/AnalyticsError.d.ts +7 -0
  2. package/lib/errors/AnalyticsError.js +23 -0
  3. package/lib/errors/assertValidationError.d.ts +5 -0
  4. package/lib/errors/assertValidationError.js +17 -0
  5. package/lib/errors/index.d.ts +3 -0
  6. package/lib/errors/index.js +12 -0
  7. package/lib/errors/validation.d.ts +9 -0
  8. package/lib/errors/validation.js +31 -0
  9. package/lib/index.d.ts +0 -3
  10. package/lib/index.js +0 -15
  11. package/lib/providers/pinpoint/apis/identifyUser.d.ts +10 -0
  12. package/lib/providers/pinpoint/apis/identifyUser.js +44 -0
  13. package/lib/providers/pinpoint/apis/index.d.ts +2 -0
  14. package/lib/providers/pinpoint/apis/index.js +9 -0
  15. package/lib/providers/pinpoint/apis/record.d.ts +11 -0
  16. package/lib/providers/pinpoint/apis/record.js +44 -0
  17. package/lib/providers/pinpoint/index.d.ts +1 -1
  18. package/lib/providers/pinpoint/index.js +1 -7
  19. package/lib/providers/pinpoint/types/errors.d.ts +9 -0
  20. package/lib/providers/pinpoint/types/errors.js +15 -0
  21. package/lib/providers/pinpoint/types/index.d.ts +2 -0
  22. package/lib/providers/pinpoint/types/index.js +7 -0
  23. package/lib/providers/pinpoint/types/parameters.d.ts +18 -0
  24. package/lib/providers/pinpoint/utils/index.d.ts +2 -0
  25. package/lib/providers/pinpoint/utils/index.js +9 -0
  26. package/lib/providers/pinpoint/utils/resolveConfig.d.ts +7 -0
  27. package/lib/providers/pinpoint/utils/resolveConfig.js +18 -0
  28. package/lib/providers/pinpoint/utils/resolveCredentials.d.ts +12 -0
  29. package/lib/providers/pinpoint/utils/resolveCredentials.js +24 -0
  30. package/lib/setupTests.js +1 -0
  31. package/lib/tsconfig.tsbuildinfo +1 -1
  32. package/{lib-esm/types/Analytics.d.ts → lib/types/analytics.d.ts} +0 -8
  33. package/lib/types/index.d.ts +1 -3
  34. package/lib/types/index.js +1 -3
  35. package/lib/utils/{UserAgent.d.ts → userAgent.d.ts} +1 -1
  36. package/lib/utils/{UserAgent.js → userAgent.js} +5 -5
  37. package/lib-esm/errors/AnalyticsError.d.ts +7 -0
  38. package/lib-esm/errors/AnalyticsError.js +20 -0
  39. package/lib-esm/errors/assertValidationError.d.ts +5 -0
  40. package/lib-esm/errors/assertValidationError.js +13 -0
  41. package/lib-esm/errors/index.d.ts +3 -0
  42. package/lib-esm/errors/index.js +5 -0
  43. package/lib-esm/errors/validation.d.ts +9 -0
  44. package/lib-esm/errors/validation.js +28 -0
  45. package/lib-esm/index.d.ts +0 -3
  46. package/lib-esm/index.js +0 -12
  47. package/lib-esm/providers/pinpoint/apis/identifyUser.d.ts +10 -0
  48. package/lib-esm/providers/pinpoint/apis/identifyUser.js +40 -0
  49. package/lib-esm/providers/pinpoint/apis/index.d.ts +2 -0
  50. package/{src/types/providers/index.ts → lib-esm/providers/pinpoint/apis/index.js} +2 -1
  51. package/lib-esm/providers/pinpoint/apis/record.d.ts +11 -0
  52. package/lib-esm/providers/pinpoint/apis/record.js +40 -0
  53. package/lib-esm/providers/pinpoint/index.d.ts +1 -1
  54. package/lib-esm/providers/pinpoint/index.js +1 -6
  55. package/lib-esm/providers/pinpoint/types/errors.d.ts +9 -0
  56. package/lib-esm/providers/pinpoint/types/errors.js +12 -0
  57. package/lib-esm/providers/pinpoint/types/index.d.ts +2 -0
  58. package/lib-esm/{types/providers → providers/pinpoint/types}/index.js +1 -1
  59. package/lib-esm/providers/pinpoint/types/parameters.d.ts +18 -0
  60. package/lib-esm/providers/pinpoint/utils/index.d.ts +2 -0
  61. package/lib-esm/{utils/AppUtils.js → providers/pinpoint/utils/index.js} +2 -4
  62. package/lib-esm/providers/pinpoint/utils/resolveConfig.d.ts +7 -0
  63. package/lib-esm/providers/pinpoint/utils/resolveConfig.js +14 -0
  64. package/lib-esm/providers/pinpoint/utils/resolveCredentials.d.ts +12 -0
  65. package/lib-esm/providers/pinpoint/utils/resolveCredentials.js +20 -0
  66. package/lib-esm/setupTests.js +1 -0
  67. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  68. package/{lib/types/Analytics.d.ts → lib-esm/types/analytics.d.ts} +0 -8
  69. package/lib-esm/types/index.d.ts +1 -3
  70. package/lib-esm/types/index.js +1 -3
  71. package/lib-esm/utils/{UserAgent.d.ts → userAgent.d.ts} +1 -1
  72. package/lib-esm/utils/{UserAgent.js → userAgent.js} +1 -1
  73. package/package.json +11 -29
  74. package/src/errors/AnalyticsError.ts +18 -0
  75. package/src/errors/assertValidationError.ts +19 -0
  76. package/src/errors/index.ts +6 -0
  77. package/src/errors/validation.ts +31 -0
  78. package/src/index.ts +0 -15
  79. package/src/providers/pinpoint/apis/identifyUser.ts +35 -0
  80. package/src/{utils/AppUtils.ts → providers/pinpoint/apis/index.ts} +2 -4
  81. package/src/providers/pinpoint/apis/record.ts +50 -0
  82. package/src/providers/pinpoint/index.ts +1 -3
  83. package/src/providers/pinpoint/types/errors.ts +12 -0
  84. package/src/providers/pinpoint/types/index.ts +5 -0
  85. package/src/providers/pinpoint/types/parameters.ts +24 -0
  86. package/src/providers/pinpoint/utils/index.ts +5 -0
  87. package/src/providers/pinpoint/utils/resolveConfig.ts +18 -0
  88. package/src/providers/pinpoint/utils/resolveCredentials.ts +20 -0
  89. package/src/types/{Analytics.ts → analytics.ts} +1 -10
  90. package/src/types/index.ts +1 -3
  91. package/src/utils/{UserAgent.ts → userAgent.ts} +1 -1
  92. package/lib/Analytics.d.ts +0 -87
  93. package/lib/Analytics.js +0 -354
  94. package/lib/providers/AWSKinesisFirehoseProvider.d.ts +0 -12
  95. package/lib/providers/AWSKinesisFirehoseProvider.js +0 -82
  96. package/lib/providers/AWSKinesisProvider.d.ts +0 -43
  97. package/lib/providers/AWSKinesisProvider.js +0 -240
  98. package/lib/providers/AWSPinpointProvider.d.ts +0 -67
  99. package/lib/providers/AWSPinpointProvider.js +0 -576
  100. package/lib/providers/AmazonPersonalizeHelper/DataType.d.ts +0 -40
  101. package/lib/providers/AmazonPersonalizeHelper/MediaAutoTrack.d.ts +0 -20
  102. package/lib/providers/AmazonPersonalizeHelper/MediaAutoTrack.js +0 -156
  103. package/lib/providers/AmazonPersonalizeHelper/SessionInfoManager.d.ts +0 -17
  104. package/lib/providers/AmazonPersonalizeHelper/SessionInfoManager.js +0 -96
  105. package/lib/providers/AmazonPersonalizeHelper/index.d.ts +0 -3
  106. package/lib/providers/AmazonPersonalizeHelper/index.js +0 -7
  107. package/lib/providers/AmazonPersonalizeProvider.d.ts +0 -76
  108. package/lib/providers/AmazonPersonalizeProvider.js +0 -331
  109. package/lib/providers/EventBuffer.d.ts +0 -28
  110. package/lib/providers/EventBuffer.js +0 -209
  111. package/lib/providers/index.d.ts +0 -4
  112. package/lib/providers/index.js +0 -14
  113. package/lib/trackers/EventTracker.d.ts +0 -9
  114. package/lib/trackers/EventTracker.js +0 -99
  115. package/lib/trackers/PageViewTracker.d.ts +0 -12
  116. package/lib/trackers/PageViewTracker.js +0 -158
  117. package/lib/trackers/SessionTracker-rn.d.ts +0 -12
  118. package/lib/trackers/SessionTracker-rn.js +0 -134
  119. package/lib/trackers/SessionTracker.d.ts +0 -14
  120. package/lib/trackers/SessionTracker.js +0 -163
  121. package/lib/trackers/index.d.ts +0 -3
  122. package/lib/trackers/index.js +0 -11
  123. package/lib/trackers/reactnative.d.ts +0 -8
  124. package/lib/trackers/reactnative.js +0 -19
  125. package/lib/types/Analytics.js +0 -2
  126. package/lib/types/Provider.d.ts +0 -10
  127. package/lib/types/providers/AWSKinesisProvider.d.ts +0 -6
  128. package/lib/types/providers/AWSKinesisProvider.js +0 -2
  129. package/lib/types/providers/AWSPinpointProvider.d.ts +0 -50
  130. package/lib/types/providers/AWSPinpointProvider.js +0 -2
  131. package/lib/types/providers/AmazonPersonalizeProvider.d.ts +0 -7
  132. package/lib/types/providers/AmazonPersonalizeProvider.js +0 -2
  133. package/lib/types/providers/index.d.ts +0 -1
  134. package/lib/types/providers/index.js +0 -6
  135. package/lib/utils/AppUtils.d.ts +0 -2
  136. package/lib/utils/AppUtils.js +0 -9
  137. package/lib/utils/AppUtils.native.d.ts +0 -2
  138. package/lib/utils/AppUtils.native.js +0 -10
  139. package/lib/utils/MethodEmbed.d.ts +0 -11
  140. package/lib/utils/MethodEmbed.js +0 -43
  141. package/lib/vendor/dom-utils/closest.d.ts +0 -12
  142. package/lib/vendor/dom-utils/closest.js +0 -27
  143. package/lib/vendor/dom-utils/delegate.d.ts +0 -18
  144. package/lib/vendor/dom-utils/delegate.js +0 -51
  145. package/lib/vendor/dom-utils/dispatch.d.ts +0 -17
  146. package/lib/vendor/dom-utils/dispatch.js +0 -51
  147. package/lib/vendor/dom-utils/get-attributes.d.ts +0 -11
  148. package/lib/vendor/dom-utils/get-attributes.js +0 -28
  149. package/lib/vendor/dom-utils/index.d.ts +0 -7
  150. package/lib/vendor/dom-utils/index.js +0 -17
  151. package/lib/vendor/dom-utils/matches.d.ts +0 -11
  152. package/lib/vendor/dom-utils/matches.js +0 -69
  153. package/lib/vendor/dom-utils/parents.d.ts +0 -10
  154. package/lib/vendor/dom-utils/parents.js +0 -22
  155. package/lib/vendor/dom-utils/parse-url.d.ts +0 -9
  156. package/lib/vendor/dom-utils/parse-url.js +0 -59
  157. package/lib-esm/Analytics.d.ts +0 -87
  158. package/lib-esm/Analytics.js +0 -351
  159. package/lib-esm/providers/AWSKinesisFirehoseProvider.d.ts +0 -12
  160. package/lib-esm/providers/AWSKinesisFirehoseProvider.js +0 -79
  161. package/lib-esm/providers/AWSKinesisProvider.d.ts +0 -43
  162. package/lib-esm/providers/AWSKinesisProvider.js +0 -237
  163. package/lib-esm/providers/AWSPinpointProvider.d.ts +0 -67
  164. package/lib-esm/providers/AWSPinpointProvider.js +0 -573
  165. package/lib-esm/providers/AmazonPersonalizeHelper/DataType.d.ts +0 -40
  166. package/lib-esm/providers/AmazonPersonalizeHelper/MediaAutoTrack.d.ts +0 -20
  167. package/lib-esm/providers/AmazonPersonalizeHelper/MediaAutoTrack.js +0 -153
  168. package/lib-esm/providers/AmazonPersonalizeHelper/SessionInfoManager.d.ts +0 -17
  169. package/lib-esm/providers/AmazonPersonalizeHelper/SessionInfoManager.js +0 -92
  170. package/lib-esm/providers/AmazonPersonalizeHelper/index.d.ts +0 -3
  171. package/lib-esm/providers/AmazonPersonalizeHelper/index.js +0 -2
  172. package/lib-esm/providers/AmazonPersonalizeProvider.d.ts +0 -76
  173. package/lib-esm/providers/AmazonPersonalizeProvider.js +0 -328
  174. package/lib-esm/providers/EventBuffer.d.ts +0 -28
  175. package/lib-esm/providers/EventBuffer.js +0 -207
  176. package/lib-esm/providers/index.d.ts +0 -4
  177. package/lib-esm/providers/index.js +0 -7
  178. package/lib-esm/trackers/EventTracker.d.ts +0 -9
  179. package/lib-esm/trackers/EventTracker.js +0 -96
  180. package/lib-esm/trackers/PageViewTracker.d.ts +0 -12
  181. package/lib-esm/trackers/PageViewTracker.js +0 -155
  182. package/lib-esm/trackers/SessionTracker-rn.d.ts +0 -12
  183. package/lib-esm/trackers/SessionTracker-rn.js +0 -131
  184. package/lib-esm/trackers/SessionTracker.d.ts +0 -14
  185. package/lib-esm/trackers/SessionTracker.js +0 -160
  186. package/lib-esm/trackers/index.d.ts +0 -3
  187. package/lib-esm/trackers/index.js +0 -5
  188. package/lib-esm/trackers/reactnative.d.ts +0 -8
  189. package/lib-esm/trackers/reactnative.js +0 -14
  190. package/lib-esm/types/Analytics.js +0 -1
  191. package/lib-esm/types/Provider.d.ts +0 -10
  192. package/lib-esm/types/providers/AWSKinesisProvider.d.ts +0 -6
  193. package/lib-esm/types/providers/AWSKinesisProvider.js +0 -1
  194. package/lib-esm/types/providers/AWSPinpointProvider.d.ts +0 -50
  195. package/lib-esm/types/providers/AWSPinpointProvider.js +0 -1
  196. package/lib-esm/types/providers/AmazonPersonalizeProvider.d.ts +0 -7
  197. package/lib-esm/types/providers/AmazonPersonalizeProvider.js +0 -1
  198. package/lib-esm/types/providers/index.d.ts +0 -1
  199. package/lib-esm/utils/AppUtils.d.ts +0 -2
  200. package/lib-esm/utils/AppUtils.native.d.ts +0 -2
  201. package/lib-esm/utils/AppUtils.native.js +0 -7
  202. package/lib-esm/utils/MethodEmbed.d.ts +0 -11
  203. package/lib-esm/utils/MethodEmbed.js +0 -40
  204. package/lib-esm/vendor/dom-utils/closest.d.ts +0 -12
  205. package/lib-esm/vendor/dom-utils/closest.js +0 -23
  206. package/lib-esm/vendor/dom-utils/delegate.d.ts +0 -18
  207. package/lib-esm/vendor/dom-utils/delegate.js +0 -47
  208. package/lib-esm/vendor/dom-utils/dispatch.d.ts +0 -17
  209. package/lib-esm/vendor/dom-utils/dispatch.js +0 -47
  210. package/lib-esm/vendor/dom-utils/get-attributes.d.ts +0 -11
  211. package/lib-esm/vendor/dom-utils/get-attributes.js +0 -24
  212. package/lib-esm/vendor/dom-utils/index.d.ts +0 -7
  213. package/lib-esm/vendor/dom-utils/index.js +0 -7
  214. package/lib-esm/vendor/dom-utils/matches.d.ts +0 -11
  215. package/lib-esm/vendor/dom-utils/matches.js +0 -65
  216. package/lib-esm/vendor/dom-utils/parents.d.ts +0 -10
  217. package/lib-esm/vendor/dom-utils/parents.js +0 -18
  218. package/lib-esm/vendor/dom-utils/parse-url.d.ts +0 -9
  219. package/lib-esm/vendor/dom-utils/parse-url.js +0 -55
  220. package/src/Analytics.ts +0 -446
  221. package/src/providers/AWSKinesisFirehoseProvider.ts +0 -105
  222. package/src/providers/AWSKinesisProvider.ts +0 -250
  223. package/src/providers/AWSPinpointProvider.ts +0 -685
  224. package/src/providers/AmazonPersonalizeHelper/DataType.ts +0 -49
  225. package/src/providers/AmazonPersonalizeHelper/MediaAutoTrack.ts +0 -196
  226. package/src/providers/AmazonPersonalizeHelper/SessionInfoManager.ts +0 -121
  227. package/src/providers/AmazonPersonalizeHelper/index.ts +0 -11
  228. package/src/providers/AmazonPersonalizeProvider.ts +0 -398
  229. package/src/providers/EventBuffer.ts +0 -257
  230. package/src/providers/index.ts +0 -8
  231. package/src/trackers/EventTracker.ts +0 -115
  232. package/src/trackers/PageViewTracker.ts +0 -157
  233. package/src/trackers/SessionTracker-rn.ts +0 -134
  234. package/src/trackers/SessionTracker.ts +0 -179
  235. package/src/trackers/index.ts +0 -5
  236. package/src/trackers/reactnative.ts +0 -13
  237. package/src/types/Provider.ts +0 -26
  238. package/src/types/providers/AWSKinesisProvider.ts +0 -8
  239. package/src/types/providers/AWSPinpointProvider.ts +0 -60
  240. package/src/types/providers/AmazonPersonalizeProvider.ts +0 -9
  241. package/src/utils/AppUtils.native.ts +0 -9
  242. package/src/utils/MethodEmbed.ts +0 -49
  243. package/src/vendor/dom-utils/closest.ts +0 -25
  244. package/src/vendor/dom-utils/delegate.ts +0 -51
  245. package/src/vendor/dom-utils/dispatch.ts +0 -59
  246. package/src/vendor/dom-utils/get-attributes.ts +0 -26
  247. package/src/vendor/dom-utils/index.ts +0 -7
  248. package/src/vendor/dom-utils/matches.ts +0 -68
  249. package/src/vendor/dom-utils/parents.ts +0 -19
  250. package/src/vendor/dom-utils/parse-url.ts +0 -66
  251. /package/lib/{types/Provider.js → providers/pinpoint/types/parameters.js} +0 -0
  252. /package/lib/{providers/AmazonPersonalizeHelper/DataType.js → types/analytics.js} +0 -0
  253. /package/lib-esm/{types/Provider.js → providers/pinpoint/types/parameters.js} +0 -0
  254. /package/lib-esm/{providers/AmazonPersonalizeHelper/DataType.js → types/analytics.js} +0 -0
@@ -1,14 +0,0 @@
1
- import { SessionTrackOpts } from '../types';
2
- export declare class SessionTracker {
3
- private _tracker;
4
- private _hasEnabled;
5
- private _config;
6
- private _hidden;
7
- private _visibilityChange;
8
- constructor(tracker: any, opts: any);
9
- private _envCheck;
10
- private _trackFunc;
11
- private _trackBeforeUnload;
12
- private _sendInitialEvent;
13
- configure(opts?: SessionTrackOpts): SessionTrackOpts;
14
- }
@@ -1,160 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { __awaiter, __generator } from "tslib";
4
- // the session tracker for web
5
- import { ConsoleLogger as Logger, browserOrNode, } from '@aws-amplify/core';
6
- var logger = new Logger('SessionTracker');
7
- var defaultOpts = {
8
- enable: false,
9
- provider: 'AWSPinpoint',
10
- };
11
- var initialEventSent = false;
12
- var SessionTracker = /** @class */ (function () {
13
- function SessionTracker(tracker, opts) {
14
- this._config = Object.assign({}, defaultOpts, opts);
15
- this._tracker = tracker;
16
- this._hasEnabled = false;
17
- this._trackFunc = this._trackFunc.bind(this);
18
- this._trackBeforeUnload = this._trackBeforeUnload.bind(this);
19
- this.configure(this._config);
20
- }
21
- SessionTracker.prototype._envCheck = function () {
22
- if (!browserOrNode().isBrowser) {
23
- return false;
24
- }
25
- if (!document || !document.addEventListener) {
26
- logger.debug('not in the supported web environment');
27
- return false;
28
- }
29
- if (typeof document.hidden !== 'undefined') {
30
- this._hidden = 'hidden';
31
- this._visibilityChange = 'visibilitychange';
32
- }
33
- else if (typeof document['msHidden'] !== 'undefined') {
34
- this._hidden = 'msHidden';
35
- this._visibilityChange = 'msvisibilitychange';
36
- }
37
- else if (typeof document['webkitHidden'] !== 'undefined') {
38
- this._hidden = 'webkitHidden';
39
- this._visibilityChange = 'webkitvisibilitychange';
40
- }
41
- else {
42
- logger.debug('not in the supported web environment');
43
- return false;
44
- }
45
- return true;
46
- };
47
- SessionTracker.prototype._trackFunc = function () {
48
- return __awaiter(this, void 0, void 0, function () {
49
- var customAttrs, _a, attributes;
50
- return __generator(this, function (_b) {
51
- switch (_b.label) {
52
- case 0:
53
- if (!(typeof this._config.attributes === 'function')) return [3 /*break*/, 2];
54
- return [4 /*yield*/, this._config.attributes()];
55
- case 1:
56
- _a = _b.sent();
57
- return [3 /*break*/, 3];
58
- case 2:
59
- _a = this._config.attributes;
60
- _b.label = 3;
61
- case 3:
62
- customAttrs = _a;
63
- attributes = Object.assign({}, customAttrs);
64
- if (document.visibilityState === this._hidden) {
65
- this._tracker({
66
- name: '_session.stop',
67
- attributes: attributes,
68
- }, this._config.provider).catch(function (e) {
69
- logger.debug('record session stop event failed.', e);
70
- });
71
- }
72
- else {
73
- this._tracker({
74
- name: '_session.start',
75
- attributes: attributes,
76
- }, this._config.provider).catch(function (e) {
77
- logger.debug('record session start event failed.', e);
78
- });
79
- }
80
- return [2 /*return*/];
81
- }
82
- });
83
- });
84
- };
85
- SessionTracker.prototype._trackBeforeUnload = function (event) {
86
- // before unload callback cannot be async => https://github.com/aws-amplify/amplify-js/issues/2088
87
- var _this = this;
88
- var customAttrs = typeof this._config.attributes === 'function'
89
- ? Promise.resolve(this._config.attributes())
90
- : Promise.resolve(this._config.attributes);
91
- customAttrs.then(function (custom) {
92
- var attributes = Object.assign({}, custom);
93
- _this._tracker({
94
- name: '_session.stop',
95
- attributes: attributes,
96
- immediate: true,
97
- }, _this._config.provider).catch(function (e) {
98
- logger.debug('record session stop event failed.', e);
99
- });
100
- });
101
- };
102
- // to keep configure a synchronized function
103
- SessionTracker.prototype._sendInitialEvent = function () {
104
- return __awaiter(this, void 0, void 0, function () {
105
- var customAttrs, _a, attributes;
106
- return __generator(this, function (_b) {
107
- switch (_b.label) {
108
- case 0:
109
- if (initialEventSent) {
110
- logger.debug('the start session has been sent when the page is loaded');
111
- return [2 /*return*/];
112
- }
113
- else {
114
- initialEventSent = true;
115
- }
116
- if (!(typeof this._config.attributes === 'function')) return [3 /*break*/, 2];
117
- return [4 /*yield*/, this._config.attributes()];
118
- case 1:
119
- _a = _b.sent();
120
- return [3 /*break*/, 3];
121
- case 2:
122
- _a = this._config.attributes;
123
- _b.label = 3;
124
- case 3:
125
- customAttrs = _a;
126
- attributes = Object.assign({}, customAttrs);
127
- this._tracker({
128
- name: '_session.start',
129
- attributes: attributes,
130
- }, this._config.provider).catch(function (e) {
131
- logger.debug('record session start event failed.', e);
132
- });
133
- return [2 /*return*/];
134
- }
135
- });
136
- });
137
- };
138
- SessionTracker.prototype.configure = function (opts) {
139
- if (!this._envCheck()) {
140
- return this._config;
141
- }
142
- Object.assign(this._config, opts);
143
- if (this._config.enable && !this._hasEnabled) {
144
- // send a start session as soon as it's enabled
145
- this._sendInitialEvent();
146
- // listen on events
147
- document.addEventListener(this._visibilityChange, this._trackFunc, false);
148
- window.addEventListener('beforeunload', this._trackBeforeUnload, false);
149
- this._hasEnabled = true;
150
- }
151
- else if (!this._config.enable && this._hasEnabled) {
152
- document.removeEventListener(this._visibilityChange, this._trackFunc, false);
153
- window.removeEventListener('beforeunload', this._trackBeforeUnload, false);
154
- this._hasEnabled = false;
155
- }
156
- return this._config;
157
- };
158
- return SessionTracker;
159
- }());
160
- export { SessionTracker };
@@ -1,3 +0,0 @@
1
- export { PageViewTracker } from './PageViewTracker';
2
- export { EventTracker } from './EventTracker';
3
- export { SessionTracker } from './SessionTracker';
@@ -1,5 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- export { PageViewTracker } from './PageViewTracker';
4
- export { EventTracker } from './EventTracker';
5
- export { SessionTracker } from './SessionTracker';
@@ -1,8 +0,0 @@
1
- import { SessionTracker } from './SessionTracker-rn';
2
- declare class EventTracker {
3
- constructor(tracker: any, opts: any);
4
- }
5
- declare class PageViewTracker {
6
- constructor(tracker: any, opts: any);
7
- }
8
- export { EventTracker, PageViewTracker, SessionTracker };
@@ -1,14 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { SessionTracker } from './SessionTracker-rn';
4
- var EventTracker = /** @class */ (function () {
5
- function EventTracker(tracker, opts) {
6
- }
7
- return EventTracker;
8
- }());
9
- var PageViewTracker = /** @class */ (function () {
10
- function PageViewTracker(tracker, opts) {
11
- }
12
- return PageViewTracker;
13
- }());
14
- export { EventTracker, PageViewTracker, SessionTracker };
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- export interface PromiseHandlers {
2
- resolve: Function;
3
- reject: Function;
4
- }
5
- export interface AnalyticsProvider {
6
- configure(config: object): object;
7
- record(params: object, handlers?: PromiseHandlers): Promise<boolean>;
8
- getCategory(): string;
9
- getProviderName(): string;
10
- }
@@ -1,6 +0,0 @@
1
- export interface KinesisAnalyticsEvent {
2
- data: object | string;
3
- partitionKey: string;
4
- streamName: string;
5
- immediate?: boolean;
6
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,50 +0,0 @@
1
- import { PromiseHandlers } from '../Provider';
2
- export type Event = {
3
- eventId: string;
4
- name: string;
5
- attributes: string;
6
- metrics: string;
7
- session: object;
8
- immediate: boolean;
9
- };
10
- export type EventConfig = {
11
- appId: string;
12
- endpointId: string;
13
- region: string;
14
- resendLimit: number;
15
- };
16
- export type EventParams = {
17
- event: Event;
18
- timestamp: string;
19
- config: EventConfig;
20
- credentials: object;
21
- resendLimit: number;
22
- };
23
- export type EventObject = {
24
- params: EventParams;
25
- handlers: PromiseHandlers;
26
- };
27
- export type EventMap = {
28
- [key: string]: EventObject;
29
- };
30
- export type EventBuffer = Array<EventMap>;
31
- export type EndpointBuffer = Array<EventObject>;
32
- export type PutEventsResponse = {
33
- EventsResponse: {
34
- Results?: {
35
- [endpointId: string]: {
36
- EventsItemResponse?: {
37
- [eventId: string]: {
38
- StatusCode?: number;
39
- Message?: string;
40
- };
41
- };
42
- };
43
- };
44
- };
45
- };
46
- export type EndpointFailureData = {
47
- err: any;
48
- update_params: any;
49
- endpointObject: EventObject;
50
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- export interface PersonalizeAnalyticsEvent {
2
- eventType?: string;
3
- userId?: string;
4
- properties?: {
5
- [key: string]: string;
6
- };
7
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * from './AWSPinpointProvider';
@@ -1,2 +0,0 @@
1
- declare const isAppInForeground: () => boolean;
2
- export { isAppInForeground };
@@ -1,2 +0,0 @@
1
- declare const isAppInForeground: () => boolean;
2
- export { isAppInForeground };
@@ -1,7 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { AppState } from 'react-native';
4
- var isAppInForeground = function () {
5
- return AppState.currentState === 'active';
6
- };
7
- export { isAppInForeground };
@@ -1,11 +0,0 @@
1
- export declare class MethodEmbed {
2
- context: any;
3
- methodName: any;
4
- private _originalMethod;
5
- private _bindedMethod;
6
- static add(context: any, methodName: any, methodOverride: any): void;
7
- static remove(context: any, methodName: any): void;
8
- constructor(context: any, methodName: any);
9
- set(methodOverride: any): void;
10
- remove(): void;
11
- }
@@ -1,40 +0,0 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { __read, __spreadArray } from "tslib";
4
- var lists = [];
5
- var MethodEmbed = /** @class */ (function () {
6
- function MethodEmbed(context, methodName) {
7
- this.context = context;
8
- this.methodName = methodName;
9
- this._originalMethod = context[methodName].bind(context);
10
- }
11
- MethodEmbed.add = function (context, methodName, methodOverride) {
12
- getInstance(context, methodName).set(methodOverride);
13
- };
14
- MethodEmbed.remove = function (context, methodName) {
15
- getInstance(context, methodName).remove();
16
- };
17
- MethodEmbed.prototype.set = function (methodOverride) {
18
- var _this = this;
19
- this.context[this.methodName] = function () {
20
- var args = [];
21
- for (var _i = 0; _i < arguments.length; _i++) {
22
- args[_i] = arguments[_i];
23
- }
24
- return methodOverride(_this._originalMethod.apply(_this, __spreadArray([], __read(args), false)));
25
- };
26
- };
27
- MethodEmbed.prototype.remove = function () {
28
- this.context[this.methodName] = this._originalMethod;
29
- };
30
- return MethodEmbed;
31
- }());
32
- export { MethodEmbed };
33
- function getInstance(context, methodName) {
34
- var instance = lists.filter(function (h) { return h.context === context && h.methodName === methodName; })[0];
35
- if (!instance) {
36
- instance = new MethodEmbed(context, methodName);
37
- lists.push(instance);
38
- }
39
- return instance;
40
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
3
- */
4
- /**
5
- * Gets the closest parent element that matches the passed selector.
6
- * @param {Element} element The element whose parents to check.
7
- * @param {string} selector The CSS selector to match against.
8
- * @param {boolean=} shouldCheckSelf True if the selector should test against
9
- * the passed element itself.
10
- * @return {Element|undefined} The matching element or undefined.
11
- */
12
- export declare function closest(element: any, selector: any, shouldCheckSelf?: boolean): any;
@@ -1,23 +0,0 @@
1
- /**
2
- * Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
3
- */
4
- import { matches } from './matches';
5
- import { parents } from './parents';
6
- /**
7
- * Gets the closest parent element that matches the passed selector.
8
- * @param {Element} element The element whose parents to check.
9
- * @param {string} selector The CSS selector to match against.
10
- * @param {boolean=} shouldCheckSelf True if the selector should test against
11
- * the passed element itself.
12
- * @return {Element|undefined} The matching element or undefined.
13
- */
14
- export function closest(element, selector, shouldCheckSelf) {
15
- if (shouldCheckSelf === void 0) { shouldCheckSelf = false; }
16
- if (!(element && element.nodeType === 1 && selector))
17
- return;
18
- var parentElements = (shouldCheckSelf ? [element] : []).concat(parents(element));
19
- for (var i = 0, parent_1; (parent_1 = parentElements[i]); i++) {
20
- if (matches(parent_1, selector))
21
- return parent_1;
22
- }
23
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
3
- */
4
- /**
5
- * Delegates the handling of events for an element matching a selector to an
6
- * ancestor of the matching element.
7
- * @param {!Node} ancestor The ancestor element to add the listener to.
8
- * @param {string} eventType The event type to listen to.
9
- * @param {string} selector A CSS selector to match against child elements.
10
- * @param {!Function} callback A function to run any time the event happens.
11
- * @param {Object=} opts A configuration options object. The available options:
12
- * - useCapture<boolean>: If true, bind to the event capture phase.
13
- * - deep<boolean>: If true, delegate into shadow trees.
14
- * @return {Object} The delegate object. It contains a destroy method.
15
- */
16
- export declare function delegate(ancestor: any, eventType: any, selector: any, callback: any, opts?: {}): {
17
- destroy: () => void;
18
- };
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
3
- */
4
- import { closest } from './closest';
5
- import { matches } from './matches';
6
- /**
7
- * Delegates the handling of events for an element matching a selector to an
8
- * ancestor of the matching element.
9
- * @param {!Node} ancestor The ancestor element to add the listener to.
10
- * @param {string} eventType The event type to listen to.
11
- * @param {string} selector A CSS selector to match against child elements.
12
- * @param {!Function} callback A function to run any time the event happens.
13
- * @param {Object=} opts A configuration options object. The available options:
14
- * - useCapture<boolean>: If true, bind to the event capture phase.
15
- * - deep<boolean>: If true, delegate into shadow trees.
16
- * @return {Object} The delegate object. It contains a destroy method.
17
- */
18
- export function delegate(ancestor, eventType, selector, callback, opts) {
19
- if (opts === void 0) { opts = {}; }
20
- // Defines the event listener.
21
- var listener = function (event) {
22
- var delegateTarget;
23
- // If opts.composed is true and the event originated from inside a Shadow
24
- // tree, check the composed path nodes.
25
- if (opts['composed'] && typeof event['composedPath'] === 'function') {
26
- var composedPath = event.composedPath();
27
- for (var i = 0, node = void 0; (node = composedPath[i]); i++) {
28
- if (node.nodeType === 1 && matches(node, selector)) {
29
- delegateTarget = node;
30
- }
31
- }
32
- }
33
- else {
34
- // Otherwise check the parents.
35
- delegateTarget = closest(event.target, selector, true);
36
- }
37
- if (delegateTarget) {
38
- callback.call(delegateTarget, event, delegateTarget);
39
- }
40
- };
41
- ancestor.addEventListener(eventType, listener, opts['useCapture']);
42
- return {
43
- destroy: function () {
44
- ancestor.removeEventListener(eventType, listener, opts['useCapture']);
45
- },
46
- };
47
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
3
- */
4
- /**
5
- * Dispatches an event on the passed element.
6
- * @param {!Element} element The DOM element to dispatch the event on.
7
- * @param {string} eventType The type of event to dispatch.
8
- * @param {Object|string=} eventName A string name of the event constructor
9
- * to use. Defaults to 'Event' if nothing is passed or 'CustomEvent' if
10
- * a value is set on `initDict.detail`. If eventName is given an object
11
- * it is assumed to be initDict and thus reassigned.
12
- * @param {Object=} initDict The initialization attributes for the
13
- * event. A `detail` property can be used here to pass custom data.
14
- * @return {boolean} The return value of `element.dispatchEvent`, which will
15
- * be false if any of the event listeners called `preventDefault`.
16
- */
17
- export declare function dispatch(element: any, eventType: any, evtName?: string, init_dict?: {}): any;
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
3
- */
4
- /**
5
- * Dispatches an event on the passed element.
6
- * @param {!Element} element The DOM element to dispatch the event on.
7
- * @param {string} eventType The type of event to dispatch.
8
- * @param {Object|string=} eventName A string name of the event constructor
9
- * to use. Defaults to 'Event' if nothing is passed or 'CustomEvent' if
10
- * a value is set on `initDict.detail`. If eventName is given an object
11
- * it is assumed to be initDict and thus reassigned.
12
- * @param {Object=} initDict The initialization attributes for the
13
- * event. A `detail` property can be used here to pass custom data.
14
- * @return {boolean} The return value of `element.dispatchEvent`, which will
15
- * be false if any of the event listeners called `preventDefault`.
16
- */
17
- export function dispatch(element, eventType, evtName, init_dict) {
18
- if (evtName === void 0) { evtName = 'Event'; }
19
- if (init_dict === void 0) { init_dict = {}; }
20
- var event;
21
- var isCustom;
22
- var initDict = init_dict;
23
- var eventName = evtName;
24
- // eventName is optional
25
- if (typeof eventName === 'object') {
26
- initDict = eventName;
27
- eventName = 'Event';
28
- }
29
- initDict['bubbles'] = initDict['bubbles'] || false;
30
- initDict['cancelable'] = initDict['cancelable'] || false;
31
- initDict['composed'] = initDict['composed'] || false;
32
- // If a detail property is passed, this is a custom event.
33
- if ('detail' in initDict)
34
- isCustom = true;
35
- eventName = isCustom ? 'CustomEvent' : eventName;
36
- // Tries to create the event using constructors, if that doesn't work,
37
- // fallback to `document.createEvent()`.
38
- try {
39
- event = new window[eventName](eventType, initDict);
40
- }
41
- catch (err) {
42
- event = document.createEvent(eventName);
43
- var initMethod = 'init' + (isCustom ? 'Custom' : '') + 'Event';
44
- event[initMethod](eventType, initDict['bubbles'], initDict['cancelable'], initDict['detail']);
45
- }
46
- return element.dispatchEvent(event);
47
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
3
- */
4
- /**
5
- * Gets all attributes of an element as a plain JavaScriot object.
6
- * @param {Element} element The element whose attributes to get.
7
- * @return {!Object} An object whose keys are the attribute keys and whose
8
- * values are the attribute values. If no attributes exist, an empty
9
- * object is returned.
10
- */
11
- export declare function getAttributes(element: any): {};
@@ -1,24 +0,0 @@
1
- /**
2
- * Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
3
- */
4
- /**
5
- * Gets all attributes of an element as a plain JavaScriot object.
6
- * @param {Element} element The element whose attributes to get.
7
- * @return {!Object} An object whose keys are the attribute keys and whose
8
- * values are the attribute values. If no attributes exist, an empty
9
- * object is returned.
10
- */
11
- export function getAttributes(element) {
12
- var attrs = {};
13
- // Validate input.
14
- if (!(element && element.nodeType === 1))
15
- return attrs;
16
- // Return an empty object if there are no attributes.
17
- var map = element.attributes;
18
- if (map.length === 0)
19
- return {};
20
- for (var i = 0, attr = void 0; (attr = map[i]); i++) {
21
- attrs[attr.name] = attr.value;
22
- }
23
- return attrs;
24
- }
@@ -1,7 +0,0 @@
1
- export { closest } from './closest';
2
- export { delegate } from './delegate';
3
- export { dispatch } from './dispatch';
4
- export { getAttributes } from './get-attributes';
5
- export { matches } from './matches';
6
- export { parents } from './parents';
7
- export { parseUrl } from './parse-url';
@@ -1,7 +0,0 @@
1
- export { closest } from './closest';
2
- export { delegate } from './delegate';
3
- export { dispatch } from './dispatch';
4
- export { getAttributes } from './get-attributes';
5
- export { matches } from './matches';
6
- export { parents } from './parents';
7
- export { parseUrl } from './parse-url';
@@ -1,11 +0,0 @@
1
- /**
2
- * Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
3
- */
4
- /**
5
- * Tests if a DOM elements matches any of the test DOM elements or selectors.
6
- * @param {Element} element The DOM element to test.
7
- * @param {Element|string|Array<Element|string>} test A DOM element, a CSS
8
- * selector, or an array of DOM elements or CSS selectors to match against.
9
- * @return {boolean} True of any part of the test matches.
10
- */
11
- export declare function matches(element: any, test: any): any;