@adland/react 0.2.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,7 +1,25 @@
1
1
  # @adland/react
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5cee97e: add different ad types
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 57d6e2e: test 1
14
+ - 12f47bb: test
15
+
3
16
  ## 0.2.0
4
17
 
5
18
  ### Minor Changes
6
19
 
20
+ - 23c1210: add network option in Ad component instead of endpoint
7
21
  - 654a33b: initial publish
22
+
23
+ ### Patch Changes
24
+
25
+ - 089d18b: adding github release to release flow
package/README.md CHANGED
@@ -19,11 +19,16 @@ import { Ad } from "@adland/react";
19
19
 
20
20
  function App() {
21
21
  return (
22
- <Ad owner="0x123..." adId="ad-1">
22
+ <Ad owner="0x123..." adId="ad-1" network="testnet">
23
23
  <img src="ad.jpg" alt="Advertisement" />
24
24
  </Ad>
25
25
  );
26
26
  }
27
+
28
+ // network defaults to "testnet" if omitted
29
+ <Ad owner="0x123..." adId="ad-1">
30
+ <img src="ad.jpg" alt="Advertisement" />
31
+ </Ad>
27
32
  ```
28
33
 
29
34
  ## Features
@@ -43,7 +48,7 @@ function App() {
43
48
  | `owner` | `string` | **required** | The owner/creator address of the ad |
44
49
  | `adId` | `string` | **required** | Unique identifier for the ad |
45
50
  | `children` | `ReactNode` | **required** | The content to display in the ad |
46
- | `trackEndpoint` | `string` | `"/api/analytics/track"` | Custom endpoint for tracking requests |
51
+ | `network` | `"testnet"` | `"testnet"` | Network to use for tracking requests. Currently only testnet is supported. Maps to `testnet.adland.space` |
47
52
 
48
53
  ## License
49
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adland/react",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,6 +1,12 @@
1
1
  import { useEffect, useRef, useCallback } from "react";
2
2
  import { sendTrackRequest } from "../utils/sdk";
3
3
 
4
+ /**
5
+ * Get the base URL for the network
6
+ * Currently only testnet is supported
7
+ */
8
+ const NETWORK_BASE_URL = "https://testnet.adland.space";
9
+
4
10
  export interface AdProps extends React.HTMLAttributes<HTMLDivElement> {
5
11
  /**
6
12
  * The owner/creator of the ad
@@ -15,9 +21,9 @@ export interface AdProps extends React.HTMLAttributes<HTMLDivElement> {
15
21
  */
16
22
  children: React.ReactNode;
17
23
  /**
18
- * Custom endpoint for tracking requests (default: "/api/analytics/track")
24
+ * Network to use for tracking requests (currently only "testnet" is supported)
19
25
  */
20
- trackEndpoint?: string;
26
+ network?: "testnet";
21
27
  }
22
28
 
23
29
  /**
@@ -26,7 +32,7 @@ export interface AdProps extends React.HTMLAttributes<HTMLDivElement> {
26
32
  *
27
33
  * @example
28
34
  * ```tsx
29
- * <Ad owner="0x123..." adId="ad-1">
35
+ * <Ad owner="0x123..." adId="ad-1" network="testnet">
30
36
  * <img src="ad-image.jpg" alt="Advertisement" />
31
37
  * </Ad>
32
38
  * ```
@@ -35,13 +41,15 @@ export function Ad({
35
41
  owner,
36
42
  adId,
37
43
  children,
38
- trackEndpoint = "/api/analytics/track",
44
+ network = "testnet",
39
45
  ...props
40
46
  }: AdProps) {
41
47
  const ref = useRef<HTMLDivElement>(null);
42
48
 
43
49
  const send = useCallback(
44
50
  (type: "view" | "click") => {
51
+ const trackEndpoint = `${NETWORK_BASE_URL}/api/analytics/track`;
52
+
45
53
  sendTrackRequest(trackEndpoint, {
46
54
  type,
47
55
  adId,
@@ -50,7 +58,7 @@ export function Ad({
50
58
  console.error(`[@adland/react] Failed to track ${type}:`, error);
51
59
  });
52
60
  },
53
- [adId, owner, trackEndpoint],
61
+ [adId, owner],
54
62
  );
55
63
 
56
64
  useEffect(() => {