File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 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' ,
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 ) ;
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' ,
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ export type AllowedPropertyValues = string | number | boolean | null;
33export 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.
You can’t perform that action at this time.
0 commit comments