@adzenai/core 0.0.1 → 1.0.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 +74 -0
- package/package.json +4 -2
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @adzenai/core
|
|
2
|
+
|
|
3
|
+
Shared types and utilities for the Adzen SDK. Used as a foundation by `@adzenai/ai`, `@adzenai/static`, and other channel packages.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @adzenai/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import {
|
|
15
|
+
type AdzenPlacement,
|
|
16
|
+
type AdzenDecision,
|
|
17
|
+
type TrackingInfo,
|
|
18
|
+
observeViewability,
|
|
19
|
+
registerErrorSink,
|
|
20
|
+
safeRun,
|
|
21
|
+
uuidv4,
|
|
22
|
+
ensureTid,
|
|
23
|
+
} from "@adzenai/core";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Exports
|
|
27
|
+
|
|
28
|
+
### Types
|
|
29
|
+
|
|
30
|
+
| Type | Description |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| `AdzenPlacement` | Ad placement data (headline, CTA, destination URL, creative, tracking URLs) |
|
|
33
|
+
| `AdzenDecision` | API response wrapper (`"serve"` or `"no_match"` with optional placement) |
|
|
34
|
+
| `TrackingInfo` | Render/view/click tracking URLs |
|
|
35
|
+
| `AdzenBaseConfig` | Shared config interface (`apiKey`, `endpointUrl`, `timeoutMs`) |
|
|
36
|
+
|
|
37
|
+
Static-channel types are also exported: `DecisionRequest`, `Decision`, `Creative`, `SlotSpec`, `BannerCreative`, `NativeCreative`, and more.
|
|
38
|
+
|
|
39
|
+
### Error Handling
|
|
40
|
+
|
|
41
|
+
| Export | Description |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `registerErrorSink(fn)` | Register a callback for all SDK errors |
|
|
44
|
+
| `reportError(error)` | Report an error to registered sinks |
|
|
45
|
+
| `safeRun(fn)` | Execute synchronous code with automatic error reporting |
|
|
46
|
+
| `safeRunAsync(fn)` | Execute async code with automatic error reporting |
|
|
47
|
+
|
|
48
|
+
### Session
|
|
49
|
+
|
|
50
|
+
| Export | Description |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `uuidv4()` | Generate a random UUID v4 |
|
|
53
|
+
| `readTid()` | Read the persistent tracking ID from localStorage |
|
|
54
|
+
| `ensureTid()` | Read or create a persistent tracking ID |
|
|
55
|
+
|
|
56
|
+
### Viewability
|
|
57
|
+
|
|
58
|
+
| Export | Description |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `observeViewability(options)` | Track element visibility using `IntersectionObserver` with a time threshold |
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { observeViewability } from "@adzenai/core";
|
|
64
|
+
|
|
65
|
+
const cleanup = observeViewability({
|
|
66
|
+
element: adCardRef.current,
|
|
67
|
+
thresholdMs: 1000,
|
|
68
|
+
onViewed: () => fireImpression(),
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adzenai/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Core types and utilities for the Adzen AI ad SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
"main": "./dist/index.cjs",
|
|
23
23
|
"module": "./dist/index.js",
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"files": [
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
26
28
|
"scripts": {
|
|
27
29
|
"build": "tsup",
|
|
28
30
|
"test": "vitest run",
|