Skip to content

Commit

Permalink
Merge pull request #602 from DemocracyLab/sprint_55_fixes
Browse files Browse the repository at this point in the history
Sprint 55 fixes
  • Loading branch information
marlonkeating authored May 6, 2021
2 parents 55d9e35 + 7ec2117 commit aeeb87f
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 19 deletions.
18 changes: 18 additions & 0 deletions civictechprojects/static/css/partials/_CreateProjectForm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,21 @@
.create-form-project-example {
padding-left: 0.5rem;
}

// quick fix to create's preview view having nested containers (thus, nested gutters)
// TODO: fix this properly so preview is 100% accurate, removing these rules
@include media-breakpoint-up(lg) {
.create-form .Profile-primary-container {
width: 550px;
}
}
@include media-breakpoint-up(xl) {
.create-form .Profile-primary-container {
width: 690px;
}
}
@include media-breakpoint-up(xxl) {
.create-form .Profile-primary-container {
width: 902px;
}
}
2 changes: 1 addition & 1 deletion civictechprojects/templates/new_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
{{ organizationSnippet }}
{{ hotjarScript }}
{{ googleScript }}
{{ headAnalyticsHeadScript }}
</head>
<body>
{{ googleTagsBodyScript }}
Expand Down Expand Up @@ -65,6 +64,7 @@
window.DONATE_PAGE_BLURB = '{{DONATE_PAGE_BLURB}}';
window.GHOST_URL = '{{GHOST_URL}}';
window.GHOST_CONTENT_API_KEY = '{{GHOST_CONTENT_API_KEY}}';
window.HEAP_ANALYTICS_ID = '{{HEAP_ANALYTICS_ID}}'

window.DLAB_MESSAGES = [];
{% for message in messages %}
Expand Down

This file was deleted.

7 changes: 2 additions & 5 deletions civictechprojects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ def index(request, id='Unused but needed for routing purposes; do not remove!'):
'BLOG_URL': settings.BLOG_URL,
'EVENT_URL': settings.EVENT_URL,
'PRIVACY_POLICY_URL': settings.PRIVACY_POLICY_URL,
'DONATE_PAGE_BLURB': settings.DONATE_PAGE_BLURB
'DONATE_PAGE_BLURB': settings.DONATE_PAGE_BLURB,
'HEAP_ANALYTICS_ID': settings.HEAP_ANALYTICS_ID
}
if settings.HOTJAR_APPLICATION_ID:
context['hotjarScript'] = loader.render_to_string('scripts/hotjar_snippet.txt',
Expand All @@ -391,10 +392,6 @@ def index(request, id='Unused but needed for routing purposes; do not remove!'):
context['googleTagsHeadScript'] = loader.render_to_string('scripts/google_tag_manager_snippet_head.txt', google_tag_context)
context['googleTagsBodyScript'] = loader.render_to_string('scripts/google_tag_manager_snippet_body.txt', google_tag_context)

if settings.HEAP_ANALYTICS_ID:
heap_tag_context = {'HEAP_ANALYTICS_ID': settings.HEAP_ANALYTICS_ID}
context['headAnalyticsHeadScript'] = loader.render_to_string('scripts/heap_analytics_snippet_head.txt', heap_tag_context)

if hasattr(settings, 'SOCIAL_APPS_VISIBILITY'):
context['SOCIAL_APPS_VISIBILITY'] = json.dumps(settings.SOCIAL_APPS_VISIBILITY)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ProjectVolunteerButton extends React.PureComponent<Props, State> {
confirmProcessingButtonText="Confirming"
maxCharacterCount={3000}
requireMessage={false}
onConfirm={this.confirmLeaveProject.bind(this)}
onSelection={this.confirmLeaveProject.bind(this)}
onConfirmOperationComplete={() =>
this.setState({
showLeaveProjectModal: false,
Expand Down
1 change: 1 addition & 0 deletions common/components/controllers/MainController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React from "react";
import MainFooter from "../chrome/MainFooter.jsx";
import SocialFooter from "../chrome/SocialFooter.jsx";
import url from "../../components/utils/url.js";
import { loadHeap } from "../utils/heapApi.js";

type State = {|
headerHeight: number,
Expand Down
44 changes: 44 additions & 0 deletions common/components/utils/heapApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// @flow

export function loadHeap() {
if (window.HEAP_ANALYTICS_ID) {
window.heap = window.heap || [];
heap.load = function(e, t) {
window.heap.appid = e;
window.heap.config = t = t || {};
let r = document.createElement("script");
r.type = "text/javascript";
r.async = !0;
r.src = "https://cdn.heapanalytics.com/js/heap-" + e + ".js";
let a = document.getElementsByTagName("script")[0];
a.parentNode.insertBefore(r, a);
for (
let n = function(e) {
return function() {
heap.push([e].concat(Array.prototype.slice.call(arguments, 0)));
};
},
p = [
"addEventProperties",
"addUserProperties",
"clearEventProperties",
"identify",
"resetIdentity",
"removeEventProperty",
"setEventProperties",
"track",
"unsetEventProperty",
],
o = 0;
o < p.length;
o++
)
heap[p[o]] = n(p[o]);
};
heap.load(window.HEAP_ANALYTICS_ID);
window.democracyLabEvents = { heapLoaded: true };
window.dispatchEvent(new Event("heapLoaded"));
}
}

loadHeap();
11 changes: 5 additions & 6 deletions common/components/utils/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ type HeapInterface = {|
track: (eventName: string, properties: ?MetricsParameters) => void,
|};

// TODO: Wait for window.heap to populate if it doesn't immediately
const heap: HeapInterface = window.heap;

function _logEvent(eventName: string, parameters: ?MetricsParameters): void {
Async.onEvent("heapLoaded", () => {
heap.track(eventName, parameters);
});
if (window.HEAP_ANALYTICS_ID) {
Async.onEvent("heapLoaded", () => {
window.heap.track(eventName, parameters);
});
}
}

class metrics {
Expand Down

0 comments on commit aeeb87f

Please sign in to comment.