Skip to content

Commit

Permalink
fix: handle when browser tracking is not configured
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhdk committed Aug 30, 2022
1 parent 9fd15c6 commit 2ed1dbb
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions samples/UmbracoV9/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
@inject IRelewiseClientFactory RelewiseClientFactory;

@{
var breadcrumb = Model.Breadcrumbs(andSelf: true).ToArray();
var homePage = breadcrumb.First();
IPublishedContent[] breadcrumb = Model.Breadcrumbs(andSelf: true).ToArray();
IPublishedContent homePage = breadcrumb.First();
IEnumerable<IPublishedElement> footer = homePage.Value<IEnumerable<IPublishedElement>>("footerLinks").EmptyIfNull();
IEnumerable<Link> headerLinks = homePage.Value<IEnumerable<Link>>("headerLinks").EmptyIfNull();

RelewiseClientOptions tracker = RelewiseClientFactory.GetOptions<ITracker>("Browser");
RelewiseClientOptions tracker = null;
try
{
tracker = RelewiseClientFactory.GetOptions<ITracker>("Browser");
}
catch (ArgumentException)
{
// Client not found - ignore error
// Note: this will be replaced by a call to a future Contains()-method on the client factory.
}
}

<!DOCTYPE html>
Expand Down Expand Up @@ -45,9 +54,12 @@
<link rel="stylesheet" type="text/css" href="/css/util.css">
<!--===============================================================================================-->

<script language="javascript">
window.__tracker = { "datasetId": "@tracker.DatasetId", "apiKey": "@tracker.ApiKey" }
</script>
@if (tracker != null)
{
<script language="javascript">
window.__tracker = { "datasetId": "@tracker.DatasetId", "apiKey": "@tracker.ApiKey" }
</script>
}
</head>
<body class="animsition">

Expand Down

0 comments on commit 2ed1dbb

Please sign in to comment.