Skip to content

Commit 4f0f3e8

Browse files
committed
Initial commit (=analytics.js-integration-segmentio v1.0.7)
0 parents  commit 4f0f3e8

14 files changed

+1165
-0
lines changed

.eslintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "segment/browser",
3+
4+
"rules": {
5+
// FIXME: Refactor and remove this rule
6+
"consistent-return": 1,
7+
"global-strict": 0,
8+
"max-len": 0,
9+
"strict": 1
10+
},
11+
12+
"globals": {
13+
"exports": true,
14+
"module": true,
15+
"require": true
16+
}
17+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.log
2+
.DS_Store
3+
build.js
4+
components
5+
node_modules

Contributing.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing
2+
3+
We're huge fans of open-source, and we absolutely love getting good contributions to **analytics.js**! Integrations are available to thousands of Segment customers and we have hundreds of integrations in already in our queue, so it's important that you do the following _before writing a pull request_.
4+
5+
1. Read about our integration options and apply to be a partner: https://segment.com/partners/
6+
1. Hear from the Segment team before submitting your pull request.
7+
8+
## Getting Set Up
9+
10+
To start, we'll get you set up with our development environment. All of our development scripts and helpers are written in [node.js](http://nodejs.org), so you'll want to install that first by going to [nodejs.org](http://nodejs.org).
11+
12+
Then after forking **analytics.js-integrations** just `cd` into the folder and run `make`:
13+
14+
```bash
15+
$ cd analytics.js-integration-segmentio
16+
$ make
17+
```
18+
19+
That will install all of our [npm](http://npmjs.org) and [component](http://component.io) dependencies and compile the latest version of the development build to test against. You can now add your changes to the library, and run `make test` to make sure everything is passing still.
20+
21+
The commands you'll want to know for development are:
22+
23+
```bash
24+
$ make # re-compiles the development build of analytics.js for testing
25+
$ make test # runs all of the tests in your terminal
26+
$ make test-browser # runs all of the tests in your browser, for nicer debugging
27+
```
28+
29+
## Writing Tests
30+
31+
Every contribution should be accompanied by matching tests. If you look inside of the `test/` directory, you'll see we're pretty serious about this. That's because:
32+
33+
1. **analytics.js** runs on tons of different types of browsers, operating systems, etc. and we want to make sure it runs well everywhere.
34+
1. It lets us add new features much, much more quickly.
35+
1. We aren't insane.
36+
37+
When adding your own integration, the easiest way to figure out what major things to test is to look at everything you've added to the integration `prototype`. You'll want to write testing groups for `#initialize`, `#load`, `#identify`, `#track`, etc. And each group should test all of the expected functionality.
38+
39+
The most important thing to writing clean, easy-to-manage integrations is to **keep them small** and **clean up after each test**, so that the environment is never polluted by an individual test.
40+
41+
If you run into any questions, check out a few of our existing integrations to see how we've done it.
42+
43+
## Contributing Checklist
44+
45+
To help make contributing easy, here's all the things you need to remember:
46+
47+
- Add your integration file to `/lib`.
48+
- Create a new Integration constructor with the `integration` factory component.
49+
- Add your integration's default options with `.option()`.
50+
- Add an `initialize` method to your integration's `prototype`.
51+
- Add methods you want to support to the `prototype`. (`identify`, `track`, `pageview`, etc.)
52+
- Write tests for all of your integration's logic.
53+
- Run the tests and get everything passing.
54+
- Commit your changes with a nice commit message.
55+
- Submit your pull request.

History.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
1.0.7 / 2016-06-17
3+
==================
4+
5+
* add .context.amp and pull segment_amp_id
6+
7+
8+
1.0.6 / 2016-05-24
9+
==================
10+
11+
* fix this forsaken dependency hell
12+
* add traits to context
13+
14+
1.0.5 / 2016-05-07
15+
==================
16+
17+
* Bump Analytics.js core, tester, integration to use Facade 2.x
18+
19+
1.0.4 / 2015-09-15
20+
==================
21+
22+
* Update send-json dependency
23+
24+
1.0.3 / 2015-09-14
25+
==================
26+
27+
* increasing `messageId` randomness
28+
29+
1.0.2 / 2015-06-30
30+
==================
31+
32+
* Replace analytics.js dependency with analytics.js-core
33+
34+
1.0.1 / 2015-06-24
35+
==================
36+
37+
* Bump analytics.js-integration version
38+
39+
1.0.0 / 2015-06-09
40+
==================
41+
42+
* Initial commit :sparkles:

License.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2015 Segment.io <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+

Makefile

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#
2+
# Binaries.
3+
#
4+
5+
DUO = node_modules/.bin/duo
6+
DUOT = node_modules/.bin/duo-test
7+
ESLINT = node_modules/.bin/eslint
8+
9+
#
10+
# Files.
11+
#
12+
13+
SRCS_DIR = lib
14+
SRCS = $(shell find $(SRCS_DIR) -type f -name "*.js")
15+
TESTS_DIR = test
16+
TESTS = $(shell find $(TESTS_DIR) -type f -name '*.test.js')
17+
18+
#
19+
# Task config.
20+
#
21+
22+
BROWSER ?= chrome
23+
24+
PORT ?= 0
25+
26+
DUOT_ARGS = \
27+
--reporter spec \
28+
--port $(PORT) \
29+
--commands "make build"
30+
31+
#
32+
# Chore tasks.
33+
#
34+
35+
# Install node dependencies.
36+
node_modules: package.json $(wildcard node_modules/*/package.json)
37+
@npm install
38+
39+
# Remove temporary files and build artifacts.
40+
clean:
41+
rm -rf build.js
42+
.PHONY: clean
43+
44+
# Remove temporary files, build artifacts, and vendor dependencies.
45+
distclean: clean
46+
rm -rf components node_modules
47+
.PHONY: distclean
48+
49+
#
50+
# Build tasks.
51+
#
52+
53+
# Build all integrations, tests, and dependencies together for testing.
54+
build.js: node_modules component.json $(SRCS) $(TESTS)
55+
@$(DUO) --stdout --development $(TESTS) > $@
56+
57+
# Build shortcut.
58+
build: build.js
59+
.DEFAULT_GOAL = build
60+
61+
#
62+
# Test tasks.
63+
#
64+
65+
# Lint JavaScript source.
66+
lint: node_modules
67+
@$(ESLINT) $(SRCS) $(TESTS)
68+
.PHONY: lint
69+
70+
# Test locally in PhantomJS.
71+
test-phantomjs: node_modules build.js
72+
@$(DUOT) phantomjs $(TESTS_DIR) args: \
73+
--path node_modules/.bin/phantomjs
74+
.PHONY: test
75+
76+
# Test locally in the browser.
77+
test-browser: node_modules build.js
78+
@$(DUOT) browser --commands "make build" $(TESTS_DIR)
79+
.PHONY: test-browser
80+
81+
# Test in Sauce Labs. Note that you must set the SAUCE_USERNAME and
82+
# SAUCE_ACCESS_KEY environment variables using your Sauce Labs credentials.
83+
test-sauce: node_modules build.js
84+
@$(DUOT) saucelabs $(TESTS_DIR) \
85+
--name analytics.js-integrations \
86+
--browsers $(BROWSER) \
87+
--user $(SAUCE_USERNAME) \
88+
--key $(SAUCE_ACCESS_KEY)
89+
.PHONY: test-sauce
90+
91+
# Test shortcut.
92+
test: lint test-phantomjs
93+
.PHONY: test

Readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# analytics.js-integration-segmentio [![Build Status][ci-badge]][ci-link]
2+
3+
Segmentio integration for [Analytics.js][].
4+
5+
## License
6+
7+
Released under the [MIT license](License.md).
8+
9+
10+
[Analytics.js]: https://segment.com/docs/libraries/analytics.js/
11+
[ci-link]: https://circleci.com/gh/segment-integrations/analytics.js-integration-segmentio
12+
[ci-badge]: https://circleci.com/gh/segment-integrations/analytics.js-integration-segmentio.svg?style=svg

circle.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
machine:
2+
node:
3+
version: 0.12
4+
dependencies:
5+
pre:
6+
- echo "github.com,192.30.252.*,192.30.253.*,192.30.254.*,192.30.255.* ssh-rsa $(ssh-keyscan -t rsa github.com | cut -d ' ' -f 3-)" >> ~/.ssh/known_hosts
7+
- npm install -g npm@'>=2.7.0'
8+
- make
9+
test:
10+
override:
11+
- make test

component.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "analytics.js-integration-segmentio",
3+
"repo": "segment-integrations/analytics.js-integration-segmentio",
4+
"description": "The Segmentio analytics.js integration.",
5+
"version": "1.0.7",
6+
"license": "MIT",
7+
"main": "lib/index.js",
8+
"dependencies": {
9+
"component/clone": "0.1.0",
10+
"component/cookie": "1.1.1",
11+
"gjohnson/uuid": "0.0.1",
12+
"satazor/SparkMD5": "1.0.0",
13+
"segmentio/ad-params": "0.0.2",
14+
"segmentio/analytics.js-integration": "^1.1.0",
15+
"segmentio/extend": "0.0.1",
16+
"segmentio/json": "1.0.0",
17+
"segmentio/protocol": "0.0.2",
18+
"segmentio/top-domain": "1.0.0",
19+
"segmentio/utm-params": "1.0.2",
20+
"segmentio/send-json": "2.0.0",
21+
"yields/store": "1.0.2"
22+
},
23+
"development": {
24+
"segmentio/assert": "^0.5.4",
25+
"segmentio/type": "1.0.1",
26+
"segmentio/analytics.js-core": "^2.12.0",
27+
"segmentio/analytics.js-integration-tester": "^1.5.4",
28+
"segmentio/clear-env": "0.2.x",
29+
"segmentio/spy": "0.3.0"
30+
}
31+
}

0 commit comments

Comments
 (0)