Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ai): adding UA string for AIConversation #5917

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/rich-bags-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
"@aws-amplify/ui-angular": patch
"@aws-amplify/ui-react-ai": patch
"@aws-amplify/ui-react-auth": patch
"@aws-amplify/ui-react-core-auth": patch
"@aws-amplify/ui-react-core-notifications": patch
"@aws-amplify/ui-react-core": patch
"@aws-amplify/ui-react-geo": patch
"@aws-amplify/ui-react-liveness": patch
"@aws-amplify/ui-react-native-auth": patch
"@aws-amplify/ui-react-native": patch
"@aws-amplify/ui-react-notifications": patch
"@aws-amplify/ui-react-storage": patch
"@aws-amplify/ui-react": patch
"@aws-amplify/ui": patch
"@aws-amplify/ui-vue": patch
"@aws-amplify/ui-angular": patch
---

chore(ai): adding UA string for AIConversation
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"@types/jest": "^29.5.5",
"@types/react-test-renderer": "^18.0.2",
"@vitejs/plugin-vue": "^2.3.4",
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"esbuild-register": "^3.5.0",
"eslint": "^8.44.0",
"fs-extra": "^11.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/projects/ui-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"peerDependencies": {
"@angular/core": ">= 14.0.0",
"@angular/common": ">= 14.0.0",
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"rxjs": "^6.5.3 || ^7.4.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"peerDependencies": {
"@aws-amplify/api-graphql": "^4.3.0",
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0",
"react-dom": "^16.14.0 || ^17.0 || ^18.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { PromptList } from './views/default/PromptList';
import { AutoHidablePromptControl } from './views/Controls';
import { ComponentClassName } from '@aws-amplify/ui';
import { AIConversationProvider } from './AIConversationProvider';
import { useSetUserAgent } from '@aws-amplify/ui-react-core';
import { VERSION } from '../../version';

interface AIConversationBaseProps
extends AIConversationProps,
Expand All @@ -32,6 +34,11 @@ function AIConversationBase({
displayText,
allowAttachments,
}: AIConversationBaseProps): JSX.Element {
useSetUserAgent({
componentName: 'AIConversation',
packageName: 'react-ai',
version: VERSION,
});
const icons = useIcons('aiConversation');
const defaultAvatars: Avatars = {
ai: {
Expand Down
1 change: 1 addition & 0 deletions packages/react-ai/src/version.ts
Copy link
Member

@ashika112 ashika112 Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this something new for UI repo? And needed to maintained manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anything new, a pattern we have for all UI packages where we use the UA string. We have a script to update the version number on build. This is so we don't have to import package.json

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VERSION = '0.3.2';
2 changes: 1 addition & 1 deletion packages/react-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"tslib": "^2.5.2"
},
"peerDependencies": {
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0",
"react-dom": "^16.14.0 || ^17.0 || ^18.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"peerDependencies": {
"@aws-amplify/core": "*",
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0"
},
"sideEffects": false
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core-notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@aws-amplify/ui-react-core": "3.0.28"
},
"peerDependencies": {
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0"
},
"sideEffects": false
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"xstate": "^4.33.6"
},
"peerDependencies": {
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0"
},
"sideEffects": false
Expand Down
2 changes: 1 addition & 1 deletion packages/react-geo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"peerDependencies": {
"@aws-amplify/geo": "^3.0.47",
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0",
"react-dom": "^16.14.0 || ^17.0 || ^18.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-liveness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"peerDependencies": {
"@aws-amplify/core": "*",
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0",
"react-dom": "^16.14.0 || ^17.0 || ^18.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"qrcode": "1.5.0"
},
"peerDependencies": {
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^18",
"react-native": "^0.70 || ^0.71 || ^0.72"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@aws-amplify/ui-react-core-notifications": "2.0.28"
},
"peerDependencies": {
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "*",
"react-native": "^0.70 || ^0.71 || ^0.72 || ^0.73 || ^0.74 || ^0.75",
"react-native-safe-area-context": "^4.2.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"tinycolor2": "1.4.2"
},
"peerDependencies": {
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0",
"react-dom": "^16.14.0 || ^17.0 || ^18.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"tslib": "^2.5.2"
},
"peerDependencies": {
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0",
"react-dom": "^16.14.0 || ^17.0 || ^18.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
},
"peerDependencies": {
"@aws-amplify/core": "*",
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"react": "^16.14.0 || ^17.0 || ^18.0",
"react-dom": "^16.14.0 || ^17.0 || ^18.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"peerDependencies": {
"@aws-amplify/core": "*",
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"xstate": "^4.33.6"
},
"peerDependenciesMeta": {
Expand Down
15 changes: 15 additions & 0 deletions packages/ui/src/utils/setUserAgent/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@ import {
InAppMessagingAction,
StorageAction,
Category,
AiAction,
AiUserAgentInput,
} from '@aws-amplify/core/internals/utils';

export const AI_INPUT_BASE: Omit<AiUserAgentInput, 'additionalDetails'> = {
category: Category.AI,
apis: [
AiAction.CreateConversation,
AiAction.DeleteConversation,
AiAction.ListConversations,
AiAction.UpdateConversation,
AiAction.OnMessage,
AiAction.SendMessage,
AiAction.Generation,
],
};

export const ACCOUNT_SETTINGS_INPUT_BASE: Omit<
AuthUserAgentInput,
'additionalDetails'
Expand Down
10 changes: 10 additions & 0 deletions packages/ui/src/utils/setUserAgent/setUserAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { setCustomUserAgent } from '@aws-amplify/core/internals/utils';

import {
ACCOUNT_SETTINGS_INPUT_BASE,
AI_INPUT_BASE,
AUTHENTICATOR_INPUT_BASE,
FILE_UPLOADER_BASE_INPUT,
IN_APP_MESSAGING_INPUT_BASE,
Expand All @@ -15,6 +16,7 @@ import { noop } from '../utils';
export type PackageName =
| 'angular'
| 'react'
| 'react-ai'
| 'react-auth'
| 'react-geo'
| 'react-liveness'
Expand All @@ -25,6 +27,7 @@ export type PackageName =
| 'vue';

export type ComponentName =
| 'AIConversation'
| 'Authenticator'
| 'ChangePassword'
| 'DeleteUser'
Expand Down Expand Up @@ -63,6 +66,13 @@ export const setUserAgent = ({
const packageData: [string, string] = [`ui-${packageName}`, version];

switch (componentName) {
case 'AIConversation': {
setCustomUserAgent({
...AI_INPUT_BASE,
additionalDetails: [[componentName], packageData],
});
break;
}
case 'Authenticator': {
setCustomUserAgent({
...AUTHENTICATOR_INPUT_BASE,
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"peerDependencies": {
"@aws-amplify/core": "*",
"aws-amplify": "^6.6.0",
"aws-amplify": "^6.6.5",
"vue": "^3.0"
}
}
1 change: 1 addition & 0 deletions scripts/generateVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const fs = require('fs-extra');
const packages = [
'packages/angular/projects/ui-angular',
'packages/react',
'packages/react-ai',
'packages/react-auth',
'packages/react-geo',
'packages/react-native',
Expand Down
Loading
Loading