File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ and this project adheres to
1010
1111### Added
1212
13+ - Add module version to the ` source ` parameter.
14+
1315### Changed
1416
1517### Fixed
Original file line number Diff line number Diff line change 11import { config } from "./config.ts" ;
22import { InvalidTimeoutError , MissingApiKeyError } from "./errors.ts" ;
3+ import { version } from "../version.ts" ;
34
45type UrlParameters = Record <
56 string ,
@@ -59,22 +60,22 @@ function getBaseUrl() {
5960 return "https://serpapi.com" ;
6061}
6162
62- // TODO(seb): get module version too
6363function getSource ( ) {
64+ const moduleSource = `serpapi@${ version } ` ;
6465 try {
6566 // Check if running in Node.js
6667 // deno-lint-ignore no-explicit-any
6768 if ( ( globalThis as any ) ?. process ?. version ) {
6869 // deno-lint-ignore no-explicit-any
6970 const nodeVersion = ( globalThis as any ) . process . version . replace ( "v" , "" ) ;
70- return `nodejs@${ nodeVersion } ` ;
71+ return `nodejs@${ nodeVersion } , ${ moduleSource } ` ;
7172 }
7273
7374 // Assumes running in Deno instead
74- return `deno@${ Deno . version . deno } ` ;
75+ return `deno@${ Deno . version . deno } , ${ moduleSource } ` ;
7576 } catch {
7677 // If something unexpectedly occurs, revert to "nodejs".
77- return " nodejs" ;
78+ return ` nodejs, ${ moduleSource } ` ;
7879 }
7980}
8081
Original file line number Diff line number Diff line change @@ -182,10 +182,10 @@ describe("execute", {
182182
183183 assertSpyCalls ( fetchStub , 1 ) ;
184184 const url = fetchStub . calls [ 0 ] . args [ 0 ] as string ;
185- // e.g. deno@1.28.2
185+ // e.g. deno@1.28.2,serpapi@1.0.0
186186 assertMatch (
187187 url ,
188- / s o u r c e = ( n o d e j s | d e n o ) % 4 0 \d + \. \d + \. \d + $ / ,
188+ / s o u r c e = ( n o d e j s | d e n o ) % 4 0 \d + \. \d + \. \d + % 2 C s e r p a p i % 4 0 \d + \. \d + \. \d + $ / ,
189189 ) ;
190190 } ) ;
191191
You can’t perform that action at this time.
0 commit comments