8000 snippets · jorgewqs/firebase-admin-python@3e5e5ad · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e5e5ad

Browse files
snippets
1 parent df9e959 commit 3e5e5ad

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

snippets/dynamic_links/__init__.py

Whitespace-only changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2018 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from firebase_admin import dynamic_links
16+
17+
18+
def get_link_stats():
19+
# [START get_link_stats]
20+
stat_options = dynamic_links.StatOptions(last_n_days=7)
21+
stats = dynamic_links.get_link_stats('https://abc.app.goo.gl/abc12', stat_options)
22+
# arrange the list results in a dict
23+
results = dict()
24+
for stat in stats.event_stats:
25+
results[(stat.platform, stat.event_type)] = stat.count
26+
27+
ios_first_installs = results.get([(dynamic_links.PLATFORM_IOS,
28+
dynamic_links.EVENT_TYPE_APP_FIRST_OPEN)])
29+
30+
if ios_first_installs:
31+
print('There were {} first install on IOS in the last 7 days'.format(ios_first_installs))
32+
# [END get_link_stats]

0 commit comments

Comments
 (0)
0