Skip to content

Commit 2d8f3f0

Browse files
author
Mike Trinkala
authored
Merge pull request #296 from mozilla-services/bugzilla_1447331
Bugzilla 1447331 - Add Pioneer Opt-in Enrollment counts
2 parents 9336f8a + 89583e1 commit 2d8f3f0

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

moz_pioneer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
cmake_minimum_required(VERSION 3.0)
6-
project(moz-pioneer VERSION 0.0.3 LANGUAGES C)
6+
project(moz-pioneer VERSION 0.0.4 LANGUAGES C)
77
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mozilla Firefox Pioneer Data Processing")
88
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${PACKAGE_PREFIX}-moz-ingest (>= 0.0.1), ${PACKAGE_PREFIX}-moz-telemetry (>= 1.2.13), ${PACKAGE_PREFIX}-jose (>= 0.0.1), ${PACKAGE_PREFIX}-lpeg (>= 1.0.0), ${PACKAGE_PREFIX}-rjson (>= 1.1.0)")
99
string(REGEX REPLACE "[()]" "" CPACK_RPM_PACKAGE_REQUIRES ${CPACK_DEBIAN_PACKAGE_DEPENDS})
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
-- This Source Code Form is subject to the terms of the Mozilla Public
2+
-- License, v. 2.0. If a copy of the MPL was not distributed with this
3+
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
--[[
6+
# Pioneer Opt-in Enrollment
7+
8+
Plugin that estimates the number of users who have the Pioneer Opt-in
9+
add-on installed per-day.
10+
11+
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1447331
12+
13+
https://docs.telemetry.mozilla.org/concepts/data_pipeline.html#hindsight
14+
15+
## Sample Configuration
16+
17+
```lua
18+
filename = 'moz_pioneer_opt_in_estimates.lua'
19+
message_matcher = 'Type=="telemetry" && Fields[docType]=="main" && Fields[environment.addons] =~ "[email protected]"%'
20+
preserve_data = true
21+
ticker_interval = 60
22+
```
23+
24+
## Sample Output
25+
Keys are the date in `YEARMONTHDAY` format, values are the estimated number of
26+
users who sent a ping that included the Pioneer add-on that day.
27+
```json
28+
{
29+
"20171001": 4523,
30+
"20171002": 5937,
31+
"20171003": 3002
32+
}
33+
```
34+
--]]
35+
require "cjson"
36+
require "hyperloglog"
37+
38+
pioneer_day_hlls = {}
39+
40+
function process_message()
41+
local day = read_message("Fields[submissionDate]")
42+
local hll = pioneer_day_hlls[day]
43+
if not hll then
44+
hll = hyperloglog.new()
45+
pioneer_day_hlls[day] = hll
46+
end
47+
hll:add(read_message("Fields[clientId]"))
48+
return 0
49+
end
50+
51+
52+
function timer_event()
53+
local pioneer_day_counts = {}
54+
local count = 0
55+
local earliest_day = nil
56+
for day, hll in pairs(pioneer_day_hlls) do
57+
pioneer_day_counts[day] = hll:count()
58+
count = count + 1
59+
if not earliest_day or day < earliest_day then
60+
earliest_day = day
61+
end
62+
end
63+
inject_payload("json", "pioneer_opt_in_count", cjson.encode(pioneer_day_counts))
64+
if count > 30 then
65+
pioneer_day_hlls[earliest_day] = nil
66+
end
67+
end

0 commit comments

Comments
 (0)