Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Commit 3b82ea8

Browse files
committed
Clean up indentation of integration test template (close snowplow#691)
1 parent f39bf59 commit 3b82ea8

1 file changed

Lines changed: 148 additions & 144 deletions

File tree

tests/pages/integration-template.html

Lines changed: 148 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -4,150 +4,154 @@
44
<title>Integration test page</title>
55
</head>
66
<body>
7-
<p id="title">Page for sending requests to request_recorder</p>
8-
9-
<script>
10-
document.body.className += ' loaded';
11-
</script>
12-
13-
<script>
14-
15-
16-
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
17-
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
18-
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
19-
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","./snowplow.js","snowplow"));
20-
21-
// Taken from a random environment variable
22-
var subdomain = '<%= subdomain %>';
23-
24-
window.snowplow('newTracker', 'cf', subdomain + '.ngrok.io', {
25-
encodeBase64: true,
26-
appId: 'CFe23a',
27-
platform: 'mob',
28-
contexts: {
29-
webPage: true
30-
}
31-
});
32-
33-
// Add a global context
34-
var geolocationContext = {
35-
schema: 'iglu:com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-1-0',
36-
data: {
37-
'latitude': 40.0,
38-
'longitude' : 55.1
39-
}
40-
};
41-
42-
function eventTypeContextGenerator(args) {
43-
var context = {};
44-
context['schema'] = 'iglu:com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-1';
45-
context['data'] = {};
46-
context['data']['osType'] = 'ubuntu';
47-
context['data']['osVersion'] = '2018.04';
48-
context['data']['deviceManufacturer'] = 'ASUS';
49-
context['data']['deviceModel'] = String(args['eventType']);
50-
return context;
51-
}
52-
53-
// A filter that will only attach contexts to structured events
54-
function structuredEventFilter(args) {
55-
return args['eventType'] === 'se';
56-
}
57-
58-
function erroneousContextGenerator(args) {
59-
return {};
60-
}
61-
62-
window.snowplow('addGlobalContexts', [erroneousContextGenerator]);
63-
window.snowplow('addGlobalContexts', [[structuredEventFilter, [eventTypeContextGenerator, geolocationContext]]]);
64-
65-
window.snowplow('setUserId', 'Malcolm');
66-
window.snowplow('trackPageView', 'My Title', [ // Auto-set page title; add page context
67-
{
68-
schema: "iglu:com.example_company/user/jsonschema/2-0-0",
69-
data: {
70-
userType: 'tester'
71-
}
72-
}
73-
]);
74-
75-
// This should have different pageViewId in web_page context
76-
window.snowplow('trackPageView');
77-
78-
window.snowplow('trackStructEvent', 'Mixes', 'Play', 'MRC/fabric-0503-mix', '', '0.0');
79-
window.snowplow('trackUnstructEvent', {
80-
schema: 'iglu:com.acme_company/viewed_product/jsonschema/5-0-0',
81-
data: {
82-
productId: 'ASO01043'
83-
}
84-
}, [], { type: 'ttm', value: 1477401868 });
85-
86-
var orderId = 'order-123';
87-
88-
window.snowplow('addTrans',
89-
orderId,
90-
'acme',
91-
'8000',
92-
'100',
93-
'50',
94-
'phoenix',
95-
'arizona',
96-
'USA',
97-
'JPY'
98-
);
99-
100-
// addItem might be called for each item in the shopping cart,
101-
// or not at all.
102-
window.snowplow('addItem',
103-
orderId,
104-
'1001',
105-
'Blue t-shirt',
106-
'clothing',
107-
'2000',
108-
'2',
109-
'JPY'
110-
);
111-
112-
// trackTrans sends the transaction to Snowplow tracking servers.
113-
// Must be called last to commit the transaction.
114-
window.snowplow('trackTrans');
115-
116-
var testAcceptRuleSet = {
117-
accept: ['iglu:com.acme_company/*/jsonschema/*-*-*']
118-
};
119-
var testRejectRuleSet = {
120-
reject: ['iglu:com.acme_company/*/jsonschema/*-*-*']
121-
};
122-
123-
// test context rulesets
124-
window.snowplow('addGlobalContexts', [[testAcceptRuleSet, [eventTypeContextGenerator, geolocationContext]]]);
125-
126-
window.snowplow('trackUnstructEvent', {
127-
schema: 'iglu:com.acme_company/viewed_product/jsonschema/5-0-0',
128-
data: {
129-
productId: 'ASO01042'
130-
}
131-
}, [], { type: 'ttm', value: 1477401869 });
132-
133-
window.snowplow('removeGlobalContexts', [[testAcceptRuleSet, [eventTypeContextGenerator, geolocationContext]]]);
134-
135-
window.snowplow('addGlobalContexts', [[testRejectRuleSet, [eventTypeContextGenerator, geolocationContext]]]);
136-
window.snowplow('trackUnstructEvent', {
137-
schema: 'iglu:com.acme_company/viewed_product/jsonschema/5-0-0',
138-
data: {
139-
productId: 'ASO01041'
140-
}
141-
}, [], { type: 'ttm', value: 1477401868 });
142-
143-
// track unhandled exception
144-
window.snowplow("enableErrorTracking");
145-
146-
// Test for exception handling
147-
function raiseException() { notExistentObject.notExistentProperty(); }
148-
setTimeout(raiseException, 2500);
149-
150-
</script>
7+
<p id="title">Page for sending requests to request_recorder</p>
8+
9+
<script>
10+
document.body.className += ' loaded';
11+
</script>
12+
13+
<script>
14+
15+
16+
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
17+
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
18+
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
19+
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","./snowplow.js","snowplow"));
20+
21+
// Taken from a random environment variable
22+
23+
var subdomain = '<%= subdomain %>';
24+
25+
window.snowplow('newTracker', 'cf', subdomain + '.ngrok.io', {
26+
encodeBase64: true,
27+
appId: 'CFe23a',
28+
platform: 'mob',
29+
contexts: {
30+
webPage: true
31+
}
32+
});
33+
34+
// Add a global context
35+
var geolocationContext = {
36+
schema: 'iglu:com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-1-0',
37+
data: {
38+
'latitude': 40.0,
39+
'longitude' : 55.1
40+
}
41+
};
42+
43+
function eventTypeContextGenerator(args) {
44+
var context = {};
45+
context['schema'] = 'iglu:com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-1';
46+
context['data'] = {};
47+
context['data']['osType'] = 'ubuntu';
48+
context['data']['osVersion'] = '2018.04';
49+
context['data']['deviceManufacturer'] = 'ASUS';
50+
context['data']['deviceModel'] = String(args['eventType']);
51+
return context;
52+
}
53+
54+
// A filter that will only attach contexts to structured events
55+
function structuredEventFilter(args) {
56+
return args['eventType'] === 'se';
57+
}
58+
59+
function erroneousContextGenerator(args) {
60+
return {};
61+
}
62+
63+
window.snowplow('addGlobalContexts', [erroneousContextGenerator]);
64+
window.snowplow('addGlobalContexts', [[structuredEventFilter, [eventTypeContextGenerator, geolocationContext]]]);
65+
66+
window.snowplow('setUserId', 'Malcolm');
67+
window.snowplow('trackPageView', 'My Title', [ // Auto-set page title; add page context
68+
{
69+
schema: "iglu:com.example_company/user/jsonschema/2-0-0",
70+
data: {
71+
userType: 'tester'
72+
}
73+
}
74+
]);
75+
76+
// This should have different pageViewId in web_page context
77+
window.snowplow('trackPageView');
78+
79+
window.snowplow('trackStructEvent', 'Mixes', 'Play', 'MRC/fabric-0503-mix', '', '0.0');
80+
window.snowplow('trackUnstructEvent', {
81+
schema: 'iglu:com.acme_company/viewed_product/jsonschema/5-0-0',
82+
data: {
83+
productId: 'ASO01043'
84+
}
85+
}, [], {type: 'ttm', value: 1477401868});
86+
87+
var orderId = 'order-123';
88+
89+
window.snowplow('addTrans',
90+
orderId,
91+
'acme',
92+
'8000',
93+
'100',
94+
'50',
95+
'phoenix',
96+
'arizona',
97+
'USA',
98+
'JPY'
99+
);
100+
101+
// addItem might be called for each item in the shopping cart,
102+
// or not at all.
103+
window.snowplow('addItem',
104+
orderId,
105+
'1001',
106+
'Blue t-shirt',
107+
'clothing',
108+
'2000',
109+
'2',
110+
'JPY'
111+
);
112+
113+
// trackTrans sends the transaction to Snowplow tracking servers.
114+
// Must be called last to commit the transaction.
115+
window.snowplow('trackTrans');
116+
117+
var testAcceptRuleSet = {
118+
accept: ['iglu:com.acme_company/*/jsonschema/*-*-*']
119+
};
120+
var testRejectRuleSet = {
121+
reject: ['iglu:com.acme_company/*/jsonschema/*-*-*']
122+
};
123+
124+
// test context rulesets
125+
window.snowplow('addGlobalContexts', [[testAcceptRuleSet, [eventTypeContextGenerator, geolocationContext]]]);
126+
127+
window.snowplow('trackUnstructEvent', {
128+
schema: 'iglu:com.acme_company/viewed_product/jsonschema/5-0-0',
129+
data: {
130+
productId: 'ASO01042'
131+
}
132+
}, [], {type: 'ttm', value: 1477401869});
133+
134+
window.snowplow('removeGlobalContexts', [[testAcceptRuleSet, [eventTypeContextGenerator, geolocationContext]]]);
135+
136+
window.snowplow('addGlobalContexts', [[testRejectRuleSet, [eventTypeContextGenerator, geolocationContext]]]);
137+
window.snowplow('trackUnstructEvent', {
138+
schema: 'iglu:com.acme_company/viewed_product/jsonschema/5-0-0',
139+
data: {
140+
productId: 'ASO01041'
141+
}
142+
}, [], {type: 'ttm', value: 1477401868});
143+
144+
// track unhandled exception
145+
window.snowplow("enableErrorTracking");
146+
147+
// Test for exception handling
148+
function raiseException() {
149+
notExistentObject.notExistentProperty();
150+
}
151+
152+
setTimeout(raiseException, 2500);
153+
154+
</script>
151155

152156
</body>
153157
</html>

0 commit comments

Comments
 (0)