@amplifyup/sdk 0.1.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.
- package/README.md +106 -0
- package/dist/AmplifyRenderer.d.mts +31 -0
- package/dist/AmplifyRenderer.d.ts +31 -0
- package/dist/AmplifyRenderer.js +1708 -0
- package/dist/AmplifyRenderer.js.map +1 -0
- package/dist/AmplifyRenderer.mjs +1706 -0
- package/dist/AmplifyRenderer.mjs.map +1 -0
- package/dist/index.d.mts +309 -0
- package/dist/index.d.ts +309 -0
- package/dist/index.js +1445 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1415 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react.d.mts +89 -0
- package/dist/react.d.ts +89 -0
- package/dist/react.js +1966 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +1958 -0
- package/dist/react.mjs.map +1 -0
- package/dist/server.d.mts +21 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.js +1398 -0
- package/dist/server.js.map +1 -0
- package/dist/server.mjs +1396 -0
- package/dist/server.mjs.map +1 -0
- package/dist/types-B9nHG2Cl.d.mts +109 -0
- package/dist/types-B9nHG2Cl.d.ts +109 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# @amplifyup/sdk
|
|
2
|
+
|
|
3
|
+
AmplifyUp Tracking SDK - CDP-agnostic event tracking library.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This SDK provides event tracking that sends events directly to AWS API Gateway. All URLs are hardcoded in the SDK - no configuration needed except `trackingId`.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @amplifyup/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Basic Setup
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { init } from '@amplifyup/sdk';
|
|
21
|
+
|
|
22
|
+
// Initialize the SDK (URLs are hardcoded)
|
|
23
|
+
await init({
|
|
24
|
+
trackingId: 'your-tracking-id',
|
|
25
|
+
debug: true, // Optional, enables debug logging
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Track Events
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import {
|
|
33
|
+
page,
|
|
34
|
+
track,
|
|
35
|
+
trackClick,
|
|
36
|
+
trackFormSubmit,
|
|
37
|
+
trackContentView,
|
|
38
|
+
identify
|
|
39
|
+
} from '@amplifyup/sdk';
|
|
40
|
+
|
|
41
|
+
// Track page view
|
|
42
|
+
page('/home');
|
|
43
|
+
|
|
44
|
+
// Track custom event
|
|
45
|
+
track('Product Viewed', {
|
|
46
|
+
productId: '123',
|
|
47
|
+
productName: 'Widget',
|
|
48
|
+
price: 29.99
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Track button click
|
|
52
|
+
trackClick('add-to-cart', 'Add to Cart', {
|
|
53
|
+
productId: '123'
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Track form submission
|
|
57
|
+
trackFormSubmit('newsletter-signup', {
|
|
58
|
+
email: 'user@example.com'
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Track content view
|
|
62
|
+
trackContentView('product-123', 'product', {
|
|
63
|
+
productName: 'Widget',
|
|
64
|
+
category: 'Electronics'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Identify user
|
|
68
|
+
identify('user-123', {
|
|
69
|
+
email: 'user@example.com',
|
|
70
|
+
name: 'John Doe'
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Get Instance ID
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { getInstanceId } from '@amplifyup/sdk';
|
|
78
|
+
|
|
79
|
+
const instanceId = getInstanceId();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Architecture
|
|
83
|
+
|
|
84
|
+
The SDK sends events directly to AWS API Gateway:
|
|
85
|
+
- Events are sent to `/v1/track` or `/v1/page` endpoints
|
|
86
|
+
- All URLs are hardcoded in the SDK
|
|
87
|
+
- No write keys or configuration needed
|
|
88
|
+
- Personalization requests go to AWS Decision API Gateway
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Build
|
|
94
|
+
npm run build
|
|
95
|
+
|
|
96
|
+
# Watch mode
|
|
97
|
+
npm run dev
|
|
98
|
+
|
|
99
|
+
# Lint
|
|
100
|
+
npm run lint
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
MIT
|
|
106
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { P as PageConfig } from './types-B9nHG2Cl.mjs';
|
|
4
|
+
|
|
5
|
+
interface AmplifyRendererProps {
|
|
6
|
+
/**
|
|
7
|
+
* Component renderer function that maps componentId to React component
|
|
8
|
+
* This is site-specific and must be provided by the developer
|
|
9
|
+
*/
|
|
10
|
+
renderComponent: (componentId: string, props: Record<string, any>, slots?: Record<string, ReactNode>) => ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Optional page config for server-side rendering (SSR/SSG)
|
|
13
|
+
* If provided, the component will use this instead of fetching client-side
|
|
14
|
+
*/
|
|
15
|
+
pageConfig?: PageConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Optional loading component
|
|
18
|
+
*/
|
|
19
|
+
loadingComponent?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Optional error component
|
|
22
|
+
*/
|
|
23
|
+
errorComponent?: (error: string) => ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Optional empty state component (when no content is configured)
|
|
26
|
+
*/
|
|
27
|
+
emptyComponent?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
30
|
+
|
|
31
|
+
export { AmplifyRenderer };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { P as PageConfig } from './types-B9nHG2Cl.js';
|
|
4
|
+
|
|
5
|
+
interface AmplifyRendererProps {
|
|
6
|
+
/**
|
|
7
|
+
* Component renderer function that maps componentId to React component
|
|
8
|
+
* This is site-specific and must be provided by the developer
|
|
9
|
+
*/
|
|
10
|
+
renderComponent: (componentId: string, props: Record<string, any>, slots?: Record<string, ReactNode>) => ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Optional page config for server-side rendering (SSR/SSG)
|
|
13
|
+
* If provided, the component will use this instead of fetching client-side
|
|
14
|
+
*/
|
|
15
|
+
pageConfig?: PageConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Optional loading component
|
|
18
|
+
*/
|
|
19
|
+
loadingComponent?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Optional error component
|
|
22
|
+
*/
|
|
23
|
+
errorComponent?: (error: string) => ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Optional empty state component (when no content is configured)
|
|
26
|
+
*/
|
|
27
|
+
emptyComponent?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
30
|
+
|
|
31
|
+
export { AmplifyRenderer };
|