@adzenai/core 0.0.1 → 1.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 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/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
1
  interface AdzenPlacement {
2
2
  ad_id: string;
3
- campaign_id: string;
4
3
  advertiser_name: string;
5
4
  advertiser_image_url?: string;
6
5
  headline: string;
@@ -9,17 +8,28 @@ interface AdzenPlacement {
9
8
  destination_url: string;
10
9
  creative_url?: string;
11
10
  adUnitPosition: string;
12
- tracking: TrackingInfo;
11
+ render_impression_url: string | null;
12
+ view_impression_url: string | null;
13
13
  }
14
- interface TrackingInfo {
15
- render_url: string;
16
- view_url: string;
17
- click_slug: string;
18
- }
19
- interface AdzenDecision {
20
- decision: "serve" | "no_match";
21
- ad?: AdzenPlacement;
22
- reason?: string;
14
+ interface ProcessResponseAd {
15
+ ad_id: number | string;
16
+ title: string;
17
+ cta: string;
18
+ click_through_url: string;
19
+ advertiser_name: string;
20
+ sponsor_logo_url: string;
21
+ creative_url: string | null;
22
+ description: string;
23
+ pricing_model: string;
24
+ relevancy_score: number;
25
+ placement: string;
26
+ pixel_trackers: string[];
27
+ render_impression_url: string | null;
28
+ view_impression_url: string | null;
29
+ }
30
+ interface ProcessResponse {
31
+ message_id: string;
32
+ ads: ProcessResponseAd[];
23
33
  }
24
34
  type AdzenEnv = "prod" | "stg" | "dev";
25
35
  type AdzenFormat = "banner" | "native" | "sticky" | "in-feed";
@@ -182,4 +192,4 @@ interface ViewabilityOptions {
182
192
  }
183
193
  declare function observeViewability(options: ViewabilityOptions): () => void;
184
194
 
185
- export { type AbContext, type AdzenApi, type AdzenBaseConfig, type AdzenConsent, type AdzenDecision, type AdzenDefaults, type AdzenEnv, type AdzenError, type AdzenFormat, type AdzenPlacement, type AdzenQueueItem, type AdzenStaticConfig, type BannerCreative, type Beacons, type Creative, type Decision, type DecisionRequest, type DecisionResponse, type NativeCreative, type PageContext, type ResolvedAdzenStaticConfig, type SlotPosition, type SlotSpec, type StickyCreative, type TrackingInfo, type UserContext, type ViewabilityOptions, type ViewportContext, ensureTid, observeViewability, readTid, registerErrorSink, reportError, safeRun, safeRunAsync, uuidv4 };
195
+ export { type AbContext, type AdzenApi, type AdzenBaseConfig, type AdzenConsent, type AdzenDefaults, type AdzenEnv, type AdzenError, type AdzenFormat, type AdzenPlacement, type AdzenQueueItem, type AdzenStaticConfig, type BannerCreative, type Beacons, type Creative, type Decision, type DecisionRequest, type DecisionResponse, type NativeCreative, type PageContext, type ProcessResponse, type ProcessResponseAd, type ResolvedAdzenStaticConfig, type SlotPosition, type SlotSpec, type StickyCreative, type UserContext, type ViewabilityOptions, type ViewportContext, ensureTid, observeViewability, readTid, registerErrorSink, reportError, safeRun, safeRunAsync, uuidv4 };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  interface AdzenPlacement {
2
2
  ad_id: string;
3
- campaign_id: string;
4
3
  advertiser_name: string;
5
4
  advertiser_image_url?: string;
6
5
  headline: string;
@@ -9,17 +8,28 @@ interface AdzenPlacement {
9
8
  destination_url: string;
10
9
  creative_url?: string;
11
10
  adUnitPosition: string;
12
- tracking: TrackingInfo;
11
+ render_impression_url: string | null;
12
+ view_impression_url: string | null;
13
13
  }
14
- interface TrackingInfo {
15
- render_url: string;
16
- view_url: string;
17
- click_slug: string;
18
- }
19
- interface AdzenDecision {
20
- decision: "serve" | "no_match";
21
- ad?: AdzenPlacement;
22
- reason?: string;
14
+ interface ProcessResponseAd {
15
+ ad_id: number | string;
16
+ title: string;
17
+ cta: string;
18
+ click_through_url: string;
19
+ advertiser_name: string;
20
+ sponsor_logo_url: string;
21
+ creative_url: string | null;
22
+ description: string;
23
+ pricing_model: string;
24
+ relevancy_score: number;
25
+ placement: string;
26
+ pixel_trackers: string[];
27
+ render_impression_url: string | null;
28
+ view_impression_url: string | null;
29
+ }
30
+ interface ProcessResponse {
31
+ message_id: string;
32
+ ads: ProcessResponseAd[];
23
33
  }
24
34
  type AdzenEnv = "prod" | "stg" | "dev";
25
35
  type AdzenFormat = "banner" | "native" | "sticky" | "in-feed";
@@ -182,4 +192,4 @@ interface ViewabilityOptions {
182
192
  }
183
193
  declare function observeViewability(options: ViewabilityOptions): () => void;
184
194
 
185
- export { type AbContext, type AdzenApi, type AdzenBaseConfig, type AdzenConsent, type AdzenDecision, type AdzenDefaults, type AdzenEnv, type AdzenError, type AdzenFormat, type AdzenPlacement, type AdzenQueueItem, type AdzenStaticConfig, type BannerCreative, type Beacons, type Creative, type Decision, type DecisionRequest, type DecisionResponse, type NativeCreative, type PageContext, type ResolvedAdzenStaticConfig, type SlotPosition, type SlotSpec, type StickyCreative, type TrackingInfo, type UserContext, type ViewabilityOptions, type ViewportContext, ensureTid, observeViewability, readTid, registerErrorSink, reportError, safeRun, safeRunAsync, uuidv4 };
195
+ export { type AbContext, type AdzenApi, type AdzenBaseConfig, type AdzenConsent, type AdzenDefaults, type AdzenEnv, type AdzenError, type AdzenFormat, type AdzenPlacement, type AdzenQueueItem, type AdzenStaticConfig, type BannerCreative, type Beacons, type Creative, type Decision, type DecisionRequest, type DecisionResponse, type NativeCreative, type PageContext, type ProcessResponse, type ProcessResponseAd, type ResolvedAdzenStaticConfig, type SlotPosition, type SlotSpec, type StickyCreative, type UserContext, type ViewabilityOptions, type ViewportContext, ensureTid, observeViewability, readTid, registerErrorSink, reportError, safeRun, safeRunAsync, uuidv4 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adzenai/core",
3
- "version": "0.0.1",
3
+ "version": "1.1.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": ["dist"],
25
+ "files": [
26
+ "dist"
27
+ ],
26
28
  "scripts": {
27
29
  "build": "tsup",
28
30
  "test": "vitest run",