Skip to content
This repository was archived by the owner on Feb 17, 2022. It is now read-only.

Commit 6d7283d

Browse files
author
Robert Kummer
committed
support injection and creates a singleton instance
1 parent 2df52de commit 6d7283d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ For Google Analytics you should place the statement right behind the `body` tag
103103

104104
<body>{!! Analytics::render() !!}
105105

106+
### Dependency Injection (since 1.2.0)
107+
108+
You can inject the analytics provider by referencing the interface:
109+
110+
class PageController extends Controller
111+
{
112+
public function show(\Ipunkt\LaravelAnalytics\Contracts\AnalyticsProviderInterface $analytics)
113+
{
114+
$analytics->setUserId(md5(\Auth::user()->id)); // identical to Analytics::setUserId(md5(\Auth::user()->id));
115+
return view('welcome');
116+
}
117+
}
118+
106119
## How to use
107120

108121
The `GoogleAnalytics` Provider automatically controls the local environment behaviour for testing purposes.

0 commit comments

Comments
 (0)