@aws-amplify/analytics 5.2.29-unstable.4 → 5.2.29

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 (160) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build.js +5 -0
  3. package/dist/aws-amplify-analytics.js +67617 -0
  4. package/dist/aws-amplify-analytics.js.map +1 -0
  5. package/dist/aws-amplify-analytics.min.js +26 -0
  6. package/dist/aws-amplify-analytics.min.js.map +1 -0
  7. package/index.js +7 -0
  8. package/lib/Analytics.js +95 -53
  9. package/lib/Analytics.js.map +1 -1
  10. package/lib/Providers/AWSKinesisFirehoseProvider.js +30 -4
  11. package/lib/Providers/AWSKinesisFirehoseProvider.js.map +1 -1
  12. package/lib/Providers/AWSKinesisProvider.js +56 -7
  13. package/lib/Providers/AWSKinesisProvider.js.map +1 -1
  14. package/lib/Providers/AWSPinpointProvider.js +107 -32
  15. package/lib/Providers/AWSPinpointProvider.js.map +1 -1
  16. package/lib/Providers/AmazonPersonalizeHelper/MediaAutoTrack.js.map +1 -1
  17. package/lib/Providers/AmazonPersonalizeHelper/SessionInfoManager.js +9 -7
  18. package/lib/Providers/AmazonPersonalizeHelper/SessionInfoManager.js.map +1 -1
  19. package/lib/Providers/AmazonPersonalizeHelper/index.js +5 -4
  20. package/lib/Providers/AmazonPersonalizeHelper/index.js.map +1 -1
  21. package/lib/Providers/AmazonPersonalizeProvider.js +61 -9
  22. package/lib/Providers/AmazonPersonalizeProvider.js.map +1 -1
  23. package/lib/Providers/EventBuffer.js +62 -7
  24. package/lib/Providers/EventBuffer.js.map +1 -1
  25. package/lib/index.js +20 -7
  26. package/lib/index.js.map +1 -1
  27. package/lib/trackers/EventTracker.js +55 -6
  28. package/lib/trackers/EventTracker.js.map +1 -1
  29. package/lib/trackers/PageViewTracker.js +60 -11
  30. package/lib/trackers/PageViewTracker.js.map +1 -1
  31. package/lib/trackers/SessionTracker-rn.js +56 -7
  32. package/lib/trackers/SessionTracker-rn.js.map +1 -1
  33. package/lib/trackers/SessionTracker.js +57 -8
  34. package/lib/trackers/SessionTracker.js.map +1 -1
  35. package/lib/trackers/index.js +3 -3
  36. package/lib/trackers/index.js.map +1 -1
  37. package/lib/types/Provider.js +12 -2
  38. package/lib/types/Provider.js.map +1 -1
  39. package/lib/types/index.js +12 -2
  40. package/lib/types/index.js.map +1 -1
  41. package/lib/utils/MethodEmbed.js +37 -4
  42. package/lib/utils/MethodEmbed.js.map +1 -1
  43. package/lib/vendor/dom-utils/matches.js +1 -1
  44. package/lib/vendor/dom-utils/matches.js.map +1 -1
  45. package/lib/vendor/dom-utils/parse-url.js +1 -1
  46. package/lib/vendor/dom-utils/parse-url.js.map +1 -1
  47. package/lib-esm/Analytics.d.ts +12 -3
  48. package/lib-esm/Analytics.js +83 -41
  49. package/lib-esm/Analytics.js.map +1 -1
  50. package/lib-esm/Providers/AWSKinesisFirehoseProvider.d.ts +4 -0
  51. package/lib-esm/Providers/AWSKinesisFirehoseProvider.js +29 -3
  52. package/lib-esm/Providers/AWSKinesisFirehoseProvider.js.map +1 -1
  53. package/lib-esm/Providers/AWSKinesisProvider.d.ts +4 -0
  54. package/lib-esm/Providers/AWSKinesisProvider.js +52 -3
  55. package/lib-esm/Providers/AWSKinesisProvider.js.map +1 -1
  56. package/lib-esm/Providers/AWSPinpointProvider.d.ts +4 -0
  57. package/lib-esm/Providers/AWSPinpointProvider.js +80 -8
  58. package/lib-esm/Providers/AWSPinpointProvider.js.map +1 -1
  59. package/lib-esm/Providers/AmazonPersonalizeHelper/MediaAutoTrack.js.map +1 -1
  60. package/lib-esm/Providers/AmazonPersonalizeHelper/SessionInfoManager.js +3 -3
  61. package/lib-esm/Providers/AmazonPersonalizeHelper/SessionInfoManager.js.map +1 -1
  62. package/lib-esm/Providers/AmazonPersonalizeHelper/index.d.ts +3 -3
  63. package/lib-esm/Providers/AmazonPersonalizeHelper/index.js +2 -2
  64. package/lib-esm/Providers/AmazonPersonalizeHelper/index.js.map +1 -1
  65. package/lib-esm/Providers/AmazonPersonalizeProvider.d.ts +4 -0
  66. package/lib-esm/Providers/AmazonPersonalizeProvider.js +54 -5
  67. package/lib-esm/Providers/AmazonPersonalizeProvider.js.map +1 -1
  68. package/lib-esm/Providers/EventBuffer.js +56 -1
  69. package/lib-esm/Providers/EventBuffer.js.map +1 -1
  70. package/lib-esm/index.d.ts +8 -3
  71. package/lib-esm/index.js +19 -4
  72. package/lib-esm/index.js.map +1 -1
  73. package/lib-esm/trackers/EventTracker.d.ts +4 -0
  74. package/lib-esm/trackers/EventTracker.js +54 -5
  75. package/lib-esm/trackers/EventTracker.js.map +1 -1
  76. package/lib-esm/trackers/PageViewTracker.d.ts +4 -0
  77. package/lib-esm/trackers/PageViewTracker.js +57 -8
  78. package/lib-esm/trackers/PageViewTracker.js.map +1 -1
  79. package/lib-esm/trackers/SessionTracker-rn.d.ts +4 -0
  80. package/lib-esm/trackers/SessionTracker-rn.js +52 -3
  81. package/lib-esm/trackers/SessionTracker-rn.js.map +1 -1
  82. package/lib-esm/trackers/SessionTracker.d.ts +4 -0
  83. package/lib-esm/trackers/SessionTracker.js +54 -5
  84. package/lib-esm/trackers/SessionTracker.js.map +1 -1
  85. package/lib-esm/trackers/index.d.ts +3 -3
  86. package/lib-esm/trackers/index.js +3 -3
  87. package/lib-esm/trackers/index.js.map +1 -1
  88. package/lib-esm/types/Provider.js +12 -2
  89. package/lib-esm/types/Provider.js.map +1 -1
  90. package/lib-esm/types/index.js +12 -2
  91. package/lib-esm/types/index.js.map +1 -1
  92. package/lib-esm/utils/MethodEmbed.d.ts +4 -0
  93. package/lib-esm/utils/MethodEmbed.js +36 -3
  94. package/lib-esm/utils/MethodEmbed.js.map +1 -1
  95. package/lib-esm/vendor/dom-utils/matches.js +2 -2
  96. package/lib-esm/vendor/dom-utils/matches.js.map +1 -1
  97. package/lib-esm/vendor/dom-utils/parse-url.js +2 -2
  98. package/lib-esm/vendor/dom-utils/parse-url.js.map +1 -1
  99. package/package.json +9 -13
  100. package/src/Analytics.ts +54 -48
  101. package/src/Providers/AWSKinesisFirehoseProvider.ts +17 -2
  102. package/src/Providers/AWSKinesisProvider.ts +17 -2
  103. package/src/Providers/AWSPinpointProvider.ts +25 -12
  104. package/src/Providers/AmazonPersonalizeHelper/DataType.ts +12 -2
  105. package/src/Providers/AmazonPersonalizeHelper/MediaAutoTrack.ts +12 -2
  106. package/src/Providers/AmazonPersonalizeHelper/SessionInfoManager.ts +16 -5
  107. package/src/Providers/AmazonPersonalizeHelper/index.ts +15 -11
  108. package/src/Providers/AmazonPersonalizeProvider.ts +23 -6
  109. package/src/index.ts +21 -10
  110. package/src/trackers/EventTracker.ts +19 -4
  111. package/src/trackers/PageViewTracker.ts +22 -7
  112. package/src/trackers/SessionTracker-rn.ts +17 -2
  113. package/src/trackers/SessionTracker.ts +19 -9
  114. package/src/trackers/index.ts +3 -3
  115. package/src/types/Analytics.ts +12 -2
  116. package/src/types/Provider.ts +12 -2
  117. package/src/types/index.ts +12 -2
  118. package/src/utils/MethodEmbed.ts +17 -2
  119. package/src/vendor/dom-utils/matches.ts +2 -2
  120. package/src/vendor/dom-utils/parse-url.ts +2 -2
  121. package/webpack.config.dev.js +6 -0
  122. package/lib/.tsbuildinfo +0 -3
  123. package/lib/Analytics.d.ts +0 -87
  124. package/lib/Providers/AWSKinesisFirehoseProvider.d.ts +0 -12
  125. package/lib/Providers/AWSKinesisProvider.d.ts +0 -43
  126. package/lib/Providers/AWSPinpointProvider.d.ts +0 -70
  127. package/lib/Providers/AmazonPersonalizeHelper/DataType.d.ts +0 -40
  128. package/lib/Providers/AmazonPersonalizeHelper/MediaAutoTrack.d.ts +0 -20
  129. package/lib/Providers/AmazonPersonalizeHelper/SessionInfoManager.d.ts +0 -17
  130. package/lib/Providers/AmazonPersonalizeHelper/index.d.ts +0 -3
  131. package/lib/Providers/AmazonPersonalizeProvider.d.ts +0 -76
  132. package/lib/Providers/EventBuffer.d.ts +0 -30
  133. package/lib/Providers/index.d.ts +0 -4
  134. package/lib/index.d.ts +0 -3
  135. package/lib/setupTests.d.ts +0 -1
  136. package/lib/trackers/EventTracker.d.ts +0 -9
  137. package/lib/trackers/PageViewTracker.d.ts +0 -12
  138. package/lib/trackers/SessionTracker-rn.d.ts +0 -12
  139. package/lib/trackers/SessionTracker.d.ts +0 -14
  140. package/lib/trackers/index.d.ts +0 -3
  141. package/lib/trackers/reactnative.d.ts +0 -8
  142. package/lib/types/Analytics.d.ts +0 -66
  143. package/lib/types/Provider.d.ts +0 -10
  144. package/lib/types/Providers/AWSKinesisProvider.d.ts +0 -5
  145. package/lib/types/Providers/AWSPinpointProvider.d.ts +0 -50
  146. package/lib/types/Providers/AmazonPersonalizeProvider.d.ts +0 -7
  147. package/lib/types/Providers/index.d.ts +0 -1
  148. package/lib/types/index.d.ts +0 -3
  149. package/lib/utils/AppUtils.d.ts +0 -2
  150. package/lib/utils/AppUtils.native.d.ts +0 -2
  151. package/lib/utils/MethodEmbed.d.ts +0 -11
  152. package/lib/vendor/dom-utils/closest.d.ts +0 -12
  153. package/lib/vendor/dom-utils/delegate.d.ts +0 -18
  154. package/lib/vendor/dom-utils/dispatch.d.ts +0 -17
  155. package/lib/vendor/dom-utils/get-attributes.d.ts +0 -11
  156. package/lib/vendor/dom-utils/index.d.ts +0 -7
  157. package/lib/vendor/dom-utils/matches.d.ts +0 -11
  158. package/lib/vendor/dom-utils/parents.d.ts +0 -10
  159. package/lib/vendor/dom-utils/parse-url.d.ts +0 -9
  160. package/lib-esm/.tsbuildinfo +0 -3
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@aws-amplify/analytics",
3
- "version": "5.2.29-unstable.4+751349a34",
3
+ "version": "5.2.29",
4
4
  "description": "Analytics category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
7
7
  "typings": "./lib-esm/index.d.ts",
8
8
  "sideEffects": [
9
+ "./src/Analytics.ts",
9
10
  "./lib/Analytics.js",
10
- "./lib-esm/Analytics.js"
11
+ "./lib-esm/Analytics.js",
12
+ "./dist/aws-amplify-analytics.js",
13
+ "./dist/aws-amplify-analytics.min.js"
11
14
  ],
12
15
  "publishConfig": {
13
16
  "access": "public"
@@ -23,8 +26,7 @@
23
26
  "build": "npm run clean && npm run build:esm && npm run build:cjs",
24
27
  "clean": "rimraf lib-esm lib dist",
25
28
  "format": "echo \"Not implemented\"",
26
- "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
27
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 69.26"
29
+ "lint": "tslint 'src/**/*.ts'"
28
30
  },
29
31
  "react-native": {
30
32
  "./lib/index": "./lib-esm/index.js",
@@ -40,21 +42,15 @@
40
42
  "url": "https://github.com/aws/aws-amplify/issues"
41
43
  },
42
44
  "homepage": "https://aws-amplify.github.io/",
43
- "files": [
44
- "lib",
45
- "lib-esm",
46
- "src"
47
- ],
48
45
  "dependencies": {
49
- "@aws-amplify/cache": "4.0.64-unstable.4+751349a34",
50
- "@aws-amplify/core": "4.7.13-unstable.4+751349a34",
46
+ "@aws-amplify/cache": "4.0.64",
47
+ "@aws-amplify/core": "4.7.13",
51
48
  "@aws-sdk/client-firehose": "3.6.1",
52
49
  "@aws-sdk/client-kinesis": "3.6.1",
53
50
  "@aws-sdk/client-personalize-events": "3.6.1",
54
51
  "@aws-sdk/client-pinpoint": "3.6.1",
55
52
  "@aws-sdk/util-utf8-browser": "3.6.1",
56
53
  "lodash": "^4.17.20",
57
- "tslib": "^1.8.0",
58
54
  "uuid": "^3.2.1"
59
55
  },
60
56
  "jest": {
@@ -105,5 +101,5 @@
105
101
  "<rootDir>/src/setupTests.ts"
106
102
  ]
107
103
  },
108
- "gitHead": "751349a340e10c0dded302db94bc5c2095f5651a"
104
+ "gitHead": "eaa4317115aaa23a632af7249b3d995e83af6ef3"
109
105
  }
package/src/Analytics.ts CHANGED
@@ -1,11 +1,21 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
 
4
14
  import {
5
15
  Amplify,
6
16
  ConsoleLogger as Logger,
7
17
  Hub,
8
- parseAWSExports,
18
+ Parser,
9
19
  } from '@aws-amplify/core';
10
20
  import { AWSPinpointProvider } from './Providers/AWSPinpointProvider';
11
21
 
@@ -73,7 +83,6 @@ export class AnalyticsClass {
73
83
  Hub.listen('auth', listener);
74
84
  Hub.listen('storage', listener);
75
85
  Hub.listen('analytics', listener);
76
- Hub.listen('core', listener);
77
86
  }
78
87
 
79
88
  public getModuleName() {
@@ -86,7 +95,7 @@ export class AnalyticsClass {
86
95
  public configure(config?) {
87
96
  if (!config) return this._config;
88
97
  logger.debug('configure Analytics', config);
89
- const amplifyConfig = parseAWSExports(config);
98
+ const amplifyConfig = Parser.parseMobilehubConfig(config);
90
99
  this._config = Object.assign(
91
100
  {},
92
101
  this._config,
@@ -208,15 +217,7 @@ export class AnalyticsClass {
208
217
  * @return - A promise which resolves if buffer doesn't overflow
209
218
  */
210
219
  public async startSession(provider?: string) {
211
- const event = { name: '_session.start' };
212
- const params = { event, provider };
213
-
214
- dispatchAnalyticsEvent(
215
- 'record',
216
- event,
217
- 'Recording Analytics session start event'
218
- );
219
-
220
+ const params = { event: { name: '_session.start' }, provider };
220
221
  return this._sendEvent(params);
221
222
  }
222
223
 
@@ -226,15 +227,7 @@ export class AnalyticsClass {
226
227
  * @return - A promise which resolves if buffer doesn't overflow
227
228
  */
228
229
  public async stopSession(provider?: string) {
229
- const event = { name: '_session.stop' };
230
- const params = { event, provider };
231
-
232
- dispatchAnalyticsEvent(
233
- 'record',
234
- event,
235
- 'Recording Analytics session stop event'
236
- );
237
-
230
+ const params = { event: { name: '_session.stop' }, provider };
238
231
  return this._sendEvent(params);
239
232
  }
240
233
 
@@ -246,11 +239,43 @@ export class AnalyticsClass {
246
239
  public async record(
247
240
  event: AnalyticsEvent | PersonalizeAnalyticsEvent | KinesisAnalyticsEvent,
248
241
  provider?: string
242
+ );
243
+ /**
244
+ * Record one analytic event and send it to Pinpoint
245
+ * @deprecated Use the new syntax and pass in the event as an object instead.
246
+ * @param eventName - The name of the event
247
+ * @param [attributes] - Attributes of the event
248
+ * @param [metrics] - Event metrics
249
+ * @return - A promise which resolves if buffer doesn't overflow
250
+ */
251
+ public async record(
252
+ eventName: string,
253
+ attributes?: EventAttributes,
254
+ metrics?: EventMetrics
255
+ );
256
+ public async record(
257
+ event:
258
+ | string
259
+ | AnalyticsEvent
260
+ | PersonalizeAnalyticsEvent
261
+ | KinesisAnalyticsEvent,
262
+ providerOrAttributes?: string | EventAttributes,
263
+ metrics?: EventMetrics
249
264
  ) {
250
- const params = { event, provider };
251
-
252
- dispatchAnalyticsEvent('record', params.event, 'Recording Analytics event');
253
-
265
+ let params = null;
266
+ // this is just for compatibility, going to be deprecated
267
+ if (typeof event === 'string') {
268
+ params = {
269
+ event: {
270
+ name: event,
271
+ attributes: providerOrAttributes,
272
+ metrics,
273
+ },
274
+ provider: 'AWSPinpoint',
275
+ };
276
+ } else {
277
+ params = { event, provider: providerOrAttributes };
278
+ }
254
279
  return this._sendEvent(params);
255
280
  }
256
281
 
@@ -322,8 +347,6 @@ export class AnalyticsClass {
322
347
  let endpointUpdated = false;
323
348
  let authConfigured = false;
324
349
  let analyticsConfigured = false;
325
- let credentialsConfigured = false;
326
-
327
350
  const listener = capsule => {
328
351
  const { channel, payload } = capsule;
329
352
  logger.debug('on hub capsule ' + channel, payload);
@@ -338,9 +361,6 @@ const listener = capsule => {
338
361
  case 'analytics':
339
362
  analyticsEvent(payload);
340
363
  break;
341
- case 'core':
342
- coreEvent(payload);
343
- break;
344
364
  default:
345
365
  break;
346
366
  }
@@ -395,7 +415,7 @@ const authEvent = payload => {
395
415
  return recordAuthEvent('auth_fail');
396
416
  case 'configured':
397
417
  authConfigured = true;
398
- if (analyticsConfigured) {
418
+ if (authConfigured && analyticsConfigured) {
399
419
  sendEvents();
400
420
  }
401
421
  break;
@@ -409,21 +429,7 @@ const analyticsEvent = payload => {
409
429
  switch (event) {
410
430
  case 'pinpointProvider_configured':
411
431
  analyticsConfigured = true;
412
- if (authConfigured || credentialsConfigured) {
413
- sendEvents();
414
- }
415
- break;
416
- }
417
- };
418
-
419
- const coreEvent = payload => {
420
- const { event } = payload;
421
- if (!event) return;
422
-
423
- switch (event) {
424
- case 'credentials_configured':
425
- credentialsConfigured = true;
426
- if (analyticsConfigured) {
432
+ if (authConfigured && analyticsConfigured) {
427
433
  sendEvents();
428
434
  }
429
435
  break;
@@ -1,5 +1,15 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
 
4
14
  import { ConsoleLogger as Logger } from '@aws-amplify/core';
5
15
  import { AWSKinesisProvider } from './AWSKinesisProvider';
@@ -101,3 +111,8 @@ export class AWSKinesisFirehoseProvider extends AWSKinesisProvider {
101
111
  return true;
102
112
  }
103
113
  }
114
+
115
+ /**
116
+ * @deprecated use named import
117
+ */
118
+ export default AWSKinesisFirehoseProvider;
@@ -1,5 +1,15 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
 
4
14
  import {
5
15
  ConsoleLogger as Logger,
@@ -241,3 +251,8 @@ export class AWSKinesisProvider implements AnalyticsProvider {
241
251
  });
242
252
  }
243
253
  }
254
+
255
+ /**
256
+ * @deprecated use named import
257
+ */
258
+ export default AWSKinesisProvider;
@@ -1,15 +1,24 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
 
4
14
  import {
5
15
  ConsoleLogger as Logger,
6
16
  ClientDevice,
7
17
  Credentials,
8
18
  Signer,
19
+ JS,
9
20
  Hub,
10
21
  getAmplifyUserAgent,
11
- transferKeyToLowerCase,
12
- transferKeyToUpperCase,
13
22
  } from '@aws-amplify/core';
14
23
  import {
15
24
  EventsBatch,
@@ -18,7 +27,7 @@ import {
18
27
  PutEventsCommandInput,
19
28
  UpdateEndpointCommand,
20
29
  } from '@aws-sdk/client-pinpoint';
21
- import { Cache } from '@aws-amplify/cache';
30
+ import Cache from '@aws-amplify/cache';
22
31
 
23
32
  import {
24
33
  AnalyticsProvider,
@@ -31,11 +40,10 @@ import {
31
40
  import { v1 as uuid } from 'uuid';
32
41
  import EventsBuffer from './EventBuffer';
33
42
 
34
- const AMPLIFY_SYMBOL = (
35
- typeof Symbol !== 'undefined' && typeof Symbol.for === 'function'
36
- ? Symbol.for('amplify_default')
37
- : '@@amplify_default'
38
- ) as Symbol;
43
+ const AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' &&
44
+ typeof Symbol.for === 'function'
45
+ ? Symbol.for('amplify_default')
46
+ : '@@amplify_default') as Symbol;
39
47
 
40
48
  const dispatchAnalyticsEvent = (event, data) => {
41
49
  Hub.dispatch('analytics', { event, data }, 'Analytics', AMPLIFY_SYMBOL);
@@ -387,7 +395,7 @@ export class AWSPinpointProvider implements AnalyticsProvider {
387
395
 
388
396
  const request = this._endpointRequest(
389
397
  config,
390
- transferKeyToLowerCase(
398
+ JS.transferKeyToLowerCase(
391
399
  event,
392
400
  [],
393
401
  ['attributes', 'userAttributes', 'Attributes', 'UserAttributes']
@@ -698,7 +706,7 @@ export class AWSPinpointProvider implements AnalyticsProvider {
698
706
  immediate,
699
707
  ...ret
700
708
  } = tmp;
701
- return transferKeyToUpperCase(
709
+ return JS.transferKeyToUpperCase(
702
710
  ret,
703
711
  [],
704
712
  ['metrics', 'userAttributes', 'attributes']
@@ -727,3 +735,8 @@ export class AWSPinpointProvider implements AnalyticsProvider {
727
735
  }
728
736
  }
729
737
  }
738
+
739
+ /**
740
+ * @deprecated use named import
741
+ */
742
+ export default AWSPinpointProvider;
@@ -1,5 +1,15 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
  import { ICredentials } from '@aws-amplify/core';
4
14
 
5
15
  interface BasePayload {
@@ -1,5 +1,15 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
  import { RequestParams } from './DataType';
4
14
 
5
15
  enum HTML5_MEDIA_EVENT {
@@ -1,11 +1,22 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
  import { SessionInfo } from './DataType';
4
14
  import isEmpty from 'lodash/isEmpty';
5
15
  import isEqual from 'lodash/isEqual';
6
16
  import { v1 as uuid } from 'uuid';
7
- import { ConsoleLogger as Logger, browserOrNode } from '@aws-amplify/core';
8
- import { Cache } from '@aws-amplify/cache';
17
+ import { ConsoleLogger as Logger, JS } from '@aws-amplify/core';
18
+
19
+ import Cache from '@aws-amplify/cache';
9
20
 
10
21
  const PERSONALIZE_CACHE = '_awsct';
11
22
  const PERSONALIZE_CACHE_USERID = '_awsct_uid';
@@ -23,7 +34,7 @@ export class SessionInfoManager {
23
34
  private _timerKey;
24
35
 
25
36
  constructor(prefixKey = '') {
26
- this._isBrowser = browserOrNode().isBrowser;
37
+ this._isBrowser = JS.browserOrNode().isBrowser;
27
38
  this._timerKey = uuid().substr(0, 15);
28
39
  this._refreshTimer();
29
40
  }
@@ -1,11 +1,15 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
3
- export {
4
- EventData,
5
- RecordEventListPayload,
6
- RecordEventPayload,
7
- RequestParams,
8
- SessionInfo,
9
- } from './DataType';
10
- export { SessionInfoManager } from './SessionInfoManager';
11
- export { MediaAutoTrack } from './MediaAutoTrack';
1
+ /*
2
+ * Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
13
+ export * from './DataType';
14
+ export * from './SessionInfoManager';
15
+ export * from './MediaAutoTrack';
@@ -1,11 +1,21 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
 
4
14
  import {
5
15
  ConsoleLogger as Logger,
6
16
  Credentials,
17
+ JS,
7
18
  getAmplifyUserAgent,
8
- browserOrNode,
9
19
  } from '@aws-amplify/core';
10
20
  import {
11
21
  PersonalizeEventsClient,
@@ -57,7 +67,7 @@ export class AmazonPersonalizeProvider implements AnalyticsProvider {
57
67
  this._config.trackingId
58
68
  );
59
69
  }
60
- this._isBrowser = browserOrNode().isBrowser;
70
+ this._isBrowser = JS.browserOrNode().isBrowser;
61
71
 
62
72
  // flush event buffer
63
73
  this._setupTimer();
@@ -250,8 +260,10 @@ export class AmazonPersonalizeProvider implements AnalyticsProvider {
250
260
  const events: RecordEventPayload[] = [];
251
261
  for (let i = 0; i < groupLen; i += 1) {
252
262
  const params: RequestParams = group.shift();
253
- const eventPayload: RecordEventPayload =
254
- this._generateSingleRecordPayload(params, sessionInfo);
263
+ const eventPayload: RecordEventPayload = this._generateSingleRecordPayload(
264
+ params,
265
+ sessionInfo
266
+ );
255
267
  events.push(eventPayload);
256
268
  }
257
269
  const payload = <PutEventsCommandInput>{};
@@ -395,3 +407,8 @@ export class AmazonPersonalizeProvider implements AnalyticsProvider {
395
407
  });
396
408
  }
397
409
  }
410
+
411
+ /**
412
+ * @deprecated use named import
413
+ */
414
+ export default AmazonPersonalizeProvider;
package/src/index.ts CHANGED
@@ -1,11 +1,22 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
 
4
- export { Analytics } from './Analytics';
5
- export { AnalyticsProvider } from './types';
6
- export {
7
- AWSPinpointProvider,
8
- AWSKinesisProvider,
9
- AWSKinesisFirehoseProvider,
10
- AmazonPersonalizeProvider,
11
- } from './Providers';
14
+ import { Analytics } from './Analytics';
15
+ import { AnalyticsProvider } from './types';
16
+
17
+ /**
18
+ * @deprecated use named import
19
+ */
20
+ export default Analytics;
21
+ export { AnalyticsProvider, Analytics };
22
+ export * from './Providers';
@@ -1,9 +1,19 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
 
4
14
  import { delegate } from '../vendor/dom-utils';
5
15
  import { EventTrackOpts } from '../types';
6
- import { ConsoleLogger as Logger, browserOrNode } from '@aws-amplify/core';
16
+ import { ConsoleLogger as Logger, JS } from '@aws-amplify/core';
7
17
 
8
18
  const logger = new Logger('EventTracker');
9
19
 
@@ -20,7 +30,7 @@ export class EventTracker {
20
30
  private _delegates;
21
31
 
22
32
  constructor(tracker, opts) {
23
- if (!browserOrNode().isBrowser || !window.addEventListener) {
33
+ if (!JS.browserOrNode().isBrowser || !window.addEventListener) {
24
34
  logger.debug('not in the supported web environment');
25
35
  return;
26
36
  }
@@ -113,3 +123,8 @@ export class EventTracker {
113
123
  });
114
124
  }
115
125
  }
126
+
127
+ /**
128
+ * @deprecated use named import
129
+ */
130
+ export default EventTracker;
@@ -1,15 +1,25 @@
1
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- // SPDX-License-Identifier: Apache-2.0
1
+ /*
2
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
3
13
 
4
14
  import { pageViewTrackOpts } from '../types';
5
15
  import { MethodEmbed } from '../utils/MethodEmbed';
6
- import { ConsoleLogger as Logger, browserOrNode } from '@aws-amplify/core';
16
+ import { ConsoleLogger as Logger, JS } from '@aws-amplify/core';
7
17
 
8
18
  const logger = new Logger('PageViewTracker');
9
19
  const PREV_URL_KEY = 'aws-amplify-analytics-prevUrl';
10
20
 
11
21
  const getUrl = () => {
12
- if (!browserOrNode().isBrowser) return '';
22
+ if (!JS.browserOrNode().isBrowser) return '';
13
23
  else return window.location.origin + window.location.pathname;
14
24
  };
15
25
 
@@ -61,7 +71,7 @@ export class PageViewTracker {
61
71
 
62
72
  private async _pageViewTrackDefault() {
63
73
  if (
64
- !browserOrNode().isBrowser ||
74
+ !JS.browserOrNode().isBrowser ||
65
75
  !window.addEventListener ||
66
76
  !window.sessionStorage
67
77
  ) {
@@ -96,7 +106,7 @@ export class PageViewTracker {
96
106
 
97
107
  private async _trackFunc() {
98
108
  if (
99
- !browserOrNode().isBrowser ||
109
+ !JS.browserOrNode().isBrowser ||
100
110
  !window.addEventListener ||
101
111
  !history.pushState ||
102
112
  !window.sessionStorage
@@ -133,7 +143,7 @@ export class PageViewTracker {
133
143
 
134
144
  private _pageViewTrackSPA() {
135
145
  if (
136
- !browserOrNode().isBrowser ||
146
+ !JS.browserOrNode().isBrowser ||
137
147
  !window.addEventListener ||
138
148
  !history.pushState
139
149
  ) {
@@ -155,3 +165,8 @@ export class PageViewTracker {
155
165
  }
156
166
  }
157
167
  }
168
+
169
+ /**
170
+ * @deprecated use named import
171
+ */
172
+ export default PageViewTracker;