-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
93 lines (83 loc) · 2.41 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
declare(strict_types=1);
use Treblle\Runtime\DataObjects\Config;
use Treblle\Runtime\Masking;
use Treblle\Runtime\Runtime;
use Treblle\Runtime\Transport\Treblle;
require __DIR__ . '/vendor/autoload.php';
// will be built by the implementation.
// $config = Config::make(config('treblle'));
$config = new Config(
api_key: '1234',
project_id: '1234',
ignored_environments: ['local'],
masking: [
'email' => Masking\EmailMatcher::class,
'password' => Masking\StringMatcher::class,
'account.*' => Masking\StringMatcher::class,
'user.email' => Masking\EmailMatcher::class,
'user.dob' => Masking\DateMatcher::class,
'user.password' => Masking\StringMatcher::class,
'user.ss' => Masking\SocialSecurityMatcher::class,
'user.payments.cc' => Masking\CreditCardMatcher::class,
'cc' => Masking\CreditCardMatcher::class,
],
);
$runtime = new Runtime(
transport: new Treblle(
apiToken: '1234',
url: 'https://httpdump.app',
),
payload: Runtime::payload(
config: $config,
),
maskingEngine: new Masking\MaskingEngine(
config: $config,
),
start: microtime(true),
);
// this happens in the middleware
$runtime->request(
data: [
'timestamp' => '2024-05-16:12:12:12',
'ip' => '127.0.0.1',
'url' => 'https://api.something.com',
'user_agent' => 'Some Agent',
'method' => 'GET',
'headers' => [
'content_type' => 'application/json',
'content_length' => 123,
'host' => 'https://api.something.com',
'user_agent' => 'Some Agent',
],
'body' => [
'user' => [
'name' => 'Steve',
'email' => 'steve@example.com',
'dob' => '09/09/1988',
'password' => 'password',
'ss' => '123-23-2345',
'payments' => [
'cc' => '1234-1234-1234-1234',
],
],
],
],
);
// this happens in the middleware
$runtime->response(
data: [
'headers' => [
'Accept' => 'application/json',
],
'code' => 200,
'size' => 123,
'load_time' => 1234,
'memory_usage' => memory_get_peak_usage(),
'body' => [
'password' => 'password',
],
],
);
//$runtime->start = microtime(true);
$runtime->process();