@tryghost/referrer-parser 0.1.15 → 0.1.17

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/dist/index.d.ts CHANGED
@@ -1,127 +1,28 @@
1
- /**
2
- * Parse a referrer URL to get source, medium and hostname
3
- *
4
- * @param referrerUrl - URL of the referrer to parse
5
- * @param options - Configuration options
6
- * @param referrerSource - Optional source to override URL parameters
7
- * @param referrerMedium - Optional medium to override URL parameters
8
- * @returns Parsed referrer data with source, medium and URL
9
- *
10
- * @example
11
- * // Basic usage
12
- * const result = parse('https://www.google.com/search?q=ghost+cms');
13
- * // result: { referrerSource: 'Google', referrerMedium: 'search', referrerUrl: 'www.google.com' }
14
- *
15
- * @example
16
- * // With site configuration
17
- * const result = parse('https://example.com/blog?utm_source=newsletter', {
18
- * siteUrl: 'https://example.com'
19
- * });
20
- *
21
- * @example
22
- * // With explicit source and medium
23
- * const result = parse('https://example.com', {}, 'newsletter', 'email');
24
- */
25
- export declare function parse(referrerUrl: string, options?: ParserOptions, referrerSource?: string, referrerMedium?: string): ReferrerData;
26
-
27
- /**
28
- * Configuration options for the parser
29
- */
30
- export declare interface ParserOptions {
31
- /** URL of the site for identifying internal traffic */
32
- siteUrl?: string;
33
- /** URL of the admin panel for identifying admin traffic */
34
- adminUrl?: string;
35
- }
36
-
37
- /**
38
- * Interface for parsed referrer data
39
- */
40
- export declare interface ReferrerData {
41
- /** The identified source of the referral traffic */
42
- referrerSource: string | null;
43
- /** The identified medium of the referral traffic */
44
- referrerMedium: string | null;
45
- /** The hostname of the referral URL */
46
- referrerUrl: string | null;
47
- }
48
-
49
- /**
50
- * Parses referrer URLs to determine source and medium
51
- */
52
- export declare class ReferrerParser {
53
- private adminUrl;
54
- private siteUrl;
55
- /**
56
- * Creates a new referrer parser instance
57
- *
58
- * @param options - Configuration options
59
- */
60
- constructor(options?: ParserOptions);
61
- /**
62
- * Parse a referrer URL to get source, medium and hostname
63
- *
64
- * @param referrerUrlStr - URL of the referrer
65
- * @param referrerSource - Source of the referrer
66
- * @param referrerMedium - Medium of the referrer
67
- * @returns Parsed referrer data with source, medium and URL. Internal referrers return null values.
68
- */
69
- parse(referrerUrlStr: string, referrerSource?: string, referrerMedium?: string): ReferrerData;
70
- /**
71
- * Fetches referrer data from known external URLs
72
- *
73
- * @param url - The URL to match against known referrers
74
- * @returns Matched referrer data or null if not found
75
- */
76
- getDataFromUrl(url: URL | null): ReferrerSourceData | null;
77
- /**
78
- * Return URL object for provided URL string
79
- *
80
- * @param url - URL string to parse
81
- * @returns Parsed URL object or null if invalid
82
- */
83
- getUrlFromStr(url: string): URL | null;
84
- /**
85
- * Determine whether the provided URL is a link to the site
86
- *
87
- * @param url - URL to check
88
- * @returns True if the URL belongs to the configured site
89
- */
90
- isSiteDomain(url: URL | null): boolean;
91
- /**
92
- * Determine whether referrer is a Ghost newsletter
93
- *
94
- * @param deps - Input parameters
95
- * @returns True if the referrer is a Ghost newsletter
96
- */
97
- isGhostNewsletter({ referrerSource }: {
98
- referrerSource: string | null;
99
- }): boolean;
100
- /**
101
- * Determine whether referrer is a Ghost.org URL
102
- *
103
- * @param referrerUrl - The referrer URL to check
104
- * @returns True if the referrer is from Ghost.org
105
- */
106
- isGhostOrgUrl(referrerUrl: URL | null): boolean;
107
- /**
108
- * Determine whether referrer is Ghost Explore
109
- *
110
- * @param deps - Input parameters
111
- * @returns True if the referrer is from Ghost Explore
112
- */
113
- isGhostExploreRef({ referrerUrl, referrerSource }: {
114
- referrerUrl: URL | null;
115
- referrerSource?: string | null;
116
- }): boolean;
117
- }
118
-
119
- /**
120
- * Interface for referrer source data
121
- */
122
- declare interface ReferrerSourceData {
123
- source: string;
124
- medium: string;
125
- }
126
-
127
- export { }
1
+ import { ReferrerParser, ReferrerData, ParserOptions } from './lib/ReferrerParser';
2
+ /**
3
+ * Parse a referrer URL to get source, medium and hostname
4
+ *
5
+ * @param referrerUrl - URL of the referrer to parse
6
+ * @param options - Configuration options
7
+ * @param referrerSource - Optional source to override URL parameters
8
+ * @param referrerMedium - Optional medium to override URL parameters
9
+ * @returns Parsed referrer data with source, medium and URL
10
+ *
11
+ * @example
12
+ * // Basic usage
13
+ * const result = parse('https://www.google.com/search?q=ghost+cms');
14
+ * // result: { referrerSource: 'Google', referrerMedium: 'search', referrerUrl: 'www.google.com' }
15
+ *
16
+ * @example
17
+ * // With site configuration
18
+ * const result = parse('https://example.com/blog?utm_source=newsletter', {
19
+ * siteUrl: 'https://example.com'
20
+ * });
21
+ *
22
+ * @example
23
+ * // With explicit source and medium
24
+ * const result = parse('https://example.com', {}, 'newsletter', 'email');
25
+ */
26
+ declare function parse(referrerUrl: string, options?: ParserOptions, referrerSource?: string, referrerMedium?: string): ReferrerData;
27
+ export { parse, ReferrerParser };
28
+ export type { ReferrerData, ParserOptions };