@adtogether/web-sdk 0.1.21 → 0.1.23
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 +45 -42
- package/README.md +161 -154
- package/dist/{chunk-RW43ES42.mjs → chunk-IDISPRGA.mjs} +30 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +30 -1
- package/dist/index.mjs +1 -1
- package/dist/react/index.js +30 -1
- package/dist/react/index.mjs +1 -1
- package/errors.txt +2 -2
- package/package.json +59 -59
- package/src/core/AdTogether.ts +32 -0
- package/src/react/AdTogetherInterstitial.tsx +370 -370
- package/tsconfig.json +19 -19
package/package.json
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@adtogether/web-sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "The official AdTogether Web SDK — reciprocal ad exchange to increase conversions and grow your audience.",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/undecided2003/AdTogether.git",
|
|
8
|
-
"directory": "sdk/web-sdk"
|
|
9
|
-
},
|
|
10
|
-
"homepage": "https://adtogether.relaxsoftwareapps.com",
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/undecided2003/AdTogether/issues"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"ads",
|
|
16
|
-
"ad-exchange",
|
|
17
|
-
"monetization",
|
|
18
|
-
"advertising",
|
|
19
|
-
"react",
|
|
20
|
-
"reciprocal",
|
|
21
|
-
"conversions"
|
|
22
|
-
],
|
|
23
|
-
"publishConfig": {
|
|
24
|
-
"access": "public"
|
|
25
|
-
},
|
|
26
|
-
"main": "./dist/index.js",
|
|
27
|
-
"module": "./dist/index.mjs",
|
|
28
|
-
"types": "./dist/index.d.ts",
|
|
29
|
-
"exports": {
|
|
30
|
-
".": {
|
|
31
|
-
"types": "./dist/index.d.ts",
|
|
32
|
-
"require": "./dist/index.js",
|
|
33
|
-
"import": "./dist/index.mjs"
|
|
34
|
-
},
|
|
35
|
-
"./react": {
|
|
36
|
-
"types": "./dist/react/index.d.ts",
|
|
37
|
-
"require": "./dist/react/index.js",
|
|
38
|
-
"import": "./dist/react/index.mjs"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "tsup",
|
|
43
|
-
"dev": "tsup --watch"
|
|
44
|
-
},
|
|
45
|
-
"author": "AdTogether Team",
|
|
46
|
-
"license": "MIT",
|
|
47
|
-
"type": "commonjs",
|
|
48
|
-
"peerDependencies": {
|
|
49
|
-
"react": "^19.2.4",
|
|
50
|
-
"react-dom": "^19.2.4"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@types/node": "^22.0.0",
|
|
54
|
-
"@types/react": "^19.2.14",
|
|
55
|
-
"@types/react-dom": "^19.2.3",
|
|
56
|
-
"tsup": "^8.5.1",
|
|
57
|
-
"typescript": "^5.3.3"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@adtogether/web-sdk",
|
|
3
|
+
"version": "0.1.23",
|
|
4
|
+
"description": "The official AdTogether Web SDK — reciprocal ad exchange to increase conversions and grow your audience.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/undecided2003/AdTogether.git",
|
|
8
|
+
"directory": "sdk/web-sdk"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://adtogether.relaxsoftwareapps.com",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/undecided2003/AdTogether/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"ads",
|
|
16
|
+
"ad-exchange",
|
|
17
|
+
"monetization",
|
|
18
|
+
"advertising",
|
|
19
|
+
"react",
|
|
20
|
+
"reciprocal",
|
|
21
|
+
"conversions"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.mjs",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"require": "./dist/index.js",
|
|
33
|
+
"import": "./dist/index.mjs"
|
|
34
|
+
},
|
|
35
|
+
"./react": {
|
|
36
|
+
"types": "./dist/react/index.d.ts",
|
|
37
|
+
"require": "./dist/react/index.js",
|
|
38
|
+
"import": "./dist/react/index.mjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup",
|
|
43
|
+
"dev": "tsup --watch"
|
|
44
|
+
},
|
|
45
|
+
"author": "AdTogether Team",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"type": "commonjs",
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"react": "^19.2.4",
|
|
50
|
+
"react-dom": "^19.2.4"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^22.0.0",
|
|
54
|
+
"@types/react": "^19.2.14",
|
|
55
|
+
"@types/react-dom": "^19.2.3",
|
|
56
|
+
"tsup": "^8.5.1",
|
|
57
|
+
"typescript": "^5.3.3"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/core/AdTogether.ts
CHANGED
|
@@ -95,6 +95,37 @@ export class AdTogether {
|
|
|
95
95
|
this.trackEvent('/api/ads/click', adId, token);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Detect the user's country code from the browser locale.
|
|
100
|
+
* Uses Intl API (most reliable) with navigator.language as fallback.
|
|
101
|
+
* Returns an ISO 3166-1 alpha-2 code like "US", "DE", "JP", or null.
|
|
102
|
+
*/
|
|
103
|
+
private static detectCountry(): string | null {
|
|
104
|
+
try {
|
|
105
|
+
// Intl API gives the most reliable region
|
|
106
|
+
if (typeof Intl !== 'undefined' && Intl.DateTimeFormat) {
|
|
107
|
+
const resolved = Intl.DateTimeFormat().resolvedOptions();
|
|
108
|
+
// timeZone is like "America/New_York" — we can map it, but locale is simpler
|
|
109
|
+
if (resolved.locale) {
|
|
110
|
+
const parts = resolved.locale.split('-');
|
|
111
|
+
if (parts.length >= 2) {
|
|
112
|
+
const region = parts[parts.length - 1].toUpperCase();
|
|
113
|
+
if (region.length === 2) return region;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Fallback: navigator.language (e.g. "en-US" -> "US")
|
|
118
|
+
if (typeof navigator !== 'undefined' && navigator.language) {
|
|
119
|
+
const parts = navigator.language.split('-');
|
|
120
|
+
if (parts.length >= 2) {
|
|
121
|
+
const region = parts[parts.length - 1].toUpperCase();
|
|
122
|
+
if (region.length === 2) return region;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} catch (_) {}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
98
129
|
private static trackEvent(endpoint: string, adId: string, token?: string) {
|
|
99
130
|
if (!AdTogether.shared.assertInitialized()) return;
|
|
100
131
|
|
|
@@ -111,6 +142,7 @@ export class AdTogether {
|
|
|
111
142
|
// Send platform and environment to match Flutter SDK
|
|
112
143
|
platform: 'web',
|
|
113
144
|
environment: typeof process !== 'undefined' && process.env?.NODE_ENV === 'development' ? 'development' : 'production',
|
|
145
|
+
country: AdTogether.detectCountry(),
|
|
114
146
|
}),
|
|
115
147
|
}).catch(console.error);
|
|
116
148
|
}
|