Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ Code licensed under the [MIT License](LICENSE.txt).

## Telemetry

vcpkg collects usage data in order to help us improve your experience. The data collected by Microsoft is anonymous. You can opt-out of telemetry by running `bootstrap-vcpkg.bat` or `bootstrap-vcpkg.sh` with `-disableMetrics`.
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.

Read more about vcpkg telemetry at docs/about/privacy.md
10 changes: 7 additions & 3 deletions docs/about/privacy.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Vcpkg telemetry and privacy

vcpkg collects telemetry data to understand usage issues, such as failing packages, and to guide tool improvements. The collected data is anonymous.
For more information about how Microsoft protects your privacy, see https://privacy.microsoft.com/en-US/privacystatement#mainenterprisedeveloperproductsmodule
For more information about how Microsoft protects your privacy, see https://privacy.microsoft.com/en-US/privacystatement#mainenterprisedeveloperproductsmodule

## Scope

Expand All @@ -22,7 +22,11 @@ vcpkg displays text similar to the following when you build vcpkg. This is how M
```
Telemetry
---------
vcpkg collects usage data in order to help us improve your experience. The data collected by Microsoft is anonymous. You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics.
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.

Read more about vcpkg telemetry at docs/about/privacy.md
```
Expand All @@ -39,7 +43,7 @@ You can see the telemetry events any command by appending `--printmetrics` after

In the source code (included in `toolsrc\`), you can search for calls to the functions `track_property()` and `track_metric()` to see every specific data point we collect.

## Avoid inadvertent disclosure information
## Avoid inadvertent disclosure information

vcpkg contributors and anyone else running a version of vcpkg that they built themselves should consider the path to their source code. If a crash occurs when using vcpkg, the file path from the build machine is collected as part of the stack trace and isn't hashed.
Because of this, builds of vcpkg shouldn't be located in directories whose path names expose personal or sensitive information.
10 changes: 7 additions & 3 deletions scripts/bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ if ($disableMetrics)
$platform = "x86"
$vcpkgReleaseDir = "$vcpkgSourcesPath\msbuild.x86.release"
if($PSVersionTable.PSVersion.Major -le 2)
{
{
$architecture=(Get-WmiObject win32_operatingsystem | Select-Object osarchitecture).osarchitecture
}
else
Expand Down Expand Up @@ -417,9 +417,13 @@ if (-not $disableMetrics)
Write-Host @"
Telemetry
---------
vcpkg collects usage data in order to help us improve your experience. The data collected by Microsoft is anonymous. You can opt-out of telemetry by re-running bootstrap-vcpkg.bat with -disableMetrics.
Read more about vcpkg telemetry at docs/about/privacy.md
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.

Read more about vcpkg telemetry at docs/about/privacy.md
"@
}

Expand Down
16 changes: 11 additions & 5 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,15 @@ rm -rf "$vcpkgRootDir/vcpkg"
cp "$buildDir/vcpkg" "$vcpkgRootDir/"

if ! [ "$vcpkgDisableMetrics" = "ON" ]; then
echo "Telemetry"
echo "---------"
echo "vcpkg collects usage data in order to help us improve your experience. The data collected by Microsoft is anonymous. You can opt-out of telemetry by re-running bootstrap-vcpkg.sh with -disableMetrics"
echo "Read more about vcpkg telemetry at docs/about/privacy.md"
echo ""
cat <<EOF
Telemetry
---------
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.

Read more about vcpkg telemetry at docs/about/privacy.md
EOF
fi
3 changes: 3 additions & 0 deletions toolsrc/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ ForEachMacros: [TEST_CASE, SECTION]
PenaltyReturnTypeOnItsOwnLine: 1000
SpaceAfterTemplateKeyword: false
SpaceBeforeCpp11BracedList: false

IncludeBlocks: Preserve
SortIncludes: false
10 changes: 6 additions & 4 deletions toolsrc/include/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
#include <winhttp.h>
#endif

#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#include <algorithm>
#include <array>
#include <atomic>
#include <cassert>
#include <cctype>
#include <chrono>
#include <codecvt>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstring>

#if VCPKG_USE_STD_FILESYSTEM
#include <filesystem>
Expand Down
46 changes: 33 additions & 13 deletions toolsrc/include/vcpkg/base/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace vcpkg::Json
{
Null,
Boolean,
Integer,
Number,
String,
Array,
Expand All @@ -84,18 +85,28 @@ namespace vcpkg::Json

struct Value
{
Value() noexcept; // equivalent to Value::null()
Value(Value&&) noexcept;
Value& operator=(Value&&) noexcept;
~Value();

Value clone() const noexcept;

ValueKind kind() const noexcept;

bool is_null() const noexcept;
bool is_boolean() const noexcept;
bool is_integer() const noexcept;
// either integer _or_ number
bool is_number() const noexcept;
bool is_string() const noexcept;
bool is_array() const noexcept;
bool is_object() const noexcept;

// a.x() asserts when !a.is_x()
bool boolean() const noexcept;
int64_t number() const noexcept;
int64_t integer() const noexcept;
double number() const noexcept;
StringView string() const noexcept;

const Array& array() const noexcept;
Expand All @@ -104,18 +115,13 @@ namespace vcpkg::Json
const Object& object() const noexcept;
Object& object() noexcept;

Value(Value&&) noexcept;
Value& operator=(Value&&) noexcept;
~Value();

Value() noexcept; // equivalent to Value::null()
static Value null(std::nullptr_t) noexcept;
static Value boolean(bool) noexcept;
static Value number(int64_t i) noexcept;
static Value integer(int64_t i) noexcept;
static Value number(double d) noexcept;
static Value string(StringView) noexcept;
static Value array(Array&&) noexcept;
static Value object(Object&&) noexcept;
Value clone() const noexcept;

private:
friend struct impl::ValueImpl;
Expand All @@ -128,6 +134,15 @@ namespace vcpkg::Json
using underlying_t = std::vector<Value>;

public:
Array() = default;
Array(Array const&) = delete;
Array(Array&&) = default;
Array& operator=(Array const&) = delete;
Array& operator=(Array&&) = default;
~Array() = default;

Array clone() const noexcept;

using iterator = underlying_t::iterator;
using const_iterator = underlying_t::const_iterator;

Expand All @@ -148,8 +163,6 @@ namespace vcpkg::Json
return this->underlying_[idx];
}

Array clone() const noexcept;

iterator begin() { return underlying_.begin(); }
iterator end() { return underlying_.end(); }
const_iterator begin() const { return cbegin(); }
Expand All @@ -160,7 +173,6 @@ namespace vcpkg::Json
private:
underlying_t underlying_;
};

struct Object
{
private:
Expand All @@ -169,6 +181,16 @@ namespace vcpkg::Json
underlying_t::const_iterator internal_find_key(StringView key) const noexcept;

public:
// these are here for better diagnostics
Object() = default;
Object(Object const&) = delete;
Object(Object&&) = default;
Object& operator=(Object const&) = delete;
Object& operator=(Object&&) = default;
~Object() = default;

Object clone() const noexcept;

// asserts if the key is found
void insert(std::string key, Value value) noexcept;

Expand Down Expand Up @@ -200,8 +222,6 @@ namespace vcpkg::Json

std::size_t size() const noexcept { return this->underlying_.size(); }

Object clone() const noexcept;

struct const_iterator
{
using value_type = std::pair<StringView, const Value&>;
Expand Down
4 changes: 3 additions & 1 deletion toolsrc/include/vcpkg/metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ namespace vcpkg::Metrics
{
void set_send_metrics(bool should_send_metrics);
void set_print_metrics(bool should_print_metrics);
void set_disabled(bool disabled);
void set_user_information(const std::string& user_id, const std::string& first_use_time);
static void init_user_information(std::string& user_id, std::string& first_use_time);

void track_metric(const std::string& name, double value);
void track_buildtime(const std::string& name, double value);
void track_property(const std::string& name, const std::string& value);

bool metrics_enabled();

void upload(const std::string& payload);
void flush();
};

extern Util::LockGuarded<Metrics> g_metrics;

std::string get_MAC_user();
bool get_compiled_metrics_enabled();
}
2 changes: 2 additions & 0 deletions toolsrc/include/vcpkg/vcpkgcmdarguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ namespace vcpkg
std::vector<std::string> binarysources;
Optional<bool> debug = nullopt;
Optional<bool> sendmetrics = nullopt;
// fully disable metrics -- both printing and sending
Optional<bool> disable_metrics = nullopt;
Optional<bool> printmetrics = nullopt;

// feature flags
Expand Down
64 changes: 45 additions & 19 deletions toolsrc/src/vcpkg-test/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <vcpkg/base/json.h>
#include <vcpkg/base/unicode.h>

#include "math.h"

// TODO: remove this once we switch to C++20 completely
// This is the worst, but we also can't really deal with it any other way.
#if __cpp_char8_t
Expand Down Expand Up @@ -57,9 +59,7 @@ TEST_CASE ("JSON parse strings", "[json]")
REQUIRE(res.get()->first.is_string());
REQUIRE(res.get()->first.string() == "\xED\xA0\x80");

const auto make_json_string = [] (vcpkg::StringView sv) {
return '"' + sv.to_string() + '"';
};
const auto make_json_string = [](vcpkg::StringView sv) { return '"' + sv.to_string() + '"'; };
const vcpkg::StringView radical = U8_STR("⎷");
const vcpkg::StringView grin = U8_STR("😁");

Expand All @@ -79,28 +79,51 @@ TEST_CASE ("JSON parse strings", "[json]")
REQUIRE(res.get()->first.string() == grin);
}

TEST_CASE ("JSON parse numbers", "[json]")
TEST_CASE ("JSON parse integers", "[json]")
{
auto res = Json::parse("0");
REQUIRE(res);
REQUIRE(res.get()->first.is_number());
REQUIRE(res.get()->first.number() == 0);
REQUIRE(res.get()->first.is_integer());
REQUIRE(res.get()->first.integer() == 0);
res = Json::parse("12345");
REQUIRE(res);
REQUIRE(res.get()->first.is_number());
REQUIRE(res.get()->first.number() == 12345);
REQUIRE(res.get()->first.is_integer());
REQUIRE(res.get()->first.integer() == 12345);
res = Json::parse("-12345");
REQUIRE(res);
REQUIRE(res.get()->first.is_number());
REQUIRE(res.get()->first.number() == -12345);
REQUIRE(res.get()->first.is_integer());
REQUIRE(res.get()->first.integer() == -12345);
res = Json::parse("9223372036854775807"); // INT64_MAX
REQUIRE(res);
REQUIRE(res.get()->first.is_number());
REQUIRE(res.get()->first.number() == 9223372036854775807);
REQUIRE(res.get()->first.is_integer());
REQUIRE(res.get()->first.integer() == 9223372036854775807);
res = Json::parse("-9223372036854775808");
REQUIRE(res);
REQUIRE(res.get()->first.is_integer());
REQUIRE(res.get()->first.integer() == (-9223372036854775807 - 1)); // INT64_MIN (C++'s parser is fun)
}

TEST_CASE ("JSON parse floats", "[json]")
{
auto res = Json::parse("0.0");
REQUIRE(res);
REQUIRE(res.get()->first.is_number());
REQUIRE(!res.get()->first.is_integer());
REQUIRE(res.get()->first.number() == 0.0);
REQUIRE(!signbit(res.get()->first.number()));
res = Json::parse("-0.0");
REQUIRE(res);
REQUIRE(res.get()->first.is_number());
REQUIRE(res.get()->first.number() == 0.0);
REQUIRE(signbit(res.get()->first.number()));
res = Json::parse("12345.6789");
REQUIRE(res);
REQUIRE(res.get()->first.is_number());
REQUIRE_THAT(res.get()->first.number(), Catch::WithinULP(12345.6789, 3));
res = Json::parse("-12345.6789");
REQUIRE(res);
REQUIRE(res.get()->first.is_number());
REQUIRE(res.get()->first.number() == (-9223372036854775807 - 1)); // INT64_MIN (C++'s parser is fun)
REQUIRE_THAT(res.get()->first.number(), Catch::WithinULP(-12345.6789, 3));
}

TEST_CASE ("JSON parse arrays", "[json]")
Expand All @@ -116,18 +139,18 @@ TEST_CASE ("JSON parse arrays", "[json]")
val = std::move(res.get()->first);
REQUIRE(val.is_array());
REQUIRE(val.array().size() == 1);
REQUIRE(val.array()[0].is_number());
REQUIRE(val.array()[0].number() == 123);
REQUIRE(val.array()[0].is_integer());
REQUIRE(val.array()[0].integer() == 123);

res = Json::parse("[123, 456]");
REQUIRE(res);
val = std::move(res.get()->first);
REQUIRE(val.is_array());
REQUIRE(val.array().size() == 2);
REQUIRE(val.array()[0].is_number());
REQUIRE(val.array()[0].number() == 123);
REQUIRE(val.array()[1].is_number());
REQUIRE(val.array()[1].number() == 456);
REQUIRE(val.array()[0].is_integer());
REQUIRE(val.array()[0].integer() == 123);
REQUIRE(val.array()[1].is_integer());
REQUIRE(val.array()[1].integer() == 456);

res = Json::parse("[123, 456, [null]]");
REQUIRE(res);
Expand Down Expand Up @@ -155,5 +178,8 @@ TEST_CASE ("JSON parse full file", "[json]")
;

auto res = Json::parse(json);
if (!res) {
std::cerr << res.error()->format() << '\n';
}
REQUIRE(res);
}
Loading