Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next major Android SDK v3 #30

Merged
merged 126 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 122 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
0a4d6d6
new project structure
marandaneto Sep 12, 2023
b719106
add spotless
marandaneto Sep 12, 2023
0c2ab01
add linters
marandaneto Sep 12, 2023
998d897
enable proguard
marandaneto Sep 12, 2023
dd7cd74
add api validator
marandaneto Sep 12, 2023
1a7ded2
add makefile and fix unused resources
marandaneto Sep 12, 2023
9a3a4ab
add explicit Api and comments
marandaneto Sep 12, 2023
584f37a
add CI
marandaneto Sep 12, 2023
5f02cb0
fix branch
marandaneto Sep 12, 2023
90f24c1
add buildSrc folder and reuse content
marandaneto Sep 12, 2023
9982bb4
add coments
marandaneto Sep 12, 2023
6e3b8d2
add deps
marandaneto Sep 12, 2023
41cd475
implement basic classes
marandaneto Sep 13, 2023
f0f4f1d
fix compile
marandaneto Sep 14, 2023
30ebddd
fix timer and refactor internal package
marandaneto Sep 14, 2023
2a2d767
add basic feature flags api
marandaneto Sep 14, 2023
ec3b5a0
add flush
marandaneto Sep 14, 2023
0b1c307
add more comments and TODOs
marandaneto Sep 14, 2023
d3860ec
add retry
marandaneto Sep 14, 2023
a4ee842
make buffered readers and writers
marandaneto Sep 15, 2023
cf0791b
add comments and pending classes, features
marandaneto Sep 15, 2023
9b40ca6
fix api
marandaneto Sep 15, 2023
2567fd6
add a few android classes and its base structure
marandaneto Sep 15, 2023
408e0b3
add integrations
marandaneto Sep 18, 2023
39950d6
add back compatibality for sending cached files
marandaneto Sep 19, 2023
2cceef7
fix add queue
marandaneto Sep 19, 2023
8dc67a7
fix issues
marandaneto Sep 19, 2023
e7d6cc1
fix api calls
marandaneto Sep 20, 2023
a83e4f0
add more integrations
marandaneto Sep 21, 2023
89101d8
add group fixes
marandaneto Sep 21, 2023
0961b14
back compatible preferences
marandaneto Sep 21, 2023
c181b02
call crypto method
marandaneto Sep 21, 2023
fc66021
swallow exceptions
marandaneto Sep 21, 2023
3ec8975
fixes
marandaneto Sep 21, 2023
58ecd99
fixes
marandaneto Sep 22, 2023
0b83e0b
add publishing scripts
marandaneto Sep 25, 2023
59e4216
add bump script
marandaneto Sep 25, 2023
fb3a16f
add GH action for releases
marandaneto Sep 25, 2023
d4c747f
fix gpg signing
marandaneto Sep 25, 2023
bc1c4d4
add commit code script
Sep 25, 2023
2ea6e53
update version based on release
marandaneto Sep 25, 2023
d690af0
fix release
marandaneto Sep 25, 2023
9befaf7
fix
marandaneto Sep 25, 2023
3f6d8ea
Update version
Sep 25, 2023
88cba3f
fix release bits
marandaneto Sep 25, 2023
0273187
delete old files
marandaneto Sep 25, 2023
6a2704b
fix file structure
marandaneto Sep 25, 2023
35ff27c
fixes
marandaneto Sep 25, 2023
a2d4d9e
add deep link and screen views
marandaneto Sep 25, 2023
d2577b1
screen lifecycle
marandaneto Sep 25, 2023
f2aff78
fix naming
marandaneto Sep 25, 2023
14e2850
fix
marandaneto Sep 25, 2023
6deef02
add on feature flags callback
marandaneto Sep 25, 2023
82e0510
fix
marandaneto Sep 25, 2023
4dc2979
add register and unregister method
marandaneto Sep 25, 2023
c009e3e
respect max batch size in legacy files
marandaneto Sep 26, 2023
aa26e4f
add max batch size to normal events
marandaneto Sep 26, 2023
8d640fe
uncomment release
marandaneto Sep 26, 2023
b0916f9
Update version
Sep 26, 2023
1c49a29
setting stage profile id
marandaneto Sep 26, 2023
a46dcb6
call close and release after publish
marandaneto Sep 26, 2023
721f5df
fix missing sources
marandaneto Sep 26, 2023
a27c63e
fix changelog
marandaneto Sep 26, 2023
57b9626
fix missing permissions check
marandaneto Sep 26, 2023
8e9a65a
add more infra
marandaneto Sep 26, 2023
479252f
fix names
marandaneto Sep 26, 2023
0a82305
fix format pipeline
marandaneto Sep 26, 2023
cf17378
test format pipeline
marandaneto Sep 26, 2023
1012a42
Update version
Sep 26, 2023
45c9c12
fix
marandaneto Sep 26, 2023
049ef7f
Push changes
Sep 26, 2023
44b39a3
test once more
marandaneto Sep 26, 2023
a623ae3
Push changes
Sep 26, 2023
5ee8dde
againnn
marandaneto Sep 26, 2023
ab65a10
Push changes
Sep 26, 2023
d6c0c54
test
marandaneto Sep 26, 2023
e17fb70
Push changes
Sep 26, 2023
07932d9
fix
marandaneto Sep 26, 2023
adcefcc
add install steps
marandaneto Sep 26, 2023
453c31c
add missing changelog
marandaneto Sep 27, 2023
99502df
Update version
Sep 27, 2023
8b731e9
test infra
marandaneto Sep 27, 2023
9f97652
testing infra and tests
marandaneto Sep 27, 2023
9173d53
Merge branch 'v3' of github.com:PostHog/posthog-android into v3
marandaneto Sep 27, 2023
d578bb0
refactor tests
marandaneto Sep 27, 2023
4d219a8
add tests for capture screen views
marandaneto Sep 28, 2023
2a49ce9
add tests for install integration
marandaneto Sep 28, 2023
c43f5ad
add dokka comments
marandaneto Sep 28, 2023
976cc83
add tests for lifecycle observer
marandaneto Sep 28, 2023
1b2ec02
add tests for android shared prefs
marandaneto Sep 28, 2023
776f78f
review
marandaneto Sep 28, 2023
269dd57
add tests for PostHogAndroidTest
marandaneto Sep 28, 2023
fc39f36
add tests for network status checker
marandaneto Sep 28, 2023
18f01dd
add tests for static and dynamic context
marandaneto Sep 28, 2023
f502f16
fix test
marandaneto Sep 28, 2023
7b0d4be
add dokka for android classes
marandaneto Sep 28, 2023
5bc9298
remove not implemented todos
marandaneto Sep 28, 2023
1b721d0
add dokka to config class
marandaneto Sep 28, 2023
b968e74
add dokka and logger tests
marandaneto Sep 29, 2023
2aecd4e
add tests to gson date type adapter
marandaneto Sep 29, 2023
6c581f3
add tests for memory prefs
marandaneto Sep 29, 2023
f827bd6
add tests for serializer for events and batches
marandaneto Sep 29, 2023
8806158
add tests for legacy events
marandaneto Sep 29, 2023
bd693cf
add tests for sending cached events
marandaneto Sep 29, 2023
4ed5d73
add tests for feature flags
marandaneto Sep 29, 2023
65a36fc
create data class for decide api request
marandaneto Oct 1, 2023
5a8247f
add data class for decide api response
marandaneto Oct 1, 2023
d8b621f
ref serializer to use generics
marandaneto Oct 2, 2023
037e851
execute safely
marandaneto Oct 2, 2023
ff14687
add tests to Api
marandaneto Oct 2, 2023
568832e
ref mockHttp
marandaneto Oct 2, 2023
50badeb
documents apis
marandaneto Oct 2, 2023
3ad8677
add tests for the queue
marandaneto Oct 2, 2023
2161c35
reuse provider
marandaneto Oct 2, 2023
b73c4b3
add tests for capture method
marandaneto Oct 2, 2023
c52f885
add more tests
marandaneto Oct 2, 2023
039a275
add more tests
marandaneto Oct 2, 2023
5b61a77
ignore test
marandaneto Oct 2, 2023
ad304ae
add changelog entry
marandaneto Oct 2, 2023
d23802a
Update version
Oct 2, 2023
12ddcdc
add more tests
marandaneto Oct 2, 2023
b242e2c
add tests for legacy events
marandaneto Oct 3, 2023
569f782
review
marandaneto Oct 3, 2023
033ef96
fix comments
marandaneto Oct 3, 2023
85fa286
add usage
marandaneto Oct 3, 2023
f133403
fix usage and feature flags
marandaneto Oct 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions .buildscript/deploy_snapshot.sh

This file was deleted.

1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @marandaneto
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 🐞 Bug Report
description: Tell us about something that's not working the way we (probably) intend.
labels: ["Platform: Android", "bug"]
body:


- type: input
id: version
attributes:
label: Version
description: SDK Version
placeholder: 3.0.0 ← should look like this
validations:
required: true

- type: textarea
id: repro
attributes:
label: Steps to Reproduce
description: How can we see what you're seeing? Specific is terrific.
placeholder: |-
1. foo
2. bar
3. baz
validations:
required: true

- type: textarea
id: expected
attributes:
label: Expected Result
validations:
required: true

- type: textarea
id: actual
attributes:
label: Actual Result
description: Logs? Screenshots? Yes, please.
validations:
required: true
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Ask in the forums
url: https://posthog.com/questions
about: A place to ask questions.
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 💡 Feature Request
description: Tell us about a problem our SDK could solve but doesn't.
labels: ["enhacement"]
body:
- type: textarea
id: problem
attributes:
label: Problem Statement
description: What problem could we solve that it doesn't?
placeholder: |-
I want to make whirled peas, but it doesn't blend.
validations:
required: true

- type: textarea
id: expected
attributes:
label: Solution Brainstorm
description: We know you have bright ideas to share ... share away, friend.
placeholder: |-
Add a blender to it.
validations:
required: false
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/maintainer-blank.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Blank Issue
description: Blank Issue. Reserved for maintainers.
body:
- type: textarea
id: description
attributes:
label: Description
description: Please describe the issue.
validations:
required: true
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
15 changes: 15 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## :bulb: Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->


## :green_heart: How did you test it?


## :pencil: Checklist
<!--- Put an `x` in the boxes that apply -->

- [ ] I reviewed the submitted code.
- [ ] I added tests to verify the changes.
- [ ] I updated the docs if needed.
- [ ] No breaking change or entry added to the changelog.
27 changes: 0 additions & 27 deletions .github/workflows/android.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'Build & Test'
on:
push:
pull_request:

jobs:
cancel-previous-workflow:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # [email protected]
with:
access_token: ${{ github.token }}

build:
name: Build Job ${{ matrix.os }} - Java ${{ matrix.java }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
java: ['17']

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: 'Set up Java: ${{ matrix.java }}'
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Make compile
run: make compile

- name: Make stop
run: make stop
11 changes: 11 additions & 0 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Validate Gradle Wrapper'
on:
push:
pull_request:

jobs:
validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # [email protected]
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Release'
on:
release:
# runs for stable and pre-releases
types: [published]

jobs:
cancel-previous-workflow:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # [email protected]
with:
access_token: ${{ github.token }}

release:
name: Release Job ${{ matrix.os }} - Java ${{ matrix.java }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
java: ['17']
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

steps:
- name: Git checkout
uses: actions/checkout@v4

- name: 'Set up Java: ${{ matrix.java }}'
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'

- name: Update version
run: ./scripts/bump-version.sh ${{ github.event.release.tag_name }}

- name: Commit & push
run: |
echo "Tag name from github.ref_name: ${{ github.event.release.target_commitish }}"
./scripts/commit-code.sh ${{ github.event.release.target_commitish }}

# Let's be sure that everything works before we release
- name: Dry release
run: make dryRelease

- name: Release
run: make release
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,7 @@ build/
gradle-app.setting

# Jacoco
/posthog/jacoco.exec
/posthog/jacoco.exec

# eclipse
.project/
17 changes: 0 additions & 17 deletions .project

This file was deleted.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 3.0.0-alpha.3 - 2023-10-02

- Added many tests and fixed small issues

## 3.0.0-alpha.2 - 2023-09-27

- Fix permission check for Network status ([commit](https://github.com/PostHog/posthog-android/commit/57b9626a745a37a9c92437529ba9eaf308b03771))

## 3.0.0-alpha.1 - 2023-09-26

- Next major of the Android SDK rewritten in Kotlin
- Just testing the release automation

## 2.0.3 - 2023-01-30

- Feature flags will be sent with payloads by default for capture and screen events.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GitHub by forking the repository and opening a pull request against `master`.

When submitting code, please make every effort to follow existing conventions
and style in order to keep the code as readable as possible. Please also make
sure your code compiles by running `make build test`. In addition please consider adding
sure your code compiles by running `make compile`. In addition please consider adding
unit tests covering your change, this will make your change much more likely to be accepted

Above all, thank you for contributing!
6 changes: 2 additions & 4 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
The MIT License (MIT)
MIT License

Copyright (c) 2014 Segment.io, Inc.

Copyright (c) 2020 Hiberly Inc.
Copyright (c) [2023] [PostHog]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
46 changes: 46 additions & 0 deletions MIGRATION.md
marandaneto marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Migration from v2 to v3
============

## Setup v2

```kotlin
// app/build.gradle.kts
implementation("com.posthog.android:posthog:2.0.3")
```

```kotlin
import com.posthog.PostHog

val apiKey = "..."
val posthog = PostHog.Builder(applicationContext, apiKey)
.captureApplicationLifecycleEvents()
captureDeepLinks()
.recordScreenViews()
.build()
PostHog.setSingletonInstance(posthog)

PostHog.with(applicationContext).capture("event")
```

## Setup v3

```kotlin
// app/build.gradle.kts
implementation("com.posthog:posthog-android:3.0.0-alpha.1")
```

```kotlin
import com.posthog.PostHog
import com.posthog.android.PostHogAndroid
import com.posthog.android.PostHogAndroidConfig

val apiKey = "..."
val config = PostHogAndroidConfig(apiKey).apply {
captureApplicationLifecycleEvents = true
captureDeepLinks = true
captureScreenViews = true
}
PostHogAndroid.setup(applicationContext, config)

PostHog.capture("event")
```
Loading