@aws-amplify/analytics 7.0.1-console-preview.a1c533e.0 → 7.0.1-console-preview.f7f118b.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.
@@ -1,9 +1,4 @@
1
1
  export declare const resolveCredentials: () => Promise<{
2
- credentials: {
3
- accessKeyId: string;
4
- secretAccessKey: string;
5
- sessionToken?: string | undefined;
6
- expiration?: Date | undefined;
7
- };
2
+ credentials: import("@aws-amplify/core/lib-esm/libraryUtils").AWSCredentials;
8
3
  identityId: string | undefined;
9
4
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/analytics",
3
- "version": "7.0.1-console-preview.a1c533e.0+a1c533e",
3
+ "version": "7.0.1-console-preview.f7f118b.0+f7f118b",
4
4
  "description": "Analytics category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -96,16 +96,14 @@
96
96
  "@aws-sdk/client-kinesis": "3.398.0",
97
97
  "@aws-sdk/client-personalize-events": "3.398.0",
98
98
  "@smithy/util-utf8": "2.0.0",
99
- "tslib": "^2.5.0",
100
- "uuid": "^9.0.0"
99
+ "tslib": "^2.5.0"
101
100
  },
102
101
  "peerDependencies": {
103
- "@aws-amplify/core": "6.0.1-console-preview.a1c533e.0+a1c533e"
102
+ "@aws-amplify/core": "6.0.1-console-preview.f7f118b.0+f7f118b"
104
103
  },
105
104
  "devDependencies": {
106
- "@aws-amplify/core": "6.0.1-console-preview.a1c533e.0+a1c533e",
105
+ "@aws-amplify/core": "6.0.1-console-preview.f7f118b.0+f7f118b",
107
106
  "@aws-sdk/types": "3.398.0",
108
- "@types/uuid": "^9.0.0",
109
107
  "typescript": "5.0.2"
110
108
  },
111
109
  "jest": {
@@ -152,5 +150,5 @@
152
150
  "<rootDir>/src/setupTests.ts"
153
151
  ]
154
152
  },
155
- "gitHead": "a1c533eae82c5386864fb15fc101bb3cb9bd93ae"
153
+ "gitHead": "f7f118b047bb772ef12531eab78e059a6a1442f1"
156
154
  }
@@ -1,8 +1,8 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { AWSCredentials } from '@aws-amplify/core/internals/utils';
4
5
  import { EventBufferConfig } from '../../../utils';
5
- import { Credentials } from '@aws-sdk/types';
6
6
  import { KinesisShard } from '../../../types';
7
7
 
8
8
  export type KinesisBufferEvent = KinesisShard & {
@@ -13,7 +13,7 @@ export type KinesisBufferEvent = KinesisShard & {
13
13
 
14
14
  export type KinesisEventBufferConfig = EventBufferConfig & {
15
15
  region: string;
16
- credentials: Credentials;
16
+ credentials: AWSCredentials;
17
17
  identityId?: string;
18
18
  resendLimit?: number;
19
19
  userAgentValue?: string;
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { EventBufferConfig } from '../../../utils';
5
5
  import { KinesisStream } from '../../../types';
6
- import { Credentials } from '@aws-sdk/types';
6
+ import { AWSCredentials } from '@aws-amplify/core/internals/utils';
7
7
 
8
8
  export type KinesisFirehoseBufferEvent = KinesisStream & {
9
9
  event: Uint8Array;
@@ -13,7 +13,7 @@ export type KinesisFirehoseBufferEvent = KinesisStream & {
13
13
 
14
14
  export type KinesisFirehoseEventBufferConfig = EventBufferConfig & {
15
15
  region: string;
16
- credentials: Credentials;
16
+ credentials: AWSCredentials;
17
17
  identityId?: string;
18
18
  resendLimit?: number;
19
19
  userAgentValue?: string;
@@ -39,10 +39,10 @@ export const record = ({
39
39
  const { region, trackingId, bufferSize, flushSize, flushInterval } =
40
40
  resolveConfig();
41
41
  resolveCredentials()
42
- .then(({ credentials, identityId }) => {
42
+ .then(async ({ credentials, identityId }) => {
43
43
  const timestamp = Date.now();
44
44
  const { sessionId: cachedSessionId, userId: cachedUserId } =
45
- resolveCachedSession(trackingId);
45
+ await resolveCachedSession();
46
46
  if (eventType === IDENTIFY_EVENT_TYPE) {
47
47
  updateCachedSession(
48
48
  typeof properties.userId === 'string' ? properties.userId : '',
@@ -54,7 +54,7 @@ export const record = ({
54
54
  }
55
55
 
56
56
  const { sessionId: updatedSessionId, userId: updatedUserId } =
57
- resolveCachedSession(trackingId);
57
+ await resolveCachedSession();
58
58
 
59
59
  const eventBuffer = getEventBuffer({
60
60
  region,
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { PersonalizeEvent } from './';
5
5
  import { EventBufferConfig } from '../../../utils';
6
- import { Credentials } from '@aws-sdk/types';
6
+ import { AWSCredentials } from '@aws-amplify/core/internals/utils';
7
7
 
8
8
  export type PersonalizeBufferEvent = {
9
9
  trackingId: string;
@@ -15,7 +15,7 @@ export type PersonalizeBufferEvent = {
15
15
 
16
16
  export type PersonalizeBufferConfig = EventBufferConfig & {
17
17
  region: string;
18
- credentials: Credentials;
18
+ credentials: AWSCredentials;
19
19
  identityId?: string;
20
20
  userAgentValue?: string;
21
21
  };
@@ -2,8 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { Cache } from '@aws-amplify/core';
5
- import { isBrowser } from '@aws-amplify/core/internals/utils';
6
- import { v4 as uuid } from 'uuid';
5
+ import { isBrowser, amplifyUuid } from '@aws-amplify/core/internals/utils';
7
6
 
8
7
  const PERSONALIZE_CACHE_USERID = '_awsct_uid';
9
8
  const PERSONALIZE_CACHE_SESSIONID = '_awsct_sid';
@@ -27,14 +26,16 @@ const setCache = (key: string, value: unknown) => {
27
26
  });
28
27
  };
29
28
 
30
- export const resolveCachedSession = (trackingId: string) => {
31
- let sessionId: string | undefined = getCache(PERSONALIZE_CACHE_SESSIONID);
29
+ export const resolveCachedSession = async () => {
30
+ let sessionId: string | undefined = await getCache(
31
+ PERSONALIZE_CACHE_SESSIONID
32
+ );
32
33
  if (!sessionId) {
33
- sessionId = uuid();
34
+ sessionId = amplifyUuid();
34
35
  setCache(PERSONALIZE_CACHE_SESSIONID, sessionId);
35
36
  }
36
37
 
37
- const userId: string | undefined = getCache(PERSONALIZE_CACHE_USERID);
38
+ const userId: string | undefined = await getCache(PERSONALIZE_CACHE_USERID);
38
39
 
39
40
  return {
40
41
  sessionId,
@@ -58,7 +59,7 @@ export const updateCachedSession = (
58
59
  !!currentSessionId && !currentUserId && !!newUserId;
59
60
 
60
61
  if (isRequireNewSession) {
61
- const newSessionId = uuid();
62
+ const newSessionId = amplifyUuid();
62
63
  setCache(PERSONALIZE_CACHE_SESSIONID, newSessionId);
63
64
  setCache(PERSONALIZE_CACHE_USERID, newUserId);
64
65
  } else if (isRequireUpdateSession) {