Skip to content

Commit e3007ab

Browse files
committed
apiHost
1 parent fe23461 commit e3007ab

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

packages/script/src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
return null;
3636
}
3737

38-
const api = script.getAttribute('data-api');
38+
const ah = script.getAttribute('data-api-host');
3939
const am = script.getAttribute('data-attribution-model');
4040
const co = script.getAttribute('data-cookie-options');
4141
const qp = script.getAttribute('data-query-param');
4242

4343
return {
44-
api: api || 'https://api.dub.co/track/click',
44+
apiHost: ah || 'https://api.dub.co',
4545
attributionModel: am || 'last-click',
4646
cookieOptions: co ? JSON.parse(co) : null,
4747
queryParam: qp || 'ref',
@@ -100,7 +100,7 @@
100100
// Function to check for { keys } in the URL and update cookie if necessary
101101
function watchForQueryParams() {
102102
const searchParams = new URLSearchParams(window.location.search);
103-
const { api, cookieOptions, attributionModel, queryParam } =
103+
const { apiHost, cookieOptions, attributionModel, queryParam } =
104104
getOptions(script);
105105

106106
let clickId = searchParams.get(CLICK_ID) || searchParams.get(OLD_CLICK_ID);
@@ -109,7 +109,7 @@
109109
const identifier = searchParams.get(queryParam);
110110

111111
if (identifier) {
112-
fetch(api, {
112+
fetch(`${apiHost}/track/click`, {
113113
method: 'POST',
114114
headers: {
115115
'Content-Type': 'application/json',

packages/web/src/generic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ function inject(props: AnalyticsProps): void {
1818
script.setAttribute('data-sdkn', name);
1919
script.setAttribute('data-sdkv', version);
2020

21-
if (props.api) {
22-
script.setAttribute('data-api', props.api);
21+
if (props.apiHost) {
22+
script.setAttribute('data-api-host', props.apiHost);
2323
}
2424

2525
if (props.attributionModel) {

packages/web/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ export type AllowedPropertyValues = string | number | boolean | null;
33
export interface AnalyticsProps {
44
/**
55
* The API endpoint to send analytics data to.
6-
* @default 'https://api.dub.co/track/click'
6+
* @default 'https://api.dub.co'
77
*/
8-
api?: string;
8+
apiHost?: string;
99

1010
/**
1111
* The Attribution Model to use for the analytics event.

0 commit comments

Comments
 (0)