-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Initial 1.0.0-SNAPSHOT release
- Loading branch information
Showing
21 changed files
with
1,093 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
[.editorconfig] | ||
ij_editorconfig_align_group_field_declarations = false | ||
ij_editorconfig_space_after_colon = false | ||
ij_editorconfig_space_after_comma = true | ||
ij_editorconfig_space_before_colon = false | ||
ij_editorconfig_space_before_comma = false | ||
ij_editorconfig_spaces_around_assignment_operators = true | ||
|
||
[{*.gradle.kts, *.kt, *.kts}] | ||
ij_kotlin_align_in_columns_case_branch = false | ||
ij_kotlin_align_multiline_binary_operation = false | ||
ij_kotlin_align_multiline_extends_list = false | ||
ij_kotlin_align_multiline_method_parentheses = false | ||
ij_kotlin_align_multiline_parameters = true | ||
ij_kotlin_align_multiline_parameters_in_calls = false | ||
ij_kotlin_allow_trailing_comma = false | ||
ij_kotlin_allow_trailing_comma_on_call_site = false | ||
ij_kotlin_assignment_wrap = off | ||
ij_kotlin_blank_lines_after_class_header = 0 | ||
ij_kotlin_blank_lines_around_block_when_branches = 0 | ||
ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1 | ||
ij_kotlin_block_comment_at_first_column = true | ||
ij_kotlin_call_parameters_new_line_after_left_paren = false | ||
ij_kotlin_call_parameters_right_paren_on_new_line = false | ||
ij_kotlin_call_parameters_wrap = off | ||
ij_kotlin_catch_on_new_line = false | ||
ij_kotlin_class_annotation_wrap = split_into_lines | ||
ij_kotlin_continuation_indent_for_chained_calls = true | ||
ij_kotlin_continuation_indent_for_expression_bodies = true | ||
ij_kotlin_continuation_indent_in_argument_lists = true | ||
ij_kotlin_continuation_indent_in_elvis = true | ||
ij_kotlin_continuation_indent_in_if_conditions = true | ||
ij_kotlin_continuation_indent_in_parameter_lists = true | ||
ij_kotlin_continuation_indent_in_supertype_lists = true | ||
ij_kotlin_else_on_new_line = false | ||
ij_kotlin_enum_constants_wrap = off | ||
ij_kotlin_extends_list_wrap = off | ||
ij_kotlin_field_annotation_wrap = split_into_lines | ||
ij_kotlin_finally_on_new_line = false | ||
ij_kotlin_if_rparen_on_new_line = false | ||
ij_kotlin_import_nested_classes = false | ||
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true | ||
ij_kotlin_keep_blank_lines_before_right_brace = 2 | ||
ij_kotlin_keep_blank_lines_in_code = 2 | ||
ij_kotlin_keep_blank_lines_in_declarations = 2 | ||
ij_kotlin_keep_first_column_comment = true | ||
ij_kotlin_keep_indents_on_empty_lines = false | ||
ij_kotlin_keep_line_breaks = true | ||
ij_kotlin_lbrace_on_next_line = false | ||
ij_kotlin_line_comment_add_space = false | ||
ij_kotlin_line_comment_at_first_column = true | ||
ij_kotlin_method_annotation_wrap = split_into_lines | ||
ij_kotlin_method_call_chain_wrap = off | ||
ij_kotlin_method_parameters_new_line_after_left_paren = false | ||
ij_kotlin_method_parameters_right_paren_on_new_line = false | ||
ij_kotlin_method_parameters_wrap = off | ||
ij_kotlin_parameter_annotation_wrap = off | ||
ij_kotlin_space_after_comma = true | ||
ij_kotlin_space_after_extend_colon = true | ||
ij_kotlin_space_after_type_colon = true | ||
ij_kotlin_space_before_catch_parentheses = true | ||
ij_kotlin_space_before_comma = false | ||
ij_kotlin_space_before_extend_colon = true | ||
ij_kotlin_space_before_for_parentheses = true | ||
ij_kotlin_space_before_if_parentheses = true | ||
ij_kotlin_space_before_lambda_arrow = true | ||
ij_kotlin_space_before_type_colon = false | ||
ij_kotlin_space_before_when_parentheses = true | ||
ij_kotlin_space_before_while_parentheses = true | ||
ij_kotlin_spaces_around_additive_operators = true | ||
ij_kotlin_spaces_around_assignment_operators = true | ||
ij_kotlin_spaces_around_equality_operators = true | ||
ij_kotlin_spaces_around_function_type_arrow = true | ||
ij_kotlin_spaces_around_logical_operators = true | ||
ij_kotlin_spaces_around_multiplicative_operators = true | ||
ij_kotlin_spaces_around_range = false | ||
ij_kotlin_spaces_around_relational_operators = true | ||
ij_kotlin_spaces_around_unary_operator = false | ||
ij_kotlin_spaces_around_when_arrow = true | ||
ij_kotlin_variable_annotation_wrap = off | ||
ij_kotlin_while_on_new_line = false | ||
ij_kotlin_wrap_elvis_expressions = 1 | ||
ij_kotlin_wrap_expression_body_functions = 0 | ||
ij_kotlin_wrap_first_method_in_call_chain = false | ||
ij_continuation_indent_size = 4 | ||
ij_kotlin_name_count_to_use_star_import = 1000 | ||
ij_kotlin_name_count_to_use_star_import_for_members = 1000 | ||
ij_kotlin_packages_to_use_import_on_demand = nothing | ||
ij_kotlin_imports_layout = * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
changelog: | ||
categories: | ||
- title: "✨ Features" | ||
labels: | ||
- "enhancement" | ||
- title: "🔧 Changes" | ||
labels: | ||
- "breaking" | ||
- title: "🐛 Fixes" | ||
labels: | ||
- "bug" | ||
- title: "📚 Documentation" | ||
labels: | ||
- "documentation" | ||
- title: "Other" | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: ["**"] | ||
tags-ignore: ["**"] | ||
pull_request: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Java JDK | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 21 | ||
distribution: temurin | ||
|
||
- name: Gradle Wrapper Validation | ||
uses: gradle/actions/wrapper-validation@v4 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v4 | ||
|
||
- name: Gradle Build | ||
run: ./gradlew build | ||
|
||
- name: Determine Status | ||
run: | | ||
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then | ||
echo "STATUS=snapshot" >> $GITHUB_ENV | ||
else | ||
echo "STATUS=release" >> $GITHUB_ENV | ||
fi | ||
- name: Publish Snapshot | ||
if: "${{ env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}" | ||
run: ./gradlew publish | ||
env: | ||
NOXCREW_MAVEN_PUBLIC_USERNAME: ${{ secrets.NOXCREW_MAVEN_PUBLIC_USERNAME }} | ||
NOXCREW_MAVEN_PUBLIC_PASSWORD: ${{ secrets.NOXCREW_MAVEN_PUBLIC_PASSWORD }} | ||
|
||
- name: Publish Release | ||
if: "${{ env.STATUS == 'release' && github.event_name == 'release' }}" | ||
run: ./gradlew publish | ||
env: | ||
NOXCREW_MAVEN_PUBLIC_USERNAME: ${{ secrets.NOXCREW_MAVEN_PUBLIC_USERNAME }} | ||
NOXCREW_MAVEN_PUBLIC_PASSWORD: ${{ secrets.NOXCREW_MAVEN_PUBLIC_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.gradle | ||
.idea | ||
**/build | ||
**/run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# SMP | ||
<img alt="GitHub License" src="https://img.shields.io/github/license/noxcrew/posthog-kotlin"> <img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/noxcrew/posthog-kotlin/build.yml"> <img alt="GitHub Release" src="https://img.shields.io/github/v/release/noxcrew/posthog-kotlin"> | ||
|
||
posthog-kotlin is a Kotlin library to interact with the PostHog API. | ||
|
||
## Features | ||
posthog-kotlin currently supports the following features: | ||
|
||
| Feature | Implemented | | ||
| --- | --— | | ||
| Single/Batch events | ✅ | | ||
| Identify | ✅ | | ||
|
||
## Usage | ||
### Dependency | ||
posthog-kotlin can be found on Noxcrew's public Maven repository and added to a Gradle project as follows: | ||
|
||
```kotlin | ||
repositories { | ||
maven { | ||
name = "noxcrew" | ||
url = uri("https://maven.noxcrew.com/public") | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("com.noxcrew.posthog-kotlin:posthog-kotlin:VERSION") | ||
} | ||
``` | ||
|
||
### Example | ||
Some simple examples of how to use the library can be seen below. | ||
For further examples, see the test files. | ||
|
||
```kotlin | ||
// Create your PostHog instance (do this once, centrally). | ||
val postHog = PostHog( | ||
hostname = "https://eu.i.posthog.com", | ||
apiKey = "<your_api_key_here>", | ||
// See docs for more settings you can change here. | ||
... | ||
) | ||
|
||
// PostHog events have properties that can be constructed using the PostHogProperties class. | ||
val properties = PostHogProperties.fromMap( | ||
mapOf( | ||
"some_key" to "my_value", | ||
"data_here" to "cool_setting", | ||
) | ||
) | ||
|
||
// Events can be added to the queue using your PostHog instance from earlier. | ||
postHog.capture( | ||
userId = "kezz", | ||
eventName = "made a cool library", | ||
properties = properties, | ||
) | ||
|
||
// You can also identify users. | ||
postHog.identify( | ||
userId = "kezz", | ||
properties = properties, | ||
) | ||
|
||
// When you are finished with your application, close the PostHog instance to flush the queue. | ||
postHog.close() | ||
``` | ||
|
||
## Documentation | ||
Documentation for how to use the library can be found on the library's entrypoint, the `PostHog` interface. | ||
Javadocs/Dokka docs are also provided. | ||
|
||
## Issues and Feature Requests | ||
Should you encounter any issues while using posthog-kotlin, please create an [issue,](https://github.com/Noxcrew/posthog-kotlin/issues/new) and we will get back to you as soon as possible. | ||
For questions and feedback, please use the [discussions tab](https://github.com/Noxcrew/posthog-kotlin/discussions) or the [#api-chat](https://discord.com/channels/707193125478596668/1134515300742733985) channel in the [MCC Discord](https://discord.gg/mcc). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode | ||
|
||
plugins { | ||
alias(libs.plugins.kotlin.jvm) | ||
alias(libs.plugins.kotlinx.serialization) | ||
alias(libs.plugins.spotless) | ||
|
||
`java-library` | ||
`maven-publish` | ||
} | ||
|
||
group = "com.noxcrew.posthog-kotlin" | ||
version = "1.0.0-SNAPSHOT" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
api(libs.kotlinx.coroutines) | ||
api(libs.okhttp) | ||
|
||
implementation(libs.kotlinx.serialization.json) | ||
implementation(libs.slf4j.api) | ||
} | ||
|
||
kotlin { | ||
explicitApi = ExplicitApiMode.Strict | ||
jvmToolchain(21) | ||
} | ||
|
||
spotless { | ||
spotless { | ||
kotlin { | ||
ktlint() | ||
} | ||
|
||
kotlinGradle { | ||
ktlint() | ||
} | ||
} | ||
} | ||
|
||
java { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "noxcrew-public" | ||
url = uri("https://maven.noxcrew.com/public") | ||
|
||
credentials { | ||
username = System.getenv("NOXCREW_MAVEN_PUBLIC_USERNAME") | ||
password = System.getenv("NOXCREW_MAVEN_PUBLIC_PASSWORD") | ||
} | ||
|
||
authentication { | ||
create<BasicAuthentication>("basic") | ||
} | ||
} | ||
} | ||
|
||
publications { | ||
create<MavenPublication>("maven") { | ||
from(components["java"]) | ||
|
||
pom { | ||
name = "smp" | ||
description = "A PostHog library for Kotlin." | ||
url = "https://github.com/Noxcrew/posthog-kotlin" | ||
|
||
scm { | ||
url = "https://github.com/Noxcrew/posthog-kotlin" | ||
connection = "scm:git:https://github.com/Noxcrew/posthog-kotlin.git" | ||
developerConnection = "scm:git:https://github.com/Noxcrew/posthog-kotlin.git" | ||
} | ||
|
||
licenses { | ||
license { | ||
name = "MIT License" | ||
url = "https://opensource.org/licenses/MIT" | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
id = "noxcrew" | ||
name = "Noxcrew" | ||
email = "[email protected]" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
kotlin.code.style=official |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[versions] | ||
kotlin = "1.9.24" | ||
|
||
[libraries] | ||
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.8.1" } | ||
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version = "1.6.3" } | ||
okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version = "4.12.0" } | ||
slf4j-api = { group = "org.slf4j", name = "slf4j-api", version = "2.0.16" } | ||
|
||
[plugins] | ||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } | ||
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } | ||
spotless = { id = "com.diffplug.spotless", version = "6.25.0" } |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.