Skip to content

Commit 78f9cfe

Browse files
committed
feat: Feature Experimentation capabilities for Go SDK
0 parents  commit 78f9cfe

File tree

160 files changed

+21118
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+21118
-0
lines changed

.github/workflows/main.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, github-action ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
if: "!contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
12+
name: Test on go ${{ matrix.go-version }} and ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os:
17+
- ubuntu-latest
18+
go-version: [ 1.16, 1.17, 1.18, 1.19, 1.21, 1.22, 1.23]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
- name: Run tests
26+
run: go test ./test/... -v
27+
- name: Upload coverage to Codecov
28+
run: |
29+
bash <(curl -s https://codecov.io/bash)
30+
- name: Notification
31+
if: always()
32+
id: slack
33+
uses: wingify/[email protected]
34+
with:
35+
channel-id: 'vwo-fs-fme-sdk-job-status'
36+
slack-message: "<!here> Go FME SDK Test on *Go-${{ matrix.go-version }}* and *${{ matrix.os }}* got *${{job.status}}* ${{job.status == 'success' && ':heavy_check_mark:' || ':x:'}} \nCommit: `${{github.event.head_commit.message}}`. \nCheck the latest build: https://github.com/wingify/vwo-fme-go-sdk/actions"
37+
color: "${{job.status == 'success' && '#00FF00' || '#FF0000'}}"
38+
env:
39+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}

.gitignore

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Dependency directories (remove the comment below to include it)
15+
# vendor/
16+
17+
# Go workspace file
18+
go.work
19+
20+
# IDE files
21+
.vscode/
22+
.idea/
23+
*.swp
24+
*.swo
25+
*~
26+
27+
# OS generated files
28+
.DS_Store
29+
.DS_Store?
30+
._*
31+
.Spotlight-V100
32+
.Trashes
33+
ehthumbs.db
34+
Thumbs.db
35+
36+
# Logs
37+
*.log
38+
39+
# Runtime data
40+
pids
41+
*.pid
42+
*.seed
43+
*.pid.lock
44+
45+
# Coverage directory used by tools like istanbul
46+
coverage/
47+
48+
# nyc test coverage
49+
.nyc_output
50+
51+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
52+
.grunt
53+
54+
# Bower dependency directory (https://bower.io/)
55+
bower_components
56+
57+
# node_modules
58+
node_modules/
59+
60+
# Optional npm cache directory
61+
.npm
62+
63+
# Optional REPL history
64+
.node_repl_history
65+
66+
# Output of 'npm pack'
67+
*.tgz
68+
69+
# Yarn Integrity file
70+
.yarn-integrity
71+
72+
# dotenv environment variables file
73+
.env
74+
75+
# Build output
76+
dist/
77+
build/
78+
79+
# Example directory
80+
example/

CHANGELOG.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.3.0] - 2024-11-06
9+
10+
### Added
11+
12+
- First release of VWO Feature Management and Experimentation capabilities
13+
14+
```go
15+
package main
16+
17+
import (
18+
"fmt"
19+
"log"
20+
21+
vwo "github.com/wingify/vwo-fme-go-sdk"
22+
)
23+
24+
func main() {
25+
// Initialize VWO SDK with your account details
26+
options := map[string]interface{}{
27+
"sdkKey": "32-alpha-numeric-sdk-key", // Replace with your SDK key
28+
"accountId": "123456", // Replace with your account ID
29+
}
30+
31+
// Initialize VWO instance
32+
vwoInstance, err := vwo.Init(options)
33+
if err != nil {
34+
log.Fatalf("Failed to initialize VWO client: %v", err)
35+
}
36+
37+
// Create user context
38+
context := map[string]interface{}{
39+
"id": "unique_user_id", // Set a unique user identifier
40+
}
41+
42+
// Check if a feature flag is enabled
43+
getFlag, err := vwoInstance.GetFlag("feature_key", context)
44+
if err != nil {
45+
log.Printf("Error getting feature flag: %v", err)
46+
} else {
47+
isFeatureEnabled := getFlag.IsEnabled()
48+
fmt.Println("Is feature enabled?", isFeatureEnabled)
49+
50+
// Get a variable value with a default fallback
51+
variableValue := getFlag.GetVariable("feature_variable", "default_value")
52+
fmt.Println("Variable value:", variableValue)
53+
}
54+
55+
// Track a custom event
56+
trackResponse, err := vwoInstance.TrackEvent("event_name", context)
57+
if err != nil {
58+
log.Printf("Error tracking event: %v", err)
59+
} else {
60+
fmt.Println("Event tracked:", trackResponse)
61+
}
62+
63+
// Set multiple custom attributes
64+
attributeMap := map[string]interface{}{
65+
"attribute-name": "attribute-value",
66+
}
67+
err = vwoInstance.SetAttribute(attributeMap, context)
68+
if err != nil {
69+
log.Printf("Error setting attributes: %v", err)
70+
}
71+
}
72+
```

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Contributing to VWO Feature Management and Experimentation SDK for Go
2+
3+
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4+
5+
- Reporting a bug
6+
- Discussing the current state of the code
7+
- Submitting a fix
8+
- Proposing new features
9+
10+
### We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
11+
12+
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
13+
14+
1. Fork the repo and create your branch from `master`.
15+
2. If you've added code that should be tested, add tests.
16+
3. Ensure the test suite passes.
17+
4. Make sure your code lints.
18+
5. Open a pull request!
19+
20+
### Any contributions you make will be under the Apache 2.0 Software License
21+
22+
When you submit code changes, your submissions are understood to be under the same [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) that covers the project. Feel free to contact the maintainers if that's a concern.
23+
24+
### Report bugs using GitHub issues
25+
26+
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/wingify/vwo-fme-go-sdk/issues); it's that easy!
27+
28+
**Note**: Write bug reports with detail, background, and sample code
29+
30+
**Great Bug Reports** tend to have:
31+
32+
- A quick summary and/or background
33+
- Steps to reproduce
34+
- Be specific!
35+
- Give sample code if you can.
36+
- What you expected would happen
37+
- What actually happens
38+
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
39+
40+
### License
41+
42+
By contributing, you agree that your contributions will be licensed under its Apache 2.0 License.

0 commit comments

Comments
 (0)