@aws-amplify/analytics 7.0.1-console-preview.67f944e.0 → 7.0.1-console-preview.0bbe168.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 (73) hide show
  1. package/kinesis-firehose/package.json +7 -0
  2. package/lib/errors/validation.d.ts +0 -1
  3. package/lib/errors/validation.js +0 -4
  4. package/lib/providers/kinesis-firehose/apis/index.d.ts +1 -0
  5. package/lib/providers/kinesis-firehose/apis/index.js +7 -0
  6. package/lib/providers/kinesis-firehose/apis/record.d.ts +2 -0
  7. package/lib/providers/kinesis-firehose/apis/record.js +9 -0
  8. package/lib/providers/kinesis-firehose/index.d.ts +1 -0
  9. package/lib/providers/kinesis-firehose/index.js +6 -0
  10. package/lib/providers/kinesis-firehose/types/index.d.ts +1 -0
  11. package/lib/providers/kinesis-firehose/types/index.js +6 -0
  12. package/lib/providers/kinesis-firehose/types/inputs.d.ts +1 -0
  13. package/lib/providers/kinesis-firehose/types/inputs.js +4 -0
  14. package/lib/providers/pinpoint/apis/identifyUser.d.ts +7 -5
  15. package/lib/providers/pinpoint/apis/identifyUser.js +14 -9
  16. package/lib/providers/pinpoint/apis/record.d.ts +8 -14
  17. package/lib/providers/pinpoint/apis/record.js +11 -19
  18. package/lib/providers/pinpoint/types/index.d.ts +1 -0
  19. package/lib/providers/pinpoint/types/inputs.d.ts +4 -17
  20. package/lib/providers/pinpoint/types/options.d.ts +5 -0
  21. package/lib/providers/pinpoint/types/options.js +4 -0
  22. package/lib/tsconfig.tsbuildinfo +1 -1
  23. package/lib/types/analytics.d.ts +1 -1
  24. package/lib/types/index.d.ts +3 -1
  25. package/lib/types/index.js +0 -2
  26. package/lib/types/inputs.d.ts +21 -0
  27. package/lib/types/inputs.js +4 -0
  28. package/lib/types/options.d.ts +4 -0
  29. package/lib/types/options.js +4 -0
  30. package/lib-esm/errors/validation.d.ts +0 -1
  31. package/lib-esm/errors/validation.js +0 -4
  32. package/lib-esm/providers/kinesis-firehose/apis/index.d.ts +1 -0
  33. package/lib-esm/providers/kinesis-firehose/apis/index.js +3 -0
  34. package/lib-esm/providers/kinesis-firehose/apis/record.d.ts +2 -0
  35. package/lib-esm/providers/kinesis-firehose/apis/record.js +5 -0
  36. package/lib-esm/providers/kinesis-firehose/index.d.ts +1 -0
  37. package/lib-esm/providers/kinesis-firehose/index.js +3 -0
  38. package/lib-esm/providers/kinesis-firehose/types/index.d.ts +1 -0
  39. package/lib-esm/providers/kinesis-firehose/types/index.js +3 -0
  40. package/lib-esm/providers/kinesis-firehose/types/inputs.d.ts +1 -0
  41. package/lib-esm/providers/kinesis-firehose/types/inputs.js +3 -0
  42. package/lib-esm/providers/pinpoint/apis/identifyUser.d.ts +7 -5
  43. package/lib-esm/providers/pinpoint/apis/identifyUser.js +14 -9
  44. package/lib-esm/providers/pinpoint/apis/record.d.ts +8 -14
  45. package/lib-esm/providers/pinpoint/apis/record.js +11 -19
  46. package/lib-esm/providers/pinpoint/types/index.d.ts +1 -0
  47. package/lib-esm/providers/pinpoint/types/inputs.d.ts +4 -17
  48. package/lib-esm/providers/pinpoint/types/options.d.ts +5 -0
  49. package/lib-esm/providers/pinpoint/types/options.js +3 -0
  50. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  51. package/lib-esm/types/analytics.d.ts +1 -1
  52. package/lib-esm/types/index.d.ts +3 -1
  53. package/lib-esm/types/index.js +1 -1
  54. package/lib-esm/types/inputs.d.ts +21 -0
  55. package/lib-esm/types/inputs.js +3 -0
  56. package/lib-esm/types/options.d.ts +4 -0
  57. package/lib-esm/types/options.js +3 -0
  58. package/package.json +15 -5
  59. package/src/errors/validation.ts +0 -4
  60. package/src/providers/kinesis-firehose/apis/index.ts +4 -0
  61. package/src/providers/kinesis-firehose/apis/record.ts +8 -0
  62. package/src/providers/kinesis-firehose/index.ts +4 -0
  63. package/src/providers/kinesis-firehose/types/index.ts +4 -0
  64. package/src/providers/kinesis-firehose/types/inputs.ts +4 -0
  65. package/src/providers/pinpoint/apis/identifyUser.ts +13 -8
  66. package/src/providers/pinpoint/apis/record.ts +13 -20
  67. package/src/providers/pinpoint/types/index.ts +1 -0
  68. package/src/providers/pinpoint/types/inputs.ts +4 -18
  69. package/src/providers/pinpoint/types/options.ts +12 -0
  70. package/src/types/analytics.ts +1 -1
  71. package/src/types/index.ts +15 -1
  72. package/src/types/inputs.ts +29 -0
  73. package/src/types/options.ts +7 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/analytics",
3
- "version": "7.0.1-console-preview.67f944e.0+67f944e",
3
+ "version": "7.0.1-console-preview.0bbe168.0+0bbe168",
4
4
  "description": "Analytics category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -35,6 +35,9 @@
35
35
  ],
36
36
  "kinesis": [
37
37
  "./lib-esm/providers/kinesis/index.d.ts"
38
+ ],
39
+ "kinesis-firehose": [
40
+ "./lib-esm/providers/kinesis-firehose/index.d.ts"
38
41
  ]
39
42
  }
40
43
  },
@@ -54,6 +57,11 @@
54
57
  "import": "./lib-esm/providers/kinesis/index.js",
55
58
  "require": "./lib/providers/kinesis/index.js"
56
59
  },
60
+ "./kinesis-firehose": {
61
+ "types": "./lib-esm/providers/kinesis-firehose/index.d.ts",
62
+ "import": "./lib-esm/providers/kinesis-firehose/index.js",
63
+ "require": "./lib/providers/kinesis-firehose/index.js"
64
+ },
57
65
  "./package.json": "./package.json"
58
66
  },
59
67
  "repository": {
@@ -71,17 +79,19 @@
71
79
  "lib-esm",
72
80
  "src",
73
81
  "pinpoint",
74
- "kinesis"
82
+ "kinesis",
83
+ "kinesis-firehose"
75
84
  ],
76
85
  "dependencies": {
77
86
  "tslib": "^2.5.0",
78
87
  "uuid": "^9.0.0"
79
88
  },
80
89
  "peerDependencies": {
81
- "@aws-amplify/core": "6.0.1-console-preview.67f944e.0+67f944e"
90
+ "@aws-amplify/core": "6.0.1-console-preview.0bbe168.0+0bbe168"
82
91
  },
83
92
  "devDependencies": {
84
- "@aws-amplify/core": "6.0.1-console-preview.67f944e.0+67f944e",
93
+ "@aws-amplify/core": "6.0.1-console-preview.0bbe168.0+0bbe168",
94
+ "@aws-sdk/client-firehose": "3.398.0",
85
95
  "@aws-sdk/client-kinesis": "3.398.0",
86
96
  "@aws-sdk/types": "3.398.0",
87
97
  "@types/uuid": "^9.0.0",
@@ -131,5 +141,5 @@
131
141
  "<rootDir>/src/setupTests.ts"
132
142
  ]
133
143
  },
134
- "gitHead": "67f944e08acb70d5edf6743f5d23a048db1a57ae"
144
+ "gitHead": "0bbe168c66929877174b331c71f7666bb16529d6"
135
145
  }
@@ -6,7 +6,6 @@ import { AmplifyErrorMap } from '@aws-amplify/core/internals/utils';
6
6
  export enum AnalyticsValidationErrorCode {
7
7
  NoAppId = 'NoAppId',
8
8
  NoCredentials = 'NoCredentials',
9
- NoEvent = 'NoEvent',
10
9
  NoEventName = 'NoEventName',
11
10
  NoRegion = 'NoRegion',
12
11
  }
@@ -19,9 +18,6 @@ export const validationErrorMap: AmplifyErrorMap<AnalyticsValidationErrorCode> =
19
18
  [AnalyticsValidationErrorCode.NoCredentials]: {
20
19
  message: 'Credentials should not be empty.',
21
20
  },
22
- [AnalyticsValidationErrorCode.NoEvent]: {
23
- message: 'An event is required to record.',
24
- },
25
21
  [AnalyticsValidationErrorCode.NoEventName]: {
26
22
  message: 'Events must specify a name.',
27
23
  },
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { record } from './record';
@@ -0,0 +1,8 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { RecordInput } from '../types';
5
+
6
+ export const record = (input: RecordInput): void => {
7
+ throw new Error('Not Yet Implemented');
8
+ };
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './apis';
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './inputs';
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export type RecordInput = {};
@@ -17,32 +17,34 @@ import { resolveConfig, resolveCredentials } from '../utils';
17
17
  * API.
18
18
  *
19
19
  * @throws service: {@link UpdateEndpointException} - Thrown when the underlying Pinpoint service returns an error.
20
- * @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
20
+ * @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
21
21
  * configuration is incorrect.
22
- *
22
+ *
23
23
  * @returns A promise that will resolve when the operation is complete.
24
- *
24
+ *
25
25
  * @example
26
26
  * ```ts
27
27
  * // Identify a user with Pinpoint
28
28
  * await identifyUser({
29
29
  * userId,
30
30
  * userProfile: {
31
- * attributes: {
32
- * email: [userEmail],
31
+ * email: [userEmail]
32
+ * customProperties: {
33
+ * phoneNumber: ['555-555-5555'],
33
34
  * },
34
35
  * }
35
36
  * });
36
37
  * ```
37
- *
38
+ *
38
39
  * @example
39
40
  * ```ts
40
41
  * // Identify a user with Pinpoint with some additional demographics
41
42
  * await identifyUser({
42
43
  * userId,
43
44
  * userProfile: {
44
- * attributes: {
45
- * email: [userEmail],
45
+ * email: [userEmail]
46
+ * customProperties: {
47
+ * phoneNumber: ['555-555-5555'],
46
48
  * },
47
49
  * demographic: {
48
50
  * platform: 'ios',
@@ -54,15 +56,18 @@ import { resolveConfig, resolveCredentials } from '../utils';
54
56
  export const identifyUser = async ({
55
57
  userId,
56
58
  userProfile,
59
+ options,
57
60
  }: IdentifyUserInput): Promise<void> => {
58
61
  const { credentials, identityId } = await resolveCredentials();
59
62
  const { appId, region } = resolveConfig();
63
+ const { userAttributes } = options?.serviceOptions ?? {};
60
64
  updateEndpoint({
61
65
  appId,
62
66
  category: 'Analytics',
63
67
  credentials,
64
68
  identityId,
65
69
  region,
70
+ userAttributes,
66
71
  userId,
67
72
  userProfile,
68
73
  userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.UpdateEndpoint),
@@ -21,40 +21,33 @@ const logger = new Logger('Analytics');
21
21
  *
22
22
  * @param {RecordInput} params The input object used to construct the request.
23
23
  *
24
- * @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
24
+ * @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
25
25
  * configuration is incorrect.
26
- *
26
+ *
27
27
  * @example
28
28
  * ```ts
29
29
  * // Send an event to Pinpoint
30
- * record({
31
- * event: {
32
- * name: eventName,
33
- * }
34
- * })
30
+ * record({ name: eventName })
35
31
  * ```
36
- *
32
+ *
37
33
  * @example
38
34
  * ```ts
39
35
  * // Send an event to Pinpoint with metrics & custom attributes
40
36
  * record({
41
- * event: {
42
- * name: eventName,
43
- * attributes: {
44
- * 'my-attribute': attributeValue
45
- * },
46
- * metrics: {
47
- * 'my-metric': metricValue
48
- * }
37
+ * name: eventName,
38
+ * attributes: {
39
+ * 'my-attribute': attributeValue
40
+ * },
41
+ * metrics: {
42
+ * 'my-metric': metricValue
49
43
  * }
50
44
  * })
51
45
  * ```
52
46
  */
53
- export const record = ({ event }: RecordInput): void => {
47
+ export const record = (input: RecordInput): void => {
54
48
  const { appId, region } = resolveConfig();
55
49
 
56
- assertValidationError(!!event, AnalyticsValidationErrorCode.NoEvent);
57
- assertValidationError(!!event.name, AnalyticsValidationErrorCode.NoEventName);
50
+ assertValidationError(!!input.name, AnalyticsValidationErrorCode.NoEventName);
58
51
 
59
52
  resolveCredentials()
60
53
  .then(({ credentials, identityId }) => {
@@ -62,7 +55,7 @@ export const record = ({ event }: RecordInput): void => {
62
55
  appId,
63
56
  category: 'Analytics',
64
57
  credentials,
65
- event,
58
+ event: input,
66
59
  identityId,
67
60
  region,
68
61
  userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.Record),
@@ -3,3 +3,4 @@
3
3
 
4
4
  export { UpdateEndpointException } from './errors';
5
5
  export { RecordInput, IdentifyUserInput } from './inputs';
6
+ export { IdentifyUserOptions } from './options';
@@ -1,30 +1,16 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { UserProfile } from '@aws-amplify/core';
5
4
  import { PinpointAnalyticsEvent } from '@aws-amplify/core/internals/providers/pinpoint';
5
+ import { IdentifyUserOptions } from '.';
6
+ import { AnalyticsIdentifyUserInput } from '../../../types';
6
7
 
7
8
  /**
8
9
  * Input type for Pinpoint record API.
9
10
  */
10
- export type RecordInput = {
11
- /**
12
- * An event to send to the default Analytics provider.
13
- */
14
- event: PinpointAnalyticsEvent;
15
- };
11
+ export type RecordInput = PinpointAnalyticsEvent;
16
12
 
17
13
  /**
18
14
  * Input type for Pinpoint identifyUser API.
19
15
  */
20
- export type IdentifyUserInput = {
21
- /**
22
- * A User ID associated to the current device.
23
- */
24
- userId: string;
25
-
26
- /**
27
- * Additional information about the user and their device.
28
- */
29
- userProfile: UserProfile;
30
- };
16
+ export type IdentifyUserInput = AnalyticsIdentifyUserInput<IdentifyUserOptions>;
@@ -0,0 +1,12 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { PinpointServiceOptions } from '@aws-amplify/core/internals/providers/pinpoint';
5
+
6
+ /**
7
+ * Options specific to Pinpoint identityUser.
8
+ */
9
+ export type IdentifyUserOptions = Pick<
10
+ PinpointServiceOptions,
11
+ 'userAttributes'
12
+ >;
@@ -13,7 +13,7 @@ export interface EventMetrics {
13
13
  [key: string]: number;
14
14
  }
15
15
 
16
- export interface pageViewTrackOpts {
16
+ export interface PageViewTrackOpts {
17
17
  enable: boolean;
18
18
  type?: string;
19
19
  eventName?: string;
@@ -1,4 +1,18 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- export * from './analytics';
4
+ export {
5
+ AutoTrackAttributes,
6
+ AutoTrackEventOpts,
7
+ AutoTrackPageViewOpts,
8
+ AutoTrackSessionOpts,
9
+ EventAttributes,
10
+ EventMetrics,
11
+ EventTrackOpts,
12
+ PageViewTrackOpts,
13
+ SessionTrackOpts,
14
+ } from './analytics';
15
+
16
+ export { AnalyticsServiceOptions } from './options';
17
+
18
+ export { AnalyticsIdentifyUserInput } from './inputs';
@@ -0,0 +1,29 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { UserProfile } from '@aws-amplify/core';
5
+ import { AnalyticsServiceOptions } from '.';
6
+
7
+ /**
8
+ * Input type for `identifyUser`.
9
+ */
10
+ export type AnalyticsIdentifyUserInput<
11
+ ServiceOptions extends AnalyticsServiceOptions = AnalyticsServiceOptions
12
+ > = {
13
+ /**
14
+ * A User ID associated to the current device.
15
+ */
16
+ userId: string;
17
+
18
+ /**
19
+ * Additional information about the user and their device.
20
+ */
21
+ userProfile: UserProfile;
22
+
23
+ /**
24
+ * Options to be passed to the API.
25
+ */
26
+ options?: {
27
+ serviceOptions?: ServiceOptions;
28
+ };
29
+ };
@@ -0,0 +1,7 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Base type for service options.
6
+ */
7
+ export type AnalyticsServiceOptions = any;