-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added utm source & medium on playground url (#1994)
- Loading branch information
1 parent
df60a01
commit 24c85d2
Showing
10 changed files
with
91 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use tailcall_version::VERSION; | ||
|
||
const UTM_MEDIUM: &str = "server"; | ||
const DEBUG_UTM_SOURCE: &str = "tailcall-debug"; | ||
const RELEASE_UTM_SOURCE: &str = "tailcall-release"; | ||
const BASE_PLAYGROUND_URL: &str = "https://tailcall.run/playground/"; | ||
|
||
pub fn build_url(graphiql_url: &str) -> String { | ||
let utm_source = if VERSION.is_dev() { | ||
DEBUG_UTM_SOURCE | ||
} else { | ||
RELEASE_UTM_SOURCE | ||
}; | ||
|
||
format!( | ||
"{}?u={}&utm_source={}&utm_medium={}", | ||
BASE_PLAYGROUND_URL, graphiql_url, utm_source, UTM_MEDIUM | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "tailcall-version" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const DEFAULT_VERSION: &str = "0.1.0-dev"; | ||
|
||
pub struct Version { | ||
version: &'static str, | ||
} | ||
|
||
impl Version { | ||
pub const fn new(version: &'static str) -> Self { | ||
Version { version } | ||
} | ||
|
||
pub const fn as_str(&self) -> &'static str { | ||
self.version | ||
} | ||
|
||
pub fn is_dev(&self) -> bool { | ||
self.version.contains("dev") | ||
} | ||
} | ||
|
||
pub const VERSION: Version = match option_env!("APP_VERSION") { | ||
Some(version) => Version::new(version), | ||
None => Version::new(DEFAULT_VERSION), | ||
}; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_default_version() { | ||
assert_eq!(VERSION.as_str(), DEFAULT_VERSION); | ||
assert!(VERSION.is_dev()); | ||
} | ||
|
||
#[test] | ||
fn test_custom_version() { | ||
const CUSTOM_VERSION: Version = Version::new("1.0.0-release"); | ||
assert_eq!(CUSTOM_VERSION.as_str(), "1.0.0-release"); | ||
assert!(!CUSTOM_VERSION.is_dev()); | ||
} | ||
} |